From 89690140c79dcbd8466ebd1c637f474670e3a7ce Mon Sep 17 00:00:00 2001 From: Bjoseph Wombat Date: Tue, 3 Mar 2015 18:04:05 +0000 Subject: Better MediaConnect handling of 1026 return status, media already connected. --- indra/newview/llvoicevivox.cpp | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'indra') diff --git a/indra/newview/llvoicevivox.cpp b/indra/newview/llvoicevivox.cpp index a6a7a35b03..ac264d395f 100755 --- a/indra/newview/llvoicevivox.cpp +++ b/indra/newview/llvoicevivox.cpp @@ -95,7 +95,7 @@ const int MAX_LOGIN_RETRIES = 12; // to voice server (EXT-4313). When voice works correctly, there is from 1 to 15 times. 50 was chosen // to make sure we don't make mistake when slight connection problems happen- situation when connection to server is // blocked is VERY rare and it's better to sacrifice response time in this situation for the sake of stability. -const int MAX_NORMAL_JOINING_SPATIAL_NUM = 50; +const int MAX_NORMAL_JOINING_SPATIAL_NUM = 150; // How often to check for expired voice fonts in seconds const F32 VOICE_FONT_EXPIRY_INTERVAL = 10.f; @@ -1512,7 +1512,7 @@ void LLVivoxVoiceClient::stateMachine() //MARK: stateLeavingSession case stateLeavingSession: // waiting for terminate session response // The handler for the Session.Terminate response will transition from here to stateSessionTerminated. - break; + //break; // brett, should fall through and clean up session before getting terminated event. //MARK: stateSessionTerminated case stateSessionTerminated: @@ -1522,6 +1522,7 @@ void LLVivoxVoiceClient::stateMachine() if(mAudioSession) { + leaveAudioSession(); sessionState *oldSession = mAudioSession; mAudioSession = NULL; @@ -1881,6 +1882,7 @@ void LLVivoxVoiceClient::leaveAudioSession() case stateJoiningSession: case stateSessionJoined: case stateRunning: + case stateSessionTerminated: if(!mAudioSession->mHandle.empty()) { @@ -2813,15 +2815,24 @@ void LLVivoxVoiceClient::sessionGroupAddSessionResponse(std::string &requestId, void LLVivoxVoiceClient::sessionConnectResponse(std::string &requestId, int statusCode, std::string &statusString) { sessionState *session = findSession(requestId); - if(statusCode != 0) + // 1026 is session already has media, somehow mediaconnect was called twice on the same session. + // set the session info to reflect that the user is already connected. + if (statusCode == 1026){ + session->mVoiceEnabled = true; + session->mMediaConnectInProgress = false; + session->mMediaStreamState = streamStateConnected; + session->mTextStreamState = streamStateConnected; + session->mErrorStatusCode = 0; + } + else if (statusCode != 0) { LL_WARNS("Voice") << "Session.Connect response failure (" << statusCode << "): " << statusString << LL_ENDL; - if(session) + if (session) { session->mMediaConnectInProgress = false; - session->mErrorStatusCode = statusCode; + session->mErrorStatusCode = statusCode; session->mErrorStatusString = statusString; - if(session == mAudioSession) + if (session == mAudioSession) setState(stateJoinSessionFailed); } } @@ -4611,6 +4622,11 @@ void LLVivoxVoiceClient::enforceTether(void) void LLVivoxVoiceClient::updatePosition(void) { + // Throttle the position updates to one every 1/10 of a second if we are in an audio session at all + if (mAudioSession == NULL) { + return; + } + LLViewerRegion *region = gAgent.getRegion(); if(region && isAgentAvatarValid()) { -- cgit v1.2.3 From 98f98e03bdbfb8a9a9dd1004e15c589c3cfe7ccd Mon Sep 17 00:00:00 2001 From: Bjoseph Wombat Date: Fri, 6 Mar 2015 22:14:26 +0000 Subject: More voice related changes to improve the user's experience. --- indra/newview/llimview.cpp | 12 +++---- indra/newview/llvoiceclient.cpp | 14 ++++---- indra/newview/llvoiceclient.h | 4 +-- indra/newview/llvoicevivox.cpp | 71 +++++++++++++++++++++++++---------------- indra/newview/llvoicevivox.h | 12 ++++--- 5 files changed, 65 insertions(+), 48 deletions(-) (limited to 'indra') diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp index 8d8239611c..96d8762c56 100755 --- a/indra/newview/llimview.cpp +++ b/indra/newview/llimview.cpp @@ -1262,12 +1262,12 @@ void LLIMModel::sendMessage(const std::string& utf8_text, info = LLAvatarTracker::instance().getBuddyInfo(other_participant_id); U8 offline = (!info || info->isOnline()) ? IM_ONLINE : IM_OFFLINE; - - if((offline == IM_OFFLINE) && (LLVoiceClient::getInstance()->isOnlineSIP(other_participant_id))) - { - // User is online through the OOW connector, but not with a regular viewer. Try to send the message via SLVoice. - sent = LLVoiceClient::getInstance()->sendTextMessage(other_participant_id, utf8_text); - } + // Old call to send messages to SLim client, no longer supported. + //if((offline == IM_OFFLINE) && (LLVoiceClient::getInstance()->isOnlineSIP(other_participant_id))) + //{ + // // User is online through the OOW connector, but not with a regular viewer. Try to send the message via SLVoice. + // sent = LLVoiceClient::getInstance()->sendTextMessage(other_participant_id, utf8_text); + //} if(!sent) { diff --git a/indra/newview/llvoiceclient.cpp b/indra/newview/llvoiceclient.cpp index 962cdf0268..6df1bda135 100755 --- a/indra/newview/llvoiceclient.cpp +++ b/indra/newview/llvoiceclient.cpp @@ -363,6 +363,7 @@ BOOL LLVoiceClient::isSessionCallBackPossible(const LLUUID& id) } } +/* obsolete BOOL LLVoiceClient::sendTextMessage(const LLUUID& participant_id, const std::string& message) { if (mVoiceModule) @@ -374,12 +375,13 @@ BOOL LLVoiceClient::sendTextMessage(const LLUUID& participant_id, const std::str return FALSE; } } +*/ void LLVoiceClient::endUserIMSession(const LLUUID& participant_id) { if (mVoiceModule) { - mVoiceModule->endUserIMSession(participant_id); + // mVoiceModule->endUserIMSession(participant_id); // A SLim leftover } } @@ -645,9 +647,8 @@ void LLVoiceClient::keyDown(KEY key, MASK mask) if(!mPTTIsMiddleMouse && LLAgent::isActionAllowed("speak")) { - bool down = (mPTTKey != KEY_NONE) - && gKeyboard->getKeyDown(mPTTKey); - inputUserControlState(down); + bool down = (mPTTKey != KEY_NONE) && gKeyboard->getKeyDown(mPTTKey); + if (down) { inputUserControlState(down); } } } @@ -655,9 +656,8 @@ void LLVoiceClient::keyUp(KEY key, MASK mask) { if(!mPTTIsMiddleMouse) { - bool down = (mPTTKey != KEY_NONE) - && gKeyboard->getKeyDown(mPTTKey); - inputUserControlState(down); + bool down = (mPTTKey != KEY_NONE) && gKeyboard->getKeyDown(mPTTKey); + if (down) { inputUserControlState(down); } } } void LLVoiceClient::middleMouseState(bool down) diff --git a/indra/newview/llvoiceclient.h b/indra/newview/llvoiceclient.h index fb387301be..4c6ff5ef8f 100755 --- a/indra/newview/llvoiceclient.h +++ b/indra/newview/llvoiceclient.h @@ -214,7 +214,7 @@ public: //@{ virtual BOOL isSessionTextIMPossible(const LLUUID& id)=0; virtual BOOL isSessionCallBackPossible(const LLUUID& id)=0; - virtual BOOL sendTextMessage(const LLUUID& participant_id, const std::string& message)=0; + //virtual BOOL sendTextMessage(const LLUUID& participant_id, const std::string& message)=0; virtual void endUserIMSession(const LLUUID &uuid)=0; //@} @@ -431,7 +431,7 @@ public: //@{ BOOL isSessionTextIMPossible(const LLUUID& id); BOOL isSessionCallBackPossible(const LLUUID& id); - BOOL sendTextMessage(const LLUUID& participant_id, const std::string& message); + //BOOL sendTextMessage(const LLUUID& participant_id, const std::string& message) const {return true;} ; void endUserIMSession(const LLUUID &uuid); //@} diff --git a/indra/newview/llvoicevivox.cpp b/indra/newview/llvoicevivox.cpp index ac264d395f..68aacb5090 100755 --- a/indra/newview/llvoicevivox.cpp +++ b/indra/newview/llvoicevivox.cpp @@ -95,7 +95,7 @@ const int MAX_LOGIN_RETRIES = 12; // to voice server (EXT-4313). When voice works correctly, there is from 1 to 15 times. 50 was chosen // to make sure we don't make mistake when slight connection problems happen- situation when connection to server is // blocked is VERY rare and it's better to sacrifice response time in this situation for the sake of stability. -const int MAX_NORMAL_JOINING_SPATIAL_NUM = 150; +const int MAX_NORMAL_JOINING_SPATIAL_NUM = 1500; // How often to check for expired voice fonts in seconds const F32 VOICE_FONT_EXPIRY_INTERVAL = 10.f; @@ -450,17 +450,20 @@ bool LLVivoxVoiceClient::writeString(const std::string &str) (const char*)str.data(), &written); - if(err == 0) + if(err == 0 && written == size) { // Success. result = true; } - // TODO: handle partial writes (written is number of bytes written) - // Need to set socket to non-blocking before this will work. -// else if(APR_STATUS_IS_EAGAIN(err)) -// { -// // -// } + else if (err == 0 && written != size) { + // Did a short write, log it for now + LL_WARNS("Voice") << ") short write on socket sending data to vivox daemon." << "Sent " << written << "bytes instead of " << size < 100) + LL_WARNS() << "There seems to be problem with connecting to a voice channel. Frames to join were " << mSpatialJoiningNum << LL_ENDL; mSpatialJoiningNum = 0; // It appears that I need to wait for BOTH the SessionGroup.AddSession response and the SessionStateChangeEvent with state 4 @@ -1512,7 +1517,7 @@ void LLVivoxVoiceClient::stateMachine() //MARK: stateLeavingSession case stateLeavingSession: // waiting for terminate session response // The handler for the Session.Terminate response will transition from here to stateSessionTerminated. - //break; // brett, should fall through and clean up session before getting terminated event. + //break; // Fall through and clean up session before getting terminated event. //MARK: stateSessionTerminated case stateSessionTerminated: @@ -1681,7 +1686,8 @@ void LLVivoxVoiceClient::loginSendMessage() << "" << mAccountName << "" << "" << mAccountPassword << "" << "VerifyAnswer" - << "false" + << "false" + << "0" << "Application" << "5" << (autoPostCrashDumps?"true":"") @@ -1913,10 +1919,12 @@ void LLVivoxVoiceClient::leaveAudioSession() case stateJoinSessionFailed: case stateJoinSessionFailedWaiting: setState(stateSessionTerminated); + break; + case stateLeavingSession: // managed to get back to this case statement before the media gets disconnected. break; default: - LL_WARNS("Voice") << "called from unknown state" << LL_ENDL; + LL_WARNS("Voice") << "called from unknown state " << getState() << LL_ENDL; break; } } @@ -1969,6 +1977,7 @@ void LLVivoxVoiceClient::sessionMediaDisconnectSendMessage(sessionState *session } +/* obsolete void LLVivoxVoiceClient::sessionTextDisconnectSendMessage(sessionState *session) { std::ostringstream stream; @@ -1982,6 +1991,7 @@ void LLVivoxVoiceClient::sessionTextDisconnectSendMessage(sessionState *session) writeString(stream.str()); } +*/ void LLVivoxVoiceClient::getCaptureDevicesSendMessage() { @@ -2821,7 +2831,7 @@ void LLVivoxVoiceClient::sessionConnectResponse(std::string &requestId, int stat session->mVoiceEnabled = true; session->mMediaConnectInProgress = false; session->mMediaStreamState = streamStateConnected; - session->mTextStreamState = streamStateConnected; + //session->mTextStreamState = streamStateConnected; session->mErrorStatusCode = 0; } else if (statusCode != 0) @@ -3028,7 +3038,7 @@ void LLVivoxVoiceClient::sessionRemovedEvent( // Reset the media state (we now have no info) session->mMediaStreamState = streamStateUnknown; - session->mTextStreamState = streamStateUnknown; + //session->mTextStreamState = streamStateUnknown; // Conditionally delete the session reapSession(session); @@ -3239,8 +3249,9 @@ void LLVivoxVoiceClient::mediaStreamUpdatedEvent( switch(state) { - case streamStateIdle: - // Standard "left audio session" + case streamStateDisconnecting: + case streamStateIdle: + // Standard "left audio session", Vivox state 'disconnected' session->mVoiceEnabled = false; session->mMediaConnectInProgress = false; leftAudioSession(session); @@ -3250,6 +3261,7 @@ void LLVivoxVoiceClient::mediaStreamUpdatedEvent( session->mVoiceEnabled = true; session->mMediaConnectInProgress = false; joinedAudioSession(session); + case streamStateConnecting: // do nothing, but prevents a warning getting into the logs. break; case streamStateRinging: @@ -3284,6 +3296,7 @@ void LLVivoxVoiceClient::mediaStreamUpdatedEvent( } } +/* Obsolete void LLVivoxVoiceClient::textStreamUpdatedEvent( std::string &sessionHandle, std::string &sessionGroupHandle, @@ -3330,6 +3343,7 @@ void LLVivoxVoiceClient::textStreamUpdatedEvent( } } } + obsolete */ void LLVivoxVoiceClient::participantAddedEvent( std::string &sessionHandle, @@ -4196,7 +4210,7 @@ LLVivoxVoiceClient::sessionState* LLVivoxVoiceClient::startUserIMSession(const L if(session->mHandle.empty()) { // Session isn't active -- start it up. - sessionCreateSendMessage(session, false, true); + sessionCreateSendMessage(session, false, false); } else { @@ -4207,6 +4221,7 @@ LLVivoxVoiceClient::sessionState* LLVivoxVoiceClient::startUserIMSession(const L return session; } +/* obsolete BOOL LLVivoxVoiceClient::sendTextMessage(const LLUUID& participant_id, const std::string& message) { bool result = false; @@ -4231,7 +4246,8 @@ BOOL LLVivoxVoiceClient::sendTextMessage(const LLUUID& participant_id, const std return result; } - +*/ +/* obsolete void LLVivoxVoiceClient::sendQueuedTextMessages(sessionState *session) { if(session->mTextStreamState == 1) @@ -4260,6 +4276,7 @@ void LLVivoxVoiceClient::sendQueuedTextMessages(sessionState *session) // Session isn't connected yet, defer until later. } } + obsolete */ void LLVivoxVoiceClient::endUserIMSession(const LLUUID &uuid) { @@ -4270,7 +4287,7 @@ void LLVivoxVoiceClient::endUserIMSession(const LLUUID &uuid) // found the session if(!session->mHandle.empty()) { - sessionTextDisconnectSendMessage(session); + // sessionTextDisconnectSendMessage(session); // a SLim leftover, not used any more. } } else @@ -6835,6 +6852,10 @@ void LLVivoxProtocolParser::processResponse(std::string tag) { LLVivoxVoiceClient::getInstance()->sessionRemovedEvent(sessionHandle, sessionGroupHandle); } + else if (!stricmp(eventTypeCstr, "SessionGroupUpdatedEvent")) + { + //TODO, we don't process this event, but we should not WARN that we have received it. + } else if (!stricmp(eventTypeCstr, "SessionGroupAddedEvent")) { LLVivoxVoiceClient::getInstance()->sessionGroupAddedEvent(sessionGroupHandle); @@ -6863,19 +6884,13 @@ void LLVivoxProtocolParser::processResponse(std::string tag) */ LLVivoxVoiceClient::getInstance()->mediaCompletionEvent(sessionGroupHandle, mediaCompletionType); } + /* obsolete, let else statement complain if a text message arrives else if (!stricmp(eventTypeCstr, "TextStreamUpdatedEvent")) { - /* - - c1_m1000xFnPP04IpREWNkuw1cOXlhw==_sg1 - c1_m1000xFnPP04IpREWNkuw1cOXlhw==1 - true - 1 - true - - */ + LLVivoxVoiceClient::getInstance()->textStreamUpdatedEvent(sessionHandle, sessionGroupHandle, enabled, state, incoming); - } + + } */ else if (!stricmp(eventTypeCstr, "ParticipantAddedEvent")) { /* diff --git a/indra/newview/llvoicevivox.h b/indra/newview/llvoicevivox.h index a4ec9f2a69..541cccd30f 100755 --- a/indra/newview/llvoicevivox.h +++ b/indra/newview/llvoicevivox.h @@ -109,7 +109,7 @@ public: virtual bool isParticipant(const LLUUID& speaker_id); // Send a text message to the specified user, initiating the session if necessary. - virtual BOOL sendTextMessage(const LLUUID& participant_id, const std::string& message); + // virtual BOOL sendTextMessage(const LLUUID& participant_id, const std::string& message) const {return false;}; // close any existing text IM session with the specified user virtual void endUserIMSession(const LLUUID &uuid); @@ -261,6 +261,8 @@ protected: streamStateIdle = 1, streamStateConnected = 2, streamStateRinging = 3, + streamStateConnecting = 6, // same as Vivox session_media_connecting enum + streamStateDisconnecting = 7, //Same as Vivox session_media_disconnecting enum }; struct participantState { @@ -325,7 +327,7 @@ protected: LLUUID mCallerID; int mErrorStatusCode; int mMediaStreamState; - int mTextStreamState; + int mTextStreamState; // obsolete bool mCreateInProgress; // True if a Session.Create has been sent for this session and no response has been received yet. bool mMediaConnectInProgress; // True if a Session.MediaConnect has been sent for this session and no response has been received yet. bool mVoiceInvitePending; // True if a voice invite is pending for this session (usually waiting on a name lookup) @@ -480,7 +482,7 @@ protected: void accountLoginStateChangeEvent(std::string &accountHandle, int statusCode, std::string &statusString, int state); void mediaCompletionEvent(std::string &sessionGroupHandle, std::string &mediaCompletionType); void mediaStreamUpdatedEvent(std::string &sessionHandle, std::string &sessionGroupHandle, int statusCode, std::string &statusString, int state, bool incoming); - void textStreamUpdatedEvent(std::string &sessionHandle, std::string &sessionGroupHandle, bool enabled, int state, bool incoming); + //obsolete void textStreamUpdatedEvent(std::string &sessionHandle, std::string &sessionGroupHandle, bool enabled, int state, bool incoming); void sessionAddedEvent(std::string &uriString, std::string &alias, std::string &sessionHandle, std::string &sessionGroupHandle, bool isChannel, bool incoming, std::string &nameString, std::string &applicationString); void sessionGroupAddedEvent(std::string &sessionGroupHandle); void sessionRemovedEvent(std::string &sessionHandle, std::string &sessionGroupHandle); @@ -596,7 +598,7 @@ protected: void sessionTerminateSendMessage(sessionState *session); void sessionGroupTerminateSendMessage(sessionState *session); void sessionMediaDisconnectSendMessage(sessionState *session); - void sessionTextDisconnectSendMessage(sessionState *session); + // void sessionTextDisconnectSendMessage(sessionState *session); @@ -760,7 +762,7 @@ private: // start a text IM session with the specified user // This will be asynchronous, the session may be established at a future time. sessionState* startUserIMSession(const LLUUID& uuid); - void sendQueuedTextMessages(sessionState *session); + // obsolete void sendQueuedTextMessages(sessionState *session); void enforceTether(void); -- cgit v1.2.3 From 4941749bb4d3b66f55c9c61d7e18305d92ec6986 Mon Sep 17 00:00:00 2001 From: Bjoseph Wombat Date: Tue, 10 Mar 2015 14:21:41 +0100 Subject: Added the loop back setting so people can hear themselves during the mic test. --- indra/newview/llvoicevivox.cpp | 11 +++++++---- indra/newview/skins/default/xui/en/panel_sound_devices.xml | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'indra') diff --git a/indra/newview/llvoicevivox.cpp b/indra/newview/llvoicevivox.cpp index 68aacb5090..99190e9919 100755 --- a/indra/newview/llvoicevivox.cpp +++ b/indra/newview/llvoicevivox.cpp @@ -972,8 +972,8 @@ void LLVivoxVoiceClient::stateMachine() } else { - // duration parameter is currently unused, per Mike S. - tuningCaptureStartSendMessage(10000); + // loop mic back to render device. + tuningCaptureStartSendMessage(1); // 1-loop, zero, don't loop setState(stateMicTuningRunning); } @@ -2143,14 +2143,15 @@ void LLVivoxVoiceClient::tuningRenderStopSendMessage() writeString(stream.str()); } -void LLVivoxVoiceClient::tuningCaptureStartSendMessage(int duration) +void LLVivoxVoiceClient::tuningCaptureStartSendMessage(int loop) { LL_DEBUGS("Voice") << "sending CaptureAudioStart" << LL_ENDL; std::ostringstream stream; stream << "" - << "" << duration << "" + << "-1" + << "" << loop << "" << "\n\n\n"; writeString(stream.str()); @@ -2372,6 +2373,8 @@ void LLVivoxVoiceClient::sendPositionalUpdate(void) { std::ostringstream stream; + if (getState() != stateRunning) return; // don't send position updates if we are transitioning between out of running. + if(mSpatialCoordsDirty) { LLVector3 l, u, a, vel; diff --git a/indra/newview/skins/default/xui/en/panel_sound_devices.xml b/indra/newview/skins/default/xui/en/panel_sound_devices.xml index 46cbc1e87f..3dbb7fb7fc 100755 --- a/indra/newview/skins/default/xui/en/panel_sound_devices.xml +++ b/indra/newview/skins/default/xui/en/panel_sound_devices.xml @@ -98,7 +98,7 @@ name="My volume label" top_pad="14" width="200"> - My volume: + Mic volume: Date: Mon, 16 Mar 2015 17:14:34 -0700 Subject: Removal of RPCXML dep on LLCurl switching to LLCore::Html --- indra/llcorehttp/_httpoprequest.cpp | 95 +++- indra/llcorehttp/_httpoprequest.h | 11 +- indra/llcorehttp/_httppolicyglobal.cpp | 30 ++ indra/llcorehttp/_httppolicyglobal.h | 3 + indra/llcorehttp/_httpservice.cpp | 80 ++- indra/llcorehttp/_httpservice.h | 9 +- indra/llcorehttp/_refcounted.h | 11 + indra/llcorehttp/bufferarray.h | 2 + indra/llcorehttp/httpcommon.cpp | 24 +- indra/llcorehttp/httpcommon.h | 116 ++++- indra/llcorehttp/httphandler.h | 4 +- indra/llcorehttp/httpheaders.h | 1 + indra/llcorehttp/httpoptions.cpp | 39 +- indra/llcorehttp/httpoptions.h | 31 ++ indra/llcorehttp/httprequest.cpp | 17 +- indra/llcorehttp/httprequest.h | 17 +- indra/llcorehttp/httpresponse.h | 25 + indra/llmessage/llcurl.cpp | 854 ++++++++++++++++---------------- indra/llmessage/llcurl.h | 9 +- indra/llmessage/llhttpclient.cpp | 49 ++ indra/llmessage/llhttpclientadapter.cpp | 90 ++-- indra/llmessage/llhttpclientadapter.h | 2 + indra/llmessage/llhttpclientinterface.h | 16 +- indra/llmessage/llsdrpcclient.h | 8 +- indra/newview/llappcorehttp.cpp | 69 +++ indra/newview/llappcorehttp.h | 4 +- indra/newview/llhttpretrypolicy.cpp | 2 +- indra/newview/llvoavatarself.cpp | 1 - indra/newview/llxmlrpctransaction.cpp | 497 +++++++++---------- indra/newview/llxmlrpctransaction.h | 4 +- 30 files changed, 1280 insertions(+), 840 deletions(-) (limited to 'indra') diff --git a/indra/llcorehttp/_httpoprequest.cpp b/indra/llcorehttp/_httpoprequest.cpp index b9632a7921..48e22468cd 100755 --- a/indra/llcorehttp/_httpoprequest.cpp +++ b/indra/llcorehttp/_httpoprequest.cpp @@ -115,8 +115,9 @@ namespace LLCore { -HttpOpRequest::HttpOpRequest() +HttpOpRequest::HttpOpRequest(HttpRequest const * const request) : HttpOperation(), + mRequest(request), mProcFlags(0U), mReqMethod(HOR_GET), mReqBody(NULL), @@ -139,7 +140,8 @@ HttpOpRequest::HttpOpRequest() mPolicyRetries(0), mPolicy503Retries(0), mPolicyRetryAt(HttpTime(0)), - mPolicyRetryLimit(HTTP_RETRY_COUNT_DEFAULT) + mPolicyRetryLimit(HTTP_RETRY_COUNT_DEFAULT), + mCallbackSSLVerify(NULL) { // *NOTE: As members are added, retry initialization/cleanup // may need to be extended in @see prepareRequest(). @@ -267,6 +269,14 @@ void HttpOpRequest::visitNotifier(HttpRequest * request) response->setContentType(mReplyConType); response->setRetries(mPolicyRetries, mPolicy503Retries); + HttpResponse::TransferStats::ptr_t stats = HttpResponse::TransferStats::ptr_t(new HttpResponse::TransferStats); + + curl_easy_getinfo(mCurlHandle, CURLINFO_SIZE_DOWNLOAD, &stats->mSizeDownload); + curl_easy_getinfo(mCurlHandle, CURLINFO_TOTAL_TIME, &stats->mTotalTime); + curl_easy_getinfo(mCurlHandle, CURLINFO_SPEED_DOWNLOAD, &stats->mSpeedDownload); + + response->setTransferStats(stats); + mUserHandler->onCompleted(static_cast(this), response); response->release(); @@ -452,18 +462,8 @@ HttpStatus HttpOpRequest::prepareRequest(HttpService * service) code = curl_easy_setopt(mCurlHandle, CURLOPT_ENCODING, ""); check_curl_easy_code(code, CURLOPT_ENCODING); - // The Linksys WRT54G V5 router has an issue with frequent - // DNS lookups from LAN machines. If they happen too often, - // like for every HTTP request, the router gets annoyed after - // about 700 or so requests and starts issuing TCP RSTs to - // new connections. Reuse the DNS lookups for even a few - // seconds and no RSTs. - code = curl_easy_setopt(mCurlHandle, CURLOPT_DNS_CACHE_TIMEOUT, 15); - check_curl_easy_code(code, CURLOPT_DNS_CACHE_TIMEOUT); code = curl_easy_setopt(mCurlHandle, CURLOPT_AUTOREFERER, 1); check_curl_easy_code(code, CURLOPT_AUTOREFERER); - code = curl_easy_setopt(mCurlHandle, CURLOPT_FOLLOWLOCATION, 1); - check_curl_easy_code(code, CURLOPT_FOLLOWLOCATION); code = curl_easy_setopt(mCurlHandle, CURLOPT_MAXREDIRS, HTTP_REDIRECTS_DEFAULT); check_curl_easy_code(code, CURLOPT_MAXREDIRS); code = curl_easy_setopt(mCurlHandle, CURLOPT_WRITEFUNCTION, writeCallback); @@ -474,11 +474,49 @@ HttpStatus HttpOpRequest::prepareRequest(HttpService * service) check_curl_easy_code(code, CURLOPT_READFUNCTION); code = curl_easy_setopt(mCurlHandle, CURLOPT_READDATA, this); check_curl_easy_code(code, CURLOPT_READDATA); - code = curl_easy_setopt(mCurlHandle, CURLOPT_SSL_VERIFYPEER, 1); + + code = curl_easy_setopt(mCurlHandle, CURLOPT_COOKIEFILE, ""); + check_curl_easy_code(code, CURLOPT_COOKIEFILE); + + if (gpolicy.mSslCtxCallback) + { + code = curl_easy_setopt(mCurlHandle, CURLOPT_SSL_CTX_FUNCTION, curlSslCtxCallback); + check_curl_easy_code(code, CURLOPT_SSL_CTX_FUNCTION); + code = curl_easy_setopt(mCurlHandle, CURLOPT_SSL_CTX_DATA, this); + check_curl_easy_code(code, CURLOPT_SSL_CTX_DATA); + mCallbackSSLVerify = gpolicy.mSslCtxCallback; + } + + long follow_redirect(1L); + long sslPeerV(0L); + long sslHostV(0L); + long dnsCacheTimeout(15L); + + if (mReqOptions) + { + follow_redirect = mReqOptions->getFollowRedirects() ? 1L : 0L; + sslPeerV = mReqOptions->getSSLVerifyHost() ? 0L : 1L; + sslHostV = mReqOptions->getSSLVerifyHost(); + dnsCacheTimeout = mReqOptions->getDNSCacheTimeout(); + } + code = curl_easy_setopt(mCurlHandle, CURLOPT_FOLLOWLOCATION, follow_redirect); + check_curl_easy_code(code, CURLOPT_FOLLOWLOCATION); + + code = curl_easy_setopt(mCurlHandle, CURLOPT_SSL_VERIFYPEER, sslPeerV); check_curl_easy_code(code, CURLOPT_SSL_VERIFYPEER); - code = curl_easy_setopt(mCurlHandle, CURLOPT_SSL_VERIFYHOST, 0); + code = curl_easy_setopt(mCurlHandle, CURLOPT_SSL_VERIFYHOST, sslHostV); check_curl_easy_code(code, CURLOPT_SSL_VERIFYHOST); + // The Linksys WRT54G V5 router has an issue with frequent + // DNS lookups from LAN machines. If they happen too often, + // like for every HTTP request, the router gets annoyed after + // about 700 or so requests and starts issuing TCP RSTs to + // new connections. Reuse the DNS lookups for even a few + // seconds and no RSTs. + code = curl_easy_setopt(mCurlHandle, CURLOPT_DNS_CACHE_TIMEOUT, dnsCacheTimeout); + check_curl_easy_code(code, CURLOPT_DNS_CACHE_TIMEOUT); + + if (gpolicy.mUseLLProxy) { // Use the viewer-based thread-safe API which has a @@ -873,6 +911,35 @@ size_t HttpOpRequest::headerCallback(void * data, size_t size, size_t nmemb, voi } +CURLcode HttpOpRequest::curlSslCtxCallback(CURL *curl, void *sslctx, void *userdata) +{ + HttpOpRequest * op(static_cast(userdata)); + + if (op->mCallbackSSLVerify) + { + SSL_CTX * ctx = (SSL_CTX *)sslctx; + // disable any default verification for server certs + SSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, NULL); + // set the verification callback. + SSL_CTX_set_cert_verify_callback(ctx, sslCertVerifyCallback, userdata); + // the calls are void + } + + return CURLE_OK; +} + +int HttpOpRequest::sslCertVerifyCallback(X509_STORE_CTX *ctx, void *param) +{ + HttpOpRequest * op(static_cast(param)); + + if (op->mCallbackSSLVerify) + { + op->mStatus = op->mCallbackSSLVerify(op->mReqURL, op->mUserHandler, ctx); + } + + return (op->mStatus) ? 1 : 0; +} + int HttpOpRequest::debugCallback(CURL * handle, curl_infotype info, char * buffer, size_t len, void * userdata) { HttpOpRequest * op(static_cast(userdata)); diff --git a/indra/llcorehttp/_httpoprequest.h b/indra/llcorehttp/_httpoprequest.h index 2f628b5aba..7a4b7c189e 100755 --- a/indra/llcorehttp/_httpoprequest.h +++ b/indra/llcorehttp/_httpoprequest.h @@ -33,6 +33,9 @@ #include #include +#include +#include + #include "httpcommon.h" #include "httprequest.h" #include "_httpoperation.h" @@ -63,7 +66,7 @@ class HttpOptions; class HttpOpRequest : public HttpOperation { public: - HttpOpRequest(); + HttpOpRequest(HttpRequest const * const request); protected: virtual ~HttpOpRequest(); // Use release() @@ -151,6 +154,9 @@ protected: static size_t writeCallback(void * data, size_t size, size_t nmemb, void * userdata); static size_t readCallback(void * data, size_t size, size_t nmemb, void * userdata); static size_t headerCallback(void * data, size_t size, size_t nmemb, void * userdata); + static CURLcode curlSslCtxCallback(CURL *curl, void *ssl_ctx, void *userptr); + static int sslCertVerifyCallback(X509_STORE_CTX *ctx, void *param); + static int debugCallback(CURL *, curl_infotype info, char * buffer, size_t len, void * userdata); protected: @@ -159,8 +165,11 @@ protected: static const unsigned int PF_SAVE_HEADERS = 0x00000002U; static const unsigned int PF_USE_RETRY_AFTER = 0x00000004U; + HttpRequest::policyCallback mCallbackSSLVerify; + public: // Request data + HttpRequest const * const mRequest; EMethod mReqMethod; std::string mReqURL; BufferArray * mReqBody; diff --git a/indra/llcorehttp/_httppolicyglobal.cpp b/indra/llcorehttp/_httppolicyglobal.cpp index 1dc95f3dce..c4ef38a815 100755 --- a/indra/llcorehttp/_httppolicyglobal.cpp +++ b/indra/llcorehttp/_httppolicyglobal.cpp @@ -106,6 +106,20 @@ HttpStatus HttpPolicyGlobal::set(HttpRequest::EPolicyOption opt, const std::stri return HttpStatus(); } +HttpStatus HttpPolicyGlobal::set(HttpRequest::EPolicyOption opt, HttpRequest::policyCallback value) +{ + switch (opt) + { + case HttpRequest::PO_SSL_VERIFY_CALLBACK: + mSslCtxCallback = value; + break; + + default: + return HttpStatus(HttpStatus::LLCORE, HE_INVALID_ARG); + } + + return HttpStatus(); +} HttpStatus HttpPolicyGlobal::get(HttpRequest::EPolicyOption opt, long * value) const { @@ -154,4 +168,20 @@ HttpStatus HttpPolicyGlobal::get(HttpRequest::EPolicyOption opt, std::string * v return HttpStatus(); } + +HttpStatus HttpPolicyGlobal::get(HttpRequest::EPolicyOption opt, HttpRequest::policyCallback * value) const +{ + switch (opt) + { + case HttpRequest::PO_SSL_VERIFY_CALLBACK: + *value = mSslCtxCallback; + break; + + default: + return HttpStatus(HttpStatus::LLCORE, HE_INVALID_ARG); + } + + return HttpStatus(); +} + } // end namespace LLCore diff --git a/indra/llcorehttp/_httppolicyglobal.h b/indra/llcorehttp/_httppolicyglobal.h index 67c4ba9481..1696238814 100755 --- a/indra/llcorehttp/_httppolicyglobal.h +++ b/indra/llcorehttp/_httppolicyglobal.h @@ -60,8 +60,10 @@ private: public: HttpStatus set(HttpRequest::EPolicyOption opt, long value); HttpStatus set(HttpRequest::EPolicyOption opt, const std::string & value); + HttpStatus set(HttpRequest::EPolicyOption opt, HttpRequest::policyCallback value); HttpStatus get(HttpRequest::EPolicyOption opt, long * value) const; HttpStatus get(HttpRequest::EPolicyOption opt, std::string * value) const; + HttpStatus get(HttpRequest::EPolicyOption opt, HttpRequest::policyCallback * value) const; public: long mConnectionLimit; @@ -70,6 +72,7 @@ public: std::string mHttpProxy; long mTrace; long mUseLLProxy; + HttpRequest::policyCallback mSslCtxCallback; }; // end class HttpPolicyGlobal } // end namespace LLCore diff --git a/indra/llcorehttp/_httpservice.cpp b/indra/llcorehttp/_httpservice.cpp index c673e1be1d..7b8aac35a8 100755 --- a/indra/llcorehttp/_httpservice.cpp +++ b/indra/llcorehttp/_httpservice.cpp @@ -53,15 +53,16 @@ namespace LLCore const HttpService::OptionDescriptor HttpService::sOptionDesc[] = { // isLong isDynamic isGlobal isClass - { true, true, true, true }, // PO_CONNECTION_LIMIT - { true, true, false, true }, // PO_PER_HOST_CONNECTION_LIMIT - { false, false, true, false }, // PO_CA_PATH - { false, false, true, false }, // PO_CA_FILE - { false, true, true, false }, // PO_HTTP_PROXY - { true, true, true, false }, // PO_LLPROXY - { true, true, true, false }, // PO_TRACE - { true, true, false, true }, // PO_ENABLE_PIPELINING - { true, true, false, true } // PO_THROTTLE_RATE + { true, true, true, true, false }, // PO_CONNECTION_LIMIT + { true, true, false, true, false }, // PO_PER_HOST_CONNECTION_LIMIT + { false, false, true, false, false }, // PO_CA_PATH + { false, false, true, false, false }, // PO_CA_FILE + { false, true, true, false, false }, // PO_HTTP_PROXY + { true, true, true, false, false }, // PO_LLPROXY + { true, true, true, false, false }, // PO_TRACE + { true, true, false, true, false }, // PO_ENABLE_PIPELINING + { true, true, false, true, false }, // PO_THROTTLE_RATE + { false, false, true, false, true } // PO_SSL_VERIFY_CALLBACK }; HttpService * HttpService::sInstance(NULL); volatile HttpService::EState HttpService::sState(NOT_INITIALIZED); @@ -413,6 +414,34 @@ HttpStatus HttpService::getPolicyOption(HttpRequest::EPolicyOption opt, HttpRequ return status; } +HttpStatus HttpService::getPolicyOption(HttpRequest::EPolicyOption opt, HttpRequest::policy_t pclass, + HttpRequest::policyCallback * ret_value) +{ + HttpStatus status(HttpStatus::LLCORE, LLCore::HE_INVALID_ARG); + + if (opt < HttpRequest::PO_CONNECTION_LIMIT // option must be in range + || opt >= HttpRequest::PO_LAST // ditto + || (sOptionDesc[opt].mIsLong) // datatype is string + || (pclass != HttpRequest::GLOBAL_POLICY_ID && pclass > mLastPolicy) // pclass in valid range + || (pclass == HttpRequest::GLOBAL_POLICY_ID && !sOptionDesc[opt].mIsGlobal) // global setting permitted + || (pclass != HttpRequest::GLOBAL_POLICY_ID && !sOptionDesc[opt].mIsClass)) // class setting permitted + // can always get, no dynamic check + { + return status; + } + + // Only global has callback values + if (pclass == HttpRequest::GLOBAL_POLICY_ID) + { + HttpPolicyGlobal & opts(mPolicy->getGlobalOptions()); + + status = opts.get(opt, ret_value); + } + + return status; +} + + HttpStatus HttpService::setPolicyOption(HttpRequest::EPolicyOption opt, HttpRequest::policy_t pclass, long value, long * ret_value) @@ -489,6 +518,37 @@ HttpStatus HttpService::setPolicyOption(HttpRequest::EPolicyOption opt, HttpRequ return status; } - + +HttpStatus HttpService::setPolicyOption(HttpRequest::EPolicyOption opt, HttpRequest::policy_t pclass, + HttpRequest::policyCallback value, HttpRequest::policyCallback * ret_value) +{ + HttpStatus status(HttpStatus::LLCORE, LLCore::HE_INVALID_ARG); + + if (opt < HttpRequest::PO_CONNECTION_LIMIT // option must be in range + || opt >= HttpRequest::PO_LAST // ditto + || (sOptionDesc[opt].mIsLong) // datatype is string + || (pclass != HttpRequest::GLOBAL_POLICY_ID && pclass > mLastPolicy) // pclass in valid range + || (pclass == HttpRequest::GLOBAL_POLICY_ID && !sOptionDesc[opt].mIsGlobal) // global setting permitted + || (pclass != HttpRequest::GLOBAL_POLICY_ID && !sOptionDesc[opt].mIsClass) // class setting permitted + || (RUNNING == sState && !sOptionDesc[opt].mIsDynamic)) // dynamic setting permitted + { + return status; + } + + // Callbacks values are always global (at this time). + if (pclass == HttpRequest::GLOBAL_POLICY_ID) + { + HttpPolicyGlobal & opts(mPolicy->getGlobalOptions()); + + status = opts.set(opt, value); + if (status && ret_value) + { + status = opts.get(opt, ret_value); + } + } + + return status; +} + } // end namespace LLCore diff --git a/indra/llcorehttp/_httpservice.h b/indra/llcorehttp/_httpservice.h index cf23f3ab61..699a8eaa4f 100755 --- a/indra/llcorehttp/_httpservice.h +++ b/indra/llcorehttp/_httpservice.h @@ -201,17 +201,24 @@ protected: bool mIsDynamic; bool mIsGlobal; bool mIsClass; + bool mIsCallback; }; HttpStatus getPolicyOption(HttpRequest::EPolicyOption opt, HttpRequest::policy_t, long * ret_value); HttpStatus getPolicyOption(HttpRequest::EPolicyOption opt, HttpRequest::policy_t, std::string * ret_value); + HttpStatus getPolicyOption(HttpRequest::EPolicyOption opt, HttpRequest::policy_t, + HttpRequest::policyCallback * ret_value); + HttpStatus setPolicyOption(HttpRequest::EPolicyOption opt, HttpRequest::policy_t, long value, long * ret_value); HttpStatus setPolicyOption(HttpRequest::EPolicyOption opt, HttpRequest::policy_t, const std::string & value, std::string * ret_value); - + HttpStatus setPolicyOption(HttpRequest::EPolicyOption opt, HttpRequest::policy_t, + HttpRequest::policyCallback value, + HttpRequest::policyCallback * ret_value); + protected: static const OptionDescriptor sOptionDesc[HttpRequest::PO_LAST]; static HttpService * sInstance; diff --git a/indra/llcorehttp/_refcounted.h b/indra/llcorehttp/_refcounted.h index 402e725152..cd16e2e2b4 100755 --- a/indra/llcorehttp/_refcounted.h +++ b/indra/llcorehttp/_refcounted.h @@ -120,7 +120,18 @@ inline void RefCounted::destroySelf() delete this; } +inline void intrusive_ptr_add_ref(RefCounted* p) +{ + p->addRef(); +} + +inline void intrusive_ptr_release(RefCounted* p) +{ + p->release(); +} + } // end namespace LLCoreInt + #endif // LLCOREINT__REFCOUNTED_H_ diff --git a/indra/llcorehttp/bufferarray.h b/indra/llcorehttp/bufferarray.h index 1094a435b4..9c2b991de6 100755 --- a/indra/llcorehttp/bufferarray.h +++ b/indra/llcorehttp/bufferarray.h @@ -73,6 +73,8 @@ public: BufferArray(); + typedef boost::intrusive_ptr ptr_t; + protected: virtual ~BufferArray(); // Use release() diff --git a/indra/llcorehttp/httpcommon.cpp b/indra/llcorehttp/httpcommon.cpp index 7907e958a4..1aece696e3 100755 --- a/indra/llcorehttp/httpcommon.cpp +++ b/indra/llcorehttp/httpcommon.cpp @@ -42,7 +42,7 @@ HttpStatus::operator unsigned long() const { static const int shift(sizeof(unsigned long) * 4); - unsigned long result(((unsigned long) mType) << shift | (unsigned long) (int) mStatus); + unsigned long result(((unsigned long)mDetails->mType) << shift | (unsigned long)(int)mDetails->mStatus); return result; } @@ -131,18 +131,18 @@ std::string HttpStatus::toString() const { return std::string(""); } - switch (mType) + switch (mDetails->mType) { case EXT_CURL_EASY: - return std::string(curl_easy_strerror(CURLcode(mStatus))); + return std::string(curl_easy_strerror(CURLcode(mDetails->mStatus))); case EXT_CURL_MULTI: - return std::string(curl_multi_strerror(CURLMcode(mStatus))); + return std::string(curl_multi_strerror(CURLMcode(mDetails->mStatus))); case LLCORE: - if (mStatus >= 0 && mStatus < llcore_errors_count) + if (mDetails->mStatus >= 0 && mDetails->mStatus < llcore_errors_count) { - return std::string(llcore_errors[mStatus]); + return std::string(llcore_errors[mDetails->mStatus]); } break; @@ -154,7 +154,7 @@ std::string HttpStatus::toString() const while (true) { int at((bottom + top) / 2); - if (mType == http_errors[at].mCode) + if (mDetails->mType == http_errors[at].mCode) { return std::string(http_errors[at].mText); } @@ -162,7 +162,7 @@ std::string HttpStatus::toString() const { break; } - else if (mType < http_errors[at].mCode) + else if (mDetails->mType < http_errors[at].mCode) { top = at; } @@ -182,9 +182,9 @@ std::string HttpStatus::toTerseString() const { std::ostringstream result; - unsigned int error_value((unsigned short) mStatus); + unsigned int error_value((unsigned short)mDetails->mStatus); - switch (mType) + switch (mDetails->mType) { case EXT_CURL_EASY: result << "Easy_"; @@ -202,7 +202,7 @@ std::string HttpStatus::toTerseString() const if (isHttpStatus()) { result << "Http_"; - error_value = mType; + error_value = mDetails->mType; } else { @@ -244,7 +244,7 @@ bool HttpStatus::isRetryable() const // Disable the '*this == inv_status' test and look for 'Core_9' // failures in log files. - return ((isHttpStatus() && mType >= 499 && mType <= 599) || // Include special 499 in retryables + return ((isHttpStatus() && mDetails->mType >= 499 && mDetails->mType <= 599) || // Include special 499 in retryables *this == cant_connect || // Connection reset/endpoint problems *this == cant_res_proxy || // DNS problems *this == cant_res_host || // DNS problems diff --git a/indra/llcorehttp/httpcommon.h b/indra/llcorehttp/httpcommon.h index 9601f94125..0244755272 100755 --- a/indra/llcorehttp/httpcommon.h +++ b/indra/llcorehttp/httpcommon.h @@ -191,7 +191,6 @@ #include - namespace LLCore { @@ -292,35 +291,35 @@ struct HttpStatus typedef unsigned short type_enum_t; HttpStatus() - : mType(LLCORE), - mStatus(HE_SUCCESS) - {} + { + mDetails = std::unique_ptr
(new Details(LLCORE, HE_SUCCESS)); + } HttpStatus(type_enum_t type, short status) - : mType(type), - mStatus(status) - {} + { + mDetails = std::unique_ptr
(new Details(type, status)); + } HttpStatus(int http_status) - : mType(http_status), - mStatus(http_status >= 200 && http_status <= 299 - ? HE_SUCCESS - : HE_REPLY_ERROR) { + mDetails = std::unique_ptr
(new Details(http_status, + (http_status >= 200 && http_status <= 299) ? HE_SUCCESS : HE_REPLY_ERROR)); llassert(http_status >= 100 && http_status <= 999); } HttpStatus(const HttpStatus & rhs) - : mType(rhs.mType), - mStatus(rhs.mStatus) - {} + { + mDetails = std::unique_ptr
(new Details(*rhs.mDetails)); + } HttpStatus & operator=(const HttpStatus & rhs) { // Don't care if lhs & rhs are the same object + mDetails->mType = rhs.mDetails->mType; + mDetails->mStatus = rhs.mDetails->mStatus; + mDetails->mMessage = rhs.mDetails->mMessage; + mDetails->mErrorData = rhs.mDetails->mErrorData; - mType = rhs.mType; - mStatus = rhs.mStatus; return *this; } @@ -328,10 +327,6 @@ struct HttpStatus static const type_enum_t EXT_CURL_MULTI = 1; ///< mStatus is an error from a curl_multi_*() call static const type_enum_t LLCORE = 2; ///< mStatus is an HE_* error code ///< 100-999 directly represent HTTP status codes - - type_enum_t mType; - short mStatus; - /// Test for successful status in the code regardless /// of error source (internal, libcurl). /// @@ -339,7 +334,7 @@ struct HttpStatus /// operator bool() const { - return 0 == mStatus; + return 0 == mDetails->mStatus; } /// Inverse of previous operator. @@ -347,14 +342,15 @@ struct HttpStatus /// @return 'true' on any error condition bool operator !() const { - return 0 != mStatus; + return 0 != mDetails->mStatus; } /// Equality and inequality tests to bypass bool conversion /// which will do the wrong thing in conditional expressions. bool operator==(const HttpStatus & rhs) const { - return mType == rhs.mType && mStatus == rhs.mStatus; + return (mDetails->mType == rhs.mDetails->mType) && + (mDetails->mStatus == rhs.mDetails->mStatus); } bool operator!=(const HttpStatus & rhs) const @@ -395,7 +391,7 @@ struct HttpStatus /// HTTP response status (100 - 999). bool isHttpStatus() const { - return mType >= type_enum_t(100) && mType <= type_enum_t(999); + return mDetails->mType >= type_enum_t(100) && mDetails->mType <= type_enum_t(999); } /// Returns true if the status is one that will be retried @@ -403,7 +399,77 @@ struct HttpStatus /// where that logic needs to be replicated. Only applies /// to failed statuses, successful statuses will return false. bool isRetryable() const; - + + /// Returns the currently set status code as a raw number + /// + short getStatus() const + { + return mDetails->mStatus; + } + + /// Returns the currently set status type + /// + type_enum_t getType() const + { + return mDetails->mType; + } + + // TODO: There must be a better way to do this. Don't want to set these + // values here since they increase the size of a structure that is already + // being passed on the stack. Consider my options + /// Returns an optional error message if one has been set. + /// + std::string getMessage() const + { + return mDetails->mMessage; + } + + /// Sets an optional error message + /// + void setMessage(const std::string &message) + { + mDetails->mMessage = message; + } + + /// Retrieves an optionally recorded SSL certificate. + void * getErrorData() const + { + return mDetails->mErrorData; + } + + /// Optionally sets an SSL certificate on this status. + void setErrorData(void *data) + { + mDetails->mErrorData = data; + } + +private: + + struct Details + { + Details(type_enum_t type, short status): + mType(type), + mStatus(status), + mMessage(), + mErrorData(NULL) + {} + + Details(const Details &rhs) : + mType(rhs.mType), + mStatus(rhs.mStatus), + mMessage(rhs.mMessage), + mErrorData(rhs.mErrorData) + {} + + + type_enum_t mType; + short mStatus; + std::string mMessage; + void * mErrorData; + }; + + std::unique_ptr
mDetails; + }; // end struct HttpStatus } // end namespace LLCore diff --git a/indra/llcorehttp/httphandler.h b/indra/llcorehttp/httphandler.h index 9171e4e7b9..740e986dec 100755 --- a/indra/llcorehttp/httphandler.h +++ b/indra/llcorehttp/httphandler.h @@ -45,7 +45,7 @@ class HttpResponse; /// be shared by any number of requests and across instances /// of HttpRequest running in the same thread. /// -/// Threading: HttpHandler itself is pure interface and is +/// Threading: HttpHandler itself is interface and is /// tread-compatible. Most derivations, however, will have /// different constraints. /// @@ -58,7 +58,7 @@ class HttpHandler { public: virtual ~HttpHandler() - {} + { } /// Method invoked during calls to @see update(). Each invocation /// represents the completion of some requested operation. Caller diff --git a/indra/llcorehttp/httpheaders.h b/indra/llcorehttp/httpheaders.h index f70cd898f3..c89d6af222 100755 --- a/indra/llcorehttp/httpheaders.h +++ b/indra/llcorehttp/httpheaders.h @@ -92,6 +92,7 @@ public: /// the instance. HttpHeaders(); + typedef boost::intrusive_ptr ptr_t; protected: virtual ~HttpHeaders(); // Use release() diff --git a/indra/llcorehttp/httpoptions.cpp b/indra/llcorehttp/httpoptions.cpp index 5bf1ecb4a5..28c2c25e92 100755 --- a/indra/llcorehttp/httpoptions.cpp +++ b/indra/llcorehttp/httpoptions.cpp @@ -25,7 +25,7 @@ */ #include "httpoptions.h" - +#include "lldefs.h" #include "_httpinternal.h" @@ -33,14 +33,17 @@ namespace LLCore { -HttpOptions::HttpOptions() - : RefCounted(true), - mWantHeaders(false), - mTracing(HTTP_TRACE_OFF), - mTimeout(HTTP_REQUEST_TIMEOUT_DEFAULT), - mTransferTimeout(HTTP_REQUEST_XFER_TIMEOUT_DEFAULT), - mRetries(HTTP_RETRY_COUNT_DEFAULT), - mUseRetryAfter(HTTP_USE_RETRY_AFTER_DEFAULT) +HttpOptions::HttpOptions() : RefCounted(true), + mWantHeaders(false), + mTracing(HTTP_TRACE_OFF), + mTimeout(HTTP_REQUEST_TIMEOUT_DEFAULT), + mTransferTimeout(HTTP_REQUEST_XFER_TIMEOUT_DEFAULT), + mRetries(HTTP_RETRY_COUNT_DEFAULT), + mUseRetryAfter(HTTP_USE_RETRY_AFTER_DEFAULT), + mFollowRedirects(false), + mVerifyPeer(false), + mVerifyHost(0), + mDNSCacheTimeout(15) {} @@ -82,5 +85,23 @@ void HttpOptions::setUseRetryAfter(bool use_retry) mUseRetryAfter = use_retry; } +void HttpOptions::setFollowRedirects(bool follow_redirect) +{ + mFollowRedirects = follow_redirect; +} + +void HttpOptions::setSSLVerifyPeer(bool verify) +{ + mVerifyPeer = verify; +} +void HttpOptions::setSSLVerifyHost(unsigned int type) +{ + mVerifyHost = llclamp(type, 0, 2); +} + +void HttpOptions::setDNSCacheTimeout(int timeout) +{ + mDNSCacheTimeout = timeout; +} } // end namespace LLCore diff --git a/indra/llcorehttp/httpoptions.h b/indra/llcorehttp/httpoptions.h index 4ab5ff18c4..d6d892213d 100755 --- a/indra/llcorehttp/httpoptions.h +++ b/indra/llcorehttp/httpoptions.h @@ -61,6 +61,8 @@ class HttpOptions : public LLCoreInt::RefCounted public: HttpOptions(); + typedef boost::intrusive_ptr ptr_t; + protected: virtual ~HttpOptions(); // Use release() @@ -109,6 +111,31 @@ public: { return mUseRetryAfter; } + + // Default: false + void setFollowRedirects(bool follow_redirect); + bool getFollowRedirects() const + { + return mFollowRedirects; + } + + void setSSLVerifyPeer(bool verify); + bool getSSLVerifyPeer() const + { + return mVerifyPeer; + } + + void setSSLVerifyHost(unsigned int type); + unsigned int getSSLVerifyHost() const + { + return mVerifyHost; + } + + void setDNSCacheTimeout(int timeout); + int getDNSCacheTimeout() const + { + return mDNSCacheTimeout; + } protected: bool mWantHeaders; @@ -117,6 +144,10 @@ protected: unsigned int mTransferTimeout; unsigned int mRetries; bool mUseRetryAfter; + bool mFollowRedirects; + bool mVerifyPeer; + unsigned int mVerifyHost; + int mDNSCacheTimeout; }; // end class HttpOptions diff --git a/indra/llcorehttp/httprequest.cpp b/indra/llcorehttp/httprequest.cpp index 7b1888e3eb..5f1ed3d43b 100755 --- a/indra/llcorehttp/httprequest.cpp +++ b/indra/llcorehttp/httprequest.cpp @@ -117,6 +117,15 @@ HttpStatus HttpRequest::setStaticPolicyOption(EPolicyOption opt, policy_t pclass return HttpService::instanceOf()->setPolicyOption(opt, pclass, value, ret_value); } +HttpStatus HttpRequest::setStaticPolicyOption(EPolicyOption opt, policy_t pclass, policyCallback value, policyCallback * ret_value) +{ + if (HttpService::RUNNING == HttpService::instanceOf()->getState()) + { + return HttpStatus(HttpStatus::LLCORE, HE_OPT_NOT_DYNAMIC); + } + + return HttpService::instanceOf()->setPolicyOption(opt, pclass, value, ret_value); +} HttpHandle HttpRequest::setPolicyOption(EPolicyOption opt, policy_t pclass, long value, HttpHandler * handler) @@ -195,7 +204,7 @@ HttpHandle HttpRequest::requestGet(policy_t policy_id, HttpStatus status; HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); - HttpOpRequest * op = new HttpOpRequest(); + HttpOpRequest * op = new HttpOpRequest(this); if (! (status = op->setupGet(policy_id, priority, url, options, headers))) { op->release(); @@ -229,7 +238,7 @@ HttpHandle HttpRequest::requestGetByteRange(policy_t policy_id, HttpStatus status; HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); - HttpOpRequest * op = new HttpOpRequest(); + HttpOpRequest * op = new HttpOpRequest(this); if (! (status = op->setupGetByteRange(policy_id, priority, url, offset, len, options, headers))) { op->release(); @@ -262,7 +271,7 @@ HttpHandle HttpRequest::requestPost(policy_t policy_id, HttpStatus status; HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); - HttpOpRequest * op = new HttpOpRequest(); + HttpOpRequest * op = new HttpOpRequest(this); if (! (status = op->setupPost(policy_id, priority, url, body, options, headers))) { op->release(); @@ -295,7 +304,7 @@ HttpHandle HttpRequest::requestPut(policy_t policy_id, HttpStatus status; HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); - HttpOpRequest * op = new HttpOpRequest(); + HttpOpRequest * op = new HttpOpRequest(this); if (! (status = op->setupPut(policy_id, priority, url, body, options, headers))) { op->release(); diff --git a/indra/llcorehttp/httprequest.h b/indra/llcorehttp/httprequest.h index 7f23723b0b..c90e056d62 100755 --- a/indra/llcorehttp/httprequest.h +++ b/indra/llcorehttp/httprequest.h @@ -97,6 +97,7 @@ public: typedef unsigned int policy_t; typedef unsigned int priority_t; + typedef std::shared_ptr ptr_t; public: /// @name PolicyMethods /// @{ @@ -163,7 +164,7 @@ public: /// Long value that if non-zero enables the use of the /// traditional LLProxy code for http/socks5 support. If - // enabled, has priority over GP_HTTP_PROXY. + /// enabled, has priority over GP_HTTP_PROXY. /// /// Global only PO_LLPROXY, @@ -219,15 +220,25 @@ public: /// Controls whether client-side throttling should be /// performed on this policy class. Positive values /// enable throttling and specify the request rate - /// (requests per second) that should be targetted. + /// (requests per second) that should be targeted. /// A value of zero, the default, specifies no throttling. /// /// Per-class only PO_THROTTLE_RATE, + /// Controls the callback function used to control SSL CTX + /// certificate verification. + /// + /// Global only + PO_SSL_VERIFY_CALLBACK, + PO_LAST // Always at end }; + /// Prototype for policy based callbacks. The callback methods will be executed + /// on the worker thread so no modifications should be made to the HttpHandler object. + typedef HttpStatus(*policyCallback)(const std::string &, HttpHandler const * const, void *); + /// Set a policy option for a global or class parameter at /// startup time (prior to thread start). /// @@ -243,6 +254,8 @@ public: long value, long * ret_value); static HttpStatus setStaticPolicyOption(EPolicyOption opt, policy_t pclass, const std::string & value, std::string * ret_value); + static HttpStatus setStaticPolicyOption(EPolicyOption opt, policy_t pclass, + policyCallback value, policyCallback * ret_value);; /// Set a parameter on a class-based policy option. Calls /// made after the start of the servicing thread are diff --git a/indra/llcorehttp/httpresponse.h b/indra/llcorehttp/httpresponse.h index aee64e2878..01e9dd2bc6 100755 --- a/indra/llcorehttp/httpresponse.h +++ b/indra/llcorehttp/httpresponse.h @@ -69,6 +69,18 @@ protected: void operator=(const HttpResponse &); // Not defined public: + /// Statistics for the HTTP + struct TransferStats + { + typedef std::shared_ptr ptr_t; + + TransferStats() : mSizeDownload(0.0), mTotalTime(0.0), mSpeedDownload(0.0) {} + F64 mSizeDownload; + F64 mTotalTime; + F64 mSpeedDownload; + }; + + /// Returns the final status of the requested operation. /// HttpStatus getStatus() const @@ -168,6 +180,17 @@ public: m503Retries = retries_503; } + void setTransferStats(TransferStats::ptr_t &stats) + { + mStats = stats; + } + + TransferStats::ptr_t getTransferStats() + { + return mStats; + } + + protected: // Response data here HttpStatus mStatus; @@ -179,6 +202,8 @@ protected: std::string mContentType; unsigned int mRetries; unsigned int m503Retries; + + TransferStats::ptr_t mStats; }; diff --git a/indra/llmessage/llcurl.cpp b/indra/llmessage/llcurl.cpp index 73df47b933..0080dd6138 100755 --- a/indra/llmessage/llcurl.cpp +++ b/indra/llmessage/llcurl.cpp @@ -676,6 +676,7 @@ void LLCurl::Easy::prepRequest(const std::string& url, } //////////////////////////////////////////////////////////////////////////// +#if 1 LLCurl::Multi::Multi(F32 idle_time_out) : mQueued(0), mErrorCount(0), @@ -1056,6 +1057,7 @@ void LLCurl::Multi::removeEasy(Easy* easy) easyFree(easy); } +#endif //------------------------------------------------------------ //LLCurlThread LLCurlThread::CurlRequest::CurlRequest(handle_t handle, LLCurl::Multi* multi, LLCurlThread* curl_thread) : @@ -1176,428 +1178,428 @@ std::string LLCurl::strerror(CURLcode errorcode) // For generating a simple request for data // using one multi and one easy per request -LLCurlRequest::LLCurlRequest() : - mActiveMulti(NULL), - mActiveRequestCount(0) -{ - mProcessing = FALSE; -} - -LLCurlRequest::~LLCurlRequest() -{ - //stop all Multi handle background threads - for (curlmulti_set_t::iterator iter = mMultiSet.begin(); iter != mMultiSet.end(); ++iter) - { - LLCurl::getCurlThread()->killMulti(*iter) ; - } - mMultiSet.clear() ; -} - -void LLCurlRequest::addMulti() -{ - LLCurl::Multi* multi = new LLCurl::Multi(); - if(!multi->isValid()) - { - LLCurl::getCurlThread()->killMulti(multi) ; - mActiveMulti = NULL ; - mActiveRequestCount = 0 ; - return; - } - - mMultiSet.insert(multi); - mActiveMulti = multi; - mActiveRequestCount = 0; -} - -LLCurl::Easy* LLCurlRequest::allocEasy() -{ - if (!mActiveMulti || - mActiveRequestCount >= MAX_ACTIVE_REQUEST_COUNT || - mActiveMulti->mErrorCount > 0) - { - addMulti(); - } - if(!mActiveMulti) - { - return NULL ; - } - - //llassert_always(mActiveMulti); - ++mActiveRequestCount; - LLCurl::Easy* easy = mActiveMulti->allocEasy(); - return easy; -} - -bool LLCurlRequest::addEasy(LLCurl::Easy* easy) -{ - llassert_always(mActiveMulti); - - if (mProcessing) - { - LL_ERRS() << "Posting to a LLCurlRequest instance from within a responder is not allowed (causes DNS timeouts)." << LL_ENDL; - } - bool res = mActiveMulti->addEasy(easy); - return res; -} - -void LLCurlRequest::get(const std::string& url, LLCurl::ResponderPtr responder) -{ - getByteRange(url, headers_t(), 0, -1, responder); -} - -// Note: (length==0) is interpreted as "the rest of the file", i.e. the whole file if (offset==0) or -// the remainder of the file if not. -bool LLCurlRequest::getByteRange(const std::string& url, - const headers_t& headers, - S32 offset, S32 length, - LLCurl::ResponderPtr responder) -{ - llassert(LLCurl::sNotQuitting); - LLCurl::Easy* easy = allocEasy(); - if (!easy) - { - return false; - } - easy->prepRequest(url, headers, responder); - easy->setopt(CURLOPT_HTTPGET, 1); - if (length > 0) - { - std::string range = llformat("bytes=%d-%d", offset,offset+length-1); - easy->slist_append(HTTP_OUT_HEADER_RANGE, range); - } - else if (offset > 0) - { - std::string range = llformat("bytes=%d-", offset); - easy->slist_append(HTTP_OUT_HEADER_RANGE, range); - } - easy->setHeaders(); - bool res = addEasy(easy); - return res; -} - -bool LLCurlRequest::post(const std::string& url, - const headers_t& headers, - const LLSD& data, - LLCurl::ResponderPtr responder, S32 time_out) -{ - llassert(LLCurl::sNotQuitting); - LLCurl::Easy* easy = allocEasy(); - if (!easy) - { - return false; - } - easy->prepRequest(url, headers, responder, time_out); - - LLSDSerialize::toXML(data, easy->getInput()); - S32 bytes = easy->getInput().str().length(); - - easy->setopt(CURLOPT_POST, 1); - easy->setopt(CURLOPT_POSTFIELDS, (void*)NULL); - easy->setopt(CURLOPT_POSTFIELDSIZE, bytes); - - easy->slist_append(HTTP_OUT_HEADER_CONTENT_TYPE, HTTP_CONTENT_LLSD_XML); - easy->setHeaders(); - - LL_DEBUGS() << "POSTING: " << bytes << " bytes." << LL_ENDL; - bool res = addEasy(easy); - return res; -} - -bool LLCurlRequest::post(const std::string& url, - const headers_t& headers, - const std::string& data, - LLCurl::ResponderPtr responder, S32 time_out) -{ - llassert(LLCurl::sNotQuitting); - LLCurl::Easy* easy = allocEasy(); - if (!easy) - { - return false; - } - easy->prepRequest(url, headers, responder, time_out); - - easy->getInput().write(data.data(), data.size()); - S32 bytes = easy->getInput().str().length(); - - easy->setopt(CURLOPT_POST, 1); - easy->setopt(CURLOPT_POSTFIELDS, (void*)NULL); - easy->setopt(CURLOPT_POSTFIELDSIZE, bytes); - - easy->slist_append(HTTP_OUT_HEADER_CONTENT_TYPE, HTTP_CONTENT_OCTET_STREAM); - easy->setHeaders(); - - LL_DEBUGS() << "POSTING: " << bytes << " bytes." << LL_ENDL; - bool res = addEasy(easy); - return res; -} - -// Note: call once per frame -S32 LLCurlRequest::process() -{ - S32 res = 0; - - mProcessing = TRUE; - for (curlmulti_set_t::iterator iter = mMultiSet.begin(); - iter != mMultiSet.end(); ) - { - curlmulti_set_t::iterator curiter = iter++; - LLCurl::Multi* multi = *curiter; - - if(!multi->isValid()) - { - if(multi == mActiveMulti) - { - mActiveMulti = NULL ; - mActiveRequestCount = 0 ; - } - mMultiSet.erase(curiter) ; - LLCurl::getCurlThread()->killMulti(multi) ; - continue ; - } - - S32 tres = multi->process(); - res += tres; - if (multi != mActiveMulti && tres == 0 && multi->mQueued == 0) - { - mMultiSet.erase(curiter); - LLCurl::getCurlThread()->killMulti(multi); - } - } - mProcessing = FALSE; - return res; -} - -S32 LLCurlRequest::getQueued() -{ - S32 queued = 0; - for (curlmulti_set_t::iterator iter = mMultiSet.begin(); - iter != mMultiSet.end(); ) - { - curlmulti_set_t::iterator curiter = iter++; - LLCurl::Multi* multi = *curiter; - - if(!multi->isValid()) - { - if(multi == mActiveMulti) - { - mActiveMulti = NULL ; - mActiveRequestCount = 0 ; - } - LLCurl::getCurlThread()->killMulti(multi); - mMultiSet.erase(curiter) ; - continue ; - } - - queued += multi->mQueued; - if (multi->getState() != LLCurl::Multi::STATE_READY) - { - ++queued; - } - } - return queued; -} - -LLCurlTextureRequest::LLCurlTextureRequest(S32 concurrency) : - LLCurlRequest(), - mConcurrency(concurrency), - mInQueue(0), - mMutex(NULL), - mHandleCounter(1), - mTotalIssuedRequests(0), - mTotalReceivedBits(0) -{ - mGlobalTimer.reset(); -} - -LLCurlTextureRequest::~LLCurlTextureRequest() -{ - mRequestMap.clear(); - - for(req_queue_t::iterator iter = mCachedRequests.begin(); iter != mCachedRequests.end(); ++iter) - { - delete *iter; - } - mCachedRequests.clear(); -} - -//return 0: success -// > 0: cached handle -U32 LLCurlTextureRequest::getByteRange(const std::string& url, - const headers_t& headers, - S32 offset, S32 length, U32 pri, - LLCurl::ResponderPtr responder, F32 delay_time) -{ - U32 ret_val = 0; - bool success = false; - - if(mInQueue < mConcurrency && delay_time < 0.f) - { - success = LLCurlRequest::getByteRange(url, headers, offset, length, responder); - } - - LLMutexLock lock(&mMutex); - - if(success) - { - mInQueue++; - mTotalIssuedRequests++; - } - else - { - request_t* request = new request_t(mHandleCounter, url, headers, offset, length, pri, responder); - if(delay_time > 0.f) - { - request->mStartTime = mGlobalTimer.getElapsedTimeF32() + delay_time; - } - - mCachedRequests.insert(request); - mRequestMap[mHandleCounter] = request; - ret_val = mHandleCounter; - mHandleCounter++; - - if(!mHandleCounter) - { - mHandleCounter = 1; - } - } - - return ret_val; -} - -void LLCurlTextureRequest::completeRequest(S32 received_bytes) -{ - LLMutexLock lock(&mMutex); - - llassert_always(mInQueue > 0); - - mInQueue--; - mTotalReceivedBits += received_bytes * 8; -} - -void LLCurlTextureRequest::nextRequests() -{ - if(mCachedRequests.empty() || mInQueue >= mConcurrency) - { - return; - } - - F32 cur_time = mGlobalTimer.getElapsedTimeF32(); - - req_queue_t::iterator iter; - { - LLMutexLock lock(&mMutex); - iter = mCachedRequests.begin(); - } - while(1) - { - request_t* request = *iter; - if(request->mStartTime < cur_time) - { - if(!LLCurlRequest::getByteRange(request->mUrl, request->mHeaders, request->mOffset, request->mLength, request->mResponder)) - { - break; - } - - LLMutexLock lock(&mMutex); - ++iter; - mInQueue++; - mTotalIssuedRequests++; - mCachedRequests.erase(request); - mRequestMap.erase(request->mHandle); - delete request; - - if(iter == mCachedRequests.end() || mInQueue >= mConcurrency) - { - break; - } - } - else - { - LLMutexLock lock(&mMutex); - ++iter; - if(iter == mCachedRequests.end() || mInQueue >= mConcurrency) - { - break; - } - } - } - - return; -} - -void LLCurlTextureRequest::updatePriority(U32 handle, U32 pri) -{ - if(!handle) - { - return; - } - - LLMutexLock lock(&mMutex); - - std::map::iterator iter = mRequestMap.find(handle); - if(iter != mRequestMap.end()) - { - request_t* req = iter->second; - - if(req->mPriority != pri) - { - mCachedRequests.erase(req); - req->mPriority = pri; - mCachedRequests.insert(req); - } - } -} - -void LLCurlTextureRequest::removeRequest(U32 handle) -{ - if(!handle) - { - return; - } - - LLMutexLock lock(&mMutex); - - std::map::iterator iter = mRequestMap.find(handle); - if(iter != mRequestMap.end()) - { - request_t* req = iter->second; - mRequestMap.erase(iter); - mCachedRequests.erase(req); - delete req; - } -} - -bool LLCurlTextureRequest::isWaiting(U32 handle) -{ - if(!handle) - { - return false; - } - - LLMutexLock lock(&mMutex); - return mRequestMap.find(handle) != mRequestMap.end(); -} - -U32 LLCurlTextureRequest::getTotalReceivedBits() -{ - LLMutexLock lock(&mMutex); - - U32 bits = mTotalReceivedBits; - mTotalReceivedBits = 0; - return bits; -} - -U32 LLCurlTextureRequest::getTotalIssuedRequests() -{ - LLMutexLock lock(&mMutex); - return mTotalIssuedRequests; -} - -S32 LLCurlTextureRequest::getNumRequests() -{ - LLMutexLock lock(&mMutex); - return mInQueue; -} +// LLCurlRequest::LLCurlRequest() : +// mActiveMulti(NULL), +// mActiveRequestCount(0) +// { +// mProcessing = FALSE; +// } +// +// LLCurlRequest::~LLCurlRequest() +// { +// //stop all Multi handle background threads +// for (curlmulti_set_t::iterator iter = mMultiSet.begin(); iter != mMultiSet.end(); ++iter) +// { +// LLCurl::getCurlThread()->killMulti(*iter) ; +// } +// mMultiSet.clear() ; +// } +// +// void LLCurlRequest::addMulti() +// { +// LLCurl::Multi* multi = new LLCurl::Multi(); +// if(!multi->isValid()) +// { +// LLCurl::getCurlThread()->killMulti(multi) ; +// mActiveMulti = NULL ; +// mActiveRequestCount = 0 ; +// return; +// } +// +// mMultiSet.insert(multi); +// mActiveMulti = multi; +// mActiveRequestCount = 0; +// } +// +// LLCurl::Easy* LLCurlRequest::allocEasy() +// { +// if (!mActiveMulti || +// mActiveRequestCount >= MAX_ACTIVE_REQUEST_COUNT || +// mActiveMulti->mErrorCount > 0) +// { +// addMulti(); +// } +// if(!mActiveMulti) +// { +// return NULL ; +// } +// +// //llassert_always(mActiveMulti); +// ++mActiveRequestCount; +// LLCurl::Easy* easy = mActiveMulti->allocEasy(); +// return easy; +// } +// +// bool LLCurlRequest::addEasy(LLCurl::Easy* easy) +// { +// llassert_always(mActiveMulti); +// +// if (mProcessing) +// { +// LL_ERRS() << "Posting to a LLCurlRequest instance from within a responder is not allowed (causes DNS timeouts)." << LL_ENDL; +// } +// bool res = mActiveMulti->addEasy(easy); +// return res; +// } +// +// void LLCurlRequest::get(const std::string& url, LLCurl::ResponderPtr responder) +// { +// getByteRange(url, headers_t(), 0, -1, responder); +// } +// +// // Note: (length==0) is interpreted as "the rest of the file", i.e. the whole file if (offset==0) or +// // the remainder of the file if not. +// bool LLCurlRequest::getByteRange(const std::string& url, +// const headers_t& headers, +// S32 offset, S32 length, +// LLCurl::ResponderPtr responder) +// { +// llassert(LLCurl::sNotQuitting); +// LLCurl::Easy* easy = allocEasy(); +// if (!easy) +// { +// return false; +// } +// easy->prepRequest(url, headers, responder); +// easy->setopt(CURLOPT_HTTPGET, 1); +// if (length > 0) +// { +// std::string range = llformat("bytes=%d-%d", offset,offset+length-1); +// easy->slist_append(HTTP_OUT_HEADER_RANGE, range); +// } +// else if (offset > 0) +// { +// std::string range = llformat("bytes=%d-", offset); +// easy->slist_append(HTTP_OUT_HEADER_RANGE, range); +// } +// easy->setHeaders(); +// bool res = addEasy(easy); +// return res; +// } +// +// bool LLCurlRequest::post(const std::string& url, +// const headers_t& headers, +// const LLSD& data, +// LLCurl::ResponderPtr responder, S32 time_out) +// { +// llassert(LLCurl::sNotQuitting); +// LLCurl::Easy* easy = allocEasy(); +// if (!easy) +// { +// return false; +// } +// easy->prepRequest(url, headers, responder, time_out); +// +// LLSDSerialize::toXML(data, easy->getInput()); +// S32 bytes = easy->getInput().str().length(); +// +// easy->setopt(CURLOPT_POST, 1); +// easy->setopt(CURLOPT_POSTFIELDS, (void*)NULL); +// easy->setopt(CURLOPT_POSTFIELDSIZE, bytes); +// +// easy->slist_append(HTTP_OUT_HEADER_CONTENT_TYPE, HTTP_CONTENT_LLSD_XML); +// easy->setHeaders(); +// +// LL_DEBUGS() << "POSTING: " << bytes << " bytes." << LL_ENDL; +// bool res = addEasy(easy); +// return res; +// } +// +// bool LLCurlRequest::post(const std::string& url, +// const headers_t& headers, +// const std::string& data, +// LLCurl::ResponderPtr responder, S32 time_out) +// { +// llassert(LLCurl::sNotQuitting); +// LLCurl::Easy* easy = allocEasy(); +// if (!easy) +// { +// return false; +// } +// easy->prepRequest(url, headers, responder, time_out); +// +// easy->getInput().write(data.data(), data.size()); +// S32 bytes = easy->getInput().str().length(); +// +// easy->setopt(CURLOPT_POST, 1); +// easy->setopt(CURLOPT_POSTFIELDS, (void*)NULL); +// easy->setopt(CURLOPT_POSTFIELDSIZE, bytes); +// +// easy->slist_append(HTTP_OUT_HEADER_CONTENT_TYPE, HTTP_CONTENT_OCTET_STREAM); +// easy->setHeaders(); +// +// LL_DEBUGS() << "POSTING: " << bytes << " bytes." << LL_ENDL; +// bool res = addEasy(easy); +// return res; +// } +// +// // Note: call once per frame +// S32 LLCurlRequest::process() +// { +// S32 res = 0; +// +// mProcessing = TRUE; +// for (curlmulti_set_t::iterator iter = mMultiSet.begin(); +// iter != mMultiSet.end(); ) +// { +// curlmulti_set_t::iterator curiter = iter++; +// LLCurl::Multi* multi = *curiter; +// +// if(!multi->isValid()) +// { +// if(multi == mActiveMulti) +// { +// mActiveMulti = NULL ; +// mActiveRequestCount = 0 ; +// } +// mMultiSet.erase(curiter) ; +// LLCurl::getCurlThread()->killMulti(multi) ; +// continue ; +// } +// +// S32 tres = multi->process(); +// res += tres; +// if (multi != mActiveMulti && tres == 0 && multi->mQueued == 0) +// { +// mMultiSet.erase(curiter); +// LLCurl::getCurlThread()->killMulti(multi); +// } +// } +// mProcessing = FALSE; +// return res; +// } +// +// S32 LLCurlRequest::getQueued() +// { +// S32 queued = 0; +// for (curlmulti_set_t::iterator iter = mMultiSet.begin(); +// iter != mMultiSet.end(); ) +// { +// curlmulti_set_t::iterator curiter = iter++; +// LLCurl::Multi* multi = *curiter; +// +// if(!multi->isValid()) +// { +// if(multi == mActiveMulti) +// { +// mActiveMulti = NULL ; +// mActiveRequestCount = 0 ; +// } +// LLCurl::getCurlThread()->killMulti(multi); +// mMultiSet.erase(curiter) ; +// continue ; +// } +// +// queued += multi->mQueued; +// if (multi->getState() != LLCurl::Multi::STATE_READY) +// { +// ++queued; +// } +// } +// return queued; +// } + +// LLCurlTextureRequest::LLCurlTextureRequest(S32 concurrency) : +// LLCurlRequest(), +// mConcurrency(concurrency), +// mInQueue(0), +// mMutex(NULL), +// mHandleCounter(1), +// mTotalIssuedRequests(0), +// mTotalReceivedBits(0) +// { +// mGlobalTimer.reset(); +// } +// +// LLCurlTextureRequest::~LLCurlTextureRequest() +// { +// mRequestMap.clear(); +// +// for(req_queue_t::iterator iter = mCachedRequests.begin(); iter != mCachedRequests.end(); ++iter) +// { +// delete *iter; +// } +// mCachedRequests.clear(); +// } +// +// //return 0: success +// // > 0: cached handle +// U32 LLCurlTextureRequest::getByteRange(const std::string& url, +// const headers_t& headers, +// S32 offset, S32 length, U32 pri, +// LLCurl::ResponderPtr responder, F32 delay_time) +// { +// U32 ret_val = 0; +// bool success = false; +// +// if(mInQueue < mConcurrency && delay_time < 0.f) +// { +// success = LLCurlRequest::getByteRange(url, headers, offset, length, responder); +// } +// +// LLMutexLock lock(&mMutex); +// +// if(success) +// { +// mInQueue++; +// mTotalIssuedRequests++; +// } +// else +// { +// request_t* request = new request_t(mHandleCounter, url, headers, offset, length, pri, responder); +// if(delay_time > 0.f) +// { +// request->mStartTime = mGlobalTimer.getElapsedTimeF32() + delay_time; +// } +// +// mCachedRequests.insert(request); +// mRequestMap[mHandleCounter] = request; +// ret_val = mHandleCounter; +// mHandleCounter++; +// +// if(!mHandleCounter) +// { +// mHandleCounter = 1; +// } +// } +// +// return ret_val; +// } +// +// void LLCurlTextureRequest::completeRequest(S32 received_bytes) +// { +// LLMutexLock lock(&mMutex); +// +// llassert_always(mInQueue > 0); +// +// mInQueue--; +// mTotalReceivedBits += received_bytes * 8; +// } +// +// void LLCurlTextureRequest::nextRequests() +// { +// if(mCachedRequests.empty() || mInQueue >= mConcurrency) +// { +// return; +// } +// +// F32 cur_time = mGlobalTimer.getElapsedTimeF32(); +// +// req_queue_t::iterator iter; +// { +// LLMutexLock lock(&mMutex); +// iter = mCachedRequests.begin(); +// } +// while(1) +// { +// request_t* request = *iter; +// if(request->mStartTime < cur_time) +// { +// if(!LLCurlRequest::getByteRange(request->mUrl, request->mHeaders, request->mOffset, request->mLength, request->mResponder)) +// { +// break; +// } +// +// LLMutexLock lock(&mMutex); +// ++iter; +// mInQueue++; +// mTotalIssuedRequests++; +// mCachedRequests.erase(request); +// mRequestMap.erase(request->mHandle); +// delete request; +// +// if(iter == mCachedRequests.end() || mInQueue >= mConcurrency) +// { +// break; +// } +// } +// else +// { +// LLMutexLock lock(&mMutex); +// ++iter; +// if(iter == mCachedRequests.end() || mInQueue >= mConcurrency) +// { +// break; +// } +// } +// } +// +// return; +// } +// +// void LLCurlTextureRequest::updatePriority(U32 handle, U32 pri) +// { +// if(!handle) +// { +// return; +// } +// +// LLMutexLock lock(&mMutex); +// +// std::map::iterator iter = mRequestMap.find(handle); +// if(iter != mRequestMap.end()) +// { +// request_t* req = iter->second; +// +// if(req->mPriority != pri) +// { +// mCachedRequests.erase(req); +// req->mPriority = pri; +// mCachedRequests.insert(req); +// } +// } +// } +// +// void LLCurlTextureRequest::removeRequest(U32 handle) +// { +// if(!handle) +// { +// return; +// } +// +// LLMutexLock lock(&mMutex); +// +// std::map::iterator iter = mRequestMap.find(handle); +// if(iter != mRequestMap.end()) +// { +// request_t* req = iter->second; +// mRequestMap.erase(iter); +// mCachedRequests.erase(req); +// delete req; +// } +// } +// +// bool LLCurlTextureRequest::isWaiting(U32 handle) +// { +// if(!handle) +// { +// return false; +// } +// +// LLMutexLock lock(&mMutex); +// return mRequestMap.find(handle) != mRequestMap.end(); +// } +// +// U32 LLCurlTextureRequest::getTotalReceivedBits() +// { +// LLMutexLock lock(&mMutex); +// +// U32 bits = mTotalReceivedBits; +// mTotalReceivedBits = 0; +// return bits; +// } +// +// U32 LLCurlTextureRequest::getTotalIssuedRequests() +// { +// LLMutexLock lock(&mMutex); +// return mTotalIssuedRequests; +// } +// +// S32 LLCurlTextureRequest::getNumRequests() +// { +// LLMutexLock lock(&mMutex); +// return mInQueue; +// } //////////////////////////////////////////////////////////////////////////// // For generating one easy request @@ -1988,10 +1990,10 @@ void LLCurlFF::check_easy_code(CURLcode code) { check_curl_code(code); } -void LLCurlFF::check_multi_code(CURLMcode code) -{ - check_curl_multi_code(code); -} +// void LLCurlFF::check_multi_code(CURLMcode code) +// { +// check_curl_multi_code(code); +// } // Static diff --git a/indra/llmessage/llcurl.h b/indra/llmessage/llcurl.h index 385d9fffa8..295e9c9fe5 100755 --- a/indra/llmessage/llcurl.h +++ b/indra/llmessage/llcurl.h @@ -309,6 +309,7 @@ private: static void deleteAllFreeHandles(); }; +#if 1 class LLCurl::Multi { LOG_CLASS(Multi); @@ -379,6 +380,7 @@ private: LLFrameTimer mIdleTimer ; F32 mIdleTimeOut; }; +#endif class LLCurlThread : public LLQueuedThread { @@ -417,7 +419,7 @@ private: void cleanupMulti(LLCurl::Multi* multi) ; } ; - +#if 0 class LLCurlRequest { public: @@ -446,7 +448,9 @@ private: S32 mActiveRequestCount; BOOL mProcessing; }; +#endif +#if 0 //for texture fetch only class LLCurlTextureRequest : public LLCurlRequest { @@ -511,6 +515,7 @@ private: LLFrameTimer mGlobalTimer; }; +#endif class LLCurlEasyRequest { @@ -550,7 +555,7 @@ private: namespace LLCurlFF { void check_easy_code(CURLcode code); - void check_multi_code(CURLMcode code); + //void check_multi_code(CURLMcode code); } #endif // LL_LLCURL_H diff --git a/indra/llmessage/llhttpclient.cpp b/indra/llmessage/llhttpclient.cpp index 200116337d..27c94b1182 100755 --- a/indra/llmessage/llhttpclient.cpp +++ b/indra/llmessage/llhttpclient.cpp @@ -38,6 +38,10 @@ #include "lluri.h" #include "message.h" +#include "httpcommon.h" +#include "httprequest.h" +#include "httpoptions.h" + #include @@ -214,6 +218,51 @@ void LLHTTPClient::setCertVerifyCallback(LLURLRequest::SSLCertVerifyCallback cal LLHTTPClient::mCertVerifyCallback = callback; } +#if 0 +typedef std::shared_ptr HttpRequestPtr_t; +typedef std::unique_ptr HttpOptionsPtr_t; +typedef std::unique_ptr InjectorPtr_t; + +static void request_( + const std::string& url, + EHTTPMethod method, + Injector* body_injector, + LLCurl::ResponderPtr responder, + const F32 timeout = HTTP_REQUEST_EXPIRY_SECS, + const LLSD& headers = LLSD(), + bool follow_redirects = true + ) +{ + HttpRequestPtr_t httpReq = HttpRequestPtr_t(new LLCore::HttpRequest()); + + HttpOptionsPtr_t httpOpts = HttpOptionsPtr_t(new LLCore::HttpOptions()); + + httpOpts->setFollowRedirects(follow_redirects); + httpOpts->setRetries(12); + httpOpts->setUseRetryAfter(true); + // for the moment lets just truncate. 60 seconds vs 60.5 seconds + httpOpts->setTransferTimeout((unsigned int)timeout); + + switch (method) + { + case HTTP_GET: + httpReq->requestGet(0, 0, url, httpOpts.get(), headers, handler); + break; + case HTTP_HEAD: + httpReq->requestHead(0, 0, url, httpOpts.get(), headers, handler); + break; + case HTTP_PUT: + httpReq->requestPut(0, 0, url, ); + break; + case HTTP_POST: + httpReq->requestPost(0, 0, url, null, httpOpts.get(), headers, handler); + break; + } + + +} +#endif + static void request( const std::string& url, EHTTPMethod method, diff --git a/indra/llmessage/llhttpclientadapter.cpp b/indra/llmessage/llhttpclientadapter.cpp index b56a804f94..8c2a0ad9cf 100755 --- a/indra/llmessage/llhttpclientadapter.cpp +++ b/indra/llmessage/llhttpclientadapter.cpp @@ -26,48 +26,48 @@ #include "llhttpclientadapter.h" #include "llhttpclient.h" - -LLHTTPClientAdapter::~LLHTTPClientAdapter() -{ -} - -void LLHTTPClientAdapter::get(const std::string& url, LLCurl::ResponderPtr responder) -{ - LLSD empty_pragma_header; - // Pragma is required to stop curl adding "no-cache" - // Space is required to stop llurlrequest from turning off proxying - empty_pragma_header[HTTP_OUT_HEADER_PRAGMA] = " "; - LLHTTPClient::get(url, responder, empty_pragma_header); -} - -void LLHTTPClientAdapter::get(const std::string& url, LLCurl::ResponderPtr responder, const LLSD& headers) -{ - LLSD empty_pragma_header = headers; - if (!empty_pragma_header.has(HTTP_OUT_HEADER_PRAGMA)) - { - // as above - empty_pragma_header[HTTP_OUT_HEADER_PRAGMA] = " "; - } - LLHTTPClient::get(url, responder, empty_pragma_header); -} - -void LLHTTPClientAdapter::put(const std::string& url, const LLSD& body, LLCurl::ResponderPtr responder) -{ - LLHTTPClient::put(url, body, responder); -} - -void LLHTTPClientAdapter::put( - const std::string& url, - const LLSD& body, - LLCurl::ResponderPtr responder, - const LLSD& headers) -{ - LLHTTPClient::put(url, body, responder, headers); -} - -void LLHTTPClientAdapter::del( - const std::string& url, - LLCurl::ResponderPtr responder) -{ - LLHTTPClient::del(url, responder); -} +// +// LLHTTPClientAdapter::~LLHTTPClientAdapter() +// { +// } +// +// void LLHTTPClientAdapter::get(const std::string& url, LLCurl::ResponderPtr responder) +// { +// LLSD empty_pragma_header; +// // Pragma is required to stop curl adding "no-cache" +// // Space is required to stop llurlrequest from turning off proxying +// empty_pragma_header[HTTP_OUT_HEADER_PRAGMA] = " "; +// LLHTTPClient::get(url, responder, empty_pragma_header); +// } +// +// void LLHTTPClientAdapter::get(const std::string& url, LLCurl::ResponderPtr responder, const LLSD& headers) +// { +// LLSD empty_pragma_header = headers; +// if (!empty_pragma_header.has(HTTP_OUT_HEADER_PRAGMA)) +// { +// // as above +// empty_pragma_header[HTTP_OUT_HEADER_PRAGMA] = " "; +// } +// LLHTTPClient::get(url, responder, empty_pragma_header); +// } +// +// void LLHTTPClientAdapter::put(const std::string& url, const LLSD& body, LLCurl::ResponderPtr responder) +// { +// LLHTTPClient::put(url, body, responder); +// } +// +// void LLHTTPClientAdapter::put( +// const std::string& url, +// const LLSD& body, +// LLCurl::ResponderPtr responder, +// const LLSD& headers) +// { +// LLHTTPClient::put(url, body, responder, headers); +// } +// +// void LLHTTPClientAdapter::del( +// const std::string& url, +// LLCurl::ResponderPtr responder) +// { +// LLHTTPClient::del(url, responder); +// } diff --git a/indra/llmessage/llhttpclientadapter.h b/indra/llmessage/llhttpclientadapter.h index 270282c66f..0067703895 100755 --- a/indra/llmessage/llhttpclientadapter.h +++ b/indra/llmessage/llhttpclientadapter.h @@ -30,6 +30,7 @@ #include "llhttpclientinterface.h" #include "llsingleton.h" // LLSingleton<> +/* class LLHTTPClientAdapter : public LLHTTPClientInterface, public LLSingleton { public: @@ -46,6 +47,7 @@ public: const std::string& url, LLCurl::ResponderPtr responder); }; +*/ #endif diff --git a/indra/llmessage/llhttpclientinterface.h b/indra/llmessage/llhttpclientinterface.h index 12a3857a61..9c1c8e7c11 100755 --- a/indra/llmessage/llhttpclientinterface.h +++ b/indra/llmessage/llhttpclientinterface.h @@ -32,14 +32,14 @@ #include -class LLHTTPClientInterface -{ -public: - virtual ~LLHTTPClientInterface() {} - virtual void get(const std::string& url, LLCurl::ResponderPtr responder) = 0; - virtual void get(const std::string& url, LLCurl::ResponderPtr responder, const LLSD& headers) = 0; - virtual void put(const std::string& url, const LLSD& body, LLCurl::ResponderPtr responder) = 0; -}; +// class LLHTTPClientInterface +// { +// public: +// virtual ~LLHTTPClientInterface() {} +// virtual void get(const std::string& url, LLCurl::ResponderPtr responder) = 0; +// virtual void get(const std::string& url, LLCurl::ResponderPtr responder, const LLSD& headers) = 0; +// virtual void put(const std::string& url, const LLSD& body, LLCurl::ResponderPtr responder) = 0; +// }; #endif // LL_LLHTTPCLIENTINTERFACE_H diff --git a/indra/llmessage/llsdrpcclient.h b/indra/llmessage/llsdrpcclient.h index c4e0333ca3..d097ecdff7 100755 --- a/indra/llmessage/llsdrpcclient.h +++ b/indra/llmessage/llsdrpcclient.h @@ -37,7 +37,9 @@ #include "llchainio.h" #include "llfiltersd2xmlrpc.h" #include "lliopipe.h" -#include "llurlrequest.h" +#if 0 +//#include "llurlrequest.h" +#endif /** * @class LLSDRPCClientResponse @@ -218,6 +220,7 @@ protected: LLIOPipe::ptr_t mResponse; }; +#if 0 /** * @class LLSDRPCClientFactory * @brief Basic implementation for making an SD RPC client factory @@ -267,7 +270,9 @@ public: protected: std::string mURL; }; +#endif +#if 0 /** * @class LLXMLSDRPCClientFactory * @brief Basic implementation for making an XMLRPC to SD RPC client factory @@ -319,5 +324,6 @@ public: protected: std::string mURL; }; +#endif #endif // LL_LLSDRPCCLIENT_H diff --git a/indra/newview/llappcorehttp.cpp b/indra/newview/llappcorehttp.cpp index f5f224b83e..dd39b9a959 100755 --- a/indra/newview/llappcorehttp.cpp +++ b/indra/newview/llappcorehttp.cpp @@ -31,6 +31,10 @@ #include "llappviewer.h" #include "llviewercontrol.h" +#include +#include +#include "llsecapi.h" +#include // Here is where we begin to get our connection usage under control. // This establishes llcorehttp policy classes that, among other @@ -151,6 +155,15 @@ void LLAppCoreHttp::init() << LL_ENDL; } + // Set up SSL Verification call back. + status = LLCore::HttpRequest::setStaticPolicyOption(LLCore::HttpRequest::PO_SSL_VERIFY_CALLBACK, + LLCore::HttpRequest::GLOBAL_POLICY_ID, + sslVerify, NULL); + if (!status) + { + LL_WARNS("Init") << "Failed to set SSL Verification. Reason: " << status.toString() << LL_ENDL; + } + // Tracing levels for library & libcurl (note that 2 & 3 are beyond spammy): // 0 - None // 1 - Basic start, stop simple transitions @@ -457,6 +470,62 @@ void LLAppCoreHttp::refreshSettings(bool initial) } } +LLCore::HttpStatus LLAppCoreHttp::sslVerify(const std::string &url, + LLCore::HttpHandler const * const handler, void *appdata) +{ + X509_STORE_CTX *ctx = static_cast(appdata); + LLCore::HttpStatus result; + LLPointer store = gSecAPIHandler->getCertificateStore(""); + LLPointer chain = gSecAPIHandler->getCertificateChain(ctx); + LLSD validation_params = LLSD::emptyMap(); + LLURI uri(url); + + validation_params[CERT_HOSTNAME] = uri.hostName(); + + // *TODO*: In the case of an exception while validating the cert, we need a way + // to pass the offending(?) cert back out. *Rider* + + try + { + // don't validate hostname. Let libcurl do it instead. That way, it'll handle redirects + store->validate(VALIDATION_POLICY_SSL & (~VALIDATION_POLICY_HOSTNAME), chain, validation_params); + } + catch (LLCertValidationTrustException &cert_exception) + { + // this exception is is handled differently than the general cert + // exceptions, as we allow the user to actually add the certificate + // for trust. + // therefore we pass back a different error code + // NOTE: We're currently 'wired' to pass around CURL error codes. This is + // somewhat clumsy, as we may run into errors that do not map directly to curl + // error codes. Should be refactored with login refactoring, perhaps. + result = LLCore::HttpStatus(LLCore::HttpStatus::EXT_CURL_EASY, CURLE_SSL_CACERT); + result.setMessage(cert_exception.getMessage()); + LLPointer cert = cert_exception.getCert(); + cert->ref(); // adding an extra ref here + result.setErrorData(cert.get()); + // We should probably have a more generic way of passing information + // back to the error handlers. + } + catch (LLCertException &cert_exception) + { + result = LLCore::HttpStatus(LLCore::HttpStatus::EXT_CURL_EASY, CURLE_SSL_PEER_CERTIFICATE); + result.setMessage(cert_exception.getMessage()); + LLPointer cert = cert_exception.getCert(); + cert->ref(); // adding an extra ref here + result.setErrorData(cert.get()); + } + catch (...) + { + // any other odd error, we just handle as a connect error. + result = LLCore::HttpStatus(LLCore::HttpStatus::EXT_CURL_EASY, CURLE_SSL_CONNECT_ERROR); + } + + return result; +} + + + void LLAppCoreHttp::onCompleted(LLCore::HttpHandle, LLCore::HttpResponse *) { diff --git a/indra/newview/llappcorehttp.h b/indra/newview/llappcorehttp.h index 37d7a737e7..9616354093 100755 --- a/indra/newview/llappcorehttp.h +++ b/indra/newview/llappcorehttp.h @@ -233,7 +233,9 @@ private: bool mStopped; HttpClass mHttpClasses[AP_COUNT]; bool mPipelined; // Global setting - boost::signals2::connection mPipelinedSignal; // Signal for 'HttpPipelining' setting + boost::signals2::connection mPipelinedSignal; // Signal for 'HttpPipelining' setting + + static LLCore::HttpStatus sslVerify(const std::string &uri, LLCore::HttpHandler const * const handler, void *appdata); }; diff --git a/indra/newview/llhttpretrypolicy.cpp b/indra/newview/llhttpretrypolicy.cpp index 2d4ce6c883..530eb685fa 100755 --- a/indra/newview/llhttpretrypolicy.cpp +++ b/indra/newview/llhttpretrypolicy.cpp @@ -87,7 +87,7 @@ void LLAdaptiveRetryPolicy::onFailure(const LLCore::HttpResponse *response) F32 retry_header_time; const LLCore::HttpHeaders *headers = response->getHeaders(); bool has_retry_header_time = getRetryAfter(headers,retry_header_time); - onFailureCommon(response->getStatus().mType, has_retry_header_time, retry_header_time); + onFailureCommon(response->getStatus().getType(), has_retry_header_time, retry_header_time); } void LLAdaptiveRetryPolicy::onFailureCommon(S32 status, bool has_retry_header_time, F32 retry_header_time) diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp index aa440c06a6..4f08057477 100755 --- a/indra/newview/llvoavatarself.cpp +++ b/indra/newview/llvoavatarself.cpp @@ -2294,7 +2294,6 @@ void LLVOAvatarSelf::sendViewerAppearanceChangeMetrics() if (!caps_url.empty()) { gPendingMetricsUploads++; - LLCurlRequest::headers_t headers; LLHTTPClient::post(caps_url, msg, new ViewerAppearanceChangeMetricsResponder(report_sequence, diff --git a/indra/newview/llxmlrpctransaction.cpp b/indra/newview/llxmlrpctransaction.cpp index c12c2cc24c..e4e63afa16 100755 --- a/indra/newview/llxmlrpctransaction.cpp +++ b/indra/newview/llxmlrpctransaction.cpp @@ -35,6 +35,11 @@ #include "llxmlrpclistener.h" #include "llcurl.h" +#include "httpcommon.h" +#include "httprequest.h" +#include "httpoptions.h" +#include "httpheaders.h" +#include "bufferarray.h" #include "llviewercontrol.h" // Have to include these last to avoid queue redefinition! @@ -155,55 +160,159 @@ XMLRPC_VALUE LLXMLRPCValue::getValue() const } +class LLXMLRPCTransaction::Handler : public LLCore::HttpHandler +{ +public: + Handler(LLCore::HttpRequest::ptr_t &request, LLXMLRPCTransaction::Impl *impl); + virtual ~Handler(); + + virtual void onCompleted(LLCore::HttpHandle handle, LLCore::HttpResponse * response); + + typedef std::unique_ptr ptr_t; + +private: + + LLXMLRPCTransaction::Impl *mImpl; + LLCore::HttpRequest::ptr_t mRequest; +}; + class LLXMLRPCTransaction::Impl { public: typedef LLXMLRPCTransaction::EStatus EStatus; - LLCurlEasyRequest* mCurlRequest; + LLCore::HttpRequest::ptr_t mHttpRequest; + + + EStatus mStatus; + CURLcode mCurlCode; + std::string mStatusMessage; + std::string mStatusURI; + LLCore::HttpResponse::TransferStats::ptr_t mTransferStats; + Handler::ptr_t mHandler; + LLCore::HttpHandle mPostH; - EStatus mStatus; - CURLcode mCurlCode; - std::string mStatusMessage; - std::string mStatusURI; - LLCurl::TransferInfo mTransferInfo; - std::string mURI; - char* mRequestText; - int mRequestTextSize; - + std::string mProxyAddress; std::string mResponseText; XMLRPC_REQUEST mResponse; std::string mCertStore; LLPointer mErrorCert; - + Impl(const std::string& uri, XMLRPC_REQUEST request, bool useGzip); Impl(const std::string& uri, - const std::string& method, LLXMLRPCValue params, bool useGzip); + const std::string& method, LLXMLRPCValue params, bool useGzip); ~Impl(); - + bool process(); - - void setStatus(EStatus code, - const std::string& message = "", const std::string& uri = ""); - void setCurlStatus(CURLcode); + + void setStatus(EStatus code, const std::string& message = "", const std::string& uri = ""); + void setHttpStatus(const LLCore::HttpStatus &status); private: void init(XMLRPC_REQUEST request, bool useGzip); - static int _sslCertVerifyCallback(X509_STORE_CTX *ctx, void *param); - static CURLcode _sslCtxFunction(CURL * curl, void *sslctx, void *param); - static size_t curlDownloadCallback( - char* data, size_t size, size_t nmemb, void* user_data); }; +LLXMLRPCTransaction::Handler::Handler(LLCore::HttpRequest::ptr_t &request, + LLXMLRPCTransaction::Impl *impl) : + mImpl(impl), + mRequest(request) +{ +} + +LLXMLRPCTransaction::Handler::~Handler() +{ +} + +void LLXMLRPCTransaction::Handler::onCompleted(LLCore::HttpHandle handle, + LLCore::HttpResponse * response) +{ + LLCore::HttpStatus status = response->getStatus(); + + if (!status) + { + if ((status.toULong() != CURLE_SSL_PEER_CERTIFICATE) && + (status.toULong() != CURLE_SSL_CACERT)) + { + // if we have a curl error that's not already been handled + // (a non cert error), then generate the error message as + // appropriate + mImpl->setHttpStatus(status); + LLCertificate *errordata = static_cast(status.getErrorData()); + + if (errordata) + { + mImpl->mErrorCert = LLPointer(errordata); + status.setErrorData(NULL); + errordata->unref(); + } + + LL_WARNS() << "LLXMLRPCTransaction error " + << status.toHex() << ": " << status.toString() << LL_ENDL; + LL_WARNS() << "LLXMLRPCTransaction request URI: " + << mImpl->mURI << LL_ENDL; + } + + return; + } + + mImpl->setStatus(LLXMLRPCTransaction::StatusComplete); + mImpl->mTransferStats = response->getTransferStats(); + + // the contents of a buffer array are potentially noncontiguous, so we + // will need to copy them into an contiguous block of memory for XMLRPC. + LLCore::BufferArray *body = response->getBody(); + char * bodydata = new char[body->size()]; + + body->read(0, bodydata, body->size()); + + mImpl->mResponse = XMLRPC_REQUEST_FromXML(bodydata, body->size(), 0); + + delete[] bodydata; + + bool hasError = false; + bool hasFault = false; + int faultCode = 0; + std::string faultString; + + LLXMLRPCValue error(XMLRPC_RequestGetError(mImpl->mResponse)); + if (error.isValid()) + { + hasError = true; + faultCode = error["faultCode"].asInt(); + faultString = error["faultString"].asString(); + } + else if (XMLRPC_ResponseIsFault(mImpl->mResponse)) + { + hasFault = true; + faultCode = XMLRPC_GetResponseFaultCode(mImpl->mResponse); + faultString = XMLRPC_GetResponseFaultString(mImpl->mResponse); + } + + if (hasError || hasFault) + { + mImpl->setStatus(LLXMLRPCTransaction::StatusXMLRPCError); + + LL_WARNS() << "LLXMLRPCTransaction XMLRPC " + << (hasError ? "error " : "fault ") + << faultCode << ": " + << faultString << LL_ENDL; + LL_WARNS() << "LLXMLRPCTransaction request URI: " + << mImpl->mURI << LL_ENDL; + } + +} + +//========================================================================= + LLXMLRPCTransaction::Impl::Impl(const std::string& uri, XMLRPC_REQUEST request, bool useGzip) - : mCurlRequest(0), + : mHttpRequest(0), mStatus(LLXMLRPCTransaction::StatusNotStarted), mURI(uri), - mRequestText(0), +// mRequestText(0), mResponse(0) { init(request, useGzip); @@ -212,10 +321,10 @@ LLXMLRPCTransaction::Impl::Impl(const std::string& uri, LLXMLRPCTransaction::Impl::Impl(const std::string& uri, const std::string& method, LLXMLRPCValue params, bool useGzip) - : mCurlRequest(0), + : mHttpRequest(0), mStatus(LLXMLRPCTransaction::StatusNotStarted), mURI(uri), - mRequestText(0), +// mRequestText(0), mResponse(0) { XMLRPC_REQUEST request = XMLRPC_RequestNew(); @@ -231,127 +340,53 @@ LLXMLRPCTransaction::Impl::Impl(const std::string& uri, XMLRPC_RequestFree(request, 1); } -// _sslCertVerifyCallback -// callback called when a cert verification is requested. -// calls SECAPI to validate the context -int LLXMLRPCTransaction::Impl::_sslCertVerifyCallback(X509_STORE_CTX *ctx, void *param) +void LLXMLRPCTransaction::Impl::init(XMLRPC_REQUEST request, bool useGzip) { - LLXMLRPCTransaction::Impl *transaction = (LLXMLRPCTransaction::Impl *)param; - LLPointer store = gSecAPIHandler->getCertificateStore(transaction->mCertStore); - LLPointer chain = gSecAPIHandler->getCertificateChain(ctx); - LLSD validation_params = LLSD::emptyMap(); - LLURI uri(transaction->mURI); - validation_params[CERT_HOSTNAME] = uri.hostName(); - try - { - // don't validate hostname. Let libcurl do it instead. That way, it'll handle redirects - store->validate(VALIDATION_POLICY_SSL & (~VALIDATION_POLICY_HOSTNAME), chain, validation_params); - } - catch (LLCertValidationTrustException& cert_exception) - { - // this exception is is handled differently than the general cert - // exceptions, as we allow the user to actually add the certificate - // for trust. - // therefore we pass back a different error code - // NOTE: We're currently 'wired' to pass around CURL error codes. This is - // somewhat clumsy, as we may run into errors that do not map directly to curl - // error codes. Should be refactored with login refactoring, perhaps. - transaction->mCurlCode = CURLE_SSL_CACERT; - // set the status directly. set curl status generates error messages and we want - // to use the fixed ones from the exceptions - transaction->setStatus(StatusCURLError, cert_exception.getMessage(), std::string()); - // We should probably have a more generic way of passing information - // back to the error handlers. - transaction->mErrorCert = cert_exception.getCert(); - return 0; - } - catch (LLCertException& cert_exception) - { - transaction->mCurlCode = CURLE_SSL_PEER_CERTIFICATE; - // set the status directly. set curl status generates error messages and we want - // to use the fixed ones from the exceptions - transaction->setStatus(StatusCURLError, cert_exception.getMessage(), std::string()); - transaction->mErrorCert = cert_exception.getCert(); - return 0; - } - catch (...) - { - // any other odd error, we just handle as a connect error. - transaction->mCurlCode = CURLE_SSL_CONNECT_ERROR; - transaction->setCurlStatus(CURLE_SSL_CONNECT_ERROR); - return 0; - } - return 1; -} + LLCore::HttpOptions::ptr_t httpOpts; + LLCore::HttpHeaders::ptr_t httpHeaders; -// _sslCtxFunction -// Callback function called when an SSL Context is created via CURL -// used to configure the context for custom cert validate(<, <#const & xs#>, <#T * #>, <#long #>)tion -// based on SECAPI - -CURLcode LLXMLRPCTransaction::Impl::_sslCtxFunction(CURL * curl, void *sslctx, void *param) -{ - SSL_CTX * ctx = (SSL_CTX *) sslctx; - // disable any default verification for server certs - SSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, NULL); - // set the verification callback. - SSL_CTX_set_cert_verify_callback(ctx, _sslCertVerifyCallback, param); - // the calls are void - return CURLE_OK; - -} -void LLXMLRPCTransaction::Impl::init(XMLRPC_REQUEST request, bool useGzip) -{ - if (!mCurlRequest) + if (!mHttpRequest) { - mCurlRequest = new LLCurlEasyRequest(); + mHttpRequest = LLCore::HttpRequest::ptr_t(new LLCore::HttpRequest); } - if(!mCurlRequest->isValid()) - { - LL_WARNS() << "mCurlRequest is invalid." << LL_ENDL ; - delete mCurlRequest ; - mCurlRequest = NULL ; - return ; - } + // LLRefCounted starts with a 1 ref, so don't add a ref in the smart pointer + httpOpts = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false); - mErrorCert = NULL; + httpOpts->setTimeout(40L); -// mCurlRequest->setopt(CURLOPT_VERBOSE, 1); // useful for debugging - mCurlRequest->setopt(CURLOPT_NOSIGNAL, 1); - mCurlRequest->setWriteCallback(&curlDownloadCallback, (void*)this); - BOOL vefifySSLCert = !gSavedSettings.getBOOL("NoVerifySSLCert"); + bool vefifySSLCert = !gSavedSettings.getBOOL("NoVerifySSLCert"); mCertStore = gSavedSettings.getString("CertStore"); - mCurlRequest->setopt(CURLOPT_SSL_VERIFYPEER, vefifySSLCert); - mCurlRequest->setopt(CURLOPT_SSL_VERIFYHOST, vefifySSLCert ? 2 : 0); - // Be a little impatient about establishing connections. - mCurlRequest->setopt(CURLOPT_CONNECTTIMEOUT, 40L); - mCurlRequest->setSSLCtxCallback(_sslCtxFunction, (void *)this); - /* Setting the DNS cache timeout to -1 disables it completely. - This might help with bug #503 */ - mCurlRequest->setopt(CURLOPT_DNS_CACHE_TIMEOUT, -1); + httpOpts->setSSLVerifyPeer( vefifySSLCert ); + httpOpts->setSSLVerifyHost( vefifySSLCert ? 2 : 0); - mCurlRequest->slist_append(HTTP_OUT_HEADER_CONTENT_TYPE, HTTP_CONTENT_TEXT_XML); + // LLRefCounted starts with a 1 ref, so don't add a ref in the smart pointer + httpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false); - if (useGzip) - { - mCurlRequest->setoptString(CURLOPT_ENCODING, ""); - } + httpHeaders->append(HTTP_OUT_HEADER_CONTENT_TYPE, HTTP_CONTENT_TEXT_XML); + + ///* Setting the DNS cache timeout to -1 disables it completely. + //This might help with bug #503 */ + //httpOpts->setDNSCacheTimeout(-1); + + LLCore::BufferArray::ptr_t body = LLCore::BufferArray::ptr_t(new LLCore::BufferArray(), false); + + // TODO: See if there is a way to serialize to a preallocated buffer I'm + // not fond of the copy here. + int requestSize(0); + char * requestText = XMLRPC_REQUEST_ToXML(request, &requestSize); + + body->append(requestText, requestSize); - mRequestText = XMLRPC_REQUEST_ToXML(request, &mRequestTextSize); - if (mRequestText) - { - mCurlRequest->setoptString(CURLOPT_POSTFIELDS, mRequestText); - mCurlRequest->setopt(CURLOPT_POSTFIELDSIZE, mRequestTextSize); - } - else - { - setStatus(StatusOtherError); - } + XMLRPC_Free(requestText); + + mHandler = LLXMLRPCTransaction::Handler::ptr_t(new Handler( mHttpRequest, this )); + + mPostH = mHttpRequest->requestPost(LLCore::HttpRequest::DEFAULT_POLICY_ID, 0, + mURI, body.get(), httpOpts.get(), httpHeaders.get(), mHandler.get()); - mCurlRequest->sendRequest(mURI); } @@ -362,27 +397,24 @@ LLXMLRPCTransaction::Impl::~Impl() XMLRPC_RequestFree(mResponse, 1); } - if (mRequestText) - { - XMLRPC_Free(mRequestText); - } + //if (mRequestText) + //{ + // XMLRPC_Free(mRequestText); + //} - delete mCurlRequest; - mCurlRequest = NULL ; + //delete mCurlRequest; + //mCurlRequest = NULL ; } bool LLXMLRPCTransaction::Impl::process() { - if(!mCurlRequest || !mCurlRequest->isValid()) + if (!mPostH || !mHttpRequest) { - LL_WARNS() << "transaction failed." << LL_ENDL ; - - delete mCurlRequest ; - mCurlRequest = NULL ; - return true ; //failed, quit. + LL_WARNS() << "transaction failed." << LL_ENDL; + return true; //failed, quit. } - switch(mStatus) + switch (mStatus) { case LLXMLRPCTransaction::StatusComplete: case LLXMLRPCTransaction::StatusCURLError: @@ -391,93 +423,25 @@ bool LLXMLRPCTransaction::Impl::process() { return true; } - + case LLXMLRPCTransaction::StatusNotStarted: { setStatus(LLXMLRPCTransaction::StatusStarted); break; } - + default: - { - // continue onward - } - } - - if(!mCurlRequest->wait()) - { - return false ; + break; } - while(1) - { - CURLcode result; - bool newmsg = mCurlRequest->getResult(&result, &mTransferInfo); - if (newmsg) - { - if (result != CURLE_OK) - { - if ((result != CURLE_SSL_PEER_CERTIFICATE) && - (result != CURLE_SSL_CACERT)) - { - // if we have a curl error that's not already been handled - // (a non cert error), then generate the error message as - // appropriate - setCurlStatus(result); - - LL_WARNS() << "LLXMLRPCTransaction CURL error " - << mCurlCode << ": " << mCurlRequest->getErrorString() << LL_ENDL; - LL_WARNS() << "LLXMLRPCTransaction request URI: " - << mURI << LL_ENDL; - } - - return true; - } - - setStatus(LLXMLRPCTransaction::StatusComplete); - - mResponse = XMLRPC_REQUEST_FromXML( - mResponseText.data(), mResponseText.size(), NULL); - - bool hasError = false; - bool hasFault = false; - int faultCode = 0; - std::string faultString; + LLCore::HttpStatus status = mHttpRequest->update(0); - LLXMLRPCValue error(XMLRPC_RequestGetError(mResponse)); - if (error.isValid()) - { - hasError = true; - faultCode = error["faultCode"].asInt(); - faultString = error["faultString"].asString(); - } - else if (XMLRPC_ResponseIsFault(mResponse)) - { - hasFault = true; - faultCode = XMLRPC_GetResponseFaultCode(mResponse); - faultString = XMLRPC_GetResponseFaultString(mResponse); - } - - if (hasError || hasFault) - { - setStatus(LLXMLRPCTransaction::StatusXMLRPCError); - - LL_WARNS() << "LLXMLRPCTransaction XMLRPC " - << (hasError ? "error " : "fault ") - << faultCode << ": " - << faultString << LL_ENDL; - LL_WARNS() << "LLXMLRPCTransaction request URI: " - << mURI << LL_ENDL; - } - - return true; - } - else - { - break; // done - } + status = mHttpRequest->getStatus(); + if (!status) + { + return false; } - + return false; } @@ -516,64 +480,49 @@ void LLXMLRPCTransaction::Impl::setStatus(EStatus status, } } -void LLXMLRPCTransaction::Impl::setCurlStatus(CURLcode code) +void LLXMLRPCTransaction::Impl::setHttpStatus(const LLCore::HttpStatus &status) { + CURLcode code = static_cast(status.toULong()); std::string message; std::string uri = "http://secondlife.com/community/support.php"; - + switch (code) { - case CURLE_COULDNT_RESOLVE_HOST: - message = - "DNS could not resolve the host name.\n" - "Please verify that you can connect to the www.secondlife.com\n" - "web site. If you can, but continue to receive this error,\n" - "please go to the support section and report this problem."; - break; - - case CURLE_SSL_PEER_CERTIFICATE: - message = - "The login server couldn't verify itself via SSL.\n" - "If you continue to receive this error, please go\n" - "to the Support section of the SecondLife.com web site\n" - "and report the problem."; - break; - - case CURLE_SSL_CACERT: - case CURLE_SSL_CONNECT_ERROR: - message = - "Often this means that your computer\'s clock is set incorrectly.\n" - "Please go to Control Panels and make sure the time and date\n" - "are set correctly.\n" - "Also check that your network and firewall are set up correctly.\n" - "If you continue to receive this error, please go\n" - "to the Support section of the SecondLife.com web site\n" - "and report the problem."; - break; - - default: - break; + case CURLE_COULDNT_RESOLVE_HOST: + message = + "DNS could not resolve the host name.\n" + "Please verify that you can connect to the www.secondlife.com\n" + "web site. If you can, but continue to receive this error,\n" + "please go to the support section and report this problem."; + break; + + case CURLE_SSL_PEER_CERTIFICATE: + message = + "The login server couldn't verify itself via SSL.\n" + "If you continue to receive this error, please go\n" + "to the Support section of the SecondLife.com web site\n" + "and report the problem."; + break; + + case CURLE_SSL_CACERT: + case CURLE_SSL_CONNECT_ERROR: + message = + "Often this means that your computer\'s clock is set incorrectly.\n" + "Please go to Control Panels and make sure the time and date\n" + "are set correctly.\n" + "Also check that your network and firewall are set up correctly.\n" + "If you continue to receive this error, please go\n" + "to the Support section of the SecondLife.com web site\n" + "and report the problem."; + break; + + default: + break; } - + mCurlCode = code; setStatus(StatusCURLError, message, uri); -} - -size_t LLXMLRPCTransaction::Impl::curlDownloadCallback( - char* data, size_t size, size_t nmemb, void* user_data) -{ - Impl& impl(*(Impl*)user_data); - - size_t n = size * nmemb; - impl.mResponseText.append(data, n); - - if (impl.mStatus == LLXMLRPCTransaction::StatusStarted) - { - impl.setStatus(LLXMLRPCTransaction::StatusDownloading); - } - - return n; } @@ -645,11 +594,11 @@ F64 LLXMLRPCTransaction::transferRate() return 0.0L; } - double rate_bits_per_sec = impl.mTransferInfo.mSpeedDownload * 8.0; + double rate_bits_per_sec = impl.mTransferStats->mSpeedDownload * 8.0; LL_INFOS("AppInit") << "Buffer size: " << impl.mResponseText.size() << " B" << LL_ENDL; - LL_DEBUGS("AppInit") << "Transfer size: " << impl.mTransferInfo.mSizeDownload << " B" << LL_ENDL; - LL_DEBUGS("AppInit") << "Transfer time: " << impl.mTransferInfo.mTotalTime << " s" << LL_ENDL; + LL_DEBUGS("AppInit") << "Transfer size: " << impl.mTransferStats->mSizeDownload << " B" << LL_ENDL; + LL_DEBUGS("AppInit") << "Transfer time: " << impl.mTransferStats->mTotalTime << " s" << LL_ENDL; LL_INFOS("AppInit") << "Transfer rate: " << rate_bits_per_sec / 1000.0 << " Kb/s" << LL_ENDL; return rate_bits_per_sec; diff --git a/indra/newview/llxmlrpctransaction.h b/indra/newview/llxmlrpctransaction.h index f2589c7f41..3a1c9c82b7 100755 --- a/indra/newview/llxmlrpctransaction.h +++ b/indra/newview/llxmlrpctransaction.h @@ -81,7 +81,7 @@ private: class LLXMLRPCTransaction - // an asynchronous request and respones via XML-RPC + // an asynchronous request and responses via XML-RPC { public: LLXMLRPCTransaction(const std::string& uri, @@ -127,7 +127,9 @@ public: // only valid if StsatusComplete, otherwise 0.0 private: + class Handler; class Impl; + Impl& impl; }; -- cgit v1.2.3 From 6b8c814df3141fa705b9921ba0a73aeaa3fe63b6 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 19 Mar 2015 17:01:21 -0700 Subject: Adding new HTTP handling for material manager. --- indra/llcorehttp/bufferarray.h | 1 + indra/llcorehttp/httpheaders.cpp | 2 +- indra/llcorehttp/httpheaders.h | 8 ++- indra/llcorehttp/httpresponse.cpp | 4 ++ indra/llcorehttp/httpresponse.h | 4 ++ indra/llmessage/CMakeLists.txt | 2 + indra/llmessage/llcorehttputil.cpp | 26 +++++++ indra/llmessage/llcorehttputil.h | 25 +++++++ indra/llmessage/llcurl.h | 99 --------------------------- indra/llmessage/llhttpsdhandler.cpp | 82 ++++++++++++++++++++++ indra/llmessage/llhttpsdhandler.h | 56 +++++++++++++++ indra/newview/llmaterialmgr.cpp | 124 ++++++++++++++++++++++++---------- indra/newview/llmaterialmgr.h | 26 +++---- indra/newview/llxmlrpctransaction.cpp | 6 +- 14 files changed, 314 insertions(+), 151 deletions(-) create mode 100644 indra/llmessage/llhttpsdhandler.cpp create mode 100644 indra/llmessage/llhttpsdhandler.h (limited to 'indra') diff --git a/indra/llcorehttp/bufferarray.h b/indra/llcorehttp/bufferarray.h index 9c2b991de6..1da807b0a6 100755 --- a/indra/llcorehttp/bufferarray.h +++ b/indra/llcorehttp/bufferarray.h @@ -131,6 +131,7 @@ protected: container_t mBlocks; size_t mLen; + }; // end class BufferArray diff --git a/indra/llcorehttp/httpheaders.cpp b/indra/llcorehttp/httpheaders.cpp index 23ebea361c..73c92c8f10 100755 --- a/indra/llcorehttp/httpheaders.cpp +++ b/indra/llcorehttp/httpheaders.cpp @@ -105,7 +105,7 @@ void HttpHeaders::appendNormal(const char * header, size_t size) // Find from end to simulate a tradition of using single-valued // std::map for this in the past. -const std::string * HttpHeaders::find(const char * name) const +const std::string * HttpHeaders::find(const std::string &name) const { const_reverse_iterator iend(rend()); for (const_reverse_iterator iter(rbegin()); iend != iter; ++iter) diff --git a/indra/llcorehttp/httpheaders.h b/indra/llcorehttp/httpheaders.h index c89d6af222..41832c4931 100755 --- a/indra/llcorehttp/httpheaders.h +++ b/indra/llcorehttp/httpheaders.h @@ -146,8 +146,12 @@ public: // a pointer to a std::string in the container. // Pointer is valid only for the lifetime of // the container or until container is modifed. - // - const std::string * find(const char * name) const; + + const std::string * find(const std::string &name) const; + const std::string * find(const char * name) const + { + return find(std::string(name)); + } // Count of headers currently in the list. size_type size() const diff --git a/indra/llcorehttp/httpresponse.cpp b/indra/llcorehttp/httpresponse.cpp index c974395b0a..87e3426415 100755 --- a/indra/llcorehttp/httpresponse.cpp +++ b/indra/llcorehttp/httpresponse.cpp @@ -89,5 +89,9 @@ void HttpResponse::setHeaders(HttpHeaders * headers) mHeaders = headers; } +size_t HttpResponse::getBodySize() const +{ + return (mBufferArray) ? mBufferArray->size() : 0; +} } // end namespace LLCore diff --git a/indra/llcorehttp/httpresponse.h b/indra/llcorehttp/httpresponse.h index 01e9dd2bc6..c6b470ee3f 100755 --- a/indra/llcorehttp/httpresponse.h +++ b/indra/llcorehttp/httpresponse.h @@ -104,6 +104,10 @@ public: return mBufferArray; } + /// Safely get the size of the body buffer. If the body buffer is missing + /// return 0 as the size. + size_t getBodySize() const; + /// Set the response data in the instance. Will drop the reference /// count to any existing data and increment the count of that passed /// in. It is legal to set the data to NULL. diff --git a/indra/llmessage/CMakeLists.txt b/indra/llmessage/CMakeLists.txt index 40eddcb0ab..c5b6024b89 100755 --- a/indra/llmessage/CMakeLists.txt +++ b/indra/llmessage/CMakeLists.txt @@ -49,6 +49,7 @@ set(llmessage_SOURCE_FILES llhttpclientadapter.cpp llhttpconstants.cpp llhttpnode.cpp + llhttpsdhandler.cpp llhttpsender.cpp llinstantmessage.cpp lliobuffer.cpp @@ -144,6 +145,7 @@ set(llmessage_HEADER_FILES llhttpconstants.h llhttpnode.h llhttpnodeadapter.h + llhttpsdhandler.h llhttpsender.h llinstantmessage.h llinvite.h diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index ee80b0fd94..1a5a6fc75f 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -88,6 +88,32 @@ HttpHandle requestPostWithLLSD(HttpRequest * request, return handle; } +HttpHandle requestPutWithLLSD(HttpRequest * request, + HttpRequest::policy_t policy_id, + HttpRequest::priority_t priority, + const std::string & url, + const LLSD & body, + HttpOptions * options, + HttpHeaders * headers, + HttpHandler * handler) +{ + HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); + + BufferArray * ba = new BufferArray(); + BufferArrayStream bas(ba); + LLSDSerialize::toXML(body, bas); + + handle = request->requestPut(policy_id, + priority, + url, + ba, + options, + headers, + handler); + ba->release(); + return handle; +} + std::string responseToString(LLCore::HttpResponse * response) { diff --git a/indra/llmessage/llcorehttputil.h b/indra/llmessage/llcorehttputil.h index d40172bc7a..7c5a5aea61 100644 --- a/indra/llmessage/llcorehttputil.h +++ b/indra/llmessage/llcorehttputil.h @@ -109,6 +109,31 @@ LLCore::HttpHandle requestPostWithLLSD(LLCore::HttpRequest * request, LLCore::HttpHeaders * headers, LLCore::HttpHandler * handler); +/// Issue a standard HttpRequest::requestPut() call but using +/// and LLSD object as the request body. Conventions are the +/// same as with that method. Caller is expected to provide +/// an HttpHeaders object with a correct 'Content-Type:' header. +/// One will not be provided by this call. +/// +/// @return If request is successfully issued, the +/// HttpHandle representing the request. +/// On error, LLCORE_HTTP_HANDLE_INVALID +/// is returned and caller can fetch detailed +/// status with the getStatus() method on the +/// request object. In case of error, no +/// request is queued and caller may need to +/// perform additional cleanup such as freeing +/// a now-useless HttpHandler object. +/// +LLCore::HttpHandle requestPutWithLLSD(LLCore::HttpRequest * request, + LLCore::HttpRequest::policy_t policy_id, + LLCore::HttpRequest::priority_t priority, + const std::string & url, + const LLSD & body, + LLCore::HttpOptions * options, + LLCore::HttpHeaders * headers, + LLCore::HttpHandler * handler); + } // end namespace LLCoreHttpUtil diff --git a/indra/llmessage/llcurl.h b/indra/llmessage/llcurl.h index 295e9c9fe5..06b3ce45e1 100755 --- a/indra/llmessage/llcurl.h +++ b/indra/llmessage/llcurl.h @@ -309,7 +309,6 @@ private: static void deleteAllFreeHandles(); }; -#if 1 class LLCurl::Multi { LOG_CLASS(Multi); @@ -380,7 +379,6 @@ private: LLFrameTimer mIdleTimer ; F32 mIdleTimeOut; }; -#endif class LLCurlThread : public LLQueuedThread { @@ -419,103 +417,6 @@ private: void cleanupMulti(LLCurl::Multi* multi) ; } ; -#if 0 -class LLCurlRequest -{ -public: - typedef std::vector headers_t; - - LLCurlRequest(); - ~LLCurlRequest(); - - void get(const std::string& url, LLCurl::ResponderPtr responder); - bool getByteRange(const std::string& url, const headers_t& headers, S32 offset, S32 length, LLCurl::ResponderPtr responder); - bool post(const std::string& url, const headers_t& headers, const LLSD& data, LLCurl::ResponderPtr responder, S32 time_out = 0); - bool post(const std::string& url, const headers_t& headers, const std::string& data, LLCurl::ResponderPtr responder, S32 time_out = 0); - - S32 process(); - S32 getQueued(); - -private: - void addMulti(); - LLCurl::Easy* allocEasy(); - bool addEasy(LLCurl::Easy* easy); - -private: - typedef std::set curlmulti_set_t; - curlmulti_set_t mMultiSet; - LLCurl::Multi* mActiveMulti; - S32 mActiveRequestCount; - BOOL mProcessing; -}; -#endif - -#if 0 -//for texture fetch only -class LLCurlTextureRequest : public LLCurlRequest -{ -public: - LLCurlTextureRequest(S32 concurrency); - ~LLCurlTextureRequest(); - - U32 getByteRange(const std::string& url, const headers_t& headers, S32 offset, S32 length, U32 pri, LLCurl::ResponderPtr responder, F32 delay_time = -1.f); - void nextRequests(); - void completeRequest(S32 received_bytes); - - void updatePriority(U32 handle, U32 pri); - void removeRequest(U32 handle); - - U32 getTotalReceivedBits(); - U32 getTotalIssuedRequests(); - S32 getNumRequests(); - bool isWaiting(U32 handle); - -private: - LLMutex mMutex; - S32 mConcurrency; - S32 mInQueue; //request currently in queue. - U32 mHandleCounter; - U32 mTotalIssuedRequests; - U32 mTotalReceivedBits; - - typedef struct _request_t - { - _request_t(U32 handle, const std::string& url, const headers_t& headers, S32 offset, S32 length, U32 pri, LLCurl::ResponderPtr responder) : - mHandle(handle), mUrl(url), mHeaders(headers), mOffset(offset), mLength(length), mPriority(pri), mResponder(responder), mStartTime(0.f) - {} - - U32 mHandle; - std::string mUrl; - LLCurlRequest::headers_t mHeaders; - S32 mOffset; - S32 mLength; - LLCurl::ResponderPtr mResponder; - U32 mPriority; - F32 mStartTime; //start time to issue this request - } request_t; - - struct request_compare - { - bool operator()(const request_t* lhs, const request_t* rhs) const - { - if(lhs->mPriority != rhs->mPriority) - { - return lhs->mPriority > rhs->mPriority; // higher priority in front of queue (set) - } - else - { - return (U32)lhs < (U32)rhs; - } - } - }; - - typedef std::set req_queue_t; - req_queue_t mCachedRequests; - std::map mRequestMap; - - LLFrameTimer mGlobalTimer; -}; -#endif class LLCurlEasyRequest { diff --git a/indra/llmessage/llhttpsdhandler.cpp b/indra/llmessage/llhttpsdhandler.cpp new file mode 100644 index 0000000000..aa9801cebc --- /dev/null +++ b/indra/llmessage/llhttpsdhandler.cpp @@ -0,0 +1,82 @@ +/** +* @file llhttpsdhandler.h +* @brief Public-facing declarations for the HttpHandler class +* +* $LicenseInfo:firstyear=2012&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2012, Linden Research, Inc. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; +* version 2.1 of the License only. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA +* $/LicenseInfo$ +*/ + +#include "linden_common.h" +#include "llhttpconstants.h" + +#include "llhttpsdhandler.h" +#include "httpresponse.h" +#include "httpheaders.h" +#include "llsd.h" +#include "llsdserialize.h" +#include "bufferstream.h" +#include "llcorehttputil.h" + +//======================================================================== +LLHttpSDHandler::LLHttpSDHandler(const LLURI &uri): + mUri(uri) +{ + +} + +void LLHttpSDHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpResponse * response) +{ + LLCore::HttpStatus status = response->getStatus(); + + if (!status) + { + this->onFailure(response, status); + } + else + { + LLSD resplsd; + const bool emit_parse_errors = false; + + bool parsed = !((response->getBodySize() == 0) || + !LLCoreHttpUtil::responseToLLSD(response, emit_parse_errors, resplsd)); + + if (!parsed) + { + // Only emit a warning if we failed to parse when 'content-type' == 'application/llsd+xml' + LLCore::HttpHeaders::ptr_t headers(response->getHeaders()); + const std::string *contentType = (headers) ? headers->find(HTTP_IN_HEADER_CONTENT_TYPE) : NULL; + + if (contentType && (HTTP_CONTENT_LLSD_XML == *contentType)) + { + std::string thebody = LLCoreHttpUtil::responseToString(response); + + LL_WARNS() << "Failed to deserialize . " << getUri() << " [status:" << response->getStatus().toString() << "] " + << " body: " << thebody << LL_ENDL; + } + } + + this->onSuccess(response, resplsd); + } + + // The handler must destroy itself when it is done. + delete this; +} + diff --git a/indra/llmessage/llhttpsdhandler.h b/indra/llmessage/llhttpsdhandler.h new file mode 100644 index 0000000000..7b7da61b3c --- /dev/null +++ b/indra/llmessage/llhttpsdhandler.h @@ -0,0 +1,56 @@ +/** +* @file llhttpsdhandler.h +* @brief Public-facing declarations for the HttpHandler class +* +* $LicenseInfo:firstyear=2012&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2012, Linden Research, Inc. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; +* version 2.1 of the License only. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA +* $/LicenseInfo$ +*/ + +#ifndef _LLHTTPSDHANDLER_H_ +#define _LLHTTPSDHANDLER_H_ +#include "httpcommon.h" +#include "httphandler.h" +#include "lluri.h" + +/// +/// +class LLHttpSDHandler : public LLCore::HttpHandler +{ +public: + LLHttpSDHandler(const LLURI &uri); + + virtual void onCompleted(LLCore::HttpHandle handle, LLCore::HttpResponse * response); + + inline const LLURI &getUri() const + { + return mUri; + } + +protected: + virtual void onSuccess(LLCore::HttpResponse * response, LLSD &content) = 0; + virtual void onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status) = 0; + +private: + LLURI mUri; +}; + + +#endif \ No newline at end of file diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index a1f6a01aa0..f43efd75b8 100755 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -36,6 +36,10 @@ #include "llviewerobjectlist.h" #include "llviewerregion.h" #include "llworld.h" +#include "llhttpsdhandler.h" +#include "httpcommon.h" +#include "httpheaders.h" +#include "llcorehttputil.h" /** * Materials cap parameters @@ -59,56 +63,51 @@ #define MATERIALS_PUT_THROTTLE_SECS 1.f #define MATERIALS_PUT_MAX_ENTRIES 50 -/** - * LLMaterialsResponder helper class - */ -class LLMaterialsResponder : public LLHTTPClient::Responder + +class LLMaterialHttpHandler : public LLHttpSDHandler { -public: - typedef boost::function CallbackFunction; +public: + typedef boost::function CallbackFunction; + typedef boost::shared_ptr ptr_t; + + LLMaterialHttpHandler(const std::string& method, const std::string& capabilityURL, CallbackFunction cback); - LLMaterialsResponder(const std::string& pMethod, const std::string& pCapabilityURL, CallbackFunction pCallback); - virtual ~LLMaterialsResponder(); + virtual ~LLMaterialHttpHandler(); - virtual void httpSuccess(); - virtual void httpFailure(); +protected: + virtual void onSuccess(LLCore::HttpResponse * response, LLSD &content); + virtual void onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status); private: std::string mMethod; - std::string mCapabilityURL; CallbackFunction mCallback; }; -LLMaterialsResponder::LLMaterialsResponder(const std::string& pMethod, const std::string& pCapabilityURL, CallbackFunction pCallback) - : LLHTTPClient::Responder() - , mMethod(pMethod) - , mCapabilityURL(pCapabilityURL) - , mCallback(pCallback) +LLMaterialHttpHandler::LLMaterialHttpHandler(const std::string& method, const std::string& capabilityURL, CallbackFunction cback): + LLHttpSDHandler(capabilityURL), + mMethod(method), + mCallback(cback) { + } -LLMaterialsResponder::~LLMaterialsResponder() +LLMaterialHttpHandler::~LLMaterialHttpHandler() { } -void LLMaterialsResponder::httpSuccess() +void LLMaterialHttpHandler::onSuccess(LLCore::HttpResponse * response, LLSD &content) { - const LLSD& pContent = getContent(); - LL_DEBUGS("Materials") << LL_ENDL; - mCallback(true, pContent); + mCallback(true, content); } -void LLMaterialsResponder::httpFailure() +void LLMaterialHttpHandler::onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status) { - U32 pStatus = (U32) getStatus(); - const std::string& pReason = getReason(); - LL_WARNS("Materials") << "\n--------------------------------------------------------------------------\n" - << mMethod << " Error[" << pStatus << "] cannot access cap '" << MATERIALS_CAPABILITY_NAME - << "'\n with url '" << mCapabilityURL << "' because " << pReason + << mMethod << " Error[" << status.toULong() << "] cannot access cap '" << MATERIALS_CAPABILITY_NAME + << "'\n with url '" << getUri() << "' because " << status.toString() << "\n--------------------------------------------------------------------------" << LL_ENDL; @@ -116,12 +115,16 @@ void LLMaterialsResponder::httpFailure() mCallback(false, emptyResult); } + + /** * LLMaterialMgr class */ LLMaterialMgr::LLMaterialMgr() { + mRequest = LLCore::HttpRequest::ptr_t(new LLCore::HttpRequest()); + mMaterials.insert(std::pair(LLMaterialID::null, LLMaterialPtr(NULL))); gIdleCallbacks.addFunction(&LLMaterialMgr::onIdle, NULL); LLWorld::instance().setRegionRemovedCallback(boost::bind(&LLMaterialMgr::onRegionRemoved, this, _1)); @@ -554,6 +557,8 @@ void LLMaterialMgr::onIdle(void*) { instancep->processPutQueue(); } + + instancep->mRequest->update(0L); } void LLMaterialMgr::processGetQueue() @@ -629,10 +634,28 @@ void LLMaterialMgr::processGetQueue() LLSD postData = LLSD::emptyMap(); postData[MATERIALS_CAP_ZIP_FIELD] = materialBinary; - LLHTTPClient::ResponderPtr materialsResponder = new LLMaterialsResponder("POST", capURL, boost::bind(&LLMaterialMgr::onGetResponse, this, _1, _2, region_id)); - LL_DEBUGS("Materials") << "POSTing to region '" << regionp->getName() << "' at '"<< capURL << " for " << materialsData.size() << " materials." + LLMaterialHttpHandler * handler = + new LLMaterialHttpHandler("POST", capURL, + boost::bind(&LLMaterialMgr::onGetResponse, this, _1, _2, region_id) + ); + + LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false); + + LL_DEBUGS("Materials") << "POSTing to region '" << regionp->getName() << "' at '" << capURL << " for " << materialsData.size() << " materials." << "\ndata: " << ll_pretty_print_sd(materialsData) << LL_ENDL; - LLHTTPClient::post(capURL, postData, materialsResponder); + + LLCore::HttpHandle handle = LLCoreHttpUtil::requestPutWithLLSD(mRequest.get(), + LLCore::HttpRequest::DEFAULT_POLICY_ID, 0, capURL, + postData, NULL, headers.get(), handler); + + if (handle == LLCORE_HTTP_HANDLE_INVALID) + { + delete handler; + LLCore::HttpStatus status = mRequest->getStatus(); + LL_ERRS("Meterials") << "Failed to execute material POST. Status = " << + status.toULong() << "\"" << status.toString() << "\"" << LL_ENDL; + } + regionp->resetMaterialsCapThrottle(); } } @@ -667,8 +690,24 @@ void LLMaterialMgr::processGetAllQueue() } LL_DEBUGS("Materials") << "GET all for region " << region_id << "url " << capURL << LL_ENDL; - LLHTTPClient::ResponderPtr materialsResponder = new LLMaterialsResponder("GET", capURL, boost::bind(&LLMaterialMgr::onGetAllResponse, this, _1, _2, *itRegion)); - LLHTTPClient::get(capURL, materialsResponder); + LLMaterialHttpHandler *handler = + new LLMaterialHttpHandler("GET", capURL, + boost::bind(&LLMaterialMgr::onGetAllResponse, this, _1, _2, *itRegion) + ); + + LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false); + + LLCore::HttpHandle handle = mRequest->requestGet(LLCore::HttpRequest::DEFAULT_POLICY_ID, 0, + capURL, NULL, headers.get(), handler); + + if (handle == LLCORE_HTTP_HANDLE_INVALID) + { + delete handler; + LLCore::HttpStatus status = mRequest->getStatus(); + LL_ERRS("Meterials") << "Failed to execute material GET. Status = " << + status.toULong() << "\"" << status.toString() << "\"" << LL_ENDL; + } + regionp->resetMaterialsCapThrottle(); mGetAllPending.insert(std::pair(region_id, LLFrameTimer::getTotalSeconds())); mGetAllQueue.erase(itRegion); // Invalidates region_id @@ -755,8 +794,25 @@ void LLMaterialMgr::processPutQueue() putData[MATERIALS_CAP_ZIP_FIELD] = materialBinary; LL_DEBUGS("Materials") << "put for " << itRequest->second.size() << " faces to region " << itRequest->first->getName() << LL_ENDL; - LLHTTPClient::ResponderPtr materialsResponder = new LLMaterialsResponder("PUT", capURL, boost::bind(&LLMaterialMgr::onPutResponse, this, _1, _2)); - LLHTTPClient::put(capURL, putData, materialsResponder); + + LLMaterialHttpHandler * handler = + new LLMaterialHttpHandler("PUT", capURL, + boost::bind(&LLMaterialMgr::onPutResponse, this, _1, _2) + ); + + LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false); + + LLCore::HttpHandle handle = LLCoreHttpUtil::requestPutWithLLSD(mRequest.get(), LLCore::HttpRequest::DEFAULT_POLICY_ID, 0, + capURL, putData, NULL, headers.get(), handler); + + if (handle == LLCORE_HTTP_HANDLE_INVALID) + { + delete handler; + LLCore::HttpStatus status = mRequest->getStatus(); + LL_ERRS("Meterials") << "Failed to execute material PUT. Status = " << + status.toULong() << "\"" << status.toString() << "\"" << LL_ENDL; + } + regionp->resetMaterialsCapThrottle(); } else diff --git a/indra/newview/llmaterialmgr.h b/indra/newview/llmaterialmgr.h index e83f1f4e01..0904c9b2c4 100644 --- a/indra/newview/llmaterialmgr.h +++ b/indra/newview/llmaterialmgr.h @@ -30,6 +30,7 @@ #include "llmaterial.h" #include "llmaterialid.h" #include "llsingleton.h" +#include "httprequest.h" class LLViewerRegion; @@ -56,7 +57,7 @@ public: void put(const LLUUID& object_id, const U8 te, const LLMaterial& material); void remove(const LLUUID& object_id, const U8 te); -protected: +private: void clearGetQueues(const LLUUID& region_id); bool isGetPending(const LLUUID& region_id, const LLMaterialID& material_id) const; bool isGetAllPending(const LLUUID& region_id) const; @@ -72,14 +73,15 @@ protected: void onPutResponse(bool success, const LLSD& content); void onRegionRemoved(LLViewerRegion* regionp); -protected: +private: typedef std::set material_queue_t; typedef std::map get_queue_t; - get_queue_t mGetQueue; typedef std::pair pending_material_t; typedef std::map get_pending_map_t; - get_pending_map_t mGetPending; typedef std::map get_callback_map_t; + + get_queue_t mGetQueue; + get_pending_map_t mGetPending; get_callback_map_t mGetCallbacks; // struct for TE-specific material ID query @@ -109,22 +111,22 @@ protected: }; typedef boost::unordered_map get_callback_te_map_t; - get_callback_te_map_t mGetTECallbacks; - typedef std::set getall_queue_t; - getall_queue_t mGetAllQueue; - getall_queue_t mGetAllRequested; typedef std::map getall_pending_map_t; - getall_pending_map_t mGetAllPending; typedef std::map getall_callback_map_t; - getall_callback_map_t mGetAllCallbacks; - typedef std::map facematerial_map_t; typedef std::map put_queue_t; - put_queue_t mPutQueue; + get_callback_te_map_t mGetTECallbacks; + getall_queue_t mGetAllQueue; + getall_queue_t mGetAllRequested; + getall_pending_map_t mGetAllPending; + getall_callback_map_t mGetAllCallbacks; + put_queue_t mPutQueue; material_map_t mMaterials; + LLCore::HttpRequest::ptr_t mRequest; + U32 getMaxEntries(const LLViewerRegion* regionp); }; diff --git a/indra/newview/llxmlrpctransaction.cpp b/indra/newview/llxmlrpctransaction.cpp index e4e63afa16..2270b840a0 100755 --- a/indra/newview/llxmlrpctransaction.cpp +++ b/indra/newview/llxmlrpctransaction.cpp @@ -312,7 +312,6 @@ LLXMLRPCTransaction::Impl::Impl(const std::string& uri, : mHttpRequest(0), mStatus(LLXMLRPCTransaction::StatusNotStarted), mURI(uri), -// mRequestText(0), mResponse(0) { init(request, useGzip); @@ -324,7 +323,6 @@ LLXMLRPCTransaction::Impl::Impl(const std::string& uri, : mHttpRequest(0), mStatus(LLXMLRPCTransaction::StatusNotStarted), mURI(uri), -// mRequestText(0), mResponse(0) { XMLRPC_REQUEST request = XMLRPC_RequestNew(); @@ -485,12 +483,14 @@ void LLXMLRPCTransaction::Impl::setHttpStatus(const LLCore::HttpStatus &status) CURLcode code = static_cast(status.toULong()); std::string message; std::string uri = "http://secondlife.com/community/support.php"; + LLURI failuri(mURI); + switch (code) { case CURLE_COULDNT_RESOLVE_HOST: message = - "DNS could not resolve the host name.\n" + std::string("DNS could not resolve the host name(") + failuri.hostName() + ").\n" "Please verify that you can connect to the www.secondlife.com\n" "web site. If you can, but continue to receive this error,\n" "please go to the support section and report this problem."; -- cgit v1.2.3 From 9d676ce5b97d7ce09630d7d6ab8abd562b958cae Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 20 Mar 2015 13:16:25 -0700 Subject: Clean up and use policies for Material transfer. --- indra/llcorehttp/_httpinternal.h | 5 ++-- indra/llmessage/llcorehttputil.cpp | 25 +++++++++++++++++ indra/llmessage/llcorehttputil.h | 18 +++++++++++++ indra/newview/llappcorehttp.cpp | 7 +++++ indra/newview/llappcorehttp.h | 11 ++++++++ indra/newview/llmaterialmgr.cpp | 55 +++++++++++++++++++++++--------------- indra/newview/llmaterialmgr.h | 45 ++++++++++++++++++------------- 7 files changed, 124 insertions(+), 42 deletions(-) (limited to 'indra') diff --git a/indra/llcorehttp/_httpinternal.h b/indra/llcorehttp/_httpinternal.h index a2a60ca056..79c89d6c92 100755 --- a/indra/llcorehttp/_httpinternal.h +++ b/indra/llcorehttp/_httpinternal.h @@ -104,8 +104,9 @@ namespace LLCore { // Maxium number of policy classes that can be defined. -// *TODO: Currently limited to the default class + 1, extend. -const int HTTP_POLICY_CLASS_LIMIT = 8; +// *TODO: Currently limited to the default class + 1, extend. +// (TSN: should this be more dynamically sized. Is there a reason to hard limit the number of policies?) +const int HTTP_POLICY_CLASS_LIMIT = 32; // Debug/informational tracing. Used both // as a global option and in per-request traces. diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index 1a5a6fc75f..366a0b9460 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -88,6 +88,19 @@ HttpHandle requestPostWithLLSD(HttpRequest * request, return handle; } +HttpHandle requestPostWithLLSD(HttpRequest::ptr_t & request, + HttpRequest::policy_t policy_id, + HttpRequest::priority_t priority, + const std::string & url, + const LLSD & body, + HttpOptions::ptr_t & options, + HttpHeaders::ptr_t & headers, + HttpHandler * handler) +{ + return requestPostWithLLSD(request.get(), policy_id, priority, + url, body, options.get(), headers.get(), handler); +} + HttpHandle requestPutWithLLSD(HttpRequest * request, HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, @@ -114,6 +127,18 @@ HttpHandle requestPutWithLLSD(HttpRequest * request, return handle; } +HttpHandle requestPutWithLLSD(HttpRequest::ptr_t & request, + HttpRequest::policy_t policy_id, + HttpRequest::priority_t priority, + const std::string & url, + const LLSD & body, + HttpOptions::ptr_t & options, + HttpHeaders::ptr_t & headers, + HttpHandler * handler) +{ + return requestPutWithLLSD(request.get(), policy_id, priority, + url, body, options.get(), headers.get(), handler); +} std::string responseToString(LLCore::HttpResponse * response) { diff --git a/indra/llmessage/llcorehttputil.h b/indra/llmessage/llcorehttputil.h index 7c5a5aea61..8e26f413fe 100644 --- a/indra/llmessage/llcorehttputil.h +++ b/indra/llmessage/llcorehttputil.h @@ -109,6 +109,15 @@ LLCore::HttpHandle requestPostWithLLSD(LLCore::HttpRequest * request, LLCore::HttpHeaders * headers, LLCore::HttpHandler * handler); +LLCore::HttpHandle requestPostWithLLSD(LLCore::HttpRequest::ptr_t & request, + LLCore::HttpRequest::policy_t policy_id, + LLCore::HttpRequest::priority_t priority, + const std::string & url, + const LLSD & body, + LLCore::HttpOptions::ptr_t & options, + LLCore::HttpHeaders::ptr_t & headers, + LLCore::HttpHandler * handler); + /// Issue a standard HttpRequest::requestPut() call but using /// and LLSD object as the request body. Conventions are the /// same as with that method. Caller is expected to provide @@ -134,6 +143,15 @@ LLCore::HttpHandle requestPutWithLLSD(LLCore::HttpRequest * request, LLCore::HttpHeaders * headers, LLCore::HttpHandler * handler); +LLCore::HttpHandle requestPutWithLLSD(LLCore::HttpRequest::ptr_t & request, + LLCore::HttpRequest::policy_t policy_id, + LLCore::HttpRequest::priority_t priority, + const std::string & url, + const LLSD & body, + LLCore::HttpOptions::ptr_t & options, + LLCore::HttpHeaders::ptr_t & headers, + LLCore::HttpHandler * handler); + } // end namespace LLCoreHttpUtil diff --git a/indra/newview/llappcorehttp.cpp b/indra/newview/llappcorehttp.cpp index dd39b9a959..420d37369f 100755 --- a/indra/newview/llappcorehttp.cpp +++ b/indra/newview/llappcorehttp.cpp @@ -97,6 +97,11 @@ static const struct 4, 1, 4, 0, false, "", "inventory" + }, + { // AP_MATERIALS + 2, 1, 8, 0, false, + "RenderMaterials", + "material manager requests" } }; @@ -195,6 +200,8 @@ void LLAppCoreHttp::init() } mHttpClasses[app_policy].mPolicy = LLCore::HttpRequest::createPolicyClass(); + // We have run out of available HTTP policies. Adjust HTTP_POLICY_CLASS_LIMIT in _httpinternal.h + llassert(mHttpClasses[app_policy].mPolicy != LLCore::HttpRequest::INVALID_POLICY_ID); if (! mHttpClasses[app_policy].mPolicy) { // Use default policy (but don't accidentally modify default) diff --git a/indra/newview/llappcorehttp.h b/indra/newview/llappcorehttp.h index 9616354093..b636c3b43c 100755 --- a/indra/newview/llappcorehttp.h +++ b/indra/newview/llappcorehttp.h @@ -164,6 +164,17 @@ public: /// Pipelined: no AP_INVENTORY, AP_REPORTING = AP_INVENTORY, // Piggy-back on inventory + + /// Material resource requests and puts. + /// + /// Destination: simhost:12043 + /// Protocol: https: + /// Transfer size: KB + /// Long poll: no + /// Concurrency: low + /// Request rate: low + /// Pipelined: no + AP_MATERIALS, AP_COUNT // Must be last }; diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index f43efd75b8..b4ebe4adb1 100755 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -38,7 +38,6 @@ #include "llworld.h" #include "llhttpsdhandler.h" #include "httpcommon.h" -#include "httpheaders.h" #include "llcorehttputil.h" /** @@ -120,10 +119,29 @@ void LLMaterialHttpHandler::onFailure(LLCore::HttpResponse * response, LLCore::H /** * LLMaterialMgr class */ - -LLMaterialMgr::LLMaterialMgr() +LLMaterialMgr::LLMaterialMgr(): + mGetQueue(), + mGetPending(), + mGetCallbacks(), + mGetTECallbacks(), + mGetAllQueue(), + mGetAllRequested(), + mGetAllPending(), + mGetAllCallbacks(), + mPutQueue(), + mMaterials(), + mHttpRequest(NULL), + mHttpHeaders(NULL), + mHttpOptions(NULL), + mHttpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID), + mHttpPriority(0) { - mRequest = LLCore::HttpRequest::ptr_t(new LLCore::HttpRequest()); + LLAppCoreHttp & app_core_http(LLAppViewer::instance()->getAppCoreHttp()); + + mHttpRequest = LLCore::HttpRequest::ptr_t(new LLCore::HttpRequest()); + mHttpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false); + mHttpOptions = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false); + mHttpPolicy = app_core_http.getPolicy(LLAppCoreHttp::AP_MATERIALS); mMaterials.insert(std::pair(LLMaterialID::null, LLMaterialPtr(NULL))); gIdleCallbacks.addFunction(&LLMaterialMgr::onIdle, NULL); @@ -558,7 +576,7 @@ void LLMaterialMgr::onIdle(void*) instancep->processPutQueue(); } - instancep->mRequest->update(0L); + instancep->mHttpRequest->update(0L); } void LLMaterialMgr::processGetQueue() @@ -639,19 +657,17 @@ void LLMaterialMgr::processGetQueue() boost::bind(&LLMaterialMgr::onGetResponse, this, _1, _2, region_id) ); - LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false); - LL_DEBUGS("Materials") << "POSTing to region '" << regionp->getName() << "' at '" << capURL << " for " << materialsData.size() << " materials." << "\ndata: " << ll_pretty_print_sd(materialsData) << LL_ENDL; - LLCore::HttpHandle handle = LLCoreHttpUtil::requestPutWithLLSD(mRequest.get(), - LLCore::HttpRequest::DEFAULT_POLICY_ID, 0, capURL, - postData, NULL, headers.get(), handler); + LLCore::HttpHandle handle = LLCoreHttpUtil::requestPutWithLLSD(mHttpRequest, + mHttpPolicy, mHttpPriority, capURL, + postData, mHttpOptions, mHttpHeaders, handler); if (handle == LLCORE_HTTP_HANDLE_INVALID) { delete handler; - LLCore::HttpStatus status = mRequest->getStatus(); + LLCore::HttpStatus status = mHttpRequest->getStatus(); LL_ERRS("Meterials") << "Failed to execute material POST. Status = " << status.toULong() << "\"" << status.toString() << "\"" << LL_ENDL; } @@ -695,15 +711,13 @@ void LLMaterialMgr::processGetAllQueue() boost::bind(&LLMaterialMgr::onGetAllResponse, this, _1, _2, *itRegion) ); - LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false); - - LLCore::HttpHandle handle = mRequest->requestGet(LLCore::HttpRequest::DEFAULT_POLICY_ID, 0, - capURL, NULL, headers.get(), handler); + LLCore::HttpHandle handle = mHttpRequest->requestGet(mHttpPolicy, mHttpPriority, capURL, + mHttpOptions.get(), mHttpHeaders.get(), handler); if (handle == LLCORE_HTTP_HANDLE_INVALID) { delete handler; - LLCore::HttpStatus status = mRequest->getStatus(); + LLCore::HttpStatus status = mHttpRequest->getStatus(); LL_ERRS("Meterials") << "Failed to execute material GET. Status = " << status.toULong() << "\"" << status.toString() << "\"" << LL_ENDL; } @@ -800,15 +814,14 @@ void LLMaterialMgr::processPutQueue() boost::bind(&LLMaterialMgr::onPutResponse, this, _1, _2) ); - LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false); - - LLCore::HttpHandle handle = LLCoreHttpUtil::requestPutWithLLSD(mRequest.get(), LLCore::HttpRequest::DEFAULT_POLICY_ID, 0, - capURL, putData, NULL, headers.get(), handler); + LLCore::HttpHandle handle = LLCoreHttpUtil::requestPutWithLLSD( + mHttpRequest, mHttpPolicy, mHttpPriority, capURL, + putData, mHttpOptions, mHttpHeaders, handler); if (handle == LLCORE_HTTP_HANDLE_INVALID) { delete handler; - LLCore::HttpStatus status = mRequest->getStatus(); + LLCore::HttpStatus status = mHttpRequest->getStatus(); LL_ERRS("Meterials") << "Failed to execute material PUT. Status = " << status.toULong() << "\"" << status.toString() << "\"" << LL_ENDL; } diff --git a/indra/newview/llmaterialmgr.h b/indra/newview/llmaterialmgr.h index 0904c9b2c4..ef202d24ba 100644 --- a/indra/newview/llmaterialmgr.h +++ b/indra/newview/llmaterialmgr.h @@ -31,6 +31,8 @@ #include "llmaterialid.h" #include "llsingleton.h" #include "httprequest.h" +#include "httpheaders.h" +#include "httpoptions.h" class LLViewerRegion; @@ -74,16 +76,6 @@ private: void onRegionRemoved(LLViewerRegion* regionp); private: - typedef std::set material_queue_t; - typedef std::map get_queue_t; - typedef std::pair pending_material_t; - typedef std::map get_pending_map_t; - typedef std::map get_callback_map_t; - - get_queue_t mGetQueue; - get_pending_map_t mGetPending; - get_callback_map_t mGetCallbacks; - // struct for TE-specific material ID query class TEMaterialPair { @@ -110,6 +102,13 @@ private: bool operator()(const TEMaterialPair& left, const TEMaterialPair& right) const { return left < right; } }; + typedef std::set material_queue_t; + typedef std::map get_queue_t; + typedef std::pair pending_material_t; + typedef std::map get_pending_map_t; + typedef std::map get_callback_map_t; + + typedef boost::unordered_map get_callback_te_map_t; typedef std::set getall_queue_t; typedef std::map getall_pending_map_t; @@ -117,15 +116,23 @@ private: typedef std::map facematerial_map_t; typedef std::map put_queue_t; - get_callback_te_map_t mGetTECallbacks; - getall_queue_t mGetAllQueue; - getall_queue_t mGetAllRequested; - getall_pending_map_t mGetAllPending; - getall_callback_map_t mGetAllCallbacks; - put_queue_t mPutQueue; - material_map_t mMaterials; - - LLCore::HttpRequest::ptr_t mRequest; + get_queue_t mGetQueue; + get_pending_map_t mGetPending; + get_callback_map_t mGetCallbacks; + + get_callback_te_map_t mGetTECallbacks; + getall_queue_t mGetAllQueue; + getall_queue_t mGetAllRequested; + getall_pending_map_t mGetAllPending; + getall_callback_map_t mGetAllCallbacks; + put_queue_t mPutQueue; + material_map_t mMaterials; + + LLCore::HttpRequest::ptr_t mHttpRequest; + LLCore::HttpHeaders::ptr_t mHttpHeaders; + LLCore::HttpOptions::ptr_t mHttpOptions; + LLCore::HttpRequest::policy_t mHttpPolicy; + LLCore::HttpRequest::priority_t mHttpPriority; U32 getMaxEntries(const LLViewerRegion* regionp); }; -- cgit v1.2.3 From f3120efae8a737336d8e313ca5cb5bb519f9b358 Mon Sep 17 00:00:00 2001 From: Bjoseph Wombat Date: Sun, 22 Mar 2015 13:04:09 -0400 Subject: Mic setting changes some device list is up to date, mic loop test works, removed obsolete code and fine tuned voice state machine to avoid frequent neccessary code paths. --- indra/newview/llpanelvoicedevicesettings.cpp | 30 ++- indra/newview/llpanelvoicedevicesettings.h | 2 + indra/newview/llvoiceclient.cpp | 12 + indra/newview/llvoiceclient.h | 2 + indra/newview/llvoicevivox.cpp | 343 +++++++++------------------ indra/newview/llvoicevivox.h | 13 +- 6 files changed, 159 insertions(+), 243 deletions(-) (limited to 'indra') diff --git a/indra/newview/llpanelvoicedevicesettings.cpp b/indra/newview/llpanelvoicedevicesettings.cpp index 3946d6a63b..07f8045546 100755 --- a/indra/newview/llpanelvoicedevicesettings.cpp +++ b/indra/newview/llpanelvoicedevicesettings.cpp @@ -51,7 +51,7 @@ LLPanelVoiceDeviceSettings::LLPanelVoiceDeviceSettings() mCtrlOutputDevices = NULL; mInputDevice = gSavedSettings.getString("VoiceInputAudioDevice"); mOutputDevice = gSavedSettings.getString("VoiceOutputAudioDevice"); - mDevicesUpdated = FALSE; + mDevicesUpdated = FALSE; //obsolete mUseTuningMode = true; // grab "live" mic volume level @@ -80,6 +80,10 @@ BOOL LLPanelVoiceDeviceSettings::postBuild() mLocalizedDeviceNames[DEFAULT_DEVICE] = getString("default_text"); mLocalizedDeviceNames["No Device"] = getString("name_no_device"); mLocalizedDeviceNames["Default System Device"] = getString("name_default_system_device"); + + mCtrlOutputDevices->setMouseDownCallback(boost::bind(&LLPanelVoiceDeviceSettings::onOutputDevicesClicked, this)); + mCtrlInputDevices->setMouseDownCallback(boost::bind(&LLPanelVoiceDeviceSettings::onInputDevicesClicked, this)); + return TRUE; } @@ -226,9 +230,8 @@ void LLPanelVoiceDeviceSettings::refresh() mCtrlOutputDevices->add(getLocalizedDeviceName(mOutputDevice), mOutputDevice, ADD_BOTTOM); mCtrlOutputDevices->setValue(mOutputDevice); } - mDevicesUpdated = FALSE; } - else if (!mDevicesUpdated) + else if (LLVoiceClient::getInstance()->deviceSettingsUpdated()) { LLVoiceDeviceList::const_iterator iter; @@ -272,7 +275,6 @@ void LLPanelVoiceDeviceSettings::refresh() mOutputDevice = DEFAULT_DEVICE; } } - mDevicesUpdated = TRUE; } } @@ -281,7 +283,6 @@ void LLPanelVoiceDeviceSettings::initialize() mInputDevice = gSavedSettings.getString("VoiceInputAudioDevice"); mOutputDevice = gSavedSettings.getString("VoiceOutputAudioDevice"); mMicVolume = gSavedSettings.getF32("AudioLevelMic"); - mDevicesUpdated = FALSE; // ask for new device enumeration LLVoiceClient::getInstance()->refreshDeviceLists(); @@ -314,8 +315,8 @@ void LLPanelVoiceDeviceSettings::onCommitInputDevice() { if(LLVoiceClient::getInstance()) { - LLVoiceClient::getInstance()->setCaptureDevice( - mCtrlInputDevices->getValue().asString()); + mInputDevice = mCtrlInputDevices->getValue().asString(); + LLVoiceClient::getInstance()->setRenderDevice(mInputDevice); } } @@ -323,7 +324,18 @@ void LLPanelVoiceDeviceSettings::onCommitOutputDevice() { if(LLVoiceClient::getInstance()) { - LLVoiceClient::getInstance()->setRenderDevice( - mCtrlInputDevices->getValue().asString()); + + mOutputDevice = mCtrlOutputDevices->getValue().asString(); + LLVoiceClient::getInstance()->setRenderDevice(mOutputDevice); } } + +void LLPanelVoiceDeviceSettings::onOutputDevicesClicked() +{ + LLVoiceClient::getInstance()->refreshDeviceLists(false); // fill in the pop up menus again if needed. +} + +void LLPanelVoiceDeviceSettings::onInputDevicesClicked() +{ + LLVoiceClient::getInstance()->refreshDeviceLists(false); // fill in the pop up menus again if needed. +} diff --git a/indra/newview/llpanelvoicedevicesettings.h b/indra/newview/llpanelvoicedevicesettings.h index 83464f476a..355bc02b05 100755 --- a/indra/newview/llpanelvoicedevicesettings.h +++ b/indra/newview/llpanelvoicedevicesettings.h @@ -53,6 +53,8 @@ protected: void onCommitInputDevice(); void onCommitOutputDevice(); + void onOutputDevicesClicked(); + void onInputDevicesClicked(); F32 mMicVolume; std::string mInputDevice; diff --git a/indra/newview/llvoiceclient.cpp b/indra/newview/llvoiceclient.cpp index 6df1bda135..e09ca1f72a 100755 --- a/indra/newview/llvoiceclient.cpp +++ b/indra/newview/llvoiceclient.cpp @@ -266,6 +266,18 @@ bool LLVoiceClient::deviceSettingsAvailable() } } +bool LLVoiceClient::deviceSettingsUpdated() +{ + if (mVoiceModule) + { + return mVoiceModule->deviceSettingsUpdated(); + } + else + { + return false; + } +} + void LLVoiceClient::refreshDeviceLists(bool clearCurrentList) { if (mVoiceModule) mVoiceModule->refreshDeviceLists(clearCurrentList); diff --git a/indra/newview/llvoiceclient.h b/indra/newview/llvoiceclient.h index 4c6ff5ef8f..51961468ca 100755 --- a/indra/newview/llvoiceclient.h +++ b/indra/newview/llvoiceclient.h @@ -128,6 +128,7 @@ public: // This returns true when it's safe to bring up the "device settings" dialog in the prefs. // i.e. when the daemon is running and connected, and the device lists are populated. virtual bool deviceSettingsAvailable()=0; + virtual bool deviceSettingsUpdated() = 0; // Requery the vivox daemon for the current list of input/output devices. // If you pass true for clearCurrentList, deviceSettingsAvailable() will be false until the query has completed @@ -335,6 +336,7 @@ public: // This returns true when it's safe to bring up the "device settings" dialog in the prefs. // i.e. when the daemon is running and connected, and the device lists are populated. bool deviceSettingsAvailable(); + bool deviceSettingsUpdated(); // returns true when the device list has been updated recently. // Requery the vivox daemon for the current list of input/output devices. // If you pass true for clearCurrentList, deviceSettingsAvailable() will be false until the query has completed diff --git a/indra/newview/llvoicevivox.cpp b/indra/newview/llvoicevivox.cpp index 99190e9919..6ac8d84771 100755 --- a/indra/newview/llvoicevivox.cpp +++ b/indra/newview/llvoicevivox.cpp @@ -91,10 +91,9 @@ const F32 LOGIN_RETRY_SECONDS = 10.0f; const int MAX_LOGIN_RETRIES = 12; // Defines the maximum number of times(in a row) "stateJoiningSession" case for spatial channel is reached in stateMachine() -// which is treated as normal. If this number is exceeded we suspect there is a problem with connection -// to voice server (EXT-4313). When voice works correctly, there is from 1 to 15 times. 50 was chosen -// to make sure we don't make mistake when slight connection problems happen- situation when connection to server is -// blocked is VERY rare and it's better to sacrifice response time in this situation for the sake of stability. +// which is treated as normal. The is the number of frames to wait for a channel join before giving up. This was changed +// from the original count of 50 for two reason. Modern PCs have higher frame rates and sometimes the SLVoice process +// backs up processing join requests. There is a log statement that records when channel joins take longer than 100 frames. const int MAX_NORMAL_JOINING_SPATIAL_NUM = 1500; // How often to check for expired voice fonts in seconds @@ -277,9 +276,10 @@ LLVivoxVoiceClient::LLVivoxVoiceClient() : mTuningEnergy(0.0f), mTuningMicVolume(0), mTuningMicVolumeDirty(true), - mTuningSpeakerVolume(0), + mTuningSpeakerVolume(50), // Set to 50 so the user can hear himself when he sets his mic volume mTuningSpeakerVolumeDirty(true), mTuningExitState(stateDisabled), + mDevicesListUpdated(false), mAreaVoiceDisabled(false), mAudioSession(NULL), @@ -718,8 +718,9 @@ void LLVivoxVoiceClient::stateMachine() setVoiceEnabled(false); } - if(mVoiceEnabled || (!mIsInitialized &&!mTerminateDaemon) ) + if ((getState() == stateRunning) && inSpatialChannel() && mUpdateTimer.hasExpired() && !mTerminateDaemon) { + // poll the avatar position so its available in various states when a 3d position is sent. updatePosition(); } else if(mTuningMode) @@ -728,7 +729,8 @@ void LLVivoxVoiceClient::stateMachine() } else { - if((getState() != stateDisabled) && (getState() != stateDisableCleanup)) + if (!gSavedSettings.getBOOL("EnableVoiceChat")) + //if((getState() != stateDisabled) && (getState() != stateDisableCleanup)) { // User turned off voice support. Send the cleanup messages, close the socket, and reset. if(!mConnected || mTerminateDaemon) @@ -746,6 +748,10 @@ void LLVivoxVoiceClient::stateMachine() } } + + // send any requests to adjust mic and speaker settings if they have changed + sendLocalAudioUpdates(); + switch(getState()) { @@ -973,6 +979,19 @@ void LLVivoxVoiceClient::stateMachine() else { // loop mic back to render device. + //setMuteMic(0); // make sure the mic is not muted + std::ostringstream stream; + + stream << "" + << "" << mConnectorHandle << "" + << "false" + << "\n\n\n"; + + // Dirty the mute mic state so that it will get reset when we finishing previewing + mMuteMicDirty = true; + mTuningSpeakerVolumeDirty = true; + + writeString(stream.str()); tuningCaptureStartSendMessage(1); // 1-loop, zero, don't loop setState(stateMicTuningRunning); @@ -1243,16 +1262,8 @@ void LLVivoxVoiceClient::stateMachine() } // Set the initial state of mic mute, local speaker volume, etc. - { - std::ostringstream stream; - - buildLocalAudioUpdates(stream); + sendLocalAudioUpdates(); - if(!stream.str().empty()) - { - writeString(stream.str()); - } - } break; //MARK: stateVoiceFontsWait @@ -1525,9 +1536,9 @@ void LLVivoxVoiceClient::stateMachine() // Must do this first, since it uses mAudioSession. notifyStatusObservers(LLVoiceClientStatusObserver::STATUS_LEFT_CHANNEL); - if(mAudioSession) + if (mAudioSession) { - leaveAudioSession(); + leaveAudioSession(); sessionState *oldSession = mAudioSession; mAudioSession = NULL; @@ -1977,21 +1988,6 @@ void LLVivoxVoiceClient::sessionMediaDisconnectSendMessage(sessionState *session } -/* obsolete -void LLVivoxVoiceClient::sessionTextDisconnectSendMessage(sessionState *session) -{ - std::ostringstream stream; - - LL_DEBUGS("Voice") << "Sending Session.TextDisconnect with handle " << session->mHandle << LL_ENDL; - stream - << "" - << "" << session->mGroupHandle << "" - << "" << session->mHandle << "" - << "\n\n\n"; - - writeString(stream.str()); -} -*/ void LLVivoxVoiceClient::getCaptureDevicesSendMessage() { @@ -2050,6 +2046,10 @@ void LLVivoxVoiceClient::setCaptureDevice(const std::string& name) } } } +void LLVivoxVoiceClient::setDevicesListUpdated(bool state) +{ + mDevicesListUpdated = state; +} void LLVivoxVoiceClient::clearRenderDevices() { @@ -2210,6 +2210,16 @@ bool LLVivoxVoiceClient::deviceSettingsAvailable() return result; } +bool LLVivoxVoiceClient::deviceSettingsUpdated() +{ + if (mDevicesListUpdated) + { + // a hot swap event or a polling of the audio devices has been parsed since the last redraw of the input and output device panel. + mDevicesListUpdated = !mDevicesListUpdated; // toggle the setting + return true; + } + return false; +} void LLVivoxVoiceClient::refreshDeviceLists(bool clearCurrentList) { @@ -2373,7 +2383,6 @@ void LLVivoxVoiceClient::sendPositionalUpdate(void) { std::ostringstream stream; - if (getState() != stateRunning) return; // don't send position updates if we are transitioning between out of running. if(mSpatialCoordsDirty) { @@ -2582,7 +2591,7 @@ void LLVivoxVoiceClient::sendPositionalUpdate(void) } } - buildLocalAudioUpdates(stream); + //sendLocalAudioUpdates(); obsolete, used to send volume setting on position updates if(!stream.str().empty()) { @@ -2622,68 +2631,73 @@ void LLVivoxVoiceClient::buildSetRenderDevice(std::ostringstream &stream) } } -void LLVivoxVoiceClient::buildLocalAudioUpdates(std::ostringstream &stream) +void LLVivoxVoiceClient::sendLocalAudioUpdates() { - buildSetCaptureDevice(stream); + // Check all of the dirty states and then send messages to those needing to be changed. + // Tuningmode hands its own mute settings. - buildSetRenderDevice(stream); + std::ostringstream stream; - if(mMuteMicDirty) + if (mMuteMicDirty && !mTuningMode) { mMuteMicDirty = false; // Send a local mute command. - - LL_DEBUGS("Voice") << "Sending MuteLocalMic command with parameter " << (mMuteMic?"true":"false") << LL_ENDL; + + LL_DEBUGS("Voice") << "Sending MuteLocalMic command with parameter " << (mMuteMic ? "true" : "false") << LL_ENDL; stream << "" << "" << mConnectorHandle << "" - << "" << (mMuteMic?"true":"false") << "" + << "" << (mMuteMic ? "true" : "false") << "" << "\n\n\n"; - + } - if(mSpeakerMuteDirty) + if (mSpeakerMuteDirty && !mTuningMode) { - const char *muteval = ((mSpeakerVolume <= scale_speaker_volume(0))?"true":"false"); + const char *muteval = ((mSpeakerVolume <= scale_speaker_volume(0)) ? "true" : "false"); mSpeakerMuteDirty = false; - LL_INFOS("Voice") << "Setting speaker mute to " << muteval << LL_ENDL; - + LL_INFOS("Voice") << "Setting speaker mute to " << muteval << LL_ENDL; + stream << "" << "" << mConnectorHandle << "" << "" << muteval << "" - << "\n\n\n"; - + << "\n\n\n"; + } - - if(mSpeakerVolumeDirty) + + if (mSpeakerVolumeDirty) { mSpeakerVolumeDirty = false; - LL_INFOS("Voice") << "Setting speaker volume to " << mSpeakerVolume << LL_ENDL; + LL_INFOS("Voice") << "Setting speaker volume to " << mSpeakerVolume << LL_ENDL; stream << "" << "" << mConnectorHandle << "" << "" << mSpeakerVolume << "" << "\n\n\n"; - + } - - if(mMicVolumeDirty) + + if (mMicVolumeDirty) { mMicVolumeDirty = false; - LL_INFOS("Voice") << "Setting mic volume to " << mMicVolume << LL_ENDL; + LL_INFOS("Voice") << "Setting mic volume to " << mMicVolume << LL_ENDL; stream << "" << "" << mConnectorHandle << "" << "" << mMicVolume << "" - << "\n\n\n"; + << "\n\n\n"; } - + + if (!stream.str().empty()) + { + writeString(stream.str()); + } } ///////////////////////////// @@ -2830,7 +2844,8 @@ void LLVivoxVoiceClient::sessionConnectResponse(std::string &requestId, int stat sessionState *session = findSession(requestId); // 1026 is session already has media, somehow mediaconnect was called twice on the same session. // set the session info to reflect that the user is already connected. - if (statusCode == 1026){ + if (statusCode == 1026) + { session->mVoiceEnabled = true; session->mMediaConnectInProgress = false; session->mMediaStreamState = streamStateConnected; @@ -2846,7 +2861,9 @@ void LLVivoxVoiceClient::sessionConnectResponse(std::string &requestId, int stat session->mErrorStatusCode = statusCode; session->mErrorStatusString = statusString; if (session == mAudioSession) + { setState(stateJoinSessionFailed); + } } } else @@ -2985,7 +3002,6 @@ void LLVivoxVoiceClient::joinedAudioSession(sessionState *session) { setState(stateSessionJoined); - // SLIM SDK: we don't always receive a participant state change for ourselves when joining a channel now. // Add the current user as a participant here. participantState *participant = session->addParticipant(sipURIFromName(mAccountName)); if(participant) @@ -3299,55 +3315,6 @@ void LLVivoxVoiceClient::mediaStreamUpdatedEvent( } } -/* Obsolete -void LLVivoxVoiceClient::textStreamUpdatedEvent( - std::string &sessionHandle, - std::string &sessionGroupHandle, - bool enabled, - int state, - bool incoming) -{ - sessionState *session = findSession(sessionHandle); - - if(session) - { - // Save the state for later use - session->mTextStreamState = state; - - // We know about this session - switch(state) - { - case 0: // We see this when the text stream closes - LL_DEBUGS("Voice") << "stream closed" << LL_ENDL; - break; - - case 1: // We see this on an incoming call from the Connector - // Try to send any text messages queued for this session. - sendQueuedTextMessages(session); - - // Send the text chat invite to the GUI layer - // TODO: Question: Should we correlate with the mute list here? - session->mTextInvitePending = true; - if(session->mName.empty()) - { - lookupName(session->mCallerID); - } - else - { - // Act like we just finished resolving the name - avatarNameResolved(session->mCallerID, session->mName); - } - break; - - default: - LL_WARNS("Voice") << "unknown state " << state << LL_ENDL; - break; - - } - } -} - obsolete */ - void LLVivoxVoiceClient::participantAddedEvent( std::string &sessionHandle, std::string &sessionGroupHandle, @@ -4224,62 +4191,6 @@ LLVivoxVoiceClient::sessionState* LLVivoxVoiceClient::startUserIMSession(const L return session; } -/* obsolete -BOOL LLVivoxVoiceClient::sendTextMessage(const LLUUID& participant_id, const std::string& message) -{ - bool result = false; - - // Attempt to locate the indicated session - sessionState *session = startUserIMSession(participant_id); - if(session) - { - // found the session, attempt to send the message - session->mTextMsgQueue.push(message); - - // Try to send queued messages (will do nothing if the session is not open yet) - sendQueuedTextMessages(session); - - // The message is queued, so we succeed. - result = true; - } - else - { - LL_DEBUGS("Voice") << "Session not found for participant ID " << participant_id << LL_ENDL; - } - - return result; -} -*/ -/* obsolete -void LLVivoxVoiceClient::sendQueuedTextMessages(sessionState *session) -{ - if(session->mTextStreamState == 1) - { - if(!session->mTextMsgQueue.empty()) - { - std::ostringstream stream; - - while(!session->mTextMsgQueue.empty()) - { - std::string message = session->mTextMsgQueue.front(); - session->mTextMsgQueue.pop(); - stream - << "" - << "" << session->mHandle << "" - << "text/HTML" - << "" << message << "" - << "" - << "\n\n\n"; - } - writeString(stream.str()); - } - } - else - { - // Session isn't connected yet, defer until later. - } -} - obsolete */ void LLVivoxVoiceClient::endUserIMSession(const LLUUID &uuid) { @@ -4641,11 +4552,6 @@ void LLVivoxVoiceClient::enforceTether(void) void LLVivoxVoiceClient::updatePosition(void) { - - // Throttle the position updates to one every 1/10 of a second if we are in an audio session at all - if (mAudioSession == NULL) { - return; - } LLViewerRegion *region = gAgent.getRegion(); if(region && isAgentAvatarValid()) @@ -5109,7 +5015,7 @@ void LLVivoxVoiceClient::filePlaybackSetMode(bool vox, float speed) LLVivoxVoiceClient::sessionState::sessionState() : mErrorStatusCode(0), mMediaStreamState(streamStateUnknown), - mTextStreamState(streamStateUnknown), + //mTextStreamState(streamStateUnknown), mCreateInProgress(false), mMediaConnectInProgress(false), mVoiceInvitePending(false), @@ -6705,6 +6611,10 @@ void LLVivoxProtocolParser::EndTag(const char *tag) uriString = string; else if (!stricmp("Presence", tag)) statusString = string; + else if (!stricmp("CaptureDevices", tag)) + LLVivoxVoiceClient::getInstance()->setDevicesListUpdated(true); + else if (!stricmp("RenderDevices", tag)) + LLVivoxVoiceClient::getInstance()->setDevicesListUpdated(true); else if (!stricmp("CaptureDevice", tag)) { LLVivoxVoiceClient::getInstance()->addCaptureDevice(deviceString); @@ -6833,7 +6743,13 @@ void LLVivoxProtocolParser::processResponse(std::string tag) if (isEvent) { const char *eventTypeCstr = eventTypeString.c_str(); - if (!stricmp(eventTypeCstr, "AccountLoginStateChangeEvent")) + if (!stricmp(eventTypeCstr, "ParticipantUpdatedEvent")) + { + // These happen so often that logging them is pretty useless. + squelchDebugOutput = true; + LLVivoxVoiceClient::getInstance()->participantUpdatedEvent(sessionHandle, sessionGroupHandle, uriString, alias, isModeratorMuted, isSpeaking, volume, energy); + } + else if (!stricmp(eventTypeCstr, "AccountLoginStateChangeEvent")) { LLVivoxVoiceClient::getInstance()->accountLoginStateChangeEvent(accountHandle, statusCode, statusString, state); } @@ -6857,7 +6773,7 @@ void LLVivoxProtocolParser::processResponse(std::string tag) } else if (!stricmp(eventTypeCstr, "SessionGroupUpdatedEvent")) { - //TODO, we don't process this event, but we should not WARN that we have received it. + //nothng useful to process for this event, but we should not WARN that we have received it. } else if (!stricmp(eventTypeCstr, "SessionGroupAddedEvent")) { @@ -6887,13 +6803,6 @@ void LLVivoxProtocolParser::processResponse(std::string tag) */ LLVivoxVoiceClient::getInstance()->mediaCompletionEvent(sessionGroupHandle, mediaCompletionType); } - /* obsolete, let else statement complain if a text message arrives - else if (!stricmp(eventTypeCstr, "TextStreamUpdatedEvent")) - { - - LLVivoxVoiceClient::getInstance()->textStreamUpdatedEvent(sessionHandle, sessionGroupHandle, enabled, state, incoming); - - } */ else if (!stricmp(eventTypeCstr, "ParticipantAddedEvent")) { /* @@ -6920,52 +6829,20 @@ void LLVivoxProtocolParser::processResponse(std::string tag) */ LLVivoxVoiceClient::getInstance()->participantRemovedEvent(sessionHandle, sessionGroupHandle, uriString, alias, nameString); } - else if (!stricmp(eventTypeCstr, "ParticipantUpdatedEvent")) - { - /* - - c1_m1000xFnPP04IpREWNkuw1cOXlhw==_sg0 - c1_m1000xFnPP04IpREWNkuw1cOXlhw==0 - sip:xFnPP04IpREWNkuw1cOXlhw==@bhr.vivox.com - false - true - 44 - 0.0879437 - - */ - - // These happen so often that logging them is pretty useless. - squelchDebugOutput = true; - - LLVivoxVoiceClient::getInstance()->participantUpdatedEvent(sessionHandle, sessionGroupHandle, uriString, alias, isModeratorMuted, isSpeaking, volume, energy); - } else if (!stricmp(eventTypeCstr, "AuxAudioPropertiesEvent")) { // These are really spammy in tuning mode squelchDebugOutput = true; - LLVivoxVoiceClient::getInstance()->auxAudioPropertiesEvent(energy); } - else if (!stricmp(eventTypeCstr, "BuddyChangedEvent")) - { - /* - - c1_m1000xFnPP04IpREWNkuw1cOXlhw== - sip:x9fFHFZjOTN6OESF1DUPrZQ==@bhr.vivox.com - Monroe Tester - - 0 - Set - - */ - // TODO: Question: Do we need to process this at all? - } else if (!stricmp(eventTypeCstr, "MessageEvent")) { + //TODO: This probably is not received any more, it was used to support SLim clients LLVivoxVoiceClient::getInstance()->messageEvent(sessionHandle, uriString, alias, messageHeader, messageBody, applicationString); } else if (!stricmp(eventTypeCstr, "SessionNotificationEvent")) { + //TODO: This probably is not received any more, it was used to support SLim clients LLVivoxVoiceClient::getInstance()->sessionNotificationEvent(sessionHandle, uriString, notificationType); } else if (!stricmp(eventTypeCstr, "SessionUpdatedEvent")) @@ -6985,19 +6862,29 @@ void LLVivoxProtocolParser::processResponse(std::string tag) */ // We don't need to process this, but we also shouldn't warn on it, since that confuses people. } - - else if (!stricmp(eventTypeCstr, "SessionGroupRemovedEvent")) + else if (!stricmp(eventTypeCstr, "SessionGroupRemovedEvent")) { - /* - - c1_m1000xFnPP04IpREWNkuw1cOXlhw==_sg0 - - */ // We don't need to process this, but we also shouldn't warn on it, since that confuses people. } - else if (!stricmp(eventTypeCstr, "VoiceServiceConnectionStateChangedEvent")) + else if (!stricmp(eventTypeCstr, "VoiceServiceConnectionStateChangedEvent")) { // Yet another ignored event } + else if (!stricmp(eventTypeCstr, "AudioDeviceHotSwapEvent")) + { + /* + + RenderDeviceChanged< / EventType> + + Speakers(Turtle Beach P11 Headset)< / Device> + Speakers(Turtle Beach P11 Headset)< / DisplayName> + SpecificDevice< / Type> + < / RelevantDevice> + < / Event> + */ + // an audio device was removed or added, fetch and update the local list of audio devices. + LLVivoxVoiceClient::getInstance()->getCaptureDevicesSendMessage(); + LLVivoxVoiceClient::getInstance()->getRenderDevicesSendMessage(); + } else { LL_WARNS("VivoxProtocolParser") << "Unknown event type " << eventTypeString << LL_ENDL; @@ -7006,7 +6893,12 @@ void LLVivoxProtocolParser::processResponse(std::string tag) else { const char *actionCstr = actionString.c_str(); - if (!stricmp(actionCstr, "Connector.Create.1")) + if (!stricmp(actionCstr, "Session.Set3DPosition.1")) + { + // We don't need to process these, but they're so spammy we don't want to log them. + squelchDebugOutput = true; + } + else if (!stricmp(actionCstr, "Connector.Create.1")) { LLVivoxVoiceClient::getInstance()->connectorCreateResponse(statusCode, statusString, connectorHandle, versionID); } @@ -7034,11 +6926,6 @@ void LLVivoxProtocolParser::processResponse(std::string tag) { LLVivoxVoiceClient::getInstance()->connectorShutdownResponse(statusCode, statusString); } - else if (!stricmp(actionCstr, "Session.Set3DPosition.1")) - { - // We don't need to process these, but they're so spammy we don't want to log them. - squelchDebugOutput = true; - } else if (!stricmp(actionCstr, "Account.GetSessionFonts.1")) { LLVivoxVoiceClient::getInstance()->accountGetSessionFontsResponse(statusCode, statusString); diff --git a/indra/newview/llvoicevivox.h b/indra/newview/llvoicevivox.h index 541cccd30f..1b8a45744a 100755 --- a/indra/newview/llvoicevivox.h +++ b/indra/newview/llvoicevivox.h @@ -91,6 +91,7 @@ public: // This returns true when it's safe to bring up the "device settings" dialog in the prefs. // i.e. when the daemon is running and connected, and the device lists are populated. virtual bool deviceSettingsAvailable(); + virtual bool deviceSettingsUpdated(); //return if the list has been updated and never fetched, only to be called from the voicepanel. // Requery the vivox daemon for the current list of input/output devices. // If you pass true for clearCurrentList, deviceSettingsAvailable() will be false until the query has completed @@ -327,7 +328,6 @@ protected: LLUUID mCallerID; int mErrorStatusCode; int mMediaStreamState; - int mTextStreamState; // obsolete bool mCreateInProgress; // True if a Session.Create has been sent for this session and no response has been received yet. bool mMediaConnectInProgress; // True if a Session.MediaConnect has been sent for this session and no response has been received yet. bool mVoiceInvitePending; // True if a voice invite is pending for this session (usually waiting on a name lookup) @@ -459,14 +459,15 @@ protected: void clearCaptureDevices(); void addCaptureDevice(const std::string& name); void clearRenderDevices(); + void setDevicesListUpdated(bool state); void addRenderDevice(const std::string& name); void buildSetAudioDevices(std::ostringstream &stream); void getCaptureDevicesSendMessage(); void getRenderDevicesSendMessage(); - // local audio updates - void buildLocalAudioUpdates(std::ostringstream &stream); + // local audio updates, mic mute, speaker mute, mic volume and speaker volumes + void sendLocalAudioUpdates(); ///////////////////////////// @@ -482,7 +483,6 @@ protected: void accountLoginStateChangeEvent(std::string &accountHandle, int statusCode, std::string &statusString, int state); void mediaCompletionEvent(std::string &sessionGroupHandle, std::string &mediaCompletionType); void mediaStreamUpdatedEvent(std::string &sessionHandle, std::string &sessionGroupHandle, int statusCode, std::string &statusString, int state, bool incoming); - //obsolete void textStreamUpdatedEvent(std::string &sessionHandle, std::string &sessionGroupHandle, bool enabled, int state, bool incoming); void sessionAddedEvent(std::string &uriString, std::string &alias, std::string &sessionHandle, std::string &sessionGroupHandle, bool isChannel, bool incoming, std::string &nameString, std::string &applicationString); void sessionGroupAddedEvent(std::string &sessionGroupHandle); void sessionRemovedEvent(std::string &sessionHandle, std::string &sessionGroupHandle); @@ -678,7 +678,9 @@ private: bool mTuningMicVolumeDirty; int mTuningSpeakerVolume; bool mTuningSpeakerVolumeDirty; - state mTuningExitState; // state to return to when we leave tuning mode. + state mTuningExitState; // state to return to when we leave tuning mode. + bool mDevicesListUpdated; // set to true when the device list has been updated + // and false when the panelvoicedevicesettings has queried for an update status. std::string mSpatialSessionURI; std::string mSpatialSessionCredentials; @@ -762,7 +764,6 @@ private: // start a text IM session with the specified user // This will be asynchronous, the session may be established at a future time. sessionState* startUserIMSession(const LLUUID& uuid); - // obsolete void sendQueuedTextMessages(sessionState *session); void enforceTether(void); -- cgit v1.2.3 From edfd19502c0cabfc836fafddae92b623005eb4cb Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 23 Mar 2015 08:51:47 -0700 Subject: Start work on appearancemgr --- indra/newview/llappearancemgr.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'indra') diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp index a64d5b50b3..9e8479eeef 100755 --- a/indra/newview/llappearancemgr.cpp +++ b/indra/newview/llappearancemgr.cpp @@ -3154,6 +3154,7 @@ void LLAppearanceMgr::updateClothingOrderingInfo(LLUUID cat_id, } +#if 1 class RequestAgentUpdateAppearanceResponder: public LLHTTPClient::Responder { LOG_CLASS(RequestAgentUpdateAppearanceResponder); @@ -3423,6 +3424,10 @@ void RequestAgentUpdateAppearanceResponder::onFailure() LL_WARNS() << "giving up after too many retries" << LL_ENDL; } } +#else + + +#endif LLSD LLAppearanceMgr::dumpCOF() const -- cgit v1.2.3 From 3b923962f8e0a065052f40d029bce42a6fe37e68 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 23 Mar 2015 12:23:35 -0700 Subject: Reogranized some headers for GCC added to the linden_common.h for shared_ptr --- indra/llcommon/linden_common.h | 1 + indra/llcorehttp/bufferarray.h | 1 + 2 files changed, 2 insertions(+) (limited to 'indra') diff --git a/indra/llcommon/linden_common.h b/indra/llcommon/linden_common.h index 5cfcdab41c..e5a913a6a9 100755 --- a/indra/llcommon/linden_common.h +++ b/indra/llcommon/linden_common.h @@ -51,6 +51,7 @@ #include #include #include +#include // Linden only libs in alpha-order other than stdtypes.h // *NOTE: Please keep includes here to a minimum, see above. diff --git a/indra/llcorehttp/bufferarray.h b/indra/llcorehttp/bufferarray.h index 1da807b0a6..076f341736 100755 --- a/indra/llcorehttp/bufferarray.h +++ b/indra/llcorehttp/bufferarray.h @@ -30,6 +30,7 @@ #include #include +#include "boost/intrusive_ptr.hpp" #include "_refcounted.h" -- cgit v1.2.3 From 530bf560b2c2c9bf534bb3ba4f588c72a59be703 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 23 Mar 2015 13:28:24 -0700 Subject: Continue with gcc issues. --- indra/llcorehttp/httpcommon.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'indra') diff --git a/indra/llcorehttp/httpcommon.cpp b/indra/llcorehttp/httpcommon.cpp index 1aece696e3..c201400423 100755 --- a/indra/llcorehttp/httpcommon.cpp +++ b/indra/llcorehttp/httpcommon.cpp @@ -131,18 +131,18 @@ std::string HttpStatus::toString() const { return std::string(""); } - switch (mDetails->mType) + switch (this->mDetails->mType) { case EXT_CURL_EASY: - return std::string(curl_easy_strerror(CURLcode(mDetails->mStatus))); + return std::string(curl_easy_strerror(CURLcode(this->mDetails->mStatus))); case EXT_CURL_MULTI: - return std::string(curl_multi_strerror(CURLMcode(mDetails->mStatus))); + return std::string(curl_multi_strerror(CURLMcode(this->mDetails->mStatus))); case LLCORE: - if (mDetails->mStatus >= 0 && mDetails->mStatus < llcore_errors_count) + if (this->mDetails->mStatus >= 0 && this->mDetails->mStatus < llcore_errors_count) { - return std::string(llcore_errors[mDetails->mStatus]); + return std::string(llcore_errors[this->mDetails->mStatus]); } break; @@ -154,7 +154,7 @@ std::string HttpStatus::toString() const while (true) { int at((bottom + top) / 2); - if (mDetails->mType == http_errors[at].mCode) + if (this->mDetails->mType == http_errors[at].mCode) { return std::string(http_errors[at].mText); } @@ -162,7 +162,7 @@ std::string HttpStatus::toString() const { break; } - else if (mDetails->mType < http_errors[at].mCode) + else if (this->mDetails->mType < http_errors[at].mCode) { top = at; } @@ -182,9 +182,9 @@ std::string HttpStatus::toTerseString() const { std::ostringstream result; - unsigned int error_value((unsigned short)mDetails->mStatus); + unsigned int error_value((unsigned short)(this->mDetails->mStatus)); - switch (mDetails->mType) + switch (this->mDetails->mType) { case EXT_CURL_EASY: result << "Easy_"; @@ -202,7 +202,7 @@ std::string HttpStatus::toTerseString() const if (isHttpStatus()) { result << "Http_"; - error_value = mDetails->mType; + error_value = this->mDetails->mType; } else { @@ -244,7 +244,7 @@ bool HttpStatus::isRetryable() const // Disable the '*this == inv_status' test and look for 'Core_9' // failures in log files. - return ((isHttpStatus() && mDetails->mType >= 499 && mDetails->mType <= 599) || // Include special 499 in retryables + return ((isHttpStatus() && this->mDetails->mType >= 499 && this->mDetails->mType <= 599) || // Include special 499 in retryables *this == cant_connect || // Connection reset/endpoint problems *this == cant_res_proxy || // DNS problems *this == cant_res_host || // DNS problems -- cgit v1.2.3 From e7a1e6198b9bf1b42d60bff9559494887e22d5e7 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 23 Mar 2015 13:39:33 -0700 Subject: Slightly cleaner than this-> ing everythnig. --- indra/llcorehttp/httpcommon.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'indra') diff --git a/indra/llcorehttp/httpcommon.cpp b/indra/llcorehttp/httpcommon.cpp index c201400423..d923dfa5d6 100755 --- a/indra/llcorehttp/httpcommon.cpp +++ b/indra/llcorehttp/httpcommon.cpp @@ -131,18 +131,18 @@ std::string HttpStatus::toString() const { return std::string(""); } - switch (this->mDetails->mType) + switch (getType()) { case EXT_CURL_EASY: - return std::string(curl_easy_strerror(CURLcode(this->mDetails->mStatus))); + return std::string(curl_easy_strerror(CURLcode(getStatus()))); case EXT_CURL_MULTI: - return std::string(curl_multi_strerror(CURLMcode(this->mDetails->mStatus))); + return std::string(curl_multi_strerror(CURLMcode(getStatus()))); case LLCORE: - if (this->mDetails->mStatus >= 0 && this->mDetails->mStatus < llcore_errors_count) + if (getStatus() >= 0 && getStatus() < llcore_errors_count) { - return std::string(llcore_errors[this->mDetails->mStatus]); + return std::string(llcore_errors[getStatus()]); } break; @@ -154,7 +154,7 @@ std::string HttpStatus::toString() const while (true) { int at((bottom + top) / 2); - if (this->mDetails->mType == http_errors[at].mCode) + if (getType() == http_errors[at].mCode) { return std::string(http_errors[at].mText); } @@ -162,7 +162,7 @@ std::string HttpStatus::toString() const { break; } - else if (this->mDetails->mType < http_errors[at].mCode) + else if (getType() < http_errors[at].mCode) { top = at; } @@ -182,9 +182,9 @@ std::string HttpStatus::toTerseString() const { std::ostringstream result; - unsigned int error_value((unsigned short)(this->mDetails->mStatus)); + unsigned int error_value((unsigned short)getStatus()); - switch (this->mDetails->mType) + switch (getType()) { case EXT_CURL_EASY: result << "Easy_"; @@ -202,7 +202,7 @@ std::string HttpStatus::toTerseString() const if (isHttpStatus()) { result << "Http_"; - error_value = this->mDetails->mType; + error_value = getType(); } else { @@ -244,7 +244,7 @@ bool HttpStatus::isRetryable() const // Disable the '*this == inv_status' test and look for 'Core_9' // failures in log files. - return ((isHttpStatus() && this->mDetails->mType >= 499 && this->mDetails->mType <= 599) || // Include special 499 in retryables + return ((isHttpStatus() && getType() >= 499 && getType() <= 599) || // Include special 499 in retryables *this == cant_connect || // Connection reset/endpoint problems *this == cant_res_proxy || // DNS problems *this == cant_res_host || // DNS problems -- cgit v1.2.3 From 379c49fc898961b52f98855c926e958df14e98c3 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 23 Mar 2015 13:50:07 -0700 Subject: Scratch the unique_ptr for the moment. --- indra/llcorehttp/httpcommon.h | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'indra') diff --git a/indra/llcorehttp/httpcommon.h b/indra/llcorehttp/httpcommon.h index 0244755272..2aded492ea 100755 --- a/indra/llcorehttp/httpcommon.h +++ b/indra/llcorehttp/httpcommon.h @@ -188,7 +188,6 @@ /// #include "linden_common.h" // Modifies curl/curl.h interfaces - #include namespace LLCore @@ -292,24 +291,29 @@ struct HttpStatus HttpStatus() { - mDetails = std::unique_ptr
(new Details(LLCORE, HE_SUCCESS)); - } + mDetails = new Details(LLCORE, HE_SUCCESS); + } HttpStatus(type_enum_t type, short status) { - mDetails = std::unique_ptr
(new Details(type, status)); + mDetails = new Details(type, status); } HttpStatus(int http_status) { - mDetails = std::unique_ptr
(new Details(http_status, - (http_status >= 200 && http_status <= 299) ? HE_SUCCESS : HE_REPLY_ERROR)); + mDetails = new Details(http_status, + (http_status >= 200 && http_status <= 299) ? HE_SUCCESS : HE_REPLY_ERROR); llassert(http_status >= 100 && http_status <= 999); } HttpStatus(const HttpStatus & rhs) { - mDetails = std::unique_ptr
(new Details(*rhs.mDetails)); + mDetails = new Details(*rhs.mDetails); + } + + ~HttpStatus() + { + delete mDetails; } HttpStatus & operator=(const HttpStatus & rhs) @@ -468,7 +472,8 @@ private: void * mErrorData; }; - std::unique_ptr
mDetails; + //boost::unique_ptr
mDetails; + Details * mDetails; }; // end struct HttpStatus -- cgit v1.2.3 From 90ae8b84c6bf515486ec94038abc598520e2320f Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 23 Mar 2015 14:22:07 -0700 Subject: Fix headers for gcc build --- indra/llcorehttp/httpcommon.h | 1 + indra/llcorehttp/httpheaders.h | 2 +- indra/llcorehttp/httpoptions.h | 1 - 3 files changed, 2 insertions(+), 2 deletions(-) (limited to 'indra') diff --git a/indra/llcorehttp/httpcommon.h b/indra/llcorehttp/httpcommon.h index 2aded492ea..e806201798 100755 --- a/indra/llcorehttp/httpcommon.h +++ b/indra/llcorehttp/httpcommon.h @@ -188,6 +188,7 @@ /// #include "linden_common.h" // Modifies curl/curl.h interfaces +#include "boost/intrusive_ptr.hpp" #include namespace LLCore diff --git a/indra/llcorehttp/httpheaders.h b/indra/llcorehttp/httpheaders.h index 41832c4931..940f92183c 100755 --- a/indra/llcorehttp/httpheaders.h +++ b/indra/llcorehttp/httpheaders.h @@ -28,8 +28,8 @@ #define _LLCORE_HTTP_HEADERS_H_ +#include "httpcommon.h" #include - #include "_refcounted.h" diff --git a/indra/llcorehttp/httpoptions.h b/indra/llcorehttp/httpoptions.h index d6d892213d..3b9ad9598b 100755 --- a/indra/llcorehttp/httpoptions.h +++ b/indra/llcorehttp/httpoptions.h @@ -29,7 +29,6 @@ #include "httpcommon.h" - #include "_refcounted.h" -- cgit v1.2.3 From d46fe1a1bb0c375ebcfe3c1fe9701e37135acd65 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 23 Mar 2015 14:48:34 -0700 Subject: Microsoft is not nearly picky enough. Headder issues caught by gcc MS likes fine. --- indra/llcorehttp/httpcommon.h | 1 + indra/llcorehttp/httprequest.h | 2 +- indra/llcorehttp/httpresponse.h | 2 +- indra/llmessage/llhttpclient.cpp | 45 ---------------------------------------- 4 files changed, 3 insertions(+), 47 deletions(-) (limited to 'indra') diff --git a/indra/llcorehttp/httpcommon.h b/indra/llcorehttp/httpcommon.h index e806201798..e673d7b589 100755 --- a/indra/llcorehttp/httpcommon.h +++ b/indra/llcorehttp/httpcommon.h @@ -189,6 +189,7 @@ #include "linden_common.h" // Modifies curl/curl.h interfaces #include "boost/intrusive_ptr.hpp" +#include "boost/shared_ptr.hpp" #include namespace LLCore diff --git a/indra/llcorehttp/httprequest.h b/indra/llcorehttp/httprequest.h index c90e056d62..4cacb3a20b 100755 --- a/indra/llcorehttp/httprequest.h +++ b/indra/llcorehttp/httprequest.h @@ -97,7 +97,7 @@ public: typedef unsigned int policy_t; typedef unsigned int priority_t; - typedef std::shared_ptr ptr_t; + typedef boost::shared_ptr ptr_t; public: /// @name PolicyMethods /// @{ diff --git a/indra/llcorehttp/httpresponse.h b/indra/llcorehttp/httpresponse.h index c6b470ee3f..39b582ff85 100755 --- a/indra/llcorehttp/httpresponse.h +++ b/indra/llcorehttp/httpresponse.h @@ -72,7 +72,7 @@ public: /// Statistics for the HTTP struct TransferStats { - typedef std::shared_ptr ptr_t; + typedef boost::shared_ptr ptr_t; TransferStats() : mSizeDownload(0.0), mTotalTime(0.0), mSpeedDownload(0.0) {} F64 mSizeDownload; diff --git a/indra/llmessage/llhttpclient.cpp b/indra/llmessage/llhttpclient.cpp index 27c94b1182..b4a76cb808 100755 --- a/indra/llmessage/llhttpclient.cpp +++ b/indra/llmessage/llhttpclient.cpp @@ -218,51 +218,6 @@ void LLHTTPClient::setCertVerifyCallback(LLURLRequest::SSLCertVerifyCallback cal LLHTTPClient::mCertVerifyCallback = callback; } -#if 0 -typedef std::shared_ptr HttpRequestPtr_t; -typedef std::unique_ptr HttpOptionsPtr_t; -typedef std::unique_ptr InjectorPtr_t; - -static void request_( - const std::string& url, - EHTTPMethod method, - Injector* body_injector, - LLCurl::ResponderPtr responder, - const F32 timeout = HTTP_REQUEST_EXPIRY_SECS, - const LLSD& headers = LLSD(), - bool follow_redirects = true - ) -{ - HttpRequestPtr_t httpReq = HttpRequestPtr_t(new LLCore::HttpRequest()); - - HttpOptionsPtr_t httpOpts = HttpOptionsPtr_t(new LLCore::HttpOptions()); - - httpOpts->setFollowRedirects(follow_redirects); - httpOpts->setRetries(12); - httpOpts->setUseRetryAfter(true); - // for the moment lets just truncate. 60 seconds vs 60.5 seconds - httpOpts->setTransferTimeout((unsigned int)timeout); - - switch (method) - { - case HTTP_GET: - httpReq->requestGet(0, 0, url, httpOpts.get(), headers, handler); - break; - case HTTP_HEAD: - httpReq->requestHead(0, 0, url, httpOpts.get(), headers, handler); - break; - case HTTP_PUT: - httpReq->requestPut(0, 0, url, ); - break; - case HTTP_POST: - httpReq->requestPost(0, 0, url, null, httpOpts.get(), headers, handler); - break; - } - - -} -#endif - static void request( const std::string& url, EHTTPMethod method, -- cgit v1.2.3 From d9e886809685cc207a52d0429d1badf6d537e5d7 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 23 Mar 2015 15:41:40 -0700 Subject: Fix the tests to not directly access HttpsStatus' internals. --- indra/llcorehttp/tests/test_httpstatus.hpp | 90 +++++++++++------------------- 1 file changed, 33 insertions(+), 57 deletions(-) (limited to 'indra') diff --git a/indra/llcorehttp/tests/test_httpstatus.hpp b/indra/llcorehttp/tests/test_httpstatus.hpp index 0b379836c9..5f8ed14c51 100755 --- a/indra/llcorehttp/tests/test_httpstatus.hpp +++ b/indra/llcorehttp/tests/test_httpstatus.hpp @@ -55,32 +55,28 @@ void HttpStatusTestObjectType::test<1>() // auto allocation fine for this HttpStatus status; - status.mType = HttpStatus::EXT_CURL_EASY; - status.mStatus = 0; + + status = HttpStatus(HttpStatus::EXT_CURL_EASY, 0); ensure(bool(status)); ensure(false == !(status)); - status.mType = HttpStatus::EXT_CURL_MULTI; - status.mStatus = 0; + status = HttpStatus(HttpStatus::EXT_CURL_MULTI, 0); ensure(bool(status)); ensure(false == !(status)); - - status.mType = HttpStatus::LLCORE; - status.mStatus = HE_SUCCESS; + + status = HttpStatus(HttpStatus::LLCORE, HE_SUCCESS); ensure(bool(status)); ensure(false == !(status)); - status.mType = HttpStatus::EXT_CURL_MULTI; - status.mStatus = -1; + status = HttpStatus(HttpStatus::EXT_CURL_MULTI, -1); ensure(false == bool(status)); ensure(!(status)); - status.mType = HttpStatus::EXT_CURL_EASY; - status.mStatus = CURLE_BAD_DOWNLOAD_RESUME; + status = HttpStatus(HttpStatus::EXT_CURL_EASY, CURLE_BAD_DOWNLOAD_RESUME); ensure(false == bool(status)); ensure(!(status)); @@ -105,27 +101,22 @@ void HttpStatusTestObjectType::test<3>() { set_test_name("HttpStatus valid status string conversion"); - HttpStatus status; - status.mType = HttpStatus::EXT_CURL_EASY; - status.mStatus = 0; + HttpStatus status = HttpStatus(HttpStatus::EXT_CURL_EASY, 0); std::string msg = status.toString(); // std::cout << "Result: " << msg << std::endl; ensure(msg.empty()); - - status.mType = HttpStatus::EXT_CURL_EASY; - status.mStatus = CURLE_BAD_FUNCTION_ARGUMENT; + + status = HttpStatus(HttpStatus::EXT_CURL_EASY, CURLE_BAD_FUNCTION_ARGUMENT); msg = status.toString(); // std::cout << "Result: " << msg << std::endl; ensure(! msg.empty()); - status.mType = HttpStatus::EXT_CURL_MULTI; - status.mStatus = CURLM_OUT_OF_MEMORY; + status = HttpStatus(HttpStatus::EXT_CURL_MULTI, CURLM_OUT_OF_MEMORY); msg = status.toString(); // std::cout << "Result: " << msg << std::endl; ensure(! msg.empty()); - status.mType = HttpStatus::LLCORE; - status.mStatus = HE_SHUTTING_DOWN; + status = HttpStatus(HttpStatus::LLCORE, HE_SHUTTING_DOWN); msg = status.toString(); // std::cout << "Result: " << msg << std::endl; ensure(! msg.empty()); @@ -137,21 +128,17 @@ void HttpStatusTestObjectType::test<4>() { set_test_name("HttpStatus invalid status string conversion"); - HttpStatus status; - status.mType = HttpStatus::EXT_CURL_EASY; - status.mStatus = 32726; + HttpStatus status = HttpStatus(HttpStatus::EXT_CURL_EASY, 32726); std::string msg = status.toString(); // std::cout << "Result: " << msg << std::endl; ensure(! msg.empty()); - - status.mType = HttpStatus::EXT_CURL_MULTI; - status.mStatus = -470; + + status = HttpStatus(HttpStatus::EXT_CURL_MULTI, -470); msg = status.toString(); // std::cout << "Result: " << msg << std::endl; ensure(! msg.empty()); - status.mType = HttpStatus::LLCORE; - status.mStatus = 923; + status = HttpStatus(HttpStatus::LLCORE, 923); msg = status.toString(); // std::cout << "Result: " << msg << std::endl; ensure(! msg.empty()); @@ -170,10 +157,9 @@ void HttpStatusTestObjectType::test<5>() HttpStatus status2(HttpStatus::EXT_CURL_EASY, HE_SUCCESS); ensure(status1 != status2); - status1.mType = HttpStatus::LLCORE; - status1.mStatus = HE_REPLY_ERROR; - status2.mType = HttpStatus::LLCORE; - status2.mStatus= HE_SHUTTING_DOWN; + status1 = HttpStatus(HttpStatus::LLCORE, HE_REPLY_ERROR); + status1 = HttpStatus(HttpStatus::LLCORE, HE_SHUTTING_DOWN); + ensure(status1 != status2); } @@ -183,44 +169,38 @@ void HttpStatusTestObjectType::test<6>() set_test_name("HttpStatus basic HTTP status encoding"); HttpStatus status; - status.mType = 200; - status.mStatus = HE_SUCCESS; + + status = HttpStatus(200, HE_SUCCESS); std::string msg = status.toString(); ensure(msg.empty()); ensure(bool(status)); // Normally a success but application says error - status.mStatus = HE_REPLY_ERROR; + status = HttpStatus(200, HE_REPLY_ERROR); msg = status.toString(); ensure(! msg.empty()); ensure(! bool(status)); ensure(status.toULong() > 1UL); // Biggish number, not a bool-to-ulong // Same statuses with distinct success/fail are distinct - status.mType = 200; - status.mStatus = HE_SUCCESS; + status = HttpStatus(200, HE_SUCCESS); HttpStatus status2(200, HE_REPLY_ERROR); ensure(status != status2); // Normally an error but application says okay - status.mType = 406; - status.mStatus = HE_SUCCESS; + status = HttpStatus(406, HE_SUCCESS); msg = status.toString(); ensure(msg.empty()); ensure(bool(status)); // Different statuses but both successful are distinct - status.mType = 200; - status.mStatus = HE_SUCCESS; - status2.mType = 201; - status2.mStatus = HE_SUCCESS; + status = HttpStatus(200, HE_SUCCESS); + status2 = HttpStatus(201, HE_SUCCESS); ensure(status != status2); // Different statuses but both failed are distinct - status.mType = 200; - status.mStatus = HE_REPLY_ERROR; - status2.mType = 201; - status2.mStatus = HE_REPLY_ERROR; + status = HttpStatus(200, HE_REPLY_ERROR); + status2 = HttpStatus(201, HE_REPLY_ERROR); ensure(status != status2); } @@ -234,27 +214,23 @@ void HttpStatusTestObjectType::test<7>() ensure(! msg.empty()); // Should be something ensure(msg == "Continue"); - status.mStatus = HE_SUCCESS; + status = HttpStatus(200, HE_SUCCESS); msg = status.toString(); ensure(msg.empty()); // Success is empty - status.mType = 199; - status.mStatus = HE_REPLY_ERROR; + status = HttpStatus(199, HE_REPLY_ERROR); msg = status.toString(); ensure(msg == "Unknown error"); - status.mType = 505; // Last defined string - status.mStatus = HE_REPLY_ERROR; + status = HttpStatus(505, HE_REPLY_ERROR); msg = status.toString(); ensure(msg == "HTTP Version not supported"); - status.mType = 506; // One beyond - status.mStatus = HE_REPLY_ERROR; + status = HttpStatus(506, HE_REPLY_ERROR); msg = status.toString(); ensure(msg == "Unknown error"); - status.mType = 999; // Last HTTP status - status.mStatus = HE_REPLY_ERROR; + status = HttpStatus(999, HE_REPLY_ERROR); msg = status.toString(); ensure(msg == "Unknown error"); } -- cgit v1.2.3 From 753d643daf4ff7407fbc7e23662b5c6e5ffbc96f Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 23 Mar 2015 16:10:45 -0700 Subject: Client adapter is removed. Its tests should be too. --- indra/llmessage/tests/llhttpclientadapter_test.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/llmessage/tests/llhttpclientadapter_test.cpp b/indra/llmessage/tests/llhttpclientadapter_test.cpp index e9ce116bb3..e0a82e237b 100755 --- a/indra/llmessage/tests/llhttpclientadapter_test.cpp +++ b/indra/llmessage/tests/llhttpclientadapter_test.cpp @@ -23,7 +23,7 @@ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ - +#if 0 #include "llhttpclientadapter.h" #include "../test/lltut.h" @@ -219,3 +219,4 @@ namespace tut } } +#endif \ No newline at end of file -- cgit v1.2.3 From 782b9a324d61e4e7814d9f7ce09b50e792c51788 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 23 Mar 2015 16:47:26 -0700 Subject: No explicit NULL in shared constructor --- indra/newview/llmaterialmgr.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra') diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index b4ebe4adb1..81372f10b3 100755 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -130,9 +130,9 @@ LLMaterialMgr::LLMaterialMgr(): mGetAllCallbacks(), mPutQueue(), mMaterials(), - mHttpRequest(NULL), - mHttpHeaders(NULL), - mHttpOptions(NULL), + mHttpRequest(), + mHttpHeaders(), + mHttpOptions(), mHttpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID), mHttpPriority(0) { -- cgit v1.2.3 From 1ac97766935ba50178fe379d3e7f02e6d2261819 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 23 Mar 2015 17:17:45 -0700 Subject: MAX_ACTIVE_REQUEST_COUNT no longer used --- indra/llmessage/llcurl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/llmessage/llcurl.cpp b/indra/llmessage/llcurl.cpp index 0080dd6138..0ba5bdc631 100755 --- a/indra/llmessage/llcurl.cpp +++ b/indra/llmessage/llcurl.cpp @@ -75,7 +75,7 @@ static const U32 EASY_HANDLE_POOL_SIZE = 5; static const S32 MULTI_PERFORM_CALL_REPEAT = 5; static const S32 CURL_REQUEST_TIMEOUT = 120; // seconds per operation static const S32 CURL_CONNECT_TIMEOUT = 30; //seconds to wait for a connection -static const S32 MAX_ACTIVE_REQUEST_COUNT = 100; +//static const S32 MAX_ACTIVE_REQUEST_COUNT = 100; // DEBUG // S32 gCurlEasyCount = 0; -- cgit v1.2.3 From 3c46c6bcf2afcac5e0d6f435480cbee5c3136f63 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 24 Mar 2015 10:00:30 -0700 Subject: Boost unique_ptr into xmlrpc --- indra/llmessage/llcurl.cpp | 2 ++ indra/newview/llxmlrpctransaction.cpp | 13 ++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) (limited to 'indra') diff --git a/indra/llmessage/llcurl.cpp b/indra/llmessage/llcurl.cpp index 0ba5bdc631..ef28a4d211 100755 --- a/indra/llmessage/llcurl.cpp +++ b/indra/llmessage/llcurl.cpp @@ -69,12 +69,14 @@ do this. */ +// *TODO: TSN remove the commented code from this file ////////////////////////////////////////////////////////////////////////////// static const U32 EASY_HANDLE_POOL_SIZE = 5; static const S32 MULTI_PERFORM_CALL_REPEAT = 5; static const S32 CURL_REQUEST_TIMEOUT = 120; // seconds per operation static const S32 CURL_CONNECT_TIMEOUT = 30; //seconds to wait for a connection + //static const S32 MAX_ACTIVE_REQUEST_COUNT = 100; // DEBUG // diff --git a/indra/newview/llxmlrpctransaction.cpp b/indra/newview/llxmlrpctransaction.cpp index 2270b840a0..f7b886b2d2 100755 --- a/indra/newview/llxmlrpctransaction.cpp +++ b/indra/newview/llxmlrpctransaction.cpp @@ -48,6 +48,13 @@ #include "llappviewer.h" #include "lltrans.h" +#include "boost/move/unique_ptr.hpp" + +namespace boost +{ + using ::boost::movelib::unique_ptr; // move unique_ptr into the boost namespace. +} + // Static instance of LLXMLRPCListener declared here so that every time we // bring in this code, we instantiate a listener. If we put the static // instance of LLXMLRPCListener into llxmlrpclistener.cpp, the linker would @@ -168,7 +175,7 @@ public: virtual void onCompleted(LLCore::HttpHandle handle, LLCore::HttpResponse * response); - typedef std::unique_ptr ptr_t; + typedef boost::unique_ptr ptr_t; private: @@ -309,7 +316,7 @@ void LLXMLRPCTransaction::Handler::onCompleted(LLCore::HttpHandle handle, LLXMLRPCTransaction::Impl::Impl(const std::string& uri, XMLRPC_REQUEST request, bool useGzip) - : mHttpRequest(0), + : mHttpRequest(), mStatus(LLXMLRPCTransaction::StatusNotStarted), mURI(uri), mResponse(0) @@ -320,7 +327,7 @@ LLXMLRPCTransaction::Impl::Impl(const std::string& uri, LLXMLRPCTransaction::Impl::Impl(const std::string& uri, const std::string& method, LLXMLRPCValue params, bool useGzip) - : mHttpRequest(0), + : mHttpRequest(), mStatus(LLXMLRPCTransaction::StatusNotStarted), mURI(uri), mResponse(0) -- cgit v1.2.3 From e140118fc41b79e403b299cabe1653af1971e87a Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 25 Mar 2015 11:31:11 -0700 Subject: Replace appearance responder with new LLCore Appearance Handler. Prep for some slight cleanup of the code. Add AP_AVATAR Policy --- indra/llcorehttp/httpcommon.cpp | 4 + indra/llcorehttp/httpcommon.h | 13 +- indra/llmessage/llhttpsdhandler.cpp | 4 +- indra/newview/llappcorehttp.cpp | 5 + indra/newview/llappcorehttp.h | 13 +- indra/newview/llappearancemgr.cpp | 8282 +++++++++++++++++---------------- indra/newview/llappearancemgr.h | 20 +- indra/newview/llmaterialmgr.cpp | 2 +- indra/newview/llxmlrpctransaction.cpp | 8 - 9 files changed, 4200 insertions(+), 4151 deletions(-) (limited to 'indra') diff --git a/indra/llcorehttp/httpcommon.cpp b/indra/llcorehttp/httpcommon.cpp index d923dfa5d6..99238ea920 100755 --- a/indra/llcorehttp/httpcommon.cpp +++ b/indra/llcorehttp/httpcommon.cpp @@ -149,6 +149,10 @@ std::string HttpStatus::toString() const default: if (isHttpStatus()) { + // special handling for status 499 "Linden Catchall" + if ((getType() == 499) && (!getMessage().empty())) + return getMessage(); + // Binary search for the error code and string int bottom(0), top(http_errors_count); while (true) diff --git a/indra/llcorehttp/httpcommon.h b/indra/llcorehttp/httpcommon.h index e673d7b589..64075f5f20 100755 --- a/indra/llcorehttp/httpcommon.h +++ b/indra/llcorehttp/httpcommon.h @@ -286,6 +286,8 @@ enum HttpError /// 5. Construct an HTTP 301 status code to be treated as success: /// HttpStatus(301, HE_SUCCESS); /// +/// 6. Construct a failed status of HTTP Status 499 with a custom error message +/// HttpStatus(499, "Failed LLSD Response"); struct HttpStatus { @@ -307,6 +309,14 @@ struct HttpStatus (http_status >= 200 && http_status <= 299) ? HE_SUCCESS : HE_REPLY_ERROR); llassert(http_status >= 100 && http_status <= 999); } + + HttpStatus(int http_status, const std::string &message) + { + mDetails = new Details(http_status, + (http_status >= 200 && http_status <= 299) ? HE_SUCCESS : HE_REPLY_ERROR); + llassert(http_status >= 100 && http_status <= 999); + mDetails->mMessage = message; + } HttpStatus(const HttpStatus & rhs) { @@ -420,9 +430,6 @@ struct HttpStatus return mDetails->mType; } - // TODO: There must be a better way to do this. Don't want to set these - // values here since they increase the size of a structure that is already - // being passed on the stack. Consider my options /// Returns an optional error message if one has been set. /// std::string getMessage() const diff --git a/indra/llmessage/llhttpsdhandler.cpp b/indra/llmessage/llhttpsdhandler.cpp index aa9801cebc..18daf443ee 100644 --- a/indra/llmessage/llhttpsdhandler.cpp +++ b/indra/llmessage/llhttpsdhandler.cpp @@ -76,7 +76,9 @@ void LLHttpSDHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRespons this->onSuccess(response, resplsd); } - // The handler must destroy itself when it is done. + // The handler must destroy itself when it is done. + // *TODO: I'm not fond of this pattern. A class shooting itself in the head + // outside of a smart pointer always makes me nervous. delete this; } diff --git a/indra/newview/llappcorehttp.cpp b/indra/newview/llappcorehttp.cpp index 420d37369f..8da78a45a6 100755 --- a/indra/newview/llappcorehttp.cpp +++ b/indra/newview/llappcorehttp.cpp @@ -102,6 +102,11 @@ static const struct 2, 1, 8, 0, false, "RenderMaterials", "material manager requests" + }, + { // AP_AVATAR + 2, 1, 32, 0, true, + "Avatar", + "Avatar requests" } }; diff --git a/indra/newview/llappcorehttp.h b/indra/newview/llappcorehttp.h index b636c3b43c..95b56100a6 100755 --- a/indra/newview/llappcorehttp.h +++ b/indra/newview/llappcorehttp.h @@ -175,7 +175,18 @@ public: /// Request rate: low /// Pipelined: no AP_MATERIALS, - + + /// Appearance resource requests and puts. + /// + /// Destination: simhost:12043 + /// Protocol: https: + /// Transfer size: KB + /// Long poll: no + /// Concurrency: mid + /// Request rate: low + /// Pipelined: yes + AP_AVATAR, + AP_COUNT // Must be last }; diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp index 9e8479eeef..077e944925 100755 --- a/indra/newview/llappearancemgr.cpp +++ b/indra/newview/llappearancemgr.cpp @@ -1,4138 +1,4150 @@ -/** - * @file llappearancemgr.cpp - * @brief Manager for initiating appearance changes on the viewer - * - * $LicenseInfo:firstyear=2004&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#include "llviewerprecompiledheaders.h" - -#include -#include "llaccordionctrltab.h" -#include "llagent.h" -#include "llagentcamera.h" -#include "llagentwearables.h" -#include "llappearancemgr.h" -#include "llattachmentsmgr.h" -#include "llcommandhandler.h" -#include "lleventtimer.h" -#include "llfloatersidepanelcontainer.h" -#include "llgesturemgr.h" -#include "llinventorybridge.h" -#include "llinventoryfunctions.h" -#include "llinventoryobserver.h" -#include "llnotificationsutil.h" -#include "lloutfitobserver.h" -#include "lloutfitslist.h" -#include "llselectmgr.h" -#include "llsidepanelappearance.h" -#include "llviewerobjectlist.h" -#include "llvoavatar.h" -#include "llvoavatarself.h" -#include "llviewerregion.h" -#include "llwearablelist.h" -#include "llsdutil.h" -#include "llsdserialize.h" -#include "llhttpretrypolicy.h" -#include "llaisapi.h" - -#if LL_MSVC -// disable boost::lexical_cast warning -#pragma warning (disable:4702) -#endif - -std::string self_av_string() -{ - // On logout gAgentAvatarp can already be invalid - return isAgentAvatarValid() ? gAgentAvatarp->avString() : ""; -} - -// RAII thingy to guarantee that a variable gets reset when the Setter -// goes out of scope. More general utility would be handy - TODO: -// check boost. -class BoolSetter -{ -public: - BoolSetter(bool& var): - mVar(var) - { - mVar = true; - } - ~BoolSetter() - { - mVar = false; - } -private: - bool& mVar; -}; - -char ORDER_NUMBER_SEPARATOR('@'); - -class LLOutfitUnLockTimer: public LLEventTimer -{ -public: - LLOutfitUnLockTimer(F32 period) : LLEventTimer(period) - { - // restart timer on BOF changed event - LLOutfitObserver::instance().addBOFChangedCallback(boost::bind( - &LLOutfitUnLockTimer::reset, this)); - stop(); - } - - /*virtual*/ - BOOL tick() - { - if(mEventTimer.hasExpired()) - { - LLAppearanceMgr::instance().setOutfitLocked(false); - } - return FALSE; - } - void stop() { mEventTimer.stop(); } - void start() { mEventTimer.start(); } - void reset() { mEventTimer.reset(); } - BOOL getStarted() { return mEventTimer.getStarted(); } - - LLTimer& getEventTimer() { return mEventTimer;} -}; - -// support for secondlife:///app/appearance SLapps -class LLAppearanceHandler : public LLCommandHandler -{ -public: - // requests will be throttled from a non-trusted browser - LLAppearanceHandler() : LLCommandHandler("appearance", UNTRUSTED_THROTTLE) {} - - bool handle(const LLSD& params, const LLSD& query_map, LLMediaCtrl* web) - { - // support secondlife:///app/appearance/show, but for now we just - // make all secondlife:///app/appearance SLapps behave this way - if (!LLUI::sSettingGroups["config"]->getBOOL("EnableAppearance")) - { - LLNotificationsUtil::add("NoAppearance", LLSD(), LLSD(), std::string("SwitchToStandardSkinAndQuit")); - return true; - } - - LLFloaterSidePanelContainer::showPanel("appearance", LLSD()); - return true; - } -}; - -LLAppearanceHandler gAppearanceHandler; - - -LLUUID findDescendentCategoryIDByName(const LLUUID& parent_id, const std::string& name) -{ - LLInventoryModel::cat_array_t cat_array; - LLInventoryModel::item_array_t item_array; - LLNameCategoryCollector has_name(name); - gInventory.collectDescendentsIf(parent_id, - cat_array, - item_array, - LLInventoryModel::EXCLUDE_TRASH, - has_name); - if (0 == cat_array.size()) - return LLUUID(); - else - { - LLViewerInventoryCategory *cat = cat_array.at(0); - if (cat) - return cat->getUUID(); - else - { - LL_WARNS() << "null cat" << LL_ENDL; - return LLUUID(); - } - } -} - -// We want this to be much lower (e.g. 15.0 is usually fine), bumping -// up for now until we can diagnose some cases of very slow response -// to requests. -const F32 DEFAULT_RETRY_AFTER_INTERVAL = 300.0; - -// Given the current back-end problems, retrying is causing too many -// duplicate items. Bump this back to 2 once they are resolved (or can -// leave at 0 if the operations become actually reliable). -const S32 DEFAULT_MAX_RETRIES = 0; - -class LLCallAfterInventoryBatchMgr: public LLEventTimer -{ -public: - LLCallAfterInventoryBatchMgr(const LLUUID& dst_cat_id, - const std::string& phase_name, - nullary_func_t on_completion_func, - nullary_func_t on_failure_func = no_op, - F32 retry_after = DEFAULT_RETRY_AFTER_INTERVAL, - S32 max_retries = DEFAULT_MAX_RETRIES - ): - mDstCatID(dst_cat_id), - mTrackingPhase(phase_name), - mOnCompletionFunc(on_completion_func), - mOnFailureFunc(on_failure_func), - mRetryAfter(retry_after), - mMaxRetries(max_retries), - mPendingRequests(0), - mFailCount(0), - mCompletionOrFailureCalled(false), - mRetryCount(0), - LLEventTimer(5.0) - { - if (!mTrackingPhase.empty()) - { - selfStartPhase(mTrackingPhase); - } - } - - void addItems(LLInventoryModel::item_array_t& src_items) - { - for (LLInventoryModel::item_array_t::const_iterator it = src_items.begin(); - it != src_items.end(); - ++it) - { - LLViewerInventoryItem* item = *it; - llassert(item); - addItem(item->getUUID()); - } - } - - // Request or re-request operation for specified item. - void addItem(const LLUUID& item_id) - { - LL_DEBUGS("Avatar") << "item_id " << item_id << LL_ENDL; - if (!requestOperation(item_id)) - { - LL_DEBUGS("Avatar") << "item_id " << item_id << " requestOperation false, skipping" << LL_ENDL; - return; - } - - mPendingRequests++; - // On a re-request, this will reset the timer. - mWaitTimes[item_id] = LLTimer(); - if (mRetryCounts.find(item_id) == mRetryCounts.end()) - { - mRetryCounts[item_id] = 0; - } - else - { - mRetryCounts[item_id]++; - } - } - - virtual bool requestOperation(const LLUUID& item_id) = 0; - - void onOp(const LLUUID& src_id, const LLUUID& dst_id, LLTimer timestamp) - { - if (ll_frand() < gSavedSettings.getF32("InventoryDebugSimulateLateOpRate")) - { - LL_WARNS() << "Simulating late operation by punting handling to later" << LL_ENDL; - doAfterInterval(boost::bind(&LLCallAfterInventoryBatchMgr::onOp,this,src_id,dst_id,timestamp), - mRetryAfter); - return; - } - mPendingRequests--; - F32 elapsed = timestamp.getElapsedTimeF32(); - LL_DEBUGS("Avatar") << "op done, src_id " << src_id << " dst_id " << dst_id << " after " << elapsed << " seconds" << LL_ENDL; - if (mWaitTimes.find(src_id) == mWaitTimes.end()) - { - // No longer waiting for this item - either serviced - // already or gave up after too many retries. - LL_WARNS() << "duplicate or late operation, src_id " << src_id << "dst_id " << dst_id - << " elapsed " << elapsed << " after end " << (S32) mCompletionOrFailureCalled << LL_ENDL; - } - mTimeStats.push(elapsed); - mWaitTimes.erase(src_id); - if (mWaitTimes.empty() && !mCompletionOrFailureCalled) - { - onCompletionOrFailure(); - } - } - - void onCompletionOrFailure() - { - assert (!mCompletionOrFailureCalled); - mCompletionOrFailureCalled = true; - - // Will never call onCompletion() if any item has been flagged as - // a failure - otherwise could wind up with corrupted - // outfit, involuntary nudity, etc. - reportStats(); - if (!mTrackingPhase.empty()) - { - selfStopPhase(mTrackingPhase); - } - if (!mFailCount) - { - onCompletion(); - } - else - { - onFailure(); - } - } - - void onFailure() - { - LL_INFOS() << "failed" << LL_ENDL; - mOnFailureFunc(); - } - - void onCompletion() - { - LL_INFOS() << "done" << LL_ENDL; - mOnCompletionFunc(); - } - - // virtual - // Will be deleted after returning true - only safe to do this if all callbacks have fired. - BOOL tick() - { - // mPendingRequests will be zero if all requests have been - // responded to. mWaitTimes.empty() will be true if we have - // received at least one reply for each UUID. If requests - // have been dropped and retried, these will not necessarily - // be the same. Only safe to return true if all requests have - // been serviced, since it will result in this object being - // deleted. - bool all_done = (mPendingRequests==0); - - if (!mWaitTimes.empty()) - { - LL_WARNS() << "still waiting on " << mWaitTimes.size() << " items" << LL_ENDL; - for (std::map::iterator it = mWaitTimes.begin(); - it != mWaitTimes.end();) - { - // Use a copy of iterator because it may be erased/invalidated. - std::map::iterator curr_it = it; - ++it; - - F32 time_waited = curr_it->second.getElapsedTimeF32(); - S32 retries = mRetryCounts[curr_it->first]; - if (time_waited > mRetryAfter) - { - if (retries < mMaxRetries) - { - LL_DEBUGS("Avatar") << "Waited " << time_waited << - " for " << curr_it->first << ", retrying" << LL_ENDL; - mRetryCount++; - addItem(curr_it->first); - } - else - { - LL_WARNS() << "Giving up on " << curr_it->first << " after too many retries" << LL_ENDL; - mWaitTimes.erase(curr_it); - mFailCount++; - } - } - if (mWaitTimes.empty()) - { - onCompletionOrFailure(); - } - - } - } - return all_done; - } - - void reportStats() - { - LL_DEBUGS("Avatar") << "Phase: " << mTrackingPhase << LL_ENDL; - LL_DEBUGS("Avatar") << "mFailCount: " << mFailCount << LL_ENDL; - LL_DEBUGS("Avatar") << "mRetryCount: " << mRetryCount << LL_ENDL; - LL_DEBUGS("Avatar") << "Times: n " << mTimeStats.getCount() << " min " << mTimeStats.getMinValue() << " max " << mTimeStats.getMaxValue() << LL_ENDL; - LL_DEBUGS("Avatar") << "Mean " << mTimeStats.getMean() << " stddev " << mTimeStats.getStdDev() << LL_ENDL; - } - - virtual ~LLCallAfterInventoryBatchMgr() - { - LL_DEBUGS("Avatar") << "deleting" << LL_ENDL; - } - -protected: - std::string mTrackingPhase; - std::map mWaitTimes; - std::map mRetryCounts; - LLUUID mDstCatID; - nullary_func_t mOnCompletionFunc; - nullary_func_t mOnFailureFunc; - F32 mRetryAfter; - S32 mMaxRetries; - S32 mPendingRequests; - S32 mFailCount; - S32 mRetryCount; - bool mCompletionOrFailureCalled; - LLViewerStats::StatsAccumulator mTimeStats; -}; - -class LLCallAfterInventoryCopyMgr: public LLCallAfterInventoryBatchMgr -{ -public: - LLCallAfterInventoryCopyMgr(LLInventoryModel::item_array_t& src_items, - const LLUUID& dst_cat_id, - const std::string& phase_name, - nullary_func_t on_completion_func, - nullary_func_t on_failure_func = no_op, - F32 retry_after = DEFAULT_RETRY_AFTER_INTERVAL, - S32 max_retries = DEFAULT_MAX_RETRIES - ): - LLCallAfterInventoryBatchMgr(dst_cat_id, phase_name, on_completion_func, on_failure_func, retry_after, max_retries) - { - addItems(src_items); - sInstanceCount++; - } - - ~LLCallAfterInventoryCopyMgr() - { - sInstanceCount--; - } - - virtual bool requestOperation(const LLUUID& item_id) - { - LLViewerInventoryItem *item = gInventory.getItem(item_id); - llassert(item); - LL_DEBUGS("Avatar") << "copying item " << item_id << LL_ENDL; - if (ll_frand() < gSavedSettings.getF32("InventoryDebugSimulateOpFailureRate")) - { - LL_DEBUGS("Avatar") << "simulating failure by not sending request for item " << item_id << LL_ENDL; - return true; - } - copy_inventory_item( - gAgent.getID(), - item->getPermissions().getOwner(), - item->getUUID(), - mDstCatID, - std::string(), - new LLBoostFuncInventoryCallback(boost::bind(&LLCallAfterInventoryBatchMgr::onOp,this,item_id,_1,LLTimer())) - ); - return true; - } - - static S32 getInstanceCount() { return sInstanceCount; } - -private: - static S32 sInstanceCount; -}; - -S32 LLCallAfterInventoryCopyMgr::sInstanceCount = 0; - -class LLWearCategoryAfterCopy: public LLInventoryCallback -{ -public: - LLWearCategoryAfterCopy(bool append): - mAppend(append) - {} - - // virtual - void fire(const LLUUID& id) - { - // Wear the inventory category. - LLInventoryCategory* cat = gInventory.getCategory(id); - LLAppearanceMgr::instance().wearInventoryCategoryOnAvatar(cat, mAppend); - } - -private: - bool mAppend; -}; - -class LLTrackPhaseWrapper : public LLInventoryCallback -{ -public: - LLTrackPhaseWrapper(const std::string& phase_name, LLPointer cb = NULL): - mTrackingPhase(phase_name), - mCB(cb) - { - selfStartPhase(mTrackingPhase); - } - - // virtual - void fire(const LLUUID& id) - { - if (mCB) - { - mCB->fire(id); - } - } - - // virtual - ~LLTrackPhaseWrapper() - { - selfStopPhase(mTrackingPhase); - } - -protected: - std::string mTrackingPhase; - LLPointer mCB; -}; - -LLUpdateAppearanceOnDestroy::LLUpdateAppearanceOnDestroy(bool enforce_item_restrictions, - bool enforce_ordering, - nullary_func_t post_update_func - ): - mFireCount(0), - mEnforceItemRestrictions(enforce_item_restrictions), - mEnforceOrdering(enforce_ordering), - mPostUpdateFunc(post_update_func) -{ - selfStartPhase("update_appearance_on_destroy"); -} - -void LLUpdateAppearanceOnDestroy::fire(const LLUUID& inv_item) -{ - LLViewerInventoryItem* item = (LLViewerInventoryItem*)gInventory.getItem(inv_item); - const std::string item_name = item ? item->getName() : "ITEM NOT FOUND"; -#ifndef LL_RELEASE_FOR_DOWNLOAD - LL_DEBUGS("Avatar") << self_av_string() << "callback fired [ name:" << item_name << " UUID:" << inv_item << " count:" << mFireCount << " ] " << LL_ENDL; -#endif - mFireCount++; -} - -LLUpdateAppearanceOnDestroy::~LLUpdateAppearanceOnDestroy() -{ - if (!LLApp::isExiting()) - { - // speculative fix for MAINT-1150 - LL_INFOS("Avatar") << self_av_string() << "done update appearance on destroy" << LL_ENDL; - - selfStopPhase("update_appearance_on_destroy"); - - LLAppearanceMgr::instance().updateAppearanceFromCOF(mEnforceItemRestrictions, - mEnforceOrdering, - mPostUpdateFunc); - } -} - -LLUpdateAppearanceAndEditWearableOnDestroy::LLUpdateAppearanceAndEditWearableOnDestroy(const LLUUID& item_id): - mItemID(item_id) -{ -} - -void edit_wearable_and_customize_avatar(LLUUID item_id) -{ - // Start editing the item if previously requested. - gAgentWearables.editWearableIfRequested(item_id); - - // TODO: camera mode may not be changed if a debug setting is tweaked - if( gAgentCamera.cameraCustomizeAvatar() ) - { - // If we're in appearance editing mode, the current tab may need to be refreshed - LLSidepanelAppearance *panel = dynamic_cast( - LLFloaterSidePanelContainer::getPanel("appearance")); - if (panel) - { - panel->showDefaultSubpart(); - } - } -} - -LLUpdateAppearanceAndEditWearableOnDestroy::~LLUpdateAppearanceAndEditWearableOnDestroy() -{ - if (!LLApp::isExiting()) - { - LLAppearanceMgr::instance().updateAppearanceFromCOF( - true,true, - boost::bind(edit_wearable_and_customize_avatar, mItemID)); - } -} - - -struct LLFoundData -{ - LLFoundData() : - mAssetType(LLAssetType::AT_NONE), - mWearableType(LLWearableType::WT_INVALID), - mWearable(NULL) {} - - LLFoundData(const LLUUID& item_id, - const LLUUID& asset_id, - const std::string& name, - const LLAssetType::EType& asset_type, - const LLWearableType::EType& wearable_type, - const bool is_replacement = false - ) : - mItemID(item_id), - mAssetID(asset_id), - mName(name), - mAssetType(asset_type), - mWearableType(wearable_type), - mIsReplacement(is_replacement), - mWearable( NULL ) {} - - LLUUID mItemID; - LLUUID mAssetID; - std::string mName; - LLAssetType::EType mAssetType; - LLWearableType::EType mWearableType; - LLViewerWearable* mWearable; - bool mIsReplacement; -}; - - -class LLWearableHoldingPattern -{ - LOG_CLASS(LLWearableHoldingPattern); - -public: - LLWearableHoldingPattern(); - ~LLWearableHoldingPattern(); - - bool pollFetchCompletion(); - void onFetchCompletion(); - bool isFetchCompleted(); - bool isTimedOut(); - - void checkMissingWearables(); - bool pollMissingWearables(); - bool isMissingCompleted(); - void recoverMissingWearable(LLWearableType::EType type); - void clearCOFLinksForMissingWearables(); - - void onWearableAssetFetch(LLViewerWearable *wearable); - void onAllComplete(); - - typedef std::list found_list_t; - found_list_t& getFoundList(); - void eraseTypeToLink(LLWearableType::EType type); - void eraseTypeToRecover(LLWearableType::EType type); - void setObjItems(const LLInventoryModel::item_array_t& items); - void setGestItems(const LLInventoryModel::item_array_t& items); - bool isMostRecent(); - void handleLateArrivals(); - void resetTime(F32 timeout); - static S32 countActive() { return sActiveHoldingPatterns.size(); } - S32 index() { return mIndex; } - -private: - found_list_t mFoundList; - LLInventoryModel::item_array_t mObjItems; - LLInventoryModel::item_array_t mGestItems; - typedef std::set type_set_t; - type_set_t mTypesToRecover; - type_set_t mTypesToLink; - S32 mResolved; - LLTimer mWaitTime; - bool mFired; - typedef std::set type_set_hp; - static type_set_hp sActiveHoldingPatterns; - static S32 sNextIndex; - S32 mIndex; - bool mIsMostRecent; - std::set mLateArrivals; - bool mIsAllComplete; -}; - -LLWearableHoldingPattern::type_set_hp LLWearableHoldingPattern::sActiveHoldingPatterns; -S32 LLWearableHoldingPattern::sNextIndex = 0; - -LLWearableHoldingPattern::LLWearableHoldingPattern(): - mResolved(0), - mFired(false), - mIsMostRecent(true), - mIsAllComplete(false) -{ - if (countActive()>0) - { - LL_INFOS() << "Creating LLWearableHoldingPattern when " - << countActive() - << " other attempts are active." - << " Flagging others as invalid." - << LL_ENDL; - for (type_set_hp::iterator it = sActiveHoldingPatterns.begin(); - it != sActiveHoldingPatterns.end(); - ++it) - { - (*it)->mIsMostRecent = false; - } - - } - mIndex = sNextIndex++; - sActiveHoldingPatterns.insert(this); - LL_DEBUGS("Avatar") << "HP " << index() << " created" << LL_ENDL; - selfStartPhase("holding_pattern"); -} - -LLWearableHoldingPattern::~LLWearableHoldingPattern() -{ - sActiveHoldingPatterns.erase(this); - if (isMostRecent()) - { - selfStopPhase("holding_pattern"); - } - LL_DEBUGS("Avatar") << "HP " << index() << " deleted" << LL_ENDL; -} - -bool LLWearableHoldingPattern::isMostRecent() -{ - return mIsMostRecent; -} - -LLWearableHoldingPattern::found_list_t& LLWearableHoldingPattern::getFoundList() -{ - return mFoundList; -} - -void LLWearableHoldingPattern::eraseTypeToLink(LLWearableType::EType type) -{ - mTypesToLink.erase(type); -} - -void LLWearableHoldingPattern::eraseTypeToRecover(LLWearableType::EType type) -{ - mTypesToRecover.erase(type); -} - -void LLWearableHoldingPattern::setObjItems(const LLInventoryModel::item_array_t& items) -{ - mObjItems = items; -} - -void LLWearableHoldingPattern::setGestItems(const LLInventoryModel::item_array_t& items) -{ - mGestItems = items; -} - -bool LLWearableHoldingPattern::isFetchCompleted() -{ - return (mResolved >= (S32)getFoundList().size()); // have everything we were waiting for? -} - -bool LLWearableHoldingPattern::isTimedOut() -{ - return mWaitTime.hasExpired(); -} - -void LLWearableHoldingPattern::checkMissingWearables() -{ - if (!isMostRecent()) - { - // runway why don't we actually skip here? - LL_WARNS() << self_av_string() << "skipping because LLWearableHolding pattern is invalid (superceded by later outfit request)" << LL_ENDL; - } - - std::vector found_by_type(LLWearableType::WT_COUNT,0); - std::vector requested_by_type(LLWearableType::WT_COUNT,0); - for (found_list_t::iterator it = getFoundList().begin(); it != getFoundList().end(); ++it) - { - LLFoundData &data = *it; - if (data.mWearableType < LLWearableType::WT_COUNT) - requested_by_type[data.mWearableType]++; - if (data.mWearable) - found_by_type[data.mWearableType]++; - } - - for (S32 type = 0; type < LLWearableType::WT_COUNT; ++type) - { - if (requested_by_type[type] > found_by_type[type]) - { - LL_WARNS() << self_av_string() << "got fewer wearables than requested, type " << type << ": requested " << requested_by_type[type] << ", found " << found_by_type[type] << LL_ENDL; - } - if (found_by_type[type] > 0) - continue; - if ( - // If at least one wearable of certain types (pants/shirt/skirt) - // was requested but none was found, create a default asset as a replacement. - // In all other cases, don't do anything. - // For critical types (shape/hair/skin/eyes), this will keep the avatar as a cloud - // due to logic in LLVOAvatarSelf::getIsCloud(). - // For non-critical types (tatoo, socks, etc.) the wearable will just be missing. - (requested_by_type[type] > 0) && - ((type == LLWearableType::WT_PANTS) || (type == LLWearableType::WT_SHIRT) || (type == LLWearableType::WT_SKIRT))) - { - mTypesToRecover.insert(type); - mTypesToLink.insert(type); - recoverMissingWearable((LLWearableType::EType)type); - LL_WARNS() << self_av_string() << "need to replace " << type << LL_ENDL; - } - } - - resetTime(60.0F); - - if (isMostRecent()) - { - selfStartPhase("get_missing_wearables_2"); - } - if (!pollMissingWearables()) - { - doOnIdleRepeating(boost::bind(&LLWearableHoldingPattern::pollMissingWearables,this)); - } -} - -void LLWearableHoldingPattern::onAllComplete() -{ - if (isAgentAvatarValid()) - { - gAgentAvatarp->outputRezTiming("Agent wearables fetch complete"); - } - - if (!isMostRecent()) - { - // runway need to skip here? - LL_WARNS() << self_av_string() << "skipping because LLWearableHolding pattern is invalid (superceded by later outfit request)" << LL_ENDL; - } - - // Activate all gestures in this folder - if (mGestItems.size() > 0) - { - LL_DEBUGS("Avatar") << self_av_string() << "Activating " << mGestItems.size() << " gestures" << LL_ENDL; - - LLGestureMgr::instance().activateGestures(mGestItems); - - // Update the inventory item labels to reflect the fact - // they are active. - LLViewerInventoryCategory* catp = - gInventory.getCategory(LLAppearanceMgr::instance().getCOF()); - - if (catp) - { - gInventory.updateCategory(catp); - gInventory.notifyObservers(); - } - } - - if (isAgentAvatarValid()) - { - LL_DEBUGS("Avatar") << self_av_string() << "Updating " << mObjItems.size() << " attachments" << LL_ENDL; - LLAgentWearables::llvo_vec_t objects_to_remove; - LLAgentWearables::llvo_vec_t objects_to_retain; - LLInventoryModel::item_array_t items_to_add; - - LLAgentWearables::findAttachmentsAddRemoveInfo(mObjItems, - objects_to_remove, - objects_to_retain, - items_to_add); - - LL_DEBUGS("Avatar") << self_av_string() << "Removing " << objects_to_remove.size() - << " attachments" << LL_ENDL; - - // Here we remove the attachment pos overrides for *all* - // attachments, even those that are not being removed. This is - // needed to get joint positions all slammed down to their - // pre-attachment states. - gAgentAvatarp->clearAttachmentPosOverrides(); - - // Take off the attachments that will no longer be in the outfit. - LLAgentWearables::userRemoveMultipleAttachments(objects_to_remove); - - // Update wearables. - LL_INFOS("Avatar") << self_av_string() << "HP " << index() << " updating agent wearables with " - << mResolved << " wearable items " << LL_ENDL; - LLAppearanceMgr::instance().updateAgentWearables(this); - - // Restore attachment pos overrides for the attachments that - // are remaining in the outfit. - for (LLAgentWearables::llvo_vec_t::iterator it = objects_to_retain.begin(); - it != objects_to_retain.end(); - ++it) - { - LLViewerObject *objectp = *it; - gAgentAvatarp->addAttachmentPosOverridesForObject(objectp); - } - - // Add new attachments to match those requested. - LL_DEBUGS("Avatar") << self_av_string() << "Adding " << items_to_add.size() << " attachments" << LL_ENDL; - LLAgentWearables::userAttachMultipleAttachments(items_to_add); - } - - if (isFetchCompleted() && isMissingCompleted()) - { - // Only safe to delete if all wearable callbacks and all missing wearables completed. - delete this; - } - else - { - mIsAllComplete = true; - handleLateArrivals(); - } -} - -void LLWearableHoldingPattern::onFetchCompletion() -{ - if (isMostRecent()) - { - selfStopPhase("get_wearables_2"); - } - - if (!isMostRecent()) - { - // runway skip here? - LL_WARNS() << self_av_string() << "skipping because LLWearableHolding pattern is invalid (superceded by later outfit request)" << LL_ENDL; - } - - checkMissingWearables(); -} - -// Runs as an idle callback until all wearables are fetched (or we time out). -bool LLWearableHoldingPattern::pollFetchCompletion() -{ - if (!isMostRecent()) - { - // runway skip here? - LL_WARNS() << self_av_string() << "skipping because LLWearableHolding pattern is invalid (superceded by later outfit request)" << LL_ENDL; - } - - bool completed = isFetchCompleted(); - bool timed_out = isTimedOut(); - bool done = completed || timed_out; - - if (done) - { - LL_INFOS("Avatar") << self_av_string() << "HP " << index() << " polling, done status: " << completed << " timed out " << timed_out - << " elapsed " << mWaitTime.getElapsedTimeF32() << LL_ENDL; - - mFired = true; - - if (timed_out) - { - LL_WARNS() << self_av_string() << "Exceeded max wait time for wearables, updating appearance based on what has arrived" << LL_ENDL; - } - - onFetchCompletion(); - } - return done; -} - -void recovered_item_link_cb(const LLUUID& item_id, LLWearableType::EType type, LLViewerWearable *wearable, LLWearableHoldingPattern* holder) -{ - if (!holder->isMostRecent()) - { - LL_WARNS() << "HP " << holder->index() << " skipping because LLWearableHolding pattern is invalid (superceded by later outfit request)" << LL_ENDL; - // runway skip here? - } - - LL_INFOS() << "HP " << holder->index() << " recovered item link for type " << type << LL_ENDL; - holder->eraseTypeToLink(type); - // Add wearable to FoundData for actual wearing - LLViewerInventoryItem *item = gInventory.getItem(item_id); - LLViewerInventoryItem *linked_item = item ? item->getLinkedItem() : NULL; - - if (linked_item) - { - gInventory.addChangedMask(LLInventoryObserver::LABEL, linked_item->getUUID()); - - if (item) - { - LLFoundData found(linked_item->getUUID(), - linked_item->getAssetUUID(), - linked_item->getName(), - linked_item->getType(), - linked_item->isWearableType() ? linked_item->getWearableType() : LLWearableType::WT_INVALID, - true // is replacement - ); - found.mWearable = wearable; - holder->getFoundList().push_front(found); - } - else - { - LL_WARNS() << self_av_string() << "inventory link not found for recovered wearable" << LL_ENDL; - } - } - else - { - LL_WARNS() << self_av_string() << "HP " << holder->index() << " inventory link not found for recovered wearable" << LL_ENDL; - } -} - -void recovered_item_cb(const LLUUID& item_id, LLWearableType::EType type, LLViewerWearable *wearable, LLWearableHoldingPattern* holder) -{ - if (!holder->isMostRecent()) - { - // runway skip here? - LL_WARNS() << self_av_string() << "skipping because LLWearableHolding pattern is invalid (superceded by later outfit request)" << LL_ENDL; - } - - LL_DEBUGS("Avatar") << self_av_string() << "Recovered item for type " << type << LL_ENDL; - LLConstPointer itemp = gInventory.getItem(item_id); - wearable->setItemID(item_id); - holder->eraseTypeToRecover(type); - llassert(itemp); - if (itemp) - { - LLPointer cb = new LLBoostFuncInventoryCallback(boost::bind(recovered_item_link_cb,_1,type,wearable,holder)); - - link_inventory_object(LLAppearanceMgr::instance().getCOF(), itemp, cb); - } -} - -void LLWearableHoldingPattern::recoverMissingWearable(LLWearableType::EType type) -{ - if (!isMostRecent()) - { - // runway skip here? - LL_WARNS() << self_av_string() << "skipping because LLWearableHolding pattern is invalid (superceded by later outfit request)" << LL_ENDL; - } - - // Try to recover by replacing missing wearable with a new one. - LLNotificationsUtil::add("ReplacedMissingWearable"); - LL_DEBUGS() << "Wearable " << LLWearableType::getTypeLabel(type) - << " could not be downloaded. Replaced inventory item with default wearable." << LL_ENDL; - LLViewerWearable* wearable = LLWearableList::instance().createNewWearable(type, gAgentAvatarp); - - // Add a new one in the lost and found folder. - const LLUUID lost_and_found_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_LOST_AND_FOUND); - LLPointer cb = new LLBoostFuncInventoryCallback(boost::bind(recovered_item_cb,_1,type,wearable,this)); - - create_inventory_item(gAgent.getID(), - gAgent.getSessionID(), - lost_and_found_id, - wearable->getTransactionID(), - wearable->getName(), - wearable->getDescription(), - wearable->getAssetType(), - LLInventoryType::IT_WEARABLE, - wearable->getType(), - wearable->getPermissions().getMaskNextOwner(), - cb); -} - -bool LLWearableHoldingPattern::isMissingCompleted() -{ - return mTypesToLink.size()==0 && mTypesToRecover.size()==0; -} - -void LLWearableHoldingPattern::clearCOFLinksForMissingWearables() -{ - for (found_list_t::iterator it = getFoundList().begin(); it != getFoundList().end(); ++it) - { - LLFoundData &data = *it; - if ((data.mWearableType < LLWearableType::WT_COUNT) && (!data.mWearable)) - { - // Wearable link that was never resolved; remove links to it from COF - LL_INFOS("Avatar") << self_av_string() << "HP " << index() << " removing link for unresolved item " << data.mItemID.asString() << LL_ENDL; - LLAppearanceMgr::instance().removeCOFItemLinks(data.mItemID); - } - } -} - -bool LLWearableHoldingPattern::pollMissingWearables() -{ - if (!isMostRecent()) - { - // runway skip here? - LL_WARNS() << self_av_string() << "skipping because LLWearableHolding pattern is invalid (superceded by later outfit request)" << LL_ENDL; - } - - bool timed_out = isTimedOut(); - bool missing_completed = isMissingCompleted(); - bool done = timed_out || missing_completed; - - if (!done) - { - LL_INFOS("Avatar") << self_av_string() << "HP " << index() << " polling missing wearables, waiting for items " << mTypesToRecover.size() - << " links " << mTypesToLink.size() - << " wearables, timed out " << timed_out - << " elapsed " << mWaitTime.getElapsedTimeF32() - << " done " << done << LL_ENDL; - } - - if (done) - { - if (isMostRecent()) - { - selfStopPhase("get_missing_wearables_2"); - } - - gAgentAvatarp->debugWearablesLoaded(); - - // BAP - if we don't call clearCOFLinksForMissingWearables() - // here, we won't have to add the link back in later if the - // wearable arrives late. This is to avoid corruption of - // wearable ordering info. Also has the effect of making - // unworn item links visible in the COF under some - // circumstances. - - //clearCOFLinksForMissingWearables(); - onAllComplete(); - } - return done; -} - -// Handle wearables that arrived after the timeout period expired. -void LLWearableHoldingPattern::handleLateArrivals() -{ - // Only safe to run if we have previously finished the missing - // wearables and other processing - otherwise we could be in some - // intermediate state - but have not been superceded by a later - // outfit change request. - if (mLateArrivals.size() == 0) - { - // Nothing to process. - return; - } - if (!isMostRecent()) - { - LL_WARNS() << self_av_string() << "Late arrivals not handled - outfit change no longer valid" << LL_ENDL; - } - if (!mIsAllComplete) - { - LL_WARNS() << self_av_string() << "Late arrivals not handled - in middle of missing wearables processing" << LL_ENDL; - } - - LL_INFOS("Avatar") << self_av_string() << "HP " << index() << " need to handle " << mLateArrivals.size() << " late arriving wearables" << LL_ENDL; - - // Update mFoundList using late-arriving wearables. - std::set replaced_types; - for (LLWearableHoldingPattern::found_list_t::iterator iter = getFoundList().begin(); - iter != getFoundList().end(); ++iter) - { - LLFoundData& data = *iter; - for (std::set::iterator wear_it = mLateArrivals.begin(); - wear_it != mLateArrivals.end(); - ++wear_it) - { - LLViewerWearable *wearable = *wear_it; - - if(wearable->getAssetID() == data.mAssetID) - { - data.mWearable = wearable; - - replaced_types.insert(data.mWearableType); - - // BAP - if we didn't call - // clearCOFLinksForMissingWearables() earlier, we - // don't need to restore the link here. Fixes - // wearable ordering problems. - - // LLAppearanceMgr::instance().addCOFItemLink(data.mItemID,false); - - // BAP failing this means inventory or asset server - // are corrupted in a way we don't handle. - llassert((data.mWearableType < LLWearableType::WT_COUNT) && (wearable->getType() == data.mWearableType)); - break; - } - } - } - - // Remove COF links for any default wearables previously used to replace the late arrivals. - // All this pussyfooting around with a while loop and explicit - // iterator incrementing is to allow removing items from the list - // without clobbering the iterator we're using to navigate. - LLWearableHoldingPattern::found_list_t::iterator iter = getFoundList().begin(); - while (iter != getFoundList().end()) - { - LLFoundData& data = *iter; - - // If an item of this type has recently shown up, removed the corresponding replacement wearable from COF. - if (data.mWearable && data.mIsReplacement && - replaced_types.find(data.mWearableType) != replaced_types.end()) - { - LLAppearanceMgr::instance().removeCOFItemLinks(data.mItemID); - std::list::iterator clobber_ator = iter; - ++iter; - getFoundList().erase(clobber_ator); - } - else - { - ++iter; - } - } - - // Clear contents of late arrivals. - mLateArrivals.clear(); - - // Update appearance based on mFoundList - LLAppearanceMgr::instance().updateAgentWearables(this); -} - -void LLWearableHoldingPattern::resetTime(F32 timeout) -{ - mWaitTime.reset(); - mWaitTime.setTimerExpirySec(timeout); -} - -void LLWearableHoldingPattern::onWearableAssetFetch(LLViewerWearable *wearable) -{ - if (!isMostRecent()) - { - LL_WARNS() << self_av_string() << "skipping because LLWearableHolding pattern is invalid (superceded by later outfit request)" << LL_ENDL; - } - - mResolved += 1; // just counting callbacks, not successes. - LL_DEBUGS("Avatar") << self_av_string() << "HP " << index() << " resolved " << mResolved << "/" << getFoundList().size() << LL_ENDL; - if (!wearable) - { - LL_WARNS() << self_av_string() << "no wearable found" << LL_ENDL; - } - - if (mFired) - { - LL_WARNS() << self_av_string() << "called after holder fired" << LL_ENDL; - if (wearable) - { - mLateArrivals.insert(wearable); - if (mIsAllComplete) - { - handleLateArrivals(); - } - } - return; - } - - if (!wearable) - { - return; - } - - for (LLWearableHoldingPattern::found_list_t::iterator iter = getFoundList().begin(); - iter != getFoundList().end(); ++iter) - { - LLFoundData& data = *iter; - if(wearable->getAssetID() == data.mAssetID) - { - // Failing this means inventory or asset server are corrupted in a way we don't handle. - if ((data.mWearableType >= LLWearableType::WT_COUNT) || (wearable->getType() != data.mWearableType)) - { - LL_WARNS() << self_av_string() << "recovered wearable but type invalid. inventory wearable type: " << data.mWearableType << " asset wearable type: " << wearable->getType() << LL_ENDL; - break; - } - - data.mWearable = wearable; - } - } -} - -static void onWearableAssetFetch(LLViewerWearable* wearable, void* data) -{ - LLWearableHoldingPattern* holder = (LLWearableHoldingPattern*)data; - holder->onWearableAssetFetch(wearable); -} - - -static void removeDuplicateItems(LLInventoryModel::item_array_t& items) -{ - LLInventoryModel::item_array_t new_items; - std::set items_seen; - std::deque tmp_list; - // Traverse from the front and keep the first of each item - // encountered, so we actually keep the *last* of each duplicate - // item. This is needed to give the right priority when adding - // duplicate items to an existing outfit. - for (S32 i=items.size()-1; i>=0; i--) - { - LLViewerInventoryItem *item = items.at(i); - LLUUID item_id = item->getLinkedUUID(); - if (items_seen.find(item_id)!=items_seen.end()) - continue; - items_seen.insert(item_id); - tmp_list.push_front(item); - } - for (std::deque::iterator it = tmp_list.begin(); - it != tmp_list.end(); - ++it) - { - new_items.push_back(*it); - } - items = new_items; -} - -const LLUUID LLAppearanceMgr::getCOF() const -{ - return gInventory.findCategoryUUIDForType(LLFolderType::FT_CURRENT_OUTFIT); -} - -S32 LLAppearanceMgr::getCOFVersion() const -{ - LLViewerInventoryCategory *cof = gInventory.getCategory(getCOF()); - if (cof) - { - return cof->getVersion(); - } - else - { - return LLViewerInventoryCategory::VERSION_UNKNOWN; - } -} - -const LLViewerInventoryItem* LLAppearanceMgr::getBaseOutfitLink() -{ - const LLUUID& current_outfit_cat = getCOF(); - LLInventoryModel::cat_array_t cat_array; - LLInventoryModel::item_array_t item_array; - // Can't search on FT_OUTFIT since links to categories return FT_CATEGORY for type since they don't - // return preferred type. - LLIsType is_category( LLAssetType::AT_CATEGORY ); - gInventory.collectDescendentsIf(current_outfit_cat, - cat_array, - item_array, - false, - is_category); - for (LLInventoryModel::item_array_t::const_iterator iter = item_array.begin(); - iter != item_array.end(); - iter++) - { - const LLViewerInventoryItem *item = (*iter); - const LLViewerInventoryCategory *cat = item->getLinkedCategory(); - if (cat && cat->getPreferredType() == LLFolderType::FT_OUTFIT) - { - const LLUUID parent_id = cat->getParentUUID(); - LLViewerInventoryCategory* parent_cat = gInventory.getCategory(parent_id); - // if base outfit moved to trash it means that we don't have base outfit - if (parent_cat != NULL && parent_cat->getPreferredType() == LLFolderType::FT_TRASH) - { - return NULL; - } - return item; - } - } - return NULL; -} - -bool LLAppearanceMgr::getBaseOutfitName(std::string& name) -{ - const LLViewerInventoryItem* outfit_link = getBaseOutfitLink(); - if(outfit_link) - { - const LLViewerInventoryCategory *cat = outfit_link->getLinkedCategory(); - if (cat) - { - name = cat->getName(); - return true; - } - } - return false; -} - -const LLUUID LLAppearanceMgr::getBaseOutfitUUID() -{ - const LLViewerInventoryItem* outfit_link = getBaseOutfitLink(); - if (!outfit_link || !outfit_link->getIsLinkType()) return LLUUID::null; - - const LLViewerInventoryCategory* outfit_cat = outfit_link->getLinkedCategory(); - if (!outfit_cat) return LLUUID::null; - - if (outfit_cat->getPreferredType() != LLFolderType::FT_OUTFIT) - { - LL_WARNS() << "Expected outfit type:" << LLFolderType::FT_OUTFIT << " but got type:" << outfit_cat->getType() << " for folder name:" << outfit_cat->getName() << LL_ENDL; - return LLUUID::null; - } - - return outfit_cat->getUUID(); -} - -void wear_on_avatar_cb(const LLUUID& inv_item, bool do_replace = false) -{ - if (inv_item.isNull()) - return; - - LLViewerInventoryItem *item = gInventory.getItem(inv_item); - if (item) - { - LLAppearanceMgr::instance().wearItemOnAvatar(inv_item, true, do_replace); - } -} - -bool LLAppearanceMgr::wearItemOnAvatar(const LLUUID& item_id_to_wear, - bool do_update, - bool replace, - LLPointer cb) -{ - - if (item_id_to_wear.isNull()) return false; - - // *TODO: issue with multi-wearable should be fixed: - // in this case this method will be called N times - loading started for each item - // and than N times will be called - loading completed for each item. - // That means subscribers will be notified that loading is done after first item in a batch is worn. - // (loading indicator disappears for example before all selected items are worn) - // Have not fix this issue for 2.1 because of stability reason. EXT-7777. - - // Disabled for now because it is *not* acceptable to call updateAppearanceFromCOF() multiple times -// gAgentWearables.notifyLoadingStarted(); - - LLViewerInventoryItem* item_to_wear = gInventory.getItem(item_id_to_wear); - if (!item_to_wear) return false; - - if (gInventory.isObjectDescendentOf(item_to_wear->getUUID(), gInventory.getLibraryRootFolderID())) - { - LLPointer cb = new LLBoostFuncInventoryCallback(boost::bind(wear_on_avatar_cb,_1,replace)); - copy_inventory_item(gAgent.getID(), item_to_wear->getPermissions().getOwner(), item_to_wear->getUUID(), LLUUID::null, std::string(), cb); - return false; - } - else if (!gInventory.isObjectDescendentOf(item_to_wear->getUUID(), gInventory.getRootFolderID())) - { - return false; // not in library and not in agent's inventory - } - else if (gInventory.isObjectDescendentOf(item_to_wear->getUUID(), gInventory.findCategoryUUIDForType(LLFolderType::FT_TRASH))) - { - LLNotificationsUtil::add("CannotWearTrash"); - return false; - } - else if (isLinkedInCOF(item_to_wear->getUUID())) // EXT-84911 - { - return false; - } - - switch (item_to_wear->getType()) - { - case LLAssetType::AT_CLOTHING: - if (gAgentWearables.areWearablesLoaded()) - { - if (!cb && do_update) - { - cb = new LLUpdateAppearanceAndEditWearableOnDestroy(item_id_to_wear); - } - S32 wearable_count = gAgentWearables.getWearableCount(item_to_wear->getWearableType()); - if ((replace && wearable_count != 0) || - (wearable_count >= LLAgentWearables::MAX_CLOTHING_PER_TYPE) ) - { - LLUUID item_id = gAgentWearables.getWearableItemID(item_to_wear->getWearableType(), - wearable_count-1); - removeCOFItemLinks(item_id, cb); - } - - addCOFItemLink(item_to_wear, cb); - } - break; - - case LLAssetType::AT_BODYPART: - // TODO: investigate wearables may not be loaded at this point EXT-8231 - - // Remove the existing wearables of the same type. - // Remove existing body parts anyway because we must not be able to wear e.g. two skins. - removeCOFLinksOfType(item_to_wear->getWearableType()); - if (!cb && do_update) - { - cb = new LLUpdateAppearanceAndEditWearableOnDestroy(item_id_to_wear); - } - addCOFItemLink(item_to_wear, cb); - break; - - case LLAssetType::AT_OBJECT: - rez_attachment(item_to_wear, NULL, replace); - break; - - default: return false;; - } - - return true; -} - -// Update appearance from outfit folder. -void LLAppearanceMgr::changeOutfit(bool proceed, const LLUUID& category, bool append) -{ - if (!proceed) - return; - LLAppearanceMgr::instance().updateCOF(category,append); -} - -void LLAppearanceMgr::replaceCurrentOutfit(const LLUUID& new_outfit) -{ - LLViewerInventoryCategory* cat = gInventory.getCategory(new_outfit); - wearInventoryCategory(cat, false, false); -} - -// Open outfit renaming dialog. -void LLAppearanceMgr::renameOutfit(const LLUUID& outfit_id) -{ - LLViewerInventoryCategory* cat = gInventory.getCategory(outfit_id); - if (!cat) - { - return; - } - - LLSD args; - args["NAME"] = cat->getName(); - - LLSD payload; - payload["cat_id"] = outfit_id; - - LLNotificationsUtil::add("RenameOutfit", args, payload, boost::bind(onOutfitRename, _1, _2)); -} - -// User typed new outfit name. -// static -void LLAppearanceMgr::onOutfitRename(const LLSD& notification, const LLSD& response) -{ - S32 option = LLNotificationsUtil::getSelectedOption(notification, response); - if (option != 0) return; // canceled - - std::string outfit_name = response["new_name"].asString(); - LLStringUtil::trim(outfit_name); - if (!outfit_name.empty()) - { - LLUUID cat_id = notification["payload"]["cat_id"].asUUID(); - rename_category(&gInventory, cat_id, outfit_name); - } -} - -void LLAppearanceMgr::setOutfitLocked(bool locked) -{ - if (mOutfitLocked == locked) - { - return; - } - - mOutfitLocked = locked; - if (locked) - { - mUnlockOutfitTimer->reset(); - mUnlockOutfitTimer->start(); - } - else - { - mUnlockOutfitTimer->stop(); - } - - LLOutfitObserver::instance().notifyOutfitLockChanged(); -} - -void LLAppearanceMgr::addCategoryToCurrentOutfit(const LLUUID& cat_id) -{ - LLViewerInventoryCategory* cat = gInventory.getCategory(cat_id); - wearInventoryCategory(cat, false, true); -} - -void LLAppearanceMgr::takeOffOutfit(const LLUUID& cat_id) -{ - LLInventoryModel::cat_array_t cats; - LLInventoryModel::item_array_t items; - LLFindWearablesEx collector(/*is_worn=*/ true, /*include_body_parts=*/ false); - - gInventory.collectDescendentsIf(cat_id, cats, items, FALSE, collector); - - LLInventoryModel::item_array_t::const_iterator it = items.begin(); - const LLInventoryModel::item_array_t::const_iterator it_end = items.end(); - uuid_vec_t uuids_to_remove; - for( ; it_end != it; ++it) - { - LLViewerInventoryItem* item = *it; - uuids_to_remove.push_back(item->getUUID()); - } - removeItemsFromAvatar(uuids_to_remove); - - // deactivate all gestures in the outfit folder - LLInventoryModel::item_array_t gest_items; - getDescendentsOfAssetType(cat_id, gest_items, LLAssetType::AT_GESTURE); - for(S32 i = 0; i < gest_items.size(); ++i) - { - LLViewerInventoryItem *gest_item = gest_items[i]; - if ( LLGestureMgr::instance().isGestureActive( gest_item->getLinkedUUID()) ) - { - LLGestureMgr::instance().deactivateGesture( gest_item->getLinkedUUID() ); - } - } -} - -// Create a copy of src_id + contents as a subfolder of dst_id. -void LLAppearanceMgr::shallowCopyCategory(const LLUUID& src_id, const LLUUID& dst_id, - LLPointer cb) -{ - LLInventoryCategory *src_cat = gInventory.getCategory(src_id); - if (!src_cat) - { - LL_WARNS() << "folder not found for src " << src_id.asString() << LL_ENDL; - return; - } - LL_INFOS() << "starting, src_id " << src_id << " name " << src_cat->getName() << " dst_id " << dst_id << LL_ENDL; - LLUUID parent_id = dst_id; - if(parent_id.isNull()) - { - parent_id = gInventory.getRootFolderID(); - } - LLUUID subfolder_id = gInventory.createNewCategory( parent_id, - LLFolderType::FT_NONE, - src_cat->getName()); - shallowCopyCategoryContents(src_id, subfolder_id, cb); - - gInventory.notifyObservers(); -} - -void LLAppearanceMgr::slamCategoryLinks(const LLUUID& src_id, const LLUUID& dst_id, - bool include_folder_links, LLPointer cb) -{ - LLInventoryModel::cat_array_t* cats; - LLInventoryModel::item_array_t* items; - LLSD contents = LLSD::emptyArray(); - gInventory.getDirectDescendentsOf(src_id, cats, items); - LL_INFOS() << "copying " << items->size() << " items" << LL_ENDL; - for (LLInventoryModel::item_array_t::const_iterator iter = items->begin(); - iter != items->end(); - ++iter) - { - const LLViewerInventoryItem* item = (*iter); - switch (item->getActualType()) - { - case LLAssetType::AT_LINK: - { - LL_DEBUGS("Avatar") << "linking inventory item " << item->getName() << LL_ENDL; - //getActualDescription() is used for a new description - //to propagate ordering information saved in descriptions of links - LLSD item_contents; - item_contents["name"] = item->getName(); - item_contents["desc"] = item->getActualDescription(); - item_contents["linked_id"] = item->getLinkedUUID(); - item_contents["type"] = LLAssetType::AT_LINK; - contents.append(item_contents); - break; - } - case LLAssetType::AT_LINK_FOLDER: - { - LLViewerInventoryCategory *catp = item->getLinkedCategory(); - if (catp && include_folder_links) - { - LL_DEBUGS("Avatar") << "linking inventory folder " << item->getName() << LL_ENDL; - LLSD base_contents; - base_contents["name"] = catp->getName(); - base_contents["desc"] = ""; // categories don't have descriptions. - base_contents["linked_id"] = catp->getLinkedUUID(); - base_contents["type"] = LLAssetType::AT_LINK_FOLDER; - contents.append(base_contents); - } - break; - } - default: - { - // Linux refuses to compile unless all possible enums are handled. Really, Linux? - break; - } - } - } - slam_inventory_folder(dst_id, contents, cb); -} -// Copy contents of src_id to dst_id. -void LLAppearanceMgr::shallowCopyCategoryContents(const LLUUID& src_id, const LLUUID& dst_id, - LLPointer cb) -{ - LLInventoryModel::cat_array_t* cats; - LLInventoryModel::item_array_t* items; - gInventory.getDirectDescendentsOf(src_id, cats, items); - LL_INFOS() << "copying " << items->size() << " items" << LL_ENDL; - LLInventoryObject::const_object_list_t link_array; - for (LLInventoryModel::item_array_t::const_iterator iter = items->begin(); - iter != items->end(); - ++iter) - { - const LLViewerInventoryItem* item = (*iter); - switch (item->getActualType()) - { - case LLAssetType::AT_LINK: - { - LL_DEBUGS("Avatar") << "linking inventory item " << item->getName() << LL_ENDL; - link_array.push_back(LLConstPointer(item)); - break; - } - case LLAssetType::AT_LINK_FOLDER: - { - LLViewerInventoryCategory *catp = item->getLinkedCategory(); - // Skip copying outfit links. - if (catp && catp->getPreferredType() != LLFolderType::FT_OUTFIT) - { - LL_DEBUGS("Avatar") << "linking inventory folder " << item->getName() << LL_ENDL; - link_array.push_back(LLConstPointer(item)); - } - break; - } - case LLAssetType::AT_CLOTHING: - case LLAssetType::AT_OBJECT: - case LLAssetType::AT_BODYPART: - case LLAssetType::AT_GESTURE: - { - LL_DEBUGS("Avatar") << "copying inventory item " << item->getName() << LL_ENDL; - copy_inventory_item(gAgent.getID(), - item->getPermissions().getOwner(), - item->getUUID(), - dst_id, - item->getName(), - cb); - break; - } - default: - // Ignore non-outfit asset types - break; - } - } - if (!link_array.empty()) - { - link_inventory_array(dst_id, link_array, cb); - } -} - -BOOL LLAppearanceMgr::getCanMakeFolderIntoOutfit(const LLUUID& folder_id) -{ - // These are the wearable items that are required for considering this - // folder as containing a complete outfit. - U32 required_wearables = 0; - required_wearables |= 1LL << LLWearableType::WT_SHAPE; - required_wearables |= 1LL << LLWearableType::WT_SKIN; - required_wearables |= 1LL << LLWearableType::WT_HAIR; - required_wearables |= 1LL << LLWearableType::WT_EYES; - - // These are the wearables that the folder actually contains. - U32 folder_wearables = 0; - LLInventoryModel::cat_array_t* cats; - LLInventoryModel::item_array_t* items; - gInventory.getDirectDescendentsOf(folder_id, cats, items); - for (LLInventoryModel::item_array_t::const_iterator iter = items->begin(); - iter != items->end(); - ++iter) - { - const LLViewerInventoryItem* item = (*iter); - if (item->isWearableType()) - { - const LLWearableType::EType wearable_type = item->getWearableType(); - folder_wearables |= 1LL << wearable_type; - } - } - - // If the folder contains the required wearables, return TRUE. - return ((required_wearables & folder_wearables) == required_wearables); -} - -bool LLAppearanceMgr::getCanRemoveOutfit(const LLUUID& outfit_cat_id) -{ - // Disallow removing the base outfit. - if (outfit_cat_id == getBaseOutfitUUID()) - { - return false; - } - - // Check if the outfit folder itself is removable. - if (!get_is_category_removable(&gInventory, outfit_cat_id)) - { - return false; - } - - // Check for the folder's non-removable descendants. - LLFindNonRemovableObjects filter_non_removable; - LLInventoryModel::cat_array_t cats; - LLInventoryModel::item_array_t items; - LLInventoryModel::item_array_t::const_iterator it; - gInventory.collectDescendentsIf(outfit_cat_id, cats, items, false, filter_non_removable); - if (!cats.empty() || !items.empty()) - { - return false; - } - - return true; -} - -// static -bool LLAppearanceMgr::getCanRemoveFromCOF(const LLUUID& outfit_cat_id) -{ - if (gAgentWearables.isCOFChangeInProgress()) - { - return false; - } - - LLFindWearablesEx is_worn(/*is_worn=*/ true, /*include_body_parts=*/ false); - return gInventory.hasMatchingDirectDescendent(outfit_cat_id, is_worn); -} - -// static -bool LLAppearanceMgr::getCanAddToCOF(const LLUUID& outfit_cat_id) -{ - if (gAgentWearables.isCOFChangeInProgress()) - { - return false; - } - - LLInventoryModel::cat_array_t cats; - LLInventoryModel::item_array_t items; - LLFindWearablesEx not_worn(/*is_worn=*/ false, /*include_body_parts=*/ false); - gInventory.collectDescendentsIf(outfit_cat_id, - cats, - items, - LLInventoryModel::EXCLUDE_TRASH, - not_worn); - - return items.size() > 0; -} - -bool LLAppearanceMgr::getCanReplaceCOF(const LLUUID& outfit_cat_id) -{ - // Don't allow wearing anything while we're changing appearance. - if (gAgentWearables.isCOFChangeInProgress()) - { - return false; - } - - // Check whether it's the base outfit. - if (outfit_cat_id.isNull() || outfit_cat_id == getBaseOutfitUUID()) - { - return false; - } - - // Check whether the outfit contains any wearables we aren't wearing already (STORM-702). - LLInventoryModel::cat_array_t cats; - LLInventoryModel::item_array_t items; - LLFindWearablesEx is_worn(/*is_worn=*/ false, /*include_body_parts=*/ true); - gInventory.collectDescendentsIf(outfit_cat_id, - cats, - items, - LLInventoryModel::EXCLUDE_TRASH, - is_worn); - - return items.size() > 0; -} - -void LLAppearanceMgr::purgeBaseOutfitLink(const LLUUID& category, LLPointer cb) -{ - LLInventoryModel::cat_array_t cats; - LLInventoryModel::item_array_t items; - gInventory.collectDescendents(category, cats, items, - LLInventoryModel::EXCLUDE_TRASH); - for (S32 i = 0; i < items.size(); ++i) - { - LLViewerInventoryItem *item = items.at(i); - if (item->getActualType() != LLAssetType::AT_LINK_FOLDER) - continue; - LLViewerInventoryCategory* catp = item->getLinkedCategory(); - if(catp && catp->getPreferredType() == LLFolderType::FT_OUTFIT) - { - remove_inventory_item(item->getUUID(), cb); - } - } -} - -// Keep the last N wearables of each type. For viewer 2.0, N is 1 for -// both body parts and clothing items. -void LLAppearanceMgr::filterWearableItems( - LLInventoryModel::item_array_t& items, S32 max_per_type) -{ - // Divvy items into arrays by wearable type. - std::vector items_by_type(LLWearableType::WT_COUNT); - divvyWearablesByType(items, items_by_type); - - // rebuild items list, retaining the last max_per_type of each array - items.clear(); - for (S32 i=0; igetName() : "[UNKNOWN]") << "'" << LL_ENDL; - - const LLUUID cof = getCOF(); - - // Deactivate currently active gestures in the COF, if replacing outfit - if (!append) - { - LLInventoryModel::item_array_t gest_items; - getDescendentsOfAssetType(cof, gest_items, LLAssetType::AT_GESTURE); - for(S32 i = 0; i < gest_items.size(); ++i) - { - LLViewerInventoryItem *gest_item = gest_items.at(i); - if ( LLGestureMgr::instance().isGestureActive( gest_item->getLinkedUUID()) ) - { - LLGestureMgr::instance().deactivateGesture( gest_item->getLinkedUUID() ); - } - } - } - - // Collect and filter descendents to determine new COF contents. - - // - Body parts: always include COF contents as a fallback in case any - // required parts are missing. - // Preserve body parts from COF if appending. - LLInventoryModel::item_array_t body_items; - getDescendentsOfAssetType(cof, body_items, LLAssetType::AT_BODYPART); - getDescendentsOfAssetType(category, body_items, LLAssetType::AT_BODYPART); - if (append) - reverse(body_items.begin(), body_items.end()); - // Reduce body items to max of one per type. - removeDuplicateItems(body_items); - filterWearableItems(body_items, 1); - - // - Wearables: include COF contents only if appending. - LLInventoryModel::item_array_t wear_items; - if (append) - getDescendentsOfAssetType(cof, wear_items, LLAssetType::AT_CLOTHING); - getDescendentsOfAssetType(category, wear_items, LLAssetType::AT_CLOTHING); - // Reduce wearables to max of one per type. - removeDuplicateItems(wear_items); - filterWearableItems(wear_items, LLAgentWearables::MAX_CLOTHING_PER_TYPE); - - // - Attachments: include COF contents only if appending. - LLInventoryModel::item_array_t obj_items; - if (append) - getDescendentsOfAssetType(cof, obj_items, LLAssetType::AT_OBJECT); - getDescendentsOfAssetType(category, obj_items, LLAssetType::AT_OBJECT); - removeDuplicateItems(obj_items); - - // - Gestures: include COF contents only if appending. - LLInventoryModel::item_array_t gest_items; - if (append) - getDescendentsOfAssetType(cof, gest_items, LLAssetType::AT_GESTURE); - getDescendentsOfAssetType(category, gest_items, LLAssetType::AT_GESTURE); - removeDuplicateItems(gest_items); - - // Create links to new COF contents. - LLInventoryModel::item_array_t all_items; - std::copy(body_items.begin(), body_items.end(), std::back_inserter(all_items)); - std::copy(wear_items.begin(), wear_items.end(), std::back_inserter(all_items)); - std::copy(obj_items.begin(), obj_items.end(), std::back_inserter(all_items)); - std::copy(gest_items.begin(), gest_items.end(), std::back_inserter(all_items)); - - // Find any wearables that need description set to enforce ordering. - desc_map_t desc_map; - getWearableOrderingDescUpdates(wear_items, desc_map); - - // Will link all the above items. - // link_waiter enforce flags are false because we've already fixed everything up in updateCOF(). - LLPointer link_waiter = new LLUpdateAppearanceOnDestroy(false,false); - LLSD contents = LLSD::emptyArray(); - - for (LLInventoryModel::item_array_t::const_iterator it = all_items.begin(); - it != all_items.end(); ++it) - { - LLSD item_contents; - LLInventoryItem *item = *it; - - std::string desc; - desc_map_t::const_iterator desc_iter = desc_map.find(item->getUUID()); - if (desc_iter != desc_map.end()) - { - desc = desc_iter->second; - LL_DEBUGS("Avatar") << item->getName() << " overriding desc to: " << desc - << " (was: " << item->getActualDescription() << ")" << LL_ENDL; - } - else - { - desc = item->getActualDescription(); - } - - item_contents["name"] = item->getName(); - item_contents["desc"] = desc; - item_contents["linked_id"] = item->getLinkedUUID(); - item_contents["type"] = LLAssetType::AT_LINK; - contents.append(item_contents); - } - const LLUUID& base_id = append ? getBaseOutfitUUID() : category; - LLViewerInventoryCategory *base_cat = gInventory.getCategory(base_id); - if (base_cat) - { - LLSD base_contents; - base_contents["name"] = base_cat->getName(); - base_contents["desc"] = ""; - base_contents["linked_id"] = base_cat->getLinkedUUID(); - base_contents["type"] = LLAssetType::AT_LINK_FOLDER; - contents.append(base_contents); - } - if (gSavedSettings.getBOOL("DebugAvatarAppearanceMessage")) - { - dump_sequential_xml(gAgentAvatarp->getFullname() + "_slam_request", contents); - } - slam_inventory_folder(getCOF(), contents, link_waiter); - - LL_DEBUGS("Avatar") << self_av_string() << "waiting for LLUpdateAppearanceOnDestroy" << LL_ENDL; -} - -void LLAppearanceMgr::updatePanelOutfitName(const std::string& name) -{ - LLSidepanelAppearance* panel_appearance = - dynamic_cast(LLFloaterSidePanelContainer::getPanel("appearance")); - if (panel_appearance) - { - panel_appearance->refreshCurrentOutfitName(name); - } -} - -void LLAppearanceMgr::createBaseOutfitLink(const LLUUID& category, LLPointer link_waiter) -{ - const LLUUID cof = getCOF(); - LLViewerInventoryCategory* catp = gInventory.getCategory(category); - std::string new_outfit_name = ""; - - purgeBaseOutfitLink(cof, link_waiter); - - if (catp && catp->getPreferredType() == LLFolderType::FT_OUTFIT) - { - link_inventory_object(cof, catp, link_waiter); - new_outfit_name = catp->getName(); - } - - updatePanelOutfitName(new_outfit_name); -} - -void LLAppearanceMgr::updateAgentWearables(LLWearableHoldingPattern* holder) -{ - LL_DEBUGS("Avatar") << "updateAgentWearables()" << LL_ENDL; - LLInventoryItem::item_array_t items; - std::vector< LLViewerWearable* > wearables; - wearables.reserve(32); - - // For each wearable type, find the wearables of that type. - for( S32 i = 0; i < LLWearableType::WT_COUNT; i++ ) - { - for (LLWearableHoldingPattern::found_list_t::iterator iter = holder->getFoundList().begin(); - iter != holder->getFoundList().end(); ++iter) - { - LLFoundData& data = *iter; - LLViewerWearable* wearable = data.mWearable; - if( wearable && ((S32)wearable->getType() == i) ) - { - LLViewerInventoryItem* item = (LLViewerInventoryItem*)gInventory.getItem(data.mItemID); - if( item && (item->getAssetUUID() == wearable->getAssetID()) ) - { - items.push_back(item); - wearables.push_back(wearable); - } - } - } - } - - if(wearables.size() > 0) - { - gAgentWearables.setWearableOutfit(items, wearables); - } -} - -S32 LLAppearanceMgr::countActiveHoldingPatterns() -{ - return LLWearableHoldingPattern::countActive(); -} - -static void remove_non_link_items(LLInventoryModel::item_array_t &items) -{ - LLInventoryModel::item_array_t pruned_items; - for (LLInventoryModel::item_array_t::const_iterator iter = items.begin(); - iter != items.end(); - ++iter) - { - const LLViewerInventoryItem *item = (*iter); - if (item && item->getIsLinkType()) - { - pruned_items.push_back((*iter)); - } - } - items = pruned_items; -} - -//a predicate for sorting inventory items by actual descriptions -bool sort_by_actual_description(const LLInventoryItem* item1, const LLInventoryItem* item2) -{ - if (!item1 || !item2) - { - LL_WARNS() << "either item1 or item2 is NULL" << LL_ENDL; - return true; - } - - return item1->getActualDescription() < item2->getActualDescription(); -} - -void item_array_diff(LLInventoryModel::item_array_t& full_list, - LLInventoryModel::item_array_t& keep_list, - LLInventoryModel::item_array_t& kill_list) - -{ - for (LLInventoryModel::item_array_t::iterator it = full_list.begin(); - it != full_list.end(); - ++it) - { - LLViewerInventoryItem *item = *it; - if (std::find(keep_list.begin(), keep_list.end(), item) == keep_list.end()) - { - kill_list.push_back(item); - } - } -} - -S32 LLAppearanceMgr::findExcessOrDuplicateItems(const LLUUID& cat_id, - LLAssetType::EType type, - S32 max_items, - LLInventoryObject::object_list_t& items_to_kill) -{ - S32 to_kill_count = 0; - - LLInventoryModel::item_array_t items; - getDescendentsOfAssetType(cat_id, items, type); - LLInventoryModel::item_array_t curr_items = items; - removeDuplicateItems(items); - if (max_items > 0) - { - filterWearableItems(items, max_items); - } - LLInventoryModel::item_array_t kill_items; - item_array_diff(curr_items,items,kill_items); - for (LLInventoryModel::item_array_t::iterator it = kill_items.begin(); - it != kill_items.end(); - ++it) - { - items_to_kill.push_back(LLPointer(*it)); - to_kill_count++; - } - return to_kill_count; -} - - -void LLAppearanceMgr::findAllExcessOrDuplicateItems(const LLUUID& cat_id, - LLInventoryObject::object_list_t& items_to_kill) -{ - findExcessOrDuplicateItems(cat_id,LLAssetType::AT_BODYPART, - 1, items_to_kill); - findExcessOrDuplicateItems(cat_id,LLAssetType::AT_CLOTHING, - LLAgentWearables::MAX_CLOTHING_PER_TYPE, items_to_kill); - findExcessOrDuplicateItems(cat_id,LLAssetType::AT_OBJECT, - -1, items_to_kill); -} - -void LLAppearanceMgr::enforceCOFItemRestrictions(LLPointer cb) -{ - LLInventoryObject::object_list_t items_to_kill; - findAllExcessOrDuplicateItems(getCOF(), items_to_kill); - if (items_to_kill.size()>0) - { - // Remove duplicate or excess wearables. Should normally be enforced at the UI level, but - // this should catch anything that gets through. - remove_inventory_items(items_to_kill, cb); - } -} - -void LLAppearanceMgr::updateAppearanceFromCOF(bool enforce_item_restrictions, - bool enforce_ordering, - nullary_func_t post_update_func) -{ - if (mIsInUpdateAppearanceFromCOF) - { - LL_WARNS() << "Called updateAppearanceFromCOF inside updateAppearanceFromCOF, skipping" << LL_ENDL; - return; - } - - LL_DEBUGS("Avatar") << self_av_string() << "starting" << LL_ENDL; - - if (enforce_item_restrictions) - { - // The point here is just to call - // updateAppearanceFromCOF() again after excess items - // have been removed. That time we will set - // enforce_item_restrictions to false so we don't get - // caught in a perpetual loop. - LLPointer cb( - new LLUpdateAppearanceOnDestroy(false, enforce_ordering, post_update_func)); - enforceCOFItemRestrictions(cb); - return; - } - - if (enforce_ordering) - { - //checking integrity of the COF in terms of ordering of wearables, - //checking and updating links' descriptions of wearables in the COF (before analyzed for "dirty" state) - - // As with enforce_item_restrictions handling above, we want - // to wait for the update callbacks, then (finally!) call - // updateAppearanceFromCOF() with no additional COF munging needed. - LLPointer cb( - new LLUpdateAppearanceOnDestroy(false, false, post_update_func)); - updateClothingOrderingInfo(LLUUID::null, cb); - return; - } - - if (!validateClothingOrderingInfo()) - { - LL_WARNS() << "Clothing ordering error" << LL_ENDL; - } - - BoolSetter setIsInUpdateAppearanceFromCOF(mIsInUpdateAppearanceFromCOF); - selfStartPhase("update_appearance_from_cof"); - - // update dirty flag to see if the state of the COF matches - // the saved outfit stored as a folder link - updateIsDirty(); - - // Send server request for appearance update - if (gAgent.getRegion() && gAgent.getRegion()->getCentralBakeVersion()) - { - requestServerAppearanceUpdate(); - } - - LLUUID current_outfit_id = getCOF(); - - // Find all the wearables that are in the COF's subtree. - LL_DEBUGS() << "LLAppearanceMgr::updateFromCOF()" << LL_ENDL; - LLInventoryModel::item_array_t wear_items; - LLInventoryModel::item_array_t obj_items; - LLInventoryModel::item_array_t gest_items; - getUserDescendents(current_outfit_id, wear_items, obj_items, gest_items); - // Get rid of non-links in case somehow the COF was corrupted. - remove_non_link_items(wear_items); - remove_non_link_items(obj_items); - remove_non_link_items(gest_items); - - dumpItemArray(wear_items,"asset_dump: wear_item"); - dumpItemArray(obj_items,"asset_dump: obj_item"); - - LLViewerInventoryCategory *cof = gInventory.getCategory(current_outfit_id); - if (!gInventory.isCategoryComplete(current_outfit_id)) - { - LL_WARNS() << "COF info is not complete. Version " << cof->getVersion() - << " descendent_count " << cof->getDescendentCount() - << " viewer desc count " << cof->getViewerDescendentCount() << LL_ENDL; - } - if(!wear_items.size()) - { - LLNotificationsUtil::add("CouldNotPutOnOutfit"); - return; - } - - //preparing the list of wearables in the correct order for LLAgentWearables - sortItemsByActualDescription(wear_items); - - - LL_DEBUGS("Avatar") << "HP block starts" << LL_ENDL; - LLTimer hp_block_timer; - LLWearableHoldingPattern* holder = new LLWearableHoldingPattern; - - holder->setObjItems(obj_items); - holder->setGestItems(gest_items); - - // Note: can't do normal iteration, because if all the - // wearables can be resolved immediately, then the - // callback will be called (and this object deleted) - // before the final getNextData(). - - for(S32 i = 0; i < wear_items.size(); ++i) - { - LLViewerInventoryItem *item = wear_items.at(i); - LLViewerInventoryItem *linked_item = item ? item->getLinkedItem() : NULL; - - // Fault injection: use debug setting to test asset - // fetch failures (should be replaced by new defaults in - // lost&found). - U32 skip_type = gSavedSettings.getU32("ForceAssetFail"); - - if (item && item->getIsLinkType() && linked_item) - { - LLFoundData found(linked_item->getUUID(), - linked_item->getAssetUUID(), - linked_item->getName(), - linked_item->getType(), - linked_item->isWearableType() ? linked_item->getWearableType() : LLWearableType::WT_INVALID - ); - - if (skip_type != LLWearableType::WT_INVALID && skip_type == found.mWearableType) - { - found.mAssetID.generate(); // Replace with new UUID, guaranteed not to exist in DB - } - //pushing back, not front, to preserve order of wearables for LLAgentWearables - holder->getFoundList().push_back(found); - } - else - { - if (!item) - { - LL_WARNS() << "Attempt to wear a null item " << LL_ENDL; - } - else if (!linked_item) - { - LL_WARNS() << "Attempt to wear a broken link [ name:" << item->getName() << " ] " << LL_ENDL; - } - } - } - - selfStartPhase("get_wearables_2"); - - for (LLWearableHoldingPattern::found_list_t::iterator it = holder->getFoundList().begin(); - it != holder->getFoundList().end(); ++it) - { - LLFoundData& found = *it; - - LL_DEBUGS() << self_av_string() << "waiting for onWearableAssetFetch callback, asset " << found.mAssetID.asString() << LL_ENDL; - - // Fetch the wearables about to be worn. - LLWearableList::instance().getAsset(found.mAssetID, - found.mName, - gAgentAvatarp, - found.mAssetType, - onWearableAssetFetch, - (void*)holder); - - } - - holder->resetTime(gSavedSettings.getF32("MaxWearableWaitTime")); - if (!holder->pollFetchCompletion()) - { - doOnIdleRepeating(boost::bind(&LLWearableHoldingPattern::pollFetchCompletion,holder)); - } - post_update_func(); - - LL_DEBUGS("Avatar") << "HP block ends, elapsed " << hp_block_timer.getElapsedTimeF32() << LL_ENDL; -} - -void LLAppearanceMgr::getDescendentsOfAssetType(const LLUUID& category, - LLInventoryModel::item_array_t& items, - LLAssetType::EType type) -{ - LLInventoryModel::cat_array_t cats; - LLIsType is_of_type(type); - gInventory.collectDescendentsIf(category, - cats, - items, - LLInventoryModel::EXCLUDE_TRASH, - is_of_type); -} - -void LLAppearanceMgr::getUserDescendents(const LLUUID& category, - LLInventoryModel::item_array_t& wear_items, - LLInventoryModel::item_array_t& obj_items, - LLInventoryModel::item_array_t& gest_items) -{ - LLInventoryModel::cat_array_t wear_cats; - LLFindWearables is_wearable; - gInventory.collectDescendentsIf(category, - wear_cats, - wear_items, - LLInventoryModel::EXCLUDE_TRASH, - is_wearable); - - LLInventoryModel::cat_array_t obj_cats; - LLIsType is_object( LLAssetType::AT_OBJECT ); - gInventory.collectDescendentsIf(category, - obj_cats, - obj_items, - LLInventoryModel::EXCLUDE_TRASH, - is_object); - - // Find all gestures in this folder - LLInventoryModel::cat_array_t gest_cats; - LLIsType is_gesture( LLAssetType::AT_GESTURE ); - gInventory.collectDescendentsIf(category, - gest_cats, - gest_items, - LLInventoryModel::EXCLUDE_TRASH, - is_gesture); -} - -void LLAppearanceMgr::wearInventoryCategory(LLInventoryCategory* category, bool copy, bool append) -{ - if(!category) return; - - selfClearPhases(); - selfStartPhase("wear_inventory_category"); - - gAgentWearables.notifyLoadingStarted(); - - LL_INFOS("Avatar") << self_av_string() << "wearInventoryCategory( " << category->getName() - << " )" << LL_ENDL; - - // If we are copying from library, attempt to use AIS to copy the category. - bool ais_ran=false; - if (copy && AISCommand::isAPIAvailable()) - { - LLUUID parent_id; - parent_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_CLOTHING); - if (parent_id.isNull()) - { - parent_id = gInventory.getRootFolderID(); - } - - LLPointer copy_cb = new LLWearCategoryAfterCopy(append); - LLPointer track_cb = new LLTrackPhaseWrapper( - std::string("wear_inventory_category_callback"), copy_cb); - LLPointer cmd_ptr = new CopyLibraryCategoryCommand(category->getUUID(), parent_id, track_cb); - ais_ran=cmd_ptr->run_command(); - } - - if (!ais_ran) - { - selfStartPhase("wear_inventory_category_fetch"); - callAfterCategoryFetch(category->getUUID(),boost::bind(&LLAppearanceMgr::wearCategoryFinal, - &LLAppearanceMgr::instance(), - category->getUUID(), copy, append)); - } -} - -S32 LLAppearanceMgr::getActiveCopyOperations() const -{ - return LLCallAfterInventoryCopyMgr::getInstanceCount(); -} - -void LLAppearanceMgr::wearCategoryFinal(LLUUID& cat_id, bool copy_items, bool append) -{ - LL_INFOS("Avatar") << self_av_string() << "starting" << LL_ENDL; - - selfStopPhase("wear_inventory_category_fetch"); - - // We now have an outfit ready to be copied to agent inventory. Do - // it, and wear that outfit normally. - LLInventoryCategory* cat = gInventory.getCategory(cat_id); - if(copy_items) - { - LLInventoryModel::cat_array_t* cats; - LLInventoryModel::item_array_t* items; - gInventory.getDirectDescendentsOf(cat_id, cats, items); - std::string name; - if(!cat) - { - // should never happen. - name = "New Outfit"; - } - else - { - name = cat->getName(); - } - LLViewerInventoryItem* item = NULL; - LLInventoryModel::item_array_t::const_iterator it = items->begin(); - LLInventoryModel::item_array_t::const_iterator end = items->end(); - LLUUID pid; - for(; it < end; ++it) - { - item = *it; - if(item) - { - if(LLInventoryType::IT_GESTURE == item->getInventoryType()) - { - pid = gInventory.findCategoryUUIDForType(LLFolderType::FT_GESTURE); - } - else - { - pid = gInventory.findCategoryUUIDForType(LLFolderType::FT_CLOTHING); - } - break; - } - } - if(pid.isNull()) - { - pid = gInventory.getRootFolderID(); - } - - LLUUID new_cat_id = gInventory.createNewCategory( - pid, - LLFolderType::FT_NONE, - name); - - // Create a CopyMgr that will copy items, manage its own destruction - new LLCallAfterInventoryCopyMgr( - *items, new_cat_id, std::string("wear_inventory_category_callback"), - boost::bind(&LLAppearanceMgr::wearInventoryCategoryOnAvatar, - LLAppearanceMgr::getInstance(), - gInventory.getCategory(new_cat_id), - append)); - - // BAP fixes a lag in display of created dir. - gInventory.notifyObservers(); - } - else - { - // Wear the inventory category. - LLAppearanceMgr::instance().wearInventoryCategoryOnAvatar(cat, append); - } -} - -// *NOTE: hack to get from avatar inventory to avatar -void LLAppearanceMgr::wearInventoryCategoryOnAvatar( LLInventoryCategory* category, bool append ) -{ - // Avoid unintentionally overwriting old wearables. We have to do - // this up front to avoid having to deal with the case of multiple - // wearables being dirty. - if (!category) return; - - if ( !LLInventoryCallbackManager::is_instantiated() ) - { - // shutting down, ignore. - return; - } - - LL_INFOS("Avatar") << self_av_string() << "wearInventoryCategoryOnAvatar '" << category->getName() - << "'" << LL_ENDL; - - if (gAgentCamera.cameraCustomizeAvatar()) - { - // switching to outfit editor should automagically save any currently edited wearable - LLFloaterSidePanelContainer::showPanel("appearance", LLSD().with("type", "edit_outfit")); - } - - LLAppearanceMgr::changeOutfit(TRUE, category->getUUID(), append); -} - -// FIXME do we really want to search entire inventory for matching name? -void LLAppearanceMgr::wearOutfitByName(const std::string& name) -{ - LL_INFOS("Avatar") << self_av_string() << "Wearing category " << name << LL_ENDL; - - LLInventoryModel::cat_array_t cat_array; - LLInventoryModel::item_array_t item_array; - LLNameCategoryCollector has_name(name); - gInventory.collectDescendentsIf(gInventory.getRootFolderID(), - cat_array, - item_array, - LLInventoryModel::EXCLUDE_TRASH, - has_name); - bool copy_items = false; - LLInventoryCategory* cat = NULL; - if (cat_array.size() > 0) - { - // Just wear the first one that matches - cat = cat_array.at(0); - } - else - { - gInventory.collectDescendentsIf(LLUUID::null, - cat_array, - item_array, - LLInventoryModel::EXCLUDE_TRASH, - has_name); - if(cat_array.size() > 0) - { - cat = cat_array.at(0); - copy_items = true; - } - } - - if(cat) - { - LLAppearanceMgr::wearInventoryCategory(cat, copy_items, false); - } - else - { - LL_WARNS() << "Couldn't find outfit " <isWearableType() && b->isWearableType() && - (a->getWearableType() == b->getWearableType())); -} - -class LLDeferredCOFLinkObserver: public LLInventoryObserver -{ -public: - LLDeferredCOFLinkObserver(const LLUUID& item_id, LLPointer cb, const std::string& description): - mItemID(item_id), - mCallback(cb), - mDescription(description) - { - } - - ~LLDeferredCOFLinkObserver() - { - } - - /* virtual */ void changed(U32 mask) - { - const LLInventoryItem *item = gInventory.getItem(mItemID); - if (item) - { - gInventory.removeObserver(this); - LLAppearanceMgr::instance().addCOFItemLink(item, mCallback, mDescription); - delete this; - } - } - -private: - const LLUUID mItemID; - std::string mDescription; - LLPointer mCallback; -}; - - -// BAP - note that this runs asynchronously if the item is not already loaded from inventory. -// Dangerous if caller assumes link will exist after calling the function. -void LLAppearanceMgr::addCOFItemLink(const LLUUID &item_id, - LLPointer cb, - const std::string description) -{ - const LLInventoryItem *item = gInventory.getItem(item_id); - if (!item) - { - LLDeferredCOFLinkObserver *observer = new LLDeferredCOFLinkObserver(item_id, cb, description); - gInventory.addObserver(observer); - } - else - { - addCOFItemLink(item, cb, description); - } -} - -void LLAppearanceMgr::addCOFItemLink(const LLInventoryItem *item, - LLPointer cb, - const std::string description) -{ - const LLViewerInventoryItem *vitem = dynamic_cast(item); - if (!vitem) - { - LL_WARNS() << "not an llviewerinventoryitem, failed" << LL_ENDL; - return; - } - - gInventory.addChangedMask(LLInventoryObserver::LABEL, vitem->getLinkedUUID()); - - LLInventoryModel::cat_array_t cat_array; - LLInventoryModel::item_array_t item_array; - gInventory.collectDescendents(LLAppearanceMgr::getCOF(), - cat_array, - item_array, - LLInventoryModel::EXCLUDE_TRASH); - bool linked_already = false; - U32 count = 0; - for (S32 i=0; igetWearableType(); - - const bool is_body_part = (wearable_type == LLWearableType::WT_SHAPE) - || (wearable_type == LLWearableType::WT_HAIR) - || (wearable_type == LLWearableType::WT_EYES) - || (wearable_type == LLWearableType::WT_SKIN); - - if (inv_item->getLinkedUUID() == vitem->getLinkedUUID()) - { - linked_already = true; - } - // Are these links to different items of the same body part - // type? If so, new item will replace old. - else if ((vitem->isWearableType()) && (vitem->getWearableType() == wearable_type)) - { - ++count; - if (is_body_part && inv_item->getIsLinkType() && (vitem->getWearableType() == wearable_type)) - { - remove_inventory_item(inv_item->getUUID(), cb); - } - else if (count >= LLAgentWearables::MAX_CLOTHING_PER_TYPE) - { - // MULTI-WEARABLES: make sure we don't go over MAX_CLOTHING_PER_TYPE - remove_inventory_item(inv_item->getUUID(), cb); - } - } - } - - if (!linked_already) - { - LLViewerInventoryItem *copy_item = new LLViewerInventoryItem; - copy_item->copyViewerItem(vitem); - copy_item->setDescription(description); - link_inventory_object(getCOF(), copy_item, cb); - } -} - -LLInventoryModel::item_array_t LLAppearanceMgr::findCOFItemLinks(const LLUUID& item_id) -{ - - LLInventoryModel::item_array_t result; - const LLViewerInventoryItem *vitem = - dynamic_cast(gInventory.getItem(item_id)); - - if (vitem) - { - LLInventoryModel::cat_array_t cat_array; - LLInventoryModel::item_array_t item_array; - gInventory.collectDescendents(LLAppearanceMgr::getCOF(), - cat_array, - item_array, - LLInventoryModel::EXCLUDE_TRASH); - for (S32 i=0; igetLinkedUUID() == vitem->getLinkedUUID()) - { - result.push_back(item_array.at(i)); - } - } - } - return result; -} - -bool LLAppearanceMgr::isLinkedInCOF(const LLUUID& item_id) -{ - LLInventoryModel::item_array_t links = LLAppearanceMgr::instance().findCOFItemLinks(item_id); - return links.size() > 0; -} - -void LLAppearanceMgr::removeAllClothesFromAvatar() -{ - // Fetch worn clothes (i.e. the ones in COF). - LLInventoryModel::item_array_t clothing_items; - LLInventoryModel::cat_array_t dummy; - LLIsType is_clothing(LLAssetType::AT_CLOTHING); - gInventory.collectDescendentsIf(getCOF(), - dummy, - clothing_items, - LLInventoryModel::EXCLUDE_TRASH, - is_clothing); - uuid_vec_t item_ids; - for (LLInventoryModel::item_array_t::iterator it = clothing_items.begin(); - it != clothing_items.end(); ++it) - { - item_ids.push_back((*it).get()->getLinkedUUID()); - } - - // Take them off by removing from COF. - removeItemsFromAvatar(item_ids); -} - -void LLAppearanceMgr::removeAllAttachmentsFromAvatar() -{ - if (!isAgentAvatarValid()) return; - - LLAgentWearables::llvo_vec_t objects_to_remove; - - for (LLVOAvatar::attachment_map_t::iterator iter = gAgentAvatarp->mAttachmentPoints.begin(); - iter != gAgentAvatarp->mAttachmentPoints.end();) - { - LLVOAvatar::attachment_map_t::iterator curiter = iter++; - LLViewerJointAttachment* attachment = curiter->second; - for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin(); - attachment_iter != attachment->mAttachedObjects.end(); - ++attachment_iter) - { - LLViewerObject *attached_object = (*attachment_iter); - if (attached_object) - { - objects_to_remove.push_back(attached_object); - } - } - } - uuid_vec_t ids_to_remove; - for (LLAgentWearables::llvo_vec_t::iterator it = objects_to_remove.begin(); - it != objects_to_remove.end(); - ++it) - { - ids_to_remove.push_back((*it)->getAttachmentItemID()); - } - removeItemsFromAvatar(ids_to_remove); -} - -void LLAppearanceMgr::removeCOFItemLinks(const LLUUID& item_id, LLPointer cb) -{ - gInventory.addChangedMask(LLInventoryObserver::LABEL, item_id); - - LLInventoryModel::cat_array_t cat_array; - LLInventoryModel::item_array_t item_array; - gInventory.collectDescendents(LLAppearanceMgr::getCOF(), - cat_array, - item_array, - LLInventoryModel::EXCLUDE_TRASH); - for (S32 i=0; igetIsLinkType() && item->getLinkedUUID() == item_id) - { - bool immediate_delete = false; - if (item->getType() == LLAssetType::AT_OBJECT) - { - immediate_delete = true; - } - remove_inventory_item(item->getUUID(), cb, immediate_delete); - } - } -} - -void LLAppearanceMgr::removeCOFLinksOfType(LLWearableType::EType type, LLPointer cb) -{ - LLFindWearablesOfType filter_wearables_of_type(type); - LLInventoryModel::cat_array_t cats; - LLInventoryModel::item_array_t items; - LLInventoryModel::item_array_t::const_iterator it; - - gInventory.collectDescendentsIf(getCOF(), cats, items, true, filter_wearables_of_type); - for (it = items.begin(); it != items.end(); ++it) - { - const LLViewerInventoryItem* item = *it; - if (item->getIsLinkType()) // we must operate on links only - { - remove_inventory_item(item->getUUID(), cb); - } - } -} - -bool sort_by_linked_uuid(const LLViewerInventoryItem* item1, const LLViewerInventoryItem* item2) -{ - if (!item1 || !item2) - { - LL_WARNS() << "item1, item2 cannot be null, something is very wrong" << LL_ENDL; - return true; - } - - return item1->getLinkedUUID() < item2->getLinkedUUID(); -} - -void LLAppearanceMgr::updateIsDirty() -{ - LLUUID cof = getCOF(); - LLUUID base_outfit; - - // find base outfit link - const LLViewerInventoryItem* base_outfit_item = getBaseOutfitLink(); - LLViewerInventoryCategory* catp = NULL; - if (base_outfit_item && base_outfit_item->getIsLinkType()) - { - catp = base_outfit_item->getLinkedCategory(); - } - if(catp && catp->getPreferredType() == LLFolderType::FT_OUTFIT) - { - base_outfit = catp->getUUID(); - } - - // Set dirty to "false" if no base outfit found to disable "Save" - // and leave only "Save As" enabled in My Outfits. - mOutfitIsDirty = false; - - if (base_outfit.notNull()) - { - LLIsValidItemLink collector; - - LLInventoryModel::cat_array_t cof_cats; - LLInventoryModel::item_array_t cof_items; - gInventory.collectDescendentsIf(cof, cof_cats, cof_items, - LLInventoryModel::EXCLUDE_TRASH, collector); - - LLInventoryModel::cat_array_t outfit_cats; - LLInventoryModel::item_array_t outfit_items; - gInventory.collectDescendentsIf(base_outfit, outfit_cats, outfit_items, - LLInventoryModel::EXCLUDE_TRASH, collector); - - if(outfit_items.size() != cof_items.size()) - { - LL_DEBUGS("Avatar") << "item count different - base " << outfit_items.size() << " cof " << cof_items.size() << LL_ENDL; - // Current outfit folder should have one more item than the outfit folder. - // this one item is the link back to the outfit folder itself. - mOutfitIsDirty = true; - return; - } - - //"dirty" - also means a difference in linked UUIDs and/or a difference in wearables order (links' descriptions) - std::sort(cof_items.begin(), cof_items.end(), sort_by_linked_uuid); - std::sort(outfit_items.begin(), outfit_items.end(), sort_by_linked_uuid); - - for (U32 i = 0; i < cof_items.size(); ++i) - { - LLViewerInventoryItem *item1 = cof_items.at(i); - LLViewerInventoryItem *item2 = outfit_items.at(i); - - if (item1->getLinkedUUID() != item2->getLinkedUUID() || - item1->getName() != item2->getName() || - item1->getActualDescription() != item2->getActualDescription()) - { - if (item1->getLinkedUUID() != item2->getLinkedUUID()) - { - LL_DEBUGS("Avatar") << "link id different " << LL_ENDL; - } - else - { - if (item1->getName() != item2->getName()) - { - LL_DEBUGS("Avatar") << "name different " << item1->getName() << " " << item2->getName() << LL_ENDL; - } - if (item1->getActualDescription() != item2->getActualDescription()) - { - LL_DEBUGS("Avatar") << "desc different " << item1->getActualDescription() - << " " << item2->getActualDescription() - << " names " << item1->getName() << " " << item2->getName() << LL_ENDL; - } - } - mOutfitIsDirty = true; - return; - } - } - } - llassert(!mOutfitIsDirty); - LL_DEBUGS("Avatar") << "clean" << LL_ENDL; -} - -// *HACK: Must match name in Library or agent inventory -const std::string ROOT_GESTURES_FOLDER = "Gestures"; -const std::string COMMON_GESTURES_FOLDER = "Common Gestures"; -const std::string MALE_GESTURES_FOLDER = "Male Gestures"; -const std::string FEMALE_GESTURES_FOLDER = "Female Gestures"; -const std::string SPEECH_GESTURES_FOLDER = "Speech Gestures"; -const std::string OTHER_GESTURES_FOLDER = "Other Gestures"; - -void LLAppearanceMgr::copyLibraryGestures() -{ - LL_INFOS("Avatar") << self_av_string() << "Copying library gestures" << LL_ENDL; - - // Copy gestures - LLUUID lib_gesture_cat_id = - gInventory.findLibraryCategoryUUIDForType(LLFolderType::FT_GESTURE,false); - if (lib_gesture_cat_id.isNull()) - { - LL_WARNS() << "Unable to copy gestures, source category not found" << LL_ENDL; - } - LLUUID dst_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_GESTURE); - - std::vector gesture_folders_to_copy; - gesture_folders_to_copy.push_back(MALE_GESTURES_FOLDER); - gesture_folders_to_copy.push_back(FEMALE_GESTURES_FOLDER); - gesture_folders_to_copy.push_back(COMMON_GESTURES_FOLDER); - gesture_folders_to_copy.push_back(SPEECH_GESTURES_FOLDER); - gesture_folders_to_copy.push_back(OTHER_GESTURES_FOLDER); - - for(std::vector::iterator it = gesture_folders_to_copy.begin(); - it != gesture_folders_to_copy.end(); - ++it) - { - std::string& folder_name = *it; - - LLPointer cb(NULL); - - // After copying gestures, activate Common, Other, plus - // Male and/or Female, depending upon the initial outfit gender. - ESex gender = gAgentAvatarp->getSex(); - - std::string activate_male_gestures; - std::string activate_female_gestures; - switch (gender) { - case SEX_MALE: - activate_male_gestures = MALE_GESTURES_FOLDER; - break; - case SEX_FEMALE: - activate_female_gestures = FEMALE_GESTURES_FOLDER; - break; - case SEX_BOTH: - activate_male_gestures = MALE_GESTURES_FOLDER; - activate_female_gestures = FEMALE_GESTURES_FOLDER; - break; - } - - if (folder_name == activate_male_gestures || - folder_name == activate_female_gestures || - folder_name == COMMON_GESTURES_FOLDER || - folder_name == OTHER_GESTURES_FOLDER) - { - cb = new LLBoostFuncInventoryCallback(activate_gesture_cb); - } - - LLUUID cat_id = findDescendentCategoryIDByName(lib_gesture_cat_id,folder_name); - if (cat_id.isNull()) - { - LL_WARNS() << self_av_string() << "failed to find gesture folder for " << folder_name << LL_ENDL; - } - else - { - LL_DEBUGS("Avatar") << self_av_string() << "initiating fetch and copy for " << folder_name << " cat_id " << cat_id << LL_ENDL; - callAfterCategoryFetch(cat_id, - boost::bind(&LLAppearanceMgr::shallowCopyCategory, - &LLAppearanceMgr::instance(), - cat_id, dst_id, cb)); - } - } -} - -// Handler for anything that's deferred until avatar de-clouds. -void LLAppearanceMgr::onFirstFullyVisible() -{ - gAgentAvatarp->outputRezTiming("Avatar fully loaded"); - gAgentAvatarp->reportAvatarRezTime(); - gAgentAvatarp->debugAvatarVisible(); - - // If this is the first time we've ever logged in, - // then copy default gestures from the library. - if (gAgent.isFirstLogin()) { - copyLibraryGestures(); - } -} - -// update "dirty" state - defined outside class to allow for calling -// after appearance mgr instance has been destroyed. -void appearance_mgr_update_dirty_state() -{ - if (LLAppearanceMgr::instanceExists()) - { - LLAppearanceMgr::getInstance()->updateIsDirty(); - LLAppearanceMgr::getInstance()->setOutfitLocked(false); - gAgentWearables.notifyLoadingFinished(); - } -} - -void update_base_outfit_after_ordering() -{ - LLAppearanceMgr& app_mgr = LLAppearanceMgr::instance(); - - LLPointer dirty_state_updater = - new LLBoostFuncInventoryCallback(no_op_inventory_func, appearance_mgr_update_dirty_state); - - //COF contains only links so we copy to the Base Outfit only links - const LLUUID base_outfit_id = app_mgr.getBaseOutfitUUID(); - bool copy_folder_links = false; - app_mgr.slamCategoryLinks(app_mgr.getCOF(), base_outfit_id, copy_folder_links, dirty_state_updater); - -} - -// Save COF changes - update the contents of the current base outfit -// to match the current COF. Fails if no current base outfit is set. -bool LLAppearanceMgr::updateBaseOutfit() -{ - if (isOutfitLocked()) - { - // don't allow modify locked outfit - llassert(!isOutfitLocked()); - return false; - } - - setOutfitLocked(true); - - gAgentWearables.notifyLoadingStarted(); - - const LLUUID base_outfit_id = getBaseOutfitUUID(); - if (base_outfit_id.isNull()) return false; - LL_DEBUGS("Avatar") << "saving cof to base outfit " << base_outfit_id << LL_ENDL; - - LLPointer cb = - new LLBoostFuncInventoryCallback(no_op_inventory_func, update_base_outfit_after_ordering); - // Really shouldn't be needed unless there's a race condition - - // updateAppearanceFromCOF() already calls updateClothingOrderingInfo. - updateClothingOrderingInfo(LLUUID::null, cb); - - return true; -} - -void LLAppearanceMgr::divvyWearablesByType(const LLInventoryModel::item_array_t& items, wearables_by_type_t& items_by_type) -{ - items_by_type.resize(LLWearableType::WT_COUNT); - if (items.empty()) return; - - for (S32 i=0; iisWearableType()) - continue; - LLWearableType::EType type = item->getWearableType(); - if(type < 0 || type >= LLWearableType::WT_COUNT) - { - LL_WARNS("Appearance") << "Invalid wearable type. Inventory type does not match wearable flag bitfield." << LL_ENDL; - continue; - } - items_by_type[type].push_back(item); - } -} - -std::string build_order_string(LLWearableType::EType type, U32 i) -{ - std::ostringstream order_num; - order_num << ORDER_NUMBER_SEPARATOR << type * 100 + i; - return order_num.str(); -} - -struct WearablesOrderComparator -{ - LOG_CLASS(WearablesOrderComparator); - WearablesOrderComparator(const LLWearableType::EType type) - { - mControlSize = build_order_string(type, 0).size(); - }; - - bool operator()(const LLInventoryItem* item1, const LLInventoryItem* item2) - { - const std::string& desc1 = item1->getActualDescription(); - const std::string& desc2 = item2->getActualDescription(); - - bool item1_valid = (desc1.size() == mControlSize) && (ORDER_NUMBER_SEPARATOR == desc1[0]); - bool item2_valid = (desc2.size() == mControlSize) && (ORDER_NUMBER_SEPARATOR == desc2[0]); - - if (item1_valid && item2_valid) - return desc1 < desc2; - - //we need to sink down invalid items: items with empty descriptions, items with "Broken link" descriptions, - //items with ordering information but not for the associated wearables type - if (!item1_valid && item2_valid) - return false; - else if (item1_valid && !item2_valid) - return true; - - return item1->getName() < item2->getName(); - } - - U32 mControlSize; -}; - -void LLAppearanceMgr::getWearableOrderingDescUpdates(LLInventoryModel::item_array_t& wear_items, - desc_map_t& desc_map) -{ - wearables_by_type_t items_by_type(LLWearableType::WT_COUNT); - divvyWearablesByType(wear_items, items_by_type); - - for (U32 type = LLWearableType::WT_SHIRT; type < LLWearableType::WT_COUNT; type++) - { - U32 size = items_by_type[type].size(); - if (!size) continue; - - //sinking down invalid items which need reordering - std::sort(items_by_type[type].begin(), items_by_type[type].end(), WearablesOrderComparator((LLWearableType::EType) type)); - - //requesting updates only for those links which don't have "valid" descriptions - for (U32 i = 0; i < size; i++) - { - LLViewerInventoryItem* item = items_by_type[type][i]; - if (!item) continue; - - std::string new_order_str = build_order_string((LLWearableType::EType)type, i); - if (new_order_str == item->getActualDescription()) continue; - - desc_map[item->getUUID()] = new_order_str; - } - } -} - -bool LLAppearanceMgr::validateClothingOrderingInfo(LLUUID cat_id) -{ - // COF is processed if cat_id is not specified - if (cat_id.isNull()) - { - cat_id = getCOF(); - } - - LLInventoryModel::item_array_t wear_items; - getDescendentsOfAssetType(cat_id, wear_items, LLAssetType::AT_CLOTHING); - - // Identify items for which desc needs to change. - desc_map_t desc_map; - getWearableOrderingDescUpdates(wear_items, desc_map); - - for (desc_map_t::const_iterator it = desc_map.begin(); - it != desc_map.end(); ++it) - { - const LLUUID& item_id = it->first; - const std::string& new_order_str = it->second; - LLViewerInventoryItem *item = gInventory.getItem(item_id); - LL_WARNS() << "Order validation fails: " << item->getName() - << " needs to update desc to: " << new_order_str - << " (from: " << item->getActualDescription() << ")" << LL_ENDL; - } - - return desc_map.size() == 0; -} - -void LLAppearanceMgr::updateClothingOrderingInfo(LLUUID cat_id, - LLPointer cb) -{ - // COF is processed if cat_id is not specified - if (cat_id.isNull()) - { - cat_id = getCOF(); - } - - LLInventoryModel::item_array_t wear_items; - getDescendentsOfAssetType(cat_id, wear_items, LLAssetType::AT_CLOTHING); - - // Identify items for which desc needs to change. - desc_map_t desc_map; - getWearableOrderingDescUpdates(wear_items, desc_map); - - for (desc_map_t::const_iterator it = desc_map.begin(); - it != desc_map.end(); ++it) - { - LLSD updates; - const LLUUID& item_id = it->first; - const std::string& new_order_str = it->second; - LLViewerInventoryItem *item = gInventory.getItem(item_id); - LL_DEBUGS("Avatar") << item->getName() << " updating desc to: " << new_order_str - << " (was: " << item->getActualDescription() << ")" << LL_ENDL; - updates["desc"] = new_order_str; - update_inventory_item(item_id,updates,cb); - } - -} - -#if 1 -class RequestAgentUpdateAppearanceResponder: public LLHTTPClient::Responder -{ - LOG_CLASS(RequestAgentUpdateAppearanceResponder); - - friend class LLAppearanceMgr; - -public: - RequestAgentUpdateAppearanceResponder(); - - virtual ~RequestAgentUpdateAppearanceResponder(); - -private: - // Called when sendServerAppearanceUpdate called. May or may not - // trigger a request depending on various bits of state. - void onRequestRequested(); - - // Post the actual appearance request to cap. - void sendRequest(); - - void debugCOF(const LLSD& content); - -protected: - // Successful completion. - /* virtual */ void httpSuccess(); - - // Error - /*virtual*/ void httpFailure(); - - void onFailure(); - void onSuccess(); - - S32 mInFlightCounter; - LLTimer mInFlightTimer; - LLPointer mRetryPolicy; -}; - -RequestAgentUpdateAppearanceResponder::RequestAgentUpdateAppearanceResponder() -{ - bool retry_on_4xx = true; - mRetryPolicy = new LLAdaptiveRetryPolicy(1.0, 32.0, 2.0, 10, retry_on_4xx); - mInFlightCounter = 0; -} - -RequestAgentUpdateAppearanceResponder::~RequestAgentUpdateAppearanceResponder() -{ -} - -void RequestAgentUpdateAppearanceResponder::onRequestRequested() -{ - // If we have already received an update for this or higher cof version, ignore. - S32 cof_version = LLAppearanceMgr::instance().getCOFVersion(); - S32 last_rcv = gAgentAvatarp->mLastUpdateReceivedCOFVersion; - S32 last_req = gAgentAvatarp->mLastUpdateRequestCOFVersion; - LL_DEBUGS("Avatar") << "cof_version " << cof_version - << " last_rcv " << last_rcv - << " last_req " << last_req - << " in flight " << mInFlightCounter << LL_ENDL; - if ((mInFlightCounter>0) && (mInFlightTimer.hasExpired())) - { - LL_WARNS("Avatar") << "in flight timer expired, resetting " << LL_ENDL; - mInFlightCounter = 0; - } - if (cof_version < last_rcv) - { - LL_DEBUGS("Avatar") << "Have already received update for cof version " << last_rcv - << " will not request for " << cof_version << LL_ENDL; - return; - } - if (mInFlightCounter>0 && last_req >= cof_version) - { - LL_DEBUGS("Avatar") << "Request already in flight for cof version " << last_req - << " will not request for " << cof_version << LL_ENDL; - return; - } - - // Actually send the request. - LL_DEBUGS("Avatar") << "Will send request for cof_version " << cof_version << LL_ENDL; - mRetryPolicy->reset(); - sendRequest(); -} - -void RequestAgentUpdateAppearanceResponder::sendRequest() -{ - if (gAgentAvatarp->isEditingAppearance()) - { - // don't send out appearance updates if in appearance editing mode - return; - } - - if (!gAgent.getRegion()) - { - LL_WARNS() << "Region not set, cannot request server appearance update" << LL_ENDL; - return; - } - if (gAgent.getRegion()->getCentralBakeVersion()==0) - { - LL_WARNS() << "Region does not support baking" << LL_ENDL; - } - std::string url = gAgent.getRegion()->getCapability("UpdateAvatarAppearance"); - if (url.empty()) - { - LL_WARNS() << "No cap for UpdateAvatarAppearance." << LL_ENDL; - return; - } - - LLSD body; - S32 cof_version = LLAppearanceMgr::instance().getCOFVersion(); - if (gSavedSettings.getBOOL("DebugAvatarExperimentalServerAppearanceUpdate")) - { - body = LLAppearanceMgr::instance().dumpCOF(); - } - else - { - body["cof_version"] = cof_version; - if (gSavedSettings.getBOOL("DebugForceAppearanceRequestFailure")) - { - body["cof_version"] = cof_version+999; - } - } - LL_DEBUGS("Avatar") << "request url " << url << " my_cof_version " << cof_version << LL_ENDL; - - mInFlightCounter++; - mInFlightTimer.setTimerExpirySec(60.0); - LLHTTPClient::post(url, body, this); - llassert(cof_version >= gAgentAvatarp->mLastUpdateRequestCOFVersion); - gAgentAvatarp->mLastUpdateRequestCOFVersion = cof_version; -} - -void RequestAgentUpdateAppearanceResponder::debugCOF(const LLSD& content) -{ - LL_INFOS("Avatar") << "AIS COF, version received: " << content["expected"].asInteger() - << " ================================= " << LL_ENDL; - std::set ais_items, local_items; - const LLSD& cof_raw = content["cof_raw"]; - for (LLSD::array_const_iterator it = cof_raw.beginArray(); - it != cof_raw.endArray(); ++it) - { - const LLSD& item = *it; - if (item["parent_id"].asUUID() == LLAppearanceMgr::instance().getCOF()) - { - ais_items.insert(item["item_id"].asUUID()); - if (item["type"].asInteger() == 24) // link - { - LL_INFOS("Avatar") << "AIS Link: item_id: " << item["item_id"].asUUID() - << " linked_item_id: " << item["asset_id"].asUUID() - << " name: " << item["name"].asString() - << LL_ENDL; - } - else if (item["type"].asInteger() == 25) // folder link - { - LL_INFOS("Avatar") << "AIS Folder link: item_id: " << item["item_id"].asUUID() - << " linked_item_id: " << item["asset_id"].asUUID() - << " name: " << item["name"].asString() - << LL_ENDL; - } - else - { - LL_INFOS("Avatar") << "AIS Other: item_id: " << item["item_id"].asUUID() - << " linked_item_id: " << item["asset_id"].asUUID() - << " name: " << item["name"].asString() - << " type: " << item["type"].asInteger() - << LL_ENDL; - } - } - } - LL_INFOS("Avatar") << LL_ENDL; - LL_INFOS("Avatar") << "Local COF, version requested: " << content["observed"].asInteger() - << " ================================= " << LL_ENDL; - LLInventoryModel::cat_array_t cat_array; - LLInventoryModel::item_array_t item_array; - gInventory.collectDescendents(LLAppearanceMgr::instance().getCOF(), - cat_array,item_array,LLInventoryModel::EXCLUDE_TRASH); - for (S32 i=0; igetUUID()); - LL_INFOS("Avatar") << "LOCAL: item_id: " << inv_item->getUUID() - << " linked_item_id: " << inv_item->getLinkedUUID() - << " name: " << inv_item->getName() - << " parent: " << inv_item->getParentUUID() - << LL_ENDL; - } - LL_INFOS("Avatar") << " ================================= " << LL_ENDL; - S32 local_only = 0, ais_only = 0; - for (std::set::iterator it = local_items.begin(); it != local_items.end(); ++it) - { - if (ais_items.find(*it) == ais_items.end()) - { - LL_INFOS("Avatar") << "LOCAL ONLY: " << *it << LL_ENDL; - local_only++; - } - } - for (std::set::iterator it = ais_items.begin(); it != ais_items.end(); ++it) - { - if (local_items.find(*it) == local_items.end()) - { - LL_INFOS("Avatar") << "AIS ONLY: " << *it << LL_ENDL; - ais_only++; - } - } - if (local_only==0 && ais_only==0) - { - LL_INFOS("Avatar") << "COF contents identical, only version numbers differ (req " - << content["observed"].asInteger() - << " rcv " << content["expected"].asInteger() - << ")" << LL_ENDL; - } -} - -/* virtual */ void RequestAgentUpdateAppearanceResponder::httpSuccess() -{ - const LLSD& content = getContent(); - if (!content.isMap()) - { - failureResult(HTTP_INTERNAL_ERROR, "Malformed response contents", content); - return; - } - if (content["success"].asBoolean()) - { - LL_DEBUGS("Avatar") << "succeeded" << LL_ENDL; - if (gSavedSettings.getBOOL("DebugAvatarAppearanceMessage")) - { - dump_sequential_xml(gAgentAvatarp->getFullname() + "_appearance_request_ok", content); - } - - onSuccess(); - } - else - { - failureResult(HTTP_INTERNAL_ERROR, "Non-success response", content); - } -} - -void RequestAgentUpdateAppearanceResponder::onSuccess() -{ - mInFlightCounter = llmax(mInFlightCounter-1,0); -} - -/*virtual*/ void RequestAgentUpdateAppearanceResponder::httpFailure() -{ - LL_WARNS("Avatar") << "appearance update request failed, status " - << getStatus() << " reason " << getReason() << LL_ENDL; - - if (gSavedSettings.getBOOL("DebugAvatarAppearanceMessage")) - { - const LLSD& content = getContent(); - dump_sequential_xml(gAgentAvatarp->getFullname() + "_appearance_request_error", content); - debugCOF(content); - } - onFailure(); -} - -void RequestAgentUpdateAppearanceResponder::onFailure() -{ - mInFlightCounter = llmax(mInFlightCounter-1,0); - - F32 seconds_to_wait; - mRetryPolicy->onFailure(getStatus(), getResponseHeaders()); - if (mRetryPolicy->shouldRetry(seconds_to_wait)) - { - LL_INFOS() << "retrying" << LL_ENDL; - doAfterInterval(boost::bind(&RequestAgentUpdateAppearanceResponder::sendRequest,this), - seconds_to_wait); - } - else - { - LL_WARNS() << "giving up after too many retries" << LL_ENDL; - } -} -#else - - -#endif - - -LLSD LLAppearanceMgr::dumpCOF() const -{ - LLSD links = LLSD::emptyArray(); - LLMD5 md5; - - LLInventoryModel::cat_array_t cat_array; - LLInventoryModel::item_array_t item_array; - gInventory.collectDescendents(getCOF(),cat_array,item_array,LLInventoryModel::EXCLUDE_TRASH); - for (S32 i=0; igetUUID()); - md5.update((unsigned char*)item_id.mData, 16); - item["description"] = inv_item->getActualDescription(); - md5.update(inv_item->getActualDescription()); - item["asset_type"] = inv_item->getActualType(); - LLUUID linked_id(inv_item->getLinkedUUID()); - item["linked_id"] = linked_id; - md5.update((unsigned char*)linked_id.mData, 16); - - if (LLAssetType::AT_LINK == inv_item->getActualType()) - { - const LLViewerInventoryItem* linked_item = inv_item->getLinkedItem(); - if (NULL == linked_item) - { - LL_WARNS() << "Broken link for item '" << inv_item->getName() - << "' (" << inv_item->getUUID() - << ") during requestServerAppearanceUpdate" << LL_ENDL; - continue; - } - // Some assets may be 'hidden' and show up as null in the viewer. - //if (linked_item->getAssetUUID().isNull()) - //{ - // LL_WARNS() << "Broken link (null asset) for item '" << inv_item->getName() - // << "' (" << inv_item->getUUID() - // << ") during requestServerAppearanceUpdate" << LL_ENDL; - // continue; - //} - LLUUID linked_asset_id(linked_item->getAssetUUID()); - md5.update((unsigned char*)linked_asset_id.mData, 16); - U32 flags = linked_item->getFlags(); - md5.update(boost::lexical_cast(flags)); - } - else if (LLAssetType::AT_LINK_FOLDER != inv_item->getActualType()) - { - LL_WARNS() << "Non-link item '" << inv_item->getName() - << "' (" << inv_item->getUUID() - << ") type " << (S32) inv_item->getActualType() - << " during requestServerAppearanceUpdate" << LL_ENDL; - continue; - } - links.append(item); - } - LLSD result = LLSD::emptyMap(); - result["cof_contents"] = links; - char cof_md5sum[MD5HEX_STR_SIZE]; - md5.finalize(); - md5.hex_digest(cof_md5sum); - result["cof_md5sum"] = std::string(cof_md5sum); - return result; -} - -void LLAppearanceMgr::requestServerAppearanceUpdate() -{ - mAppearanceResponder->onRequestRequested(); -} - -class LLIncrementCofVersionResponder : public LLHTTPClient::Responder -{ - LOG_CLASS(LLIncrementCofVersionResponder); -public: - LLIncrementCofVersionResponder() : LLHTTPClient::Responder() - { - mRetryPolicy = new LLAdaptiveRetryPolicy(1.0, 16.0, 2.0, 5); - } - - virtual ~LLIncrementCofVersionResponder() - { - } - -protected: - virtual void httpSuccess() - { - LL_INFOS() << "Successfully incremented agent's COF." << LL_ENDL; - const LLSD& content = getContent(); - if (!content.isMap()) - { - failureResult(HTTP_INTERNAL_ERROR, "Malformed response contents", content); - return; - } - S32 new_version = content["category"]["version"].asInteger(); - - // cof_version should have increased - llassert(new_version > gAgentAvatarp->mLastUpdateRequestCOFVersion); - - gAgentAvatarp->mLastUpdateRequestCOFVersion = new_version; - } - - virtual void httpFailure() - { - LL_WARNS("Avatar") << "While attempting to increment the agent's cof we got an error " - << dumpResponse() << LL_ENDL; - F32 seconds_to_wait; - mRetryPolicy->onFailure(getStatus(), getResponseHeaders()); - if (mRetryPolicy->shouldRetry(seconds_to_wait)) - { - LL_INFOS() << "retrying" << LL_ENDL; - doAfterInterval(boost::bind(&LLAppearanceMgr::incrementCofVersion, - LLAppearanceMgr::getInstance(), - LLHTTPClient::ResponderPtr(this)), - seconds_to_wait); - } - else - { - LL_WARNS() << "giving up after too many retries" << LL_ENDL; - } - } - -private: - LLPointer mRetryPolicy; -}; - -void LLAppearanceMgr::incrementCofVersion(LLHTTPClient::ResponderPtr responder_ptr) -{ - // If we don't have a region, report it as an error - if (gAgent.getRegion() == NULL) - { - LL_WARNS() << "Region not set, cannot request cof_version increment" << LL_ENDL; - return; - } - - std::string url = gAgent.getRegion()->getCapability("IncrementCofVersion"); - if (url.empty()) - { - LL_WARNS() << "No cap for IncrementCofVersion." << LL_ENDL; - return; - } - - LL_INFOS() << "Requesting cof_version be incremented via capability to: " - << url << LL_ENDL; - LLSD headers; - LLSD body = LLSD::emptyMap(); - - if (!responder_ptr.get()) - { - responder_ptr = LLHTTPClient::ResponderPtr(new LLIncrementCofVersionResponder()); - } - - LLHTTPClient::get(url, body, responder_ptr, headers, 30.0f); -} - -U32 LLAppearanceMgr::getNumAttachmentsInCOF() -{ - const LLUUID cof = getCOF(); - LLInventoryModel::item_array_t obj_items; - getDescendentsOfAssetType(cof, obj_items, LLAssetType::AT_OBJECT); - return obj_items.size(); -} - - -std::string LLAppearanceMgr::getAppearanceServiceURL() const -{ - if (gSavedSettings.getString("DebugAvatarAppearanceServiceURLOverride").empty()) - { - return mAppearanceServiceURL; - } - return gSavedSettings.getString("DebugAvatarAppearanceServiceURLOverride"); -} - -void show_created_outfit(LLUUID& folder_id, bool show_panel = true) -{ - if (!LLApp::isRunning()) - { - LL_WARNS() << "called during shutdown, skipping" << LL_ENDL; - return; - } - - LL_DEBUGS("Avatar") << "called" << LL_ENDL; - LLSD key; - - //EXT-7727. For new accounts inventory callback is created during login process - // and may be processed after login process is finished - if (show_panel) - { - LL_DEBUGS("Avatar") << "showing panel" << LL_ENDL; - LLFloaterSidePanelContainer::showPanel("appearance", "panel_outfits_inventory", key); - - } - LLOutfitsList *outfits_list = - dynamic_cast(LLFloaterSidePanelContainer::getPanel("appearance", "outfitslist_tab")); - if (outfits_list) - { - outfits_list->setSelectedOutfitByUUID(folder_id); - } - - LLAppearanceMgr::getInstance()->updateIsDirty(); - gAgentWearables.notifyLoadingFinished(); // New outfit is saved. - LLAppearanceMgr::getInstance()->updatePanelOutfitName(""); - - // For SSB, need to update appearance after we add a base outfit - // link, since, the COF version has changed. There is a race - // condition in initial outfit setup which can lead to rez - // failures - SH-3860. - LL_DEBUGS("Avatar") << "requesting appearance update after createBaseOutfitLink" << LL_ENDL; - LLPointer cb = new LLUpdateAppearanceOnDestroy; - LLAppearanceMgr::getInstance()->createBaseOutfitLink(folder_id, cb); -} - -void LLAppearanceMgr::onOutfitFolderCreated(const LLUUID& folder_id, bool show_panel) -{ - LLPointer cb = - new LLBoostFuncInventoryCallback(no_op_inventory_func, - boost::bind(&LLAppearanceMgr::onOutfitFolderCreatedAndClothingOrdered,this,folder_id,show_panel)); - updateClothingOrderingInfo(LLUUID::null, cb); -} - -void LLAppearanceMgr::onOutfitFolderCreatedAndClothingOrdered(const LLUUID& folder_id, bool show_panel) -{ - LLPointer cb = - new LLBoostFuncInventoryCallback(no_op_inventory_func, - boost::bind(show_created_outfit,folder_id,show_panel)); - bool copy_folder_links = false; - slamCategoryLinks(getCOF(), folder_id, copy_folder_links, cb); -} - -void LLAppearanceMgr::makeNewOutfitLinks(const std::string& new_folder_name, bool show_panel) -{ - if (!isAgentAvatarValid()) return; - - LL_DEBUGS("Avatar") << "creating new outfit" << LL_ENDL; - - gAgentWearables.notifyLoadingStarted(); - - // First, make a folder in the My Outfits directory. - const LLUUID parent_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_MY_OUTFITS); - if (AISCommand::isAPIAvailable()) - { - // cap-based category creation was buggy until recently. use - // existence of AIS as an indicator the fix is present. Does - // not actually use AIS to create the category. - inventory_func_type func = boost::bind(&LLAppearanceMgr::onOutfitFolderCreated,this,_1,show_panel); - LLUUID folder_id = gInventory.createNewCategory( - parent_id, - LLFolderType::FT_OUTFIT, - new_folder_name, - func); - } - else - { - LLUUID folder_id = gInventory.createNewCategory( - parent_id, - LLFolderType::FT_OUTFIT, - new_folder_name); - onOutfitFolderCreated(folder_id, show_panel); - } -} - -void LLAppearanceMgr::wearBaseOutfit() -{ - const LLUUID& base_outfit_id = getBaseOutfitUUID(); - if (base_outfit_id.isNull()) return; - - updateCOF(base_outfit_id); -} - -void LLAppearanceMgr::removeItemsFromAvatar(const uuid_vec_t& ids_to_remove) -{ - if (ids_to_remove.empty()) - { - LL_WARNS() << "called with empty list, nothing to do" << LL_ENDL; - return; - } - LLPointer cb = new LLUpdateAppearanceOnDestroy; - for (uuid_vec_t::const_iterator it = ids_to_remove.begin(); it != ids_to_remove.end(); ++it) - { - const LLUUID& id_to_remove = *it; - const LLUUID& linked_item_id = gInventory.getLinkedItemID(id_to_remove); - removeCOFItemLinks(linked_item_id, cb); - addDoomedTempAttachment(linked_item_id); - } -} - -void LLAppearanceMgr::removeItemFromAvatar(const LLUUID& id_to_remove) -{ - LLUUID linked_item_id = gInventory.getLinkedItemID(id_to_remove); - LLPointer cb = new LLUpdateAppearanceOnDestroy; - removeCOFItemLinks(linked_item_id, cb); - addDoomedTempAttachment(linked_item_id); -} - - -// Adds the given item ID to mDoomedTempAttachmentIDs iff it's a temp attachment -void LLAppearanceMgr::addDoomedTempAttachment(const LLUUID& id_to_remove) -{ - LLViewerObject * attachmentp = gAgentAvatarp->findAttachmentByID(id_to_remove); - if (attachmentp && - attachmentp->isTempAttachment()) - { // If this is a temp attachment and we want to remove it, record the ID - // so it will be deleted when attachments are synced up with COF - mDoomedTempAttachmentIDs.insert(id_to_remove); - //LL_INFOS() << "Will remove temp attachment id " << id_to_remove << LL_ENDL; - } -} - -// Find AND REMOVES the given UUID from mDoomedTempAttachmentIDs -bool LLAppearanceMgr::shouldRemoveTempAttachment(const LLUUID& item_id) -{ - doomed_temp_attachments_t::iterator iter = mDoomedTempAttachmentIDs.find(item_id); - if (iter != mDoomedTempAttachmentIDs.end()) - { - mDoomedTempAttachmentIDs.erase(iter); +/** + * @file llappearancemgr.cpp + * @brief Manager for initiating appearance changes on the viewer + * + * $LicenseInfo:firstyear=2004&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include +#include "llaccordionctrltab.h" +#include "llagent.h" +#include "llagentcamera.h" +#include "llagentwearables.h" +#include "llappearancemgr.h" +#include "llattachmentsmgr.h" +#include "llcommandhandler.h" +#include "lleventtimer.h" +#include "llfloatersidepanelcontainer.h" +#include "llgesturemgr.h" +#include "llinventorybridge.h" +#include "llinventoryfunctions.h" +#include "llinventoryobserver.h" +#include "llnotificationsutil.h" +#include "lloutfitobserver.h" +#include "lloutfitslist.h" +#include "llselectmgr.h" +#include "llsidepanelappearance.h" +#include "llviewerobjectlist.h" +#include "llvoavatar.h" +#include "llvoavatarself.h" +#include "llviewerregion.h" +#include "llwearablelist.h" +#include "llsdutil.h" +#include "llsdserialize.h" +#include "llhttpretrypolicy.h" +#include "llaisapi.h" +#include "llhttpsdhandler.h" +#include "llcorehttputil.h" +#include "llappviewer.h" + +#if LL_MSVC +// disable boost::lexical_cast warning +#pragma warning (disable:4702) +#endif + +std::string self_av_string() +{ + // On logout gAgentAvatarp can already be invalid + return isAgentAvatarValid() ? gAgentAvatarp->avString() : ""; +} + +// RAII thingy to guarantee that a variable gets reset when the Setter +// goes out of scope. More general utility would be handy - TODO: +// check boost. +class BoolSetter +{ +public: + BoolSetter(bool& var): + mVar(var) + { + mVar = true; + } + ~BoolSetter() + { + mVar = false; + } +private: + bool& mVar; +}; + +char ORDER_NUMBER_SEPARATOR('@'); + +class LLOutfitUnLockTimer: public LLEventTimer +{ +public: + LLOutfitUnLockTimer(F32 period) : LLEventTimer(period) + { + // restart timer on BOF changed event + LLOutfitObserver::instance().addBOFChangedCallback(boost::bind( + &LLOutfitUnLockTimer::reset, this)); + stop(); + } + + /*virtual*/ + BOOL tick() + { + if(mEventTimer.hasExpired()) + { + LLAppearanceMgr::instance().setOutfitLocked(false); + } + return FALSE; + } + void stop() { mEventTimer.stop(); } + void start() { mEventTimer.start(); } + void reset() { mEventTimer.reset(); } + BOOL getStarted() { return mEventTimer.getStarted(); } + + LLTimer& getEventTimer() { return mEventTimer;} +}; + +// support for secondlife:///app/appearance SLapps +class LLAppearanceHandler : public LLCommandHandler +{ +public: + // requests will be throttled from a non-trusted browser + LLAppearanceHandler() : LLCommandHandler("appearance", UNTRUSTED_THROTTLE) {} + + bool handle(const LLSD& params, const LLSD& query_map, LLMediaCtrl* web) + { + // support secondlife:///app/appearance/show, but for now we just + // make all secondlife:///app/appearance SLapps behave this way + if (!LLUI::sSettingGroups["config"]->getBOOL("EnableAppearance")) + { + LLNotificationsUtil::add("NoAppearance", LLSD(), LLSD(), std::string("SwitchToStandardSkinAndQuit")); + return true; + } + + LLFloaterSidePanelContainer::showPanel("appearance", LLSD()); + return true; + } +}; + +LLAppearanceHandler gAppearanceHandler; + + +LLUUID findDescendentCategoryIDByName(const LLUUID& parent_id, const std::string& name) +{ + LLInventoryModel::cat_array_t cat_array; + LLInventoryModel::item_array_t item_array; + LLNameCategoryCollector has_name(name); + gInventory.collectDescendentsIf(parent_id, + cat_array, + item_array, + LLInventoryModel::EXCLUDE_TRASH, + has_name); + if (0 == cat_array.size()) + return LLUUID(); + else + { + LLViewerInventoryCategory *cat = cat_array.at(0); + if (cat) + return cat->getUUID(); + else + { + LL_WARNS() << "null cat" << LL_ENDL; + return LLUUID(); + } + } +} + +// We want this to be much lower (e.g. 15.0 is usually fine), bumping +// up for now until we can diagnose some cases of very slow response +// to requests. +const F32 DEFAULT_RETRY_AFTER_INTERVAL = 300.0; + +// Given the current back-end problems, retrying is causing too many +// duplicate items. Bump this back to 2 once they are resolved (or can +// leave at 0 if the operations become actually reliable). +const S32 DEFAULT_MAX_RETRIES = 0; + +class LLCallAfterInventoryBatchMgr: public LLEventTimer +{ +public: + LLCallAfterInventoryBatchMgr(const LLUUID& dst_cat_id, + const std::string& phase_name, + nullary_func_t on_completion_func, + nullary_func_t on_failure_func = no_op, + F32 retry_after = DEFAULT_RETRY_AFTER_INTERVAL, + S32 max_retries = DEFAULT_MAX_RETRIES + ): + mDstCatID(dst_cat_id), + mTrackingPhase(phase_name), + mOnCompletionFunc(on_completion_func), + mOnFailureFunc(on_failure_func), + mRetryAfter(retry_after), + mMaxRetries(max_retries), + mPendingRequests(0), + mFailCount(0), + mCompletionOrFailureCalled(false), + mRetryCount(0), + LLEventTimer(5.0) + { + if (!mTrackingPhase.empty()) + { + selfStartPhase(mTrackingPhase); + } + } + + void addItems(LLInventoryModel::item_array_t& src_items) + { + for (LLInventoryModel::item_array_t::const_iterator it = src_items.begin(); + it != src_items.end(); + ++it) + { + LLViewerInventoryItem* item = *it; + llassert(item); + addItem(item->getUUID()); + } + } + + // Request or re-request operation for specified item. + void addItem(const LLUUID& item_id) + { + LL_DEBUGS("Avatar") << "item_id " << item_id << LL_ENDL; + if (!requestOperation(item_id)) + { + LL_DEBUGS("Avatar") << "item_id " << item_id << " requestOperation false, skipping" << LL_ENDL; + return; + } + + mPendingRequests++; + // On a re-request, this will reset the timer. + mWaitTimes[item_id] = LLTimer(); + if (mRetryCounts.find(item_id) == mRetryCounts.end()) + { + mRetryCounts[item_id] = 0; + } + else + { + mRetryCounts[item_id]++; + } + } + + virtual bool requestOperation(const LLUUID& item_id) = 0; + + void onOp(const LLUUID& src_id, const LLUUID& dst_id, LLTimer timestamp) + { + if (ll_frand() < gSavedSettings.getF32("InventoryDebugSimulateLateOpRate")) + { + LL_WARNS() << "Simulating late operation by punting handling to later" << LL_ENDL; + doAfterInterval(boost::bind(&LLCallAfterInventoryBatchMgr::onOp,this,src_id,dst_id,timestamp), + mRetryAfter); + return; + } + mPendingRequests--; + F32 elapsed = timestamp.getElapsedTimeF32(); + LL_DEBUGS("Avatar") << "op done, src_id " << src_id << " dst_id " << dst_id << " after " << elapsed << " seconds" << LL_ENDL; + if (mWaitTimes.find(src_id) == mWaitTimes.end()) + { + // No longer waiting for this item - either serviced + // already or gave up after too many retries. + LL_WARNS() << "duplicate or late operation, src_id " << src_id << "dst_id " << dst_id + << " elapsed " << elapsed << " after end " << (S32) mCompletionOrFailureCalled << LL_ENDL; + } + mTimeStats.push(elapsed); + mWaitTimes.erase(src_id); + if (mWaitTimes.empty() && !mCompletionOrFailureCalled) + { + onCompletionOrFailure(); + } + } + + void onCompletionOrFailure() + { + assert (!mCompletionOrFailureCalled); + mCompletionOrFailureCalled = true; + + // Will never call onCompletion() if any item has been flagged as + // a failure - otherwise could wind up with corrupted + // outfit, involuntary nudity, etc. + reportStats(); + if (!mTrackingPhase.empty()) + { + selfStopPhase(mTrackingPhase); + } + if (!mFailCount) + { + onCompletion(); + } + else + { + onFailure(); + } + } + + void onFailure() + { + LL_INFOS() << "failed" << LL_ENDL; + mOnFailureFunc(); + } + + void onCompletion() + { + LL_INFOS() << "done" << LL_ENDL; + mOnCompletionFunc(); + } + + // virtual + // Will be deleted after returning true - only safe to do this if all callbacks have fired. + BOOL tick() + { + // mPendingRequests will be zero if all requests have been + // responded to. mWaitTimes.empty() will be true if we have + // received at least one reply for each UUID. If requests + // have been dropped and retried, these will not necessarily + // be the same. Only safe to return true if all requests have + // been serviced, since it will result in this object being + // deleted. + bool all_done = (mPendingRequests==0); + + if (!mWaitTimes.empty()) + { + LL_WARNS() << "still waiting on " << mWaitTimes.size() << " items" << LL_ENDL; + for (std::map::iterator it = mWaitTimes.begin(); + it != mWaitTimes.end();) + { + // Use a copy of iterator because it may be erased/invalidated. + std::map::iterator curr_it = it; + ++it; + + F32 time_waited = curr_it->second.getElapsedTimeF32(); + S32 retries = mRetryCounts[curr_it->first]; + if (time_waited > mRetryAfter) + { + if (retries < mMaxRetries) + { + LL_DEBUGS("Avatar") << "Waited " << time_waited << + " for " << curr_it->first << ", retrying" << LL_ENDL; + mRetryCount++; + addItem(curr_it->first); + } + else + { + LL_WARNS() << "Giving up on " << curr_it->first << " after too many retries" << LL_ENDL; + mWaitTimes.erase(curr_it); + mFailCount++; + } + } + if (mWaitTimes.empty()) + { + onCompletionOrFailure(); + } + + } + } + return all_done; + } + + void reportStats() + { + LL_DEBUGS("Avatar") << "Phase: " << mTrackingPhase << LL_ENDL; + LL_DEBUGS("Avatar") << "mFailCount: " << mFailCount << LL_ENDL; + LL_DEBUGS("Avatar") << "mRetryCount: " << mRetryCount << LL_ENDL; + LL_DEBUGS("Avatar") << "Times: n " << mTimeStats.getCount() << " min " << mTimeStats.getMinValue() << " max " << mTimeStats.getMaxValue() << LL_ENDL; + LL_DEBUGS("Avatar") << "Mean " << mTimeStats.getMean() << " stddev " << mTimeStats.getStdDev() << LL_ENDL; + } + + virtual ~LLCallAfterInventoryBatchMgr() + { + LL_DEBUGS("Avatar") << "deleting" << LL_ENDL; + } + +protected: + std::string mTrackingPhase; + std::map mWaitTimes; + std::map mRetryCounts; + LLUUID mDstCatID; + nullary_func_t mOnCompletionFunc; + nullary_func_t mOnFailureFunc; + F32 mRetryAfter; + S32 mMaxRetries; + S32 mPendingRequests; + S32 mFailCount; + S32 mRetryCount; + bool mCompletionOrFailureCalled; + LLViewerStats::StatsAccumulator mTimeStats; +}; + +class LLCallAfterInventoryCopyMgr: public LLCallAfterInventoryBatchMgr +{ +public: + LLCallAfterInventoryCopyMgr(LLInventoryModel::item_array_t& src_items, + const LLUUID& dst_cat_id, + const std::string& phase_name, + nullary_func_t on_completion_func, + nullary_func_t on_failure_func = no_op, + F32 retry_after = DEFAULT_RETRY_AFTER_INTERVAL, + S32 max_retries = DEFAULT_MAX_RETRIES + ): + LLCallAfterInventoryBatchMgr(dst_cat_id, phase_name, on_completion_func, on_failure_func, retry_after, max_retries) + { + addItems(src_items); + sInstanceCount++; + } + + ~LLCallAfterInventoryCopyMgr() + { + sInstanceCount--; + } + + virtual bool requestOperation(const LLUUID& item_id) + { + LLViewerInventoryItem *item = gInventory.getItem(item_id); + llassert(item); + LL_DEBUGS("Avatar") << "copying item " << item_id << LL_ENDL; + if (ll_frand() < gSavedSettings.getF32("InventoryDebugSimulateOpFailureRate")) + { + LL_DEBUGS("Avatar") << "simulating failure by not sending request for item " << item_id << LL_ENDL; + return true; + } + copy_inventory_item( + gAgent.getID(), + item->getPermissions().getOwner(), + item->getUUID(), + mDstCatID, + std::string(), + new LLBoostFuncInventoryCallback(boost::bind(&LLCallAfterInventoryBatchMgr::onOp,this,item_id,_1,LLTimer())) + ); + return true; + } + + static S32 getInstanceCount() { return sInstanceCount; } + +private: + static S32 sInstanceCount; +}; + +S32 LLCallAfterInventoryCopyMgr::sInstanceCount = 0; + +class LLWearCategoryAfterCopy: public LLInventoryCallback +{ +public: + LLWearCategoryAfterCopy(bool append): + mAppend(append) + {} + + // virtual + void fire(const LLUUID& id) + { + // Wear the inventory category. + LLInventoryCategory* cat = gInventory.getCategory(id); + LLAppearanceMgr::instance().wearInventoryCategoryOnAvatar(cat, mAppend); + } + +private: + bool mAppend; +}; + +class LLTrackPhaseWrapper : public LLInventoryCallback +{ +public: + LLTrackPhaseWrapper(const std::string& phase_name, LLPointer cb = NULL): + mTrackingPhase(phase_name), + mCB(cb) + { + selfStartPhase(mTrackingPhase); + } + + // virtual + void fire(const LLUUID& id) + { + if (mCB) + { + mCB->fire(id); + } + } + + // virtual + ~LLTrackPhaseWrapper() + { + selfStopPhase(mTrackingPhase); + } + +protected: + std::string mTrackingPhase; + LLPointer mCB; +}; + +LLUpdateAppearanceOnDestroy::LLUpdateAppearanceOnDestroy(bool enforce_item_restrictions, + bool enforce_ordering, + nullary_func_t post_update_func + ): + mFireCount(0), + mEnforceItemRestrictions(enforce_item_restrictions), + mEnforceOrdering(enforce_ordering), + mPostUpdateFunc(post_update_func) +{ + selfStartPhase("update_appearance_on_destroy"); +} + +void LLUpdateAppearanceOnDestroy::fire(const LLUUID& inv_item) +{ + LLViewerInventoryItem* item = (LLViewerInventoryItem*)gInventory.getItem(inv_item); + const std::string item_name = item ? item->getName() : "ITEM NOT FOUND"; +#ifndef LL_RELEASE_FOR_DOWNLOAD + LL_DEBUGS("Avatar") << self_av_string() << "callback fired [ name:" << item_name << " UUID:" << inv_item << " count:" << mFireCount << " ] " << LL_ENDL; +#endif + mFireCount++; +} + +LLUpdateAppearanceOnDestroy::~LLUpdateAppearanceOnDestroy() +{ + if (!LLApp::isExiting()) + { + // speculative fix for MAINT-1150 + LL_INFOS("Avatar") << self_av_string() << "done update appearance on destroy" << LL_ENDL; + + selfStopPhase("update_appearance_on_destroy"); + + LLAppearanceMgr::instance().updateAppearanceFromCOF(mEnforceItemRestrictions, + mEnforceOrdering, + mPostUpdateFunc); + } +} + +LLUpdateAppearanceAndEditWearableOnDestroy::LLUpdateAppearanceAndEditWearableOnDestroy(const LLUUID& item_id): + mItemID(item_id) +{ +} + +void edit_wearable_and_customize_avatar(LLUUID item_id) +{ + // Start editing the item if previously requested. + gAgentWearables.editWearableIfRequested(item_id); + + // TODO: camera mode may not be changed if a debug setting is tweaked + if( gAgentCamera.cameraCustomizeAvatar() ) + { + // If we're in appearance editing mode, the current tab may need to be refreshed + LLSidepanelAppearance *panel = dynamic_cast( + LLFloaterSidePanelContainer::getPanel("appearance")); + if (panel) + { + panel->showDefaultSubpart(); + } + } +} + +LLUpdateAppearanceAndEditWearableOnDestroy::~LLUpdateAppearanceAndEditWearableOnDestroy() +{ + if (!LLApp::isExiting()) + { + LLAppearanceMgr::instance().updateAppearanceFromCOF( + true,true, + boost::bind(edit_wearable_and_customize_avatar, mItemID)); + } +} + + +struct LLFoundData +{ + LLFoundData() : + mAssetType(LLAssetType::AT_NONE), + mWearableType(LLWearableType::WT_INVALID), + mWearable(NULL) {} + + LLFoundData(const LLUUID& item_id, + const LLUUID& asset_id, + const std::string& name, + const LLAssetType::EType& asset_type, + const LLWearableType::EType& wearable_type, + const bool is_replacement = false + ) : + mItemID(item_id), + mAssetID(asset_id), + mName(name), + mAssetType(asset_type), + mWearableType(wearable_type), + mIsReplacement(is_replacement), + mWearable( NULL ) {} + + LLUUID mItemID; + LLUUID mAssetID; + std::string mName; + LLAssetType::EType mAssetType; + LLWearableType::EType mWearableType; + LLViewerWearable* mWearable; + bool mIsReplacement; +}; + + +class LLWearableHoldingPattern +{ + LOG_CLASS(LLWearableHoldingPattern); + +public: + LLWearableHoldingPattern(); + ~LLWearableHoldingPattern(); + + bool pollFetchCompletion(); + void onFetchCompletion(); + bool isFetchCompleted(); + bool isTimedOut(); + + void checkMissingWearables(); + bool pollMissingWearables(); + bool isMissingCompleted(); + void recoverMissingWearable(LLWearableType::EType type); + void clearCOFLinksForMissingWearables(); + + void onWearableAssetFetch(LLViewerWearable *wearable); + void onAllComplete(); + + typedef std::list found_list_t; + found_list_t& getFoundList(); + void eraseTypeToLink(LLWearableType::EType type); + void eraseTypeToRecover(LLWearableType::EType type); + void setObjItems(const LLInventoryModel::item_array_t& items); + void setGestItems(const LLInventoryModel::item_array_t& items); + bool isMostRecent(); + void handleLateArrivals(); + void resetTime(F32 timeout); + static S32 countActive() { return sActiveHoldingPatterns.size(); } + S32 index() { return mIndex; } + +private: + found_list_t mFoundList; + LLInventoryModel::item_array_t mObjItems; + LLInventoryModel::item_array_t mGestItems; + typedef std::set type_set_t; + type_set_t mTypesToRecover; + type_set_t mTypesToLink; + S32 mResolved; + LLTimer mWaitTime; + bool mFired; + typedef std::set type_set_hp; + static type_set_hp sActiveHoldingPatterns; + static S32 sNextIndex; + S32 mIndex; + bool mIsMostRecent; + std::set mLateArrivals; + bool mIsAllComplete; +}; + +LLWearableHoldingPattern::type_set_hp LLWearableHoldingPattern::sActiveHoldingPatterns; +S32 LLWearableHoldingPattern::sNextIndex = 0; + +LLWearableHoldingPattern::LLWearableHoldingPattern(): + mResolved(0), + mFired(false), + mIsMostRecent(true), + mIsAllComplete(false) +{ + if (countActive()>0) + { + LL_INFOS() << "Creating LLWearableHoldingPattern when " + << countActive() + << " other attempts are active." + << " Flagging others as invalid." + << LL_ENDL; + for (type_set_hp::iterator it = sActiveHoldingPatterns.begin(); + it != sActiveHoldingPatterns.end(); + ++it) + { + (*it)->mIsMostRecent = false; + } + + } + mIndex = sNextIndex++; + sActiveHoldingPatterns.insert(this); + LL_DEBUGS("Avatar") << "HP " << index() << " created" << LL_ENDL; + selfStartPhase("holding_pattern"); +} + +LLWearableHoldingPattern::~LLWearableHoldingPattern() +{ + sActiveHoldingPatterns.erase(this); + if (isMostRecent()) + { + selfStopPhase("holding_pattern"); + } + LL_DEBUGS("Avatar") << "HP " << index() << " deleted" << LL_ENDL; +} + +bool LLWearableHoldingPattern::isMostRecent() +{ + return mIsMostRecent; +} + +LLWearableHoldingPattern::found_list_t& LLWearableHoldingPattern::getFoundList() +{ + return mFoundList; +} + +void LLWearableHoldingPattern::eraseTypeToLink(LLWearableType::EType type) +{ + mTypesToLink.erase(type); +} + +void LLWearableHoldingPattern::eraseTypeToRecover(LLWearableType::EType type) +{ + mTypesToRecover.erase(type); +} + +void LLWearableHoldingPattern::setObjItems(const LLInventoryModel::item_array_t& items) +{ + mObjItems = items; +} + +void LLWearableHoldingPattern::setGestItems(const LLInventoryModel::item_array_t& items) +{ + mGestItems = items; +} + +bool LLWearableHoldingPattern::isFetchCompleted() +{ + return (mResolved >= (S32)getFoundList().size()); // have everything we were waiting for? +} + +bool LLWearableHoldingPattern::isTimedOut() +{ + return mWaitTime.hasExpired(); +} + +void LLWearableHoldingPattern::checkMissingWearables() +{ + if (!isMostRecent()) + { + // runway why don't we actually skip here? + LL_WARNS() << self_av_string() << "skipping because LLWearableHolding pattern is invalid (superceded by later outfit request)" << LL_ENDL; + } + + std::vector found_by_type(LLWearableType::WT_COUNT,0); + std::vector requested_by_type(LLWearableType::WT_COUNT,0); + for (found_list_t::iterator it = getFoundList().begin(); it != getFoundList().end(); ++it) + { + LLFoundData &data = *it; + if (data.mWearableType < LLWearableType::WT_COUNT) + requested_by_type[data.mWearableType]++; + if (data.mWearable) + found_by_type[data.mWearableType]++; + } + + for (S32 type = 0; type < LLWearableType::WT_COUNT; ++type) + { + if (requested_by_type[type] > found_by_type[type]) + { + LL_WARNS() << self_av_string() << "got fewer wearables than requested, type " << type << ": requested " << requested_by_type[type] << ", found " << found_by_type[type] << LL_ENDL; + } + if (found_by_type[type] > 0) + continue; + if ( + // If at least one wearable of certain types (pants/shirt/skirt) + // was requested but none was found, create a default asset as a replacement. + // In all other cases, don't do anything. + // For critical types (shape/hair/skin/eyes), this will keep the avatar as a cloud + // due to logic in LLVOAvatarSelf::getIsCloud(). + // For non-critical types (tatoo, socks, etc.) the wearable will just be missing. + (requested_by_type[type] > 0) && + ((type == LLWearableType::WT_PANTS) || (type == LLWearableType::WT_SHIRT) || (type == LLWearableType::WT_SKIRT))) + { + mTypesToRecover.insert(type); + mTypesToLink.insert(type); + recoverMissingWearable((LLWearableType::EType)type); + LL_WARNS() << self_av_string() << "need to replace " << type << LL_ENDL; + } + } + + resetTime(60.0F); + + if (isMostRecent()) + { + selfStartPhase("get_missing_wearables_2"); + } + if (!pollMissingWearables()) + { + doOnIdleRepeating(boost::bind(&LLWearableHoldingPattern::pollMissingWearables,this)); + } +} + +void LLWearableHoldingPattern::onAllComplete() +{ + if (isAgentAvatarValid()) + { + gAgentAvatarp->outputRezTiming("Agent wearables fetch complete"); + } + + if (!isMostRecent()) + { + // runway need to skip here? + LL_WARNS() << self_av_string() << "skipping because LLWearableHolding pattern is invalid (superceded by later outfit request)" << LL_ENDL; + } + + // Activate all gestures in this folder + if (mGestItems.size() > 0) + { + LL_DEBUGS("Avatar") << self_av_string() << "Activating " << mGestItems.size() << " gestures" << LL_ENDL; + + LLGestureMgr::instance().activateGestures(mGestItems); + + // Update the inventory item labels to reflect the fact + // they are active. + LLViewerInventoryCategory* catp = + gInventory.getCategory(LLAppearanceMgr::instance().getCOF()); + + if (catp) + { + gInventory.updateCategory(catp); + gInventory.notifyObservers(); + } + } + + if (isAgentAvatarValid()) + { + LL_DEBUGS("Avatar") << self_av_string() << "Updating " << mObjItems.size() << " attachments" << LL_ENDL; + LLAgentWearables::llvo_vec_t objects_to_remove; + LLAgentWearables::llvo_vec_t objects_to_retain; + LLInventoryModel::item_array_t items_to_add; + + LLAgentWearables::findAttachmentsAddRemoveInfo(mObjItems, + objects_to_remove, + objects_to_retain, + items_to_add); + + LL_DEBUGS("Avatar") << self_av_string() << "Removing " << objects_to_remove.size() + << " attachments" << LL_ENDL; + + // Here we remove the attachment pos overrides for *all* + // attachments, even those that are not being removed. This is + // needed to get joint positions all slammed down to their + // pre-attachment states. + gAgentAvatarp->clearAttachmentPosOverrides(); + + // Take off the attachments that will no longer be in the outfit. + LLAgentWearables::userRemoveMultipleAttachments(objects_to_remove); + + // Update wearables. + LL_INFOS("Avatar") << self_av_string() << "HP " << index() << " updating agent wearables with " + << mResolved << " wearable items " << LL_ENDL; + LLAppearanceMgr::instance().updateAgentWearables(this); + + // Restore attachment pos overrides for the attachments that + // are remaining in the outfit. + for (LLAgentWearables::llvo_vec_t::iterator it = objects_to_retain.begin(); + it != objects_to_retain.end(); + ++it) + { + LLViewerObject *objectp = *it; + gAgentAvatarp->addAttachmentPosOverridesForObject(objectp); + } + + // Add new attachments to match those requested. + LL_DEBUGS("Avatar") << self_av_string() << "Adding " << items_to_add.size() << " attachments" << LL_ENDL; + LLAgentWearables::userAttachMultipleAttachments(items_to_add); + } + + if (isFetchCompleted() && isMissingCompleted()) + { + // Only safe to delete if all wearable callbacks and all missing wearables completed. + delete this; + } + else + { + mIsAllComplete = true; + handleLateArrivals(); + } +} + +void LLWearableHoldingPattern::onFetchCompletion() +{ + if (isMostRecent()) + { + selfStopPhase("get_wearables_2"); + } + + if (!isMostRecent()) + { + // runway skip here? + LL_WARNS() << self_av_string() << "skipping because LLWearableHolding pattern is invalid (superceded by later outfit request)" << LL_ENDL; + } + + checkMissingWearables(); +} + +// Runs as an idle callback until all wearables are fetched (or we time out). +bool LLWearableHoldingPattern::pollFetchCompletion() +{ + if (!isMostRecent()) + { + // runway skip here? + LL_WARNS() << self_av_string() << "skipping because LLWearableHolding pattern is invalid (superceded by later outfit request)" << LL_ENDL; + } + + bool completed = isFetchCompleted(); + bool timed_out = isTimedOut(); + bool done = completed || timed_out; + + if (done) + { + LL_INFOS("Avatar") << self_av_string() << "HP " << index() << " polling, done status: " << completed << " timed out " << timed_out + << " elapsed " << mWaitTime.getElapsedTimeF32() << LL_ENDL; + + mFired = true; + + if (timed_out) + { + LL_WARNS() << self_av_string() << "Exceeded max wait time for wearables, updating appearance based on what has arrived" << LL_ENDL; + } + + onFetchCompletion(); + } + return done; +} + +void recovered_item_link_cb(const LLUUID& item_id, LLWearableType::EType type, LLViewerWearable *wearable, LLWearableHoldingPattern* holder) +{ + if (!holder->isMostRecent()) + { + LL_WARNS() << "HP " << holder->index() << " skipping because LLWearableHolding pattern is invalid (superceded by later outfit request)" << LL_ENDL; + // runway skip here? + } + + LL_INFOS() << "HP " << holder->index() << " recovered item link for type " << type << LL_ENDL; + holder->eraseTypeToLink(type); + // Add wearable to FoundData for actual wearing + LLViewerInventoryItem *item = gInventory.getItem(item_id); + LLViewerInventoryItem *linked_item = item ? item->getLinkedItem() : NULL; + + if (linked_item) + { + gInventory.addChangedMask(LLInventoryObserver::LABEL, linked_item->getUUID()); + + if (item) + { + LLFoundData found(linked_item->getUUID(), + linked_item->getAssetUUID(), + linked_item->getName(), + linked_item->getType(), + linked_item->isWearableType() ? linked_item->getWearableType() : LLWearableType::WT_INVALID, + true // is replacement + ); + found.mWearable = wearable; + holder->getFoundList().push_front(found); + } + else + { + LL_WARNS() << self_av_string() << "inventory link not found for recovered wearable" << LL_ENDL; + } + } + else + { + LL_WARNS() << self_av_string() << "HP " << holder->index() << " inventory link not found for recovered wearable" << LL_ENDL; + } +} + +void recovered_item_cb(const LLUUID& item_id, LLWearableType::EType type, LLViewerWearable *wearable, LLWearableHoldingPattern* holder) +{ + if (!holder->isMostRecent()) + { + // runway skip here? + LL_WARNS() << self_av_string() << "skipping because LLWearableHolding pattern is invalid (superceded by later outfit request)" << LL_ENDL; + } + + LL_DEBUGS("Avatar") << self_av_string() << "Recovered item for type " << type << LL_ENDL; + LLConstPointer itemp = gInventory.getItem(item_id); + wearable->setItemID(item_id); + holder->eraseTypeToRecover(type); + llassert(itemp); + if (itemp) + { + LLPointer cb = new LLBoostFuncInventoryCallback(boost::bind(recovered_item_link_cb,_1,type,wearable,holder)); + + link_inventory_object(LLAppearanceMgr::instance().getCOF(), itemp, cb); + } +} + +void LLWearableHoldingPattern::recoverMissingWearable(LLWearableType::EType type) +{ + if (!isMostRecent()) + { + // runway skip here? + LL_WARNS() << self_av_string() << "skipping because LLWearableHolding pattern is invalid (superceded by later outfit request)" << LL_ENDL; + } + + // Try to recover by replacing missing wearable with a new one. + LLNotificationsUtil::add("ReplacedMissingWearable"); + LL_DEBUGS() << "Wearable " << LLWearableType::getTypeLabel(type) + << " could not be downloaded. Replaced inventory item with default wearable." << LL_ENDL; + LLViewerWearable* wearable = LLWearableList::instance().createNewWearable(type, gAgentAvatarp); + + // Add a new one in the lost and found folder. + const LLUUID lost_and_found_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_LOST_AND_FOUND); + LLPointer cb = new LLBoostFuncInventoryCallback(boost::bind(recovered_item_cb,_1,type,wearable,this)); + + create_inventory_item(gAgent.getID(), + gAgent.getSessionID(), + lost_and_found_id, + wearable->getTransactionID(), + wearable->getName(), + wearable->getDescription(), + wearable->getAssetType(), + LLInventoryType::IT_WEARABLE, + wearable->getType(), + wearable->getPermissions().getMaskNextOwner(), + cb); +} + +bool LLWearableHoldingPattern::isMissingCompleted() +{ + return mTypesToLink.size()==0 && mTypesToRecover.size()==0; +} + +void LLWearableHoldingPattern::clearCOFLinksForMissingWearables() +{ + for (found_list_t::iterator it = getFoundList().begin(); it != getFoundList().end(); ++it) + { + LLFoundData &data = *it; + if ((data.mWearableType < LLWearableType::WT_COUNT) && (!data.mWearable)) + { + // Wearable link that was never resolved; remove links to it from COF + LL_INFOS("Avatar") << self_av_string() << "HP " << index() << " removing link for unresolved item " << data.mItemID.asString() << LL_ENDL; + LLAppearanceMgr::instance().removeCOFItemLinks(data.mItemID); + } + } +} + +bool LLWearableHoldingPattern::pollMissingWearables() +{ + if (!isMostRecent()) + { + // runway skip here? + LL_WARNS() << self_av_string() << "skipping because LLWearableHolding pattern is invalid (superceded by later outfit request)" << LL_ENDL; + } + + bool timed_out = isTimedOut(); + bool missing_completed = isMissingCompleted(); + bool done = timed_out || missing_completed; + + if (!done) + { + LL_INFOS("Avatar") << self_av_string() << "HP " << index() << " polling missing wearables, waiting for items " << mTypesToRecover.size() + << " links " << mTypesToLink.size() + << " wearables, timed out " << timed_out + << " elapsed " << mWaitTime.getElapsedTimeF32() + << " done " << done << LL_ENDL; + } + + if (done) + { + if (isMostRecent()) + { + selfStopPhase("get_missing_wearables_2"); + } + + gAgentAvatarp->debugWearablesLoaded(); + + // BAP - if we don't call clearCOFLinksForMissingWearables() + // here, we won't have to add the link back in later if the + // wearable arrives late. This is to avoid corruption of + // wearable ordering info. Also has the effect of making + // unworn item links visible in the COF under some + // circumstances. + + //clearCOFLinksForMissingWearables(); + onAllComplete(); + } + return done; +} + +// Handle wearables that arrived after the timeout period expired. +void LLWearableHoldingPattern::handleLateArrivals() +{ + // Only safe to run if we have previously finished the missing + // wearables and other processing - otherwise we could be in some + // intermediate state - but have not been superceded by a later + // outfit change request. + if (mLateArrivals.size() == 0) + { + // Nothing to process. + return; + } + if (!isMostRecent()) + { + LL_WARNS() << self_av_string() << "Late arrivals not handled - outfit change no longer valid" << LL_ENDL; + } + if (!mIsAllComplete) + { + LL_WARNS() << self_av_string() << "Late arrivals not handled - in middle of missing wearables processing" << LL_ENDL; + } + + LL_INFOS("Avatar") << self_av_string() << "HP " << index() << " need to handle " << mLateArrivals.size() << " late arriving wearables" << LL_ENDL; + + // Update mFoundList using late-arriving wearables. + std::set replaced_types; + for (LLWearableHoldingPattern::found_list_t::iterator iter = getFoundList().begin(); + iter != getFoundList().end(); ++iter) + { + LLFoundData& data = *iter; + for (std::set::iterator wear_it = mLateArrivals.begin(); + wear_it != mLateArrivals.end(); + ++wear_it) + { + LLViewerWearable *wearable = *wear_it; + + if(wearable->getAssetID() == data.mAssetID) + { + data.mWearable = wearable; + + replaced_types.insert(data.mWearableType); + + // BAP - if we didn't call + // clearCOFLinksForMissingWearables() earlier, we + // don't need to restore the link here. Fixes + // wearable ordering problems. + + // LLAppearanceMgr::instance().addCOFItemLink(data.mItemID,false); + + // BAP failing this means inventory or asset server + // are corrupted in a way we don't handle. + llassert((data.mWearableType < LLWearableType::WT_COUNT) && (wearable->getType() == data.mWearableType)); + break; + } + } + } + + // Remove COF links for any default wearables previously used to replace the late arrivals. + // All this pussyfooting around with a while loop and explicit + // iterator incrementing is to allow removing items from the list + // without clobbering the iterator we're using to navigate. + LLWearableHoldingPattern::found_list_t::iterator iter = getFoundList().begin(); + while (iter != getFoundList().end()) + { + LLFoundData& data = *iter; + + // If an item of this type has recently shown up, removed the corresponding replacement wearable from COF. + if (data.mWearable && data.mIsReplacement && + replaced_types.find(data.mWearableType) != replaced_types.end()) + { + LLAppearanceMgr::instance().removeCOFItemLinks(data.mItemID); + std::list::iterator clobber_ator = iter; + ++iter; + getFoundList().erase(clobber_ator); + } + else + { + ++iter; + } + } + + // Clear contents of late arrivals. + mLateArrivals.clear(); + + // Update appearance based on mFoundList + LLAppearanceMgr::instance().updateAgentWearables(this); +} + +void LLWearableHoldingPattern::resetTime(F32 timeout) +{ + mWaitTime.reset(); + mWaitTime.setTimerExpirySec(timeout); +} + +void LLWearableHoldingPattern::onWearableAssetFetch(LLViewerWearable *wearable) +{ + if (!isMostRecent()) + { + LL_WARNS() << self_av_string() << "skipping because LLWearableHolding pattern is invalid (superceded by later outfit request)" << LL_ENDL; + } + + mResolved += 1; // just counting callbacks, not successes. + LL_DEBUGS("Avatar") << self_av_string() << "HP " << index() << " resolved " << mResolved << "/" << getFoundList().size() << LL_ENDL; + if (!wearable) + { + LL_WARNS() << self_av_string() << "no wearable found" << LL_ENDL; + } + + if (mFired) + { + LL_WARNS() << self_av_string() << "called after holder fired" << LL_ENDL; + if (wearable) + { + mLateArrivals.insert(wearable); + if (mIsAllComplete) + { + handleLateArrivals(); + } + } + return; + } + + if (!wearable) + { + return; + } + + for (LLWearableHoldingPattern::found_list_t::iterator iter = getFoundList().begin(); + iter != getFoundList().end(); ++iter) + { + LLFoundData& data = *iter; + if(wearable->getAssetID() == data.mAssetID) + { + // Failing this means inventory or asset server are corrupted in a way we don't handle. + if ((data.mWearableType >= LLWearableType::WT_COUNT) || (wearable->getType() != data.mWearableType)) + { + LL_WARNS() << self_av_string() << "recovered wearable but type invalid. inventory wearable type: " << data.mWearableType << " asset wearable type: " << wearable->getType() << LL_ENDL; + break; + } + + data.mWearable = wearable; + } + } +} + +static void onWearableAssetFetch(LLViewerWearable* wearable, void* data) +{ + LLWearableHoldingPattern* holder = (LLWearableHoldingPattern*)data; + holder->onWearableAssetFetch(wearable); +} + + +static void removeDuplicateItems(LLInventoryModel::item_array_t& items) +{ + LLInventoryModel::item_array_t new_items; + std::set items_seen; + std::deque tmp_list; + // Traverse from the front and keep the first of each item + // encountered, so we actually keep the *last* of each duplicate + // item. This is needed to give the right priority when adding + // duplicate items to an existing outfit. + for (S32 i=items.size()-1; i>=0; i--) + { + LLViewerInventoryItem *item = items.at(i); + LLUUID item_id = item->getLinkedUUID(); + if (items_seen.find(item_id)!=items_seen.end()) + continue; + items_seen.insert(item_id); + tmp_list.push_front(item); + } + for (std::deque::iterator it = tmp_list.begin(); + it != tmp_list.end(); + ++it) + { + new_items.push_back(*it); + } + items = new_items; +} + +const LLUUID LLAppearanceMgr::getCOF() const +{ + return gInventory.findCategoryUUIDForType(LLFolderType::FT_CURRENT_OUTFIT); +} + +S32 LLAppearanceMgr::getCOFVersion() const +{ + LLViewerInventoryCategory *cof = gInventory.getCategory(getCOF()); + if (cof) + { + return cof->getVersion(); + } + else + { + return LLViewerInventoryCategory::VERSION_UNKNOWN; + } +} + +const LLViewerInventoryItem* LLAppearanceMgr::getBaseOutfitLink() +{ + const LLUUID& current_outfit_cat = getCOF(); + LLInventoryModel::cat_array_t cat_array; + LLInventoryModel::item_array_t item_array; + // Can't search on FT_OUTFIT since links to categories return FT_CATEGORY for type since they don't + // return preferred type. + LLIsType is_category( LLAssetType::AT_CATEGORY ); + gInventory.collectDescendentsIf(current_outfit_cat, + cat_array, + item_array, + false, + is_category); + for (LLInventoryModel::item_array_t::const_iterator iter = item_array.begin(); + iter != item_array.end(); + iter++) + { + const LLViewerInventoryItem *item = (*iter); + const LLViewerInventoryCategory *cat = item->getLinkedCategory(); + if (cat && cat->getPreferredType() == LLFolderType::FT_OUTFIT) + { + const LLUUID parent_id = cat->getParentUUID(); + LLViewerInventoryCategory* parent_cat = gInventory.getCategory(parent_id); + // if base outfit moved to trash it means that we don't have base outfit + if (parent_cat != NULL && parent_cat->getPreferredType() == LLFolderType::FT_TRASH) + { + return NULL; + } + return item; + } + } + return NULL; +} + +bool LLAppearanceMgr::getBaseOutfitName(std::string& name) +{ + const LLViewerInventoryItem* outfit_link = getBaseOutfitLink(); + if(outfit_link) + { + const LLViewerInventoryCategory *cat = outfit_link->getLinkedCategory(); + if (cat) + { + name = cat->getName(); + return true; + } + } + return false; +} + +const LLUUID LLAppearanceMgr::getBaseOutfitUUID() +{ + const LLViewerInventoryItem* outfit_link = getBaseOutfitLink(); + if (!outfit_link || !outfit_link->getIsLinkType()) return LLUUID::null; + + const LLViewerInventoryCategory* outfit_cat = outfit_link->getLinkedCategory(); + if (!outfit_cat) return LLUUID::null; + + if (outfit_cat->getPreferredType() != LLFolderType::FT_OUTFIT) + { + LL_WARNS() << "Expected outfit type:" << LLFolderType::FT_OUTFIT << " but got type:" << outfit_cat->getType() << " for folder name:" << outfit_cat->getName() << LL_ENDL; + return LLUUID::null; + } + + return outfit_cat->getUUID(); +} + +void wear_on_avatar_cb(const LLUUID& inv_item, bool do_replace = false) +{ + if (inv_item.isNull()) + return; + + LLViewerInventoryItem *item = gInventory.getItem(inv_item); + if (item) + { + LLAppearanceMgr::instance().wearItemOnAvatar(inv_item, true, do_replace); + } +} + +bool LLAppearanceMgr::wearItemOnAvatar(const LLUUID& item_id_to_wear, + bool do_update, + bool replace, + LLPointer cb) +{ + + if (item_id_to_wear.isNull()) return false; + + // *TODO: issue with multi-wearable should be fixed: + // in this case this method will be called N times - loading started for each item + // and than N times will be called - loading completed for each item. + // That means subscribers will be notified that loading is done after first item in a batch is worn. + // (loading indicator disappears for example before all selected items are worn) + // Have not fix this issue for 2.1 because of stability reason. EXT-7777. + + // Disabled for now because it is *not* acceptable to call updateAppearanceFromCOF() multiple times +// gAgentWearables.notifyLoadingStarted(); + + LLViewerInventoryItem* item_to_wear = gInventory.getItem(item_id_to_wear); + if (!item_to_wear) return false; + + if (gInventory.isObjectDescendentOf(item_to_wear->getUUID(), gInventory.getLibraryRootFolderID())) + { + LLPointer cb = new LLBoostFuncInventoryCallback(boost::bind(wear_on_avatar_cb,_1,replace)); + copy_inventory_item(gAgent.getID(), item_to_wear->getPermissions().getOwner(), item_to_wear->getUUID(), LLUUID::null, std::string(), cb); + return false; + } + else if (!gInventory.isObjectDescendentOf(item_to_wear->getUUID(), gInventory.getRootFolderID())) + { + return false; // not in library and not in agent's inventory + } + else if (gInventory.isObjectDescendentOf(item_to_wear->getUUID(), gInventory.findCategoryUUIDForType(LLFolderType::FT_TRASH))) + { + LLNotificationsUtil::add("CannotWearTrash"); + return false; + } + else if (isLinkedInCOF(item_to_wear->getUUID())) // EXT-84911 + { + return false; + } + + switch (item_to_wear->getType()) + { + case LLAssetType::AT_CLOTHING: + if (gAgentWearables.areWearablesLoaded()) + { + if (!cb && do_update) + { + cb = new LLUpdateAppearanceAndEditWearableOnDestroy(item_id_to_wear); + } + S32 wearable_count = gAgentWearables.getWearableCount(item_to_wear->getWearableType()); + if ((replace && wearable_count != 0) || + (wearable_count >= LLAgentWearables::MAX_CLOTHING_PER_TYPE) ) + { + LLUUID item_id = gAgentWearables.getWearableItemID(item_to_wear->getWearableType(), + wearable_count-1); + removeCOFItemLinks(item_id, cb); + } + + addCOFItemLink(item_to_wear, cb); + } + break; + + case LLAssetType::AT_BODYPART: + // TODO: investigate wearables may not be loaded at this point EXT-8231 + + // Remove the existing wearables of the same type. + // Remove existing body parts anyway because we must not be able to wear e.g. two skins. + removeCOFLinksOfType(item_to_wear->getWearableType()); + if (!cb && do_update) + { + cb = new LLUpdateAppearanceAndEditWearableOnDestroy(item_id_to_wear); + } + addCOFItemLink(item_to_wear, cb); + break; + + case LLAssetType::AT_OBJECT: + rez_attachment(item_to_wear, NULL, replace); + break; + + default: return false;; + } + + return true; +} + +// Update appearance from outfit folder. +void LLAppearanceMgr::changeOutfit(bool proceed, const LLUUID& category, bool append) +{ + if (!proceed) + return; + LLAppearanceMgr::instance().updateCOF(category,append); +} + +void LLAppearanceMgr::replaceCurrentOutfit(const LLUUID& new_outfit) +{ + LLViewerInventoryCategory* cat = gInventory.getCategory(new_outfit); + wearInventoryCategory(cat, false, false); +} + +// Open outfit renaming dialog. +void LLAppearanceMgr::renameOutfit(const LLUUID& outfit_id) +{ + LLViewerInventoryCategory* cat = gInventory.getCategory(outfit_id); + if (!cat) + { + return; + } + + LLSD args; + args["NAME"] = cat->getName(); + + LLSD payload; + payload["cat_id"] = outfit_id; + + LLNotificationsUtil::add("RenameOutfit", args, payload, boost::bind(onOutfitRename, _1, _2)); +} + +// User typed new outfit name. +// static +void LLAppearanceMgr::onOutfitRename(const LLSD& notification, const LLSD& response) +{ + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); + if (option != 0) return; // canceled + + std::string outfit_name = response["new_name"].asString(); + LLStringUtil::trim(outfit_name); + if (!outfit_name.empty()) + { + LLUUID cat_id = notification["payload"]["cat_id"].asUUID(); + rename_category(&gInventory, cat_id, outfit_name); + } +} + +void LLAppearanceMgr::setOutfitLocked(bool locked) +{ + if (mOutfitLocked == locked) + { + return; + } + + mOutfitLocked = locked; + if (locked) + { + mUnlockOutfitTimer->reset(); + mUnlockOutfitTimer->start(); + } + else + { + mUnlockOutfitTimer->stop(); + } + + LLOutfitObserver::instance().notifyOutfitLockChanged(); +} + +void LLAppearanceMgr::addCategoryToCurrentOutfit(const LLUUID& cat_id) +{ + LLViewerInventoryCategory* cat = gInventory.getCategory(cat_id); + wearInventoryCategory(cat, false, true); +} + +void LLAppearanceMgr::takeOffOutfit(const LLUUID& cat_id) +{ + LLInventoryModel::cat_array_t cats; + LLInventoryModel::item_array_t items; + LLFindWearablesEx collector(/*is_worn=*/ true, /*include_body_parts=*/ false); + + gInventory.collectDescendentsIf(cat_id, cats, items, FALSE, collector); + + LLInventoryModel::item_array_t::const_iterator it = items.begin(); + const LLInventoryModel::item_array_t::const_iterator it_end = items.end(); + uuid_vec_t uuids_to_remove; + for( ; it_end != it; ++it) + { + LLViewerInventoryItem* item = *it; + uuids_to_remove.push_back(item->getUUID()); + } + removeItemsFromAvatar(uuids_to_remove); + + // deactivate all gestures in the outfit folder + LLInventoryModel::item_array_t gest_items; + getDescendentsOfAssetType(cat_id, gest_items, LLAssetType::AT_GESTURE); + for(S32 i = 0; i < gest_items.size(); ++i) + { + LLViewerInventoryItem *gest_item = gest_items[i]; + if ( LLGestureMgr::instance().isGestureActive( gest_item->getLinkedUUID()) ) + { + LLGestureMgr::instance().deactivateGesture( gest_item->getLinkedUUID() ); + } + } +} + +// Create a copy of src_id + contents as a subfolder of dst_id. +void LLAppearanceMgr::shallowCopyCategory(const LLUUID& src_id, const LLUUID& dst_id, + LLPointer cb) +{ + LLInventoryCategory *src_cat = gInventory.getCategory(src_id); + if (!src_cat) + { + LL_WARNS() << "folder not found for src " << src_id.asString() << LL_ENDL; + return; + } + LL_INFOS() << "starting, src_id " << src_id << " name " << src_cat->getName() << " dst_id " << dst_id << LL_ENDL; + LLUUID parent_id = dst_id; + if(parent_id.isNull()) + { + parent_id = gInventory.getRootFolderID(); + } + LLUUID subfolder_id = gInventory.createNewCategory( parent_id, + LLFolderType::FT_NONE, + src_cat->getName()); + shallowCopyCategoryContents(src_id, subfolder_id, cb); + + gInventory.notifyObservers(); +} + +void LLAppearanceMgr::slamCategoryLinks(const LLUUID& src_id, const LLUUID& dst_id, + bool include_folder_links, LLPointer cb) +{ + LLInventoryModel::cat_array_t* cats; + LLInventoryModel::item_array_t* items; + LLSD contents = LLSD::emptyArray(); + gInventory.getDirectDescendentsOf(src_id, cats, items); + LL_INFOS() << "copying " << items->size() << " items" << LL_ENDL; + for (LLInventoryModel::item_array_t::const_iterator iter = items->begin(); + iter != items->end(); + ++iter) + { + const LLViewerInventoryItem* item = (*iter); + switch (item->getActualType()) + { + case LLAssetType::AT_LINK: + { + LL_DEBUGS("Avatar") << "linking inventory item " << item->getName() << LL_ENDL; + //getActualDescription() is used for a new description + //to propagate ordering information saved in descriptions of links + LLSD item_contents; + item_contents["name"] = item->getName(); + item_contents["desc"] = item->getActualDescription(); + item_contents["linked_id"] = item->getLinkedUUID(); + item_contents["type"] = LLAssetType::AT_LINK; + contents.append(item_contents); + break; + } + case LLAssetType::AT_LINK_FOLDER: + { + LLViewerInventoryCategory *catp = item->getLinkedCategory(); + if (catp && include_folder_links) + { + LL_DEBUGS("Avatar") << "linking inventory folder " << item->getName() << LL_ENDL; + LLSD base_contents; + base_contents["name"] = catp->getName(); + base_contents["desc"] = ""; // categories don't have descriptions. + base_contents["linked_id"] = catp->getLinkedUUID(); + base_contents["type"] = LLAssetType::AT_LINK_FOLDER; + contents.append(base_contents); + } + break; + } + default: + { + // Linux refuses to compile unless all possible enums are handled. Really, Linux? + break; + } + } + } + slam_inventory_folder(dst_id, contents, cb); +} +// Copy contents of src_id to dst_id. +void LLAppearanceMgr::shallowCopyCategoryContents(const LLUUID& src_id, const LLUUID& dst_id, + LLPointer cb) +{ + LLInventoryModel::cat_array_t* cats; + LLInventoryModel::item_array_t* items; + gInventory.getDirectDescendentsOf(src_id, cats, items); + LL_INFOS() << "copying " << items->size() << " items" << LL_ENDL; + LLInventoryObject::const_object_list_t link_array; + for (LLInventoryModel::item_array_t::const_iterator iter = items->begin(); + iter != items->end(); + ++iter) + { + const LLViewerInventoryItem* item = (*iter); + switch (item->getActualType()) + { + case LLAssetType::AT_LINK: + { + LL_DEBUGS("Avatar") << "linking inventory item " << item->getName() << LL_ENDL; + link_array.push_back(LLConstPointer(item)); + break; + } + case LLAssetType::AT_LINK_FOLDER: + { + LLViewerInventoryCategory *catp = item->getLinkedCategory(); + // Skip copying outfit links. + if (catp && catp->getPreferredType() != LLFolderType::FT_OUTFIT) + { + LL_DEBUGS("Avatar") << "linking inventory folder " << item->getName() << LL_ENDL; + link_array.push_back(LLConstPointer(item)); + } + break; + } + case LLAssetType::AT_CLOTHING: + case LLAssetType::AT_OBJECT: + case LLAssetType::AT_BODYPART: + case LLAssetType::AT_GESTURE: + { + LL_DEBUGS("Avatar") << "copying inventory item " << item->getName() << LL_ENDL; + copy_inventory_item(gAgent.getID(), + item->getPermissions().getOwner(), + item->getUUID(), + dst_id, + item->getName(), + cb); + break; + } + default: + // Ignore non-outfit asset types + break; + } + } + if (!link_array.empty()) + { + link_inventory_array(dst_id, link_array, cb); + } +} + +BOOL LLAppearanceMgr::getCanMakeFolderIntoOutfit(const LLUUID& folder_id) +{ + // These are the wearable items that are required for considering this + // folder as containing a complete outfit. + U32 required_wearables = 0; + required_wearables |= 1LL << LLWearableType::WT_SHAPE; + required_wearables |= 1LL << LLWearableType::WT_SKIN; + required_wearables |= 1LL << LLWearableType::WT_HAIR; + required_wearables |= 1LL << LLWearableType::WT_EYES; + + // These are the wearables that the folder actually contains. + U32 folder_wearables = 0; + LLInventoryModel::cat_array_t* cats; + LLInventoryModel::item_array_t* items; + gInventory.getDirectDescendentsOf(folder_id, cats, items); + for (LLInventoryModel::item_array_t::const_iterator iter = items->begin(); + iter != items->end(); + ++iter) + { + const LLViewerInventoryItem* item = (*iter); + if (item->isWearableType()) + { + const LLWearableType::EType wearable_type = item->getWearableType(); + folder_wearables |= 1LL << wearable_type; + } + } + + // If the folder contains the required wearables, return TRUE. + return ((required_wearables & folder_wearables) == required_wearables); +} + +bool LLAppearanceMgr::getCanRemoveOutfit(const LLUUID& outfit_cat_id) +{ + // Disallow removing the base outfit. + if (outfit_cat_id == getBaseOutfitUUID()) + { + return false; + } + + // Check if the outfit folder itself is removable. + if (!get_is_category_removable(&gInventory, outfit_cat_id)) + { + return false; + } + + // Check for the folder's non-removable descendants. + LLFindNonRemovableObjects filter_non_removable; + LLInventoryModel::cat_array_t cats; + LLInventoryModel::item_array_t items; + LLInventoryModel::item_array_t::const_iterator it; + gInventory.collectDescendentsIf(outfit_cat_id, cats, items, false, filter_non_removable); + if (!cats.empty() || !items.empty()) + { + return false; + } + + return true; +} + +// static +bool LLAppearanceMgr::getCanRemoveFromCOF(const LLUUID& outfit_cat_id) +{ + if (gAgentWearables.isCOFChangeInProgress()) + { + return false; + } + + LLFindWearablesEx is_worn(/*is_worn=*/ true, /*include_body_parts=*/ false); + return gInventory.hasMatchingDirectDescendent(outfit_cat_id, is_worn); +} + +// static +bool LLAppearanceMgr::getCanAddToCOF(const LLUUID& outfit_cat_id) +{ + if (gAgentWearables.isCOFChangeInProgress()) + { + return false; + } + + LLInventoryModel::cat_array_t cats; + LLInventoryModel::item_array_t items; + LLFindWearablesEx not_worn(/*is_worn=*/ false, /*include_body_parts=*/ false); + gInventory.collectDescendentsIf(outfit_cat_id, + cats, + items, + LLInventoryModel::EXCLUDE_TRASH, + not_worn); + + return items.size() > 0; +} + +bool LLAppearanceMgr::getCanReplaceCOF(const LLUUID& outfit_cat_id) +{ + // Don't allow wearing anything while we're changing appearance. + if (gAgentWearables.isCOFChangeInProgress()) + { + return false; + } + + // Check whether it's the base outfit. + if (outfit_cat_id.isNull() || outfit_cat_id == getBaseOutfitUUID()) + { + return false; + } + + // Check whether the outfit contains any wearables we aren't wearing already (STORM-702). + LLInventoryModel::cat_array_t cats; + LLInventoryModel::item_array_t items; + LLFindWearablesEx is_worn(/*is_worn=*/ false, /*include_body_parts=*/ true); + gInventory.collectDescendentsIf(outfit_cat_id, + cats, + items, + LLInventoryModel::EXCLUDE_TRASH, + is_worn); + + return items.size() > 0; +} + +void LLAppearanceMgr::purgeBaseOutfitLink(const LLUUID& category, LLPointer cb) +{ + LLInventoryModel::cat_array_t cats; + LLInventoryModel::item_array_t items; + gInventory.collectDescendents(category, cats, items, + LLInventoryModel::EXCLUDE_TRASH); + for (S32 i = 0; i < items.size(); ++i) + { + LLViewerInventoryItem *item = items.at(i); + if (item->getActualType() != LLAssetType::AT_LINK_FOLDER) + continue; + LLViewerInventoryCategory* catp = item->getLinkedCategory(); + if(catp && catp->getPreferredType() == LLFolderType::FT_OUTFIT) + { + remove_inventory_item(item->getUUID(), cb); + } + } +} + +// Keep the last N wearables of each type. For viewer 2.0, N is 1 for +// both body parts and clothing items. +void LLAppearanceMgr::filterWearableItems( + LLInventoryModel::item_array_t& items, S32 max_per_type) +{ + // Divvy items into arrays by wearable type. + std::vector items_by_type(LLWearableType::WT_COUNT); + divvyWearablesByType(items, items_by_type); + + // rebuild items list, retaining the last max_per_type of each array + items.clear(); + for (S32 i=0; igetName() : "[UNKNOWN]") << "'" << LL_ENDL; + + const LLUUID cof = getCOF(); + + // Deactivate currently active gestures in the COF, if replacing outfit + if (!append) + { + LLInventoryModel::item_array_t gest_items; + getDescendentsOfAssetType(cof, gest_items, LLAssetType::AT_GESTURE); + for(S32 i = 0; i < gest_items.size(); ++i) + { + LLViewerInventoryItem *gest_item = gest_items.at(i); + if ( LLGestureMgr::instance().isGestureActive( gest_item->getLinkedUUID()) ) + { + LLGestureMgr::instance().deactivateGesture( gest_item->getLinkedUUID() ); + } + } + } + + // Collect and filter descendents to determine new COF contents. + + // - Body parts: always include COF contents as a fallback in case any + // required parts are missing. + // Preserve body parts from COF if appending. + LLInventoryModel::item_array_t body_items; + getDescendentsOfAssetType(cof, body_items, LLAssetType::AT_BODYPART); + getDescendentsOfAssetType(category, body_items, LLAssetType::AT_BODYPART); + if (append) + reverse(body_items.begin(), body_items.end()); + // Reduce body items to max of one per type. + removeDuplicateItems(body_items); + filterWearableItems(body_items, 1); + + // - Wearables: include COF contents only if appending. + LLInventoryModel::item_array_t wear_items; + if (append) + getDescendentsOfAssetType(cof, wear_items, LLAssetType::AT_CLOTHING); + getDescendentsOfAssetType(category, wear_items, LLAssetType::AT_CLOTHING); + // Reduce wearables to max of one per type. + removeDuplicateItems(wear_items); + filterWearableItems(wear_items, LLAgentWearables::MAX_CLOTHING_PER_TYPE); + + // - Attachments: include COF contents only if appending. + LLInventoryModel::item_array_t obj_items; + if (append) + getDescendentsOfAssetType(cof, obj_items, LLAssetType::AT_OBJECT); + getDescendentsOfAssetType(category, obj_items, LLAssetType::AT_OBJECT); + removeDuplicateItems(obj_items); + + // - Gestures: include COF contents only if appending. + LLInventoryModel::item_array_t gest_items; + if (append) + getDescendentsOfAssetType(cof, gest_items, LLAssetType::AT_GESTURE); + getDescendentsOfAssetType(category, gest_items, LLAssetType::AT_GESTURE); + removeDuplicateItems(gest_items); + + // Create links to new COF contents. + LLInventoryModel::item_array_t all_items; + std::copy(body_items.begin(), body_items.end(), std::back_inserter(all_items)); + std::copy(wear_items.begin(), wear_items.end(), std::back_inserter(all_items)); + std::copy(obj_items.begin(), obj_items.end(), std::back_inserter(all_items)); + std::copy(gest_items.begin(), gest_items.end(), std::back_inserter(all_items)); + + // Find any wearables that need description set to enforce ordering. + desc_map_t desc_map; + getWearableOrderingDescUpdates(wear_items, desc_map); + + // Will link all the above items. + // link_waiter enforce flags are false because we've already fixed everything up in updateCOF(). + LLPointer link_waiter = new LLUpdateAppearanceOnDestroy(false,false); + LLSD contents = LLSD::emptyArray(); + + for (LLInventoryModel::item_array_t::const_iterator it = all_items.begin(); + it != all_items.end(); ++it) + { + LLSD item_contents; + LLInventoryItem *item = *it; + + std::string desc; + desc_map_t::const_iterator desc_iter = desc_map.find(item->getUUID()); + if (desc_iter != desc_map.end()) + { + desc = desc_iter->second; + LL_DEBUGS("Avatar") << item->getName() << " overriding desc to: " << desc + << " (was: " << item->getActualDescription() << ")" << LL_ENDL; + } + else + { + desc = item->getActualDescription(); + } + + item_contents["name"] = item->getName(); + item_contents["desc"] = desc; + item_contents["linked_id"] = item->getLinkedUUID(); + item_contents["type"] = LLAssetType::AT_LINK; + contents.append(item_contents); + } + const LLUUID& base_id = append ? getBaseOutfitUUID() : category; + LLViewerInventoryCategory *base_cat = gInventory.getCategory(base_id); + if (base_cat) + { + LLSD base_contents; + base_contents["name"] = base_cat->getName(); + base_contents["desc"] = ""; + base_contents["linked_id"] = base_cat->getLinkedUUID(); + base_contents["type"] = LLAssetType::AT_LINK_FOLDER; + contents.append(base_contents); + } + if (gSavedSettings.getBOOL("DebugAvatarAppearanceMessage")) + { + dump_sequential_xml(gAgentAvatarp->getFullname() + "_slam_request", contents); + } + slam_inventory_folder(getCOF(), contents, link_waiter); + + LL_DEBUGS("Avatar") << self_av_string() << "waiting for LLUpdateAppearanceOnDestroy" << LL_ENDL; +} + +void LLAppearanceMgr::updatePanelOutfitName(const std::string& name) +{ + LLSidepanelAppearance* panel_appearance = + dynamic_cast(LLFloaterSidePanelContainer::getPanel("appearance")); + if (panel_appearance) + { + panel_appearance->refreshCurrentOutfitName(name); + } +} + +void LLAppearanceMgr::createBaseOutfitLink(const LLUUID& category, LLPointer link_waiter) +{ + const LLUUID cof = getCOF(); + LLViewerInventoryCategory* catp = gInventory.getCategory(category); + std::string new_outfit_name = ""; + + purgeBaseOutfitLink(cof, link_waiter); + + if (catp && catp->getPreferredType() == LLFolderType::FT_OUTFIT) + { + link_inventory_object(cof, catp, link_waiter); + new_outfit_name = catp->getName(); + } + + updatePanelOutfitName(new_outfit_name); +} + +void LLAppearanceMgr::updateAgentWearables(LLWearableHoldingPattern* holder) +{ + LL_DEBUGS("Avatar") << "updateAgentWearables()" << LL_ENDL; + LLInventoryItem::item_array_t items; + std::vector< LLViewerWearable* > wearables; + wearables.reserve(32); + + // For each wearable type, find the wearables of that type. + for( S32 i = 0; i < LLWearableType::WT_COUNT; i++ ) + { + for (LLWearableHoldingPattern::found_list_t::iterator iter = holder->getFoundList().begin(); + iter != holder->getFoundList().end(); ++iter) + { + LLFoundData& data = *iter; + LLViewerWearable* wearable = data.mWearable; + if( wearable && ((S32)wearable->getType() == i) ) + { + LLViewerInventoryItem* item = (LLViewerInventoryItem*)gInventory.getItem(data.mItemID); + if( item && (item->getAssetUUID() == wearable->getAssetID()) ) + { + items.push_back(item); + wearables.push_back(wearable); + } + } + } + } + + if(wearables.size() > 0) + { + gAgentWearables.setWearableOutfit(items, wearables); + } +} + +S32 LLAppearanceMgr::countActiveHoldingPatterns() +{ + return LLWearableHoldingPattern::countActive(); +} + +static void remove_non_link_items(LLInventoryModel::item_array_t &items) +{ + LLInventoryModel::item_array_t pruned_items; + for (LLInventoryModel::item_array_t::const_iterator iter = items.begin(); + iter != items.end(); + ++iter) + { + const LLViewerInventoryItem *item = (*iter); + if (item && item->getIsLinkType()) + { + pruned_items.push_back((*iter)); + } + } + items = pruned_items; +} + +//a predicate for sorting inventory items by actual descriptions +bool sort_by_actual_description(const LLInventoryItem* item1, const LLInventoryItem* item2) +{ + if (!item1 || !item2) + { + LL_WARNS() << "either item1 or item2 is NULL" << LL_ENDL; + return true; + } + + return item1->getActualDescription() < item2->getActualDescription(); +} + +void item_array_diff(LLInventoryModel::item_array_t& full_list, + LLInventoryModel::item_array_t& keep_list, + LLInventoryModel::item_array_t& kill_list) + +{ + for (LLInventoryModel::item_array_t::iterator it = full_list.begin(); + it != full_list.end(); + ++it) + { + LLViewerInventoryItem *item = *it; + if (std::find(keep_list.begin(), keep_list.end(), item) == keep_list.end()) + { + kill_list.push_back(item); + } + } +} + +S32 LLAppearanceMgr::findExcessOrDuplicateItems(const LLUUID& cat_id, + LLAssetType::EType type, + S32 max_items, + LLInventoryObject::object_list_t& items_to_kill) +{ + S32 to_kill_count = 0; + + LLInventoryModel::item_array_t items; + getDescendentsOfAssetType(cat_id, items, type); + LLInventoryModel::item_array_t curr_items = items; + removeDuplicateItems(items); + if (max_items > 0) + { + filterWearableItems(items, max_items); + } + LLInventoryModel::item_array_t kill_items; + item_array_diff(curr_items,items,kill_items); + for (LLInventoryModel::item_array_t::iterator it = kill_items.begin(); + it != kill_items.end(); + ++it) + { + items_to_kill.push_back(LLPointer(*it)); + to_kill_count++; + } + return to_kill_count; +} + + +void LLAppearanceMgr::findAllExcessOrDuplicateItems(const LLUUID& cat_id, + LLInventoryObject::object_list_t& items_to_kill) +{ + findExcessOrDuplicateItems(cat_id,LLAssetType::AT_BODYPART, + 1, items_to_kill); + findExcessOrDuplicateItems(cat_id,LLAssetType::AT_CLOTHING, + LLAgentWearables::MAX_CLOTHING_PER_TYPE, items_to_kill); + findExcessOrDuplicateItems(cat_id,LLAssetType::AT_OBJECT, + -1, items_to_kill); +} + +void LLAppearanceMgr::enforceCOFItemRestrictions(LLPointer cb) +{ + LLInventoryObject::object_list_t items_to_kill; + findAllExcessOrDuplicateItems(getCOF(), items_to_kill); + if (items_to_kill.size()>0) + { + // Remove duplicate or excess wearables. Should normally be enforced at the UI level, but + // this should catch anything that gets through. + remove_inventory_items(items_to_kill, cb); + } +} + +void LLAppearanceMgr::updateAppearanceFromCOF(bool enforce_item_restrictions, + bool enforce_ordering, + nullary_func_t post_update_func) +{ + if (mIsInUpdateAppearanceFromCOF) + { + LL_WARNS() << "Called updateAppearanceFromCOF inside updateAppearanceFromCOF, skipping" << LL_ENDL; + return; + } + + LL_DEBUGS("Avatar") << self_av_string() << "starting" << LL_ENDL; + + if (enforce_item_restrictions) + { + // The point here is just to call + // updateAppearanceFromCOF() again after excess items + // have been removed. That time we will set + // enforce_item_restrictions to false so we don't get + // caught in a perpetual loop. + LLPointer cb( + new LLUpdateAppearanceOnDestroy(false, enforce_ordering, post_update_func)); + enforceCOFItemRestrictions(cb); + return; + } + + if (enforce_ordering) + { + //checking integrity of the COF in terms of ordering of wearables, + //checking and updating links' descriptions of wearables in the COF (before analyzed for "dirty" state) + + // As with enforce_item_restrictions handling above, we want + // to wait for the update callbacks, then (finally!) call + // updateAppearanceFromCOF() with no additional COF munging needed. + LLPointer cb( + new LLUpdateAppearanceOnDestroy(false, false, post_update_func)); + updateClothingOrderingInfo(LLUUID::null, cb); + return; + } + + if (!validateClothingOrderingInfo()) + { + LL_WARNS() << "Clothing ordering error" << LL_ENDL; + } + + BoolSetter setIsInUpdateAppearanceFromCOF(mIsInUpdateAppearanceFromCOF); + selfStartPhase("update_appearance_from_cof"); + + // update dirty flag to see if the state of the COF matches + // the saved outfit stored as a folder link + updateIsDirty(); + + // Send server request for appearance update + if (gAgent.getRegion() && gAgent.getRegion()->getCentralBakeVersion()) + { + requestServerAppearanceUpdate(); + } + + LLUUID current_outfit_id = getCOF(); + + // Find all the wearables that are in the COF's subtree. + LL_DEBUGS() << "LLAppearanceMgr::updateFromCOF()" << LL_ENDL; + LLInventoryModel::item_array_t wear_items; + LLInventoryModel::item_array_t obj_items; + LLInventoryModel::item_array_t gest_items; + getUserDescendents(current_outfit_id, wear_items, obj_items, gest_items); + // Get rid of non-links in case somehow the COF was corrupted. + remove_non_link_items(wear_items); + remove_non_link_items(obj_items); + remove_non_link_items(gest_items); + + dumpItemArray(wear_items,"asset_dump: wear_item"); + dumpItemArray(obj_items,"asset_dump: obj_item"); + + LLViewerInventoryCategory *cof = gInventory.getCategory(current_outfit_id); + if (!gInventory.isCategoryComplete(current_outfit_id)) + { + LL_WARNS() << "COF info is not complete. Version " << cof->getVersion() + << " descendent_count " << cof->getDescendentCount() + << " viewer desc count " << cof->getViewerDescendentCount() << LL_ENDL; + } + if(!wear_items.size()) + { + LLNotificationsUtil::add("CouldNotPutOnOutfit"); + return; + } + + //preparing the list of wearables in the correct order for LLAgentWearables + sortItemsByActualDescription(wear_items); + + + LL_DEBUGS("Avatar") << "HP block starts" << LL_ENDL; + LLTimer hp_block_timer; + LLWearableHoldingPattern* holder = new LLWearableHoldingPattern; + + holder->setObjItems(obj_items); + holder->setGestItems(gest_items); + + // Note: can't do normal iteration, because if all the + // wearables can be resolved immediately, then the + // callback will be called (and this object deleted) + // before the final getNextData(). + + for(S32 i = 0; i < wear_items.size(); ++i) + { + LLViewerInventoryItem *item = wear_items.at(i); + LLViewerInventoryItem *linked_item = item ? item->getLinkedItem() : NULL; + + // Fault injection: use debug setting to test asset + // fetch failures (should be replaced by new defaults in + // lost&found). + U32 skip_type = gSavedSettings.getU32("ForceAssetFail"); + + if (item && item->getIsLinkType() && linked_item) + { + LLFoundData found(linked_item->getUUID(), + linked_item->getAssetUUID(), + linked_item->getName(), + linked_item->getType(), + linked_item->isWearableType() ? linked_item->getWearableType() : LLWearableType::WT_INVALID + ); + + if (skip_type != LLWearableType::WT_INVALID && skip_type == found.mWearableType) + { + found.mAssetID.generate(); // Replace with new UUID, guaranteed not to exist in DB + } + //pushing back, not front, to preserve order of wearables for LLAgentWearables + holder->getFoundList().push_back(found); + } + else + { + if (!item) + { + LL_WARNS() << "Attempt to wear a null item " << LL_ENDL; + } + else if (!linked_item) + { + LL_WARNS() << "Attempt to wear a broken link [ name:" << item->getName() << " ] " << LL_ENDL; + } + } + } + + selfStartPhase("get_wearables_2"); + + for (LLWearableHoldingPattern::found_list_t::iterator it = holder->getFoundList().begin(); + it != holder->getFoundList().end(); ++it) + { + LLFoundData& found = *it; + + LL_DEBUGS() << self_av_string() << "waiting for onWearableAssetFetch callback, asset " << found.mAssetID.asString() << LL_ENDL; + + // Fetch the wearables about to be worn. + LLWearableList::instance().getAsset(found.mAssetID, + found.mName, + gAgentAvatarp, + found.mAssetType, + onWearableAssetFetch, + (void*)holder); + + } + + holder->resetTime(gSavedSettings.getF32("MaxWearableWaitTime")); + if (!holder->pollFetchCompletion()) + { + doOnIdleRepeating(boost::bind(&LLWearableHoldingPattern::pollFetchCompletion,holder)); + } + post_update_func(); + + LL_DEBUGS("Avatar") << "HP block ends, elapsed " << hp_block_timer.getElapsedTimeF32() << LL_ENDL; +} + +void LLAppearanceMgr::getDescendentsOfAssetType(const LLUUID& category, + LLInventoryModel::item_array_t& items, + LLAssetType::EType type) +{ + LLInventoryModel::cat_array_t cats; + LLIsType is_of_type(type); + gInventory.collectDescendentsIf(category, + cats, + items, + LLInventoryModel::EXCLUDE_TRASH, + is_of_type); +} + +void LLAppearanceMgr::getUserDescendents(const LLUUID& category, + LLInventoryModel::item_array_t& wear_items, + LLInventoryModel::item_array_t& obj_items, + LLInventoryModel::item_array_t& gest_items) +{ + LLInventoryModel::cat_array_t wear_cats; + LLFindWearables is_wearable; + gInventory.collectDescendentsIf(category, + wear_cats, + wear_items, + LLInventoryModel::EXCLUDE_TRASH, + is_wearable); + + LLInventoryModel::cat_array_t obj_cats; + LLIsType is_object( LLAssetType::AT_OBJECT ); + gInventory.collectDescendentsIf(category, + obj_cats, + obj_items, + LLInventoryModel::EXCLUDE_TRASH, + is_object); + + // Find all gestures in this folder + LLInventoryModel::cat_array_t gest_cats; + LLIsType is_gesture( LLAssetType::AT_GESTURE ); + gInventory.collectDescendentsIf(category, + gest_cats, + gest_items, + LLInventoryModel::EXCLUDE_TRASH, + is_gesture); +} + +void LLAppearanceMgr::wearInventoryCategory(LLInventoryCategory* category, bool copy, bool append) +{ + if(!category) return; + + selfClearPhases(); + selfStartPhase("wear_inventory_category"); + + gAgentWearables.notifyLoadingStarted(); + + LL_INFOS("Avatar") << self_av_string() << "wearInventoryCategory( " << category->getName() + << " )" << LL_ENDL; + + // If we are copying from library, attempt to use AIS to copy the category. + bool ais_ran=false; + if (copy && AISCommand::isAPIAvailable()) + { + LLUUID parent_id; + parent_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_CLOTHING); + if (parent_id.isNull()) + { + parent_id = gInventory.getRootFolderID(); + } + + LLPointer copy_cb = new LLWearCategoryAfterCopy(append); + LLPointer track_cb = new LLTrackPhaseWrapper( + std::string("wear_inventory_category_callback"), copy_cb); + LLPointer cmd_ptr = new CopyLibraryCategoryCommand(category->getUUID(), parent_id, track_cb); + ais_ran=cmd_ptr->run_command(); + } + + if (!ais_ran) + { + selfStartPhase("wear_inventory_category_fetch"); + callAfterCategoryFetch(category->getUUID(),boost::bind(&LLAppearanceMgr::wearCategoryFinal, + &LLAppearanceMgr::instance(), + category->getUUID(), copy, append)); + } +} + +S32 LLAppearanceMgr::getActiveCopyOperations() const +{ + return LLCallAfterInventoryCopyMgr::getInstanceCount(); +} + +void LLAppearanceMgr::wearCategoryFinal(LLUUID& cat_id, bool copy_items, bool append) +{ + LL_INFOS("Avatar") << self_av_string() << "starting" << LL_ENDL; + + selfStopPhase("wear_inventory_category_fetch"); + + // We now have an outfit ready to be copied to agent inventory. Do + // it, and wear that outfit normally. + LLInventoryCategory* cat = gInventory.getCategory(cat_id); + if(copy_items) + { + LLInventoryModel::cat_array_t* cats; + LLInventoryModel::item_array_t* items; + gInventory.getDirectDescendentsOf(cat_id, cats, items); + std::string name; + if(!cat) + { + // should never happen. + name = "New Outfit"; + } + else + { + name = cat->getName(); + } + LLViewerInventoryItem* item = NULL; + LLInventoryModel::item_array_t::const_iterator it = items->begin(); + LLInventoryModel::item_array_t::const_iterator end = items->end(); + LLUUID pid; + for(; it < end; ++it) + { + item = *it; + if(item) + { + if(LLInventoryType::IT_GESTURE == item->getInventoryType()) + { + pid = gInventory.findCategoryUUIDForType(LLFolderType::FT_GESTURE); + } + else + { + pid = gInventory.findCategoryUUIDForType(LLFolderType::FT_CLOTHING); + } + break; + } + } + if(pid.isNull()) + { + pid = gInventory.getRootFolderID(); + } + + LLUUID new_cat_id = gInventory.createNewCategory( + pid, + LLFolderType::FT_NONE, + name); + + // Create a CopyMgr that will copy items, manage its own destruction + new LLCallAfterInventoryCopyMgr( + *items, new_cat_id, std::string("wear_inventory_category_callback"), + boost::bind(&LLAppearanceMgr::wearInventoryCategoryOnAvatar, + LLAppearanceMgr::getInstance(), + gInventory.getCategory(new_cat_id), + append)); + + // BAP fixes a lag in display of created dir. + gInventory.notifyObservers(); + } + else + { + // Wear the inventory category. + LLAppearanceMgr::instance().wearInventoryCategoryOnAvatar(cat, append); + } +} + +// *NOTE: hack to get from avatar inventory to avatar +void LLAppearanceMgr::wearInventoryCategoryOnAvatar( LLInventoryCategory* category, bool append ) +{ + // Avoid unintentionally overwriting old wearables. We have to do + // this up front to avoid having to deal with the case of multiple + // wearables being dirty. + if (!category) return; + + if ( !LLInventoryCallbackManager::is_instantiated() ) + { + // shutting down, ignore. + return; + } + + LL_INFOS("Avatar") << self_av_string() << "wearInventoryCategoryOnAvatar '" << category->getName() + << "'" << LL_ENDL; + + if (gAgentCamera.cameraCustomizeAvatar()) + { + // switching to outfit editor should automagically save any currently edited wearable + LLFloaterSidePanelContainer::showPanel("appearance", LLSD().with("type", "edit_outfit")); + } + + LLAppearanceMgr::changeOutfit(TRUE, category->getUUID(), append); +} + +// FIXME do we really want to search entire inventory for matching name? +void LLAppearanceMgr::wearOutfitByName(const std::string& name) +{ + LL_INFOS("Avatar") << self_av_string() << "Wearing category " << name << LL_ENDL; + + LLInventoryModel::cat_array_t cat_array; + LLInventoryModel::item_array_t item_array; + LLNameCategoryCollector has_name(name); + gInventory.collectDescendentsIf(gInventory.getRootFolderID(), + cat_array, + item_array, + LLInventoryModel::EXCLUDE_TRASH, + has_name); + bool copy_items = false; + LLInventoryCategory* cat = NULL; + if (cat_array.size() > 0) + { + // Just wear the first one that matches + cat = cat_array.at(0); + } + else + { + gInventory.collectDescendentsIf(LLUUID::null, + cat_array, + item_array, + LLInventoryModel::EXCLUDE_TRASH, + has_name); + if(cat_array.size() > 0) + { + cat = cat_array.at(0); + copy_items = true; + } + } + + if(cat) + { + LLAppearanceMgr::wearInventoryCategory(cat, copy_items, false); + } + else + { + LL_WARNS() << "Couldn't find outfit " <isWearableType() && b->isWearableType() && + (a->getWearableType() == b->getWearableType())); +} + +class LLDeferredCOFLinkObserver: public LLInventoryObserver +{ +public: + LLDeferredCOFLinkObserver(const LLUUID& item_id, LLPointer cb, const std::string& description): + mItemID(item_id), + mCallback(cb), + mDescription(description) + { + } + + ~LLDeferredCOFLinkObserver() + { + } + + /* virtual */ void changed(U32 mask) + { + const LLInventoryItem *item = gInventory.getItem(mItemID); + if (item) + { + gInventory.removeObserver(this); + LLAppearanceMgr::instance().addCOFItemLink(item, mCallback, mDescription); + delete this; + } + } + +private: + const LLUUID mItemID; + std::string mDescription; + LLPointer mCallback; +}; + + +// BAP - note that this runs asynchronously if the item is not already loaded from inventory. +// Dangerous if caller assumes link will exist after calling the function. +void LLAppearanceMgr::addCOFItemLink(const LLUUID &item_id, + LLPointer cb, + const std::string description) +{ + const LLInventoryItem *item = gInventory.getItem(item_id); + if (!item) + { + LLDeferredCOFLinkObserver *observer = new LLDeferredCOFLinkObserver(item_id, cb, description); + gInventory.addObserver(observer); + } + else + { + addCOFItemLink(item, cb, description); + } +} + +void LLAppearanceMgr::addCOFItemLink(const LLInventoryItem *item, + LLPointer cb, + const std::string description) +{ + const LLViewerInventoryItem *vitem = dynamic_cast(item); + if (!vitem) + { + LL_WARNS() << "not an llviewerinventoryitem, failed" << LL_ENDL; + return; + } + + gInventory.addChangedMask(LLInventoryObserver::LABEL, vitem->getLinkedUUID()); + + LLInventoryModel::cat_array_t cat_array; + LLInventoryModel::item_array_t item_array; + gInventory.collectDescendents(LLAppearanceMgr::getCOF(), + cat_array, + item_array, + LLInventoryModel::EXCLUDE_TRASH); + bool linked_already = false; + U32 count = 0; + for (S32 i=0; igetWearableType(); + + const bool is_body_part = (wearable_type == LLWearableType::WT_SHAPE) + || (wearable_type == LLWearableType::WT_HAIR) + || (wearable_type == LLWearableType::WT_EYES) + || (wearable_type == LLWearableType::WT_SKIN); + + if (inv_item->getLinkedUUID() == vitem->getLinkedUUID()) + { + linked_already = true; + } + // Are these links to different items of the same body part + // type? If so, new item will replace old. + else if ((vitem->isWearableType()) && (vitem->getWearableType() == wearable_type)) + { + ++count; + if (is_body_part && inv_item->getIsLinkType() && (vitem->getWearableType() == wearable_type)) + { + remove_inventory_item(inv_item->getUUID(), cb); + } + else if (count >= LLAgentWearables::MAX_CLOTHING_PER_TYPE) + { + // MULTI-WEARABLES: make sure we don't go over MAX_CLOTHING_PER_TYPE + remove_inventory_item(inv_item->getUUID(), cb); + } + } + } + + if (!linked_already) + { + LLViewerInventoryItem *copy_item = new LLViewerInventoryItem; + copy_item->copyViewerItem(vitem); + copy_item->setDescription(description); + link_inventory_object(getCOF(), copy_item, cb); + } +} + +LLInventoryModel::item_array_t LLAppearanceMgr::findCOFItemLinks(const LLUUID& item_id) +{ + + LLInventoryModel::item_array_t result; + const LLViewerInventoryItem *vitem = + dynamic_cast(gInventory.getItem(item_id)); + + if (vitem) + { + LLInventoryModel::cat_array_t cat_array; + LLInventoryModel::item_array_t item_array; + gInventory.collectDescendents(LLAppearanceMgr::getCOF(), + cat_array, + item_array, + LLInventoryModel::EXCLUDE_TRASH); + for (S32 i=0; igetLinkedUUID() == vitem->getLinkedUUID()) + { + result.push_back(item_array.at(i)); + } + } + } + return result; +} + +bool LLAppearanceMgr::isLinkedInCOF(const LLUUID& item_id) +{ + LLInventoryModel::item_array_t links = LLAppearanceMgr::instance().findCOFItemLinks(item_id); + return links.size() > 0; +} + +void LLAppearanceMgr::removeAllClothesFromAvatar() +{ + // Fetch worn clothes (i.e. the ones in COF). + LLInventoryModel::item_array_t clothing_items; + LLInventoryModel::cat_array_t dummy; + LLIsType is_clothing(LLAssetType::AT_CLOTHING); + gInventory.collectDescendentsIf(getCOF(), + dummy, + clothing_items, + LLInventoryModel::EXCLUDE_TRASH, + is_clothing); + uuid_vec_t item_ids; + for (LLInventoryModel::item_array_t::iterator it = clothing_items.begin(); + it != clothing_items.end(); ++it) + { + item_ids.push_back((*it).get()->getLinkedUUID()); + } + + // Take them off by removing from COF. + removeItemsFromAvatar(item_ids); +} + +void LLAppearanceMgr::removeAllAttachmentsFromAvatar() +{ + if (!isAgentAvatarValid()) return; + + LLAgentWearables::llvo_vec_t objects_to_remove; + + for (LLVOAvatar::attachment_map_t::iterator iter = gAgentAvatarp->mAttachmentPoints.begin(); + iter != gAgentAvatarp->mAttachmentPoints.end();) + { + LLVOAvatar::attachment_map_t::iterator curiter = iter++; + LLViewerJointAttachment* attachment = curiter->second; + for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin(); + attachment_iter != attachment->mAttachedObjects.end(); + ++attachment_iter) + { + LLViewerObject *attached_object = (*attachment_iter); + if (attached_object) + { + objects_to_remove.push_back(attached_object); + } + } + } + uuid_vec_t ids_to_remove; + for (LLAgentWearables::llvo_vec_t::iterator it = objects_to_remove.begin(); + it != objects_to_remove.end(); + ++it) + { + ids_to_remove.push_back((*it)->getAttachmentItemID()); + } + removeItemsFromAvatar(ids_to_remove); +} + +void LLAppearanceMgr::removeCOFItemLinks(const LLUUID& item_id, LLPointer cb) +{ + gInventory.addChangedMask(LLInventoryObserver::LABEL, item_id); + + LLInventoryModel::cat_array_t cat_array; + LLInventoryModel::item_array_t item_array; + gInventory.collectDescendents(LLAppearanceMgr::getCOF(), + cat_array, + item_array, + LLInventoryModel::EXCLUDE_TRASH); + for (S32 i=0; igetIsLinkType() && item->getLinkedUUID() == item_id) + { + bool immediate_delete = false; + if (item->getType() == LLAssetType::AT_OBJECT) + { + immediate_delete = true; + } + remove_inventory_item(item->getUUID(), cb, immediate_delete); + } + } +} + +void LLAppearanceMgr::removeCOFLinksOfType(LLWearableType::EType type, LLPointer cb) +{ + LLFindWearablesOfType filter_wearables_of_type(type); + LLInventoryModel::cat_array_t cats; + LLInventoryModel::item_array_t items; + LLInventoryModel::item_array_t::const_iterator it; + + gInventory.collectDescendentsIf(getCOF(), cats, items, true, filter_wearables_of_type); + for (it = items.begin(); it != items.end(); ++it) + { + const LLViewerInventoryItem* item = *it; + if (item->getIsLinkType()) // we must operate on links only + { + remove_inventory_item(item->getUUID(), cb); + } + } +} + +bool sort_by_linked_uuid(const LLViewerInventoryItem* item1, const LLViewerInventoryItem* item2) +{ + if (!item1 || !item2) + { + LL_WARNS() << "item1, item2 cannot be null, something is very wrong" << LL_ENDL; + return true; + } + + return item1->getLinkedUUID() < item2->getLinkedUUID(); +} + +void LLAppearanceMgr::updateIsDirty() +{ + LLUUID cof = getCOF(); + LLUUID base_outfit; + + // find base outfit link + const LLViewerInventoryItem* base_outfit_item = getBaseOutfitLink(); + LLViewerInventoryCategory* catp = NULL; + if (base_outfit_item && base_outfit_item->getIsLinkType()) + { + catp = base_outfit_item->getLinkedCategory(); + } + if(catp && catp->getPreferredType() == LLFolderType::FT_OUTFIT) + { + base_outfit = catp->getUUID(); + } + + // Set dirty to "false" if no base outfit found to disable "Save" + // and leave only "Save As" enabled in My Outfits. + mOutfitIsDirty = false; + + if (base_outfit.notNull()) + { + LLIsValidItemLink collector; + + LLInventoryModel::cat_array_t cof_cats; + LLInventoryModel::item_array_t cof_items; + gInventory.collectDescendentsIf(cof, cof_cats, cof_items, + LLInventoryModel::EXCLUDE_TRASH, collector); + + LLInventoryModel::cat_array_t outfit_cats; + LLInventoryModel::item_array_t outfit_items; + gInventory.collectDescendentsIf(base_outfit, outfit_cats, outfit_items, + LLInventoryModel::EXCLUDE_TRASH, collector); + + if(outfit_items.size() != cof_items.size()) + { + LL_DEBUGS("Avatar") << "item count different - base " << outfit_items.size() << " cof " << cof_items.size() << LL_ENDL; + // Current outfit folder should have one more item than the outfit folder. + // this one item is the link back to the outfit folder itself. + mOutfitIsDirty = true; + return; + } + + //"dirty" - also means a difference in linked UUIDs and/or a difference in wearables order (links' descriptions) + std::sort(cof_items.begin(), cof_items.end(), sort_by_linked_uuid); + std::sort(outfit_items.begin(), outfit_items.end(), sort_by_linked_uuid); + + for (U32 i = 0; i < cof_items.size(); ++i) + { + LLViewerInventoryItem *item1 = cof_items.at(i); + LLViewerInventoryItem *item2 = outfit_items.at(i); + + if (item1->getLinkedUUID() != item2->getLinkedUUID() || + item1->getName() != item2->getName() || + item1->getActualDescription() != item2->getActualDescription()) + { + if (item1->getLinkedUUID() != item2->getLinkedUUID()) + { + LL_DEBUGS("Avatar") << "link id different " << LL_ENDL; + } + else + { + if (item1->getName() != item2->getName()) + { + LL_DEBUGS("Avatar") << "name different " << item1->getName() << " " << item2->getName() << LL_ENDL; + } + if (item1->getActualDescription() != item2->getActualDescription()) + { + LL_DEBUGS("Avatar") << "desc different " << item1->getActualDescription() + << " " << item2->getActualDescription() + << " names " << item1->getName() << " " << item2->getName() << LL_ENDL; + } + } + mOutfitIsDirty = true; + return; + } + } + } + llassert(!mOutfitIsDirty); + LL_DEBUGS("Avatar") << "clean" << LL_ENDL; +} + +// *HACK: Must match name in Library or agent inventory +const std::string ROOT_GESTURES_FOLDER = "Gestures"; +const std::string COMMON_GESTURES_FOLDER = "Common Gestures"; +const std::string MALE_GESTURES_FOLDER = "Male Gestures"; +const std::string FEMALE_GESTURES_FOLDER = "Female Gestures"; +const std::string SPEECH_GESTURES_FOLDER = "Speech Gestures"; +const std::string OTHER_GESTURES_FOLDER = "Other Gestures"; + +void LLAppearanceMgr::copyLibraryGestures() +{ + LL_INFOS("Avatar") << self_av_string() << "Copying library gestures" << LL_ENDL; + + // Copy gestures + LLUUID lib_gesture_cat_id = + gInventory.findLibraryCategoryUUIDForType(LLFolderType::FT_GESTURE,false); + if (lib_gesture_cat_id.isNull()) + { + LL_WARNS() << "Unable to copy gestures, source category not found" << LL_ENDL; + } + LLUUID dst_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_GESTURE); + + std::vector gesture_folders_to_copy; + gesture_folders_to_copy.push_back(MALE_GESTURES_FOLDER); + gesture_folders_to_copy.push_back(FEMALE_GESTURES_FOLDER); + gesture_folders_to_copy.push_back(COMMON_GESTURES_FOLDER); + gesture_folders_to_copy.push_back(SPEECH_GESTURES_FOLDER); + gesture_folders_to_copy.push_back(OTHER_GESTURES_FOLDER); + + for(std::vector::iterator it = gesture_folders_to_copy.begin(); + it != gesture_folders_to_copy.end(); + ++it) + { + std::string& folder_name = *it; + + LLPointer cb(NULL); + + // After copying gestures, activate Common, Other, plus + // Male and/or Female, depending upon the initial outfit gender. + ESex gender = gAgentAvatarp->getSex(); + + std::string activate_male_gestures; + std::string activate_female_gestures; + switch (gender) { + case SEX_MALE: + activate_male_gestures = MALE_GESTURES_FOLDER; + break; + case SEX_FEMALE: + activate_female_gestures = FEMALE_GESTURES_FOLDER; + break; + case SEX_BOTH: + activate_male_gestures = MALE_GESTURES_FOLDER; + activate_female_gestures = FEMALE_GESTURES_FOLDER; + break; + } + + if (folder_name == activate_male_gestures || + folder_name == activate_female_gestures || + folder_name == COMMON_GESTURES_FOLDER || + folder_name == OTHER_GESTURES_FOLDER) + { + cb = new LLBoostFuncInventoryCallback(activate_gesture_cb); + } + + LLUUID cat_id = findDescendentCategoryIDByName(lib_gesture_cat_id,folder_name); + if (cat_id.isNull()) + { + LL_WARNS() << self_av_string() << "failed to find gesture folder for " << folder_name << LL_ENDL; + } + else + { + LL_DEBUGS("Avatar") << self_av_string() << "initiating fetch and copy for " << folder_name << " cat_id " << cat_id << LL_ENDL; + callAfterCategoryFetch(cat_id, + boost::bind(&LLAppearanceMgr::shallowCopyCategory, + &LLAppearanceMgr::instance(), + cat_id, dst_id, cb)); + } + } +} + +// Handler for anything that's deferred until avatar de-clouds. +void LLAppearanceMgr::onFirstFullyVisible() +{ + gAgentAvatarp->outputRezTiming("Avatar fully loaded"); + gAgentAvatarp->reportAvatarRezTime(); + gAgentAvatarp->debugAvatarVisible(); + + // If this is the first time we've ever logged in, + // then copy default gestures from the library. + if (gAgent.isFirstLogin()) { + copyLibraryGestures(); + } +} + +// update "dirty" state - defined outside class to allow for calling +// after appearance mgr instance has been destroyed. +void appearance_mgr_update_dirty_state() +{ + if (LLAppearanceMgr::instanceExists()) + { + LLAppearanceMgr::getInstance()->updateIsDirty(); + LLAppearanceMgr::getInstance()->setOutfitLocked(false); + gAgentWearables.notifyLoadingFinished(); + } +} + +void update_base_outfit_after_ordering() +{ + LLAppearanceMgr& app_mgr = LLAppearanceMgr::instance(); + + LLPointer dirty_state_updater = + new LLBoostFuncInventoryCallback(no_op_inventory_func, appearance_mgr_update_dirty_state); + + //COF contains only links so we copy to the Base Outfit only links + const LLUUID base_outfit_id = app_mgr.getBaseOutfitUUID(); + bool copy_folder_links = false; + app_mgr.slamCategoryLinks(app_mgr.getCOF(), base_outfit_id, copy_folder_links, dirty_state_updater); + +} + +// Save COF changes - update the contents of the current base outfit +// to match the current COF. Fails if no current base outfit is set. +bool LLAppearanceMgr::updateBaseOutfit() +{ + if (isOutfitLocked()) + { + // don't allow modify locked outfit + llassert(!isOutfitLocked()); + return false; + } + + setOutfitLocked(true); + + gAgentWearables.notifyLoadingStarted(); + + const LLUUID base_outfit_id = getBaseOutfitUUID(); + if (base_outfit_id.isNull()) return false; + LL_DEBUGS("Avatar") << "saving cof to base outfit " << base_outfit_id << LL_ENDL; + + LLPointer cb = + new LLBoostFuncInventoryCallback(no_op_inventory_func, update_base_outfit_after_ordering); + // Really shouldn't be needed unless there's a race condition - + // updateAppearanceFromCOF() already calls updateClothingOrderingInfo. + updateClothingOrderingInfo(LLUUID::null, cb); + + return true; +} + +void LLAppearanceMgr::divvyWearablesByType(const LLInventoryModel::item_array_t& items, wearables_by_type_t& items_by_type) +{ + items_by_type.resize(LLWearableType::WT_COUNT); + if (items.empty()) return; + + for (S32 i=0; iisWearableType()) + continue; + LLWearableType::EType type = item->getWearableType(); + if(type < 0 || type >= LLWearableType::WT_COUNT) + { + LL_WARNS("Appearance") << "Invalid wearable type. Inventory type does not match wearable flag bitfield." << LL_ENDL; + continue; + } + items_by_type[type].push_back(item); + } +} + +std::string build_order_string(LLWearableType::EType type, U32 i) +{ + std::ostringstream order_num; + order_num << ORDER_NUMBER_SEPARATOR << type * 100 + i; + return order_num.str(); +} + +struct WearablesOrderComparator +{ + LOG_CLASS(WearablesOrderComparator); + WearablesOrderComparator(const LLWearableType::EType type) + { + mControlSize = build_order_string(type, 0).size(); + }; + + bool operator()(const LLInventoryItem* item1, const LLInventoryItem* item2) + { + const std::string& desc1 = item1->getActualDescription(); + const std::string& desc2 = item2->getActualDescription(); + + bool item1_valid = (desc1.size() == mControlSize) && (ORDER_NUMBER_SEPARATOR == desc1[0]); + bool item2_valid = (desc2.size() == mControlSize) && (ORDER_NUMBER_SEPARATOR == desc2[0]); + + if (item1_valid && item2_valid) + return desc1 < desc2; + + //we need to sink down invalid items: items with empty descriptions, items with "Broken link" descriptions, + //items with ordering information but not for the associated wearables type + if (!item1_valid && item2_valid) + return false; + else if (item1_valid && !item2_valid) + return true; + + return item1->getName() < item2->getName(); + } + + U32 mControlSize; +}; + +void LLAppearanceMgr::getWearableOrderingDescUpdates(LLInventoryModel::item_array_t& wear_items, + desc_map_t& desc_map) +{ + wearables_by_type_t items_by_type(LLWearableType::WT_COUNT); + divvyWearablesByType(wear_items, items_by_type); + + for (U32 type = LLWearableType::WT_SHIRT; type < LLWearableType::WT_COUNT; type++) + { + U32 size = items_by_type[type].size(); + if (!size) continue; + + //sinking down invalid items which need reordering + std::sort(items_by_type[type].begin(), items_by_type[type].end(), WearablesOrderComparator((LLWearableType::EType) type)); + + //requesting updates only for those links which don't have "valid" descriptions + for (U32 i = 0; i < size; i++) + { + LLViewerInventoryItem* item = items_by_type[type][i]; + if (!item) continue; + + std::string new_order_str = build_order_string((LLWearableType::EType)type, i); + if (new_order_str == item->getActualDescription()) continue; + + desc_map[item->getUUID()] = new_order_str; + } + } +} + +bool LLAppearanceMgr::validateClothingOrderingInfo(LLUUID cat_id) +{ + // COF is processed if cat_id is not specified + if (cat_id.isNull()) + { + cat_id = getCOF(); + } + + LLInventoryModel::item_array_t wear_items; + getDescendentsOfAssetType(cat_id, wear_items, LLAssetType::AT_CLOTHING); + + // Identify items for which desc needs to change. + desc_map_t desc_map; + getWearableOrderingDescUpdates(wear_items, desc_map); + + for (desc_map_t::const_iterator it = desc_map.begin(); + it != desc_map.end(); ++it) + { + const LLUUID& item_id = it->first; + const std::string& new_order_str = it->second; + LLViewerInventoryItem *item = gInventory.getItem(item_id); + LL_WARNS() << "Order validation fails: " << item->getName() + << " needs to update desc to: " << new_order_str + << " (from: " << item->getActualDescription() << ")" << LL_ENDL; + } + + return desc_map.size() == 0; +} + +void LLAppearanceMgr::updateClothingOrderingInfo(LLUUID cat_id, + LLPointer cb) +{ + // COF is processed if cat_id is not specified + if (cat_id.isNull()) + { + cat_id = getCOF(); + } + + LLInventoryModel::item_array_t wear_items; + getDescendentsOfAssetType(cat_id, wear_items, LLAssetType::AT_CLOTHING); + + // Identify items for which desc needs to change. + desc_map_t desc_map; + getWearableOrderingDescUpdates(wear_items, desc_map); + + for (desc_map_t::const_iterator it = desc_map.begin(); + it != desc_map.end(); ++it) + { + LLSD updates; + const LLUUID& item_id = it->first; + const std::string& new_order_str = it->second; + LLViewerInventoryItem *item = gInventory.getItem(item_id); + LL_DEBUGS("Avatar") << item->getName() << " updating desc to: " << new_order_str + << " (was: " << item->getActualDescription() << ")" << LL_ENDL; + updates["desc"] = new_order_str; + update_inventory_item(item_id,updates,cb); + } + +} + +//========================================================================= +class LLAppearanceMgrHttpHandler : public LLHttpSDHandler +{ +public: + LLAppearanceMgrHttpHandler(const std::string& capabilityURL, LLAppearanceMgr *mgr) : + LLHttpSDHandler(capabilityURL), + mManager(mgr) + { } + + virtual ~LLAppearanceMgrHttpHandler() + { } + + virtual void onCompleted(LLCore::HttpHandle handle, LLCore::HttpResponse * response); + +protected: + virtual void onSuccess(LLCore::HttpResponse * response, LLSD &content); + virtual void onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status); + +private: + static void debugCOF(const LLSD& content); + + LLAppearanceMgr *mManager; + +}; + +//------------------------------------------------------------------------- +void LLAppearanceMgrHttpHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpResponse * response) +{ + mManager->decrementInFlightCounter(); + + LLHttpSDHandler::onCompleted(handle, response); +} + +void LLAppearanceMgrHttpHandler::onSuccess(LLCore::HttpResponse * response, LLSD &content) +{ + if (!content.isMap()) + { + LLCore::HttpStatus status = LLCore::HttpStatus(HTTP_INTERNAL_ERROR, "Malformed response contents"); + response->setStatus(status); + onFailure(response, status); + if (gSavedSettings.getBOOL("DebugAvatarAppearanceMessage")) + { + debugCOF(content); + } + return; + } + if (content["success"].asBoolean()) + { + LL_DEBUGS("Avatar") << "succeeded" << LL_ENDL; + if (gSavedSettings.getBOOL("DebugAvatarAppearanceMessage")) + { + dump_sequential_xml(gAgentAvatarp->getFullname() + "_appearance_request_ok", content); + } + } + else + { + LLCore::HttpStatus status = LLCore::HttpStatus(HTTP_INTERNAL_ERROR, "Non-success response"); + response->setStatus(status); + onFailure(response, status); + if (gSavedSettings.getBOOL("DebugAvatarAppearanceMessage")) + { + debugCOF(content); + } + return; + } +} + +void LLAppearanceMgrHttpHandler::onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status) +{ + LL_WARNS("Avatar") << "Appearance Mgr request failed to " << getUri() + << ". Reason code: (" << status.toTerseString() << ") " + << status.toString() << LL_ENDL; +} + +void LLAppearanceMgrHttpHandler::debugCOF(const LLSD& content) +{ + dump_sequential_xml(gAgentAvatarp->getFullname() + "_appearance_request_error", content); + + LL_INFOS("Avatar") << "AIS COF, version received: " << content["expected"].asInteger() + << " ================================= " << LL_ENDL; + std::set ais_items, local_items; + const LLSD& cof_raw = content["cof_raw"]; + for (LLSD::array_const_iterator it = cof_raw.beginArray(); + it != cof_raw.endArray(); ++it) + { + const LLSD& item = *it; + if (item["parent_id"].asUUID() == LLAppearanceMgr::instance().getCOF()) + { + ais_items.insert(item["item_id"].asUUID()); + if (item["type"].asInteger() == 24) // link + { + LL_INFOS("Avatar") << "AIS Link: item_id: " << item["item_id"].asUUID() + << " linked_item_id: " << item["asset_id"].asUUID() + << " name: " << item["name"].asString() + << LL_ENDL; + } + else if (item["type"].asInteger() == 25) // folder link + { + LL_INFOS("Avatar") << "AIS Folder link: item_id: " << item["item_id"].asUUID() + << " linked_item_id: " << item["asset_id"].asUUID() + << " name: " << item["name"].asString() + << LL_ENDL; + } + else + { + LL_INFOS("Avatar") << "AIS Other: item_id: " << item["item_id"].asUUID() + << " linked_item_id: " << item["asset_id"].asUUID() + << " name: " << item["name"].asString() + << " type: " << item["type"].asInteger() + << LL_ENDL; + } + } + } + LL_INFOS("Avatar") << LL_ENDL; + LL_INFOS("Avatar") << "Local COF, version requested: " << content["observed"].asInteger() + << " ================================= " << LL_ENDL; + LLInventoryModel::cat_array_t cat_array; + LLInventoryModel::item_array_t item_array; + gInventory.collectDescendents(LLAppearanceMgr::instance().getCOF(), + cat_array,item_array,LLInventoryModel::EXCLUDE_TRASH); + for (S32 i=0; igetUUID()); + LL_INFOS("Avatar") << "LOCAL: item_id: " << inv_item->getUUID() + << " linked_item_id: " << inv_item->getLinkedUUID() + << " name: " << inv_item->getName() + << " parent: " << inv_item->getParentUUID() + << LL_ENDL; + } + LL_INFOS("Avatar") << " ================================= " << LL_ENDL; + S32 local_only = 0, ais_only = 0; + for (std::set::iterator it = local_items.begin(); it != local_items.end(); ++it) + { + if (ais_items.find(*it) == ais_items.end()) + { + LL_INFOS("Avatar") << "LOCAL ONLY: " << *it << LL_ENDL; + local_only++; + } + } + for (std::set::iterator it = ais_items.begin(); it != ais_items.end(); ++it) + { + if (local_items.find(*it) == local_items.end()) + { + LL_INFOS("Avatar") << "AIS ONLY: " << *it << LL_ENDL; + ais_only++; + } + } + if (local_only==0 && ais_only==0) + { + LL_INFOS("Avatar") << "COF contents identical, only version numbers differ (req " + << content["observed"].asInteger() + << " rcv " << content["expected"].asInteger() + << ")" << LL_ENDL; + } +} + +//========================================================================= + + +LLSD LLAppearanceMgr::dumpCOF() const +{ + LLSD links = LLSD::emptyArray(); + LLMD5 md5; + + LLInventoryModel::cat_array_t cat_array; + LLInventoryModel::item_array_t item_array; + gInventory.collectDescendents(getCOF(),cat_array,item_array,LLInventoryModel::EXCLUDE_TRASH); + for (S32 i=0; igetUUID()); + md5.update((unsigned char*)item_id.mData, 16); + item["description"] = inv_item->getActualDescription(); + md5.update(inv_item->getActualDescription()); + item["asset_type"] = inv_item->getActualType(); + LLUUID linked_id(inv_item->getLinkedUUID()); + item["linked_id"] = linked_id; + md5.update((unsigned char*)linked_id.mData, 16); + + if (LLAssetType::AT_LINK == inv_item->getActualType()) + { + const LLViewerInventoryItem* linked_item = inv_item->getLinkedItem(); + if (NULL == linked_item) + { + LL_WARNS() << "Broken link for item '" << inv_item->getName() + << "' (" << inv_item->getUUID() + << ") during requestServerAppearanceUpdate" << LL_ENDL; + continue; + } + // Some assets may be 'hidden' and show up as null in the viewer. + //if (linked_item->getAssetUUID().isNull()) + //{ + // LL_WARNS() << "Broken link (null asset) for item '" << inv_item->getName() + // << "' (" << inv_item->getUUID() + // << ") during requestServerAppearanceUpdate" << LL_ENDL; + // continue; + //} + LLUUID linked_asset_id(linked_item->getAssetUUID()); + md5.update((unsigned char*)linked_asset_id.mData, 16); + U32 flags = linked_item->getFlags(); + md5.update(boost::lexical_cast(flags)); + } + else if (LLAssetType::AT_LINK_FOLDER != inv_item->getActualType()) + { + LL_WARNS() << "Non-link item '" << inv_item->getName() + << "' (" << inv_item->getUUID() + << ") type " << (S32) inv_item->getActualType() + << " during requestServerAppearanceUpdate" << LL_ENDL; + continue; + } + links.append(item); + } + LLSD result = LLSD::emptyMap(); + result["cof_contents"] = links; + char cof_md5sum[MD5HEX_STR_SIZE]; + md5.finalize(); + md5.hex_digest(cof_md5sum); + result["cof_md5sum"] = std::string(cof_md5sum); + return result; +} + +void LLAppearanceMgr::requestServerAppearanceUpdate() +{ + + if (!testCOFRequestVersion()) + { + // *TODO: LL_LOG message here + return; + } + + if ((mInFlightCounter > 0) && (mInFlightTimer.hasExpired())) + { + LL_WARNS("Avatar") << "in flight timer expired, resetting " << LL_ENDL; + mInFlightCounter = 0; + } + + if (gAgentAvatarp->isEditingAppearance()) + { + LL_WARNS("Avatar") << "Avatar editing appeance, not sending request." << LL_ENDL; + // don't send out appearance updates if in appearance editing mode + return; + } + + if (!gAgent.getRegion()) + { + LL_WARNS("Avatar") << "Region not set, cannot request server appearance update" << LL_ENDL; + return; + } + if (gAgent.getRegion()->getCentralBakeVersion() == 0) + { + LL_WARNS("Avatar") << "Region does not support baking" << LL_ENDL; + } + std::string url = gAgent.getRegion()->getCapability("UpdateAvatarAppearance"); + if (url.empty()) + { + LL_WARNS("Avatar") << "No cap for UpdateAvatarAppearance." << LL_ENDL; + return; + } + + LLSD postData; + S32 cof_version = LLAppearanceMgr::instance().getCOFVersion(); + if (gSavedSettings.getBOOL("DebugAvatarExperimentalServerAppearanceUpdate")) + { + postData = LLAppearanceMgr::instance().dumpCOF(); + } + else + { + postData["cof_version"] = cof_version; + if (gSavedSettings.getBOOL("DebugForceAppearanceRequestFailure")) + { + postData["cof_version"] = cof_version + 999; + } + } + LL_DEBUGS("Avatar") << "request url " << url << " my_cof_version " << cof_version << LL_ENDL; + + LLAppearanceMgrHttpHandler * handler = new LLAppearanceMgrHttpHandler(url, this); + + mInFlightCounter++; + mInFlightTimer.setTimerExpirySec(60.0); + + llassert(cof_version >= gAgentAvatarp->mLastUpdateRequestCOFVersion); + gAgentAvatarp->mLastUpdateRequestCOFVersion = cof_version; + + LLCore::HttpHandle handle = LLCoreHttpUtil::requestPostWithLLSD(mHttpRequest, + mHttpPolicy, mHttpPriority, url, + postData, mHttpOptions, mHttpHeaders, handler); + + if (handle == LLCORE_HTTP_HANDLE_INVALID) + { + delete handler; + LLCore::HttpStatus status = mHttpRequest->getStatus(); + LL_WARNS("Avatar") << "Appearance request post failed Reason " << status.toTerseString() + << " \"" << status.toString() << "\"" << LL_ENDL; + } +} + +bool LLAppearanceMgr::testCOFRequestVersion() const +{ + // If we have already received an update for this or higher cof version, ignore. + S32 cof_version = getCOFVersion(); + S32 last_rcv = gAgentAvatarp->mLastUpdateReceivedCOFVersion; + S32 last_req = gAgentAvatarp->mLastUpdateRequestCOFVersion; + + LL_DEBUGS("Avatar") << "cof_version " << cof_version + << " last_rcv " << last_rcv + << " last_req " << last_req + << " in flight " << mInFlightCounter + << LL_ENDL; + if (cof_version < last_rcv) + { + LL_DEBUGS("Avatar") << "Have already received update for cof version " << last_rcv + << " will not request for " << cof_version << LL_ENDL; + return false; + } + if (/*mInFlightCounter > 0 &&*/ last_req >= cof_version) + { + LL_DEBUGS("Avatar") << "Request already in flight for cof version " << last_req + << " will not request for " << cof_version << LL_ENDL; + return false; + } + + // Actually send the request. + LL_DEBUGS("Avatar") << "Will send request for cof_version " << cof_version << LL_ENDL; + return true; +} + +bool LLAppearanceMgr::onIdle() +{ + if (!LLAppearanceMgr::mActive) return true; - } + mHttpRequest->update(0L); return false; } - - -bool LLAppearanceMgr::moveWearable(LLViewerInventoryItem* item, bool closer_to_body) -{ - if (!item || !item->isWearableType()) return false; - if (item->getType() != LLAssetType::AT_CLOTHING) return false; - if (!gInventory.isObjectDescendentOf(item->getUUID(), getCOF())) return false; - - LLInventoryModel::cat_array_t cats; - LLInventoryModel::item_array_t items; - LLFindWearablesOfType filter_wearables_of_type(item->getWearableType()); - gInventory.collectDescendentsIf(getCOF(), cats, items, true, filter_wearables_of_type); - if (items.empty()) return false; - - // We assume that the items have valid descriptions. - std::sort(items.begin(), items.end(), WearablesOrderComparator(item->getWearableType())); - - if (closer_to_body && items.front() == item) return false; - if (!closer_to_body && items.back() == item) return false; - - LLInventoryModel::item_array_t::iterator it = std::find(items.begin(), items.end(), item); - if (items.end() == it) return false; - - - //swapping descriptions - closer_to_body ? --it : ++it; - LLViewerInventoryItem* swap_item = *it; - if (!swap_item) return false; - std::string tmp = swap_item->getActualDescription(); - swap_item->setDescription(item->getActualDescription()); - item->setDescription(tmp); - - // LL_DEBUGS("Inventory") << "swap, item " - // << ll_pretty_print_sd(item->asLLSD()) - // << " swap_item " - // << ll_pretty_print_sd(swap_item->asLLSD()) << LL_ENDL; - - // FIXME switch to use AISv3 where supported. - //items need to be updated on a dataserver - item->setComplete(TRUE); - item->updateServer(FALSE); - gInventory.updateItem(item); - - swap_item->setComplete(TRUE); - swap_item->updateServer(FALSE); - gInventory.updateItem(swap_item); - - //to cause appearance of the agent to be updated - bool result = false; - if ((result = gAgentWearables.moveWearable(item, closer_to_body))) - { - gAgentAvatarp->wearableUpdated(item->getWearableType()); - } - - setOutfitDirty(true); - - //*TODO do we need to notify observers here in such a way? - gInventory.notifyObservers(); - - return result; -} - -//static -void LLAppearanceMgr::sortItemsByActualDescription(LLInventoryModel::item_array_t& items) -{ - if (items.size() < 2) return; - - std::sort(items.begin(), items.end(), sort_by_actual_description); -} - -//#define DUMP_CAT_VERBOSE - -void LLAppearanceMgr::dumpCat(const LLUUID& cat_id, const std::string& msg) -{ - LLInventoryModel::cat_array_t cats; - LLInventoryModel::item_array_t items; - gInventory.collectDescendents(cat_id, cats, items, LLInventoryModel::EXCLUDE_TRASH); - -#ifdef DUMP_CAT_VERBOSE - LL_INFOS() << LL_ENDL; - LL_INFOS() << str << LL_ENDL; - S32 hitcount = 0; - for(S32 i=0; igetName() <getLinkedItem() : NULL; - LLUUID asset_id; - if (linked_item) - { - asset_id = linked_item->getAssetUUID(); - } - LL_DEBUGS("Avatar") << self_av_string() << msg << " " << i <<" " << (item ? item->getName() : "(nullitem)") << " " << asset_id.asString() << LL_ENDL; - } -} - -LLAppearanceMgr::LLAppearanceMgr(): - mAttachmentInvLinkEnabled(false), - mOutfitIsDirty(false), - mOutfitLocked(false), - mIsInUpdateAppearanceFromCOF(false), - mAppearanceResponder(new RequestAgentUpdateAppearanceResponder) -{ - LLOutfitObserver& outfit_observer = LLOutfitObserver::instance(); - - // unlock outfit on save operation completed - outfit_observer.addCOFSavedCallback(boost::bind( - &LLAppearanceMgr::setOutfitLocked, this, false)); - - mUnlockOutfitTimer.reset(new LLOutfitUnLockTimer(gSavedSettings.getS32( - "OutfitOperationsTimeout"))); - - gIdleCallbacks.addFunction(&LLAttachmentsMgr::onIdle,NULL); -} - -LLAppearanceMgr::~LLAppearanceMgr() -{ -} - -void LLAppearanceMgr::setAttachmentInvLinkEnable(bool val) -{ - LL_DEBUGS("Avatar") << "setAttachmentInvLinkEnable => " << (int) val << LL_ENDL; - mAttachmentInvLinkEnabled = val; -} - -void dumpAttachmentSet(const std::set& atts, const std::string& msg) -{ - LL_INFOS() << msg << LL_ENDL; - for (std::set::const_iterator it = atts.begin(); - it != atts.end(); - ++it) - { - LLUUID item_id = *it; - LLViewerInventoryItem *item = gInventory.getItem(item_id); - if (item) - LL_INFOS() << "atts " << item->getName() << LL_ENDL; - else - LL_INFOS() << "atts " << "UNKNOWN[" << item_id.asString() << "]" << LL_ENDL; - } - LL_INFOS() << LL_ENDL; -} - -void LLAppearanceMgr::registerAttachment(const LLUUID& item_id) -{ - gInventory.addChangedMask(LLInventoryObserver::LABEL, item_id); - - if (mAttachmentInvLinkEnabled) - { - // we have to pass do_update = true to call LLAppearanceMgr::updateAppearanceFromCOF. - // it will trigger gAgentWariables.notifyLoadingFinished() - // But it is not acceptable solution. See EXT-7777 - if (!isLinkedInCOF(item_id)) - { - LLPointer cb = new LLUpdateAppearanceOnDestroy(); - LLAppearanceMgr::addCOFItemLink(item_id, cb); // Add COF link for item. - } - } - else - { - //LL_INFOS() << "no link changes, inv link not enabled" << LL_ENDL; - } -} - -void LLAppearanceMgr::unregisterAttachment(const LLUUID& item_id) -{ - gInventory.addChangedMask(LLInventoryObserver::LABEL, item_id); - - if (mAttachmentInvLinkEnabled) - { - LLAppearanceMgr::removeCOFItemLinks(item_id); - } - else - { - //LL_INFOS() << "no link changes, inv link not enabled" << LL_ENDL; - } -} - -BOOL LLAppearanceMgr::getIsInCOF(const LLUUID& obj_id) const -{ - const LLUUID& cof = getCOF(); - if (obj_id == cof) - return TRUE; - const LLInventoryObject* obj = gInventory.getObject(obj_id); - if (obj && obj->getParentUUID() == cof) - return TRUE; - return FALSE; -} - -// static -bool LLAppearanceMgr::isLinkInCOF(const LLUUID& obj_id) -{ - const LLUUID& target_id = gInventory.getLinkedItemID(obj_id); - LLLinkedItemIDMatches find_links(target_id); - return gInventory.hasMatchingDirectDescendent(LLAppearanceMgr::instance().getCOF(), find_links); -} - -BOOL LLAppearanceMgr::getIsProtectedCOFItem(const LLUUID& obj_id) const -{ - if (!getIsInCOF(obj_id)) return FALSE; - - // If a non-link somehow ended up in COF, allow deletion. - const LLInventoryObject *obj = gInventory.getObject(obj_id); - if (obj && !obj->getIsLinkType()) - { - return FALSE; - } - - // For now, don't allow direct deletion from the COF. Instead, force users - // to choose "Detach" or "Take Off". - return TRUE; -} - -class CallAfterCategoryFetchStage2: public LLInventoryFetchItemsObserver -{ -public: - CallAfterCategoryFetchStage2(const uuid_vec_t& ids, - nullary_func_t callable) : - LLInventoryFetchItemsObserver(ids), - mCallable(callable) - { - } - ~CallAfterCategoryFetchStage2() - { - } - virtual void done() - { - LL_INFOS() << this << " done with incomplete " << mIncomplete.size() - << " complete " << mComplete.size() << " calling callable" << LL_ENDL; - - gInventory.removeObserver(this); - doOnIdleOneTime(mCallable); - delete this; - } -protected: - nullary_func_t mCallable; -}; - -class CallAfterCategoryFetchStage1: public LLInventoryFetchDescendentsObserver -{ -public: - CallAfterCategoryFetchStage1(const LLUUID& cat_id, nullary_func_t callable) : - LLInventoryFetchDescendentsObserver(cat_id), - mCallable(callable) - { - } - ~CallAfterCategoryFetchStage1() - { - } - virtual void done() - { - // What we do here is get the complete information on the - // items in the requested category, and set up an observer - // that will wait for that to happen. - LLInventoryModel::cat_array_t cat_array; - LLInventoryModel::item_array_t item_array; - gInventory.collectDescendents(mComplete.front(), - cat_array, - item_array, - LLInventoryModel::EXCLUDE_TRASH); - S32 count = item_array.size(); - if(!count) - { - LL_WARNS() << "Nothing fetched in category " << mComplete.front() - << LL_ENDL; - gInventory.removeObserver(this); - doOnIdleOneTime(mCallable); - - delete this; - return; - } - - LL_INFOS() << "stage1 got " << item_array.size() << " items, passing to stage2 " << LL_ENDL; - uuid_vec_t ids; - for(S32 i = 0; i < count; ++i) - { - ids.push_back(item_array.at(i)->getUUID()); - } - - gInventory.removeObserver(this); - - // do the fetch - CallAfterCategoryFetchStage2 *stage2 = new CallAfterCategoryFetchStage2(ids, mCallable); - stage2->startFetch(); - if(stage2->isFinished()) - { - // everything is already here - call done. - stage2->done(); - } - else - { - // it's all on it's way - add an observer, and the inventory - // will call done for us when everything is here. - gInventory.addObserver(stage2); - } - delete this; - } -protected: - nullary_func_t mCallable; -}; - -void callAfterCategoryFetch(const LLUUID& cat_id, nullary_func_t cb) -{ - CallAfterCategoryFetchStage1 *stage1 = new CallAfterCategoryFetchStage1(cat_id, cb); - stage1->startFetch(); - if (stage1->isFinished()) - { - stage1->done(); - } - else - { - gInventory.addObserver(stage1); - } -} - -void wear_multiple(const uuid_vec_t& ids, bool replace) -{ - LLPointer cb = new LLUpdateAppearanceOnDestroy; - - bool first = true; - uuid_vec_t::const_iterator it; - for (it = ids.begin(); it != ids.end(); ++it) - { - // if replace is requested, the first item worn will replace the current top - // item, and others will be added. - LLAppearanceMgr::instance().wearItemOnAvatar(*it,false,first && replace,cb); - first = false; - } -} - -// SLapp for easy-wearing of a stock (library) avatar -// -class LLWearFolderHandler : public LLCommandHandler -{ -public: - // not allowed from outside the app - LLWearFolderHandler() : LLCommandHandler("wear_folder", UNTRUSTED_BLOCK) { } - - bool handle(const LLSD& tokens, const LLSD& query_map, - LLMediaCtrl* web) - { - LLSD::UUID folder_uuid; - - if (folder_uuid.isNull() && query_map.has("folder_name")) - { - std::string outfit_folder_name = query_map["folder_name"]; - folder_uuid = findDescendentCategoryIDByName( - gInventory.getLibraryRootFolderID(), - outfit_folder_name); - } - if (folder_uuid.isNull() && query_map.has("folder_id")) - { - folder_uuid = query_map["folder_id"].asUUID(); - } - - if (folder_uuid.notNull()) - { - LLPointer category = new LLInventoryCategory(folder_uuid, - LLUUID::null, - LLFolderType::FT_CLOTHING, - "Quick Appearance"); - if ( gInventory.getCategory( folder_uuid ) != NULL ) - { - LLAppearanceMgr::getInstance()->wearInventoryCategory(category, true, false); - - // *TODOw: This may not be necessary if initial outfit is chosen already -- josh - gAgent.setOutfitChosen(TRUE); - } - } - - // release avatar picker keyboard focus - gFocusMgr.setKeyboardFocus( NULL ); - - return true; - } -}; - -LLWearFolderHandler gWearFolderHandler; + +class LLIncrementCofVersionResponder : public LLHTTPClient::Responder +{ + LOG_CLASS(LLIncrementCofVersionResponder); +public: + LLIncrementCofVersionResponder() : LLHTTPClient::Responder() + { + mRetryPolicy = new LLAdaptiveRetryPolicy(1.0, 16.0, 2.0, 5); + } + + virtual ~LLIncrementCofVersionResponder() + { + } + +protected: + virtual void httpSuccess() + { + LL_INFOS() << "Successfully incremented agent's COF." << LL_ENDL; + const LLSD& content = getContent(); + if (!content.isMap()) + { + failureResult(HTTP_INTERNAL_ERROR, "Malformed response contents", content); + return; + } + S32 new_version = content["category"]["version"].asInteger(); + + // cof_version should have increased + llassert(new_version > gAgentAvatarp->mLastUpdateRequestCOFVersion); + + gAgentAvatarp->mLastUpdateRequestCOFVersion = new_version; + } + + virtual void httpFailure() + { + LL_WARNS("Avatar") << "While attempting to increment the agent's cof we got an error " + << dumpResponse() << LL_ENDL; + F32 seconds_to_wait; + mRetryPolicy->onFailure(getStatus(), getResponseHeaders()); + if (mRetryPolicy->shouldRetry(seconds_to_wait)) + { + LL_INFOS() << "retrying" << LL_ENDL; + doAfterInterval(boost::bind(&LLAppearanceMgr::incrementCofVersion, + LLAppearanceMgr::getInstance(), + LLHTTPClient::ResponderPtr(this)), + seconds_to_wait); + } + else + { + LL_WARNS() << "giving up after too many retries" << LL_ENDL; + } + } + +private: + LLPointer mRetryPolicy; +}; + +void LLAppearanceMgr::incrementCofVersion(LLHTTPClient::ResponderPtr responder_ptr) +{ + // If we don't have a region, report it as an error + if (gAgent.getRegion() == NULL) + { + LL_WARNS() << "Region not set, cannot request cof_version increment" << LL_ENDL; + return; + } + + std::string url = gAgent.getRegion()->getCapability("IncrementCofVersion"); + if (url.empty()) + { + LL_WARNS() << "No cap for IncrementCofVersion." << LL_ENDL; + return; + } + + LL_INFOS() << "Requesting cof_version be incremented via capability to: " + << url << LL_ENDL; + LLSD headers; + LLSD body = LLSD::emptyMap(); + + if (!responder_ptr.get()) + { + responder_ptr = LLHTTPClient::ResponderPtr(new LLIncrementCofVersionResponder()); + } + + LLHTTPClient::get(url, body, responder_ptr, headers, 30.0f); +} + +U32 LLAppearanceMgr::getNumAttachmentsInCOF() +{ + const LLUUID cof = getCOF(); + LLInventoryModel::item_array_t obj_items; + getDescendentsOfAssetType(cof, obj_items, LLAssetType::AT_OBJECT); + return obj_items.size(); +} + + +std::string LLAppearanceMgr::getAppearanceServiceURL() const +{ + if (gSavedSettings.getString("DebugAvatarAppearanceServiceURLOverride").empty()) + { + return mAppearanceServiceURL; + } + return gSavedSettings.getString("DebugAvatarAppearanceServiceURLOverride"); +} + +void show_created_outfit(LLUUID& folder_id, bool show_panel = true) +{ + if (!LLApp::isRunning()) + { + LL_WARNS() << "called during shutdown, skipping" << LL_ENDL; + return; + } + + LL_DEBUGS("Avatar") << "called" << LL_ENDL; + LLSD key; + + //EXT-7727. For new accounts inventory callback is created during login process + // and may be processed after login process is finished + if (show_panel) + { + LL_DEBUGS("Avatar") << "showing panel" << LL_ENDL; + LLFloaterSidePanelContainer::showPanel("appearance", "panel_outfits_inventory", key); + + } + LLOutfitsList *outfits_list = + dynamic_cast(LLFloaterSidePanelContainer::getPanel("appearance", "outfitslist_tab")); + if (outfits_list) + { + outfits_list->setSelectedOutfitByUUID(folder_id); + } + + LLAppearanceMgr::getInstance()->updateIsDirty(); + gAgentWearables.notifyLoadingFinished(); // New outfit is saved. + LLAppearanceMgr::getInstance()->updatePanelOutfitName(""); + + // For SSB, need to update appearance after we add a base outfit + // link, since, the COF version has changed. There is a race + // condition in initial outfit setup which can lead to rez + // failures - SH-3860. + LL_DEBUGS("Avatar") << "requesting appearance update after createBaseOutfitLink" << LL_ENDL; + LLPointer cb = new LLUpdateAppearanceOnDestroy; + LLAppearanceMgr::getInstance()->createBaseOutfitLink(folder_id, cb); +} + +void LLAppearanceMgr::onOutfitFolderCreated(const LLUUID& folder_id, bool show_panel) +{ + LLPointer cb = + new LLBoostFuncInventoryCallback(no_op_inventory_func, + boost::bind(&LLAppearanceMgr::onOutfitFolderCreatedAndClothingOrdered,this,folder_id,show_panel)); + updateClothingOrderingInfo(LLUUID::null, cb); +} + +void LLAppearanceMgr::onOutfitFolderCreatedAndClothingOrdered(const LLUUID& folder_id, bool show_panel) +{ + LLPointer cb = + new LLBoostFuncInventoryCallback(no_op_inventory_func, + boost::bind(show_created_outfit,folder_id,show_panel)); + bool copy_folder_links = false; + slamCategoryLinks(getCOF(), folder_id, copy_folder_links, cb); +} + +void LLAppearanceMgr::makeNewOutfitLinks(const std::string& new_folder_name, bool show_panel) +{ + if (!isAgentAvatarValid()) return; + + LL_DEBUGS("Avatar") << "creating new outfit" << LL_ENDL; + + gAgentWearables.notifyLoadingStarted(); + + // First, make a folder in the My Outfits directory. + const LLUUID parent_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_MY_OUTFITS); + if (AISCommand::isAPIAvailable()) + { + // cap-based category creation was buggy until recently. use + // existence of AIS as an indicator the fix is present. Does + // not actually use AIS to create the category. + inventory_func_type func = boost::bind(&LLAppearanceMgr::onOutfitFolderCreated,this,_1,show_panel); + LLUUID folder_id = gInventory.createNewCategory( + parent_id, + LLFolderType::FT_OUTFIT, + new_folder_name, + func); + } + else + { + LLUUID folder_id = gInventory.createNewCategory( + parent_id, + LLFolderType::FT_OUTFIT, + new_folder_name); + onOutfitFolderCreated(folder_id, show_panel); + } +} + +void LLAppearanceMgr::wearBaseOutfit() +{ + const LLUUID& base_outfit_id = getBaseOutfitUUID(); + if (base_outfit_id.isNull()) return; + + updateCOF(base_outfit_id); +} + +void LLAppearanceMgr::removeItemsFromAvatar(const uuid_vec_t& ids_to_remove) +{ + if (ids_to_remove.empty()) + { + LL_WARNS() << "called with empty list, nothing to do" << LL_ENDL; + return; + } + LLPointer cb = new LLUpdateAppearanceOnDestroy; + for (uuid_vec_t::const_iterator it = ids_to_remove.begin(); it != ids_to_remove.end(); ++it) + { + const LLUUID& id_to_remove = *it; + const LLUUID& linked_item_id = gInventory.getLinkedItemID(id_to_remove); + removeCOFItemLinks(linked_item_id, cb); + addDoomedTempAttachment(linked_item_id); + } +} + +void LLAppearanceMgr::removeItemFromAvatar(const LLUUID& id_to_remove) +{ + LLUUID linked_item_id = gInventory.getLinkedItemID(id_to_remove); + LLPointer cb = new LLUpdateAppearanceOnDestroy; + removeCOFItemLinks(linked_item_id, cb); + addDoomedTempAttachment(linked_item_id); +} + + +// Adds the given item ID to mDoomedTempAttachmentIDs iff it's a temp attachment +void LLAppearanceMgr::addDoomedTempAttachment(const LLUUID& id_to_remove) +{ + LLViewerObject * attachmentp = gAgentAvatarp->findAttachmentByID(id_to_remove); + if (attachmentp && + attachmentp->isTempAttachment()) + { // If this is a temp attachment and we want to remove it, record the ID + // so it will be deleted when attachments are synced up with COF + mDoomedTempAttachmentIDs.insert(id_to_remove); + //LL_INFOS() << "Will remove temp attachment id " << id_to_remove << LL_ENDL; + } +} + +// Find AND REMOVES the given UUID from mDoomedTempAttachmentIDs +bool LLAppearanceMgr::shouldRemoveTempAttachment(const LLUUID& item_id) +{ + doomed_temp_attachments_t::iterator iter = mDoomedTempAttachmentIDs.find(item_id); + if (iter != mDoomedTempAttachmentIDs.end()) + { + mDoomedTempAttachmentIDs.erase(iter); + return true; + } + return false; +} + + +bool LLAppearanceMgr::moveWearable(LLViewerInventoryItem* item, bool closer_to_body) +{ + if (!item || !item->isWearableType()) return false; + if (item->getType() != LLAssetType::AT_CLOTHING) return false; + if (!gInventory.isObjectDescendentOf(item->getUUID(), getCOF())) return false; + + LLInventoryModel::cat_array_t cats; + LLInventoryModel::item_array_t items; + LLFindWearablesOfType filter_wearables_of_type(item->getWearableType()); + gInventory.collectDescendentsIf(getCOF(), cats, items, true, filter_wearables_of_type); + if (items.empty()) return false; + + // We assume that the items have valid descriptions. + std::sort(items.begin(), items.end(), WearablesOrderComparator(item->getWearableType())); + + if (closer_to_body && items.front() == item) return false; + if (!closer_to_body && items.back() == item) return false; + + LLInventoryModel::item_array_t::iterator it = std::find(items.begin(), items.end(), item); + if (items.end() == it) return false; + + + //swapping descriptions + closer_to_body ? --it : ++it; + LLViewerInventoryItem* swap_item = *it; + if (!swap_item) return false; + std::string tmp = swap_item->getActualDescription(); + swap_item->setDescription(item->getActualDescription()); + item->setDescription(tmp); + + // LL_DEBUGS("Inventory") << "swap, item " + // << ll_pretty_print_sd(item->asLLSD()) + // << " swap_item " + // << ll_pretty_print_sd(swap_item->asLLSD()) << LL_ENDL; + + // FIXME switch to use AISv3 where supported. + //items need to be updated on a dataserver + item->setComplete(TRUE); + item->updateServer(FALSE); + gInventory.updateItem(item); + + swap_item->setComplete(TRUE); + swap_item->updateServer(FALSE); + gInventory.updateItem(swap_item); + + //to cause appearance of the agent to be updated + bool result = false; + if ((result = gAgentWearables.moveWearable(item, closer_to_body))) + { + gAgentAvatarp->wearableUpdated(item->getWearableType()); + } + + setOutfitDirty(true); + + //*TODO do we need to notify observers here in such a way? + gInventory.notifyObservers(); + + return result; +} + +//static +void LLAppearanceMgr::sortItemsByActualDescription(LLInventoryModel::item_array_t& items) +{ + if (items.size() < 2) return; + + std::sort(items.begin(), items.end(), sort_by_actual_description); +} + +//#define DUMP_CAT_VERBOSE + +void LLAppearanceMgr::dumpCat(const LLUUID& cat_id, const std::string& msg) +{ + LLInventoryModel::cat_array_t cats; + LLInventoryModel::item_array_t items; + gInventory.collectDescendents(cat_id, cats, items, LLInventoryModel::EXCLUDE_TRASH); + +#ifdef DUMP_CAT_VERBOSE + LL_INFOS() << LL_ENDL; + LL_INFOS() << str << LL_ENDL; + S32 hitcount = 0; + for(S32 i=0; igetName() <getLinkedItem() : NULL; + LLUUID asset_id; + if (linked_item) + { + asset_id = linked_item->getAssetUUID(); + } + LL_DEBUGS("Avatar") << self_av_string() << msg << " " << i <<" " << (item ? item->getName() : "(nullitem)") << " " << asset_id.asString() << LL_ENDL; + } +} + +bool LLAppearanceMgr::mActive = true; + +LLAppearanceMgr::LLAppearanceMgr(): + mAttachmentInvLinkEnabled(false), + mOutfitIsDirty(false), + mOutfitLocked(false), + mInFlightCounter(0), + mInFlightTimer(), + mIsInUpdateAppearanceFromCOF(false), + //mAppearanceResponder(new RequestAgentUpdateAppearanceResponder), + mHttpRequest(), + mHttpHeaders(), + mHttpOptions(), + mHttpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID), + mHttpPriority(0) +{ + LLAppCoreHttp & app_core_http(LLAppViewer::instance()->getAppCoreHttp()); + + mHttpRequest = LLCore::HttpRequest::ptr_t(new LLCore::HttpRequest()); + mHttpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false); + mHttpOptions = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false); + mHttpPolicy = app_core_http.getPolicy(LLAppCoreHttp::AP_AVATAR); + + LLOutfitObserver& outfit_observer = LLOutfitObserver::instance(); + // unlock outfit on save operation completed + outfit_observer.addCOFSavedCallback(boost::bind( + &LLAppearanceMgr::setOutfitLocked, this, false)); + + mUnlockOutfitTimer.reset(new LLOutfitUnLockTimer(gSavedSettings.getS32( + "OutfitOperationsTimeout"))); + + gIdleCallbacks.addFunction(&LLAttachmentsMgr::onIdle, NULL); + doOnIdleRepeating(boost::bind(&LLAppearanceMgr::onIdle, this)); +} + +LLAppearanceMgr::~LLAppearanceMgr() +{ + mActive = false; +} + +void LLAppearanceMgr::setAttachmentInvLinkEnable(bool val) +{ + LL_DEBUGS("Avatar") << "setAttachmentInvLinkEnable => " << (int) val << LL_ENDL; + mAttachmentInvLinkEnabled = val; +} + +void dumpAttachmentSet(const std::set& atts, const std::string& msg) +{ + LL_INFOS() << msg << LL_ENDL; + for (std::set::const_iterator it = atts.begin(); + it != atts.end(); + ++it) + { + LLUUID item_id = *it; + LLViewerInventoryItem *item = gInventory.getItem(item_id); + if (item) + LL_INFOS() << "atts " << item->getName() << LL_ENDL; + else + LL_INFOS() << "atts " << "UNKNOWN[" << item_id.asString() << "]" << LL_ENDL; + } + LL_INFOS() << LL_ENDL; +} + +void LLAppearanceMgr::registerAttachment(const LLUUID& item_id) +{ + gInventory.addChangedMask(LLInventoryObserver::LABEL, item_id); + + if (mAttachmentInvLinkEnabled) + { + // we have to pass do_update = true to call LLAppearanceMgr::updateAppearanceFromCOF. + // it will trigger gAgentWariables.notifyLoadingFinished() + // But it is not acceptable solution. See EXT-7777 + if (!isLinkedInCOF(item_id)) + { + LLPointer cb = new LLUpdateAppearanceOnDestroy(); + LLAppearanceMgr::addCOFItemLink(item_id, cb); // Add COF link for item. + } + } + else + { + //LL_INFOS() << "no link changes, inv link not enabled" << LL_ENDL; + } +} + +void LLAppearanceMgr::unregisterAttachment(const LLUUID& item_id) +{ + gInventory.addChangedMask(LLInventoryObserver::LABEL, item_id); + + if (mAttachmentInvLinkEnabled) + { + LLAppearanceMgr::removeCOFItemLinks(item_id); + } + else + { + //LL_INFOS() << "no link changes, inv link not enabled" << LL_ENDL; + } +} + +BOOL LLAppearanceMgr::getIsInCOF(const LLUUID& obj_id) const +{ + const LLUUID& cof = getCOF(); + if (obj_id == cof) + return TRUE; + const LLInventoryObject* obj = gInventory.getObject(obj_id); + if (obj && obj->getParentUUID() == cof) + return TRUE; + return FALSE; +} + +// static +bool LLAppearanceMgr::isLinkInCOF(const LLUUID& obj_id) +{ + const LLUUID& target_id = gInventory.getLinkedItemID(obj_id); + LLLinkedItemIDMatches find_links(target_id); + return gInventory.hasMatchingDirectDescendent(LLAppearanceMgr::instance().getCOF(), find_links); +} + +BOOL LLAppearanceMgr::getIsProtectedCOFItem(const LLUUID& obj_id) const +{ + if (!getIsInCOF(obj_id)) return FALSE; + + // If a non-link somehow ended up in COF, allow deletion. + const LLInventoryObject *obj = gInventory.getObject(obj_id); + if (obj && !obj->getIsLinkType()) + { + return FALSE; + } + + // For now, don't allow direct deletion from the COF. Instead, force users + // to choose "Detach" or "Take Off". + return TRUE; +} + +class CallAfterCategoryFetchStage2: public LLInventoryFetchItemsObserver +{ +public: + CallAfterCategoryFetchStage2(const uuid_vec_t& ids, + nullary_func_t callable) : + LLInventoryFetchItemsObserver(ids), + mCallable(callable) + { + } + ~CallAfterCategoryFetchStage2() + { + } + virtual void done() + { + LL_INFOS() << this << " done with incomplete " << mIncomplete.size() + << " complete " << mComplete.size() << " calling callable" << LL_ENDL; + + gInventory.removeObserver(this); + doOnIdleOneTime(mCallable); + delete this; + } +protected: + nullary_func_t mCallable; +}; + +class CallAfterCategoryFetchStage1: public LLInventoryFetchDescendentsObserver +{ +public: + CallAfterCategoryFetchStage1(const LLUUID& cat_id, nullary_func_t callable) : + LLInventoryFetchDescendentsObserver(cat_id), + mCallable(callable) + { + } + ~CallAfterCategoryFetchStage1() + { + } + virtual void done() + { + // What we do here is get the complete information on the + // items in the requested category, and set up an observer + // that will wait for that to happen. + LLInventoryModel::cat_array_t cat_array; + LLInventoryModel::item_array_t item_array; + gInventory.collectDescendents(mComplete.front(), + cat_array, + item_array, + LLInventoryModel::EXCLUDE_TRASH); + S32 count = item_array.size(); + if(!count) + { + LL_WARNS() << "Nothing fetched in category " << mComplete.front() + << LL_ENDL; + gInventory.removeObserver(this); + doOnIdleOneTime(mCallable); + + delete this; + return; + } + + LL_INFOS() << "stage1 got " << item_array.size() << " items, passing to stage2 " << LL_ENDL; + uuid_vec_t ids; + for(S32 i = 0; i < count; ++i) + { + ids.push_back(item_array.at(i)->getUUID()); + } + + gInventory.removeObserver(this); + + // do the fetch + CallAfterCategoryFetchStage2 *stage2 = new CallAfterCategoryFetchStage2(ids, mCallable); + stage2->startFetch(); + if(stage2->isFinished()) + { + // everything is already here - call done. + stage2->done(); + } + else + { + // it's all on it's way - add an observer, and the inventory + // will call done for us when everything is here. + gInventory.addObserver(stage2); + } + delete this; + } +protected: + nullary_func_t mCallable; +}; + +void callAfterCategoryFetch(const LLUUID& cat_id, nullary_func_t cb) +{ + CallAfterCategoryFetchStage1 *stage1 = new CallAfterCategoryFetchStage1(cat_id, cb); + stage1->startFetch(); + if (stage1->isFinished()) + { + stage1->done(); + } + else + { + gInventory.addObserver(stage1); + } +} + +void wear_multiple(const uuid_vec_t& ids, bool replace) +{ + LLPointer cb = new LLUpdateAppearanceOnDestroy; + + bool first = true; + uuid_vec_t::const_iterator it; + for (it = ids.begin(); it != ids.end(); ++it) + { + // if replace is requested, the first item worn will replace the current top + // item, and others will be added. + LLAppearanceMgr::instance().wearItemOnAvatar(*it,false,first && replace,cb); + first = false; + } +} + +// SLapp for easy-wearing of a stock (library) avatar +// +class LLWearFolderHandler : public LLCommandHandler +{ +public: + // not allowed from outside the app + LLWearFolderHandler() : LLCommandHandler("wear_folder", UNTRUSTED_BLOCK) { } + + bool handle(const LLSD& tokens, const LLSD& query_map, + LLMediaCtrl* web) + { + LLSD::UUID folder_uuid; + + if (folder_uuid.isNull() && query_map.has("folder_name")) + { + std::string outfit_folder_name = query_map["folder_name"]; + folder_uuid = findDescendentCategoryIDByName( + gInventory.getLibraryRootFolderID(), + outfit_folder_name); + } + if (folder_uuid.isNull() && query_map.has("folder_id")) + { + folder_uuid = query_map["folder_id"].asUUID(); + } + + if (folder_uuid.notNull()) + { + LLPointer category = new LLInventoryCategory(folder_uuid, + LLUUID::null, + LLFolderType::FT_CLOTHING, + "Quick Appearance"); + if ( gInventory.getCategory( folder_uuid ) != NULL ) + { + LLAppearanceMgr::getInstance()->wearInventoryCategory(category, true, false); + + // *TODOw: This may not be necessary if initial outfit is chosen already -- josh + gAgent.setOutfitChosen(TRUE); + } + } + + // release avatar picker keyboard focus + gFocusMgr.setKeyboardFocus( NULL ); + + return true; + } +}; + +LLWearFolderHandler gWearFolderHandler; diff --git a/indra/newview/llappearancemgr.h b/indra/newview/llappearancemgr.h index 7742a19c07..74d4829ed2 100755 --- a/indra/newview/llappearancemgr.h +++ b/indra/newview/llappearancemgr.h @@ -225,9 +225,22 @@ public: void setAppearanceServiceURL(const std::string& url) { mAppearanceServiceURL = url; } std::string getAppearanceServiceURL() const; + + bool testCOFRequestVersion() const; + void LLAppearanceMgr::decrementInFlightCounter() + { + mInFlightCounter = llmax(mInFlightCounter - 1, 0); + } + + private: std::string mAppearanceServiceURL; + LLCore::HttpRequest::ptr_t mHttpRequest; + LLCore::HttpHeaders::ptr_t mHttpHeaders; + LLCore::HttpOptions::ptr_t mHttpOptions; + LLCore::HttpRequest::policy_t mHttpPolicy; + LLCore::HttpRequest::priority_t mHttpPriority; protected: LLAppearanceMgr(); @@ -248,17 +261,20 @@ private: static void onOutfitRename(const LLSD& notification, const LLSD& response); + bool onIdle(); + bool mAttachmentInvLinkEnabled; bool mOutfitIsDirty; bool mIsInUpdateAppearanceFromCOF; // to detect recursive calls. - LLPointer mAppearanceResponder; - /** * Lock for blocking operations on outfit until server reply or timeout exceed * to avoid unsynchronized outfit state or performing duplicate operations. */ bool mOutfitLocked; + S32 mInFlightCounter; + LLTimer mInFlightTimer; + static bool mActive; std::auto_ptr mUnlockOutfitTimer; diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index 81372f10b3..065d763596 100755 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -660,7 +660,7 @@ void LLMaterialMgr::processGetQueue() LL_DEBUGS("Materials") << "POSTing to region '" << regionp->getName() << "' at '" << capURL << " for " << materialsData.size() << " materials." << "\ndata: " << ll_pretty_print_sd(materialsData) << LL_ENDL; - LLCore::HttpHandle handle = LLCoreHttpUtil::requestPutWithLLSD(mHttpRequest, + LLCore::HttpHandle handle = LLCoreHttpUtil::requestPostWithLLSD(mHttpRequest, mHttpPolicy, mHttpPriority, capURL, postData, mHttpOptions, mHttpHeaders, handler); diff --git a/indra/newview/llxmlrpctransaction.cpp b/indra/newview/llxmlrpctransaction.cpp index f7b886b2d2..702d0c3a29 100755 --- a/indra/newview/llxmlrpctransaction.cpp +++ b/indra/newview/llxmlrpctransaction.cpp @@ -401,14 +401,6 @@ LLXMLRPCTransaction::Impl::~Impl() { XMLRPC_RequestFree(mResponse, 1); } - - //if (mRequestText) - //{ - // XMLRPC_Free(mRequestText); - //} - - //delete mCurlRequest; - //mCurlRequest = NULL ; } bool LLXMLRPCTransaction::Impl::process() -- cgit v1.2.3 From 281d1166cb302679bb2b1375bab9b238d59fdb87 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 25 Mar 2015 13:02:52 -0700 Subject: gcc remove extra qualification on decrementInFlightCounter static. --- indra/newview/llappearancemgr.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/llappearancemgr.h b/indra/newview/llappearancemgr.h index 74d4829ed2..812d3c366c 100755 --- a/indra/newview/llappearancemgr.h +++ b/indra/newview/llappearancemgr.h @@ -227,7 +227,7 @@ public: bool testCOFRequestVersion() const; - void LLAppearanceMgr::decrementInFlightCounter() + void decrementInFlightCounter() { mInFlightCounter = llmax(mInFlightCounter - 1, 0); } -- cgit v1.2.3 From 77a9d183aa94496bd3e7d354f0744d0509bc3734 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 25 Mar 2015 14:49:44 -0700 Subject: Some slight reorganization and removal of some dead code. --- indra/newview/llappearancemgr.cpp | 411 +++++++++++++++----------------------- indra/newview/llappearancemgr.h | 9 - 2 files changed, 159 insertions(+), 261 deletions(-) (limited to 'indra') diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp index 077e944925..dbc858bdb0 100755 --- a/indra/newview/llappearancemgr.cpp +++ b/indra/newview/llappearancemgr.cpp @@ -1245,6 +1245,165 @@ static void removeDuplicateItems(LLInventoryModel::item_array_t& items) items = new_items; } +//========================================================================= +class LLAppearanceMgrHttpHandler : public LLHttpSDHandler +{ +public: + LLAppearanceMgrHttpHandler(const std::string& capabilityURL, LLAppearanceMgr *mgr) : + LLHttpSDHandler(capabilityURL), + mManager(mgr) + { } + + virtual ~LLAppearanceMgrHttpHandler() + { } + + virtual void onCompleted(LLCore::HttpHandle handle, LLCore::HttpResponse * response); + +protected: + virtual void onSuccess(LLCore::HttpResponse * response, LLSD &content); + virtual void onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status); + +private: + static void debugCOF(const LLSD& content); + + LLAppearanceMgr *mManager; + +}; + +//------------------------------------------------------------------------- +void LLAppearanceMgrHttpHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpResponse * response) +{ + mManager->decrementInFlightCounter(); + + LLHttpSDHandler::onCompleted(handle, response); +} + +void LLAppearanceMgrHttpHandler::onSuccess(LLCore::HttpResponse * response, LLSD &content) +{ + if (!content.isMap()) + { + LLCore::HttpStatus status = LLCore::HttpStatus(HTTP_INTERNAL_ERROR, "Malformed response contents"); + response->setStatus(status); + onFailure(response, status); + if (gSavedSettings.getBOOL("DebugAvatarAppearanceMessage")) + { + debugCOF(content); + } + return; + } + if (content["success"].asBoolean()) + { + LL_DEBUGS("Avatar") << "succeeded" << LL_ENDL; + if (gSavedSettings.getBOOL("DebugAvatarAppearanceMessage")) + { + dump_sequential_xml(gAgentAvatarp->getFullname() + "_appearance_request_ok", content); + } + } + else + { + LLCore::HttpStatus status = LLCore::HttpStatus(HTTP_INTERNAL_ERROR, "Non-success response"); + response->setStatus(status); + onFailure(response, status); + if (gSavedSettings.getBOOL("DebugAvatarAppearanceMessage")) + { + debugCOF(content); + } + return; + } +} + +void LLAppearanceMgrHttpHandler::onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status) +{ + LL_WARNS("Avatar") << "Appearance Mgr request failed to " << getUri() + << ". Reason code: (" << status.toTerseString() << ") " + << status.toString() << LL_ENDL; +} + +void LLAppearanceMgrHttpHandler::debugCOF(const LLSD& content) +{ + dump_sequential_xml(gAgentAvatarp->getFullname() + "_appearance_request_error", content); + + LL_INFOS("Avatar") << "AIS COF, version received: " << content["expected"].asInteger() + << " ================================= " << LL_ENDL; + std::set ais_items, local_items; + const LLSD& cof_raw = content["cof_raw"]; + for (LLSD::array_const_iterator it = cof_raw.beginArray(); + it != cof_raw.endArray(); ++it) + { + const LLSD& item = *it; + if (item["parent_id"].asUUID() == LLAppearanceMgr::instance().getCOF()) + { + ais_items.insert(item["item_id"].asUUID()); + if (item["type"].asInteger() == 24) // link + { + LL_INFOS("Avatar") << "AIS Link: item_id: " << item["item_id"].asUUID() + << " linked_item_id: " << item["asset_id"].asUUID() + << " name: " << item["name"].asString() + << LL_ENDL; + } + else if (item["type"].asInteger() == 25) // folder link + { + LL_INFOS("Avatar") << "AIS Folder link: item_id: " << item["item_id"].asUUID() + << " linked_item_id: " << item["asset_id"].asUUID() + << " name: " << item["name"].asString() + << LL_ENDL; + } + else + { + LL_INFOS("Avatar") << "AIS Other: item_id: " << item["item_id"].asUUID() + << " linked_item_id: " << item["asset_id"].asUUID() + << " name: " << item["name"].asString() + << " type: " << item["type"].asInteger() + << LL_ENDL; + } + } + } + LL_INFOS("Avatar") << LL_ENDL; + LL_INFOS("Avatar") << "Local COF, version requested: " << content["observed"].asInteger() + << " ================================= " << LL_ENDL; + LLInventoryModel::cat_array_t cat_array; + LLInventoryModel::item_array_t item_array; + gInventory.collectDescendents(LLAppearanceMgr::instance().getCOF(), + cat_array, item_array, LLInventoryModel::EXCLUDE_TRASH); + for (S32 i = 0; i < item_array.size(); i++) + { + const LLViewerInventoryItem* inv_item = item_array.at(i).get(); + local_items.insert(inv_item->getUUID()); + LL_INFOS("Avatar") << "LOCAL: item_id: " << inv_item->getUUID() + << " linked_item_id: " << inv_item->getLinkedUUID() + << " name: " << inv_item->getName() + << " parent: " << inv_item->getParentUUID() + << LL_ENDL; + } + LL_INFOS("Avatar") << " ================================= " << LL_ENDL; + S32 local_only = 0, ais_only = 0; + for (std::set::iterator it = local_items.begin(); it != local_items.end(); ++it) + { + if (ais_items.find(*it) == ais_items.end()) + { + LL_INFOS("Avatar") << "LOCAL ONLY: " << *it << LL_ENDL; + local_only++; + } + } + for (std::set::iterator it = ais_items.begin(); it != ais_items.end(); ++it) + { + if (local_items.find(*it) == local_items.end()) + { + LL_INFOS("Avatar") << "AIS ONLY: " << *it << LL_ENDL; + ais_only++; + } + } + if (local_only == 0 && ais_only == 0) + { + LL_INFOS("Avatar") << "COF contents identical, only version numbers differ (req " + << content["observed"].asInteger() + << " rcv " << content["expected"].asInteger() + << ")" << LL_ENDL; + } +} + +//========================================================================= + const LLUUID LLAppearanceMgr::getCOF() const { return gInventory.findCategoryUUIDForType(LLFolderType::FT_CURRENT_OUTFIT); @@ -3157,165 +3316,6 @@ void LLAppearanceMgr::updateClothingOrderingInfo(LLUUID cat_id, } -//========================================================================= -class LLAppearanceMgrHttpHandler : public LLHttpSDHandler -{ -public: - LLAppearanceMgrHttpHandler(const std::string& capabilityURL, LLAppearanceMgr *mgr) : - LLHttpSDHandler(capabilityURL), - mManager(mgr) - { } - - virtual ~LLAppearanceMgrHttpHandler() - { } - - virtual void onCompleted(LLCore::HttpHandle handle, LLCore::HttpResponse * response); - -protected: - virtual void onSuccess(LLCore::HttpResponse * response, LLSD &content); - virtual void onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status); - -private: - static void debugCOF(const LLSD& content); - - LLAppearanceMgr *mManager; - -}; - -//------------------------------------------------------------------------- -void LLAppearanceMgrHttpHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpResponse * response) -{ - mManager->decrementInFlightCounter(); - - LLHttpSDHandler::onCompleted(handle, response); -} - -void LLAppearanceMgrHttpHandler::onSuccess(LLCore::HttpResponse * response, LLSD &content) -{ - if (!content.isMap()) - { - LLCore::HttpStatus status = LLCore::HttpStatus(HTTP_INTERNAL_ERROR, "Malformed response contents"); - response->setStatus(status); - onFailure(response, status); - if (gSavedSettings.getBOOL("DebugAvatarAppearanceMessage")) - { - debugCOF(content); - } - return; - } - if (content["success"].asBoolean()) - { - LL_DEBUGS("Avatar") << "succeeded" << LL_ENDL; - if (gSavedSettings.getBOOL("DebugAvatarAppearanceMessage")) - { - dump_sequential_xml(gAgentAvatarp->getFullname() + "_appearance_request_ok", content); - } - } - else - { - LLCore::HttpStatus status = LLCore::HttpStatus(HTTP_INTERNAL_ERROR, "Non-success response"); - response->setStatus(status); - onFailure(response, status); - if (gSavedSettings.getBOOL("DebugAvatarAppearanceMessage")) - { - debugCOF(content); - } - return; - } -} - -void LLAppearanceMgrHttpHandler::onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status) -{ - LL_WARNS("Avatar") << "Appearance Mgr request failed to " << getUri() - << ". Reason code: (" << status.toTerseString() << ") " - << status.toString() << LL_ENDL; -} - -void LLAppearanceMgrHttpHandler::debugCOF(const LLSD& content) -{ - dump_sequential_xml(gAgentAvatarp->getFullname() + "_appearance_request_error", content); - - LL_INFOS("Avatar") << "AIS COF, version received: " << content["expected"].asInteger() - << " ================================= " << LL_ENDL; - std::set ais_items, local_items; - const LLSD& cof_raw = content["cof_raw"]; - for (LLSD::array_const_iterator it = cof_raw.beginArray(); - it != cof_raw.endArray(); ++it) - { - const LLSD& item = *it; - if (item["parent_id"].asUUID() == LLAppearanceMgr::instance().getCOF()) - { - ais_items.insert(item["item_id"].asUUID()); - if (item["type"].asInteger() == 24) // link - { - LL_INFOS("Avatar") << "AIS Link: item_id: " << item["item_id"].asUUID() - << " linked_item_id: " << item["asset_id"].asUUID() - << " name: " << item["name"].asString() - << LL_ENDL; - } - else if (item["type"].asInteger() == 25) // folder link - { - LL_INFOS("Avatar") << "AIS Folder link: item_id: " << item["item_id"].asUUID() - << " linked_item_id: " << item["asset_id"].asUUID() - << " name: " << item["name"].asString() - << LL_ENDL; - } - else - { - LL_INFOS("Avatar") << "AIS Other: item_id: " << item["item_id"].asUUID() - << " linked_item_id: " << item["asset_id"].asUUID() - << " name: " << item["name"].asString() - << " type: " << item["type"].asInteger() - << LL_ENDL; - } - } - } - LL_INFOS("Avatar") << LL_ENDL; - LL_INFOS("Avatar") << "Local COF, version requested: " << content["observed"].asInteger() - << " ================================= " << LL_ENDL; - LLInventoryModel::cat_array_t cat_array; - LLInventoryModel::item_array_t item_array; - gInventory.collectDescendents(LLAppearanceMgr::instance().getCOF(), - cat_array,item_array,LLInventoryModel::EXCLUDE_TRASH); - for (S32 i=0; igetUUID()); - LL_INFOS("Avatar") << "LOCAL: item_id: " << inv_item->getUUID() - << " linked_item_id: " << inv_item->getLinkedUUID() - << " name: " << inv_item->getName() - << " parent: " << inv_item->getParentUUID() - << LL_ENDL; - } - LL_INFOS("Avatar") << " ================================= " << LL_ENDL; - S32 local_only = 0, ais_only = 0; - for (std::set::iterator it = local_items.begin(); it != local_items.end(); ++it) - { - if (ais_items.find(*it) == ais_items.end()) - { - LL_INFOS("Avatar") << "LOCAL ONLY: " << *it << LL_ENDL; - local_only++; - } - } - for (std::set::iterator it = ais_items.begin(); it != ais_items.end(); ++it) - { - if (local_items.find(*it) == local_items.end()) - { - LL_INFOS("Avatar") << "AIS ONLY: " << *it << LL_ENDL; - ais_only++; - } - } - if (local_only==0 && ais_only==0) - { - LL_INFOS("Avatar") << "COF contents identical, only version numbers differ (req " - << content["observed"].asInteger() - << " rcv " << content["expected"].asInteger() - << ")" << LL_ENDL; - } -} - -//========================================================================= - LLSD LLAppearanceMgr::dumpCOF() const { @@ -3493,99 +3493,6 @@ bool LLAppearanceMgr::onIdle() return false; } -class LLIncrementCofVersionResponder : public LLHTTPClient::Responder -{ - LOG_CLASS(LLIncrementCofVersionResponder); -public: - LLIncrementCofVersionResponder() : LLHTTPClient::Responder() - { - mRetryPolicy = new LLAdaptiveRetryPolicy(1.0, 16.0, 2.0, 5); - } - - virtual ~LLIncrementCofVersionResponder() - { - } - -protected: - virtual void httpSuccess() - { - LL_INFOS() << "Successfully incremented agent's COF." << LL_ENDL; - const LLSD& content = getContent(); - if (!content.isMap()) - { - failureResult(HTTP_INTERNAL_ERROR, "Malformed response contents", content); - return; - } - S32 new_version = content["category"]["version"].asInteger(); - - // cof_version should have increased - llassert(new_version > gAgentAvatarp->mLastUpdateRequestCOFVersion); - - gAgentAvatarp->mLastUpdateRequestCOFVersion = new_version; - } - - virtual void httpFailure() - { - LL_WARNS("Avatar") << "While attempting to increment the agent's cof we got an error " - << dumpResponse() << LL_ENDL; - F32 seconds_to_wait; - mRetryPolicy->onFailure(getStatus(), getResponseHeaders()); - if (mRetryPolicy->shouldRetry(seconds_to_wait)) - { - LL_INFOS() << "retrying" << LL_ENDL; - doAfterInterval(boost::bind(&LLAppearanceMgr::incrementCofVersion, - LLAppearanceMgr::getInstance(), - LLHTTPClient::ResponderPtr(this)), - seconds_to_wait); - } - else - { - LL_WARNS() << "giving up after too many retries" << LL_ENDL; - } - } - -private: - LLPointer mRetryPolicy; -}; - -void LLAppearanceMgr::incrementCofVersion(LLHTTPClient::ResponderPtr responder_ptr) -{ - // If we don't have a region, report it as an error - if (gAgent.getRegion() == NULL) - { - LL_WARNS() << "Region not set, cannot request cof_version increment" << LL_ENDL; - return; - } - - std::string url = gAgent.getRegion()->getCapability("IncrementCofVersion"); - if (url.empty()) - { - LL_WARNS() << "No cap for IncrementCofVersion." << LL_ENDL; - return; - } - - LL_INFOS() << "Requesting cof_version be incremented via capability to: " - << url << LL_ENDL; - LLSD headers; - LLSD body = LLSD::emptyMap(); - - if (!responder_ptr.get()) - { - responder_ptr = LLHTTPClient::ResponderPtr(new LLIncrementCofVersionResponder()); - } - - LLHTTPClient::get(url, body, responder_ptr, headers, 30.0f); -} - -U32 LLAppearanceMgr::getNumAttachmentsInCOF() -{ - const LLUUID cof = getCOF(); - LLInventoryModel::item_array_t obj_items; - getDescendentsOfAssetType(cof, obj_items, LLAssetType::AT_OBJECT); - return obj_items.size(); -} - - std::string LLAppearanceMgr::getAppearanceServiceURL() const { if (gSavedSettings.getString("DebugAvatarAppearanceServiceURLOverride").empty()) diff --git a/indra/newview/llappearancemgr.h b/indra/newview/llappearancemgr.h index 812d3c366c..707b8d5a77 100755 --- a/indra/newview/llappearancemgr.h +++ b/indra/newview/llappearancemgr.h @@ -39,7 +39,6 @@ class LLWearableHoldingPattern; class LLInventoryCallback; class LLOutfitUnLockTimer; -class RequestAgentUpdateAppearanceResponder; class LLAppearanceMgr: public LLSingleton { @@ -54,7 +53,6 @@ public: void updateAppearanceFromCOF(bool enforce_item_restrictions = true, bool enforce_ordering = true, nullary_func_t post_update_func = no_op); - bool needToSaveCOF(); void updateCOF(const LLUUID& category, bool append = false); void wearInventoryCategory(LLInventoryCategory* category, bool copy, bool append); void wearInventoryCategoryOnAvatar(LLInventoryCategory* category, bool append); @@ -215,13 +213,6 @@ public: void requestServerAppearanceUpdate(); - void incrementCofVersion(LLHTTPClient::ResponderPtr responder_ptr = NULL); - - U32 getNumAttachmentsInCOF(); - - // *HACK Remove this after server side texture baking is deployed on all sims. - void incrementCofVersionLegacy(); - void setAppearanceServiceURL(const std::string& url) { mAppearanceServiceURL = url; } std::string getAppearanceServiceURL() const; -- cgit v1.2.3 From f6ba7514d2392bfb5bbbe8b003b4b860118fddc5 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 26 Mar 2015 10:34:19 -0700 Subject: Fix line endings on appearancemgr and added LLCore::Http to llAgent. --- indra/newview/llagent.cpp | 156 +- indra/newview/llagent.h | 14 +- indra/newview/llappearancemgr.cpp | 8088 ++++++++++++++++++------------------- indra/newview/llappearancemgr.h | 15 +- 4 files changed, 4156 insertions(+), 4117 deletions(-) (limited to 'indra') diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index f151b15e29..ff0e2c42c1 100755 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -95,6 +95,8 @@ #include "lscript_byteformat.h" #include "stringize.h" #include "boost/foreach.hpp" +#include "llhttpsdhandler.h" +#include "llcorehttputil.h" using namespace LLAvatarAppearanceDefines; @@ -323,6 +325,7 @@ 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 @@ -361,7 +364,12 @@ LLAgent::LLAgent() : mMaturityPreferenceNumRetries(0U), mLastKnownRequestMaturity(SIM_ACCESS_MIN), mLastKnownResponseMaturity(SIM_ACCESS_MIN), - mTeleportState( TELEPORT_NONE ), + mHttpRequest(), + mHttpHeaders(), + mHttpOptions(), + mHttpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID), + mHttpPriority(0), + mTeleportState(TELEPORT_NONE), mRegionp(NULL), mAgentOriginGlobal(), @@ -459,6 +467,15 @@ void LLAgent::init() mTeleportFailedSlot = LLViewerParcelMgr::getInstance()->setTeleportFailedCallback(boost::bind(&LLAgent::handleTeleportFailed, this)); } + LLAppCoreHttp & app_core_http(LLAppViewer::instance()->getAppCoreHttp()); + + mHttpRequest = LLCore::HttpRequest::ptr_t(new LLCore::HttpRequest()); + mHttpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false); + mHttpOptions = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false); + mHttpPolicy = app_core_http.getPolicy(LLAppCoreHttp::AP_AVATAR); + + doOnIdleRepeating(boost::bind(&LLAgent::onIdle, this)); + mInitialized = TRUE; } @@ -467,6 +484,7 @@ void LLAgent::init() //----------------------------------------------------------------------------- void LLAgent::cleanup() { + mActive = false; mRegionp = NULL; if (mTeleportFinishedSlot.connected()) { @@ -498,6 +516,17 @@ LLAgent::~LLAgent() mTeleportSourceSLURL = NULL; } +//----------------------------------------------------------------------------- +// Idle processing +//----------------------------------------------------------------------------- +bool LLAgent::onIdle() +{ + if (!LLAgent::mActive) + return true; + mHttpRequest->update(0L); + return false; +} + // Handle any actions that need to be performed when the main app gains focus // (such as through alt-tab). //----------------------------------------------------------------------------- @@ -2515,66 +2544,61 @@ int LLAgent::convertTextToMaturity(char text) return LLAgentAccess::convertTextToMaturity(text); } -class LLMaturityPreferencesResponder : public LLHTTPClient::Responder +//========================================================================= +class LLMaturityHttpHandler : public LLHttpSDHandler { - LOG_CLASS(LLMaturityPreferencesResponder); public: - LLMaturityPreferencesResponder(LLAgent *pAgent, U8 pPreferredMaturity, U8 pPreviousMaturity); - virtual ~LLMaturityPreferencesResponder(); + LLMaturityHttpHandler(const std::string& capabilityURL, LLAgent *agent, U8 preferred, U8 previous): + LLHttpSDHandler(capabilityURL), + mAgent(agent), + mPreferredMaturity(preferred), + mPreviousMaturity(previous) + { } -protected: - virtual void httpSuccess(); - virtual void httpFailure(); + virtual ~LLMaturityHttpHandler() + { } protected: + virtual void onSuccess(LLCore::HttpResponse * response, LLSD &content); + virtual void onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status); private: - U8 parseMaturityFromServerResponse(const LLSD &pContent) const; - - LLAgent *mAgent; - U8 mPreferredMaturity; - U8 mPreviousMaturity; -}; + U8 LLMaturityHttpHandler::parseMaturityFromServerResponse(const LLSD &pContent) const; -LLMaturityPreferencesResponder::LLMaturityPreferencesResponder(LLAgent *pAgent, U8 pPreferredMaturity, U8 pPreviousMaturity) - : LLHTTPClient::Responder(), - mAgent(pAgent), - mPreferredMaturity(pPreferredMaturity), - mPreviousMaturity(pPreviousMaturity) -{ -} + LLAgent * mAgent; + U8 mPreferredMaturity; + U8 mPreviousMaturity; -LLMaturityPreferencesResponder::~LLMaturityPreferencesResponder() -{ -} +}; -void LLMaturityPreferencesResponder::httpSuccess() +//------------------------------------------------------------------------- +void LLMaturityHttpHandler::onSuccess(LLCore::HttpResponse * response, LLSD &content) { - U8 actualMaturity = parseMaturityFromServerResponse(getContent()); + U8 actualMaturity = parseMaturityFromServerResponse(content); if (actualMaturity != mPreferredMaturity) { LL_WARNS() << "while attempting to change maturity preference from '" - << LLViewerRegion::accessToString(mPreviousMaturity) - << "' to '" << LLViewerRegion::accessToString(mPreferredMaturity) - << "', the server responded with '" - << LLViewerRegion::accessToString(actualMaturity) - << "' [value:" << static_cast(actualMaturity) - << "], " << dumpResponse() << LL_ENDL; + << LLViewerRegion::accessToString(mPreviousMaturity) + << "' to '" << LLViewerRegion::accessToString(mPreferredMaturity) + << "', the server responded with '" + << LLViewerRegion::accessToString(actualMaturity) + << "' [value:" << static_cast(actualMaturity) + << "], " << LL_ENDL; } mAgent->handlePreferredMaturityResult(actualMaturity); } -void LLMaturityPreferencesResponder::httpFailure() +void LLMaturityHttpHandler::onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status) { - LL_WARNS() << "while attempting to change maturity preference from '" - << LLViewerRegion::accessToString(mPreviousMaturity) - << "' to '" << LLViewerRegion::accessToString(mPreferredMaturity) - << "', " << dumpResponse() << LL_ENDL; + LL_WARNS() << "while attempting to change maturity preference from '" + << LLViewerRegion::accessToString(mPreviousMaturity) + << "' to '" << LLViewerRegion::accessToString(mPreferredMaturity) + << "', " << LL_ENDL; mAgent->handlePreferredMaturityError(); } -U8 LLMaturityPreferencesResponder::parseMaturityFromServerResponse(const LLSD &pContent) const +U8 LLMaturityHttpHandler::parseMaturityFromServerResponse(const LLSD &pContent) const { U8 maturity = SIM_ACCESS_MIN; @@ -2595,6 +2619,7 @@ U8 LLMaturityPreferencesResponder::parseMaturityFromServerResponse(const LLSD &p return maturity; } +//========================================================================= void LLAgent::handlePreferredMaturityResult(U8 pServerMaturity) { @@ -2724,38 +2749,41 @@ void LLAgent::sendMaturityPreferenceToServer(U8 pPreferredMaturity) // Update the last know maturity request mLastKnownRequestMaturity = pPreferredMaturity; - // Create a response handler - LLHTTPClient::ResponderPtr responderPtr = LLHTTPClient::ResponderPtr(new LLMaturityPreferencesResponder(this, pPreferredMaturity, mLastKnownResponseMaturity)); - // If we don't have a region, report it as an error if (getRegion() == NULL) { - responderPtr->failureResult(0U, "region is not defined", LLSD()); + LL_WARNS("Agent") << "Region is not defined, can not change Maturity setting." << LL_ENDL; + return; } - else + std::string url = getRegion()->getCapability("UpdateAgentInformation"); + + // If the capability is not defined, report it as an error + if (url.empty()) { - // Find the capability to send maturity preference - std::string url = getRegion()->getCapability("UpdateAgentInformation"); + LL_WARNS("Agent") << "'UpdateAgentInformation' is not defined for region" << LL_ENDL; + return; + } - // If the capability is not defined, report it as an error - if (url.empty()) - { - responderPtr->failureResult(0U, - "capability 'UpdateAgentInformation' is not defined for region", LLSD()); - } - else - { - // Set new access preference - LLSD access_prefs = LLSD::emptyMap(); - access_prefs["max"] = LLViewerRegion::accessToShortString(pPreferredMaturity); - - LLSD body = LLSD::emptyMap(); - body["access_prefs"] = access_prefs; - LL_INFOS() << "Sending viewer preferred maturity to '" << LLViewerRegion::accessToString(pPreferredMaturity) - << "' via capability to: " << url << LL_ENDL; - LLSD headers; - LLHTTPClient::post(url, body, responderPtr, headers, 30.0f); - } + LLMaturityHttpHandler * handler = new LLMaturityHttpHandler(url, this, pPreferredMaturity, mLastKnownResponseMaturity); + + LLSD access_prefs = LLSD::emptyMap(); + access_prefs["max"] = LLViewerRegion::accessToShortString(pPreferredMaturity); + + LLSD postData = LLSD::emptyMap(); + postData["access_prefs"] = access_prefs; + LL_INFOS() << "Sending viewer preferred maturity to '" << LLViewerRegion::accessToString(pPreferredMaturity) + << "' via capability to: " << url << LL_ENDL; + + LLCore::HttpHandle handle = LLCoreHttpUtil::requestPostWithLLSD(mHttpRequest, + mHttpPolicy, mHttpPriority, url, + postData, mHttpOptions, mHttpHeaders, handler); + + if (handle == LLCORE_HTTP_HANDLE_INVALID) + { + delete handler; + LLCore::HttpStatus status = mHttpRequest->getStatus(); + LL_WARNS("Avatar") << "Maturity request post failed Reason " << status.toTerseString() + << " \"" << status.toString() << "\"" << LL_ENDL; } } } diff --git a/indra/newview/llagent.h b/indra/newview/llagent.h index 56bd1428ce..278e4c0fa1 100755 --- a/indra/newview/llagent.h +++ b/indra/newview/llagent.h @@ -35,6 +35,9 @@ #include "llavatarappearancedefines.h" #include "llpermissionsflags.h" #include "v3dmath.h" +#include "httprequest.h" +#include "httpheaders.h" +#include "httpoptions.h" #include #include @@ -112,6 +115,10 @@ public: void init(); void cleanup(); +private: + bool onIdle(); + + static bool mActive; //-------------------------------------------------------------------- // Login //-------------------------------------------------------------------- @@ -754,11 +761,16 @@ private: unsigned int mMaturityPreferenceNumRetries; U8 mLastKnownRequestMaturity; U8 mLastKnownResponseMaturity; + LLCore::HttpRequest::ptr_t mHttpRequest; + LLCore::HttpHeaders::ptr_t mHttpHeaders; + LLCore::HttpOptions::ptr_t mHttpOptions; + LLCore::HttpRequest::policy_t mHttpPolicy; + LLCore::HttpRequest::priority_t mHttpPriority; bool isMaturityPreferenceSyncedWithServer() const; void sendMaturityPreferenceToServer(U8 pPreferredMaturity); - friend class LLMaturityPreferencesResponder; + friend class LLMaturityHttpHandler; void handlePreferredMaturityResult(U8 pServerMaturity); void handlePreferredMaturityError(); void reportPreferredMaturitySuccess(); diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp index dbc858bdb0..bb4228dbb2 100755 --- a/indra/newview/llappearancemgr.cpp +++ b/indra/newview/llappearancemgr.cpp @@ -1,3490 +1,3490 @@ -/** - * @file llappearancemgr.cpp - * @brief Manager for initiating appearance changes on the viewer - * - * $LicenseInfo:firstyear=2004&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#include "llviewerprecompiledheaders.h" - -#include -#include "llaccordionctrltab.h" -#include "llagent.h" -#include "llagentcamera.h" -#include "llagentwearables.h" -#include "llappearancemgr.h" -#include "llattachmentsmgr.h" -#include "llcommandhandler.h" -#include "lleventtimer.h" -#include "llfloatersidepanelcontainer.h" -#include "llgesturemgr.h" -#include "llinventorybridge.h" -#include "llinventoryfunctions.h" -#include "llinventoryobserver.h" -#include "llnotificationsutil.h" -#include "lloutfitobserver.h" -#include "lloutfitslist.h" -#include "llselectmgr.h" -#include "llsidepanelappearance.h" -#include "llviewerobjectlist.h" -#include "llvoavatar.h" -#include "llvoavatarself.h" -#include "llviewerregion.h" -#include "llwearablelist.h" -#include "llsdutil.h" -#include "llsdserialize.h" -#include "llhttpretrypolicy.h" -#include "llaisapi.h" -#include "llhttpsdhandler.h" -#include "llcorehttputil.h" -#include "llappviewer.h" - -#if LL_MSVC -// disable boost::lexical_cast warning -#pragma warning (disable:4702) -#endif - -std::string self_av_string() -{ - // On logout gAgentAvatarp can already be invalid - return isAgentAvatarValid() ? gAgentAvatarp->avString() : ""; -} - -// RAII thingy to guarantee that a variable gets reset when the Setter -// goes out of scope. More general utility would be handy - TODO: -// check boost. -class BoolSetter -{ -public: - BoolSetter(bool& var): - mVar(var) - { - mVar = true; - } - ~BoolSetter() - { - mVar = false; - } -private: - bool& mVar; -}; - -char ORDER_NUMBER_SEPARATOR('@'); - -class LLOutfitUnLockTimer: public LLEventTimer -{ -public: - LLOutfitUnLockTimer(F32 period) : LLEventTimer(period) - { - // restart timer on BOF changed event - LLOutfitObserver::instance().addBOFChangedCallback(boost::bind( - &LLOutfitUnLockTimer::reset, this)); - stop(); - } - - /*virtual*/ - BOOL tick() - { - if(mEventTimer.hasExpired()) - { - LLAppearanceMgr::instance().setOutfitLocked(false); - } - return FALSE; - } - void stop() { mEventTimer.stop(); } - void start() { mEventTimer.start(); } - void reset() { mEventTimer.reset(); } - BOOL getStarted() { return mEventTimer.getStarted(); } - - LLTimer& getEventTimer() { return mEventTimer;} -}; - -// support for secondlife:///app/appearance SLapps -class LLAppearanceHandler : public LLCommandHandler -{ -public: - // requests will be throttled from a non-trusted browser - LLAppearanceHandler() : LLCommandHandler("appearance", UNTRUSTED_THROTTLE) {} - - bool handle(const LLSD& params, const LLSD& query_map, LLMediaCtrl* web) - { - // support secondlife:///app/appearance/show, but for now we just - // make all secondlife:///app/appearance SLapps behave this way - if (!LLUI::sSettingGroups["config"]->getBOOL("EnableAppearance")) - { - LLNotificationsUtil::add("NoAppearance", LLSD(), LLSD(), std::string("SwitchToStandardSkinAndQuit")); - return true; - } - - LLFloaterSidePanelContainer::showPanel("appearance", LLSD()); - return true; - } -}; - -LLAppearanceHandler gAppearanceHandler; - - -LLUUID findDescendentCategoryIDByName(const LLUUID& parent_id, const std::string& name) -{ - LLInventoryModel::cat_array_t cat_array; - LLInventoryModel::item_array_t item_array; - LLNameCategoryCollector has_name(name); - gInventory.collectDescendentsIf(parent_id, - cat_array, - item_array, - LLInventoryModel::EXCLUDE_TRASH, - has_name); - if (0 == cat_array.size()) - return LLUUID(); - else - { - LLViewerInventoryCategory *cat = cat_array.at(0); - if (cat) - return cat->getUUID(); - else - { - LL_WARNS() << "null cat" << LL_ENDL; - return LLUUID(); - } - } -} - -// We want this to be much lower (e.g. 15.0 is usually fine), bumping -// up for now until we can diagnose some cases of very slow response -// to requests. -const F32 DEFAULT_RETRY_AFTER_INTERVAL = 300.0; - -// Given the current back-end problems, retrying is causing too many -// duplicate items. Bump this back to 2 once they are resolved (or can -// leave at 0 if the operations become actually reliable). -const S32 DEFAULT_MAX_RETRIES = 0; - -class LLCallAfterInventoryBatchMgr: public LLEventTimer -{ -public: - LLCallAfterInventoryBatchMgr(const LLUUID& dst_cat_id, - const std::string& phase_name, - nullary_func_t on_completion_func, - nullary_func_t on_failure_func = no_op, - F32 retry_after = DEFAULT_RETRY_AFTER_INTERVAL, - S32 max_retries = DEFAULT_MAX_RETRIES - ): - mDstCatID(dst_cat_id), - mTrackingPhase(phase_name), - mOnCompletionFunc(on_completion_func), - mOnFailureFunc(on_failure_func), - mRetryAfter(retry_after), - mMaxRetries(max_retries), - mPendingRequests(0), - mFailCount(0), - mCompletionOrFailureCalled(false), - mRetryCount(0), - LLEventTimer(5.0) - { - if (!mTrackingPhase.empty()) - { - selfStartPhase(mTrackingPhase); - } - } - - void addItems(LLInventoryModel::item_array_t& src_items) - { - for (LLInventoryModel::item_array_t::const_iterator it = src_items.begin(); - it != src_items.end(); - ++it) - { - LLViewerInventoryItem* item = *it; - llassert(item); - addItem(item->getUUID()); - } - } - - // Request or re-request operation for specified item. - void addItem(const LLUUID& item_id) - { - LL_DEBUGS("Avatar") << "item_id " << item_id << LL_ENDL; - if (!requestOperation(item_id)) - { - LL_DEBUGS("Avatar") << "item_id " << item_id << " requestOperation false, skipping" << LL_ENDL; - return; - } - - mPendingRequests++; - // On a re-request, this will reset the timer. - mWaitTimes[item_id] = LLTimer(); - if (mRetryCounts.find(item_id) == mRetryCounts.end()) - { - mRetryCounts[item_id] = 0; - } - else - { - mRetryCounts[item_id]++; - } - } - - virtual bool requestOperation(const LLUUID& item_id) = 0; - - void onOp(const LLUUID& src_id, const LLUUID& dst_id, LLTimer timestamp) - { - if (ll_frand() < gSavedSettings.getF32("InventoryDebugSimulateLateOpRate")) - { - LL_WARNS() << "Simulating late operation by punting handling to later" << LL_ENDL; - doAfterInterval(boost::bind(&LLCallAfterInventoryBatchMgr::onOp,this,src_id,dst_id,timestamp), - mRetryAfter); - return; - } - mPendingRequests--; - F32 elapsed = timestamp.getElapsedTimeF32(); - LL_DEBUGS("Avatar") << "op done, src_id " << src_id << " dst_id " << dst_id << " after " << elapsed << " seconds" << LL_ENDL; - if (mWaitTimes.find(src_id) == mWaitTimes.end()) - { - // No longer waiting for this item - either serviced - // already or gave up after too many retries. - LL_WARNS() << "duplicate or late operation, src_id " << src_id << "dst_id " << dst_id - << " elapsed " << elapsed << " after end " << (S32) mCompletionOrFailureCalled << LL_ENDL; - } - mTimeStats.push(elapsed); - mWaitTimes.erase(src_id); - if (mWaitTimes.empty() && !mCompletionOrFailureCalled) - { - onCompletionOrFailure(); - } - } - - void onCompletionOrFailure() - { - assert (!mCompletionOrFailureCalled); - mCompletionOrFailureCalled = true; - - // Will never call onCompletion() if any item has been flagged as - // a failure - otherwise could wind up with corrupted - // outfit, involuntary nudity, etc. - reportStats(); - if (!mTrackingPhase.empty()) - { - selfStopPhase(mTrackingPhase); - } - if (!mFailCount) - { - onCompletion(); - } - else - { - onFailure(); - } - } - - void onFailure() - { - LL_INFOS() << "failed" << LL_ENDL; - mOnFailureFunc(); - } - - void onCompletion() - { - LL_INFOS() << "done" << LL_ENDL; - mOnCompletionFunc(); - } - - // virtual - // Will be deleted after returning true - only safe to do this if all callbacks have fired. - BOOL tick() - { - // mPendingRequests will be zero if all requests have been - // responded to. mWaitTimes.empty() will be true if we have - // received at least one reply for each UUID. If requests - // have been dropped and retried, these will not necessarily - // be the same. Only safe to return true if all requests have - // been serviced, since it will result in this object being - // deleted. - bool all_done = (mPendingRequests==0); - - if (!mWaitTimes.empty()) - { - LL_WARNS() << "still waiting on " << mWaitTimes.size() << " items" << LL_ENDL; - for (std::map::iterator it = mWaitTimes.begin(); - it != mWaitTimes.end();) - { - // Use a copy of iterator because it may be erased/invalidated. - std::map::iterator curr_it = it; - ++it; - - F32 time_waited = curr_it->second.getElapsedTimeF32(); - S32 retries = mRetryCounts[curr_it->first]; - if (time_waited > mRetryAfter) - { - if (retries < mMaxRetries) - { - LL_DEBUGS("Avatar") << "Waited " << time_waited << - " for " << curr_it->first << ", retrying" << LL_ENDL; - mRetryCount++; - addItem(curr_it->first); - } - else - { - LL_WARNS() << "Giving up on " << curr_it->first << " after too many retries" << LL_ENDL; - mWaitTimes.erase(curr_it); - mFailCount++; - } - } - if (mWaitTimes.empty()) - { - onCompletionOrFailure(); - } - - } - } - return all_done; - } - - void reportStats() - { - LL_DEBUGS("Avatar") << "Phase: " << mTrackingPhase << LL_ENDL; - LL_DEBUGS("Avatar") << "mFailCount: " << mFailCount << LL_ENDL; - LL_DEBUGS("Avatar") << "mRetryCount: " << mRetryCount << LL_ENDL; - LL_DEBUGS("Avatar") << "Times: n " << mTimeStats.getCount() << " min " << mTimeStats.getMinValue() << " max " << mTimeStats.getMaxValue() << LL_ENDL; - LL_DEBUGS("Avatar") << "Mean " << mTimeStats.getMean() << " stddev " << mTimeStats.getStdDev() << LL_ENDL; - } - - virtual ~LLCallAfterInventoryBatchMgr() - { - LL_DEBUGS("Avatar") << "deleting" << LL_ENDL; - } - -protected: - std::string mTrackingPhase; - std::map mWaitTimes; - std::map mRetryCounts; - LLUUID mDstCatID; - nullary_func_t mOnCompletionFunc; - nullary_func_t mOnFailureFunc; - F32 mRetryAfter; - S32 mMaxRetries; - S32 mPendingRequests; - S32 mFailCount; - S32 mRetryCount; - bool mCompletionOrFailureCalled; - LLViewerStats::StatsAccumulator mTimeStats; -}; - -class LLCallAfterInventoryCopyMgr: public LLCallAfterInventoryBatchMgr -{ -public: - LLCallAfterInventoryCopyMgr(LLInventoryModel::item_array_t& src_items, - const LLUUID& dst_cat_id, - const std::string& phase_name, - nullary_func_t on_completion_func, - nullary_func_t on_failure_func = no_op, - F32 retry_after = DEFAULT_RETRY_AFTER_INTERVAL, - S32 max_retries = DEFAULT_MAX_RETRIES - ): - LLCallAfterInventoryBatchMgr(dst_cat_id, phase_name, on_completion_func, on_failure_func, retry_after, max_retries) - { - addItems(src_items); - sInstanceCount++; - } - - ~LLCallAfterInventoryCopyMgr() - { - sInstanceCount--; - } - - virtual bool requestOperation(const LLUUID& item_id) - { - LLViewerInventoryItem *item = gInventory.getItem(item_id); - llassert(item); - LL_DEBUGS("Avatar") << "copying item " << item_id << LL_ENDL; - if (ll_frand() < gSavedSettings.getF32("InventoryDebugSimulateOpFailureRate")) - { - LL_DEBUGS("Avatar") << "simulating failure by not sending request for item " << item_id << LL_ENDL; - return true; - } - copy_inventory_item( - gAgent.getID(), - item->getPermissions().getOwner(), - item->getUUID(), - mDstCatID, - std::string(), - new LLBoostFuncInventoryCallback(boost::bind(&LLCallAfterInventoryBatchMgr::onOp,this,item_id,_1,LLTimer())) - ); - return true; - } - - static S32 getInstanceCount() { return sInstanceCount; } - -private: - static S32 sInstanceCount; -}; - -S32 LLCallAfterInventoryCopyMgr::sInstanceCount = 0; - -class LLWearCategoryAfterCopy: public LLInventoryCallback -{ -public: - LLWearCategoryAfterCopy(bool append): - mAppend(append) - {} - - // virtual - void fire(const LLUUID& id) - { - // Wear the inventory category. - LLInventoryCategory* cat = gInventory.getCategory(id); - LLAppearanceMgr::instance().wearInventoryCategoryOnAvatar(cat, mAppend); - } - -private: - bool mAppend; -}; - -class LLTrackPhaseWrapper : public LLInventoryCallback -{ -public: - LLTrackPhaseWrapper(const std::string& phase_name, LLPointer cb = NULL): - mTrackingPhase(phase_name), - mCB(cb) - { - selfStartPhase(mTrackingPhase); - } - - // virtual - void fire(const LLUUID& id) - { - if (mCB) - { - mCB->fire(id); - } - } - - // virtual - ~LLTrackPhaseWrapper() - { - selfStopPhase(mTrackingPhase); - } - -protected: - std::string mTrackingPhase; - LLPointer mCB; -}; - -LLUpdateAppearanceOnDestroy::LLUpdateAppearanceOnDestroy(bool enforce_item_restrictions, - bool enforce_ordering, - nullary_func_t post_update_func - ): - mFireCount(0), - mEnforceItemRestrictions(enforce_item_restrictions), - mEnforceOrdering(enforce_ordering), - mPostUpdateFunc(post_update_func) -{ - selfStartPhase("update_appearance_on_destroy"); -} - -void LLUpdateAppearanceOnDestroy::fire(const LLUUID& inv_item) -{ - LLViewerInventoryItem* item = (LLViewerInventoryItem*)gInventory.getItem(inv_item); - const std::string item_name = item ? item->getName() : "ITEM NOT FOUND"; -#ifndef LL_RELEASE_FOR_DOWNLOAD - LL_DEBUGS("Avatar") << self_av_string() << "callback fired [ name:" << item_name << " UUID:" << inv_item << " count:" << mFireCount << " ] " << LL_ENDL; -#endif - mFireCount++; -} - -LLUpdateAppearanceOnDestroy::~LLUpdateAppearanceOnDestroy() -{ - if (!LLApp::isExiting()) - { - // speculative fix for MAINT-1150 - LL_INFOS("Avatar") << self_av_string() << "done update appearance on destroy" << LL_ENDL; - - selfStopPhase("update_appearance_on_destroy"); - - LLAppearanceMgr::instance().updateAppearanceFromCOF(mEnforceItemRestrictions, - mEnforceOrdering, - mPostUpdateFunc); - } -} - -LLUpdateAppearanceAndEditWearableOnDestroy::LLUpdateAppearanceAndEditWearableOnDestroy(const LLUUID& item_id): - mItemID(item_id) -{ -} - -void edit_wearable_and_customize_avatar(LLUUID item_id) -{ - // Start editing the item if previously requested. - gAgentWearables.editWearableIfRequested(item_id); - - // TODO: camera mode may not be changed if a debug setting is tweaked - if( gAgentCamera.cameraCustomizeAvatar() ) - { - // If we're in appearance editing mode, the current tab may need to be refreshed - LLSidepanelAppearance *panel = dynamic_cast( - LLFloaterSidePanelContainer::getPanel("appearance")); - if (panel) - { - panel->showDefaultSubpart(); - } - } -} - -LLUpdateAppearanceAndEditWearableOnDestroy::~LLUpdateAppearanceAndEditWearableOnDestroy() -{ - if (!LLApp::isExiting()) - { - LLAppearanceMgr::instance().updateAppearanceFromCOF( - true,true, - boost::bind(edit_wearable_and_customize_avatar, mItemID)); - } -} - - -struct LLFoundData -{ - LLFoundData() : - mAssetType(LLAssetType::AT_NONE), - mWearableType(LLWearableType::WT_INVALID), - mWearable(NULL) {} - - LLFoundData(const LLUUID& item_id, - const LLUUID& asset_id, - const std::string& name, - const LLAssetType::EType& asset_type, - const LLWearableType::EType& wearable_type, - const bool is_replacement = false - ) : - mItemID(item_id), - mAssetID(asset_id), - mName(name), - mAssetType(asset_type), - mWearableType(wearable_type), - mIsReplacement(is_replacement), - mWearable( NULL ) {} - - LLUUID mItemID; - LLUUID mAssetID; - std::string mName; - LLAssetType::EType mAssetType; - LLWearableType::EType mWearableType; - LLViewerWearable* mWearable; - bool mIsReplacement; -}; - - -class LLWearableHoldingPattern -{ - LOG_CLASS(LLWearableHoldingPattern); - -public: - LLWearableHoldingPattern(); - ~LLWearableHoldingPattern(); - - bool pollFetchCompletion(); - void onFetchCompletion(); - bool isFetchCompleted(); - bool isTimedOut(); - - void checkMissingWearables(); - bool pollMissingWearables(); - bool isMissingCompleted(); - void recoverMissingWearable(LLWearableType::EType type); - void clearCOFLinksForMissingWearables(); - - void onWearableAssetFetch(LLViewerWearable *wearable); - void onAllComplete(); - - typedef std::list found_list_t; - found_list_t& getFoundList(); - void eraseTypeToLink(LLWearableType::EType type); - void eraseTypeToRecover(LLWearableType::EType type); - void setObjItems(const LLInventoryModel::item_array_t& items); - void setGestItems(const LLInventoryModel::item_array_t& items); - bool isMostRecent(); - void handleLateArrivals(); - void resetTime(F32 timeout); - static S32 countActive() { return sActiveHoldingPatterns.size(); } - S32 index() { return mIndex; } - -private: - found_list_t mFoundList; - LLInventoryModel::item_array_t mObjItems; - LLInventoryModel::item_array_t mGestItems; - typedef std::set type_set_t; - type_set_t mTypesToRecover; - type_set_t mTypesToLink; - S32 mResolved; - LLTimer mWaitTime; - bool mFired; - typedef std::set type_set_hp; - static type_set_hp sActiveHoldingPatterns; - static S32 sNextIndex; - S32 mIndex; - bool mIsMostRecent; - std::set mLateArrivals; - bool mIsAllComplete; -}; - -LLWearableHoldingPattern::type_set_hp LLWearableHoldingPattern::sActiveHoldingPatterns; -S32 LLWearableHoldingPattern::sNextIndex = 0; - -LLWearableHoldingPattern::LLWearableHoldingPattern(): - mResolved(0), - mFired(false), - mIsMostRecent(true), - mIsAllComplete(false) -{ - if (countActive()>0) - { - LL_INFOS() << "Creating LLWearableHoldingPattern when " - << countActive() - << " other attempts are active." - << " Flagging others as invalid." - << LL_ENDL; - for (type_set_hp::iterator it = sActiveHoldingPatterns.begin(); - it != sActiveHoldingPatterns.end(); - ++it) - { - (*it)->mIsMostRecent = false; - } - - } - mIndex = sNextIndex++; - sActiveHoldingPatterns.insert(this); - LL_DEBUGS("Avatar") << "HP " << index() << " created" << LL_ENDL; - selfStartPhase("holding_pattern"); -} - -LLWearableHoldingPattern::~LLWearableHoldingPattern() -{ - sActiveHoldingPatterns.erase(this); - if (isMostRecent()) - { - selfStopPhase("holding_pattern"); - } - LL_DEBUGS("Avatar") << "HP " << index() << " deleted" << LL_ENDL; -} - -bool LLWearableHoldingPattern::isMostRecent() -{ - return mIsMostRecent; -} - -LLWearableHoldingPattern::found_list_t& LLWearableHoldingPattern::getFoundList() -{ - return mFoundList; -} - -void LLWearableHoldingPattern::eraseTypeToLink(LLWearableType::EType type) -{ - mTypesToLink.erase(type); -} - -void LLWearableHoldingPattern::eraseTypeToRecover(LLWearableType::EType type) -{ - mTypesToRecover.erase(type); -} - -void LLWearableHoldingPattern::setObjItems(const LLInventoryModel::item_array_t& items) -{ - mObjItems = items; -} - -void LLWearableHoldingPattern::setGestItems(const LLInventoryModel::item_array_t& items) -{ - mGestItems = items; -} - -bool LLWearableHoldingPattern::isFetchCompleted() -{ - return (mResolved >= (S32)getFoundList().size()); // have everything we were waiting for? -} - -bool LLWearableHoldingPattern::isTimedOut() -{ - return mWaitTime.hasExpired(); -} - -void LLWearableHoldingPattern::checkMissingWearables() -{ - if (!isMostRecent()) - { - // runway why don't we actually skip here? - LL_WARNS() << self_av_string() << "skipping because LLWearableHolding pattern is invalid (superceded by later outfit request)" << LL_ENDL; - } - - std::vector found_by_type(LLWearableType::WT_COUNT,0); - std::vector requested_by_type(LLWearableType::WT_COUNT,0); - for (found_list_t::iterator it = getFoundList().begin(); it != getFoundList().end(); ++it) - { - LLFoundData &data = *it; - if (data.mWearableType < LLWearableType::WT_COUNT) - requested_by_type[data.mWearableType]++; - if (data.mWearable) - found_by_type[data.mWearableType]++; - } - - for (S32 type = 0; type < LLWearableType::WT_COUNT; ++type) - { - if (requested_by_type[type] > found_by_type[type]) - { - LL_WARNS() << self_av_string() << "got fewer wearables than requested, type " << type << ": requested " << requested_by_type[type] << ", found " << found_by_type[type] << LL_ENDL; - } - if (found_by_type[type] > 0) - continue; - if ( - // If at least one wearable of certain types (pants/shirt/skirt) - // was requested but none was found, create a default asset as a replacement. - // In all other cases, don't do anything. - // For critical types (shape/hair/skin/eyes), this will keep the avatar as a cloud - // due to logic in LLVOAvatarSelf::getIsCloud(). - // For non-critical types (tatoo, socks, etc.) the wearable will just be missing. - (requested_by_type[type] > 0) && - ((type == LLWearableType::WT_PANTS) || (type == LLWearableType::WT_SHIRT) || (type == LLWearableType::WT_SKIRT))) - { - mTypesToRecover.insert(type); - mTypesToLink.insert(type); - recoverMissingWearable((LLWearableType::EType)type); - LL_WARNS() << self_av_string() << "need to replace " << type << LL_ENDL; - } - } - - resetTime(60.0F); - - if (isMostRecent()) - { - selfStartPhase("get_missing_wearables_2"); - } - if (!pollMissingWearables()) - { - doOnIdleRepeating(boost::bind(&LLWearableHoldingPattern::pollMissingWearables,this)); - } -} - -void LLWearableHoldingPattern::onAllComplete() -{ - if (isAgentAvatarValid()) - { - gAgentAvatarp->outputRezTiming("Agent wearables fetch complete"); - } - - if (!isMostRecent()) - { - // runway need to skip here? - LL_WARNS() << self_av_string() << "skipping because LLWearableHolding pattern is invalid (superceded by later outfit request)" << LL_ENDL; - } - - // Activate all gestures in this folder - if (mGestItems.size() > 0) - { - LL_DEBUGS("Avatar") << self_av_string() << "Activating " << mGestItems.size() << " gestures" << LL_ENDL; - - LLGestureMgr::instance().activateGestures(mGestItems); - - // Update the inventory item labels to reflect the fact - // they are active. - LLViewerInventoryCategory* catp = - gInventory.getCategory(LLAppearanceMgr::instance().getCOF()); - - if (catp) - { - gInventory.updateCategory(catp); - gInventory.notifyObservers(); - } - } - - if (isAgentAvatarValid()) - { - LL_DEBUGS("Avatar") << self_av_string() << "Updating " << mObjItems.size() << " attachments" << LL_ENDL; - LLAgentWearables::llvo_vec_t objects_to_remove; - LLAgentWearables::llvo_vec_t objects_to_retain; - LLInventoryModel::item_array_t items_to_add; - - LLAgentWearables::findAttachmentsAddRemoveInfo(mObjItems, - objects_to_remove, - objects_to_retain, - items_to_add); - - LL_DEBUGS("Avatar") << self_av_string() << "Removing " << objects_to_remove.size() - << " attachments" << LL_ENDL; - - // Here we remove the attachment pos overrides for *all* - // attachments, even those that are not being removed. This is - // needed to get joint positions all slammed down to their - // pre-attachment states. - gAgentAvatarp->clearAttachmentPosOverrides(); - - // Take off the attachments that will no longer be in the outfit. - LLAgentWearables::userRemoveMultipleAttachments(objects_to_remove); - - // Update wearables. - LL_INFOS("Avatar") << self_av_string() << "HP " << index() << " updating agent wearables with " - << mResolved << " wearable items " << LL_ENDL; - LLAppearanceMgr::instance().updateAgentWearables(this); - - // Restore attachment pos overrides for the attachments that - // are remaining in the outfit. - for (LLAgentWearables::llvo_vec_t::iterator it = objects_to_retain.begin(); - it != objects_to_retain.end(); - ++it) - { - LLViewerObject *objectp = *it; - gAgentAvatarp->addAttachmentPosOverridesForObject(objectp); - } - - // Add new attachments to match those requested. - LL_DEBUGS("Avatar") << self_av_string() << "Adding " << items_to_add.size() << " attachments" << LL_ENDL; - LLAgentWearables::userAttachMultipleAttachments(items_to_add); - } - - if (isFetchCompleted() && isMissingCompleted()) - { - // Only safe to delete if all wearable callbacks and all missing wearables completed. - delete this; - } - else - { - mIsAllComplete = true; - handleLateArrivals(); - } -} - -void LLWearableHoldingPattern::onFetchCompletion() -{ - if (isMostRecent()) - { - selfStopPhase("get_wearables_2"); - } - - if (!isMostRecent()) - { - // runway skip here? - LL_WARNS() << self_av_string() << "skipping because LLWearableHolding pattern is invalid (superceded by later outfit request)" << LL_ENDL; - } - - checkMissingWearables(); -} - -// Runs as an idle callback until all wearables are fetched (or we time out). -bool LLWearableHoldingPattern::pollFetchCompletion() -{ - if (!isMostRecent()) - { - // runway skip here? - LL_WARNS() << self_av_string() << "skipping because LLWearableHolding pattern is invalid (superceded by later outfit request)" << LL_ENDL; - } - - bool completed = isFetchCompleted(); - bool timed_out = isTimedOut(); - bool done = completed || timed_out; - - if (done) - { - LL_INFOS("Avatar") << self_av_string() << "HP " << index() << " polling, done status: " << completed << " timed out " << timed_out - << " elapsed " << mWaitTime.getElapsedTimeF32() << LL_ENDL; - - mFired = true; - - if (timed_out) - { - LL_WARNS() << self_av_string() << "Exceeded max wait time for wearables, updating appearance based on what has arrived" << LL_ENDL; - } - - onFetchCompletion(); - } - return done; -} - -void recovered_item_link_cb(const LLUUID& item_id, LLWearableType::EType type, LLViewerWearable *wearable, LLWearableHoldingPattern* holder) -{ - if (!holder->isMostRecent()) - { - LL_WARNS() << "HP " << holder->index() << " skipping because LLWearableHolding pattern is invalid (superceded by later outfit request)" << LL_ENDL; - // runway skip here? - } - - LL_INFOS() << "HP " << holder->index() << " recovered item link for type " << type << LL_ENDL; - holder->eraseTypeToLink(type); - // Add wearable to FoundData for actual wearing - LLViewerInventoryItem *item = gInventory.getItem(item_id); - LLViewerInventoryItem *linked_item = item ? item->getLinkedItem() : NULL; - - if (linked_item) - { - gInventory.addChangedMask(LLInventoryObserver::LABEL, linked_item->getUUID()); - - if (item) - { - LLFoundData found(linked_item->getUUID(), - linked_item->getAssetUUID(), - linked_item->getName(), - linked_item->getType(), - linked_item->isWearableType() ? linked_item->getWearableType() : LLWearableType::WT_INVALID, - true // is replacement - ); - found.mWearable = wearable; - holder->getFoundList().push_front(found); - } - else - { - LL_WARNS() << self_av_string() << "inventory link not found for recovered wearable" << LL_ENDL; - } - } - else - { - LL_WARNS() << self_av_string() << "HP " << holder->index() << " inventory link not found for recovered wearable" << LL_ENDL; - } -} - -void recovered_item_cb(const LLUUID& item_id, LLWearableType::EType type, LLViewerWearable *wearable, LLWearableHoldingPattern* holder) -{ - if (!holder->isMostRecent()) - { - // runway skip here? - LL_WARNS() << self_av_string() << "skipping because LLWearableHolding pattern is invalid (superceded by later outfit request)" << LL_ENDL; - } - - LL_DEBUGS("Avatar") << self_av_string() << "Recovered item for type " << type << LL_ENDL; - LLConstPointer itemp = gInventory.getItem(item_id); - wearable->setItemID(item_id); - holder->eraseTypeToRecover(type); - llassert(itemp); - if (itemp) - { - LLPointer cb = new LLBoostFuncInventoryCallback(boost::bind(recovered_item_link_cb,_1,type,wearable,holder)); - - link_inventory_object(LLAppearanceMgr::instance().getCOF(), itemp, cb); - } -} - -void LLWearableHoldingPattern::recoverMissingWearable(LLWearableType::EType type) -{ - if (!isMostRecent()) - { - // runway skip here? - LL_WARNS() << self_av_string() << "skipping because LLWearableHolding pattern is invalid (superceded by later outfit request)" << LL_ENDL; - } - - // Try to recover by replacing missing wearable with a new one. - LLNotificationsUtil::add("ReplacedMissingWearable"); - LL_DEBUGS() << "Wearable " << LLWearableType::getTypeLabel(type) - << " could not be downloaded. Replaced inventory item with default wearable." << LL_ENDL; - LLViewerWearable* wearable = LLWearableList::instance().createNewWearable(type, gAgentAvatarp); - - // Add a new one in the lost and found folder. - const LLUUID lost_and_found_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_LOST_AND_FOUND); - LLPointer cb = new LLBoostFuncInventoryCallback(boost::bind(recovered_item_cb,_1,type,wearable,this)); - - create_inventory_item(gAgent.getID(), - gAgent.getSessionID(), - lost_and_found_id, - wearable->getTransactionID(), - wearable->getName(), - wearable->getDescription(), - wearable->getAssetType(), - LLInventoryType::IT_WEARABLE, - wearable->getType(), - wearable->getPermissions().getMaskNextOwner(), - cb); -} - -bool LLWearableHoldingPattern::isMissingCompleted() -{ - return mTypesToLink.size()==0 && mTypesToRecover.size()==0; -} - -void LLWearableHoldingPattern::clearCOFLinksForMissingWearables() -{ - for (found_list_t::iterator it = getFoundList().begin(); it != getFoundList().end(); ++it) - { - LLFoundData &data = *it; - if ((data.mWearableType < LLWearableType::WT_COUNT) && (!data.mWearable)) - { - // Wearable link that was never resolved; remove links to it from COF - LL_INFOS("Avatar") << self_av_string() << "HP " << index() << " removing link for unresolved item " << data.mItemID.asString() << LL_ENDL; - LLAppearanceMgr::instance().removeCOFItemLinks(data.mItemID); - } - } -} - -bool LLWearableHoldingPattern::pollMissingWearables() -{ - if (!isMostRecent()) - { - // runway skip here? - LL_WARNS() << self_av_string() << "skipping because LLWearableHolding pattern is invalid (superceded by later outfit request)" << LL_ENDL; - } - - bool timed_out = isTimedOut(); - bool missing_completed = isMissingCompleted(); - bool done = timed_out || missing_completed; - - if (!done) - { - LL_INFOS("Avatar") << self_av_string() << "HP " << index() << " polling missing wearables, waiting for items " << mTypesToRecover.size() - << " links " << mTypesToLink.size() - << " wearables, timed out " << timed_out - << " elapsed " << mWaitTime.getElapsedTimeF32() - << " done " << done << LL_ENDL; - } - - if (done) - { - if (isMostRecent()) - { - selfStopPhase("get_missing_wearables_2"); - } - - gAgentAvatarp->debugWearablesLoaded(); - - // BAP - if we don't call clearCOFLinksForMissingWearables() - // here, we won't have to add the link back in later if the - // wearable arrives late. This is to avoid corruption of - // wearable ordering info. Also has the effect of making - // unworn item links visible in the COF under some - // circumstances. - - //clearCOFLinksForMissingWearables(); - onAllComplete(); - } - return done; -} - -// Handle wearables that arrived after the timeout period expired. -void LLWearableHoldingPattern::handleLateArrivals() -{ - // Only safe to run if we have previously finished the missing - // wearables and other processing - otherwise we could be in some - // intermediate state - but have not been superceded by a later - // outfit change request. - if (mLateArrivals.size() == 0) - { - // Nothing to process. - return; - } - if (!isMostRecent()) - { - LL_WARNS() << self_av_string() << "Late arrivals not handled - outfit change no longer valid" << LL_ENDL; - } - if (!mIsAllComplete) - { - LL_WARNS() << self_av_string() << "Late arrivals not handled - in middle of missing wearables processing" << LL_ENDL; - } - - LL_INFOS("Avatar") << self_av_string() << "HP " << index() << " need to handle " << mLateArrivals.size() << " late arriving wearables" << LL_ENDL; - - // Update mFoundList using late-arriving wearables. - std::set replaced_types; - for (LLWearableHoldingPattern::found_list_t::iterator iter = getFoundList().begin(); - iter != getFoundList().end(); ++iter) - { - LLFoundData& data = *iter; - for (std::set::iterator wear_it = mLateArrivals.begin(); - wear_it != mLateArrivals.end(); - ++wear_it) - { - LLViewerWearable *wearable = *wear_it; - - if(wearable->getAssetID() == data.mAssetID) - { - data.mWearable = wearable; - - replaced_types.insert(data.mWearableType); - - // BAP - if we didn't call - // clearCOFLinksForMissingWearables() earlier, we - // don't need to restore the link here. Fixes - // wearable ordering problems. - - // LLAppearanceMgr::instance().addCOFItemLink(data.mItemID,false); - - // BAP failing this means inventory or asset server - // are corrupted in a way we don't handle. - llassert((data.mWearableType < LLWearableType::WT_COUNT) && (wearable->getType() == data.mWearableType)); - break; - } - } - } - - // Remove COF links for any default wearables previously used to replace the late arrivals. - // All this pussyfooting around with a while loop and explicit - // iterator incrementing is to allow removing items from the list - // without clobbering the iterator we're using to navigate. - LLWearableHoldingPattern::found_list_t::iterator iter = getFoundList().begin(); - while (iter != getFoundList().end()) - { - LLFoundData& data = *iter; - - // If an item of this type has recently shown up, removed the corresponding replacement wearable from COF. - if (data.mWearable && data.mIsReplacement && - replaced_types.find(data.mWearableType) != replaced_types.end()) - { - LLAppearanceMgr::instance().removeCOFItemLinks(data.mItemID); - std::list::iterator clobber_ator = iter; - ++iter; - getFoundList().erase(clobber_ator); - } - else - { - ++iter; - } - } - - // Clear contents of late arrivals. - mLateArrivals.clear(); - - // Update appearance based on mFoundList - LLAppearanceMgr::instance().updateAgentWearables(this); -} - -void LLWearableHoldingPattern::resetTime(F32 timeout) -{ - mWaitTime.reset(); - mWaitTime.setTimerExpirySec(timeout); -} - -void LLWearableHoldingPattern::onWearableAssetFetch(LLViewerWearable *wearable) -{ - if (!isMostRecent()) - { - LL_WARNS() << self_av_string() << "skipping because LLWearableHolding pattern is invalid (superceded by later outfit request)" << LL_ENDL; - } - - mResolved += 1; // just counting callbacks, not successes. - LL_DEBUGS("Avatar") << self_av_string() << "HP " << index() << " resolved " << mResolved << "/" << getFoundList().size() << LL_ENDL; - if (!wearable) - { - LL_WARNS() << self_av_string() << "no wearable found" << LL_ENDL; - } - - if (mFired) - { - LL_WARNS() << self_av_string() << "called after holder fired" << LL_ENDL; - if (wearable) - { - mLateArrivals.insert(wearable); - if (mIsAllComplete) - { - handleLateArrivals(); - } - } - return; - } - - if (!wearable) - { - return; - } - - for (LLWearableHoldingPattern::found_list_t::iterator iter = getFoundList().begin(); - iter != getFoundList().end(); ++iter) - { - LLFoundData& data = *iter; - if(wearable->getAssetID() == data.mAssetID) - { - // Failing this means inventory or asset server are corrupted in a way we don't handle. - if ((data.mWearableType >= LLWearableType::WT_COUNT) || (wearable->getType() != data.mWearableType)) - { - LL_WARNS() << self_av_string() << "recovered wearable but type invalid. inventory wearable type: " << data.mWearableType << " asset wearable type: " << wearable->getType() << LL_ENDL; - break; - } - - data.mWearable = wearable; - } - } -} - -static void onWearableAssetFetch(LLViewerWearable* wearable, void* data) -{ - LLWearableHoldingPattern* holder = (LLWearableHoldingPattern*)data; - holder->onWearableAssetFetch(wearable); -} - - -static void removeDuplicateItems(LLInventoryModel::item_array_t& items) -{ - LLInventoryModel::item_array_t new_items; - std::set items_seen; - std::deque tmp_list; - // Traverse from the front and keep the first of each item - // encountered, so we actually keep the *last* of each duplicate - // item. This is needed to give the right priority when adding - // duplicate items to an existing outfit. - for (S32 i=items.size()-1; i>=0; i--) - { - LLViewerInventoryItem *item = items.at(i); - LLUUID item_id = item->getLinkedUUID(); - if (items_seen.find(item_id)!=items_seen.end()) - continue; - items_seen.insert(item_id); - tmp_list.push_front(item); - } - for (std::deque::iterator it = tmp_list.begin(); - it != tmp_list.end(); - ++it) - { - new_items.push_back(*it); - } - items = new_items; -} - -//========================================================================= -class LLAppearanceMgrHttpHandler : public LLHttpSDHandler -{ -public: - LLAppearanceMgrHttpHandler(const std::string& capabilityURL, LLAppearanceMgr *mgr) : - LLHttpSDHandler(capabilityURL), - mManager(mgr) - { } - - virtual ~LLAppearanceMgrHttpHandler() - { } - +/** + * @file llappearancemgr.cpp + * @brief Manager for initiating appearance changes on the viewer + * + * $LicenseInfo:firstyear=2004&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include +#include "llaccordionctrltab.h" +#include "llagent.h" +#include "llagentcamera.h" +#include "llagentwearables.h" +#include "llappearancemgr.h" +#include "llattachmentsmgr.h" +#include "llcommandhandler.h" +#include "lleventtimer.h" +#include "llfloatersidepanelcontainer.h" +#include "llgesturemgr.h" +#include "llinventorybridge.h" +#include "llinventoryfunctions.h" +#include "llinventoryobserver.h" +#include "llnotificationsutil.h" +#include "lloutfitobserver.h" +#include "lloutfitslist.h" +#include "llselectmgr.h" +#include "llsidepanelappearance.h" +#include "llviewerobjectlist.h" +#include "llvoavatar.h" +#include "llvoavatarself.h" +#include "llviewerregion.h" +#include "llwearablelist.h" +#include "llsdutil.h" +#include "llsdserialize.h" +#include "llhttpretrypolicy.h" +#include "llaisapi.h" +#include "llhttpsdhandler.h" +#include "llcorehttputil.h" +#include "llappviewer.h" + +#if LL_MSVC +// disable boost::lexical_cast warning +#pragma warning (disable:4702) +#endif + +std::string self_av_string() +{ + // On logout gAgentAvatarp can already be invalid + return isAgentAvatarValid() ? gAgentAvatarp->avString() : ""; +} + +// RAII thingy to guarantee that a variable gets reset when the Setter +// goes out of scope. More general utility would be handy - TODO: +// check boost. +class BoolSetter +{ +public: + BoolSetter(bool& var): + mVar(var) + { + mVar = true; + } + ~BoolSetter() + { + mVar = false; + } +private: + bool& mVar; +}; + +char ORDER_NUMBER_SEPARATOR('@'); + +class LLOutfitUnLockTimer: public LLEventTimer +{ +public: + LLOutfitUnLockTimer(F32 period) : LLEventTimer(period) + { + // restart timer on BOF changed event + LLOutfitObserver::instance().addBOFChangedCallback(boost::bind( + &LLOutfitUnLockTimer::reset, this)); + stop(); + } + + /*virtual*/ + BOOL tick() + { + if(mEventTimer.hasExpired()) + { + LLAppearanceMgr::instance().setOutfitLocked(false); + } + return FALSE; + } + void stop() { mEventTimer.stop(); } + void start() { mEventTimer.start(); } + void reset() { mEventTimer.reset(); } + BOOL getStarted() { return mEventTimer.getStarted(); } + + LLTimer& getEventTimer() { return mEventTimer;} +}; + +// support for secondlife:///app/appearance SLapps +class LLAppearanceHandler : public LLCommandHandler +{ +public: + // requests will be throttled from a non-trusted browser + LLAppearanceHandler() : LLCommandHandler("appearance", UNTRUSTED_THROTTLE) {} + + bool handle(const LLSD& params, const LLSD& query_map, LLMediaCtrl* web) + { + // support secondlife:///app/appearance/show, but for now we just + // make all secondlife:///app/appearance SLapps behave this way + if (!LLUI::sSettingGroups["config"]->getBOOL("EnableAppearance")) + { + LLNotificationsUtil::add("NoAppearance", LLSD(), LLSD(), std::string("SwitchToStandardSkinAndQuit")); + return true; + } + + LLFloaterSidePanelContainer::showPanel("appearance", LLSD()); + return true; + } +}; + +LLAppearanceHandler gAppearanceHandler; + + +LLUUID findDescendentCategoryIDByName(const LLUUID& parent_id, const std::string& name) +{ + LLInventoryModel::cat_array_t cat_array; + LLInventoryModel::item_array_t item_array; + LLNameCategoryCollector has_name(name); + gInventory.collectDescendentsIf(parent_id, + cat_array, + item_array, + LLInventoryModel::EXCLUDE_TRASH, + has_name); + if (0 == cat_array.size()) + return LLUUID(); + else + { + LLViewerInventoryCategory *cat = cat_array.at(0); + if (cat) + return cat->getUUID(); + else + { + LL_WARNS() << "null cat" << LL_ENDL; + return LLUUID(); + } + } +} + +// We want this to be much lower (e.g. 15.0 is usually fine), bumping +// up for now until we can diagnose some cases of very slow response +// to requests. +const F32 DEFAULT_RETRY_AFTER_INTERVAL = 300.0; + +// Given the current back-end problems, retrying is causing too many +// duplicate items. Bump this back to 2 once they are resolved (or can +// leave at 0 if the operations become actually reliable). +const S32 DEFAULT_MAX_RETRIES = 0; + +class LLCallAfterInventoryBatchMgr: public LLEventTimer +{ +public: + LLCallAfterInventoryBatchMgr(const LLUUID& dst_cat_id, + const std::string& phase_name, + nullary_func_t on_completion_func, + nullary_func_t on_failure_func = no_op, + F32 retry_after = DEFAULT_RETRY_AFTER_INTERVAL, + S32 max_retries = DEFAULT_MAX_RETRIES + ): + mDstCatID(dst_cat_id), + mTrackingPhase(phase_name), + mOnCompletionFunc(on_completion_func), + mOnFailureFunc(on_failure_func), + mRetryAfter(retry_after), + mMaxRetries(max_retries), + mPendingRequests(0), + mFailCount(0), + mCompletionOrFailureCalled(false), + mRetryCount(0), + LLEventTimer(5.0) + { + if (!mTrackingPhase.empty()) + { + selfStartPhase(mTrackingPhase); + } + } + + void addItems(LLInventoryModel::item_array_t& src_items) + { + for (LLInventoryModel::item_array_t::const_iterator it = src_items.begin(); + it != src_items.end(); + ++it) + { + LLViewerInventoryItem* item = *it; + llassert(item); + addItem(item->getUUID()); + } + } + + // Request or re-request operation for specified item. + void addItem(const LLUUID& item_id) + { + LL_DEBUGS("Avatar") << "item_id " << item_id << LL_ENDL; + if (!requestOperation(item_id)) + { + LL_DEBUGS("Avatar") << "item_id " << item_id << " requestOperation false, skipping" << LL_ENDL; + return; + } + + mPendingRequests++; + // On a re-request, this will reset the timer. + mWaitTimes[item_id] = LLTimer(); + if (mRetryCounts.find(item_id) == mRetryCounts.end()) + { + mRetryCounts[item_id] = 0; + } + else + { + mRetryCounts[item_id]++; + } + } + + virtual bool requestOperation(const LLUUID& item_id) = 0; + + void onOp(const LLUUID& src_id, const LLUUID& dst_id, LLTimer timestamp) + { + if (ll_frand() < gSavedSettings.getF32("InventoryDebugSimulateLateOpRate")) + { + LL_WARNS() << "Simulating late operation by punting handling to later" << LL_ENDL; + doAfterInterval(boost::bind(&LLCallAfterInventoryBatchMgr::onOp,this,src_id,dst_id,timestamp), + mRetryAfter); + return; + } + mPendingRequests--; + F32 elapsed = timestamp.getElapsedTimeF32(); + LL_DEBUGS("Avatar") << "op done, src_id " << src_id << " dst_id " << dst_id << " after " << elapsed << " seconds" << LL_ENDL; + if (mWaitTimes.find(src_id) == mWaitTimes.end()) + { + // No longer waiting for this item - either serviced + // already or gave up after too many retries. + LL_WARNS() << "duplicate or late operation, src_id " << src_id << "dst_id " << dst_id + << " elapsed " << elapsed << " after end " << (S32) mCompletionOrFailureCalled << LL_ENDL; + } + mTimeStats.push(elapsed); + mWaitTimes.erase(src_id); + if (mWaitTimes.empty() && !mCompletionOrFailureCalled) + { + onCompletionOrFailure(); + } + } + + void onCompletionOrFailure() + { + assert (!mCompletionOrFailureCalled); + mCompletionOrFailureCalled = true; + + // Will never call onCompletion() if any item has been flagged as + // a failure - otherwise could wind up with corrupted + // outfit, involuntary nudity, etc. + reportStats(); + if (!mTrackingPhase.empty()) + { + selfStopPhase(mTrackingPhase); + } + if (!mFailCount) + { + onCompletion(); + } + else + { + onFailure(); + } + } + + void onFailure() + { + LL_INFOS() << "failed" << LL_ENDL; + mOnFailureFunc(); + } + + void onCompletion() + { + LL_INFOS() << "done" << LL_ENDL; + mOnCompletionFunc(); + } + + // virtual + // Will be deleted after returning true - only safe to do this if all callbacks have fired. + BOOL tick() + { + // mPendingRequests will be zero if all requests have been + // responded to. mWaitTimes.empty() will be true if we have + // received at least one reply for each UUID. If requests + // have been dropped and retried, these will not necessarily + // be the same. Only safe to return true if all requests have + // been serviced, since it will result in this object being + // deleted. + bool all_done = (mPendingRequests==0); + + if (!mWaitTimes.empty()) + { + LL_WARNS() << "still waiting on " << mWaitTimes.size() << " items" << LL_ENDL; + for (std::map::iterator it = mWaitTimes.begin(); + it != mWaitTimes.end();) + { + // Use a copy of iterator because it may be erased/invalidated. + std::map::iterator curr_it = it; + ++it; + + F32 time_waited = curr_it->second.getElapsedTimeF32(); + S32 retries = mRetryCounts[curr_it->first]; + if (time_waited > mRetryAfter) + { + if (retries < mMaxRetries) + { + LL_DEBUGS("Avatar") << "Waited " << time_waited << + " for " << curr_it->first << ", retrying" << LL_ENDL; + mRetryCount++; + addItem(curr_it->first); + } + else + { + LL_WARNS() << "Giving up on " << curr_it->first << " after too many retries" << LL_ENDL; + mWaitTimes.erase(curr_it); + mFailCount++; + } + } + if (mWaitTimes.empty()) + { + onCompletionOrFailure(); + } + + } + } + return all_done; + } + + void reportStats() + { + LL_DEBUGS("Avatar") << "Phase: " << mTrackingPhase << LL_ENDL; + LL_DEBUGS("Avatar") << "mFailCount: " << mFailCount << LL_ENDL; + LL_DEBUGS("Avatar") << "mRetryCount: " << mRetryCount << LL_ENDL; + LL_DEBUGS("Avatar") << "Times: n " << mTimeStats.getCount() << " min " << mTimeStats.getMinValue() << " max " << mTimeStats.getMaxValue() << LL_ENDL; + LL_DEBUGS("Avatar") << "Mean " << mTimeStats.getMean() << " stddev " << mTimeStats.getStdDev() << LL_ENDL; + } + + virtual ~LLCallAfterInventoryBatchMgr() + { + LL_DEBUGS("Avatar") << "deleting" << LL_ENDL; + } + +protected: + std::string mTrackingPhase; + std::map mWaitTimes; + std::map mRetryCounts; + LLUUID mDstCatID; + nullary_func_t mOnCompletionFunc; + nullary_func_t mOnFailureFunc; + F32 mRetryAfter; + S32 mMaxRetries; + S32 mPendingRequests; + S32 mFailCount; + S32 mRetryCount; + bool mCompletionOrFailureCalled; + LLViewerStats::StatsAccumulator mTimeStats; +}; + +class LLCallAfterInventoryCopyMgr: public LLCallAfterInventoryBatchMgr +{ +public: + LLCallAfterInventoryCopyMgr(LLInventoryModel::item_array_t& src_items, + const LLUUID& dst_cat_id, + const std::string& phase_name, + nullary_func_t on_completion_func, + nullary_func_t on_failure_func = no_op, + F32 retry_after = DEFAULT_RETRY_AFTER_INTERVAL, + S32 max_retries = DEFAULT_MAX_RETRIES + ): + LLCallAfterInventoryBatchMgr(dst_cat_id, phase_name, on_completion_func, on_failure_func, retry_after, max_retries) + { + addItems(src_items); + sInstanceCount++; + } + + ~LLCallAfterInventoryCopyMgr() + { + sInstanceCount--; + } + + virtual bool requestOperation(const LLUUID& item_id) + { + LLViewerInventoryItem *item = gInventory.getItem(item_id); + llassert(item); + LL_DEBUGS("Avatar") << "copying item " << item_id << LL_ENDL; + if (ll_frand() < gSavedSettings.getF32("InventoryDebugSimulateOpFailureRate")) + { + LL_DEBUGS("Avatar") << "simulating failure by not sending request for item " << item_id << LL_ENDL; + return true; + } + copy_inventory_item( + gAgent.getID(), + item->getPermissions().getOwner(), + item->getUUID(), + mDstCatID, + std::string(), + new LLBoostFuncInventoryCallback(boost::bind(&LLCallAfterInventoryBatchMgr::onOp,this,item_id,_1,LLTimer())) + ); + return true; + } + + static S32 getInstanceCount() { return sInstanceCount; } + +private: + static S32 sInstanceCount; +}; + +S32 LLCallAfterInventoryCopyMgr::sInstanceCount = 0; + +class LLWearCategoryAfterCopy: public LLInventoryCallback +{ +public: + LLWearCategoryAfterCopy(bool append): + mAppend(append) + {} + + // virtual + void fire(const LLUUID& id) + { + // Wear the inventory category. + LLInventoryCategory* cat = gInventory.getCategory(id); + LLAppearanceMgr::instance().wearInventoryCategoryOnAvatar(cat, mAppend); + } + +private: + bool mAppend; +}; + +class LLTrackPhaseWrapper : public LLInventoryCallback +{ +public: + LLTrackPhaseWrapper(const std::string& phase_name, LLPointer cb = NULL): + mTrackingPhase(phase_name), + mCB(cb) + { + selfStartPhase(mTrackingPhase); + } + + // virtual + void fire(const LLUUID& id) + { + if (mCB) + { + mCB->fire(id); + } + } + + // virtual + ~LLTrackPhaseWrapper() + { + selfStopPhase(mTrackingPhase); + } + +protected: + std::string mTrackingPhase; + LLPointer mCB; +}; + +LLUpdateAppearanceOnDestroy::LLUpdateAppearanceOnDestroy(bool enforce_item_restrictions, + bool enforce_ordering, + nullary_func_t post_update_func + ): + mFireCount(0), + mEnforceItemRestrictions(enforce_item_restrictions), + mEnforceOrdering(enforce_ordering), + mPostUpdateFunc(post_update_func) +{ + selfStartPhase("update_appearance_on_destroy"); +} + +void LLUpdateAppearanceOnDestroy::fire(const LLUUID& inv_item) +{ + LLViewerInventoryItem* item = (LLViewerInventoryItem*)gInventory.getItem(inv_item); + const std::string item_name = item ? item->getName() : "ITEM NOT FOUND"; +#ifndef LL_RELEASE_FOR_DOWNLOAD + LL_DEBUGS("Avatar") << self_av_string() << "callback fired [ name:" << item_name << " UUID:" << inv_item << " count:" << mFireCount << " ] " << LL_ENDL; +#endif + mFireCount++; +} + +LLUpdateAppearanceOnDestroy::~LLUpdateAppearanceOnDestroy() +{ + if (!LLApp::isExiting()) + { + // speculative fix for MAINT-1150 + LL_INFOS("Avatar") << self_av_string() << "done update appearance on destroy" << LL_ENDL; + + selfStopPhase("update_appearance_on_destroy"); + + LLAppearanceMgr::instance().updateAppearanceFromCOF(mEnforceItemRestrictions, + mEnforceOrdering, + mPostUpdateFunc); + } +} + +LLUpdateAppearanceAndEditWearableOnDestroy::LLUpdateAppearanceAndEditWearableOnDestroy(const LLUUID& item_id): + mItemID(item_id) +{ +} + +void edit_wearable_and_customize_avatar(LLUUID item_id) +{ + // Start editing the item if previously requested. + gAgentWearables.editWearableIfRequested(item_id); + + // TODO: camera mode may not be changed if a debug setting is tweaked + if( gAgentCamera.cameraCustomizeAvatar() ) + { + // If we're in appearance editing mode, the current tab may need to be refreshed + LLSidepanelAppearance *panel = dynamic_cast( + LLFloaterSidePanelContainer::getPanel("appearance")); + if (panel) + { + panel->showDefaultSubpart(); + } + } +} + +LLUpdateAppearanceAndEditWearableOnDestroy::~LLUpdateAppearanceAndEditWearableOnDestroy() +{ + if (!LLApp::isExiting()) + { + LLAppearanceMgr::instance().updateAppearanceFromCOF( + true,true, + boost::bind(edit_wearable_and_customize_avatar, mItemID)); + } +} + + +struct LLFoundData +{ + LLFoundData() : + mAssetType(LLAssetType::AT_NONE), + mWearableType(LLWearableType::WT_INVALID), + mWearable(NULL) {} + + LLFoundData(const LLUUID& item_id, + const LLUUID& asset_id, + const std::string& name, + const LLAssetType::EType& asset_type, + const LLWearableType::EType& wearable_type, + const bool is_replacement = false + ) : + mItemID(item_id), + mAssetID(asset_id), + mName(name), + mAssetType(asset_type), + mWearableType(wearable_type), + mIsReplacement(is_replacement), + mWearable( NULL ) {} + + LLUUID mItemID; + LLUUID mAssetID; + std::string mName; + LLAssetType::EType mAssetType; + LLWearableType::EType mWearableType; + LLViewerWearable* mWearable; + bool mIsReplacement; +}; + + +class LLWearableHoldingPattern +{ + LOG_CLASS(LLWearableHoldingPattern); + +public: + LLWearableHoldingPattern(); + ~LLWearableHoldingPattern(); + + bool pollFetchCompletion(); + void onFetchCompletion(); + bool isFetchCompleted(); + bool isTimedOut(); + + void checkMissingWearables(); + bool pollMissingWearables(); + bool isMissingCompleted(); + void recoverMissingWearable(LLWearableType::EType type); + void clearCOFLinksForMissingWearables(); + + void onWearableAssetFetch(LLViewerWearable *wearable); + void onAllComplete(); + + typedef std::list found_list_t; + found_list_t& getFoundList(); + void eraseTypeToLink(LLWearableType::EType type); + void eraseTypeToRecover(LLWearableType::EType type); + void setObjItems(const LLInventoryModel::item_array_t& items); + void setGestItems(const LLInventoryModel::item_array_t& items); + bool isMostRecent(); + void handleLateArrivals(); + void resetTime(F32 timeout); + static S32 countActive() { return sActiveHoldingPatterns.size(); } + S32 index() { return mIndex; } + +private: + found_list_t mFoundList; + LLInventoryModel::item_array_t mObjItems; + LLInventoryModel::item_array_t mGestItems; + typedef std::set type_set_t; + type_set_t mTypesToRecover; + type_set_t mTypesToLink; + S32 mResolved; + LLTimer mWaitTime; + bool mFired; + typedef std::set type_set_hp; + static type_set_hp sActiveHoldingPatterns; + static S32 sNextIndex; + S32 mIndex; + bool mIsMostRecent; + std::set mLateArrivals; + bool mIsAllComplete; +}; + +LLWearableHoldingPattern::type_set_hp LLWearableHoldingPattern::sActiveHoldingPatterns; +S32 LLWearableHoldingPattern::sNextIndex = 0; + +LLWearableHoldingPattern::LLWearableHoldingPattern(): + mResolved(0), + mFired(false), + mIsMostRecent(true), + mIsAllComplete(false) +{ + if (countActive()>0) + { + LL_INFOS() << "Creating LLWearableHoldingPattern when " + << countActive() + << " other attempts are active." + << " Flagging others as invalid." + << LL_ENDL; + for (type_set_hp::iterator it = sActiveHoldingPatterns.begin(); + it != sActiveHoldingPatterns.end(); + ++it) + { + (*it)->mIsMostRecent = false; + } + + } + mIndex = sNextIndex++; + sActiveHoldingPatterns.insert(this); + LL_DEBUGS("Avatar") << "HP " << index() << " created" << LL_ENDL; + selfStartPhase("holding_pattern"); +} + +LLWearableHoldingPattern::~LLWearableHoldingPattern() +{ + sActiveHoldingPatterns.erase(this); + if (isMostRecent()) + { + selfStopPhase("holding_pattern"); + } + LL_DEBUGS("Avatar") << "HP " << index() << " deleted" << LL_ENDL; +} + +bool LLWearableHoldingPattern::isMostRecent() +{ + return mIsMostRecent; +} + +LLWearableHoldingPattern::found_list_t& LLWearableHoldingPattern::getFoundList() +{ + return mFoundList; +} + +void LLWearableHoldingPattern::eraseTypeToLink(LLWearableType::EType type) +{ + mTypesToLink.erase(type); +} + +void LLWearableHoldingPattern::eraseTypeToRecover(LLWearableType::EType type) +{ + mTypesToRecover.erase(type); +} + +void LLWearableHoldingPattern::setObjItems(const LLInventoryModel::item_array_t& items) +{ + mObjItems = items; +} + +void LLWearableHoldingPattern::setGestItems(const LLInventoryModel::item_array_t& items) +{ + mGestItems = items; +} + +bool LLWearableHoldingPattern::isFetchCompleted() +{ + return (mResolved >= (S32)getFoundList().size()); // have everything we were waiting for? +} + +bool LLWearableHoldingPattern::isTimedOut() +{ + return mWaitTime.hasExpired(); +} + +void LLWearableHoldingPattern::checkMissingWearables() +{ + if (!isMostRecent()) + { + // runway why don't we actually skip here? + LL_WARNS() << self_av_string() << "skipping because LLWearableHolding pattern is invalid (superceded by later outfit request)" << LL_ENDL; + } + + std::vector found_by_type(LLWearableType::WT_COUNT,0); + std::vector requested_by_type(LLWearableType::WT_COUNT,0); + for (found_list_t::iterator it = getFoundList().begin(); it != getFoundList().end(); ++it) + { + LLFoundData &data = *it; + if (data.mWearableType < LLWearableType::WT_COUNT) + requested_by_type[data.mWearableType]++; + if (data.mWearable) + found_by_type[data.mWearableType]++; + } + + for (S32 type = 0; type < LLWearableType::WT_COUNT; ++type) + { + if (requested_by_type[type] > found_by_type[type]) + { + LL_WARNS() << self_av_string() << "got fewer wearables than requested, type " << type << ": requested " << requested_by_type[type] << ", found " << found_by_type[type] << LL_ENDL; + } + if (found_by_type[type] > 0) + continue; + if ( + // If at least one wearable of certain types (pants/shirt/skirt) + // was requested but none was found, create a default asset as a replacement. + // In all other cases, don't do anything. + // For critical types (shape/hair/skin/eyes), this will keep the avatar as a cloud + // due to logic in LLVOAvatarSelf::getIsCloud(). + // For non-critical types (tatoo, socks, etc.) the wearable will just be missing. + (requested_by_type[type] > 0) && + ((type == LLWearableType::WT_PANTS) || (type == LLWearableType::WT_SHIRT) || (type == LLWearableType::WT_SKIRT))) + { + mTypesToRecover.insert(type); + mTypesToLink.insert(type); + recoverMissingWearable((LLWearableType::EType)type); + LL_WARNS() << self_av_string() << "need to replace " << type << LL_ENDL; + } + } + + resetTime(60.0F); + + if (isMostRecent()) + { + selfStartPhase("get_missing_wearables_2"); + } + if (!pollMissingWearables()) + { + doOnIdleRepeating(boost::bind(&LLWearableHoldingPattern::pollMissingWearables,this)); + } +} + +void LLWearableHoldingPattern::onAllComplete() +{ + if (isAgentAvatarValid()) + { + gAgentAvatarp->outputRezTiming("Agent wearables fetch complete"); + } + + if (!isMostRecent()) + { + // runway need to skip here? + LL_WARNS() << self_av_string() << "skipping because LLWearableHolding pattern is invalid (superceded by later outfit request)" << LL_ENDL; + } + + // Activate all gestures in this folder + if (mGestItems.size() > 0) + { + LL_DEBUGS("Avatar") << self_av_string() << "Activating " << mGestItems.size() << " gestures" << LL_ENDL; + + LLGestureMgr::instance().activateGestures(mGestItems); + + // Update the inventory item labels to reflect the fact + // they are active. + LLViewerInventoryCategory* catp = + gInventory.getCategory(LLAppearanceMgr::instance().getCOF()); + + if (catp) + { + gInventory.updateCategory(catp); + gInventory.notifyObservers(); + } + } + + if (isAgentAvatarValid()) + { + LL_DEBUGS("Avatar") << self_av_string() << "Updating " << mObjItems.size() << " attachments" << LL_ENDL; + LLAgentWearables::llvo_vec_t objects_to_remove; + LLAgentWearables::llvo_vec_t objects_to_retain; + LLInventoryModel::item_array_t items_to_add; + + LLAgentWearables::findAttachmentsAddRemoveInfo(mObjItems, + objects_to_remove, + objects_to_retain, + items_to_add); + + LL_DEBUGS("Avatar") << self_av_string() << "Removing " << objects_to_remove.size() + << " attachments" << LL_ENDL; + + // Here we remove the attachment pos overrides for *all* + // attachments, even those that are not being removed. This is + // needed to get joint positions all slammed down to their + // pre-attachment states. + gAgentAvatarp->clearAttachmentPosOverrides(); + + // Take off the attachments that will no longer be in the outfit. + LLAgentWearables::userRemoveMultipleAttachments(objects_to_remove); + + // Update wearables. + LL_INFOS("Avatar") << self_av_string() << "HP " << index() << " updating agent wearables with " + << mResolved << " wearable items " << LL_ENDL; + LLAppearanceMgr::instance().updateAgentWearables(this); + + // Restore attachment pos overrides for the attachments that + // are remaining in the outfit. + for (LLAgentWearables::llvo_vec_t::iterator it = objects_to_retain.begin(); + it != objects_to_retain.end(); + ++it) + { + LLViewerObject *objectp = *it; + gAgentAvatarp->addAttachmentPosOverridesForObject(objectp); + } + + // Add new attachments to match those requested. + LL_DEBUGS("Avatar") << self_av_string() << "Adding " << items_to_add.size() << " attachments" << LL_ENDL; + LLAgentWearables::userAttachMultipleAttachments(items_to_add); + } + + if (isFetchCompleted() && isMissingCompleted()) + { + // Only safe to delete if all wearable callbacks and all missing wearables completed. + delete this; + } + else + { + mIsAllComplete = true; + handleLateArrivals(); + } +} + +void LLWearableHoldingPattern::onFetchCompletion() +{ + if (isMostRecent()) + { + selfStopPhase("get_wearables_2"); + } + + if (!isMostRecent()) + { + // runway skip here? + LL_WARNS() << self_av_string() << "skipping because LLWearableHolding pattern is invalid (superceded by later outfit request)" << LL_ENDL; + } + + checkMissingWearables(); +} + +// Runs as an idle callback until all wearables are fetched (or we time out). +bool LLWearableHoldingPattern::pollFetchCompletion() +{ + if (!isMostRecent()) + { + // runway skip here? + LL_WARNS() << self_av_string() << "skipping because LLWearableHolding pattern is invalid (superceded by later outfit request)" << LL_ENDL; + } + + bool completed = isFetchCompleted(); + bool timed_out = isTimedOut(); + bool done = completed || timed_out; + + if (done) + { + LL_INFOS("Avatar") << self_av_string() << "HP " << index() << " polling, done status: " << completed << " timed out " << timed_out + << " elapsed " << mWaitTime.getElapsedTimeF32() << LL_ENDL; + + mFired = true; + + if (timed_out) + { + LL_WARNS() << self_av_string() << "Exceeded max wait time for wearables, updating appearance based on what has arrived" << LL_ENDL; + } + + onFetchCompletion(); + } + return done; +} + +void recovered_item_link_cb(const LLUUID& item_id, LLWearableType::EType type, LLViewerWearable *wearable, LLWearableHoldingPattern* holder) +{ + if (!holder->isMostRecent()) + { + LL_WARNS() << "HP " << holder->index() << " skipping because LLWearableHolding pattern is invalid (superceded by later outfit request)" << LL_ENDL; + // runway skip here? + } + + LL_INFOS() << "HP " << holder->index() << " recovered item link for type " << type << LL_ENDL; + holder->eraseTypeToLink(type); + // Add wearable to FoundData for actual wearing + LLViewerInventoryItem *item = gInventory.getItem(item_id); + LLViewerInventoryItem *linked_item = item ? item->getLinkedItem() : NULL; + + if (linked_item) + { + gInventory.addChangedMask(LLInventoryObserver::LABEL, linked_item->getUUID()); + + if (item) + { + LLFoundData found(linked_item->getUUID(), + linked_item->getAssetUUID(), + linked_item->getName(), + linked_item->getType(), + linked_item->isWearableType() ? linked_item->getWearableType() : LLWearableType::WT_INVALID, + true // is replacement + ); + found.mWearable = wearable; + holder->getFoundList().push_front(found); + } + else + { + LL_WARNS() << self_av_string() << "inventory link not found for recovered wearable" << LL_ENDL; + } + } + else + { + LL_WARNS() << self_av_string() << "HP " << holder->index() << " inventory link not found for recovered wearable" << LL_ENDL; + } +} + +void recovered_item_cb(const LLUUID& item_id, LLWearableType::EType type, LLViewerWearable *wearable, LLWearableHoldingPattern* holder) +{ + if (!holder->isMostRecent()) + { + // runway skip here? + LL_WARNS() << self_av_string() << "skipping because LLWearableHolding pattern is invalid (superceded by later outfit request)" << LL_ENDL; + } + + LL_DEBUGS("Avatar") << self_av_string() << "Recovered item for type " << type << LL_ENDL; + LLConstPointer itemp = gInventory.getItem(item_id); + wearable->setItemID(item_id); + holder->eraseTypeToRecover(type); + llassert(itemp); + if (itemp) + { + LLPointer cb = new LLBoostFuncInventoryCallback(boost::bind(recovered_item_link_cb,_1,type,wearable,holder)); + + link_inventory_object(LLAppearanceMgr::instance().getCOF(), itemp, cb); + } +} + +void LLWearableHoldingPattern::recoverMissingWearable(LLWearableType::EType type) +{ + if (!isMostRecent()) + { + // runway skip here? + LL_WARNS() << self_av_string() << "skipping because LLWearableHolding pattern is invalid (superceded by later outfit request)" << LL_ENDL; + } + + // Try to recover by replacing missing wearable with a new one. + LLNotificationsUtil::add("ReplacedMissingWearable"); + LL_DEBUGS() << "Wearable " << LLWearableType::getTypeLabel(type) + << " could not be downloaded. Replaced inventory item with default wearable." << LL_ENDL; + LLViewerWearable* wearable = LLWearableList::instance().createNewWearable(type, gAgentAvatarp); + + // Add a new one in the lost and found folder. + const LLUUID lost_and_found_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_LOST_AND_FOUND); + LLPointer cb = new LLBoostFuncInventoryCallback(boost::bind(recovered_item_cb,_1,type,wearable,this)); + + create_inventory_item(gAgent.getID(), + gAgent.getSessionID(), + lost_and_found_id, + wearable->getTransactionID(), + wearable->getName(), + wearable->getDescription(), + wearable->getAssetType(), + LLInventoryType::IT_WEARABLE, + wearable->getType(), + wearable->getPermissions().getMaskNextOwner(), + cb); +} + +bool LLWearableHoldingPattern::isMissingCompleted() +{ + return mTypesToLink.size()==0 && mTypesToRecover.size()==0; +} + +void LLWearableHoldingPattern::clearCOFLinksForMissingWearables() +{ + for (found_list_t::iterator it = getFoundList().begin(); it != getFoundList().end(); ++it) + { + LLFoundData &data = *it; + if ((data.mWearableType < LLWearableType::WT_COUNT) && (!data.mWearable)) + { + // Wearable link that was never resolved; remove links to it from COF + LL_INFOS("Avatar") << self_av_string() << "HP " << index() << " removing link for unresolved item " << data.mItemID.asString() << LL_ENDL; + LLAppearanceMgr::instance().removeCOFItemLinks(data.mItemID); + } + } +} + +bool LLWearableHoldingPattern::pollMissingWearables() +{ + if (!isMostRecent()) + { + // runway skip here? + LL_WARNS() << self_av_string() << "skipping because LLWearableHolding pattern is invalid (superceded by later outfit request)" << LL_ENDL; + } + + bool timed_out = isTimedOut(); + bool missing_completed = isMissingCompleted(); + bool done = timed_out || missing_completed; + + if (!done) + { + LL_INFOS("Avatar") << self_av_string() << "HP " << index() << " polling missing wearables, waiting for items " << mTypesToRecover.size() + << " links " << mTypesToLink.size() + << " wearables, timed out " << timed_out + << " elapsed " << mWaitTime.getElapsedTimeF32() + << " done " << done << LL_ENDL; + } + + if (done) + { + if (isMostRecent()) + { + selfStopPhase("get_missing_wearables_2"); + } + + gAgentAvatarp->debugWearablesLoaded(); + + // BAP - if we don't call clearCOFLinksForMissingWearables() + // here, we won't have to add the link back in later if the + // wearable arrives late. This is to avoid corruption of + // wearable ordering info. Also has the effect of making + // unworn item links visible in the COF under some + // circumstances. + + //clearCOFLinksForMissingWearables(); + onAllComplete(); + } + return done; +} + +// Handle wearables that arrived after the timeout period expired. +void LLWearableHoldingPattern::handleLateArrivals() +{ + // Only safe to run if we have previously finished the missing + // wearables and other processing - otherwise we could be in some + // intermediate state - but have not been superceded by a later + // outfit change request. + if (mLateArrivals.size() == 0) + { + // Nothing to process. + return; + } + if (!isMostRecent()) + { + LL_WARNS() << self_av_string() << "Late arrivals not handled - outfit change no longer valid" << LL_ENDL; + } + if (!mIsAllComplete) + { + LL_WARNS() << self_av_string() << "Late arrivals not handled - in middle of missing wearables processing" << LL_ENDL; + } + + LL_INFOS("Avatar") << self_av_string() << "HP " << index() << " need to handle " << mLateArrivals.size() << " late arriving wearables" << LL_ENDL; + + // Update mFoundList using late-arriving wearables. + std::set replaced_types; + for (LLWearableHoldingPattern::found_list_t::iterator iter = getFoundList().begin(); + iter != getFoundList().end(); ++iter) + { + LLFoundData& data = *iter; + for (std::set::iterator wear_it = mLateArrivals.begin(); + wear_it != mLateArrivals.end(); + ++wear_it) + { + LLViewerWearable *wearable = *wear_it; + + if(wearable->getAssetID() == data.mAssetID) + { + data.mWearable = wearable; + + replaced_types.insert(data.mWearableType); + + // BAP - if we didn't call + // clearCOFLinksForMissingWearables() earlier, we + // don't need to restore the link here. Fixes + // wearable ordering problems. + + // LLAppearanceMgr::instance().addCOFItemLink(data.mItemID,false); + + // BAP failing this means inventory or asset server + // are corrupted in a way we don't handle. + llassert((data.mWearableType < LLWearableType::WT_COUNT) && (wearable->getType() == data.mWearableType)); + break; + } + } + } + + // Remove COF links for any default wearables previously used to replace the late arrivals. + // All this pussyfooting around with a while loop and explicit + // iterator incrementing is to allow removing items from the list + // without clobbering the iterator we're using to navigate. + LLWearableHoldingPattern::found_list_t::iterator iter = getFoundList().begin(); + while (iter != getFoundList().end()) + { + LLFoundData& data = *iter; + + // If an item of this type has recently shown up, removed the corresponding replacement wearable from COF. + if (data.mWearable && data.mIsReplacement && + replaced_types.find(data.mWearableType) != replaced_types.end()) + { + LLAppearanceMgr::instance().removeCOFItemLinks(data.mItemID); + std::list::iterator clobber_ator = iter; + ++iter; + getFoundList().erase(clobber_ator); + } + else + { + ++iter; + } + } + + // Clear contents of late arrivals. + mLateArrivals.clear(); + + // Update appearance based on mFoundList + LLAppearanceMgr::instance().updateAgentWearables(this); +} + +void LLWearableHoldingPattern::resetTime(F32 timeout) +{ + mWaitTime.reset(); + mWaitTime.setTimerExpirySec(timeout); +} + +void LLWearableHoldingPattern::onWearableAssetFetch(LLViewerWearable *wearable) +{ + if (!isMostRecent()) + { + LL_WARNS() << self_av_string() << "skipping because LLWearableHolding pattern is invalid (superceded by later outfit request)" << LL_ENDL; + } + + mResolved += 1; // just counting callbacks, not successes. + LL_DEBUGS("Avatar") << self_av_string() << "HP " << index() << " resolved " << mResolved << "/" << getFoundList().size() << LL_ENDL; + if (!wearable) + { + LL_WARNS() << self_av_string() << "no wearable found" << LL_ENDL; + } + + if (mFired) + { + LL_WARNS() << self_av_string() << "called after holder fired" << LL_ENDL; + if (wearable) + { + mLateArrivals.insert(wearable); + if (mIsAllComplete) + { + handleLateArrivals(); + } + } + return; + } + + if (!wearable) + { + return; + } + + for (LLWearableHoldingPattern::found_list_t::iterator iter = getFoundList().begin(); + iter != getFoundList().end(); ++iter) + { + LLFoundData& data = *iter; + if(wearable->getAssetID() == data.mAssetID) + { + // Failing this means inventory or asset server are corrupted in a way we don't handle. + if ((data.mWearableType >= LLWearableType::WT_COUNT) || (wearable->getType() != data.mWearableType)) + { + LL_WARNS() << self_av_string() << "recovered wearable but type invalid. inventory wearable type: " << data.mWearableType << " asset wearable type: " << wearable->getType() << LL_ENDL; + break; + } + + data.mWearable = wearable; + } + } +} + +static void onWearableAssetFetch(LLViewerWearable* wearable, void* data) +{ + LLWearableHoldingPattern* holder = (LLWearableHoldingPattern*)data; + holder->onWearableAssetFetch(wearable); +} + + +static void removeDuplicateItems(LLInventoryModel::item_array_t& items) +{ + LLInventoryModel::item_array_t new_items; + std::set items_seen; + std::deque tmp_list; + // Traverse from the front and keep the first of each item + // encountered, so we actually keep the *last* of each duplicate + // item. This is needed to give the right priority when adding + // duplicate items to an existing outfit. + for (S32 i=items.size()-1; i>=0; i--) + { + LLViewerInventoryItem *item = items.at(i); + LLUUID item_id = item->getLinkedUUID(); + if (items_seen.find(item_id)!=items_seen.end()) + continue; + items_seen.insert(item_id); + tmp_list.push_front(item); + } + for (std::deque::iterator it = tmp_list.begin(); + it != tmp_list.end(); + ++it) + { + new_items.push_back(*it); + } + items = new_items; +} + +//========================================================================= +class LLAppearanceMgrHttpHandler : public LLHttpSDHandler +{ +public: + LLAppearanceMgrHttpHandler(const std::string& capabilityURL, LLAppearanceMgr *mgr) : + LLHttpSDHandler(capabilityURL), + mManager(mgr) + { } + + virtual ~LLAppearanceMgrHttpHandler() + { } + virtual void onCompleted(LLCore::HttpHandle handle, LLCore::HttpResponse * response); -protected: - virtual void onSuccess(LLCore::HttpResponse * response, LLSD &content); - virtual void onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status); - -private: - static void debugCOF(const LLSD& content); - - LLAppearanceMgr *mManager; - -}; - -//------------------------------------------------------------------------- -void LLAppearanceMgrHttpHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpResponse * response) +protected: + virtual void onSuccess(LLCore::HttpResponse * response, LLSD &content); + virtual void onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status); + +private: + static void debugCOF(const LLSD& content); + + LLAppearanceMgr *mManager; + +}; + +//------------------------------------------------------------------------- +void LLAppearanceMgrHttpHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpResponse * response) +{ + mManager->decrementInFlightCounter(); + + LLHttpSDHandler::onCompleted(handle, response); +} + +void LLAppearanceMgrHttpHandler::onSuccess(LLCore::HttpResponse * response, LLSD &content) +{ + if (!content.isMap()) + { + LLCore::HttpStatus status = LLCore::HttpStatus(HTTP_INTERNAL_ERROR, "Malformed response contents"); + response->setStatus(status); + onFailure(response, status); + if (gSavedSettings.getBOOL("DebugAvatarAppearanceMessage")) + { + debugCOF(content); + } + return; + } + if (content["success"].asBoolean()) + { + LL_DEBUGS("Avatar") << "succeeded" << LL_ENDL; + if (gSavedSettings.getBOOL("DebugAvatarAppearanceMessage")) + { + dump_sequential_xml(gAgentAvatarp->getFullname() + "_appearance_request_ok", content); + } + } + else + { + LLCore::HttpStatus status = LLCore::HttpStatus(HTTP_INTERNAL_ERROR, "Non-success response"); + response->setStatus(status); + onFailure(response, status); + if (gSavedSettings.getBOOL("DebugAvatarAppearanceMessage")) + { + debugCOF(content); + } + return; + } +} + +void LLAppearanceMgrHttpHandler::onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status) +{ + LL_WARNS("Avatar") << "Appearance Mgr request failed to " << getUri() + << ". Reason code: (" << status.toTerseString() << ") " + << status.toString() << LL_ENDL; +} + +void LLAppearanceMgrHttpHandler::debugCOF(const LLSD& content) +{ + dump_sequential_xml(gAgentAvatarp->getFullname() + "_appearance_request_error", content); + + LL_INFOS("Avatar") << "AIS COF, version received: " << content["expected"].asInteger() + << " ================================= " << LL_ENDL; + std::set ais_items, local_items; + const LLSD& cof_raw = content["cof_raw"]; + for (LLSD::array_const_iterator it = cof_raw.beginArray(); + it != cof_raw.endArray(); ++it) + { + const LLSD& item = *it; + if (item["parent_id"].asUUID() == LLAppearanceMgr::instance().getCOF()) + { + ais_items.insert(item["item_id"].asUUID()); + if (item["type"].asInteger() == 24) // link + { + LL_INFOS("Avatar") << "AIS Link: item_id: " << item["item_id"].asUUID() + << " linked_item_id: " << item["asset_id"].asUUID() + << " name: " << item["name"].asString() + << LL_ENDL; + } + else if (item["type"].asInteger() == 25) // folder link + { + LL_INFOS("Avatar") << "AIS Folder link: item_id: " << item["item_id"].asUUID() + << " linked_item_id: " << item["asset_id"].asUUID() + << " name: " << item["name"].asString() + << LL_ENDL; + } + else + { + LL_INFOS("Avatar") << "AIS Other: item_id: " << item["item_id"].asUUID() + << " linked_item_id: " << item["asset_id"].asUUID() + << " name: " << item["name"].asString() + << " type: " << item["type"].asInteger() + << LL_ENDL; + } + } + } + LL_INFOS("Avatar") << LL_ENDL; + LL_INFOS("Avatar") << "Local COF, version requested: " << content["observed"].asInteger() + << " ================================= " << LL_ENDL; + LLInventoryModel::cat_array_t cat_array; + LLInventoryModel::item_array_t item_array; + gInventory.collectDescendents(LLAppearanceMgr::instance().getCOF(), + cat_array, item_array, LLInventoryModel::EXCLUDE_TRASH); + for (S32 i = 0; i < item_array.size(); i++) + { + const LLViewerInventoryItem* inv_item = item_array.at(i).get(); + local_items.insert(inv_item->getUUID()); + LL_INFOS("Avatar") << "LOCAL: item_id: " << inv_item->getUUID() + << " linked_item_id: " << inv_item->getLinkedUUID() + << " name: " << inv_item->getName() + << " parent: " << inv_item->getParentUUID() + << LL_ENDL; + } + LL_INFOS("Avatar") << " ================================= " << LL_ENDL; + S32 local_only = 0, ais_only = 0; + for (std::set::iterator it = local_items.begin(); it != local_items.end(); ++it) + { + if (ais_items.find(*it) == ais_items.end()) + { + LL_INFOS("Avatar") << "LOCAL ONLY: " << *it << LL_ENDL; + local_only++; + } + } + for (std::set::iterator it = ais_items.begin(); it != ais_items.end(); ++it) + { + if (local_items.find(*it) == local_items.end()) + { + LL_INFOS("Avatar") << "AIS ONLY: " << *it << LL_ENDL; + ais_only++; + } + } + if (local_only == 0 && ais_only == 0) + { + LL_INFOS("Avatar") << "COF contents identical, only version numbers differ (req " + << content["observed"].asInteger() + << " rcv " << content["expected"].asInteger() + << ")" << LL_ENDL; + } +} + +//========================================================================= + +const LLUUID LLAppearanceMgr::getCOF() const +{ + return gInventory.findCategoryUUIDForType(LLFolderType::FT_CURRENT_OUTFIT); +} + +S32 LLAppearanceMgr::getCOFVersion() const +{ + LLViewerInventoryCategory *cof = gInventory.getCategory(getCOF()); + if (cof) + { + return cof->getVersion(); + } + else + { + return LLViewerInventoryCategory::VERSION_UNKNOWN; + } +} + +const LLViewerInventoryItem* LLAppearanceMgr::getBaseOutfitLink() +{ + const LLUUID& current_outfit_cat = getCOF(); + LLInventoryModel::cat_array_t cat_array; + LLInventoryModel::item_array_t item_array; + // Can't search on FT_OUTFIT since links to categories return FT_CATEGORY for type since they don't + // return preferred type. + LLIsType is_category( LLAssetType::AT_CATEGORY ); + gInventory.collectDescendentsIf(current_outfit_cat, + cat_array, + item_array, + false, + is_category); + for (LLInventoryModel::item_array_t::const_iterator iter = item_array.begin(); + iter != item_array.end(); + iter++) + { + const LLViewerInventoryItem *item = (*iter); + const LLViewerInventoryCategory *cat = item->getLinkedCategory(); + if (cat && cat->getPreferredType() == LLFolderType::FT_OUTFIT) + { + const LLUUID parent_id = cat->getParentUUID(); + LLViewerInventoryCategory* parent_cat = gInventory.getCategory(parent_id); + // if base outfit moved to trash it means that we don't have base outfit + if (parent_cat != NULL && parent_cat->getPreferredType() == LLFolderType::FT_TRASH) + { + return NULL; + } + return item; + } + } + return NULL; +} + +bool LLAppearanceMgr::getBaseOutfitName(std::string& name) +{ + const LLViewerInventoryItem* outfit_link = getBaseOutfitLink(); + if(outfit_link) + { + const LLViewerInventoryCategory *cat = outfit_link->getLinkedCategory(); + if (cat) + { + name = cat->getName(); + return true; + } + } + return false; +} + +const LLUUID LLAppearanceMgr::getBaseOutfitUUID() +{ + const LLViewerInventoryItem* outfit_link = getBaseOutfitLink(); + if (!outfit_link || !outfit_link->getIsLinkType()) return LLUUID::null; + + const LLViewerInventoryCategory* outfit_cat = outfit_link->getLinkedCategory(); + if (!outfit_cat) return LLUUID::null; + + if (outfit_cat->getPreferredType() != LLFolderType::FT_OUTFIT) + { + LL_WARNS() << "Expected outfit type:" << LLFolderType::FT_OUTFIT << " but got type:" << outfit_cat->getType() << " for folder name:" << outfit_cat->getName() << LL_ENDL; + return LLUUID::null; + } + + return outfit_cat->getUUID(); +} + +void wear_on_avatar_cb(const LLUUID& inv_item, bool do_replace = false) +{ + if (inv_item.isNull()) + return; + + LLViewerInventoryItem *item = gInventory.getItem(inv_item); + if (item) + { + LLAppearanceMgr::instance().wearItemOnAvatar(inv_item, true, do_replace); + } +} + +bool LLAppearanceMgr::wearItemOnAvatar(const LLUUID& item_id_to_wear, + bool do_update, + bool replace, + LLPointer cb) +{ + + if (item_id_to_wear.isNull()) return false; + + // *TODO: issue with multi-wearable should be fixed: + // in this case this method will be called N times - loading started for each item + // and than N times will be called - loading completed for each item. + // That means subscribers will be notified that loading is done after first item in a batch is worn. + // (loading indicator disappears for example before all selected items are worn) + // Have not fix this issue for 2.1 because of stability reason. EXT-7777. + + // Disabled for now because it is *not* acceptable to call updateAppearanceFromCOF() multiple times +// gAgentWearables.notifyLoadingStarted(); + + LLViewerInventoryItem* item_to_wear = gInventory.getItem(item_id_to_wear); + if (!item_to_wear) return false; + + if (gInventory.isObjectDescendentOf(item_to_wear->getUUID(), gInventory.getLibraryRootFolderID())) + { + LLPointer cb = new LLBoostFuncInventoryCallback(boost::bind(wear_on_avatar_cb,_1,replace)); + copy_inventory_item(gAgent.getID(), item_to_wear->getPermissions().getOwner(), item_to_wear->getUUID(), LLUUID::null, std::string(), cb); + return false; + } + else if (!gInventory.isObjectDescendentOf(item_to_wear->getUUID(), gInventory.getRootFolderID())) + { + return false; // not in library and not in agent's inventory + } + else if (gInventory.isObjectDescendentOf(item_to_wear->getUUID(), gInventory.findCategoryUUIDForType(LLFolderType::FT_TRASH))) + { + LLNotificationsUtil::add("CannotWearTrash"); + return false; + } + else if (isLinkedInCOF(item_to_wear->getUUID())) // EXT-84911 + { + return false; + } + + switch (item_to_wear->getType()) + { + case LLAssetType::AT_CLOTHING: + if (gAgentWearables.areWearablesLoaded()) + { + if (!cb && do_update) + { + cb = new LLUpdateAppearanceAndEditWearableOnDestroy(item_id_to_wear); + } + S32 wearable_count = gAgentWearables.getWearableCount(item_to_wear->getWearableType()); + if ((replace && wearable_count != 0) || + (wearable_count >= LLAgentWearables::MAX_CLOTHING_PER_TYPE) ) + { + LLUUID item_id = gAgentWearables.getWearableItemID(item_to_wear->getWearableType(), + wearable_count-1); + removeCOFItemLinks(item_id, cb); + } + + addCOFItemLink(item_to_wear, cb); + } + break; + + case LLAssetType::AT_BODYPART: + // TODO: investigate wearables may not be loaded at this point EXT-8231 + + // Remove the existing wearables of the same type. + // Remove existing body parts anyway because we must not be able to wear e.g. two skins. + removeCOFLinksOfType(item_to_wear->getWearableType()); + if (!cb && do_update) + { + cb = new LLUpdateAppearanceAndEditWearableOnDestroy(item_id_to_wear); + } + addCOFItemLink(item_to_wear, cb); + break; + + case LLAssetType::AT_OBJECT: + rez_attachment(item_to_wear, NULL, replace); + break; + + default: return false;; + } + + return true; +} + +// Update appearance from outfit folder. +void LLAppearanceMgr::changeOutfit(bool proceed, const LLUUID& category, bool append) +{ + if (!proceed) + return; + LLAppearanceMgr::instance().updateCOF(category,append); +} + +void LLAppearanceMgr::replaceCurrentOutfit(const LLUUID& new_outfit) +{ + LLViewerInventoryCategory* cat = gInventory.getCategory(new_outfit); + wearInventoryCategory(cat, false, false); +} + +// Open outfit renaming dialog. +void LLAppearanceMgr::renameOutfit(const LLUUID& outfit_id) +{ + LLViewerInventoryCategory* cat = gInventory.getCategory(outfit_id); + if (!cat) + { + return; + } + + LLSD args; + args["NAME"] = cat->getName(); + + LLSD payload; + payload["cat_id"] = outfit_id; + + LLNotificationsUtil::add("RenameOutfit", args, payload, boost::bind(onOutfitRename, _1, _2)); +} + +// User typed new outfit name. +// static +void LLAppearanceMgr::onOutfitRename(const LLSD& notification, const LLSD& response) +{ + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); + if (option != 0) return; // canceled + + std::string outfit_name = response["new_name"].asString(); + LLStringUtil::trim(outfit_name); + if (!outfit_name.empty()) + { + LLUUID cat_id = notification["payload"]["cat_id"].asUUID(); + rename_category(&gInventory, cat_id, outfit_name); + } +} + +void LLAppearanceMgr::setOutfitLocked(bool locked) +{ + if (mOutfitLocked == locked) + { + return; + } + + mOutfitLocked = locked; + if (locked) + { + mUnlockOutfitTimer->reset(); + mUnlockOutfitTimer->start(); + } + else + { + mUnlockOutfitTimer->stop(); + } + + LLOutfitObserver::instance().notifyOutfitLockChanged(); +} + +void LLAppearanceMgr::addCategoryToCurrentOutfit(const LLUUID& cat_id) +{ + LLViewerInventoryCategory* cat = gInventory.getCategory(cat_id); + wearInventoryCategory(cat, false, true); +} + +void LLAppearanceMgr::takeOffOutfit(const LLUUID& cat_id) +{ + LLInventoryModel::cat_array_t cats; + LLInventoryModel::item_array_t items; + LLFindWearablesEx collector(/*is_worn=*/ true, /*include_body_parts=*/ false); + + gInventory.collectDescendentsIf(cat_id, cats, items, FALSE, collector); + + LLInventoryModel::item_array_t::const_iterator it = items.begin(); + const LLInventoryModel::item_array_t::const_iterator it_end = items.end(); + uuid_vec_t uuids_to_remove; + for( ; it_end != it; ++it) + { + LLViewerInventoryItem* item = *it; + uuids_to_remove.push_back(item->getUUID()); + } + removeItemsFromAvatar(uuids_to_remove); + + // deactivate all gestures in the outfit folder + LLInventoryModel::item_array_t gest_items; + getDescendentsOfAssetType(cat_id, gest_items, LLAssetType::AT_GESTURE); + for(S32 i = 0; i < gest_items.size(); ++i) + { + LLViewerInventoryItem *gest_item = gest_items[i]; + if ( LLGestureMgr::instance().isGestureActive( gest_item->getLinkedUUID()) ) + { + LLGestureMgr::instance().deactivateGesture( gest_item->getLinkedUUID() ); + } + } +} + +// Create a copy of src_id + contents as a subfolder of dst_id. +void LLAppearanceMgr::shallowCopyCategory(const LLUUID& src_id, const LLUUID& dst_id, + LLPointer cb) +{ + LLInventoryCategory *src_cat = gInventory.getCategory(src_id); + if (!src_cat) + { + LL_WARNS() << "folder not found for src " << src_id.asString() << LL_ENDL; + return; + } + LL_INFOS() << "starting, src_id " << src_id << " name " << src_cat->getName() << " dst_id " << dst_id << LL_ENDL; + LLUUID parent_id = dst_id; + if(parent_id.isNull()) + { + parent_id = gInventory.getRootFolderID(); + } + LLUUID subfolder_id = gInventory.createNewCategory( parent_id, + LLFolderType::FT_NONE, + src_cat->getName()); + shallowCopyCategoryContents(src_id, subfolder_id, cb); + + gInventory.notifyObservers(); +} + +void LLAppearanceMgr::slamCategoryLinks(const LLUUID& src_id, const LLUUID& dst_id, + bool include_folder_links, LLPointer cb) +{ + LLInventoryModel::cat_array_t* cats; + LLInventoryModel::item_array_t* items; + LLSD contents = LLSD::emptyArray(); + gInventory.getDirectDescendentsOf(src_id, cats, items); + LL_INFOS() << "copying " << items->size() << " items" << LL_ENDL; + for (LLInventoryModel::item_array_t::const_iterator iter = items->begin(); + iter != items->end(); + ++iter) + { + const LLViewerInventoryItem* item = (*iter); + switch (item->getActualType()) + { + case LLAssetType::AT_LINK: + { + LL_DEBUGS("Avatar") << "linking inventory item " << item->getName() << LL_ENDL; + //getActualDescription() is used for a new description + //to propagate ordering information saved in descriptions of links + LLSD item_contents; + item_contents["name"] = item->getName(); + item_contents["desc"] = item->getActualDescription(); + item_contents["linked_id"] = item->getLinkedUUID(); + item_contents["type"] = LLAssetType::AT_LINK; + contents.append(item_contents); + break; + } + case LLAssetType::AT_LINK_FOLDER: + { + LLViewerInventoryCategory *catp = item->getLinkedCategory(); + if (catp && include_folder_links) + { + LL_DEBUGS("Avatar") << "linking inventory folder " << item->getName() << LL_ENDL; + LLSD base_contents; + base_contents["name"] = catp->getName(); + base_contents["desc"] = ""; // categories don't have descriptions. + base_contents["linked_id"] = catp->getLinkedUUID(); + base_contents["type"] = LLAssetType::AT_LINK_FOLDER; + contents.append(base_contents); + } + break; + } + default: + { + // Linux refuses to compile unless all possible enums are handled. Really, Linux? + break; + } + } + } + slam_inventory_folder(dst_id, contents, cb); +} +// Copy contents of src_id to dst_id. +void LLAppearanceMgr::shallowCopyCategoryContents(const LLUUID& src_id, const LLUUID& dst_id, + LLPointer cb) +{ + LLInventoryModel::cat_array_t* cats; + LLInventoryModel::item_array_t* items; + gInventory.getDirectDescendentsOf(src_id, cats, items); + LL_INFOS() << "copying " << items->size() << " items" << LL_ENDL; + LLInventoryObject::const_object_list_t link_array; + for (LLInventoryModel::item_array_t::const_iterator iter = items->begin(); + iter != items->end(); + ++iter) + { + const LLViewerInventoryItem* item = (*iter); + switch (item->getActualType()) + { + case LLAssetType::AT_LINK: + { + LL_DEBUGS("Avatar") << "linking inventory item " << item->getName() << LL_ENDL; + link_array.push_back(LLConstPointer(item)); + break; + } + case LLAssetType::AT_LINK_FOLDER: + { + LLViewerInventoryCategory *catp = item->getLinkedCategory(); + // Skip copying outfit links. + if (catp && catp->getPreferredType() != LLFolderType::FT_OUTFIT) + { + LL_DEBUGS("Avatar") << "linking inventory folder " << item->getName() << LL_ENDL; + link_array.push_back(LLConstPointer(item)); + } + break; + } + case LLAssetType::AT_CLOTHING: + case LLAssetType::AT_OBJECT: + case LLAssetType::AT_BODYPART: + case LLAssetType::AT_GESTURE: + { + LL_DEBUGS("Avatar") << "copying inventory item " << item->getName() << LL_ENDL; + copy_inventory_item(gAgent.getID(), + item->getPermissions().getOwner(), + item->getUUID(), + dst_id, + item->getName(), + cb); + break; + } + default: + // Ignore non-outfit asset types + break; + } + } + if (!link_array.empty()) + { + link_inventory_array(dst_id, link_array, cb); + } +} + +BOOL LLAppearanceMgr::getCanMakeFolderIntoOutfit(const LLUUID& folder_id) +{ + // These are the wearable items that are required for considering this + // folder as containing a complete outfit. + U32 required_wearables = 0; + required_wearables |= 1LL << LLWearableType::WT_SHAPE; + required_wearables |= 1LL << LLWearableType::WT_SKIN; + required_wearables |= 1LL << LLWearableType::WT_HAIR; + required_wearables |= 1LL << LLWearableType::WT_EYES; + + // These are the wearables that the folder actually contains. + U32 folder_wearables = 0; + LLInventoryModel::cat_array_t* cats; + LLInventoryModel::item_array_t* items; + gInventory.getDirectDescendentsOf(folder_id, cats, items); + for (LLInventoryModel::item_array_t::const_iterator iter = items->begin(); + iter != items->end(); + ++iter) + { + const LLViewerInventoryItem* item = (*iter); + if (item->isWearableType()) + { + const LLWearableType::EType wearable_type = item->getWearableType(); + folder_wearables |= 1LL << wearable_type; + } + } + + // If the folder contains the required wearables, return TRUE. + return ((required_wearables & folder_wearables) == required_wearables); +} + +bool LLAppearanceMgr::getCanRemoveOutfit(const LLUUID& outfit_cat_id) +{ + // Disallow removing the base outfit. + if (outfit_cat_id == getBaseOutfitUUID()) + { + return false; + } + + // Check if the outfit folder itself is removable. + if (!get_is_category_removable(&gInventory, outfit_cat_id)) + { + return false; + } + + // Check for the folder's non-removable descendants. + LLFindNonRemovableObjects filter_non_removable; + LLInventoryModel::cat_array_t cats; + LLInventoryModel::item_array_t items; + LLInventoryModel::item_array_t::const_iterator it; + gInventory.collectDescendentsIf(outfit_cat_id, cats, items, false, filter_non_removable); + if (!cats.empty() || !items.empty()) + { + return false; + } + + return true; +} + +// static +bool LLAppearanceMgr::getCanRemoveFromCOF(const LLUUID& outfit_cat_id) +{ + if (gAgentWearables.isCOFChangeInProgress()) + { + return false; + } + + LLFindWearablesEx is_worn(/*is_worn=*/ true, /*include_body_parts=*/ false); + return gInventory.hasMatchingDirectDescendent(outfit_cat_id, is_worn); +} + +// static +bool LLAppearanceMgr::getCanAddToCOF(const LLUUID& outfit_cat_id) +{ + if (gAgentWearables.isCOFChangeInProgress()) + { + return false; + } + + LLInventoryModel::cat_array_t cats; + LLInventoryModel::item_array_t items; + LLFindWearablesEx not_worn(/*is_worn=*/ false, /*include_body_parts=*/ false); + gInventory.collectDescendentsIf(outfit_cat_id, + cats, + items, + LLInventoryModel::EXCLUDE_TRASH, + not_worn); + + return items.size() > 0; +} + +bool LLAppearanceMgr::getCanReplaceCOF(const LLUUID& outfit_cat_id) +{ + // Don't allow wearing anything while we're changing appearance. + if (gAgentWearables.isCOFChangeInProgress()) + { + return false; + } + + // Check whether it's the base outfit. + if (outfit_cat_id.isNull() || outfit_cat_id == getBaseOutfitUUID()) + { + return false; + } + + // Check whether the outfit contains any wearables we aren't wearing already (STORM-702). + LLInventoryModel::cat_array_t cats; + LLInventoryModel::item_array_t items; + LLFindWearablesEx is_worn(/*is_worn=*/ false, /*include_body_parts=*/ true); + gInventory.collectDescendentsIf(outfit_cat_id, + cats, + items, + LLInventoryModel::EXCLUDE_TRASH, + is_worn); + + return items.size() > 0; +} + +void LLAppearanceMgr::purgeBaseOutfitLink(const LLUUID& category, LLPointer cb) +{ + LLInventoryModel::cat_array_t cats; + LLInventoryModel::item_array_t items; + gInventory.collectDescendents(category, cats, items, + LLInventoryModel::EXCLUDE_TRASH); + for (S32 i = 0; i < items.size(); ++i) + { + LLViewerInventoryItem *item = items.at(i); + if (item->getActualType() != LLAssetType::AT_LINK_FOLDER) + continue; + LLViewerInventoryCategory* catp = item->getLinkedCategory(); + if(catp && catp->getPreferredType() == LLFolderType::FT_OUTFIT) + { + remove_inventory_item(item->getUUID(), cb); + } + } +} + +// Keep the last N wearables of each type. For viewer 2.0, N is 1 for +// both body parts and clothing items. +void LLAppearanceMgr::filterWearableItems( + LLInventoryModel::item_array_t& items, S32 max_per_type) +{ + // Divvy items into arrays by wearable type. + std::vector items_by_type(LLWearableType::WT_COUNT); + divvyWearablesByType(items, items_by_type); + + // rebuild items list, retaining the last max_per_type of each array + items.clear(); + for (S32 i=0; igetName() : "[UNKNOWN]") << "'" << LL_ENDL; + + const LLUUID cof = getCOF(); + + // Deactivate currently active gestures in the COF, if replacing outfit + if (!append) + { + LLInventoryModel::item_array_t gest_items; + getDescendentsOfAssetType(cof, gest_items, LLAssetType::AT_GESTURE); + for(S32 i = 0; i < gest_items.size(); ++i) + { + LLViewerInventoryItem *gest_item = gest_items.at(i); + if ( LLGestureMgr::instance().isGestureActive( gest_item->getLinkedUUID()) ) + { + LLGestureMgr::instance().deactivateGesture( gest_item->getLinkedUUID() ); + } + } + } + + // Collect and filter descendents to determine new COF contents. + + // - Body parts: always include COF contents as a fallback in case any + // required parts are missing. + // Preserve body parts from COF if appending. + LLInventoryModel::item_array_t body_items; + getDescendentsOfAssetType(cof, body_items, LLAssetType::AT_BODYPART); + getDescendentsOfAssetType(category, body_items, LLAssetType::AT_BODYPART); + if (append) + reverse(body_items.begin(), body_items.end()); + // Reduce body items to max of one per type. + removeDuplicateItems(body_items); + filterWearableItems(body_items, 1); + + // - Wearables: include COF contents only if appending. + LLInventoryModel::item_array_t wear_items; + if (append) + getDescendentsOfAssetType(cof, wear_items, LLAssetType::AT_CLOTHING); + getDescendentsOfAssetType(category, wear_items, LLAssetType::AT_CLOTHING); + // Reduce wearables to max of one per type. + removeDuplicateItems(wear_items); + filterWearableItems(wear_items, LLAgentWearables::MAX_CLOTHING_PER_TYPE); + + // - Attachments: include COF contents only if appending. + LLInventoryModel::item_array_t obj_items; + if (append) + getDescendentsOfAssetType(cof, obj_items, LLAssetType::AT_OBJECT); + getDescendentsOfAssetType(category, obj_items, LLAssetType::AT_OBJECT); + removeDuplicateItems(obj_items); + + // - Gestures: include COF contents only if appending. + LLInventoryModel::item_array_t gest_items; + if (append) + getDescendentsOfAssetType(cof, gest_items, LLAssetType::AT_GESTURE); + getDescendentsOfAssetType(category, gest_items, LLAssetType::AT_GESTURE); + removeDuplicateItems(gest_items); + + // Create links to new COF contents. + LLInventoryModel::item_array_t all_items; + std::copy(body_items.begin(), body_items.end(), std::back_inserter(all_items)); + std::copy(wear_items.begin(), wear_items.end(), std::back_inserter(all_items)); + std::copy(obj_items.begin(), obj_items.end(), std::back_inserter(all_items)); + std::copy(gest_items.begin(), gest_items.end(), std::back_inserter(all_items)); + + // Find any wearables that need description set to enforce ordering. + desc_map_t desc_map; + getWearableOrderingDescUpdates(wear_items, desc_map); + + // Will link all the above items. + // link_waiter enforce flags are false because we've already fixed everything up in updateCOF(). + LLPointer link_waiter = new LLUpdateAppearanceOnDestroy(false,false); + LLSD contents = LLSD::emptyArray(); + + for (LLInventoryModel::item_array_t::const_iterator it = all_items.begin(); + it != all_items.end(); ++it) + { + LLSD item_contents; + LLInventoryItem *item = *it; + + std::string desc; + desc_map_t::const_iterator desc_iter = desc_map.find(item->getUUID()); + if (desc_iter != desc_map.end()) + { + desc = desc_iter->second; + LL_DEBUGS("Avatar") << item->getName() << " overriding desc to: " << desc + << " (was: " << item->getActualDescription() << ")" << LL_ENDL; + } + else + { + desc = item->getActualDescription(); + } + + item_contents["name"] = item->getName(); + item_contents["desc"] = desc; + item_contents["linked_id"] = item->getLinkedUUID(); + item_contents["type"] = LLAssetType::AT_LINK; + contents.append(item_contents); + } + const LLUUID& base_id = append ? getBaseOutfitUUID() : category; + LLViewerInventoryCategory *base_cat = gInventory.getCategory(base_id); + if (base_cat) + { + LLSD base_contents; + base_contents["name"] = base_cat->getName(); + base_contents["desc"] = ""; + base_contents["linked_id"] = base_cat->getLinkedUUID(); + base_contents["type"] = LLAssetType::AT_LINK_FOLDER; + contents.append(base_contents); + } + if (gSavedSettings.getBOOL("DebugAvatarAppearanceMessage")) + { + dump_sequential_xml(gAgentAvatarp->getFullname() + "_slam_request", contents); + } + slam_inventory_folder(getCOF(), contents, link_waiter); + + LL_DEBUGS("Avatar") << self_av_string() << "waiting for LLUpdateAppearanceOnDestroy" << LL_ENDL; +} + +void LLAppearanceMgr::updatePanelOutfitName(const std::string& name) +{ + LLSidepanelAppearance* panel_appearance = + dynamic_cast(LLFloaterSidePanelContainer::getPanel("appearance")); + if (panel_appearance) + { + panel_appearance->refreshCurrentOutfitName(name); + } +} + +void LLAppearanceMgr::createBaseOutfitLink(const LLUUID& category, LLPointer link_waiter) +{ + const LLUUID cof = getCOF(); + LLViewerInventoryCategory* catp = gInventory.getCategory(category); + std::string new_outfit_name = ""; + + purgeBaseOutfitLink(cof, link_waiter); + + if (catp && catp->getPreferredType() == LLFolderType::FT_OUTFIT) + { + link_inventory_object(cof, catp, link_waiter); + new_outfit_name = catp->getName(); + } + + updatePanelOutfitName(new_outfit_name); +} + +void LLAppearanceMgr::updateAgentWearables(LLWearableHoldingPattern* holder) +{ + LL_DEBUGS("Avatar") << "updateAgentWearables()" << LL_ENDL; + LLInventoryItem::item_array_t items; + std::vector< LLViewerWearable* > wearables; + wearables.reserve(32); + + // For each wearable type, find the wearables of that type. + for( S32 i = 0; i < LLWearableType::WT_COUNT; i++ ) + { + for (LLWearableHoldingPattern::found_list_t::iterator iter = holder->getFoundList().begin(); + iter != holder->getFoundList().end(); ++iter) + { + LLFoundData& data = *iter; + LLViewerWearable* wearable = data.mWearable; + if( wearable && ((S32)wearable->getType() == i) ) + { + LLViewerInventoryItem* item = (LLViewerInventoryItem*)gInventory.getItem(data.mItemID); + if( item && (item->getAssetUUID() == wearable->getAssetID()) ) + { + items.push_back(item); + wearables.push_back(wearable); + } + } + } + } + + if(wearables.size() > 0) + { + gAgentWearables.setWearableOutfit(items, wearables); + } +} + +S32 LLAppearanceMgr::countActiveHoldingPatterns() +{ + return LLWearableHoldingPattern::countActive(); +} + +static void remove_non_link_items(LLInventoryModel::item_array_t &items) +{ + LLInventoryModel::item_array_t pruned_items; + for (LLInventoryModel::item_array_t::const_iterator iter = items.begin(); + iter != items.end(); + ++iter) + { + const LLViewerInventoryItem *item = (*iter); + if (item && item->getIsLinkType()) + { + pruned_items.push_back((*iter)); + } + } + items = pruned_items; +} + +//a predicate for sorting inventory items by actual descriptions +bool sort_by_actual_description(const LLInventoryItem* item1, const LLInventoryItem* item2) +{ + if (!item1 || !item2) + { + LL_WARNS() << "either item1 or item2 is NULL" << LL_ENDL; + return true; + } + + return item1->getActualDescription() < item2->getActualDescription(); +} + +void item_array_diff(LLInventoryModel::item_array_t& full_list, + LLInventoryModel::item_array_t& keep_list, + LLInventoryModel::item_array_t& kill_list) + +{ + for (LLInventoryModel::item_array_t::iterator it = full_list.begin(); + it != full_list.end(); + ++it) + { + LLViewerInventoryItem *item = *it; + if (std::find(keep_list.begin(), keep_list.end(), item) == keep_list.end()) + { + kill_list.push_back(item); + } + } +} + +S32 LLAppearanceMgr::findExcessOrDuplicateItems(const LLUUID& cat_id, + LLAssetType::EType type, + S32 max_items, + LLInventoryObject::object_list_t& items_to_kill) +{ + S32 to_kill_count = 0; + + LLInventoryModel::item_array_t items; + getDescendentsOfAssetType(cat_id, items, type); + LLInventoryModel::item_array_t curr_items = items; + removeDuplicateItems(items); + if (max_items > 0) + { + filterWearableItems(items, max_items); + } + LLInventoryModel::item_array_t kill_items; + item_array_diff(curr_items,items,kill_items); + for (LLInventoryModel::item_array_t::iterator it = kill_items.begin(); + it != kill_items.end(); + ++it) + { + items_to_kill.push_back(LLPointer(*it)); + to_kill_count++; + } + return to_kill_count; +} + + +void LLAppearanceMgr::findAllExcessOrDuplicateItems(const LLUUID& cat_id, + LLInventoryObject::object_list_t& items_to_kill) +{ + findExcessOrDuplicateItems(cat_id,LLAssetType::AT_BODYPART, + 1, items_to_kill); + findExcessOrDuplicateItems(cat_id,LLAssetType::AT_CLOTHING, + LLAgentWearables::MAX_CLOTHING_PER_TYPE, items_to_kill); + findExcessOrDuplicateItems(cat_id,LLAssetType::AT_OBJECT, + -1, items_to_kill); +} + +void LLAppearanceMgr::enforceCOFItemRestrictions(LLPointer cb) +{ + LLInventoryObject::object_list_t items_to_kill; + findAllExcessOrDuplicateItems(getCOF(), items_to_kill); + if (items_to_kill.size()>0) + { + // Remove duplicate or excess wearables. Should normally be enforced at the UI level, but + // this should catch anything that gets through. + remove_inventory_items(items_to_kill, cb); + } +} + +void LLAppearanceMgr::updateAppearanceFromCOF(bool enforce_item_restrictions, + bool enforce_ordering, + nullary_func_t post_update_func) +{ + if (mIsInUpdateAppearanceFromCOF) + { + LL_WARNS() << "Called updateAppearanceFromCOF inside updateAppearanceFromCOF, skipping" << LL_ENDL; + return; + } + + LL_DEBUGS("Avatar") << self_av_string() << "starting" << LL_ENDL; + + if (enforce_item_restrictions) + { + // The point here is just to call + // updateAppearanceFromCOF() again after excess items + // have been removed. That time we will set + // enforce_item_restrictions to false so we don't get + // caught in a perpetual loop. + LLPointer cb( + new LLUpdateAppearanceOnDestroy(false, enforce_ordering, post_update_func)); + enforceCOFItemRestrictions(cb); + return; + } + + if (enforce_ordering) + { + //checking integrity of the COF in terms of ordering of wearables, + //checking and updating links' descriptions of wearables in the COF (before analyzed for "dirty" state) + + // As with enforce_item_restrictions handling above, we want + // to wait for the update callbacks, then (finally!) call + // updateAppearanceFromCOF() with no additional COF munging needed. + LLPointer cb( + new LLUpdateAppearanceOnDestroy(false, false, post_update_func)); + updateClothingOrderingInfo(LLUUID::null, cb); + return; + } + + if (!validateClothingOrderingInfo()) + { + LL_WARNS() << "Clothing ordering error" << LL_ENDL; + } + + BoolSetter setIsInUpdateAppearanceFromCOF(mIsInUpdateAppearanceFromCOF); + selfStartPhase("update_appearance_from_cof"); + + // update dirty flag to see if the state of the COF matches + // the saved outfit stored as a folder link + updateIsDirty(); + + // Send server request for appearance update + if (gAgent.getRegion() && gAgent.getRegion()->getCentralBakeVersion()) + { + requestServerAppearanceUpdate(); + } + + LLUUID current_outfit_id = getCOF(); + + // Find all the wearables that are in the COF's subtree. + LL_DEBUGS() << "LLAppearanceMgr::updateFromCOF()" << LL_ENDL; + LLInventoryModel::item_array_t wear_items; + LLInventoryModel::item_array_t obj_items; + LLInventoryModel::item_array_t gest_items; + getUserDescendents(current_outfit_id, wear_items, obj_items, gest_items); + // Get rid of non-links in case somehow the COF was corrupted. + remove_non_link_items(wear_items); + remove_non_link_items(obj_items); + remove_non_link_items(gest_items); + + dumpItemArray(wear_items,"asset_dump: wear_item"); + dumpItemArray(obj_items,"asset_dump: obj_item"); + + LLViewerInventoryCategory *cof = gInventory.getCategory(current_outfit_id); + if (!gInventory.isCategoryComplete(current_outfit_id)) + { + LL_WARNS() << "COF info is not complete. Version " << cof->getVersion() + << " descendent_count " << cof->getDescendentCount() + << " viewer desc count " << cof->getViewerDescendentCount() << LL_ENDL; + } + if(!wear_items.size()) + { + LLNotificationsUtil::add("CouldNotPutOnOutfit"); + return; + } + + //preparing the list of wearables in the correct order for LLAgentWearables + sortItemsByActualDescription(wear_items); + + + LL_DEBUGS("Avatar") << "HP block starts" << LL_ENDL; + LLTimer hp_block_timer; + LLWearableHoldingPattern* holder = new LLWearableHoldingPattern; + + holder->setObjItems(obj_items); + holder->setGestItems(gest_items); + + // Note: can't do normal iteration, because if all the + // wearables can be resolved immediately, then the + // callback will be called (and this object deleted) + // before the final getNextData(). + + for(S32 i = 0; i < wear_items.size(); ++i) + { + LLViewerInventoryItem *item = wear_items.at(i); + LLViewerInventoryItem *linked_item = item ? item->getLinkedItem() : NULL; + + // Fault injection: use debug setting to test asset + // fetch failures (should be replaced by new defaults in + // lost&found). + U32 skip_type = gSavedSettings.getU32("ForceAssetFail"); + + if (item && item->getIsLinkType() && linked_item) + { + LLFoundData found(linked_item->getUUID(), + linked_item->getAssetUUID(), + linked_item->getName(), + linked_item->getType(), + linked_item->isWearableType() ? linked_item->getWearableType() : LLWearableType::WT_INVALID + ); + + if (skip_type != LLWearableType::WT_INVALID && skip_type == found.mWearableType) + { + found.mAssetID.generate(); // Replace with new UUID, guaranteed not to exist in DB + } + //pushing back, not front, to preserve order of wearables for LLAgentWearables + holder->getFoundList().push_back(found); + } + else + { + if (!item) + { + LL_WARNS() << "Attempt to wear a null item " << LL_ENDL; + } + else if (!linked_item) + { + LL_WARNS() << "Attempt to wear a broken link [ name:" << item->getName() << " ] " << LL_ENDL; + } + } + } + + selfStartPhase("get_wearables_2"); + + for (LLWearableHoldingPattern::found_list_t::iterator it = holder->getFoundList().begin(); + it != holder->getFoundList().end(); ++it) + { + LLFoundData& found = *it; + + LL_DEBUGS() << self_av_string() << "waiting for onWearableAssetFetch callback, asset " << found.mAssetID.asString() << LL_ENDL; + + // Fetch the wearables about to be worn. + LLWearableList::instance().getAsset(found.mAssetID, + found.mName, + gAgentAvatarp, + found.mAssetType, + onWearableAssetFetch, + (void*)holder); + + } + + holder->resetTime(gSavedSettings.getF32("MaxWearableWaitTime")); + if (!holder->pollFetchCompletion()) + { + doOnIdleRepeating(boost::bind(&LLWearableHoldingPattern::pollFetchCompletion,holder)); + } + post_update_func(); + + LL_DEBUGS("Avatar") << "HP block ends, elapsed " << hp_block_timer.getElapsedTimeF32() << LL_ENDL; +} + +void LLAppearanceMgr::getDescendentsOfAssetType(const LLUUID& category, + LLInventoryModel::item_array_t& items, + LLAssetType::EType type) +{ + LLInventoryModel::cat_array_t cats; + LLIsType is_of_type(type); + gInventory.collectDescendentsIf(category, + cats, + items, + LLInventoryModel::EXCLUDE_TRASH, + is_of_type); +} + +void LLAppearanceMgr::getUserDescendents(const LLUUID& category, + LLInventoryModel::item_array_t& wear_items, + LLInventoryModel::item_array_t& obj_items, + LLInventoryModel::item_array_t& gest_items) +{ + LLInventoryModel::cat_array_t wear_cats; + LLFindWearables is_wearable; + gInventory.collectDescendentsIf(category, + wear_cats, + wear_items, + LLInventoryModel::EXCLUDE_TRASH, + is_wearable); + + LLInventoryModel::cat_array_t obj_cats; + LLIsType is_object( LLAssetType::AT_OBJECT ); + gInventory.collectDescendentsIf(category, + obj_cats, + obj_items, + LLInventoryModel::EXCLUDE_TRASH, + is_object); + + // Find all gestures in this folder + LLInventoryModel::cat_array_t gest_cats; + LLIsType is_gesture( LLAssetType::AT_GESTURE ); + gInventory.collectDescendentsIf(category, + gest_cats, + gest_items, + LLInventoryModel::EXCLUDE_TRASH, + is_gesture); +} + +void LLAppearanceMgr::wearInventoryCategory(LLInventoryCategory* category, bool copy, bool append) +{ + if(!category) return; + + selfClearPhases(); + selfStartPhase("wear_inventory_category"); + + gAgentWearables.notifyLoadingStarted(); + + LL_INFOS("Avatar") << self_av_string() << "wearInventoryCategory( " << category->getName() + << " )" << LL_ENDL; + + // If we are copying from library, attempt to use AIS to copy the category. + bool ais_ran=false; + if (copy && AISCommand::isAPIAvailable()) + { + LLUUID parent_id; + parent_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_CLOTHING); + if (parent_id.isNull()) + { + parent_id = gInventory.getRootFolderID(); + } + + LLPointer copy_cb = new LLWearCategoryAfterCopy(append); + LLPointer track_cb = new LLTrackPhaseWrapper( + std::string("wear_inventory_category_callback"), copy_cb); + LLPointer cmd_ptr = new CopyLibraryCategoryCommand(category->getUUID(), parent_id, track_cb); + ais_ran=cmd_ptr->run_command(); + } + + if (!ais_ran) + { + selfStartPhase("wear_inventory_category_fetch"); + callAfterCategoryFetch(category->getUUID(),boost::bind(&LLAppearanceMgr::wearCategoryFinal, + &LLAppearanceMgr::instance(), + category->getUUID(), copy, append)); + } +} + +S32 LLAppearanceMgr::getActiveCopyOperations() const +{ + return LLCallAfterInventoryCopyMgr::getInstanceCount(); +} + +void LLAppearanceMgr::wearCategoryFinal(LLUUID& cat_id, bool copy_items, bool append) +{ + LL_INFOS("Avatar") << self_av_string() << "starting" << LL_ENDL; + + selfStopPhase("wear_inventory_category_fetch"); + + // We now have an outfit ready to be copied to agent inventory. Do + // it, and wear that outfit normally. + LLInventoryCategory* cat = gInventory.getCategory(cat_id); + if(copy_items) + { + LLInventoryModel::cat_array_t* cats; + LLInventoryModel::item_array_t* items; + gInventory.getDirectDescendentsOf(cat_id, cats, items); + std::string name; + if(!cat) + { + // should never happen. + name = "New Outfit"; + } + else + { + name = cat->getName(); + } + LLViewerInventoryItem* item = NULL; + LLInventoryModel::item_array_t::const_iterator it = items->begin(); + LLInventoryModel::item_array_t::const_iterator end = items->end(); + LLUUID pid; + for(; it < end; ++it) + { + item = *it; + if(item) + { + if(LLInventoryType::IT_GESTURE == item->getInventoryType()) + { + pid = gInventory.findCategoryUUIDForType(LLFolderType::FT_GESTURE); + } + else + { + pid = gInventory.findCategoryUUIDForType(LLFolderType::FT_CLOTHING); + } + break; + } + } + if(pid.isNull()) + { + pid = gInventory.getRootFolderID(); + } + + LLUUID new_cat_id = gInventory.createNewCategory( + pid, + LLFolderType::FT_NONE, + name); + + // Create a CopyMgr that will copy items, manage its own destruction + new LLCallAfterInventoryCopyMgr( + *items, new_cat_id, std::string("wear_inventory_category_callback"), + boost::bind(&LLAppearanceMgr::wearInventoryCategoryOnAvatar, + LLAppearanceMgr::getInstance(), + gInventory.getCategory(new_cat_id), + append)); + + // BAP fixes a lag in display of created dir. + gInventory.notifyObservers(); + } + else + { + // Wear the inventory category. + LLAppearanceMgr::instance().wearInventoryCategoryOnAvatar(cat, append); + } +} + +// *NOTE: hack to get from avatar inventory to avatar +void LLAppearanceMgr::wearInventoryCategoryOnAvatar( LLInventoryCategory* category, bool append ) +{ + // Avoid unintentionally overwriting old wearables. We have to do + // this up front to avoid having to deal with the case of multiple + // wearables being dirty. + if (!category) return; + + if ( !LLInventoryCallbackManager::is_instantiated() ) + { + // shutting down, ignore. + return; + } + + LL_INFOS("Avatar") << self_av_string() << "wearInventoryCategoryOnAvatar '" << category->getName() + << "'" << LL_ENDL; + + if (gAgentCamera.cameraCustomizeAvatar()) + { + // switching to outfit editor should automagically save any currently edited wearable + LLFloaterSidePanelContainer::showPanel("appearance", LLSD().with("type", "edit_outfit")); + } + + LLAppearanceMgr::changeOutfit(TRUE, category->getUUID(), append); +} + +// FIXME do we really want to search entire inventory for matching name? +void LLAppearanceMgr::wearOutfitByName(const std::string& name) +{ + LL_INFOS("Avatar") << self_av_string() << "Wearing category " << name << LL_ENDL; + + LLInventoryModel::cat_array_t cat_array; + LLInventoryModel::item_array_t item_array; + LLNameCategoryCollector has_name(name); + gInventory.collectDescendentsIf(gInventory.getRootFolderID(), + cat_array, + item_array, + LLInventoryModel::EXCLUDE_TRASH, + has_name); + bool copy_items = false; + LLInventoryCategory* cat = NULL; + if (cat_array.size() > 0) + { + // Just wear the first one that matches + cat = cat_array.at(0); + } + else + { + gInventory.collectDescendentsIf(LLUUID::null, + cat_array, + item_array, + LLInventoryModel::EXCLUDE_TRASH, + has_name); + if(cat_array.size() > 0) + { + cat = cat_array.at(0); + copy_items = true; + } + } + + if(cat) + { + LLAppearanceMgr::wearInventoryCategory(cat, copy_items, false); + } + else + { + LL_WARNS() << "Couldn't find outfit " <isWearableType() && b->isWearableType() && + (a->getWearableType() == b->getWearableType())); +} + +class LLDeferredCOFLinkObserver: public LLInventoryObserver +{ +public: + LLDeferredCOFLinkObserver(const LLUUID& item_id, LLPointer cb, const std::string& description): + mItemID(item_id), + mCallback(cb), + mDescription(description) + { + } + + ~LLDeferredCOFLinkObserver() + { + } + + /* virtual */ void changed(U32 mask) + { + const LLInventoryItem *item = gInventory.getItem(mItemID); + if (item) + { + gInventory.removeObserver(this); + LLAppearanceMgr::instance().addCOFItemLink(item, mCallback, mDescription); + delete this; + } + } + +private: + const LLUUID mItemID; + std::string mDescription; + LLPointer mCallback; +}; + + +// BAP - note that this runs asynchronously if the item is not already loaded from inventory. +// Dangerous if caller assumes link will exist after calling the function. +void LLAppearanceMgr::addCOFItemLink(const LLUUID &item_id, + LLPointer cb, + const std::string description) +{ + const LLInventoryItem *item = gInventory.getItem(item_id); + if (!item) + { + LLDeferredCOFLinkObserver *observer = new LLDeferredCOFLinkObserver(item_id, cb, description); + gInventory.addObserver(observer); + } + else + { + addCOFItemLink(item, cb, description); + } +} + +void LLAppearanceMgr::addCOFItemLink(const LLInventoryItem *item, + LLPointer cb, + const std::string description) { - mManager->decrementInFlightCounter(); - - LLHttpSDHandler::onCompleted(handle, response); + const LLViewerInventoryItem *vitem = dynamic_cast(item); + if (!vitem) + { + LL_WARNS() << "not an llviewerinventoryitem, failed" << LL_ENDL; + return; + } + + gInventory.addChangedMask(LLInventoryObserver::LABEL, vitem->getLinkedUUID()); + + LLInventoryModel::cat_array_t cat_array; + LLInventoryModel::item_array_t item_array; + gInventory.collectDescendents(LLAppearanceMgr::getCOF(), + cat_array, + item_array, + LLInventoryModel::EXCLUDE_TRASH); + bool linked_already = false; + U32 count = 0; + for (S32 i=0; igetWearableType(); + + const bool is_body_part = (wearable_type == LLWearableType::WT_SHAPE) + || (wearable_type == LLWearableType::WT_HAIR) + || (wearable_type == LLWearableType::WT_EYES) + || (wearable_type == LLWearableType::WT_SKIN); + + if (inv_item->getLinkedUUID() == vitem->getLinkedUUID()) + { + linked_already = true; + } + // Are these links to different items of the same body part + // type? If so, new item will replace old. + else if ((vitem->isWearableType()) && (vitem->getWearableType() == wearable_type)) + { + ++count; + if (is_body_part && inv_item->getIsLinkType() && (vitem->getWearableType() == wearable_type)) + { + remove_inventory_item(inv_item->getUUID(), cb); + } + else if (count >= LLAgentWearables::MAX_CLOTHING_PER_TYPE) + { + // MULTI-WEARABLES: make sure we don't go over MAX_CLOTHING_PER_TYPE + remove_inventory_item(inv_item->getUUID(), cb); + } + } + } + + if (!linked_already) + { + LLViewerInventoryItem *copy_item = new LLViewerInventoryItem; + copy_item->copyViewerItem(vitem); + copy_item->setDescription(description); + link_inventory_object(getCOF(), copy_item, cb); + } +} + +LLInventoryModel::item_array_t LLAppearanceMgr::findCOFItemLinks(const LLUUID& item_id) +{ + + LLInventoryModel::item_array_t result; + const LLViewerInventoryItem *vitem = + dynamic_cast(gInventory.getItem(item_id)); + + if (vitem) + { + LLInventoryModel::cat_array_t cat_array; + LLInventoryModel::item_array_t item_array; + gInventory.collectDescendents(LLAppearanceMgr::getCOF(), + cat_array, + item_array, + LLInventoryModel::EXCLUDE_TRASH); + for (S32 i=0; igetLinkedUUID() == vitem->getLinkedUUID()) + { + result.push_back(item_array.at(i)); + } + } + } + return result; +} + +bool LLAppearanceMgr::isLinkedInCOF(const LLUUID& item_id) +{ + LLInventoryModel::item_array_t links = LLAppearanceMgr::instance().findCOFItemLinks(item_id); + return links.size() > 0; +} + +void LLAppearanceMgr::removeAllClothesFromAvatar() +{ + // Fetch worn clothes (i.e. the ones in COF). + LLInventoryModel::item_array_t clothing_items; + LLInventoryModel::cat_array_t dummy; + LLIsType is_clothing(LLAssetType::AT_CLOTHING); + gInventory.collectDescendentsIf(getCOF(), + dummy, + clothing_items, + LLInventoryModel::EXCLUDE_TRASH, + is_clothing); + uuid_vec_t item_ids; + for (LLInventoryModel::item_array_t::iterator it = clothing_items.begin(); + it != clothing_items.end(); ++it) + { + item_ids.push_back((*it).get()->getLinkedUUID()); + } + + // Take them off by removing from COF. + removeItemsFromAvatar(item_ids); +} + +void LLAppearanceMgr::removeAllAttachmentsFromAvatar() +{ + if (!isAgentAvatarValid()) return; + + LLAgentWearables::llvo_vec_t objects_to_remove; + + for (LLVOAvatar::attachment_map_t::iterator iter = gAgentAvatarp->mAttachmentPoints.begin(); + iter != gAgentAvatarp->mAttachmentPoints.end();) + { + LLVOAvatar::attachment_map_t::iterator curiter = iter++; + LLViewerJointAttachment* attachment = curiter->second; + for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin(); + attachment_iter != attachment->mAttachedObjects.end(); + ++attachment_iter) + { + LLViewerObject *attached_object = (*attachment_iter); + if (attached_object) + { + objects_to_remove.push_back(attached_object); + } + } + } + uuid_vec_t ids_to_remove; + for (LLAgentWearables::llvo_vec_t::iterator it = objects_to_remove.begin(); + it != objects_to_remove.end(); + ++it) + { + ids_to_remove.push_back((*it)->getAttachmentItemID()); + } + removeItemsFromAvatar(ids_to_remove); +} + +void LLAppearanceMgr::removeCOFItemLinks(const LLUUID& item_id, LLPointer cb) +{ + gInventory.addChangedMask(LLInventoryObserver::LABEL, item_id); + + LLInventoryModel::cat_array_t cat_array; + LLInventoryModel::item_array_t item_array; + gInventory.collectDescendents(LLAppearanceMgr::getCOF(), + cat_array, + item_array, + LLInventoryModel::EXCLUDE_TRASH); + for (S32 i=0; igetIsLinkType() && item->getLinkedUUID() == item_id) + { + bool immediate_delete = false; + if (item->getType() == LLAssetType::AT_OBJECT) + { + immediate_delete = true; + } + remove_inventory_item(item->getUUID(), cb, immediate_delete); + } + } +} + +void LLAppearanceMgr::removeCOFLinksOfType(LLWearableType::EType type, LLPointer cb) +{ + LLFindWearablesOfType filter_wearables_of_type(type); + LLInventoryModel::cat_array_t cats; + LLInventoryModel::item_array_t items; + LLInventoryModel::item_array_t::const_iterator it; + + gInventory.collectDescendentsIf(getCOF(), cats, items, true, filter_wearables_of_type); + for (it = items.begin(); it != items.end(); ++it) + { + const LLViewerInventoryItem* item = *it; + if (item->getIsLinkType()) // we must operate on links only + { + remove_inventory_item(item->getUUID(), cb); + } + } +} + +bool sort_by_linked_uuid(const LLViewerInventoryItem* item1, const LLViewerInventoryItem* item2) +{ + if (!item1 || !item2) + { + LL_WARNS() << "item1, item2 cannot be null, something is very wrong" << LL_ENDL; + return true; + } + + return item1->getLinkedUUID() < item2->getLinkedUUID(); +} + +void LLAppearanceMgr::updateIsDirty() +{ + LLUUID cof = getCOF(); + LLUUID base_outfit; + + // find base outfit link + const LLViewerInventoryItem* base_outfit_item = getBaseOutfitLink(); + LLViewerInventoryCategory* catp = NULL; + if (base_outfit_item && base_outfit_item->getIsLinkType()) + { + catp = base_outfit_item->getLinkedCategory(); + } + if(catp && catp->getPreferredType() == LLFolderType::FT_OUTFIT) + { + base_outfit = catp->getUUID(); + } + + // Set dirty to "false" if no base outfit found to disable "Save" + // and leave only "Save As" enabled in My Outfits. + mOutfitIsDirty = false; + + if (base_outfit.notNull()) + { + LLIsValidItemLink collector; + + LLInventoryModel::cat_array_t cof_cats; + LLInventoryModel::item_array_t cof_items; + gInventory.collectDescendentsIf(cof, cof_cats, cof_items, + LLInventoryModel::EXCLUDE_TRASH, collector); + + LLInventoryModel::cat_array_t outfit_cats; + LLInventoryModel::item_array_t outfit_items; + gInventory.collectDescendentsIf(base_outfit, outfit_cats, outfit_items, + LLInventoryModel::EXCLUDE_TRASH, collector); + + if(outfit_items.size() != cof_items.size()) + { + LL_DEBUGS("Avatar") << "item count different - base " << outfit_items.size() << " cof " << cof_items.size() << LL_ENDL; + // Current outfit folder should have one more item than the outfit folder. + // this one item is the link back to the outfit folder itself. + mOutfitIsDirty = true; + return; + } + + //"dirty" - also means a difference in linked UUIDs and/or a difference in wearables order (links' descriptions) + std::sort(cof_items.begin(), cof_items.end(), sort_by_linked_uuid); + std::sort(outfit_items.begin(), outfit_items.end(), sort_by_linked_uuid); + + for (U32 i = 0; i < cof_items.size(); ++i) + { + LLViewerInventoryItem *item1 = cof_items.at(i); + LLViewerInventoryItem *item2 = outfit_items.at(i); + + if (item1->getLinkedUUID() != item2->getLinkedUUID() || + item1->getName() != item2->getName() || + item1->getActualDescription() != item2->getActualDescription()) + { + if (item1->getLinkedUUID() != item2->getLinkedUUID()) + { + LL_DEBUGS("Avatar") << "link id different " << LL_ENDL; + } + else + { + if (item1->getName() != item2->getName()) + { + LL_DEBUGS("Avatar") << "name different " << item1->getName() << " " << item2->getName() << LL_ENDL; + } + if (item1->getActualDescription() != item2->getActualDescription()) + { + LL_DEBUGS("Avatar") << "desc different " << item1->getActualDescription() + << " " << item2->getActualDescription() + << " names " << item1->getName() << " " << item2->getName() << LL_ENDL; + } + } + mOutfitIsDirty = true; + return; + } + } + } + llassert(!mOutfitIsDirty); + LL_DEBUGS("Avatar") << "clean" << LL_ENDL; +} + +// *HACK: Must match name in Library or agent inventory +const std::string ROOT_GESTURES_FOLDER = "Gestures"; +const std::string COMMON_GESTURES_FOLDER = "Common Gestures"; +const std::string MALE_GESTURES_FOLDER = "Male Gestures"; +const std::string FEMALE_GESTURES_FOLDER = "Female Gestures"; +const std::string SPEECH_GESTURES_FOLDER = "Speech Gestures"; +const std::string OTHER_GESTURES_FOLDER = "Other Gestures"; + +void LLAppearanceMgr::copyLibraryGestures() +{ + LL_INFOS("Avatar") << self_av_string() << "Copying library gestures" << LL_ENDL; + + // Copy gestures + LLUUID lib_gesture_cat_id = + gInventory.findLibraryCategoryUUIDForType(LLFolderType::FT_GESTURE,false); + if (lib_gesture_cat_id.isNull()) + { + LL_WARNS() << "Unable to copy gestures, source category not found" << LL_ENDL; + } + LLUUID dst_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_GESTURE); + + std::vector gesture_folders_to_copy; + gesture_folders_to_copy.push_back(MALE_GESTURES_FOLDER); + gesture_folders_to_copy.push_back(FEMALE_GESTURES_FOLDER); + gesture_folders_to_copy.push_back(COMMON_GESTURES_FOLDER); + gesture_folders_to_copy.push_back(SPEECH_GESTURES_FOLDER); + gesture_folders_to_copy.push_back(OTHER_GESTURES_FOLDER); + + for(std::vector::iterator it = gesture_folders_to_copy.begin(); + it != gesture_folders_to_copy.end(); + ++it) + { + std::string& folder_name = *it; + + LLPointer cb(NULL); + + // After copying gestures, activate Common, Other, plus + // Male and/or Female, depending upon the initial outfit gender. + ESex gender = gAgentAvatarp->getSex(); + + std::string activate_male_gestures; + std::string activate_female_gestures; + switch (gender) { + case SEX_MALE: + activate_male_gestures = MALE_GESTURES_FOLDER; + break; + case SEX_FEMALE: + activate_female_gestures = FEMALE_GESTURES_FOLDER; + break; + case SEX_BOTH: + activate_male_gestures = MALE_GESTURES_FOLDER; + activate_female_gestures = FEMALE_GESTURES_FOLDER; + break; + } + + if (folder_name == activate_male_gestures || + folder_name == activate_female_gestures || + folder_name == COMMON_GESTURES_FOLDER || + folder_name == OTHER_GESTURES_FOLDER) + { + cb = new LLBoostFuncInventoryCallback(activate_gesture_cb); + } + + LLUUID cat_id = findDescendentCategoryIDByName(lib_gesture_cat_id,folder_name); + if (cat_id.isNull()) + { + LL_WARNS() << self_av_string() << "failed to find gesture folder for " << folder_name << LL_ENDL; + } + else + { + LL_DEBUGS("Avatar") << self_av_string() << "initiating fetch and copy for " << folder_name << " cat_id " << cat_id << LL_ENDL; + callAfterCategoryFetch(cat_id, + boost::bind(&LLAppearanceMgr::shallowCopyCategory, + &LLAppearanceMgr::instance(), + cat_id, dst_id, cb)); + } + } +} + +// Handler for anything that's deferred until avatar de-clouds. +void LLAppearanceMgr::onFirstFullyVisible() +{ + gAgentAvatarp->outputRezTiming("Avatar fully loaded"); + gAgentAvatarp->reportAvatarRezTime(); + gAgentAvatarp->debugAvatarVisible(); + + // If this is the first time we've ever logged in, + // then copy default gestures from the library. + if (gAgent.isFirstLogin()) { + copyLibraryGestures(); + } } - -void LLAppearanceMgrHttpHandler::onSuccess(LLCore::HttpResponse * response, LLSD &content) -{ - if (!content.isMap()) - { - LLCore::HttpStatus status = LLCore::HttpStatus(HTTP_INTERNAL_ERROR, "Malformed response contents"); - response->setStatus(status); - onFailure(response, status); - if (gSavedSettings.getBOOL("DebugAvatarAppearanceMessage")) - { - debugCOF(content); - } - return; - } - if (content["success"].asBoolean()) - { - LL_DEBUGS("Avatar") << "succeeded" << LL_ENDL; - if (gSavedSettings.getBOOL("DebugAvatarAppearanceMessage")) - { - dump_sequential_xml(gAgentAvatarp->getFullname() + "_appearance_request_ok", content); - } - } - else - { - LLCore::HttpStatus status = LLCore::HttpStatus(HTTP_INTERNAL_ERROR, "Non-success response"); - response->setStatus(status); - onFailure(response, status); - if (gSavedSettings.getBOOL("DebugAvatarAppearanceMessage")) - { - debugCOF(content); - } - return; - } -} - -void LLAppearanceMgrHttpHandler::onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status) -{ - LL_WARNS("Avatar") << "Appearance Mgr request failed to " << getUri() - << ". Reason code: (" << status.toTerseString() << ") " - << status.toString() << LL_ENDL; -} - -void LLAppearanceMgrHttpHandler::debugCOF(const LLSD& content) -{ - dump_sequential_xml(gAgentAvatarp->getFullname() + "_appearance_request_error", content); - - LL_INFOS("Avatar") << "AIS COF, version received: " << content["expected"].asInteger() - << " ================================= " << LL_ENDL; - std::set ais_items, local_items; - const LLSD& cof_raw = content["cof_raw"]; - for (LLSD::array_const_iterator it = cof_raw.beginArray(); - it != cof_raw.endArray(); ++it) - { - const LLSD& item = *it; - if (item["parent_id"].asUUID() == LLAppearanceMgr::instance().getCOF()) - { - ais_items.insert(item["item_id"].asUUID()); - if (item["type"].asInteger() == 24) // link - { - LL_INFOS("Avatar") << "AIS Link: item_id: " << item["item_id"].asUUID() - << " linked_item_id: " << item["asset_id"].asUUID() - << " name: " << item["name"].asString() - << LL_ENDL; - } - else if (item["type"].asInteger() == 25) // folder link - { - LL_INFOS("Avatar") << "AIS Folder link: item_id: " << item["item_id"].asUUID() - << " linked_item_id: " << item["asset_id"].asUUID() - << " name: " << item["name"].asString() - << LL_ENDL; - } - else - { - LL_INFOS("Avatar") << "AIS Other: item_id: " << item["item_id"].asUUID() - << " linked_item_id: " << item["asset_id"].asUUID() - << " name: " << item["name"].asString() - << " type: " << item["type"].asInteger() - << LL_ENDL; - } - } - } - LL_INFOS("Avatar") << LL_ENDL; - LL_INFOS("Avatar") << "Local COF, version requested: " << content["observed"].asInteger() - << " ================================= " << LL_ENDL; - LLInventoryModel::cat_array_t cat_array; - LLInventoryModel::item_array_t item_array; - gInventory.collectDescendents(LLAppearanceMgr::instance().getCOF(), - cat_array, item_array, LLInventoryModel::EXCLUDE_TRASH); - for (S32 i = 0; i < item_array.size(); i++) - { - const LLViewerInventoryItem* inv_item = item_array.at(i).get(); - local_items.insert(inv_item->getUUID()); - LL_INFOS("Avatar") << "LOCAL: item_id: " << inv_item->getUUID() - << " linked_item_id: " << inv_item->getLinkedUUID() - << " name: " << inv_item->getName() - << " parent: " << inv_item->getParentUUID() - << LL_ENDL; - } - LL_INFOS("Avatar") << " ================================= " << LL_ENDL; - S32 local_only = 0, ais_only = 0; - for (std::set::iterator it = local_items.begin(); it != local_items.end(); ++it) - { - if (ais_items.find(*it) == ais_items.end()) - { - LL_INFOS("Avatar") << "LOCAL ONLY: " << *it << LL_ENDL; - local_only++; - } - } - for (std::set::iterator it = ais_items.begin(); it != ais_items.end(); ++it) - { - if (local_items.find(*it) == local_items.end()) - { - LL_INFOS("Avatar") << "AIS ONLY: " << *it << LL_ENDL; - ais_only++; - } - } - if (local_only == 0 && ais_only == 0) - { - LL_INFOS("Avatar") << "COF contents identical, only version numbers differ (req " - << content["observed"].asInteger() - << " rcv " << content["expected"].asInteger() - << ")" << LL_ENDL; - } -} - -//========================================================================= - -const LLUUID LLAppearanceMgr::getCOF() const -{ - return gInventory.findCategoryUUIDForType(LLFolderType::FT_CURRENT_OUTFIT); -} - -S32 LLAppearanceMgr::getCOFVersion() const -{ - LLViewerInventoryCategory *cof = gInventory.getCategory(getCOF()); - if (cof) - { - return cof->getVersion(); - } - else - { - return LLViewerInventoryCategory::VERSION_UNKNOWN; - } -} - -const LLViewerInventoryItem* LLAppearanceMgr::getBaseOutfitLink() -{ - const LLUUID& current_outfit_cat = getCOF(); - LLInventoryModel::cat_array_t cat_array; - LLInventoryModel::item_array_t item_array; - // Can't search on FT_OUTFIT since links to categories return FT_CATEGORY for type since they don't - // return preferred type. - LLIsType is_category( LLAssetType::AT_CATEGORY ); - gInventory.collectDescendentsIf(current_outfit_cat, - cat_array, - item_array, - false, - is_category); - for (LLInventoryModel::item_array_t::const_iterator iter = item_array.begin(); - iter != item_array.end(); - iter++) - { - const LLViewerInventoryItem *item = (*iter); - const LLViewerInventoryCategory *cat = item->getLinkedCategory(); - if (cat && cat->getPreferredType() == LLFolderType::FT_OUTFIT) - { - const LLUUID parent_id = cat->getParentUUID(); - LLViewerInventoryCategory* parent_cat = gInventory.getCategory(parent_id); - // if base outfit moved to trash it means that we don't have base outfit - if (parent_cat != NULL && parent_cat->getPreferredType() == LLFolderType::FT_TRASH) - { - return NULL; - } - return item; - } - } - return NULL; -} - -bool LLAppearanceMgr::getBaseOutfitName(std::string& name) -{ - const LLViewerInventoryItem* outfit_link = getBaseOutfitLink(); - if(outfit_link) - { - const LLViewerInventoryCategory *cat = outfit_link->getLinkedCategory(); - if (cat) - { - name = cat->getName(); - return true; - } - } - return false; -} - -const LLUUID LLAppearanceMgr::getBaseOutfitUUID() -{ - const LLViewerInventoryItem* outfit_link = getBaseOutfitLink(); - if (!outfit_link || !outfit_link->getIsLinkType()) return LLUUID::null; - - const LLViewerInventoryCategory* outfit_cat = outfit_link->getLinkedCategory(); - if (!outfit_cat) return LLUUID::null; - - if (outfit_cat->getPreferredType() != LLFolderType::FT_OUTFIT) - { - LL_WARNS() << "Expected outfit type:" << LLFolderType::FT_OUTFIT << " but got type:" << outfit_cat->getType() << " for folder name:" << outfit_cat->getName() << LL_ENDL; - return LLUUID::null; - } - - return outfit_cat->getUUID(); -} - -void wear_on_avatar_cb(const LLUUID& inv_item, bool do_replace = false) -{ - if (inv_item.isNull()) - return; - - LLViewerInventoryItem *item = gInventory.getItem(inv_item); - if (item) - { - LLAppearanceMgr::instance().wearItemOnAvatar(inv_item, true, do_replace); - } -} - -bool LLAppearanceMgr::wearItemOnAvatar(const LLUUID& item_id_to_wear, - bool do_update, - bool replace, - LLPointer cb) -{ - - if (item_id_to_wear.isNull()) return false; - - // *TODO: issue with multi-wearable should be fixed: - // in this case this method will be called N times - loading started for each item - // and than N times will be called - loading completed for each item. - // That means subscribers will be notified that loading is done after first item in a batch is worn. - // (loading indicator disappears for example before all selected items are worn) - // Have not fix this issue for 2.1 because of stability reason. EXT-7777. - - // Disabled for now because it is *not* acceptable to call updateAppearanceFromCOF() multiple times -// gAgentWearables.notifyLoadingStarted(); - - LLViewerInventoryItem* item_to_wear = gInventory.getItem(item_id_to_wear); - if (!item_to_wear) return false; - - if (gInventory.isObjectDescendentOf(item_to_wear->getUUID(), gInventory.getLibraryRootFolderID())) - { - LLPointer cb = new LLBoostFuncInventoryCallback(boost::bind(wear_on_avatar_cb,_1,replace)); - copy_inventory_item(gAgent.getID(), item_to_wear->getPermissions().getOwner(), item_to_wear->getUUID(), LLUUID::null, std::string(), cb); - return false; - } - else if (!gInventory.isObjectDescendentOf(item_to_wear->getUUID(), gInventory.getRootFolderID())) - { - return false; // not in library and not in agent's inventory - } - else if (gInventory.isObjectDescendentOf(item_to_wear->getUUID(), gInventory.findCategoryUUIDForType(LLFolderType::FT_TRASH))) - { - LLNotificationsUtil::add("CannotWearTrash"); - return false; - } - else if (isLinkedInCOF(item_to_wear->getUUID())) // EXT-84911 - { - return false; - } - - switch (item_to_wear->getType()) - { - case LLAssetType::AT_CLOTHING: - if (gAgentWearables.areWearablesLoaded()) - { - if (!cb && do_update) - { - cb = new LLUpdateAppearanceAndEditWearableOnDestroy(item_id_to_wear); - } - S32 wearable_count = gAgentWearables.getWearableCount(item_to_wear->getWearableType()); - if ((replace && wearable_count != 0) || - (wearable_count >= LLAgentWearables::MAX_CLOTHING_PER_TYPE) ) - { - LLUUID item_id = gAgentWearables.getWearableItemID(item_to_wear->getWearableType(), - wearable_count-1); - removeCOFItemLinks(item_id, cb); - } - - addCOFItemLink(item_to_wear, cb); - } - break; - - case LLAssetType::AT_BODYPART: - // TODO: investigate wearables may not be loaded at this point EXT-8231 - - // Remove the existing wearables of the same type. - // Remove existing body parts anyway because we must not be able to wear e.g. two skins. - removeCOFLinksOfType(item_to_wear->getWearableType()); - if (!cb && do_update) - { - cb = new LLUpdateAppearanceAndEditWearableOnDestroy(item_id_to_wear); - } - addCOFItemLink(item_to_wear, cb); - break; - - case LLAssetType::AT_OBJECT: - rez_attachment(item_to_wear, NULL, replace); - break; - - default: return false;; - } - - return true; -} - -// Update appearance from outfit folder. -void LLAppearanceMgr::changeOutfit(bool proceed, const LLUUID& category, bool append) -{ - if (!proceed) - return; - LLAppearanceMgr::instance().updateCOF(category,append); -} - -void LLAppearanceMgr::replaceCurrentOutfit(const LLUUID& new_outfit) -{ - LLViewerInventoryCategory* cat = gInventory.getCategory(new_outfit); - wearInventoryCategory(cat, false, false); -} - -// Open outfit renaming dialog. -void LLAppearanceMgr::renameOutfit(const LLUUID& outfit_id) -{ - LLViewerInventoryCategory* cat = gInventory.getCategory(outfit_id); - if (!cat) - { - return; - } - - LLSD args; - args["NAME"] = cat->getName(); - - LLSD payload; - payload["cat_id"] = outfit_id; - - LLNotificationsUtil::add("RenameOutfit", args, payload, boost::bind(onOutfitRename, _1, _2)); -} - -// User typed new outfit name. -// static -void LLAppearanceMgr::onOutfitRename(const LLSD& notification, const LLSD& response) -{ - S32 option = LLNotificationsUtil::getSelectedOption(notification, response); - if (option != 0) return; // canceled - - std::string outfit_name = response["new_name"].asString(); - LLStringUtil::trim(outfit_name); - if (!outfit_name.empty()) - { - LLUUID cat_id = notification["payload"]["cat_id"].asUUID(); - rename_category(&gInventory, cat_id, outfit_name); - } -} - -void LLAppearanceMgr::setOutfitLocked(bool locked) -{ - if (mOutfitLocked == locked) - { - return; - } - - mOutfitLocked = locked; - if (locked) - { - mUnlockOutfitTimer->reset(); - mUnlockOutfitTimer->start(); - } - else - { - mUnlockOutfitTimer->stop(); - } - - LLOutfitObserver::instance().notifyOutfitLockChanged(); -} - -void LLAppearanceMgr::addCategoryToCurrentOutfit(const LLUUID& cat_id) -{ - LLViewerInventoryCategory* cat = gInventory.getCategory(cat_id); - wearInventoryCategory(cat, false, true); -} - -void LLAppearanceMgr::takeOffOutfit(const LLUUID& cat_id) -{ - LLInventoryModel::cat_array_t cats; - LLInventoryModel::item_array_t items; - LLFindWearablesEx collector(/*is_worn=*/ true, /*include_body_parts=*/ false); - - gInventory.collectDescendentsIf(cat_id, cats, items, FALSE, collector); - - LLInventoryModel::item_array_t::const_iterator it = items.begin(); - const LLInventoryModel::item_array_t::const_iterator it_end = items.end(); - uuid_vec_t uuids_to_remove; - for( ; it_end != it; ++it) - { - LLViewerInventoryItem* item = *it; - uuids_to_remove.push_back(item->getUUID()); - } - removeItemsFromAvatar(uuids_to_remove); - - // deactivate all gestures in the outfit folder - LLInventoryModel::item_array_t gest_items; - getDescendentsOfAssetType(cat_id, gest_items, LLAssetType::AT_GESTURE); - for(S32 i = 0; i < gest_items.size(); ++i) - { - LLViewerInventoryItem *gest_item = gest_items[i]; - if ( LLGestureMgr::instance().isGestureActive( gest_item->getLinkedUUID()) ) - { - LLGestureMgr::instance().deactivateGesture( gest_item->getLinkedUUID() ); - } - } -} - -// Create a copy of src_id + contents as a subfolder of dst_id. -void LLAppearanceMgr::shallowCopyCategory(const LLUUID& src_id, const LLUUID& dst_id, - LLPointer cb) -{ - LLInventoryCategory *src_cat = gInventory.getCategory(src_id); - if (!src_cat) - { - LL_WARNS() << "folder not found for src " << src_id.asString() << LL_ENDL; - return; - } - LL_INFOS() << "starting, src_id " << src_id << " name " << src_cat->getName() << " dst_id " << dst_id << LL_ENDL; - LLUUID parent_id = dst_id; - if(parent_id.isNull()) - { - parent_id = gInventory.getRootFolderID(); - } - LLUUID subfolder_id = gInventory.createNewCategory( parent_id, - LLFolderType::FT_NONE, - src_cat->getName()); - shallowCopyCategoryContents(src_id, subfolder_id, cb); - - gInventory.notifyObservers(); -} - -void LLAppearanceMgr::slamCategoryLinks(const LLUUID& src_id, const LLUUID& dst_id, - bool include_folder_links, LLPointer cb) -{ - LLInventoryModel::cat_array_t* cats; - LLInventoryModel::item_array_t* items; - LLSD contents = LLSD::emptyArray(); - gInventory.getDirectDescendentsOf(src_id, cats, items); - LL_INFOS() << "copying " << items->size() << " items" << LL_ENDL; - for (LLInventoryModel::item_array_t::const_iterator iter = items->begin(); - iter != items->end(); - ++iter) - { - const LLViewerInventoryItem* item = (*iter); - switch (item->getActualType()) - { - case LLAssetType::AT_LINK: - { - LL_DEBUGS("Avatar") << "linking inventory item " << item->getName() << LL_ENDL; - //getActualDescription() is used for a new description - //to propagate ordering information saved in descriptions of links - LLSD item_contents; - item_contents["name"] = item->getName(); - item_contents["desc"] = item->getActualDescription(); - item_contents["linked_id"] = item->getLinkedUUID(); - item_contents["type"] = LLAssetType::AT_LINK; - contents.append(item_contents); - break; - } - case LLAssetType::AT_LINK_FOLDER: - { - LLViewerInventoryCategory *catp = item->getLinkedCategory(); - if (catp && include_folder_links) - { - LL_DEBUGS("Avatar") << "linking inventory folder " << item->getName() << LL_ENDL; - LLSD base_contents; - base_contents["name"] = catp->getName(); - base_contents["desc"] = ""; // categories don't have descriptions. - base_contents["linked_id"] = catp->getLinkedUUID(); - base_contents["type"] = LLAssetType::AT_LINK_FOLDER; - contents.append(base_contents); - } - break; - } - default: - { - // Linux refuses to compile unless all possible enums are handled. Really, Linux? - break; - } - } - } - slam_inventory_folder(dst_id, contents, cb); -} -// Copy contents of src_id to dst_id. -void LLAppearanceMgr::shallowCopyCategoryContents(const LLUUID& src_id, const LLUUID& dst_id, - LLPointer cb) -{ - LLInventoryModel::cat_array_t* cats; - LLInventoryModel::item_array_t* items; - gInventory.getDirectDescendentsOf(src_id, cats, items); - LL_INFOS() << "copying " << items->size() << " items" << LL_ENDL; - LLInventoryObject::const_object_list_t link_array; - for (LLInventoryModel::item_array_t::const_iterator iter = items->begin(); - iter != items->end(); - ++iter) - { - const LLViewerInventoryItem* item = (*iter); - switch (item->getActualType()) - { - case LLAssetType::AT_LINK: - { - LL_DEBUGS("Avatar") << "linking inventory item " << item->getName() << LL_ENDL; - link_array.push_back(LLConstPointer(item)); - break; - } - case LLAssetType::AT_LINK_FOLDER: - { - LLViewerInventoryCategory *catp = item->getLinkedCategory(); - // Skip copying outfit links. - if (catp && catp->getPreferredType() != LLFolderType::FT_OUTFIT) - { - LL_DEBUGS("Avatar") << "linking inventory folder " << item->getName() << LL_ENDL; - link_array.push_back(LLConstPointer(item)); - } - break; - } - case LLAssetType::AT_CLOTHING: - case LLAssetType::AT_OBJECT: - case LLAssetType::AT_BODYPART: - case LLAssetType::AT_GESTURE: - { - LL_DEBUGS("Avatar") << "copying inventory item " << item->getName() << LL_ENDL; - copy_inventory_item(gAgent.getID(), - item->getPermissions().getOwner(), - item->getUUID(), - dst_id, - item->getName(), - cb); - break; - } - default: - // Ignore non-outfit asset types - break; - } - } - if (!link_array.empty()) - { - link_inventory_array(dst_id, link_array, cb); - } -} - -BOOL LLAppearanceMgr::getCanMakeFolderIntoOutfit(const LLUUID& folder_id) -{ - // These are the wearable items that are required for considering this - // folder as containing a complete outfit. - U32 required_wearables = 0; - required_wearables |= 1LL << LLWearableType::WT_SHAPE; - required_wearables |= 1LL << LLWearableType::WT_SKIN; - required_wearables |= 1LL << LLWearableType::WT_HAIR; - required_wearables |= 1LL << LLWearableType::WT_EYES; - - // These are the wearables that the folder actually contains. - U32 folder_wearables = 0; - LLInventoryModel::cat_array_t* cats; - LLInventoryModel::item_array_t* items; - gInventory.getDirectDescendentsOf(folder_id, cats, items); - for (LLInventoryModel::item_array_t::const_iterator iter = items->begin(); - iter != items->end(); - ++iter) - { - const LLViewerInventoryItem* item = (*iter); - if (item->isWearableType()) - { - const LLWearableType::EType wearable_type = item->getWearableType(); - folder_wearables |= 1LL << wearable_type; - } - } - - // If the folder contains the required wearables, return TRUE. - return ((required_wearables & folder_wearables) == required_wearables); -} - -bool LLAppearanceMgr::getCanRemoveOutfit(const LLUUID& outfit_cat_id) -{ - // Disallow removing the base outfit. - if (outfit_cat_id == getBaseOutfitUUID()) - { - return false; - } - - // Check if the outfit folder itself is removable. - if (!get_is_category_removable(&gInventory, outfit_cat_id)) - { - return false; - } - - // Check for the folder's non-removable descendants. - LLFindNonRemovableObjects filter_non_removable; - LLInventoryModel::cat_array_t cats; - LLInventoryModel::item_array_t items; - LLInventoryModel::item_array_t::const_iterator it; - gInventory.collectDescendentsIf(outfit_cat_id, cats, items, false, filter_non_removable); - if (!cats.empty() || !items.empty()) - { - return false; - } - - return true; -} - -// static -bool LLAppearanceMgr::getCanRemoveFromCOF(const LLUUID& outfit_cat_id) -{ - if (gAgentWearables.isCOFChangeInProgress()) - { - return false; - } - - LLFindWearablesEx is_worn(/*is_worn=*/ true, /*include_body_parts=*/ false); - return gInventory.hasMatchingDirectDescendent(outfit_cat_id, is_worn); -} - -// static -bool LLAppearanceMgr::getCanAddToCOF(const LLUUID& outfit_cat_id) -{ - if (gAgentWearables.isCOFChangeInProgress()) - { - return false; - } - - LLInventoryModel::cat_array_t cats; - LLInventoryModel::item_array_t items; - LLFindWearablesEx not_worn(/*is_worn=*/ false, /*include_body_parts=*/ false); - gInventory.collectDescendentsIf(outfit_cat_id, - cats, - items, - LLInventoryModel::EXCLUDE_TRASH, - not_worn); - - return items.size() > 0; -} - -bool LLAppearanceMgr::getCanReplaceCOF(const LLUUID& outfit_cat_id) -{ - // Don't allow wearing anything while we're changing appearance. - if (gAgentWearables.isCOFChangeInProgress()) - { - return false; - } - - // Check whether it's the base outfit. - if (outfit_cat_id.isNull() || outfit_cat_id == getBaseOutfitUUID()) - { - return false; - } - - // Check whether the outfit contains any wearables we aren't wearing already (STORM-702). - LLInventoryModel::cat_array_t cats; - LLInventoryModel::item_array_t items; - LLFindWearablesEx is_worn(/*is_worn=*/ false, /*include_body_parts=*/ true); - gInventory.collectDescendentsIf(outfit_cat_id, - cats, - items, - LLInventoryModel::EXCLUDE_TRASH, - is_worn); - - return items.size() > 0; -} - -void LLAppearanceMgr::purgeBaseOutfitLink(const LLUUID& category, LLPointer cb) -{ - LLInventoryModel::cat_array_t cats; - LLInventoryModel::item_array_t items; - gInventory.collectDescendents(category, cats, items, - LLInventoryModel::EXCLUDE_TRASH); - for (S32 i = 0; i < items.size(); ++i) - { - LLViewerInventoryItem *item = items.at(i); - if (item->getActualType() != LLAssetType::AT_LINK_FOLDER) - continue; - LLViewerInventoryCategory* catp = item->getLinkedCategory(); - if(catp && catp->getPreferredType() == LLFolderType::FT_OUTFIT) - { - remove_inventory_item(item->getUUID(), cb); - } - } -} - -// Keep the last N wearables of each type. For viewer 2.0, N is 1 for -// both body parts and clothing items. -void LLAppearanceMgr::filterWearableItems( - LLInventoryModel::item_array_t& items, S32 max_per_type) -{ - // Divvy items into arrays by wearable type. - std::vector items_by_type(LLWearableType::WT_COUNT); - divvyWearablesByType(items, items_by_type); - - // rebuild items list, retaining the last max_per_type of each array - items.clear(); - for (S32 i=0; igetName() : "[UNKNOWN]") << "'" << LL_ENDL; - - const LLUUID cof = getCOF(); - - // Deactivate currently active gestures in the COF, if replacing outfit - if (!append) - { - LLInventoryModel::item_array_t gest_items; - getDescendentsOfAssetType(cof, gest_items, LLAssetType::AT_GESTURE); - for(S32 i = 0; i < gest_items.size(); ++i) - { - LLViewerInventoryItem *gest_item = gest_items.at(i); - if ( LLGestureMgr::instance().isGestureActive( gest_item->getLinkedUUID()) ) - { - LLGestureMgr::instance().deactivateGesture( gest_item->getLinkedUUID() ); - } - } - } - - // Collect and filter descendents to determine new COF contents. - - // - Body parts: always include COF contents as a fallback in case any - // required parts are missing. - // Preserve body parts from COF if appending. - LLInventoryModel::item_array_t body_items; - getDescendentsOfAssetType(cof, body_items, LLAssetType::AT_BODYPART); - getDescendentsOfAssetType(category, body_items, LLAssetType::AT_BODYPART); - if (append) - reverse(body_items.begin(), body_items.end()); - // Reduce body items to max of one per type. - removeDuplicateItems(body_items); - filterWearableItems(body_items, 1); - - // - Wearables: include COF contents only if appending. - LLInventoryModel::item_array_t wear_items; - if (append) - getDescendentsOfAssetType(cof, wear_items, LLAssetType::AT_CLOTHING); - getDescendentsOfAssetType(category, wear_items, LLAssetType::AT_CLOTHING); - // Reduce wearables to max of one per type. - removeDuplicateItems(wear_items); - filterWearableItems(wear_items, LLAgentWearables::MAX_CLOTHING_PER_TYPE); - - // - Attachments: include COF contents only if appending. - LLInventoryModel::item_array_t obj_items; - if (append) - getDescendentsOfAssetType(cof, obj_items, LLAssetType::AT_OBJECT); - getDescendentsOfAssetType(category, obj_items, LLAssetType::AT_OBJECT); - removeDuplicateItems(obj_items); - - // - Gestures: include COF contents only if appending. - LLInventoryModel::item_array_t gest_items; - if (append) - getDescendentsOfAssetType(cof, gest_items, LLAssetType::AT_GESTURE); - getDescendentsOfAssetType(category, gest_items, LLAssetType::AT_GESTURE); - removeDuplicateItems(gest_items); - - // Create links to new COF contents. - LLInventoryModel::item_array_t all_items; - std::copy(body_items.begin(), body_items.end(), std::back_inserter(all_items)); - std::copy(wear_items.begin(), wear_items.end(), std::back_inserter(all_items)); - std::copy(obj_items.begin(), obj_items.end(), std::back_inserter(all_items)); - std::copy(gest_items.begin(), gest_items.end(), std::back_inserter(all_items)); - - // Find any wearables that need description set to enforce ordering. - desc_map_t desc_map; - getWearableOrderingDescUpdates(wear_items, desc_map); - - // Will link all the above items. - // link_waiter enforce flags are false because we've already fixed everything up in updateCOF(). - LLPointer link_waiter = new LLUpdateAppearanceOnDestroy(false,false); - LLSD contents = LLSD::emptyArray(); - - for (LLInventoryModel::item_array_t::const_iterator it = all_items.begin(); - it != all_items.end(); ++it) - { - LLSD item_contents; - LLInventoryItem *item = *it; - - std::string desc; - desc_map_t::const_iterator desc_iter = desc_map.find(item->getUUID()); - if (desc_iter != desc_map.end()) - { - desc = desc_iter->second; - LL_DEBUGS("Avatar") << item->getName() << " overriding desc to: " << desc - << " (was: " << item->getActualDescription() << ")" << LL_ENDL; - } - else - { - desc = item->getActualDescription(); - } - - item_contents["name"] = item->getName(); - item_contents["desc"] = desc; - item_contents["linked_id"] = item->getLinkedUUID(); - item_contents["type"] = LLAssetType::AT_LINK; - contents.append(item_contents); - } - const LLUUID& base_id = append ? getBaseOutfitUUID() : category; - LLViewerInventoryCategory *base_cat = gInventory.getCategory(base_id); - if (base_cat) - { - LLSD base_contents; - base_contents["name"] = base_cat->getName(); - base_contents["desc"] = ""; - base_contents["linked_id"] = base_cat->getLinkedUUID(); - base_contents["type"] = LLAssetType::AT_LINK_FOLDER; - contents.append(base_contents); - } - if (gSavedSettings.getBOOL("DebugAvatarAppearanceMessage")) - { - dump_sequential_xml(gAgentAvatarp->getFullname() + "_slam_request", contents); - } - slam_inventory_folder(getCOF(), contents, link_waiter); - - LL_DEBUGS("Avatar") << self_av_string() << "waiting for LLUpdateAppearanceOnDestroy" << LL_ENDL; -} - -void LLAppearanceMgr::updatePanelOutfitName(const std::string& name) -{ - LLSidepanelAppearance* panel_appearance = - dynamic_cast(LLFloaterSidePanelContainer::getPanel("appearance")); - if (panel_appearance) - { - panel_appearance->refreshCurrentOutfitName(name); - } -} - -void LLAppearanceMgr::createBaseOutfitLink(const LLUUID& category, LLPointer link_waiter) -{ - const LLUUID cof = getCOF(); - LLViewerInventoryCategory* catp = gInventory.getCategory(category); - std::string new_outfit_name = ""; - - purgeBaseOutfitLink(cof, link_waiter); - - if (catp && catp->getPreferredType() == LLFolderType::FT_OUTFIT) - { - link_inventory_object(cof, catp, link_waiter); - new_outfit_name = catp->getName(); - } - - updatePanelOutfitName(new_outfit_name); -} - -void LLAppearanceMgr::updateAgentWearables(LLWearableHoldingPattern* holder) -{ - LL_DEBUGS("Avatar") << "updateAgentWearables()" << LL_ENDL; - LLInventoryItem::item_array_t items; - std::vector< LLViewerWearable* > wearables; - wearables.reserve(32); - - // For each wearable type, find the wearables of that type. - for( S32 i = 0; i < LLWearableType::WT_COUNT; i++ ) - { - for (LLWearableHoldingPattern::found_list_t::iterator iter = holder->getFoundList().begin(); - iter != holder->getFoundList().end(); ++iter) - { - LLFoundData& data = *iter; - LLViewerWearable* wearable = data.mWearable; - if( wearable && ((S32)wearable->getType() == i) ) - { - LLViewerInventoryItem* item = (LLViewerInventoryItem*)gInventory.getItem(data.mItemID); - if( item && (item->getAssetUUID() == wearable->getAssetID()) ) - { - items.push_back(item); - wearables.push_back(wearable); - } - } - } - } - - if(wearables.size() > 0) - { - gAgentWearables.setWearableOutfit(items, wearables); - } -} - -S32 LLAppearanceMgr::countActiveHoldingPatterns() -{ - return LLWearableHoldingPattern::countActive(); -} - -static void remove_non_link_items(LLInventoryModel::item_array_t &items) -{ - LLInventoryModel::item_array_t pruned_items; - for (LLInventoryModel::item_array_t::const_iterator iter = items.begin(); - iter != items.end(); - ++iter) - { - const LLViewerInventoryItem *item = (*iter); - if (item && item->getIsLinkType()) - { - pruned_items.push_back((*iter)); - } - } - items = pruned_items; -} - -//a predicate for sorting inventory items by actual descriptions -bool sort_by_actual_description(const LLInventoryItem* item1, const LLInventoryItem* item2) -{ - if (!item1 || !item2) - { - LL_WARNS() << "either item1 or item2 is NULL" << LL_ENDL; - return true; - } - - return item1->getActualDescription() < item2->getActualDescription(); -} - -void item_array_diff(LLInventoryModel::item_array_t& full_list, - LLInventoryModel::item_array_t& keep_list, - LLInventoryModel::item_array_t& kill_list) - -{ - for (LLInventoryModel::item_array_t::iterator it = full_list.begin(); - it != full_list.end(); - ++it) - { - LLViewerInventoryItem *item = *it; - if (std::find(keep_list.begin(), keep_list.end(), item) == keep_list.end()) - { - kill_list.push_back(item); - } - } -} - -S32 LLAppearanceMgr::findExcessOrDuplicateItems(const LLUUID& cat_id, - LLAssetType::EType type, - S32 max_items, - LLInventoryObject::object_list_t& items_to_kill) -{ - S32 to_kill_count = 0; - - LLInventoryModel::item_array_t items; - getDescendentsOfAssetType(cat_id, items, type); - LLInventoryModel::item_array_t curr_items = items; - removeDuplicateItems(items); - if (max_items > 0) - { - filterWearableItems(items, max_items); - } - LLInventoryModel::item_array_t kill_items; - item_array_diff(curr_items,items,kill_items); - for (LLInventoryModel::item_array_t::iterator it = kill_items.begin(); - it != kill_items.end(); - ++it) - { - items_to_kill.push_back(LLPointer(*it)); - to_kill_count++; - } - return to_kill_count; -} - - -void LLAppearanceMgr::findAllExcessOrDuplicateItems(const LLUUID& cat_id, - LLInventoryObject::object_list_t& items_to_kill) -{ - findExcessOrDuplicateItems(cat_id,LLAssetType::AT_BODYPART, - 1, items_to_kill); - findExcessOrDuplicateItems(cat_id,LLAssetType::AT_CLOTHING, - LLAgentWearables::MAX_CLOTHING_PER_TYPE, items_to_kill); - findExcessOrDuplicateItems(cat_id,LLAssetType::AT_OBJECT, - -1, items_to_kill); -} - -void LLAppearanceMgr::enforceCOFItemRestrictions(LLPointer cb) -{ - LLInventoryObject::object_list_t items_to_kill; - findAllExcessOrDuplicateItems(getCOF(), items_to_kill); - if (items_to_kill.size()>0) - { - // Remove duplicate or excess wearables. Should normally be enforced at the UI level, but - // this should catch anything that gets through. - remove_inventory_items(items_to_kill, cb); - } -} - -void LLAppearanceMgr::updateAppearanceFromCOF(bool enforce_item_restrictions, - bool enforce_ordering, - nullary_func_t post_update_func) -{ - if (mIsInUpdateAppearanceFromCOF) - { - LL_WARNS() << "Called updateAppearanceFromCOF inside updateAppearanceFromCOF, skipping" << LL_ENDL; - return; - } - - LL_DEBUGS("Avatar") << self_av_string() << "starting" << LL_ENDL; - - if (enforce_item_restrictions) - { - // The point here is just to call - // updateAppearanceFromCOF() again after excess items - // have been removed. That time we will set - // enforce_item_restrictions to false so we don't get - // caught in a perpetual loop. - LLPointer cb( - new LLUpdateAppearanceOnDestroy(false, enforce_ordering, post_update_func)); - enforceCOFItemRestrictions(cb); - return; - } - - if (enforce_ordering) - { - //checking integrity of the COF in terms of ordering of wearables, - //checking and updating links' descriptions of wearables in the COF (before analyzed for "dirty" state) - - // As with enforce_item_restrictions handling above, we want - // to wait for the update callbacks, then (finally!) call - // updateAppearanceFromCOF() with no additional COF munging needed. - LLPointer cb( - new LLUpdateAppearanceOnDestroy(false, false, post_update_func)); - updateClothingOrderingInfo(LLUUID::null, cb); - return; - } - - if (!validateClothingOrderingInfo()) - { - LL_WARNS() << "Clothing ordering error" << LL_ENDL; - } - - BoolSetter setIsInUpdateAppearanceFromCOF(mIsInUpdateAppearanceFromCOF); - selfStartPhase("update_appearance_from_cof"); - - // update dirty flag to see if the state of the COF matches - // the saved outfit stored as a folder link - updateIsDirty(); - - // Send server request for appearance update - if (gAgent.getRegion() && gAgent.getRegion()->getCentralBakeVersion()) - { - requestServerAppearanceUpdate(); - } - - LLUUID current_outfit_id = getCOF(); - - // Find all the wearables that are in the COF's subtree. - LL_DEBUGS() << "LLAppearanceMgr::updateFromCOF()" << LL_ENDL; - LLInventoryModel::item_array_t wear_items; - LLInventoryModel::item_array_t obj_items; - LLInventoryModel::item_array_t gest_items; - getUserDescendents(current_outfit_id, wear_items, obj_items, gest_items); - // Get rid of non-links in case somehow the COF was corrupted. - remove_non_link_items(wear_items); - remove_non_link_items(obj_items); - remove_non_link_items(gest_items); - - dumpItemArray(wear_items,"asset_dump: wear_item"); - dumpItemArray(obj_items,"asset_dump: obj_item"); - - LLViewerInventoryCategory *cof = gInventory.getCategory(current_outfit_id); - if (!gInventory.isCategoryComplete(current_outfit_id)) - { - LL_WARNS() << "COF info is not complete. Version " << cof->getVersion() - << " descendent_count " << cof->getDescendentCount() - << " viewer desc count " << cof->getViewerDescendentCount() << LL_ENDL; - } - if(!wear_items.size()) - { - LLNotificationsUtil::add("CouldNotPutOnOutfit"); - return; - } - - //preparing the list of wearables in the correct order for LLAgentWearables - sortItemsByActualDescription(wear_items); - - - LL_DEBUGS("Avatar") << "HP block starts" << LL_ENDL; - LLTimer hp_block_timer; - LLWearableHoldingPattern* holder = new LLWearableHoldingPattern; - - holder->setObjItems(obj_items); - holder->setGestItems(gest_items); - - // Note: can't do normal iteration, because if all the - // wearables can be resolved immediately, then the - // callback will be called (and this object deleted) - // before the final getNextData(). - - for(S32 i = 0; i < wear_items.size(); ++i) - { - LLViewerInventoryItem *item = wear_items.at(i); - LLViewerInventoryItem *linked_item = item ? item->getLinkedItem() : NULL; - - // Fault injection: use debug setting to test asset - // fetch failures (should be replaced by new defaults in - // lost&found). - U32 skip_type = gSavedSettings.getU32("ForceAssetFail"); - - if (item && item->getIsLinkType() && linked_item) - { - LLFoundData found(linked_item->getUUID(), - linked_item->getAssetUUID(), - linked_item->getName(), - linked_item->getType(), - linked_item->isWearableType() ? linked_item->getWearableType() : LLWearableType::WT_INVALID - ); - - if (skip_type != LLWearableType::WT_INVALID && skip_type == found.mWearableType) - { - found.mAssetID.generate(); // Replace with new UUID, guaranteed not to exist in DB - } - //pushing back, not front, to preserve order of wearables for LLAgentWearables - holder->getFoundList().push_back(found); - } - else - { - if (!item) - { - LL_WARNS() << "Attempt to wear a null item " << LL_ENDL; - } - else if (!linked_item) - { - LL_WARNS() << "Attempt to wear a broken link [ name:" << item->getName() << " ] " << LL_ENDL; - } - } - } - - selfStartPhase("get_wearables_2"); - - for (LLWearableHoldingPattern::found_list_t::iterator it = holder->getFoundList().begin(); - it != holder->getFoundList().end(); ++it) - { - LLFoundData& found = *it; - - LL_DEBUGS() << self_av_string() << "waiting for onWearableAssetFetch callback, asset " << found.mAssetID.asString() << LL_ENDL; - - // Fetch the wearables about to be worn. - LLWearableList::instance().getAsset(found.mAssetID, - found.mName, - gAgentAvatarp, - found.mAssetType, - onWearableAssetFetch, - (void*)holder); - - } - - holder->resetTime(gSavedSettings.getF32("MaxWearableWaitTime")); - if (!holder->pollFetchCompletion()) - { - doOnIdleRepeating(boost::bind(&LLWearableHoldingPattern::pollFetchCompletion,holder)); - } - post_update_func(); - - LL_DEBUGS("Avatar") << "HP block ends, elapsed " << hp_block_timer.getElapsedTimeF32() << LL_ENDL; -} - -void LLAppearanceMgr::getDescendentsOfAssetType(const LLUUID& category, - LLInventoryModel::item_array_t& items, - LLAssetType::EType type) -{ - LLInventoryModel::cat_array_t cats; - LLIsType is_of_type(type); - gInventory.collectDescendentsIf(category, - cats, - items, - LLInventoryModel::EXCLUDE_TRASH, - is_of_type); -} - -void LLAppearanceMgr::getUserDescendents(const LLUUID& category, - LLInventoryModel::item_array_t& wear_items, - LLInventoryModel::item_array_t& obj_items, - LLInventoryModel::item_array_t& gest_items) -{ - LLInventoryModel::cat_array_t wear_cats; - LLFindWearables is_wearable; - gInventory.collectDescendentsIf(category, - wear_cats, - wear_items, - LLInventoryModel::EXCLUDE_TRASH, - is_wearable); - - LLInventoryModel::cat_array_t obj_cats; - LLIsType is_object( LLAssetType::AT_OBJECT ); - gInventory.collectDescendentsIf(category, - obj_cats, - obj_items, - LLInventoryModel::EXCLUDE_TRASH, - is_object); - - // Find all gestures in this folder - LLInventoryModel::cat_array_t gest_cats; - LLIsType is_gesture( LLAssetType::AT_GESTURE ); - gInventory.collectDescendentsIf(category, - gest_cats, - gest_items, - LLInventoryModel::EXCLUDE_TRASH, - is_gesture); -} - -void LLAppearanceMgr::wearInventoryCategory(LLInventoryCategory* category, bool copy, bool append) -{ - if(!category) return; - - selfClearPhases(); - selfStartPhase("wear_inventory_category"); - - gAgentWearables.notifyLoadingStarted(); - - LL_INFOS("Avatar") << self_av_string() << "wearInventoryCategory( " << category->getName() - << " )" << LL_ENDL; - - // If we are copying from library, attempt to use AIS to copy the category. - bool ais_ran=false; - if (copy && AISCommand::isAPIAvailable()) - { - LLUUID parent_id; - parent_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_CLOTHING); - if (parent_id.isNull()) - { - parent_id = gInventory.getRootFolderID(); - } - - LLPointer copy_cb = new LLWearCategoryAfterCopy(append); - LLPointer track_cb = new LLTrackPhaseWrapper( - std::string("wear_inventory_category_callback"), copy_cb); - LLPointer cmd_ptr = new CopyLibraryCategoryCommand(category->getUUID(), parent_id, track_cb); - ais_ran=cmd_ptr->run_command(); - } - - if (!ais_ran) - { - selfStartPhase("wear_inventory_category_fetch"); - callAfterCategoryFetch(category->getUUID(),boost::bind(&LLAppearanceMgr::wearCategoryFinal, - &LLAppearanceMgr::instance(), - category->getUUID(), copy, append)); - } -} - -S32 LLAppearanceMgr::getActiveCopyOperations() const -{ - return LLCallAfterInventoryCopyMgr::getInstanceCount(); -} - -void LLAppearanceMgr::wearCategoryFinal(LLUUID& cat_id, bool copy_items, bool append) -{ - LL_INFOS("Avatar") << self_av_string() << "starting" << LL_ENDL; - - selfStopPhase("wear_inventory_category_fetch"); - - // We now have an outfit ready to be copied to agent inventory. Do - // it, and wear that outfit normally. - LLInventoryCategory* cat = gInventory.getCategory(cat_id); - if(copy_items) - { - LLInventoryModel::cat_array_t* cats; - LLInventoryModel::item_array_t* items; - gInventory.getDirectDescendentsOf(cat_id, cats, items); - std::string name; - if(!cat) - { - // should never happen. - name = "New Outfit"; - } - else - { - name = cat->getName(); - } - LLViewerInventoryItem* item = NULL; - LLInventoryModel::item_array_t::const_iterator it = items->begin(); - LLInventoryModel::item_array_t::const_iterator end = items->end(); - LLUUID pid; - for(; it < end; ++it) - { - item = *it; - if(item) - { - if(LLInventoryType::IT_GESTURE == item->getInventoryType()) - { - pid = gInventory.findCategoryUUIDForType(LLFolderType::FT_GESTURE); - } - else - { - pid = gInventory.findCategoryUUIDForType(LLFolderType::FT_CLOTHING); - } - break; - } - } - if(pid.isNull()) - { - pid = gInventory.getRootFolderID(); - } - - LLUUID new_cat_id = gInventory.createNewCategory( - pid, - LLFolderType::FT_NONE, - name); - - // Create a CopyMgr that will copy items, manage its own destruction - new LLCallAfterInventoryCopyMgr( - *items, new_cat_id, std::string("wear_inventory_category_callback"), - boost::bind(&LLAppearanceMgr::wearInventoryCategoryOnAvatar, - LLAppearanceMgr::getInstance(), - gInventory.getCategory(new_cat_id), - append)); - - // BAP fixes a lag in display of created dir. - gInventory.notifyObservers(); - } - else - { - // Wear the inventory category. - LLAppearanceMgr::instance().wearInventoryCategoryOnAvatar(cat, append); - } -} - -// *NOTE: hack to get from avatar inventory to avatar -void LLAppearanceMgr::wearInventoryCategoryOnAvatar( LLInventoryCategory* category, bool append ) -{ - // Avoid unintentionally overwriting old wearables. We have to do - // this up front to avoid having to deal with the case of multiple - // wearables being dirty. - if (!category) return; - - if ( !LLInventoryCallbackManager::is_instantiated() ) - { - // shutting down, ignore. - return; - } - - LL_INFOS("Avatar") << self_av_string() << "wearInventoryCategoryOnAvatar '" << category->getName() - << "'" << LL_ENDL; - - if (gAgentCamera.cameraCustomizeAvatar()) - { - // switching to outfit editor should automagically save any currently edited wearable - LLFloaterSidePanelContainer::showPanel("appearance", LLSD().with("type", "edit_outfit")); - } - - LLAppearanceMgr::changeOutfit(TRUE, category->getUUID(), append); -} - -// FIXME do we really want to search entire inventory for matching name? -void LLAppearanceMgr::wearOutfitByName(const std::string& name) -{ - LL_INFOS("Avatar") << self_av_string() << "Wearing category " << name << LL_ENDL; - - LLInventoryModel::cat_array_t cat_array; - LLInventoryModel::item_array_t item_array; - LLNameCategoryCollector has_name(name); - gInventory.collectDescendentsIf(gInventory.getRootFolderID(), - cat_array, - item_array, - LLInventoryModel::EXCLUDE_TRASH, - has_name); - bool copy_items = false; - LLInventoryCategory* cat = NULL; - if (cat_array.size() > 0) - { - // Just wear the first one that matches - cat = cat_array.at(0); - } - else - { - gInventory.collectDescendentsIf(LLUUID::null, - cat_array, - item_array, - LLInventoryModel::EXCLUDE_TRASH, - has_name); - if(cat_array.size() > 0) - { - cat = cat_array.at(0); - copy_items = true; - } - } - - if(cat) - { - LLAppearanceMgr::wearInventoryCategory(cat, copy_items, false); - } - else - { - LL_WARNS() << "Couldn't find outfit " <isWearableType() && b->isWearableType() && - (a->getWearableType() == b->getWearableType())); -} - -class LLDeferredCOFLinkObserver: public LLInventoryObserver -{ -public: - LLDeferredCOFLinkObserver(const LLUUID& item_id, LLPointer cb, const std::string& description): - mItemID(item_id), - mCallback(cb), - mDescription(description) - { - } - - ~LLDeferredCOFLinkObserver() - { - } - - /* virtual */ void changed(U32 mask) - { - const LLInventoryItem *item = gInventory.getItem(mItemID); - if (item) - { - gInventory.removeObserver(this); - LLAppearanceMgr::instance().addCOFItemLink(item, mCallback, mDescription); - delete this; - } - } - -private: - const LLUUID mItemID; - std::string mDescription; - LLPointer mCallback; -}; - - -// BAP - note that this runs asynchronously if the item is not already loaded from inventory. -// Dangerous if caller assumes link will exist after calling the function. -void LLAppearanceMgr::addCOFItemLink(const LLUUID &item_id, - LLPointer cb, - const std::string description) -{ - const LLInventoryItem *item = gInventory.getItem(item_id); - if (!item) - { - LLDeferredCOFLinkObserver *observer = new LLDeferredCOFLinkObserver(item_id, cb, description); - gInventory.addObserver(observer); - } - else - { - addCOFItemLink(item, cb, description); - } -} - -void LLAppearanceMgr::addCOFItemLink(const LLInventoryItem *item, - LLPointer cb, - const std::string description) -{ - const LLViewerInventoryItem *vitem = dynamic_cast(item); - if (!vitem) - { - LL_WARNS() << "not an llviewerinventoryitem, failed" << LL_ENDL; - return; - } - - gInventory.addChangedMask(LLInventoryObserver::LABEL, vitem->getLinkedUUID()); - - LLInventoryModel::cat_array_t cat_array; - LLInventoryModel::item_array_t item_array; - gInventory.collectDescendents(LLAppearanceMgr::getCOF(), - cat_array, - item_array, - LLInventoryModel::EXCLUDE_TRASH); - bool linked_already = false; - U32 count = 0; - for (S32 i=0; igetWearableType(); - - const bool is_body_part = (wearable_type == LLWearableType::WT_SHAPE) - || (wearable_type == LLWearableType::WT_HAIR) - || (wearable_type == LLWearableType::WT_EYES) - || (wearable_type == LLWearableType::WT_SKIN); - - if (inv_item->getLinkedUUID() == vitem->getLinkedUUID()) - { - linked_already = true; - } - // Are these links to different items of the same body part - // type? If so, new item will replace old. - else if ((vitem->isWearableType()) && (vitem->getWearableType() == wearable_type)) - { - ++count; - if (is_body_part && inv_item->getIsLinkType() && (vitem->getWearableType() == wearable_type)) - { - remove_inventory_item(inv_item->getUUID(), cb); - } - else if (count >= LLAgentWearables::MAX_CLOTHING_PER_TYPE) - { - // MULTI-WEARABLES: make sure we don't go over MAX_CLOTHING_PER_TYPE - remove_inventory_item(inv_item->getUUID(), cb); - } - } - } - - if (!linked_already) - { - LLViewerInventoryItem *copy_item = new LLViewerInventoryItem; - copy_item->copyViewerItem(vitem); - copy_item->setDescription(description); - link_inventory_object(getCOF(), copy_item, cb); - } -} - -LLInventoryModel::item_array_t LLAppearanceMgr::findCOFItemLinks(const LLUUID& item_id) -{ - - LLInventoryModel::item_array_t result; - const LLViewerInventoryItem *vitem = - dynamic_cast(gInventory.getItem(item_id)); - - if (vitem) - { - LLInventoryModel::cat_array_t cat_array; - LLInventoryModel::item_array_t item_array; - gInventory.collectDescendents(LLAppearanceMgr::getCOF(), - cat_array, - item_array, - LLInventoryModel::EXCLUDE_TRASH); - for (S32 i=0; igetLinkedUUID() == vitem->getLinkedUUID()) - { - result.push_back(item_array.at(i)); - } - } - } - return result; -} - -bool LLAppearanceMgr::isLinkedInCOF(const LLUUID& item_id) -{ - LLInventoryModel::item_array_t links = LLAppearanceMgr::instance().findCOFItemLinks(item_id); - return links.size() > 0; -} - -void LLAppearanceMgr::removeAllClothesFromAvatar() -{ - // Fetch worn clothes (i.e. the ones in COF). - LLInventoryModel::item_array_t clothing_items; - LLInventoryModel::cat_array_t dummy; - LLIsType is_clothing(LLAssetType::AT_CLOTHING); - gInventory.collectDescendentsIf(getCOF(), - dummy, - clothing_items, - LLInventoryModel::EXCLUDE_TRASH, - is_clothing); - uuid_vec_t item_ids; - for (LLInventoryModel::item_array_t::iterator it = clothing_items.begin(); - it != clothing_items.end(); ++it) - { - item_ids.push_back((*it).get()->getLinkedUUID()); - } - - // Take them off by removing from COF. - removeItemsFromAvatar(item_ids); -} - -void LLAppearanceMgr::removeAllAttachmentsFromAvatar() -{ - if (!isAgentAvatarValid()) return; - - LLAgentWearables::llvo_vec_t objects_to_remove; - - for (LLVOAvatar::attachment_map_t::iterator iter = gAgentAvatarp->mAttachmentPoints.begin(); - iter != gAgentAvatarp->mAttachmentPoints.end();) - { - LLVOAvatar::attachment_map_t::iterator curiter = iter++; - LLViewerJointAttachment* attachment = curiter->second; - for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin(); - attachment_iter != attachment->mAttachedObjects.end(); - ++attachment_iter) - { - LLViewerObject *attached_object = (*attachment_iter); - if (attached_object) - { - objects_to_remove.push_back(attached_object); - } - } - } - uuid_vec_t ids_to_remove; - for (LLAgentWearables::llvo_vec_t::iterator it = objects_to_remove.begin(); - it != objects_to_remove.end(); - ++it) - { - ids_to_remove.push_back((*it)->getAttachmentItemID()); - } - removeItemsFromAvatar(ids_to_remove); -} - -void LLAppearanceMgr::removeCOFItemLinks(const LLUUID& item_id, LLPointer cb) -{ - gInventory.addChangedMask(LLInventoryObserver::LABEL, item_id); - - LLInventoryModel::cat_array_t cat_array; - LLInventoryModel::item_array_t item_array; - gInventory.collectDescendents(LLAppearanceMgr::getCOF(), - cat_array, - item_array, - LLInventoryModel::EXCLUDE_TRASH); - for (S32 i=0; igetIsLinkType() && item->getLinkedUUID() == item_id) - { - bool immediate_delete = false; - if (item->getType() == LLAssetType::AT_OBJECT) - { - immediate_delete = true; - } - remove_inventory_item(item->getUUID(), cb, immediate_delete); - } - } -} - -void LLAppearanceMgr::removeCOFLinksOfType(LLWearableType::EType type, LLPointer cb) -{ - LLFindWearablesOfType filter_wearables_of_type(type); - LLInventoryModel::cat_array_t cats; - LLInventoryModel::item_array_t items; - LLInventoryModel::item_array_t::const_iterator it; - - gInventory.collectDescendentsIf(getCOF(), cats, items, true, filter_wearables_of_type); - for (it = items.begin(); it != items.end(); ++it) - { - const LLViewerInventoryItem* item = *it; - if (item->getIsLinkType()) // we must operate on links only - { - remove_inventory_item(item->getUUID(), cb); - } - } -} - -bool sort_by_linked_uuid(const LLViewerInventoryItem* item1, const LLViewerInventoryItem* item2) -{ - if (!item1 || !item2) - { - LL_WARNS() << "item1, item2 cannot be null, something is very wrong" << LL_ENDL; - return true; - } - - return item1->getLinkedUUID() < item2->getLinkedUUID(); -} - -void LLAppearanceMgr::updateIsDirty() -{ - LLUUID cof = getCOF(); - LLUUID base_outfit; - - // find base outfit link - const LLViewerInventoryItem* base_outfit_item = getBaseOutfitLink(); - LLViewerInventoryCategory* catp = NULL; - if (base_outfit_item && base_outfit_item->getIsLinkType()) - { - catp = base_outfit_item->getLinkedCategory(); - } - if(catp && catp->getPreferredType() == LLFolderType::FT_OUTFIT) - { - base_outfit = catp->getUUID(); - } - - // Set dirty to "false" if no base outfit found to disable "Save" - // and leave only "Save As" enabled in My Outfits. - mOutfitIsDirty = false; - - if (base_outfit.notNull()) - { - LLIsValidItemLink collector; - - LLInventoryModel::cat_array_t cof_cats; - LLInventoryModel::item_array_t cof_items; - gInventory.collectDescendentsIf(cof, cof_cats, cof_items, - LLInventoryModel::EXCLUDE_TRASH, collector); - - LLInventoryModel::cat_array_t outfit_cats; - LLInventoryModel::item_array_t outfit_items; - gInventory.collectDescendentsIf(base_outfit, outfit_cats, outfit_items, - LLInventoryModel::EXCLUDE_TRASH, collector); - - if(outfit_items.size() != cof_items.size()) - { - LL_DEBUGS("Avatar") << "item count different - base " << outfit_items.size() << " cof " << cof_items.size() << LL_ENDL; - // Current outfit folder should have one more item than the outfit folder. - // this one item is the link back to the outfit folder itself. - mOutfitIsDirty = true; - return; - } - - //"dirty" - also means a difference in linked UUIDs and/or a difference in wearables order (links' descriptions) - std::sort(cof_items.begin(), cof_items.end(), sort_by_linked_uuid); - std::sort(outfit_items.begin(), outfit_items.end(), sort_by_linked_uuid); - - for (U32 i = 0; i < cof_items.size(); ++i) - { - LLViewerInventoryItem *item1 = cof_items.at(i); - LLViewerInventoryItem *item2 = outfit_items.at(i); - - if (item1->getLinkedUUID() != item2->getLinkedUUID() || - item1->getName() != item2->getName() || - item1->getActualDescription() != item2->getActualDescription()) - { - if (item1->getLinkedUUID() != item2->getLinkedUUID()) - { - LL_DEBUGS("Avatar") << "link id different " << LL_ENDL; - } - else - { - if (item1->getName() != item2->getName()) - { - LL_DEBUGS("Avatar") << "name different " << item1->getName() << " " << item2->getName() << LL_ENDL; - } - if (item1->getActualDescription() != item2->getActualDescription()) - { - LL_DEBUGS("Avatar") << "desc different " << item1->getActualDescription() - << " " << item2->getActualDescription() - << " names " << item1->getName() << " " << item2->getName() << LL_ENDL; - } - } - mOutfitIsDirty = true; - return; - } - } - } - llassert(!mOutfitIsDirty); - LL_DEBUGS("Avatar") << "clean" << LL_ENDL; -} - -// *HACK: Must match name in Library or agent inventory -const std::string ROOT_GESTURES_FOLDER = "Gestures"; -const std::string COMMON_GESTURES_FOLDER = "Common Gestures"; -const std::string MALE_GESTURES_FOLDER = "Male Gestures"; -const std::string FEMALE_GESTURES_FOLDER = "Female Gestures"; -const std::string SPEECH_GESTURES_FOLDER = "Speech Gestures"; -const std::string OTHER_GESTURES_FOLDER = "Other Gestures"; - -void LLAppearanceMgr::copyLibraryGestures() -{ - LL_INFOS("Avatar") << self_av_string() << "Copying library gestures" << LL_ENDL; - - // Copy gestures - LLUUID lib_gesture_cat_id = - gInventory.findLibraryCategoryUUIDForType(LLFolderType::FT_GESTURE,false); - if (lib_gesture_cat_id.isNull()) - { - LL_WARNS() << "Unable to copy gestures, source category not found" << LL_ENDL; - } - LLUUID dst_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_GESTURE); - - std::vector gesture_folders_to_copy; - gesture_folders_to_copy.push_back(MALE_GESTURES_FOLDER); - gesture_folders_to_copy.push_back(FEMALE_GESTURES_FOLDER); - gesture_folders_to_copy.push_back(COMMON_GESTURES_FOLDER); - gesture_folders_to_copy.push_back(SPEECH_GESTURES_FOLDER); - gesture_folders_to_copy.push_back(OTHER_GESTURES_FOLDER); - - for(std::vector::iterator it = gesture_folders_to_copy.begin(); - it != gesture_folders_to_copy.end(); - ++it) - { - std::string& folder_name = *it; - - LLPointer cb(NULL); - - // After copying gestures, activate Common, Other, plus - // Male and/or Female, depending upon the initial outfit gender. - ESex gender = gAgentAvatarp->getSex(); - - std::string activate_male_gestures; - std::string activate_female_gestures; - switch (gender) { - case SEX_MALE: - activate_male_gestures = MALE_GESTURES_FOLDER; - break; - case SEX_FEMALE: - activate_female_gestures = FEMALE_GESTURES_FOLDER; - break; - case SEX_BOTH: - activate_male_gestures = MALE_GESTURES_FOLDER; - activate_female_gestures = FEMALE_GESTURES_FOLDER; - break; - } - - if (folder_name == activate_male_gestures || - folder_name == activate_female_gestures || - folder_name == COMMON_GESTURES_FOLDER || - folder_name == OTHER_GESTURES_FOLDER) - { - cb = new LLBoostFuncInventoryCallback(activate_gesture_cb); - } - - LLUUID cat_id = findDescendentCategoryIDByName(lib_gesture_cat_id,folder_name); - if (cat_id.isNull()) - { - LL_WARNS() << self_av_string() << "failed to find gesture folder for " << folder_name << LL_ENDL; - } - else - { - LL_DEBUGS("Avatar") << self_av_string() << "initiating fetch and copy for " << folder_name << " cat_id " << cat_id << LL_ENDL; - callAfterCategoryFetch(cat_id, - boost::bind(&LLAppearanceMgr::shallowCopyCategory, - &LLAppearanceMgr::instance(), - cat_id, dst_id, cb)); - } - } -} - -// Handler for anything that's deferred until avatar de-clouds. -void LLAppearanceMgr::onFirstFullyVisible() -{ - gAgentAvatarp->outputRezTiming("Avatar fully loaded"); - gAgentAvatarp->reportAvatarRezTime(); - gAgentAvatarp->debugAvatarVisible(); - - // If this is the first time we've ever logged in, - // then copy default gestures from the library. - if (gAgent.isFirstLogin()) { - copyLibraryGestures(); - } -} - -// update "dirty" state - defined outside class to allow for calling -// after appearance mgr instance has been destroyed. -void appearance_mgr_update_dirty_state() -{ - if (LLAppearanceMgr::instanceExists()) - { - LLAppearanceMgr::getInstance()->updateIsDirty(); - LLAppearanceMgr::getInstance()->setOutfitLocked(false); - gAgentWearables.notifyLoadingFinished(); - } -} - -void update_base_outfit_after_ordering() -{ - LLAppearanceMgr& app_mgr = LLAppearanceMgr::instance(); - - LLPointer dirty_state_updater = - new LLBoostFuncInventoryCallback(no_op_inventory_func, appearance_mgr_update_dirty_state); - - //COF contains only links so we copy to the Base Outfit only links - const LLUUID base_outfit_id = app_mgr.getBaseOutfitUUID(); - bool copy_folder_links = false; - app_mgr.slamCategoryLinks(app_mgr.getCOF(), base_outfit_id, copy_folder_links, dirty_state_updater); - -} - -// Save COF changes - update the contents of the current base outfit -// to match the current COF. Fails if no current base outfit is set. -bool LLAppearanceMgr::updateBaseOutfit() -{ - if (isOutfitLocked()) - { - // don't allow modify locked outfit - llassert(!isOutfitLocked()); - return false; - } - - setOutfitLocked(true); - - gAgentWearables.notifyLoadingStarted(); - - const LLUUID base_outfit_id = getBaseOutfitUUID(); - if (base_outfit_id.isNull()) return false; - LL_DEBUGS("Avatar") << "saving cof to base outfit " << base_outfit_id << LL_ENDL; - - LLPointer cb = - new LLBoostFuncInventoryCallback(no_op_inventory_func, update_base_outfit_after_ordering); - // Really shouldn't be needed unless there's a race condition - - // updateAppearanceFromCOF() already calls updateClothingOrderingInfo. - updateClothingOrderingInfo(LLUUID::null, cb); - - return true; -} - -void LLAppearanceMgr::divvyWearablesByType(const LLInventoryModel::item_array_t& items, wearables_by_type_t& items_by_type) -{ - items_by_type.resize(LLWearableType::WT_COUNT); - if (items.empty()) return; - - for (S32 i=0; iisWearableType()) - continue; - LLWearableType::EType type = item->getWearableType(); - if(type < 0 || type >= LLWearableType::WT_COUNT) - { - LL_WARNS("Appearance") << "Invalid wearable type. Inventory type does not match wearable flag bitfield." << LL_ENDL; - continue; - } - items_by_type[type].push_back(item); - } -} - -std::string build_order_string(LLWearableType::EType type, U32 i) -{ - std::ostringstream order_num; - order_num << ORDER_NUMBER_SEPARATOR << type * 100 + i; - return order_num.str(); -} - -struct WearablesOrderComparator -{ - LOG_CLASS(WearablesOrderComparator); - WearablesOrderComparator(const LLWearableType::EType type) - { - mControlSize = build_order_string(type, 0).size(); - }; - - bool operator()(const LLInventoryItem* item1, const LLInventoryItem* item2) - { - const std::string& desc1 = item1->getActualDescription(); - const std::string& desc2 = item2->getActualDescription(); - - bool item1_valid = (desc1.size() == mControlSize) && (ORDER_NUMBER_SEPARATOR == desc1[0]); - bool item2_valid = (desc2.size() == mControlSize) && (ORDER_NUMBER_SEPARATOR == desc2[0]); - - if (item1_valid && item2_valid) - return desc1 < desc2; - - //we need to sink down invalid items: items with empty descriptions, items with "Broken link" descriptions, - //items with ordering information but not for the associated wearables type - if (!item1_valid && item2_valid) - return false; - else if (item1_valid && !item2_valid) - return true; - - return item1->getName() < item2->getName(); - } - - U32 mControlSize; -}; - -void LLAppearanceMgr::getWearableOrderingDescUpdates(LLInventoryModel::item_array_t& wear_items, - desc_map_t& desc_map) -{ - wearables_by_type_t items_by_type(LLWearableType::WT_COUNT); - divvyWearablesByType(wear_items, items_by_type); - - for (U32 type = LLWearableType::WT_SHIRT; type < LLWearableType::WT_COUNT; type++) - { - U32 size = items_by_type[type].size(); - if (!size) continue; - - //sinking down invalid items which need reordering - std::sort(items_by_type[type].begin(), items_by_type[type].end(), WearablesOrderComparator((LLWearableType::EType) type)); - - //requesting updates only for those links which don't have "valid" descriptions - for (U32 i = 0; i < size; i++) - { - LLViewerInventoryItem* item = items_by_type[type][i]; - if (!item) continue; - - std::string new_order_str = build_order_string((LLWearableType::EType)type, i); - if (new_order_str == item->getActualDescription()) continue; - - desc_map[item->getUUID()] = new_order_str; - } - } -} - -bool LLAppearanceMgr::validateClothingOrderingInfo(LLUUID cat_id) -{ - // COF is processed if cat_id is not specified - if (cat_id.isNull()) - { - cat_id = getCOF(); - } - - LLInventoryModel::item_array_t wear_items; - getDescendentsOfAssetType(cat_id, wear_items, LLAssetType::AT_CLOTHING); - - // Identify items for which desc needs to change. - desc_map_t desc_map; - getWearableOrderingDescUpdates(wear_items, desc_map); - - for (desc_map_t::const_iterator it = desc_map.begin(); - it != desc_map.end(); ++it) - { - const LLUUID& item_id = it->first; - const std::string& new_order_str = it->second; - LLViewerInventoryItem *item = gInventory.getItem(item_id); - LL_WARNS() << "Order validation fails: " << item->getName() - << " needs to update desc to: " << new_order_str - << " (from: " << item->getActualDescription() << ")" << LL_ENDL; - } - - return desc_map.size() == 0; -} - -void LLAppearanceMgr::updateClothingOrderingInfo(LLUUID cat_id, - LLPointer cb) -{ - // COF is processed if cat_id is not specified - if (cat_id.isNull()) - { - cat_id = getCOF(); - } - - LLInventoryModel::item_array_t wear_items; - getDescendentsOfAssetType(cat_id, wear_items, LLAssetType::AT_CLOTHING); - - // Identify items for which desc needs to change. - desc_map_t desc_map; - getWearableOrderingDescUpdates(wear_items, desc_map); - - for (desc_map_t::const_iterator it = desc_map.begin(); - it != desc_map.end(); ++it) - { - LLSD updates; - const LLUUID& item_id = it->first; - const std::string& new_order_str = it->second; - LLViewerInventoryItem *item = gInventory.getItem(item_id); - LL_DEBUGS("Avatar") << item->getName() << " updating desc to: " << new_order_str - << " (was: " << item->getActualDescription() << ")" << LL_ENDL; - updates["desc"] = new_order_str; - update_inventory_item(item_id,updates,cb); - } - -} - - -LLSD LLAppearanceMgr::dumpCOF() const -{ - LLSD links = LLSD::emptyArray(); - LLMD5 md5; - - LLInventoryModel::cat_array_t cat_array; - LLInventoryModel::item_array_t item_array; - gInventory.collectDescendents(getCOF(),cat_array,item_array,LLInventoryModel::EXCLUDE_TRASH); - for (S32 i=0; igetUUID()); - md5.update((unsigned char*)item_id.mData, 16); - item["description"] = inv_item->getActualDescription(); - md5.update(inv_item->getActualDescription()); - item["asset_type"] = inv_item->getActualType(); - LLUUID linked_id(inv_item->getLinkedUUID()); - item["linked_id"] = linked_id; - md5.update((unsigned char*)linked_id.mData, 16); - - if (LLAssetType::AT_LINK == inv_item->getActualType()) - { - const LLViewerInventoryItem* linked_item = inv_item->getLinkedItem(); - if (NULL == linked_item) - { - LL_WARNS() << "Broken link for item '" << inv_item->getName() - << "' (" << inv_item->getUUID() - << ") during requestServerAppearanceUpdate" << LL_ENDL; - continue; - } - // Some assets may be 'hidden' and show up as null in the viewer. - //if (linked_item->getAssetUUID().isNull()) - //{ - // LL_WARNS() << "Broken link (null asset) for item '" << inv_item->getName() - // << "' (" << inv_item->getUUID() - // << ") during requestServerAppearanceUpdate" << LL_ENDL; - // continue; - //} - LLUUID linked_asset_id(linked_item->getAssetUUID()); - md5.update((unsigned char*)linked_asset_id.mData, 16); - U32 flags = linked_item->getFlags(); - md5.update(boost::lexical_cast(flags)); - } - else if (LLAssetType::AT_LINK_FOLDER != inv_item->getActualType()) - { - LL_WARNS() << "Non-link item '" << inv_item->getName() - << "' (" << inv_item->getUUID() - << ") type " << (S32) inv_item->getActualType() - << " during requestServerAppearanceUpdate" << LL_ENDL; - continue; - } - links.append(item); - } - LLSD result = LLSD::emptyMap(); - result["cof_contents"] = links; - char cof_md5sum[MD5HEX_STR_SIZE]; - md5.finalize(); - md5.hex_digest(cof_md5sum); - result["cof_md5sum"] = std::string(cof_md5sum); - return result; -} - -void LLAppearanceMgr::requestServerAppearanceUpdate() -{ - - if (!testCOFRequestVersion()) - { - // *TODO: LL_LOG message here - return; - } - - if ((mInFlightCounter > 0) && (mInFlightTimer.hasExpired())) - { - LL_WARNS("Avatar") << "in flight timer expired, resetting " << LL_ENDL; - mInFlightCounter = 0; - } - - if (gAgentAvatarp->isEditingAppearance()) - { - LL_WARNS("Avatar") << "Avatar editing appeance, not sending request." << LL_ENDL; - // don't send out appearance updates if in appearance editing mode - return; - } - - if (!gAgent.getRegion()) - { - LL_WARNS("Avatar") << "Region not set, cannot request server appearance update" << LL_ENDL; - return; - } - if (gAgent.getRegion()->getCentralBakeVersion() == 0) - { - LL_WARNS("Avatar") << "Region does not support baking" << LL_ENDL; - } - std::string url = gAgent.getRegion()->getCapability("UpdateAvatarAppearance"); - if (url.empty()) - { - LL_WARNS("Avatar") << "No cap for UpdateAvatarAppearance." << LL_ENDL; - return; - } - - LLSD postData; - S32 cof_version = LLAppearanceMgr::instance().getCOFVersion(); - if (gSavedSettings.getBOOL("DebugAvatarExperimentalServerAppearanceUpdate")) - { - postData = LLAppearanceMgr::instance().dumpCOF(); - } - else - { - postData["cof_version"] = cof_version; - if (gSavedSettings.getBOOL("DebugForceAppearanceRequestFailure")) - { - postData["cof_version"] = cof_version + 999; - } - } - LL_DEBUGS("Avatar") << "request url " << url << " my_cof_version " << cof_version << LL_ENDL; - - LLAppearanceMgrHttpHandler * handler = new LLAppearanceMgrHttpHandler(url, this); - - mInFlightCounter++; - mInFlightTimer.setTimerExpirySec(60.0); - - llassert(cof_version >= gAgentAvatarp->mLastUpdateRequestCOFVersion); - gAgentAvatarp->mLastUpdateRequestCOFVersion = cof_version; - - LLCore::HttpHandle handle = LLCoreHttpUtil::requestPostWithLLSD(mHttpRequest, - mHttpPolicy, mHttpPriority, url, - postData, mHttpOptions, mHttpHeaders, handler); - - if (handle == LLCORE_HTTP_HANDLE_INVALID) - { + +// update "dirty" state - defined outside class to allow for calling +// after appearance mgr instance has been destroyed. +void appearance_mgr_update_dirty_state() +{ + if (LLAppearanceMgr::instanceExists()) + { + LLAppearanceMgr::getInstance()->updateIsDirty(); + LLAppearanceMgr::getInstance()->setOutfitLocked(false); + gAgentWearables.notifyLoadingFinished(); + } +} + +void update_base_outfit_after_ordering() +{ + LLAppearanceMgr& app_mgr = LLAppearanceMgr::instance(); + + LLPointer dirty_state_updater = + new LLBoostFuncInventoryCallback(no_op_inventory_func, appearance_mgr_update_dirty_state); + + //COF contains only links so we copy to the Base Outfit only links + const LLUUID base_outfit_id = app_mgr.getBaseOutfitUUID(); + bool copy_folder_links = false; + app_mgr.slamCategoryLinks(app_mgr.getCOF(), base_outfit_id, copy_folder_links, dirty_state_updater); + +} + +// Save COF changes - update the contents of the current base outfit +// to match the current COF. Fails if no current base outfit is set. +bool LLAppearanceMgr::updateBaseOutfit() +{ + if (isOutfitLocked()) + { + // don't allow modify locked outfit + llassert(!isOutfitLocked()); + return false; + } + + setOutfitLocked(true); + + gAgentWearables.notifyLoadingStarted(); + + const LLUUID base_outfit_id = getBaseOutfitUUID(); + if (base_outfit_id.isNull()) return false; + LL_DEBUGS("Avatar") << "saving cof to base outfit " << base_outfit_id << LL_ENDL; + + LLPointer cb = + new LLBoostFuncInventoryCallback(no_op_inventory_func, update_base_outfit_after_ordering); + // Really shouldn't be needed unless there's a race condition - + // updateAppearanceFromCOF() already calls updateClothingOrderingInfo. + updateClothingOrderingInfo(LLUUID::null, cb); + + return true; +} + +void LLAppearanceMgr::divvyWearablesByType(const LLInventoryModel::item_array_t& items, wearables_by_type_t& items_by_type) +{ + items_by_type.resize(LLWearableType::WT_COUNT); + if (items.empty()) return; + + for (S32 i=0; iisWearableType()) + continue; + LLWearableType::EType type = item->getWearableType(); + if(type < 0 || type >= LLWearableType::WT_COUNT) + { + LL_WARNS("Appearance") << "Invalid wearable type. Inventory type does not match wearable flag bitfield." << LL_ENDL; + continue; + } + items_by_type[type].push_back(item); + } +} + +std::string build_order_string(LLWearableType::EType type, U32 i) +{ + std::ostringstream order_num; + order_num << ORDER_NUMBER_SEPARATOR << type * 100 + i; + return order_num.str(); +} + +struct WearablesOrderComparator +{ + LOG_CLASS(WearablesOrderComparator); + WearablesOrderComparator(const LLWearableType::EType type) + { + mControlSize = build_order_string(type, 0).size(); + }; + + bool operator()(const LLInventoryItem* item1, const LLInventoryItem* item2) + { + const std::string& desc1 = item1->getActualDescription(); + const std::string& desc2 = item2->getActualDescription(); + + bool item1_valid = (desc1.size() == mControlSize) && (ORDER_NUMBER_SEPARATOR == desc1[0]); + bool item2_valid = (desc2.size() == mControlSize) && (ORDER_NUMBER_SEPARATOR == desc2[0]); + + if (item1_valid && item2_valid) + return desc1 < desc2; + + //we need to sink down invalid items: items with empty descriptions, items with "Broken link" descriptions, + //items with ordering information but not for the associated wearables type + if (!item1_valid && item2_valid) + return false; + else if (item1_valid && !item2_valid) + return true; + + return item1->getName() < item2->getName(); + } + + U32 mControlSize; +}; + +void LLAppearanceMgr::getWearableOrderingDescUpdates(LLInventoryModel::item_array_t& wear_items, + desc_map_t& desc_map) +{ + wearables_by_type_t items_by_type(LLWearableType::WT_COUNT); + divvyWearablesByType(wear_items, items_by_type); + + for (U32 type = LLWearableType::WT_SHIRT; type < LLWearableType::WT_COUNT; type++) + { + U32 size = items_by_type[type].size(); + if (!size) continue; + + //sinking down invalid items which need reordering + std::sort(items_by_type[type].begin(), items_by_type[type].end(), WearablesOrderComparator((LLWearableType::EType) type)); + + //requesting updates only for those links which don't have "valid" descriptions + for (U32 i = 0; i < size; i++) + { + LLViewerInventoryItem* item = items_by_type[type][i]; + if (!item) continue; + + std::string new_order_str = build_order_string((LLWearableType::EType)type, i); + if (new_order_str == item->getActualDescription()) continue; + + desc_map[item->getUUID()] = new_order_str; + } + } +} + +bool LLAppearanceMgr::validateClothingOrderingInfo(LLUUID cat_id) +{ + // COF is processed if cat_id is not specified + if (cat_id.isNull()) + { + cat_id = getCOF(); + } + + LLInventoryModel::item_array_t wear_items; + getDescendentsOfAssetType(cat_id, wear_items, LLAssetType::AT_CLOTHING); + + // Identify items for which desc needs to change. + desc_map_t desc_map; + getWearableOrderingDescUpdates(wear_items, desc_map); + + for (desc_map_t::const_iterator it = desc_map.begin(); + it != desc_map.end(); ++it) + { + const LLUUID& item_id = it->first; + const std::string& new_order_str = it->second; + LLViewerInventoryItem *item = gInventory.getItem(item_id); + LL_WARNS() << "Order validation fails: " << item->getName() + << " needs to update desc to: " << new_order_str + << " (from: " << item->getActualDescription() << ")" << LL_ENDL; + } + + return desc_map.size() == 0; +} + +void LLAppearanceMgr::updateClothingOrderingInfo(LLUUID cat_id, + LLPointer cb) +{ + // COF is processed if cat_id is not specified + if (cat_id.isNull()) + { + cat_id = getCOF(); + } + + LLInventoryModel::item_array_t wear_items; + getDescendentsOfAssetType(cat_id, wear_items, LLAssetType::AT_CLOTHING); + + // Identify items for which desc needs to change. + desc_map_t desc_map; + getWearableOrderingDescUpdates(wear_items, desc_map); + + for (desc_map_t::const_iterator it = desc_map.begin(); + it != desc_map.end(); ++it) + { + LLSD updates; + const LLUUID& item_id = it->first; + const std::string& new_order_str = it->second; + LLViewerInventoryItem *item = gInventory.getItem(item_id); + LL_DEBUGS("Avatar") << item->getName() << " updating desc to: " << new_order_str + << " (was: " << item->getActualDescription() << ")" << LL_ENDL; + updates["desc"] = new_order_str; + update_inventory_item(item_id,updates,cb); + } + +} + + +LLSD LLAppearanceMgr::dumpCOF() const +{ + LLSD links = LLSD::emptyArray(); + LLMD5 md5; + + LLInventoryModel::cat_array_t cat_array; + LLInventoryModel::item_array_t item_array; + gInventory.collectDescendents(getCOF(),cat_array,item_array,LLInventoryModel::EXCLUDE_TRASH); + for (S32 i=0; igetUUID()); + md5.update((unsigned char*)item_id.mData, 16); + item["description"] = inv_item->getActualDescription(); + md5.update(inv_item->getActualDescription()); + item["asset_type"] = inv_item->getActualType(); + LLUUID linked_id(inv_item->getLinkedUUID()); + item["linked_id"] = linked_id; + md5.update((unsigned char*)linked_id.mData, 16); + + if (LLAssetType::AT_LINK == inv_item->getActualType()) + { + const LLViewerInventoryItem* linked_item = inv_item->getLinkedItem(); + if (NULL == linked_item) + { + LL_WARNS() << "Broken link for item '" << inv_item->getName() + << "' (" << inv_item->getUUID() + << ") during requestServerAppearanceUpdate" << LL_ENDL; + continue; + } + // Some assets may be 'hidden' and show up as null in the viewer. + //if (linked_item->getAssetUUID().isNull()) + //{ + // LL_WARNS() << "Broken link (null asset) for item '" << inv_item->getName() + // << "' (" << inv_item->getUUID() + // << ") during requestServerAppearanceUpdate" << LL_ENDL; + // continue; + //} + LLUUID linked_asset_id(linked_item->getAssetUUID()); + md5.update((unsigned char*)linked_asset_id.mData, 16); + U32 flags = linked_item->getFlags(); + md5.update(boost::lexical_cast(flags)); + } + else if (LLAssetType::AT_LINK_FOLDER != inv_item->getActualType()) + { + LL_WARNS() << "Non-link item '" << inv_item->getName() + << "' (" << inv_item->getUUID() + << ") type " << (S32) inv_item->getActualType() + << " during requestServerAppearanceUpdate" << LL_ENDL; + continue; + } + links.append(item); + } + LLSD result = LLSD::emptyMap(); + result["cof_contents"] = links; + char cof_md5sum[MD5HEX_STR_SIZE]; + md5.finalize(); + md5.hex_digest(cof_md5sum); + result["cof_md5sum"] = std::string(cof_md5sum); + return result; +} + +void LLAppearanceMgr::requestServerAppearanceUpdate() +{ + + if (!testCOFRequestVersion()) + { + // *TODO: LL_LOG message here + return; + } + + if ((mInFlightCounter > 0) && (mInFlightTimer.hasExpired())) + { + LL_WARNS("Avatar") << "in flight timer expired, resetting " << LL_ENDL; + mInFlightCounter = 0; + } + + if (gAgentAvatarp->isEditingAppearance()) + { + LL_WARNS("Avatar") << "Avatar editing appeance, not sending request." << LL_ENDL; + // don't send out appearance updates if in appearance editing mode + return; + } + + if (!gAgent.getRegion()) + { + LL_WARNS("Avatar") << "Region not set, cannot request server appearance update" << LL_ENDL; + return; + } + if (gAgent.getRegion()->getCentralBakeVersion() == 0) + { + LL_WARNS("Avatar") << "Region does not support baking" << LL_ENDL; + } + std::string url = gAgent.getRegion()->getCapability("UpdateAvatarAppearance"); + if (url.empty()) + { + LL_WARNS("Avatar") << "No cap for UpdateAvatarAppearance." << LL_ENDL; + return; + } + + LLSD postData; + S32 cof_version = LLAppearanceMgr::instance().getCOFVersion(); + if (gSavedSettings.getBOOL("DebugAvatarExperimentalServerAppearanceUpdate")) + { + postData = LLAppearanceMgr::instance().dumpCOF(); + } + else + { + postData["cof_version"] = cof_version; + if (gSavedSettings.getBOOL("DebugForceAppearanceRequestFailure")) + { + postData["cof_version"] = cof_version + 999; + } + } + LL_DEBUGS("Avatar") << "request url " << url << " my_cof_version " << cof_version << LL_ENDL; + + LLAppearanceMgrHttpHandler * handler = new LLAppearanceMgrHttpHandler(url, this); + + mInFlightCounter++; + mInFlightTimer.setTimerExpirySec(60.0); + + llassert(cof_version >= gAgentAvatarp->mLastUpdateRequestCOFVersion); + gAgentAvatarp->mLastUpdateRequestCOFVersion = cof_version; + + LLCore::HttpHandle handle = LLCoreHttpUtil::requestPostWithLLSD(mHttpRequest, + mHttpPolicy, mHttpPriority, url, + postData, mHttpOptions, mHttpHeaders, handler); + + if (handle == LLCORE_HTTP_HANDLE_INVALID) + { delete handler; LLCore::HttpStatus status = mHttpRequest->getStatus(); - LL_WARNS("Avatar") << "Appearance request post failed Reason " << status.toTerseString() - << " \"" << status.toString() << "\"" << LL_ENDL; - } -} - -bool LLAppearanceMgr::testCOFRequestVersion() const -{ - // If we have already received an update for this or higher cof version, ignore. - S32 cof_version = getCOFVersion(); - S32 last_rcv = gAgentAvatarp->mLastUpdateReceivedCOFVersion; - S32 last_req = gAgentAvatarp->mLastUpdateRequestCOFVersion; - - LL_DEBUGS("Avatar") << "cof_version " << cof_version - << " last_rcv " << last_rcv - << " last_req " << last_req - << " in flight " << mInFlightCounter - << LL_ENDL; - if (cof_version < last_rcv) - { - LL_DEBUGS("Avatar") << "Have already received update for cof version " << last_rcv - << " will not request for " << cof_version << LL_ENDL; - return false; - } - if (/*mInFlightCounter > 0 &&*/ last_req >= cof_version) - { - LL_DEBUGS("Avatar") << "Request already in flight for cof version " << last_req - << " will not request for " << cof_version << LL_ENDL; - return false; - } - - // Actually send the request. - LL_DEBUGS("Avatar") << "Will send request for cof_version " << cof_version << LL_ENDL; - return true; -} - + LL_WARNS("Avatar") << "Appearance request post failed Reason " << status.toTerseString() + << " \"" << status.toString() << "\"" << LL_ENDL; + } +} + +bool LLAppearanceMgr::testCOFRequestVersion() const +{ + // If we have already received an update for this or higher cof version, ignore. + S32 cof_version = getCOFVersion(); + S32 last_rcv = gAgentAvatarp->mLastUpdateReceivedCOFVersion; + S32 last_req = gAgentAvatarp->mLastUpdateRequestCOFVersion; + + LL_DEBUGS("Avatar") << "cof_version " << cof_version + << " last_rcv " << last_rcv + << " last_req " << last_req + << " in flight " << mInFlightCounter + << LL_ENDL; + if (cof_version < last_rcv) + { + LL_DEBUGS("Avatar") << "Have already received update for cof version " << last_rcv + << " will not request for " << cof_version << LL_ENDL; + return false; + } + if (/*mInFlightCounter > 0 &&*/ last_req >= cof_version) + { + LL_DEBUGS("Avatar") << "Request already in flight for cof version " << last_req + << " will not request for " << cof_version << LL_ENDL; + return false; + } + + // Actually send the request. + LL_DEBUGS("Avatar") << "Will send request for cof_version " << cof_version << LL_ENDL; + return true; +} + bool LLAppearanceMgr::onIdle() { if (!LLAppearanceMgr::mActive) @@ -3492,566 +3492,566 @@ bool LLAppearanceMgr::onIdle() mHttpRequest->update(0L); return false; } - -std::string LLAppearanceMgr::getAppearanceServiceURL() const -{ - if (gSavedSettings.getString("DebugAvatarAppearanceServiceURLOverride").empty()) - { - return mAppearanceServiceURL; - } - return gSavedSettings.getString("DebugAvatarAppearanceServiceURLOverride"); -} - -void show_created_outfit(LLUUID& folder_id, bool show_panel = true) -{ - if (!LLApp::isRunning()) - { - LL_WARNS() << "called during shutdown, skipping" << LL_ENDL; - return; - } - - LL_DEBUGS("Avatar") << "called" << LL_ENDL; - LLSD key; - - //EXT-7727. For new accounts inventory callback is created during login process - // and may be processed after login process is finished - if (show_panel) - { - LL_DEBUGS("Avatar") << "showing panel" << LL_ENDL; - LLFloaterSidePanelContainer::showPanel("appearance", "panel_outfits_inventory", key); - - } - LLOutfitsList *outfits_list = - dynamic_cast(LLFloaterSidePanelContainer::getPanel("appearance", "outfitslist_tab")); - if (outfits_list) - { - outfits_list->setSelectedOutfitByUUID(folder_id); - } - - LLAppearanceMgr::getInstance()->updateIsDirty(); - gAgentWearables.notifyLoadingFinished(); // New outfit is saved. - LLAppearanceMgr::getInstance()->updatePanelOutfitName(""); - - // For SSB, need to update appearance after we add a base outfit - // link, since, the COF version has changed. There is a race - // condition in initial outfit setup which can lead to rez - // failures - SH-3860. - LL_DEBUGS("Avatar") << "requesting appearance update after createBaseOutfitLink" << LL_ENDL; - LLPointer cb = new LLUpdateAppearanceOnDestroy; - LLAppearanceMgr::getInstance()->createBaseOutfitLink(folder_id, cb); -} - -void LLAppearanceMgr::onOutfitFolderCreated(const LLUUID& folder_id, bool show_panel) -{ - LLPointer cb = - new LLBoostFuncInventoryCallback(no_op_inventory_func, - boost::bind(&LLAppearanceMgr::onOutfitFolderCreatedAndClothingOrdered,this,folder_id,show_panel)); - updateClothingOrderingInfo(LLUUID::null, cb); -} - -void LLAppearanceMgr::onOutfitFolderCreatedAndClothingOrdered(const LLUUID& folder_id, bool show_panel) -{ - LLPointer cb = - new LLBoostFuncInventoryCallback(no_op_inventory_func, - boost::bind(show_created_outfit,folder_id,show_panel)); - bool copy_folder_links = false; - slamCategoryLinks(getCOF(), folder_id, copy_folder_links, cb); -} - -void LLAppearanceMgr::makeNewOutfitLinks(const std::string& new_folder_name, bool show_panel) -{ - if (!isAgentAvatarValid()) return; - - LL_DEBUGS("Avatar") << "creating new outfit" << LL_ENDL; - - gAgentWearables.notifyLoadingStarted(); - - // First, make a folder in the My Outfits directory. - const LLUUID parent_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_MY_OUTFITS); - if (AISCommand::isAPIAvailable()) - { - // cap-based category creation was buggy until recently. use - // existence of AIS as an indicator the fix is present. Does - // not actually use AIS to create the category. - inventory_func_type func = boost::bind(&LLAppearanceMgr::onOutfitFolderCreated,this,_1,show_panel); - LLUUID folder_id = gInventory.createNewCategory( - parent_id, - LLFolderType::FT_OUTFIT, - new_folder_name, - func); - } - else - { - LLUUID folder_id = gInventory.createNewCategory( - parent_id, - LLFolderType::FT_OUTFIT, - new_folder_name); - onOutfitFolderCreated(folder_id, show_panel); - } -} - -void LLAppearanceMgr::wearBaseOutfit() -{ - const LLUUID& base_outfit_id = getBaseOutfitUUID(); - if (base_outfit_id.isNull()) return; - - updateCOF(base_outfit_id); -} - -void LLAppearanceMgr::removeItemsFromAvatar(const uuid_vec_t& ids_to_remove) -{ - if (ids_to_remove.empty()) - { - LL_WARNS() << "called with empty list, nothing to do" << LL_ENDL; - return; - } - LLPointer cb = new LLUpdateAppearanceOnDestroy; - for (uuid_vec_t::const_iterator it = ids_to_remove.begin(); it != ids_to_remove.end(); ++it) - { - const LLUUID& id_to_remove = *it; - const LLUUID& linked_item_id = gInventory.getLinkedItemID(id_to_remove); - removeCOFItemLinks(linked_item_id, cb); - addDoomedTempAttachment(linked_item_id); - } -} - -void LLAppearanceMgr::removeItemFromAvatar(const LLUUID& id_to_remove) -{ - LLUUID linked_item_id = gInventory.getLinkedItemID(id_to_remove); - LLPointer cb = new LLUpdateAppearanceOnDestroy; - removeCOFItemLinks(linked_item_id, cb); - addDoomedTempAttachment(linked_item_id); -} - - -// Adds the given item ID to mDoomedTempAttachmentIDs iff it's a temp attachment -void LLAppearanceMgr::addDoomedTempAttachment(const LLUUID& id_to_remove) -{ - LLViewerObject * attachmentp = gAgentAvatarp->findAttachmentByID(id_to_remove); - if (attachmentp && - attachmentp->isTempAttachment()) - { // If this is a temp attachment and we want to remove it, record the ID - // so it will be deleted when attachments are synced up with COF - mDoomedTempAttachmentIDs.insert(id_to_remove); - //LL_INFOS() << "Will remove temp attachment id " << id_to_remove << LL_ENDL; - } -} - -// Find AND REMOVES the given UUID from mDoomedTempAttachmentIDs -bool LLAppearanceMgr::shouldRemoveTempAttachment(const LLUUID& item_id) -{ - doomed_temp_attachments_t::iterator iter = mDoomedTempAttachmentIDs.find(item_id); - if (iter != mDoomedTempAttachmentIDs.end()) - { - mDoomedTempAttachmentIDs.erase(iter); - return true; - } - return false; -} - - -bool LLAppearanceMgr::moveWearable(LLViewerInventoryItem* item, bool closer_to_body) -{ - if (!item || !item->isWearableType()) return false; - if (item->getType() != LLAssetType::AT_CLOTHING) return false; - if (!gInventory.isObjectDescendentOf(item->getUUID(), getCOF())) return false; - - LLInventoryModel::cat_array_t cats; - LLInventoryModel::item_array_t items; - LLFindWearablesOfType filter_wearables_of_type(item->getWearableType()); - gInventory.collectDescendentsIf(getCOF(), cats, items, true, filter_wearables_of_type); - if (items.empty()) return false; - - // We assume that the items have valid descriptions. - std::sort(items.begin(), items.end(), WearablesOrderComparator(item->getWearableType())); - - if (closer_to_body && items.front() == item) return false; - if (!closer_to_body && items.back() == item) return false; - - LLInventoryModel::item_array_t::iterator it = std::find(items.begin(), items.end(), item); - if (items.end() == it) return false; - - - //swapping descriptions - closer_to_body ? --it : ++it; - LLViewerInventoryItem* swap_item = *it; - if (!swap_item) return false; - std::string tmp = swap_item->getActualDescription(); - swap_item->setDescription(item->getActualDescription()); - item->setDescription(tmp); - - // LL_DEBUGS("Inventory") << "swap, item " - // << ll_pretty_print_sd(item->asLLSD()) - // << " swap_item " - // << ll_pretty_print_sd(swap_item->asLLSD()) << LL_ENDL; - - // FIXME switch to use AISv3 where supported. - //items need to be updated on a dataserver - item->setComplete(TRUE); - item->updateServer(FALSE); - gInventory.updateItem(item); - - swap_item->setComplete(TRUE); - swap_item->updateServer(FALSE); - gInventory.updateItem(swap_item); - - //to cause appearance of the agent to be updated - bool result = false; - if ((result = gAgentWearables.moveWearable(item, closer_to_body))) - { - gAgentAvatarp->wearableUpdated(item->getWearableType()); - } - - setOutfitDirty(true); - - //*TODO do we need to notify observers here in such a way? - gInventory.notifyObservers(); - - return result; -} - -//static -void LLAppearanceMgr::sortItemsByActualDescription(LLInventoryModel::item_array_t& items) -{ - if (items.size() < 2) return; - - std::sort(items.begin(), items.end(), sort_by_actual_description); -} - -//#define DUMP_CAT_VERBOSE - -void LLAppearanceMgr::dumpCat(const LLUUID& cat_id, const std::string& msg) -{ - LLInventoryModel::cat_array_t cats; - LLInventoryModel::item_array_t items; - gInventory.collectDescendents(cat_id, cats, items, LLInventoryModel::EXCLUDE_TRASH); - -#ifdef DUMP_CAT_VERBOSE - LL_INFOS() << LL_ENDL; - LL_INFOS() << str << LL_ENDL; - S32 hitcount = 0; - for(S32 i=0; igetName() <getLinkedItem() : NULL; - LLUUID asset_id; - if (linked_item) - { - asset_id = linked_item->getAssetUUID(); - } - LL_DEBUGS("Avatar") << self_av_string() << msg << " " << i <<" " << (item ? item->getName() : "(nullitem)") << " " << asset_id.asString() << LL_ENDL; - } -} - -bool LLAppearanceMgr::mActive = true; - -LLAppearanceMgr::LLAppearanceMgr(): - mAttachmentInvLinkEnabled(false), - mOutfitIsDirty(false), - mOutfitLocked(false), - mInFlightCounter(0), - mInFlightTimer(), - mIsInUpdateAppearanceFromCOF(false), - //mAppearanceResponder(new RequestAgentUpdateAppearanceResponder), - mHttpRequest(), - mHttpHeaders(), - mHttpOptions(), - mHttpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID), - mHttpPriority(0) -{ - LLAppCoreHttp & app_core_http(LLAppViewer::instance()->getAppCoreHttp()); - - mHttpRequest = LLCore::HttpRequest::ptr_t(new LLCore::HttpRequest()); - mHttpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false); - mHttpOptions = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false); - mHttpPolicy = app_core_http.getPolicy(LLAppCoreHttp::AP_AVATAR); - - LLOutfitObserver& outfit_observer = LLOutfitObserver::instance(); - // unlock outfit on save operation completed - outfit_observer.addCOFSavedCallback(boost::bind( - &LLAppearanceMgr::setOutfitLocked, this, false)); - - mUnlockOutfitTimer.reset(new LLOutfitUnLockTimer(gSavedSettings.getS32( - "OutfitOperationsTimeout"))); - - gIdleCallbacks.addFunction(&LLAttachmentsMgr::onIdle, NULL); - doOnIdleRepeating(boost::bind(&LLAppearanceMgr::onIdle, this)); -} - -LLAppearanceMgr::~LLAppearanceMgr() -{ - mActive = false; -} - -void LLAppearanceMgr::setAttachmentInvLinkEnable(bool val) -{ - LL_DEBUGS("Avatar") << "setAttachmentInvLinkEnable => " << (int) val << LL_ENDL; - mAttachmentInvLinkEnabled = val; -} - -void dumpAttachmentSet(const std::set& atts, const std::string& msg) -{ - LL_INFOS() << msg << LL_ENDL; - for (std::set::const_iterator it = atts.begin(); - it != atts.end(); - ++it) - { - LLUUID item_id = *it; - LLViewerInventoryItem *item = gInventory.getItem(item_id); - if (item) - LL_INFOS() << "atts " << item->getName() << LL_ENDL; - else - LL_INFOS() << "atts " << "UNKNOWN[" << item_id.asString() << "]" << LL_ENDL; - } - LL_INFOS() << LL_ENDL; -} - -void LLAppearanceMgr::registerAttachment(const LLUUID& item_id) -{ - gInventory.addChangedMask(LLInventoryObserver::LABEL, item_id); - - if (mAttachmentInvLinkEnabled) - { - // we have to pass do_update = true to call LLAppearanceMgr::updateAppearanceFromCOF. - // it will trigger gAgentWariables.notifyLoadingFinished() - // But it is not acceptable solution. See EXT-7777 - if (!isLinkedInCOF(item_id)) - { - LLPointer cb = new LLUpdateAppearanceOnDestroy(); - LLAppearanceMgr::addCOFItemLink(item_id, cb); // Add COF link for item. - } - } - else - { - //LL_INFOS() << "no link changes, inv link not enabled" << LL_ENDL; - } -} - -void LLAppearanceMgr::unregisterAttachment(const LLUUID& item_id) -{ - gInventory.addChangedMask(LLInventoryObserver::LABEL, item_id); - - if (mAttachmentInvLinkEnabled) - { - LLAppearanceMgr::removeCOFItemLinks(item_id); - } - else - { - //LL_INFOS() << "no link changes, inv link not enabled" << LL_ENDL; - } -} - -BOOL LLAppearanceMgr::getIsInCOF(const LLUUID& obj_id) const -{ - const LLUUID& cof = getCOF(); - if (obj_id == cof) - return TRUE; - const LLInventoryObject* obj = gInventory.getObject(obj_id); - if (obj && obj->getParentUUID() == cof) - return TRUE; - return FALSE; -} - -// static -bool LLAppearanceMgr::isLinkInCOF(const LLUUID& obj_id) -{ - const LLUUID& target_id = gInventory.getLinkedItemID(obj_id); - LLLinkedItemIDMatches find_links(target_id); - return gInventory.hasMatchingDirectDescendent(LLAppearanceMgr::instance().getCOF(), find_links); -} - -BOOL LLAppearanceMgr::getIsProtectedCOFItem(const LLUUID& obj_id) const -{ - if (!getIsInCOF(obj_id)) return FALSE; - - // If a non-link somehow ended up in COF, allow deletion. - const LLInventoryObject *obj = gInventory.getObject(obj_id); - if (obj && !obj->getIsLinkType()) - { - return FALSE; - } - - // For now, don't allow direct deletion from the COF. Instead, force users - // to choose "Detach" or "Take Off". - return TRUE; -} - -class CallAfterCategoryFetchStage2: public LLInventoryFetchItemsObserver -{ -public: - CallAfterCategoryFetchStage2(const uuid_vec_t& ids, - nullary_func_t callable) : - LLInventoryFetchItemsObserver(ids), - mCallable(callable) - { - } - ~CallAfterCategoryFetchStage2() - { - } - virtual void done() - { - LL_INFOS() << this << " done with incomplete " << mIncomplete.size() - << " complete " << mComplete.size() << " calling callable" << LL_ENDL; - - gInventory.removeObserver(this); - doOnIdleOneTime(mCallable); - delete this; - } -protected: - nullary_func_t mCallable; -}; - -class CallAfterCategoryFetchStage1: public LLInventoryFetchDescendentsObserver -{ -public: - CallAfterCategoryFetchStage1(const LLUUID& cat_id, nullary_func_t callable) : - LLInventoryFetchDescendentsObserver(cat_id), - mCallable(callable) - { - } - ~CallAfterCategoryFetchStage1() - { - } - virtual void done() - { - // What we do here is get the complete information on the - // items in the requested category, and set up an observer - // that will wait for that to happen. - LLInventoryModel::cat_array_t cat_array; - LLInventoryModel::item_array_t item_array; - gInventory.collectDescendents(mComplete.front(), - cat_array, - item_array, - LLInventoryModel::EXCLUDE_TRASH); - S32 count = item_array.size(); - if(!count) - { - LL_WARNS() << "Nothing fetched in category " << mComplete.front() - << LL_ENDL; - gInventory.removeObserver(this); - doOnIdleOneTime(mCallable); - - delete this; - return; - } - - LL_INFOS() << "stage1 got " << item_array.size() << " items, passing to stage2 " << LL_ENDL; - uuid_vec_t ids; - for(S32 i = 0; i < count; ++i) - { - ids.push_back(item_array.at(i)->getUUID()); - } - - gInventory.removeObserver(this); - - // do the fetch - CallAfterCategoryFetchStage2 *stage2 = new CallAfterCategoryFetchStage2(ids, mCallable); - stage2->startFetch(); - if(stage2->isFinished()) - { - // everything is already here - call done. - stage2->done(); - } - else - { - // it's all on it's way - add an observer, and the inventory - // will call done for us when everything is here. - gInventory.addObserver(stage2); - } - delete this; - } -protected: - nullary_func_t mCallable; -}; - -void callAfterCategoryFetch(const LLUUID& cat_id, nullary_func_t cb) -{ - CallAfterCategoryFetchStage1 *stage1 = new CallAfterCategoryFetchStage1(cat_id, cb); - stage1->startFetch(); - if (stage1->isFinished()) - { - stage1->done(); - } - else - { - gInventory.addObserver(stage1); - } -} - -void wear_multiple(const uuid_vec_t& ids, bool replace) -{ - LLPointer cb = new LLUpdateAppearanceOnDestroy; - - bool first = true; - uuid_vec_t::const_iterator it; - for (it = ids.begin(); it != ids.end(); ++it) - { - // if replace is requested, the first item worn will replace the current top - // item, and others will be added. - LLAppearanceMgr::instance().wearItemOnAvatar(*it,false,first && replace,cb); - first = false; - } -} - -// SLapp for easy-wearing of a stock (library) avatar -// -class LLWearFolderHandler : public LLCommandHandler -{ -public: - // not allowed from outside the app - LLWearFolderHandler() : LLCommandHandler("wear_folder", UNTRUSTED_BLOCK) { } - - bool handle(const LLSD& tokens, const LLSD& query_map, - LLMediaCtrl* web) - { - LLSD::UUID folder_uuid; - - if (folder_uuid.isNull() && query_map.has("folder_name")) - { - std::string outfit_folder_name = query_map["folder_name"]; - folder_uuid = findDescendentCategoryIDByName( - gInventory.getLibraryRootFolderID(), - outfit_folder_name); - } - if (folder_uuid.isNull() && query_map.has("folder_id")) - { - folder_uuid = query_map["folder_id"].asUUID(); - } - - if (folder_uuid.notNull()) - { - LLPointer category = new LLInventoryCategory(folder_uuid, - LLUUID::null, - LLFolderType::FT_CLOTHING, - "Quick Appearance"); - if ( gInventory.getCategory( folder_uuid ) != NULL ) - { - LLAppearanceMgr::getInstance()->wearInventoryCategory(category, true, false); - - // *TODOw: This may not be necessary if initial outfit is chosen already -- josh - gAgent.setOutfitChosen(TRUE); - } - } - - // release avatar picker keyboard focus - gFocusMgr.setKeyboardFocus( NULL ); - - return true; - } -}; - -LLWearFolderHandler gWearFolderHandler; + +std::string LLAppearanceMgr::getAppearanceServiceURL() const +{ + if (gSavedSettings.getString("DebugAvatarAppearanceServiceURLOverride").empty()) + { + return mAppearanceServiceURL; + } + return gSavedSettings.getString("DebugAvatarAppearanceServiceURLOverride"); +} + +void show_created_outfit(LLUUID& folder_id, bool show_panel = true) +{ + if (!LLApp::isRunning()) + { + LL_WARNS() << "called during shutdown, skipping" << LL_ENDL; + return; + } + + LL_DEBUGS("Avatar") << "called" << LL_ENDL; + LLSD key; + + //EXT-7727. For new accounts inventory callback is created during login process + // and may be processed after login process is finished + if (show_panel) + { + LL_DEBUGS("Avatar") << "showing panel" << LL_ENDL; + LLFloaterSidePanelContainer::showPanel("appearance", "panel_outfits_inventory", key); + + } + LLOutfitsList *outfits_list = + dynamic_cast(LLFloaterSidePanelContainer::getPanel("appearance", "outfitslist_tab")); + if (outfits_list) + { + outfits_list->setSelectedOutfitByUUID(folder_id); + } + + LLAppearanceMgr::getInstance()->updateIsDirty(); + gAgentWearables.notifyLoadingFinished(); // New outfit is saved. + LLAppearanceMgr::getInstance()->updatePanelOutfitName(""); + + // For SSB, need to update appearance after we add a base outfit + // link, since, the COF version has changed. There is a race + // condition in initial outfit setup which can lead to rez + // failures - SH-3860. + LL_DEBUGS("Avatar") << "requesting appearance update after createBaseOutfitLink" << LL_ENDL; + LLPointer cb = new LLUpdateAppearanceOnDestroy; + LLAppearanceMgr::getInstance()->createBaseOutfitLink(folder_id, cb); +} + +void LLAppearanceMgr::onOutfitFolderCreated(const LLUUID& folder_id, bool show_panel) +{ + LLPointer cb = + new LLBoostFuncInventoryCallback(no_op_inventory_func, + boost::bind(&LLAppearanceMgr::onOutfitFolderCreatedAndClothingOrdered,this,folder_id,show_panel)); + updateClothingOrderingInfo(LLUUID::null, cb); +} + +void LLAppearanceMgr::onOutfitFolderCreatedAndClothingOrdered(const LLUUID& folder_id, bool show_panel) +{ + LLPointer cb = + new LLBoostFuncInventoryCallback(no_op_inventory_func, + boost::bind(show_created_outfit,folder_id,show_panel)); + bool copy_folder_links = false; + slamCategoryLinks(getCOF(), folder_id, copy_folder_links, cb); +} + +void LLAppearanceMgr::makeNewOutfitLinks(const std::string& new_folder_name, bool show_panel) +{ + if (!isAgentAvatarValid()) return; + + LL_DEBUGS("Avatar") << "creating new outfit" << LL_ENDL; + + gAgentWearables.notifyLoadingStarted(); + + // First, make a folder in the My Outfits directory. + const LLUUID parent_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_MY_OUTFITS); + if (AISCommand::isAPIAvailable()) + { + // cap-based category creation was buggy until recently. use + // existence of AIS as an indicator the fix is present. Does + // not actually use AIS to create the category. + inventory_func_type func = boost::bind(&LLAppearanceMgr::onOutfitFolderCreated,this,_1,show_panel); + LLUUID folder_id = gInventory.createNewCategory( + parent_id, + LLFolderType::FT_OUTFIT, + new_folder_name, + func); + } + else + { + LLUUID folder_id = gInventory.createNewCategory( + parent_id, + LLFolderType::FT_OUTFIT, + new_folder_name); + onOutfitFolderCreated(folder_id, show_panel); + } +} + +void LLAppearanceMgr::wearBaseOutfit() +{ + const LLUUID& base_outfit_id = getBaseOutfitUUID(); + if (base_outfit_id.isNull()) return; + + updateCOF(base_outfit_id); +} + +void LLAppearanceMgr::removeItemsFromAvatar(const uuid_vec_t& ids_to_remove) +{ + if (ids_to_remove.empty()) + { + LL_WARNS() << "called with empty list, nothing to do" << LL_ENDL; + return; + } + LLPointer cb = new LLUpdateAppearanceOnDestroy; + for (uuid_vec_t::const_iterator it = ids_to_remove.begin(); it != ids_to_remove.end(); ++it) + { + const LLUUID& id_to_remove = *it; + const LLUUID& linked_item_id = gInventory.getLinkedItemID(id_to_remove); + removeCOFItemLinks(linked_item_id, cb); + addDoomedTempAttachment(linked_item_id); + } +} + +void LLAppearanceMgr::removeItemFromAvatar(const LLUUID& id_to_remove) +{ + LLUUID linked_item_id = gInventory.getLinkedItemID(id_to_remove); + LLPointer cb = new LLUpdateAppearanceOnDestroy; + removeCOFItemLinks(linked_item_id, cb); + addDoomedTempAttachment(linked_item_id); +} + + +// Adds the given item ID to mDoomedTempAttachmentIDs iff it's a temp attachment +void LLAppearanceMgr::addDoomedTempAttachment(const LLUUID& id_to_remove) +{ + LLViewerObject * attachmentp = gAgentAvatarp->findAttachmentByID(id_to_remove); + if (attachmentp && + attachmentp->isTempAttachment()) + { // If this is a temp attachment and we want to remove it, record the ID + // so it will be deleted when attachments are synced up with COF + mDoomedTempAttachmentIDs.insert(id_to_remove); + //LL_INFOS() << "Will remove temp attachment id " << id_to_remove << LL_ENDL; + } +} + +// Find AND REMOVES the given UUID from mDoomedTempAttachmentIDs +bool LLAppearanceMgr::shouldRemoveTempAttachment(const LLUUID& item_id) +{ + doomed_temp_attachments_t::iterator iter = mDoomedTempAttachmentIDs.find(item_id); + if (iter != mDoomedTempAttachmentIDs.end()) + { + mDoomedTempAttachmentIDs.erase(iter); + return true; + } + return false; +} + + +bool LLAppearanceMgr::moveWearable(LLViewerInventoryItem* item, bool closer_to_body) +{ + if (!item || !item->isWearableType()) return false; + if (item->getType() != LLAssetType::AT_CLOTHING) return false; + if (!gInventory.isObjectDescendentOf(item->getUUID(), getCOF())) return false; + + LLInventoryModel::cat_array_t cats; + LLInventoryModel::item_array_t items; + LLFindWearablesOfType filter_wearables_of_type(item->getWearableType()); + gInventory.collectDescendentsIf(getCOF(), cats, items, true, filter_wearables_of_type); + if (items.empty()) return false; + + // We assume that the items have valid descriptions. + std::sort(items.begin(), items.end(), WearablesOrderComparator(item->getWearableType())); + + if (closer_to_body && items.front() == item) return false; + if (!closer_to_body && items.back() == item) return false; + + LLInventoryModel::item_array_t::iterator it = std::find(items.begin(), items.end(), item); + if (items.end() == it) return false; + + + //swapping descriptions + closer_to_body ? --it : ++it; + LLViewerInventoryItem* swap_item = *it; + if (!swap_item) return false; + std::string tmp = swap_item->getActualDescription(); + swap_item->setDescription(item->getActualDescription()); + item->setDescription(tmp); + + // LL_DEBUGS("Inventory") << "swap, item " + // << ll_pretty_print_sd(item->asLLSD()) + // << " swap_item " + // << ll_pretty_print_sd(swap_item->asLLSD()) << LL_ENDL; + + // FIXME switch to use AISv3 where supported. + //items need to be updated on a dataserver + item->setComplete(TRUE); + item->updateServer(FALSE); + gInventory.updateItem(item); + + swap_item->setComplete(TRUE); + swap_item->updateServer(FALSE); + gInventory.updateItem(swap_item); + + //to cause appearance of the agent to be updated + bool result = false; + if ((result = gAgentWearables.moveWearable(item, closer_to_body))) + { + gAgentAvatarp->wearableUpdated(item->getWearableType()); + } + + setOutfitDirty(true); + + //*TODO do we need to notify observers here in such a way? + gInventory.notifyObservers(); + + return result; +} + +//static +void LLAppearanceMgr::sortItemsByActualDescription(LLInventoryModel::item_array_t& items) +{ + if (items.size() < 2) return; + + std::sort(items.begin(), items.end(), sort_by_actual_description); +} + +//#define DUMP_CAT_VERBOSE + +void LLAppearanceMgr::dumpCat(const LLUUID& cat_id, const std::string& msg) +{ + LLInventoryModel::cat_array_t cats; + LLInventoryModel::item_array_t items; + gInventory.collectDescendents(cat_id, cats, items, LLInventoryModel::EXCLUDE_TRASH); + +#ifdef DUMP_CAT_VERBOSE + LL_INFOS() << LL_ENDL; + LL_INFOS() << str << LL_ENDL; + S32 hitcount = 0; + for(S32 i=0; igetName() <getLinkedItem() : NULL; + LLUUID asset_id; + if (linked_item) + { + asset_id = linked_item->getAssetUUID(); + } + LL_DEBUGS("Avatar") << self_av_string() << msg << " " << i <<" " << (item ? item->getName() : "(nullitem)") << " " << asset_id.asString() << LL_ENDL; + } +} + +bool LLAppearanceMgr::mActive = true; + +LLAppearanceMgr::LLAppearanceMgr(): + mAttachmentInvLinkEnabled(false), + mOutfitIsDirty(false), + mOutfitLocked(false), + mInFlightCounter(0), + mInFlightTimer(), + mIsInUpdateAppearanceFromCOF(false), + //mAppearanceResponder(new RequestAgentUpdateAppearanceResponder), + mHttpRequest(), + mHttpHeaders(), + mHttpOptions(), + mHttpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID), + mHttpPriority(0) +{ + LLAppCoreHttp & app_core_http(LLAppViewer::instance()->getAppCoreHttp()); + + mHttpRequest = LLCore::HttpRequest::ptr_t(new LLCore::HttpRequest()); + mHttpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false); + mHttpOptions = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false); + mHttpPolicy = app_core_http.getPolicy(LLAppCoreHttp::AP_AVATAR); + + LLOutfitObserver& outfit_observer = LLOutfitObserver::instance(); + // unlock outfit on save operation completed + outfit_observer.addCOFSavedCallback(boost::bind( + &LLAppearanceMgr::setOutfitLocked, this, false)); + + mUnlockOutfitTimer.reset(new LLOutfitUnLockTimer(gSavedSettings.getS32( + "OutfitOperationsTimeout"))); + + gIdleCallbacks.addFunction(&LLAttachmentsMgr::onIdle, NULL); + doOnIdleRepeating(boost::bind(&LLAppearanceMgr::onIdle, this)); +} + +LLAppearanceMgr::~LLAppearanceMgr() +{ + mActive = false; +} + +void LLAppearanceMgr::setAttachmentInvLinkEnable(bool val) +{ + LL_DEBUGS("Avatar") << "setAttachmentInvLinkEnable => " << (int) val << LL_ENDL; + mAttachmentInvLinkEnabled = val; +} + +void dumpAttachmentSet(const std::set& atts, const std::string& msg) +{ + LL_INFOS() << msg << LL_ENDL; + for (std::set::const_iterator it = atts.begin(); + it != atts.end(); + ++it) + { + LLUUID item_id = *it; + LLViewerInventoryItem *item = gInventory.getItem(item_id); + if (item) + LL_INFOS() << "atts " << item->getName() << LL_ENDL; + else + LL_INFOS() << "atts " << "UNKNOWN[" << item_id.asString() << "]" << LL_ENDL; + } + LL_INFOS() << LL_ENDL; +} + +void LLAppearanceMgr::registerAttachment(const LLUUID& item_id) +{ + gInventory.addChangedMask(LLInventoryObserver::LABEL, item_id); + + if (mAttachmentInvLinkEnabled) + { + // we have to pass do_update = true to call LLAppearanceMgr::updateAppearanceFromCOF. + // it will trigger gAgentWariables.notifyLoadingFinished() + // But it is not acceptable solution. See EXT-7777 + if (!isLinkedInCOF(item_id)) + { + LLPointer cb = new LLUpdateAppearanceOnDestroy(); + LLAppearanceMgr::addCOFItemLink(item_id, cb); // Add COF link for item. + } + } + else + { + //LL_INFOS() << "no link changes, inv link not enabled" << LL_ENDL; + } +} + +void LLAppearanceMgr::unregisterAttachment(const LLUUID& item_id) +{ + gInventory.addChangedMask(LLInventoryObserver::LABEL, item_id); + + if (mAttachmentInvLinkEnabled) + { + LLAppearanceMgr::removeCOFItemLinks(item_id); + } + else + { + //LL_INFOS() << "no link changes, inv link not enabled" << LL_ENDL; + } +} + +BOOL LLAppearanceMgr::getIsInCOF(const LLUUID& obj_id) const +{ + const LLUUID& cof = getCOF(); + if (obj_id == cof) + return TRUE; + const LLInventoryObject* obj = gInventory.getObject(obj_id); + if (obj && obj->getParentUUID() == cof) + return TRUE; + return FALSE; +} + +// static +bool LLAppearanceMgr::isLinkInCOF(const LLUUID& obj_id) +{ + const LLUUID& target_id = gInventory.getLinkedItemID(obj_id); + LLLinkedItemIDMatches find_links(target_id); + return gInventory.hasMatchingDirectDescendent(LLAppearanceMgr::instance().getCOF(), find_links); +} + +BOOL LLAppearanceMgr::getIsProtectedCOFItem(const LLUUID& obj_id) const +{ + if (!getIsInCOF(obj_id)) return FALSE; + + // If a non-link somehow ended up in COF, allow deletion. + const LLInventoryObject *obj = gInventory.getObject(obj_id); + if (obj && !obj->getIsLinkType()) + { + return FALSE; + } + + // For now, don't allow direct deletion from the COF. Instead, force users + // to choose "Detach" or "Take Off". + return TRUE; +} + +class CallAfterCategoryFetchStage2: public LLInventoryFetchItemsObserver +{ +public: + CallAfterCategoryFetchStage2(const uuid_vec_t& ids, + nullary_func_t callable) : + LLInventoryFetchItemsObserver(ids), + mCallable(callable) + { + } + ~CallAfterCategoryFetchStage2() + { + } + virtual void done() + { + LL_INFOS() << this << " done with incomplete " << mIncomplete.size() + << " complete " << mComplete.size() << " calling callable" << LL_ENDL; + + gInventory.removeObserver(this); + doOnIdleOneTime(mCallable); + delete this; + } +protected: + nullary_func_t mCallable; +}; + +class CallAfterCategoryFetchStage1: public LLInventoryFetchDescendentsObserver +{ +public: + CallAfterCategoryFetchStage1(const LLUUID& cat_id, nullary_func_t callable) : + LLInventoryFetchDescendentsObserver(cat_id), + mCallable(callable) + { + } + ~CallAfterCategoryFetchStage1() + { + } + virtual void done() + { + // What we do here is get the complete information on the + // items in the requested category, and set up an observer + // that will wait for that to happen. + LLInventoryModel::cat_array_t cat_array; + LLInventoryModel::item_array_t item_array; + gInventory.collectDescendents(mComplete.front(), + cat_array, + item_array, + LLInventoryModel::EXCLUDE_TRASH); + S32 count = item_array.size(); + if(!count) + { + LL_WARNS() << "Nothing fetched in category " << mComplete.front() + << LL_ENDL; + gInventory.removeObserver(this); + doOnIdleOneTime(mCallable); + + delete this; + return; + } + + LL_INFOS() << "stage1 got " << item_array.size() << " items, passing to stage2 " << LL_ENDL; + uuid_vec_t ids; + for(S32 i = 0; i < count; ++i) + { + ids.push_back(item_array.at(i)->getUUID()); + } + + gInventory.removeObserver(this); + + // do the fetch + CallAfterCategoryFetchStage2 *stage2 = new CallAfterCategoryFetchStage2(ids, mCallable); + stage2->startFetch(); + if(stage2->isFinished()) + { + // everything is already here - call done. + stage2->done(); + } + else + { + // it's all on it's way - add an observer, and the inventory + // will call done for us when everything is here. + gInventory.addObserver(stage2); + } + delete this; + } +protected: + nullary_func_t mCallable; +}; + +void callAfterCategoryFetch(const LLUUID& cat_id, nullary_func_t cb) +{ + CallAfterCategoryFetchStage1 *stage1 = new CallAfterCategoryFetchStage1(cat_id, cb); + stage1->startFetch(); + if (stage1->isFinished()) + { + stage1->done(); + } + else + { + gInventory.addObserver(stage1); + } +} + +void wear_multiple(const uuid_vec_t& ids, bool replace) +{ + LLPointer cb = new LLUpdateAppearanceOnDestroy; + + bool first = true; + uuid_vec_t::const_iterator it; + for (it = ids.begin(); it != ids.end(); ++it) + { + // if replace is requested, the first item worn will replace the current top + // item, and others will be added. + LLAppearanceMgr::instance().wearItemOnAvatar(*it,false,first && replace,cb); + first = false; + } +} + +// SLapp for easy-wearing of a stock (library) avatar +// +class LLWearFolderHandler : public LLCommandHandler +{ +public: + // not allowed from outside the app + LLWearFolderHandler() : LLCommandHandler("wear_folder", UNTRUSTED_BLOCK) { } + + bool handle(const LLSD& tokens, const LLSD& query_map, + LLMediaCtrl* web) + { + LLSD::UUID folder_uuid; + + if (folder_uuid.isNull() && query_map.has("folder_name")) + { + std::string outfit_folder_name = query_map["folder_name"]; + folder_uuid = findDescendentCategoryIDByName( + gInventory.getLibraryRootFolderID(), + outfit_folder_name); + } + if (folder_uuid.isNull() && query_map.has("folder_id")) + { + folder_uuid = query_map["folder_id"].asUUID(); + } + + if (folder_uuid.notNull()) + { + LLPointer category = new LLInventoryCategory(folder_uuid, + LLUUID::null, + LLFolderType::FT_CLOTHING, + "Quick Appearance"); + if ( gInventory.getCategory( folder_uuid ) != NULL ) + { + LLAppearanceMgr::getInstance()->wearInventoryCategory(category, true, false); + + // *TODOw: This may not be necessary if initial outfit is chosen already -- josh + gAgent.setOutfitChosen(TRUE); + } + } + + // release avatar picker keyboard focus + gFocusMgr.setKeyboardFocus( NULL ); + + return true; + } +}; + +LLWearFolderHandler gWearFolderHandler; diff --git a/indra/newview/llappearancemgr.h b/indra/newview/llappearancemgr.h index 707b8d5a77..b90ef65f95 100755 --- a/indra/newview/llappearancemgr.h +++ b/indra/newview/llappearancemgr.h @@ -34,7 +34,6 @@ #include "llinventorymodel.h" #include "llinventoryobserver.h" #include "llviewerinventory.h" -#include "llhttpclient.h" class LLWearableHoldingPattern; class LLInventoryCallback; @@ -218,10 +217,10 @@ public: bool testCOFRequestVersion() const; - void decrementInFlightCounter() - { - mInFlightCounter = llmax(mInFlightCounter - 1, 0); - } + void decrementInFlightCounter() + { + mInFlightCounter = llmax(mInFlightCounter - 1, 0); + } private: @@ -263,9 +262,9 @@ private: * to avoid unsynchronized outfit state or performing duplicate operations. */ bool mOutfitLocked; - S32 mInFlightCounter; - LLTimer mInFlightTimer; - static bool mActive; + S32 mInFlightCounter; + LLTimer mInFlightTimer; + static bool mActive; std::auto_ptr mUnlockOutfitTimer; -- cgit v1.2.3 From 97b93179692b764aba7eee571f1b557f6f8070db Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 26 Mar 2015 13:32:09 -0700 Subject: Create trivial handler for SD Messages, method in LLAgent for posting HTTP requests. --- indra/llmessage/llhttpsdhandler.cpp | 21 +++++++++++++++++++++ indra/llmessage/llhttpsdhandler.h | 20 +++++++++++++++++++- indra/newview/llagent.cpp | 35 +++++++++++++++++++++++++++-------- indra/newview/llagent.h | 15 +++++++++++++++ indra/newview/llappcorehttp.cpp | 6 +++--- indra/newview/llappcorehttp.h | 2 +- indra/newview/llappearancemgr.cpp | 3 ++- 7 files changed, 88 insertions(+), 14 deletions(-) (limited to 'indra') diff --git a/indra/llmessage/llhttpsdhandler.cpp b/indra/llmessage/llhttpsdhandler.cpp index 18daf443ee..0d385d6497 100644 --- a/indra/llmessage/llhttpsdhandler.cpp +++ b/indra/llmessage/llhttpsdhandler.cpp @@ -82,3 +82,24 @@ void LLHttpSDHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRespons delete this; } +//======================================================================== +LLHttpSDGenericHandler::LLHttpSDGenericHandler(const LLURI &uri, const std::string &caps) : + LLHttpSDHandler(uri), + mCaps(caps) +{ +} + +void LLHttpSDGenericHandler::onSuccess(LLCore::HttpResponse * response, LLSD &content) +{ + LL_DEBUGS() << mCaps << " Success." << LL_ENDL; +} + +void LLHttpSDGenericHandler::onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status) +{ + LL_WARNS() + << "\n--------------------------------------------------------------------------\n" + << mCaps << " Error[" << status.toULong() << "] cannot access cap with url '" + << getUri() << "' because " << status.toString() + << "\n--------------------------------------------------------------------------" + << LL_ENDL; +} diff --git a/indra/llmessage/llhttpsdhandler.h b/indra/llmessage/llhttpsdhandler.h index 7b7da61b3c..b3eb7d6145 100644 --- a/indra/llmessage/llhttpsdhandler.h +++ b/indra/llmessage/llhttpsdhandler.h @@ -30,8 +30,12 @@ #include "httphandler.h" #include "lluri.h" +/// Handler class LLCore's HTTP library. Splitting with separate success and +/// failure routines and parsing the result body into LLSD on success. It +/// is intended to be subclassed for specific capability handling. /// -/// +// *TODO: This class self deletes at the end of onCompleted method. This is +// less than ideal and should be revisited. class LLHttpSDHandler : public LLCore::HttpHandler { public: @@ -52,5 +56,19 @@ private: LLURI mUri; }; +/// A trivial implementation of LLHttpSDHandler. This success and failure +/// methods log the action taken, the URI accessed and the status code retuned +/// in the response. +class LLHttpSDGenericHandler : public LLHttpSDHandler +{ +public: + LLHttpSDGenericHandler(const LLURI &uri, const std::string &action); + +protected: + virtual void onSuccess(LLCore::HttpResponse * response, LLSD &content); + virtual void onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status); +private: + std::string mCaps; +}; #endif \ No newline at end of file diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index ff0e2c42c1..81387fb927 100755 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -472,7 +472,7 @@ void LLAgent::init() mHttpRequest = LLCore::HttpRequest::ptr_t(new LLCore::HttpRequest()); mHttpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false); mHttpOptions = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false); - mHttpPolicy = app_core_http.getPolicy(LLAppCoreHttp::AP_AVATAR); + mHttpPolicy = app_core_http.getPolicy(LLAppCoreHttp::AP_AGENT); doOnIdleRepeating(boost::bind(&LLAgent::onIdle, this)); @@ -2563,7 +2563,7 @@ protected: virtual void onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status); private: - U8 LLMaturityHttpHandler::parseMaturityFromServerResponse(const LLSD &pContent) const; + U8 parseMaturityFromServerResponse(const LLSD &pContent) const; LLAgent * mAgent; U8 mPreferredMaturity; @@ -2774,20 +2774,39 @@ void LLAgent::sendMaturityPreferenceToServer(U8 pPreferredMaturity) LL_INFOS() << "Sending viewer preferred maturity to '" << LLViewerRegion::accessToString(pPreferredMaturity) << "' via capability to: " << url << LL_ENDL; - LLCore::HttpHandle handle = LLCoreHttpUtil::requestPostWithLLSD(mHttpRequest, - mHttpPolicy, mHttpPriority, url, - postData, mHttpOptions, mHttpHeaders, handler); + LLCore::HttpHandle handle = requestPostCapibility("UpdateAgentInformation", url, postData, handler); if (handle == LLCORE_HTTP_HANDLE_INVALID) { delete handler; - LLCore::HttpStatus status = mHttpRequest->getStatus(); - LL_WARNS("Avatar") << "Maturity request post failed Reason " << status.toTerseString() - << " \"" << status.toString() << "\"" << LL_ENDL; + LL_WARNS("Avatar") << "Maturity request post failed." << LL_ENDL; } } } +LLCore::HttpHandle LLAgent::requestPostCapibility(const std::string &cap, const std::string &url, LLSD &postData, LLHttpSDHandler *usrhndlr) +{ + LLHttpSDHandler * handler = (usrhndlr) ? usrhndlr : new LLHttpSDGenericHandler(url, cap); + LLCore::HttpHandle handle = LLCoreHttpUtil::requestPostWithLLSD(mHttpRequest, + mHttpPolicy, mHttpPriority, url, + postData, mHttpOptions, mHttpHeaders, handler); + + if (handle == LLCORE_HTTP_HANDLE_INVALID) + { + if (!usrhndlr) + delete handler; + LLCore::HttpStatus status = mHttpRequest->getStatus(); + LL_WARNS("Avatar") << "'" << 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) +//{ +//} + + BOOL LLAgent::getAdminOverride() const { return mAgentAccess->getAdminOverride(); diff --git a/indra/newview/llagent.h b/indra/newview/llagent.h index 278e4c0fa1..6b636a2dc0 100755 --- a/indra/newview/llagent.h +++ b/indra/newview/llagent.h @@ -63,6 +63,7 @@ class LLSLURL; class LLPauseRequestHandle; class LLUIColor; class LLTeleportRequest; +class LLHttpSDHandler; typedef boost::shared_ptr LLTeleportRequestPtr; @@ -917,6 +918,20 @@ public: ** ** *******************************************************************************/ +/******************************************************************************** + ** ** + ** UTILITY + **/ +public: + /// Utilities for allowing the the agent sub managers to post and get via + /// HTTP using the agent's policy settings and headers. + LLCore::HttpHandle requestPostCapibility(const std::string &cap, const std::string &url, LLSD &postData, LLHttpSDHandler *usrhndlr = NULL); + //LLCore::HttpHandle httpGetCapibility(const std::string &cap, const LLURI &uri, LLHttpSDHandler *usrhndlr = NULL); + +/** Utility + ** ** + *******************************************************************************/ + /******************************************************************************** ** ** ** DEBUGGING diff --git a/indra/newview/llappcorehttp.cpp b/indra/newview/llappcorehttp.cpp index 8da78a45a6..cd9166f7b7 100755 --- a/indra/newview/llappcorehttp.cpp +++ b/indra/newview/llappcorehttp.cpp @@ -103,10 +103,10 @@ static const struct "RenderMaterials", "material manager requests" }, - { // AP_AVATAR + { // AP_AGENT 2, 1, 32, 0, true, - "Avatar", - "Avatar requests" + "Agent", + "Agent requests" } }; diff --git a/indra/newview/llappcorehttp.h b/indra/newview/llappcorehttp.h index 95b56100a6..410d7c6b07 100755 --- a/indra/newview/llappcorehttp.h +++ b/indra/newview/llappcorehttp.h @@ -185,7 +185,7 @@ public: /// Concurrency: mid /// Request rate: low /// Pipelined: yes - AP_AVATAR, + AP_AGENT, AP_COUNT // Must be last }; diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp index bb4228dbb2..ae758609ab 100755 --- a/indra/newview/llappearancemgr.cpp +++ b/indra/newview/llappearancemgr.cpp @@ -3442,6 +3442,7 @@ void LLAppearanceMgr::requestServerAppearanceUpdate() llassert(cof_version >= gAgentAvatarp->mLastUpdateRequestCOFVersion); gAgentAvatarp->mLastUpdateRequestCOFVersion = cof_version; + // *TODO: use the unified call in LLAgent (?) LLCore::HttpHandle handle = LLCoreHttpUtil::requestPostWithLLSD(mHttpRequest, mHttpPolicy, mHttpPriority, url, postData, mHttpOptions, mHttpHeaders, handler); @@ -3778,7 +3779,7 @@ LLAppearanceMgr::LLAppearanceMgr(): mHttpRequest = LLCore::HttpRequest::ptr_t(new LLCore::HttpRequest()); mHttpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false); mHttpOptions = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false); - mHttpPolicy = app_core_http.getPolicy(LLAppCoreHttp::AP_AVATAR); + mHttpPolicy = app_core_http.getPolicy(LLAppCoreHttp::AP_AGENT); LLOutfitObserver& outfit_observer = LLOutfitObserver::instance(); // unlock outfit on save operation completed -- cgit v1.2.3 From b9e80807091aa7a27f1a10a23dd32bbb292d9dfb Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 26 Mar 2015 16:41:16 -0700 Subject: Adding llagentlanguage to new LLCore::Http code moved some of llappearancemgr handling into llAgent. --- indra/newview/llagentlanguage.cpp | 8 +++++++- indra/newview/llappearancemgr.cpp | 33 +++------------------------------ indra/newview/llappearancemgr.h | 8 -------- 3 files changed, 10 insertions(+), 39 deletions(-) (limited to 'indra') diff --git a/indra/newview/llagentlanguage.cpp b/indra/newview/llagentlanguage.cpp index fe6236a32a..81fce9b257 100755 --- a/indra/newview/llagentlanguage.cpp +++ b/indra/newview/llagentlanguage.cpp @@ -32,6 +32,7 @@ #include "llviewerregion.h" // library includes #include "llui.h" // getLanguage() +#include "httpcommon.h" // static void LLAgentLanguage::init() @@ -69,7 +70,12 @@ bool LLAgentLanguage::update() body["language"] = language; body["language_is_public"] = gSavedSettings.getBOOL("LanguageIsPublic"); - LLHTTPClient::post(url, body, new LLHTTPClient::Responder); + //LLHTTPClient::post(url, body, new LLHTTPClient::Responder); + LLCore::HttpHandle handle = gAgent.requestPostCapibility("UpdateAgentLanguage", url, body); + if (handle == LLCORE_HTTP_HANDLE_INVALID) + { + LL_WARNS() << "Unable to change language." << LL_ENDL; + } } return true; } diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp index ae758609ab..be71c430f4 100755 --- a/indra/newview/llappearancemgr.cpp +++ b/indra/newview/llappearancemgr.cpp @@ -3442,17 +3442,12 @@ void LLAppearanceMgr::requestServerAppearanceUpdate() llassert(cof_version >= gAgentAvatarp->mLastUpdateRequestCOFVersion); gAgentAvatarp->mLastUpdateRequestCOFVersion = cof_version; - // *TODO: use the unified call in LLAgent (?) - LLCore::HttpHandle handle = LLCoreHttpUtil::requestPostWithLLSD(mHttpRequest, - mHttpPolicy, mHttpPriority, url, - postData, mHttpOptions, mHttpHeaders, handler); + + LLCore::HttpHandle handle = gAgent.requestPostCapibility("UpdateAvatarAppearance", url, postData, handler); if (handle == LLCORE_HTTP_HANDLE_INVALID) { delete handler; - LLCore::HttpStatus status = mHttpRequest->getStatus(); - LL_WARNS("Avatar") << "Appearance request post failed Reason " << status.toTerseString() - << " \"" << status.toString() << "\"" << LL_ENDL; } } @@ -3486,14 +3481,6 @@ bool LLAppearanceMgr::testCOFRequestVersion() const return true; } -bool LLAppearanceMgr::onIdle() -{ - if (!LLAppearanceMgr::mActive) - return true; - mHttpRequest->update(0L); - return false; -} - std::string LLAppearanceMgr::getAppearanceServiceURL() const { if (gSavedSettings.getString("DebugAvatarAppearanceServiceURLOverride").empty()) @@ -3766,21 +3753,8 @@ LLAppearanceMgr::LLAppearanceMgr(): mOutfitLocked(false), mInFlightCounter(0), mInFlightTimer(), - mIsInUpdateAppearanceFromCOF(false), - //mAppearanceResponder(new RequestAgentUpdateAppearanceResponder), - mHttpRequest(), - mHttpHeaders(), - mHttpOptions(), - mHttpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID), - mHttpPriority(0) + mIsInUpdateAppearanceFromCOF(false) { - LLAppCoreHttp & app_core_http(LLAppViewer::instance()->getAppCoreHttp()); - - mHttpRequest = LLCore::HttpRequest::ptr_t(new LLCore::HttpRequest()); - mHttpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false); - mHttpOptions = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false); - mHttpPolicy = app_core_http.getPolicy(LLAppCoreHttp::AP_AGENT); - LLOutfitObserver& outfit_observer = LLOutfitObserver::instance(); // unlock outfit on save operation completed outfit_observer.addCOFSavedCallback(boost::bind( @@ -3790,7 +3764,6 @@ LLAppearanceMgr::LLAppearanceMgr(): "OutfitOperationsTimeout"))); gIdleCallbacks.addFunction(&LLAttachmentsMgr::onIdle, NULL); - doOnIdleRepeating(boost::bind(&LLAppearanceMgr::onIdle, this)); } LLAppearanceMgr::~LLAppearanceMgr() diff --git a/indra/newview/llappearancemgr.h b/indra/newview/llappearancemgr.h index b90ef65f95..760a0bc6ef 100755 --- a/indra/newview/llappearancemgr.h +++ b/indra/newview/llappearancemgr.h @@ -226,12 +226,6 @@ public: private: std::string mAppearanceServiceURL; - LLCore::HttpRequest::ptr_t mHttpRequest; - LLCore::HttpHeaders::ptr_t mHttpHeaders; - LLCore::HttpOptions::ptr_t mHttpOptions; - LLCore::HttpRequest::policy_t mHttpPolicy; - LLCore::HttpRequest::priority_t mHttpPriority; - protected: LLAppearanceMgr(); ~LLAppearanceMgr(); @@ -251,8 +245,6 @@ private: static void onOutfitRename(const LLSD& notification, const LLSD& response); - bool onIdle(); - bool mAttachmentInvLinkEnabled; bool mOutfitIsDirty; bool mIsInUpdateAppearanceFromCOF; // to detect recursive calls. -- cgit v1.2.3 From 735364038767694ea29d9b6a168410e6482cc9c2 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 27 Mar 2015 17:00:02 -0700 Subject: first set of chnages from code review from Nat --- indra/llcorehttp/_httpoprequest.cpp | 10 +- indra/llcorehttp/_httpoprequest.h | 5 +- indra/llcorehttp/_httppolicyglobal.cpp | 4 +- indra/llcorehttp/_httppolicyglobal.h | 6 +- indra/llcorehttp/_httpservice.cpp | 4 +- indra/llcorehttp/_httpservice.h | 6 +- indra/llcorehttp/httpcommon.h | 75 +++++++------- indra/llcorehttp/httpoptions.cpp | 8 +- indra/llcorehttp/httpoptions.h | 90 ++++++++++------- indra/llcorehttp/httprequest.cpp | 10 +- indra/llcorehttp/httprequest.h | 4 +- indra/llmessage/llhttpsdhandler.cpp | 2 +- indra/llmessage/llhttpsdhandler.h | 4 +- indra/newview/llagent.cpp | 11 ++- indra/newview/llagent.h | 4 +- indra/newview/llagentlanguage.cpp | 2 +- indra/newview/llappcorehttp.cpp | 2 +- indra/newview/llappearancemgr.cpp | 6 +- indra/newview/llavatarrenderinfoaccountant.cpp | 131 ++++++++++++++++++++++++- indra/newview/llavatarrenderinfoaccountant.h | 10 +- indra/newview/llmaterialmgr.cpp | 4 +- 21 files changed, 271 insertions(+), 127 deletions(-) (limited to 'indra') diff --git a/indra/llcorehttp/_httpoprequest.cpp b/indra/llcorehttp/_httpoprequest.cpp index 48e22468cd..5768fe5a90 100755 --- a/indra/llcorehttp/_httpoprequest.cpp +++ b/indra/llcorehttp/_httpoprequest.cpp @@ -115,9 +115,8 @@ namespace LLCore { -HttpOpRequest::HttpOpRequest(HttpRequest const * const request) +HttpOpRequest::HttpOpRequest() : HttpOperation(), - mRequest(request), mProcFlags(0U), mReqMethod(HOR_GET), mReqBody(NULL), @@ -490,13 +489,13 @@ HttpStatus HttpOpRequest::prepareRequest(HttpService * service) long follow_redirect(1L); long sslPeerV(0L); long sslHostV(0L); - long dnsCacheTimeout(15L); + long dnsCacheTimeout(-1L); if (mReqOptions) { follow_redirect = mReqOptions->getFollowRedirects() ? 1L : 0L; - sslPeerV = mReqOptions->getSSLVerifyHost() ? 0L : 1L; - sslHostV = mReqOptions->getSSLVerifyHost(); + sslPeerV = mReqOptions->getSSLVerifyPeer() ? 1L : 0L; + sslHostV = mReqOptions->getSSLVerifyHost() ? 2L : 0L; dnsCacheTimeout = mReqOptions->getDNSCacheTimeout(); } code = curl_easy_setopt(mCurlHandle, CURLOPT_FOLLOWLOCATION, follow_redirect); @@ -516,7 +515,6 @@ HttpStatus HttpOpRequest::prepareRequest(HttpService * service) code = curl_easy_setopt(mCurlHandle, CURLOPT_DNS_CACHE_TIMEOUT, dnsCacheTimeout); check_curl_easy_code(code, CURLOPT_DNS_CACHE_TIMEOUT); - if (gpolicy.mUseLLProxy) { // Use the viewer-based thread-safe API which has a diff --git a/indra/llcorehttp/_httpoprequest.h b/indra/llcorehttp/_httpoprequest.h index 7a4b7c189e..e71d1d1edf 100755 --- a/indra/llcorehttp/_httpoprequest.h +++ b/indra/llcorehttp/_httpoprequest.h @@ -66,7 +66,7 @@ class HttpOptions; class HttpOpRequest : public HttpOperation { public: - HttpOpRequest(HttpRequest const * const request); + HttpOpRequest(); protected: virtual ~HttpOpRequest(); // Use release() @@ -165,11 +165,10 @@ protected: static const unsigned int PF_SAVE_HEADERS = 0x00000002U; static const unsigned int PF_USE_RETRY_AFTER = 0x00000004U; - HttpRequest::policyCallback mCallbackSSLVerify; + HttpRequest::policyCallback_t mCallbackSSLVerify; public: // Request data - HttpRequest const * const mRequest; EMethod mReqMethod; std::string mReqURL; BufferArray * mReqBody; diff --git a/indra/llcorehttp/_httppolicyglobal.cpp b/indra/llcorehttp/_httppolicyglobal.cpp index c4ef38a815..3d0df96ade 100755 --- a/indra/llcorehttp/_httppolicyglobal.cpp +++ b/indra/llcorehttp/_httppolicyglobal.cpp @@ -106,7 +106,7 @@ HttpStatus HttpPolicyGlobal::set(HttpRequest::EPolicyOption opt, const std::stri return HttpStatus(); } -HttpStatus HttpPolicyGlobal::set(HttpRequest::EPolicyOption opt, HttpRequest::policyCallback value) +HttpStatus HttpPolicyGlobal::set(HttpRequest::EPolicyOption opt, HttpRequest::policyCallback_t value) { switch (opt) { @@ -169,7 +169,7 @@ HttpStatus HttpPolicyGlobal::get(HttpRequest::EPolicyOption opt, std::string * v } -HttpStatus HttpPolicyGlobal::get(HttpRequest::EPolicyOption opt, HttpRequest::policyCallback * value) const +HttpStatus HttpPolicyGlobal::get(HttpRequest::EPolicyOption opt, HttpRequest::policyCallback_t * value) const { switch (opt) { diff --git a/indra/llcorehttp/_httppolicyglobal.h b/indra/llcorehttp/_httppolicyglobal.h index 1696238814..e02da4386a 100755 --- a/indra/llcorehttp/_httppolicyglobal.h +++ b/indra/llcorehttp/_httppolicyglobal.h @@ -60,10 +60,10 @@ private: public: HttpStatus set(HttpRequest::EPolicyOption opt, long value); HttpStatus set(HttpRequest::EPolicyOption opt, const std::string & value); - HttpStatus set(HttpRequest::EPolicyOption opt, HttpRequest::policyCallback value); + HttpStatus set(HttpRequest::EPolicyOption opt, HttpRequest::policyCallback_t value); HttpStatus get(HttpRequest::EPolicyOption opt, long * value) const; HttpStatus get(HttpRequest::EPolicyOption opt, std::string * value) const; - HttpStatus get(HttpRequest::EPolicyOption opt, HttpRequest::policyCallback * value) const; + HttpStatus get(HttpRequest::EPolicyOption opt, HttpRequest::policyCallback_t * value) const; public: long mConnectionLimit; @@ -72,7 +72,7 @@ public: std::string mHttpProxy; long mTrace; long mUseLLProxy; - HttpRequest::policyCallback mSslCtxCallback; + HttpRequest::policyCallback_t mSslCtxCallback; }; // end class HttpPolicyGlobal } // end namespace LLCore diff --git a/indra/llcorehttp/_httpservice.cpp b/indra/llcorehttp/_httpservice.cpp index 7b8aac35a8..252db78c89 100755 --- a/indra/llcorehttp/_httpservice.cpp +++ b/indra/llcorehttp/_httpservice.cpp @@ -415,7 +415,7 @@ HttpStatus HttpService::getPolicyOption(HttpRequest::EPolicyOption opt, HttpRequ } HttpStatus HttpService::getPolicyOption(HttpRequest::EPolicyOption opt, HttpRequest::policy_t pclass, - HttpRequest::policyCallback * ret_value) + HttpRequest::policyCallback_t * ret_value) { HttpStatus status(HttpStatus::LLCORE, LLCore::HE_INVALID_ARG); @@ -520,7 +520,7 @@ HttpStatus HttpService::setPolicyOption(HttpRequest::EPolicyOption opt, HttpRequ } HttpStatus HttpService::setPolicyOption(HttpRequest::EPolicyOption opt, HttpRequest::policy_t pclass, - HttpRequest::policyCallback value, HttpRequest::policyCallback * ret_value) + HttpRequest::policyCallback_t value, HttpRequest::policyCallback_t * ret_value) { HttpStatus status(HttpStatus::LLCORE, LLCore::HE_INVALID_ARG); diff --git a/indra/llcorehttp/_httpservice.h b/indra/llcorehttp/_httpservice.h index 699a8eaa4f..ac518a5de7 100755 --- a/indra/llcorehttp/_httpservice.h +++ b/indra/llcorehttp/_httpservice.h @@ -209,15 +209,15 @@ protected: HttpStatus getPolicyOption(HttpRequest::EPolicyOption opt, HttpRequest::policy_t, std::string * ret_value); HttpStatus getPolicyOption(HttpRequest::EPolicyOption opt, HttpRequest::policy_t, - HttpRequest::policyCallback * ret_value); + HttpRequest::policyCallback_t * ret_value); HttpStatus setPolicyOption(HttpRequest::EPolicyOption opt, HttpRequest::policy_t, long value, long * ret_value); HttpStatus setPolicyOption(HttpRequest::EPolicyOption opt, HttpRequest::policy_t, const std::string & value, std::string * ret_value); HttpStatus setPolicyOption(HttpRequest::EPolicyOption opt, HttpRequest::policy_t, - HttpRequest::policyCallback value, - HttpRequest::policyCallback * ret_value); + HttpRequest::policyCallback_t value, + HttpRequest::policyCallback_t * ret_value); protected: static const OptionDescriptor sOptionDesc[HttpRequest::PO_LAST]; diff --git a/indra/llcorehttp/httpcommon.h b/indra/llcorehttp/httpcommon.h index 64075f5f20..ada5c1bbe7 100755 --- a/indra/llcorehttp/httpcommon.h +++ b/indra/llcorehttp/httpcommon.h @@ -190,6 +190,7 @@ #include "linden_common.h" // Modifies curl/curl.h interfaces #include "boost/intrusive_ptr.hpp" #include "boost/shared_ptr.hpp" +#include "boost/function.hpp" #include namespace LLCore @@ -294,50 +295,50 @@ struct HttpStatus typedef unsigned short type_enum_t; HttpStatus() - { - mDetails = new Details(LLCORE, HE_SUCCESS); - } + { + mDetails = boost::shared_ptr
(new Details(LLCORE, HE_SUCCESS)); + } HttpStatus(type_enum_t type, short status) - { - mDetails = new Details(type, status); - } + { + mDetails = boost::shared_ptr
(new Details(type, status)); + } HttpStatus(int http_status) - { - mDetails = new Details(http_status, - (http_status >= 200 && http_status <= 299) ? HE_SUCCESS : HE_REPLY_ERROR); - llassert(http_status >= 100 && http_status <= 999); - } + { + mDetails = boost::shared_ptr
(new Details(http_status, + (http_status >= 200 && http_status <= 299) ? HE_SUCCESS : HE_REPLY_ERROR)); + llassert(http_status >= 100 && http_status <= 999); + } HttpStatus(int http_status, const std::string &message) - { - mDetails = new Details(http_status, - (http_status >= 200 && http_status <= 299) ? HE_SUCCESS : HE_REPLY_ERROR); - llassert(http_status >= 100 && http_status <= 999); - mDetails->mMessage = message; - } + { + mDetails = boost::shared_ptr
(new Details(http_status, + (http_status >= 200 && http_status <= 299) ? HE_SUCCESS : HE_REPLY_ERROR)); + llassert(http_status >= 100 && http_status <= 999); + mDetails->mMessage = message; + } HttpStatus(const HttpStatus & rhs) - { - mDetails = new Details(*rhs.mDetails); - } + { + mDetails = rhs.mDetails; + } ~HttpStatus() - { - delete mDetails; - } + { + } HttpStatus & operator=(const HttpStatus & rhs) - { - // Don't care if lhs & rhs are the same object - mDetails->mType = rhs.mDetails->mType; - mDetails->mStatus = rhs.mDetails->mStatus; - mDetails->mMessage = rhs.mDetails->mMessage; - mDetails->mErrorData = rhs.mDetails->mErrorData; - - return *this; - } + { + mDetails = rhs.mDetails; + return *this; + } + + HttpStatus & clone(const HttpStatus &rhs) + { + mDetails = boost::shared_ptr
(new Details(*rhs.mDetails)); + return *this; + } static const type_enum_t EXT_CURL_EASY = 0; ///< mStatus is an error from a curl_easy_*() call static const type_enum_t EXT_CURL_MULTI = 1; ///< mStatus is an error from a curl_multi_*() call @@ -365,8 +366,7 @@ struct HttpStatus /// which will do the wrong thing in conditional expressions. bool operator==(const HttpStatus & rhs) const { - return (mDetails->mType == rhs.mDetails->mType) && - (mDetails->mStatus == rhs.mDetails->mStatus); + return (*mDetails == *rhs.mDetails); } bool operator!=(const HttpStatus & rhs) const @@ -474,6 +474,10 @@ private: mErrorData(rhs.mErrorData) {} + bool operator == (const Details &rhs) const + { + return (mType == rhs.mType) && (mStatus == rhs.mStatus); + } type_enum_t mType; short mStatus; @@ -481,8 +485,7 @@ private: void * mErrorData; }; - //boost::unique_ptr
mDetails; - Details * mDetails; + boost::shared_ptr
mDetails; }; // end struct HttpStatus diff --git a/indra/llcorehttp/httpoptions.cpp b/indra/llcorehttp/httpoptions.cpp index 28c2c25e92..a4d08a80df 100755 --- a/indra/llcorehttp/httpoptions.cpp +++ b/indra/llcorehttp/httpoptions.cpp @@ -42,8 +42,8 @@ HttpOptions::HttpOptions() : RefCounted(true), mUseRetryAfter(HTTP_USE_RETRY_AFTER_DEFAULT), mFollowRedirects(false), mVerifyPeer(false), - mVerifyHost(0), - mDNSCacheTimeout(15) + mVerifyHost(false), + mDNSCacheTimeout(-1L) {} @@ -95,9 +95,9 @@ void HttpOptions::setSSLVerifyPeer(bool verify) mVerifyPeer = verify; } -void HttpOptions::setSSLVerifyHost(unsigned int type) +void HttpOptions::setSSLVerifyHost(bool verify) { - mVerifyHost = llclamp(type, 0, 2); + mVerifyHost = verify; } void HttpOptions::setDNSCacheTimeout(int timeout) diff --git a/indra/llcorehttp/httpoptions.h b/indra/llcorehttp/httpoptions.h index 3b9ad9598b..765d2431bb 100755 --- a/indra/llcorehttp/httpoptions.h +++ b/indra/llcorehttp/httpoptions.h @@ -69,72 +69,86 @@ protected: void operator=(const HttpOptions &); // Not defined public: + // Default: false void setWantHeaders(bool wanted); bool getWantHeaders() const - { - return mWantHeaders; - } + { + return mWantHeaders; + } // Default: 0 void setTrace(int long); int getTrace() const - { - return mTracing; - } + { + return mTracing; + } // Default: 30 void setTimeout(unsigned int timeout); unsigned int getTimeout() const - { - return mTimeout; - } + { + return mTimeout; + } // Default: 0 void setTransferTimeout(unsigned int timeout); unsigned int getTransferTimeout() const - { - return mTransferTimeout; - } + { + return mTransferTimeout; + } + /// Sets the number of retries on an LLCore::HTTPRequest before the + /// request fails. // Default: 8 void setRetries(unsigned int retries); unsigned int getRetries() const - { - return mRetries; - } + { + return mRetries; + } // Default: true void setUseRetryAfter(bool use_retry); bool getUseRetryAfter() const - { - return mUseRetryAfter; - } + { + return mUseRetryAfter; + } - // Default: false + /// Instructs the LLCore::HTTPRequest to follow redirects + /// Default: false void setFollowRedirects(bool follow_redirect); bool getFollowRedirects() const - { - return mFollowRedirects; - } - - void setSSLVerifyPeer(bool verify); + { + return mFollowRedirects; + } + + /// Instructs the LLCore::HTTPRequest to verify that the exchanged security + /// certificate is authentic. + /// Default: false + void setSSLVerifyPeer(bool verify); bool getSSLVerifyPeer() const - { - return mVerifyPeer; - } - - void setSSLVerifyHost(unsigned int type); - unsigned int getSSLVerifyHost() const - { - return mVerifyHost; - } - + { + return mVerifyPeer; + } + + /// Instructs the LLCore::HTTPRequest to verify that the name in the + /// security certificate matches the name of the host contacted. + /// Default: false + void setSSLVerifyHost(bool verify); + bool getSSLVerifyHost() const + { + return mVerifyHost; + } + + /// Sets the time for DNS name caching in seconds. Setting this value + /// to 0 will disable name caching. Setting this value to -1 causes the + /// name cache to never time out. + /// Default: -1 void setDNSCacheTimeout(int timeout); int getDNSCacheTimeout() const - { - return mDNSCacheTimeout; - } + { + return mDNSCacheTimeout; + } protected: bool mWantHeaders; @@ -145,7 +159,7 @@ protected: bool mUseRetryAfter; bool mFollowRedirects; bool mVerifyPeer; - unsigned int mVerifyHost; + bool mVerifyHost; int mDNSCacheTimeout; }; // end class HttpOptions diff --git a/indra/llcorehttp/httprequest.cpp b/indra/llcorehttp/httprequest.cpp index 5f1ed3d43b..df8502b947 100755 --- a/indra/llcorehttp/httprequest.cpp +++ b/indra/llcorehttp/httprequest.cpp @@ -117,7 +117,7 @@ HttpStatus HttpRequest::setStaticPolicyOption(EPolicyOption opt, policy_t pclass return HttpService::instanceOf()->setPolicyOption(opt, pclass, value, ret_value); } -HttpStatus HttpRequest::setStaticPolicyOption(EPolicyOption opt, policy_t pclass, policyCallback value, policyCallback * ret_value) +HttpStatus HttpRequest::setStaticPolicyOption(EPolicyOption opt, policy_t pclass, policyCallback_t value, policyCallback_t * ret_value) { if (HttpService::RUNNING == HttpService::instanceOf()->getState()) { @@ -204,7 +204,7 @@ HttpHandle HttpRequest::requestGet(policy_t policy_id, HttpStatus status; HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); - HttpOpRequest * op = new HttpOpRequest(this); + HttpOpRequest * op = new HttpOpRequest(); if (! (status = op->setupGet(policy_id, priority, url, options, headers))) { op->release(); @@ -238,7 +238,7 @@ HttpHandle HttpRequest::requestGetByteRange(policy_t policy_id, HttpStatus status; HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); - HttpOpRequest * op = new HttpOpRequest(this); + HttpOpRequest * op = new HttpOpRequest(); if (! (status = op->setupGetByteRange(policy_id, priority, url, offset, len, options, headers))) { op->release(); @@ -271,7 +271,7 @@ HttpHandle HttpRequest::requestPost(policy_t policy_id, HttpStatus status; HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); - HttpOpRequest * op = new HttpOpRequest(this); + HttpOpRequest * op = new HttpOpRequest(); if (! (status = op->setupPost(policy_id, priority, url, body, options, headers))) { op->release(); @@ -304,7 +304,7 @@ HttpHandle HttpRequest::requestPut(policy_t policy_id, HttpStatus status; HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); - HttpOpRequest * op = new HttpOpRequest(this); + HttpOpRequest * op = new HttpOpRequest(); if (! (status = op->setupPut(policy_id, priority, url, body, options, headers))) { op->release(); diff --git a/indra/llcorehttp/httprequest.h b/indra/llcorehttp/httprequest.h index 4cacb3a20b..f7ce82d412 100755 --- a/indra/llcorehttp/httprequest.h +++ b/indra/llcorehttp/httprequest.h @@ -237,7 +237,7 @@ public: /// Prototype for policy based callbacks. The callback methods will be executed /// on the worker thread so no modifications should be made to the HttpHandler object. - typedef HttpStatus(*policyCallback)(const std::string &, HttpHandler const * const, void *); + typedef boost::function policyCallback_t; /// Set a policy option for a global or class parameter at /// startup time (prior to thread start). @@ -255,7 +255,7 @@ public: static HttpStatus setStaticPolicyOption(EPolicyOption opt, policy_t pclass, const std::string & value, std::string * ret_value); static HttpStatus setStaticPolicyOption(EPolicyOption opt, policy_t pclass, - policyCallback value, policyCallback * ret_value);; + policyCallback_t value, policyCallback_t * ret_value);; /// Set a parameter on a class-based policy option. Calls /// made after the start of the servicing thread are diff --git a/indra/llmessage/llhttpsdhandler.cpp b/indra/llmessage/llhttpsdhandler.cpp index 0d385d6497..72ecfe77e2 100644 --- a/indra/llmessage/llhttpsdhandler.cpp +++ b/indra/llmessage/llhttpsdhandler.cpp @@ -89,7 +89,7 @@ LLHttpSDGenericHandler::LLHttpSDGenericHandler(const LLURI &uri, const std::stri { } -void LLHttpSDGenericHandler::onSuccess(LLCore::HttpResponse * response, LLSD &content) +void LLHttpSDGenericHandler::onSuccess(LLCore::HttpResponse * response, const LLSD &content) { LL_DEBUGS() << mCaps << " Success." << LL_ENDL; } diff --git a/indra/llmessage/llhttpsdhandler.h b/indra/llmessage/llhttpsdhandler.h index b3eb7d6145..a2598c9709 100644 --- a/indra/llmessage/llhttpsdhandler.h +++ b/indra/llmessage/llhttpsdhandler.h @@ -49,7 +49,7 @@ public: } protected: - virtual void onSuccess(LLCore::HttpResponse * response, LLSD &content) = 0; + virtual void onSuccess(LLCore::HttpResponse * response, const LLSD &content) = 0; virtual void onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status) = 0; private: @@ -65,7 +65,7 @@ public: LLHttpSDGenericHandler(const LLURI &uri, const std::string &action); protected: - virtual void onSuccess(LLCore::HttpResponse * response, LLSD &content); + virtual void onSuccess(LLCore::HttpResponse * response, const LLSD &content); virtual void onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status); private: diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index 81387fb927..667d530e39 100755 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -2559,7 +2559,7 @@ public: { } protected: - virtual void onSuccess(LLCore::HttpResponse * response, LLSD &content); + virtual void onSuccess(LLCore::HttpResponse * response, const LLSD &content); virtual void onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status); private: @@ -2572,7 +2572,7 @@ private: }; //------------------------------------------------------------------------- -void LLMaturityHttpHandler::onSuccess(LLCore::HttpResponse * response, LLSD &content) +void LLMaturityHttpHandler::onSuccess(LLCore::HttpResponse * response, const LLSD &content) { U8 actualMaturity = parseMaturityFromServerResponse(content); @@ -2774,7 +2774,7 @@ void LLAgent::sendMaturityPreferenceToServer(U8 pPreferredMaturity) LL_INFOS() << "Sending viewer preferred maturity to '" << LLViewerRegion::accessToString(pPreferredMaturity) << "' via capability to: " << url << LL_ENDL; - LLCore::HttpHandle handle = requestPostCapibility("UpdateAgentInformation", url, postData, handler); + LLCore::HttpHandle handle = requestPostCapability("UpdateAgentInformation", url, postData, handler); if (handle == LLCORE_HTTP_HANDLE_INVALID) { @@ -2784,7 +2784,7 @@ void LLAgent::sendMaturityPreferenceToServer(U8 pPreferredMaturity) } } -LLCore::HttpHandle LLAgent::requestPostCapibility(const std::string &cap, const std::string &url, LLSD &postData, LLHttpSDHandler *usrhndlr) +LLCore::HttpHandle LLAgent::requestPostCapability(const std::string &cap, const std::string &url, LLSD &postData, LLHttpSDHandler *usrhndlr) { LLHttpSDHandler * handler = (usrhndlr) ? usrhndlr : new LLHttpSDGenericHandler(url, cap); LLCore::HttpHandle handle = LLCoreHttpUtil::requestPostWithLLSD(mHttpRequest, @@ -2793,6 +2793,9 @@ LLCore::HttpHandle LLAgent::requestPostCapibility(const std::string &cap, const 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(); diff --git a/indra/newview/llagent.h b/indra/newview/llagent.h index 6b636a2dc0..26120b52f6 100755 --- a/indra/newview/llagent.h +++ b/indra/newview/llagent.h @@ -925,8 +925,8 @@ public: public: /// Utilities for allowing the the agent sub managers to post and get via /// HTTP using the agent's policy settings and headers. - LLCore::HttpHandle requestPostCapibility(const std::string &cap, const std::string &url, LLSD &postData, LLHttpSDHandler *usrhndlr = NULL); - //LLCore::HttpHandle httpGetCapibility(const std::string &cap, const LLURI &uri, LLHttpSDHandler *usrhndlr = NULL); + 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); /** Utility ** ** diff --git a/indra/newview/llagentlanguage.cpp b/indra/newview/llagentlanguage.cpp index 81fce9b257..f2ac323578 100755 --- a/indra/newview/llagentlanguage.cpp +++ b/indra/newview/llagentlanguage.cpp @@ -71,7 +71,7 @@ bool LLAgentLanguage::update() body["language_is_public"] = gSavedSettings.getBOOL("LanguageIsPublic"); //LLHTTPClient::post(url, body, new LLHTTPClient::Responder); - LLCore::HttpHandle handle = gAgent.requestPostCapibility("UpdateAgentLanguage", url, body); + LLCore::HttpHandle handle = gAgent.requestPostCapability("UpdateAgentLanguage", url, body); if (handle == LLCORE_HTTP_HANDLE_INVALID) { LL_WARNS() << "Unable to change language." << LL_ENDL; diff --git a/indra/newview/llappcorehttp.cpp b/indra/newview/llappcorehttp.cpp index cd9166f7b7..51cca273d8 100755 --- a/indra/newview/llappcorehttp.cpp +++ b/indra/newview/llappcorehttp.cpp @@ -494,7 +494,7 @@ LLCore::HttpStatus LLAppCoreHttp::sslVerify(const std::string &url, validation_params[CERT_HOSTNAME] = uri.hostName(); - // *TODO*: In the case of an exception while validating the cert, we need a way + // *TODO: In the case of an exception while validating the cert, we need a way // to pass the offending(?) cert back out. *Rider* try diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp index be71c430f4..709d9881e1 100755 --- a/indra/newview/llappearancemgr.cpp +++ b/indra/newview/llappearancemgr.cpp @@ -1260,7 +1260,7 @@ public: virtual void onCompleted(LLCore::HttpHandle handle, LLCore::HttpResponse * response); protected: - virtual void onSuccess(LLCore::HttpResponse * response, LLSD &content); + virtual void onSuccess(LLCore::HttpResponse * response, const LLSD &content); virtual void onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status); private: @@ -1278,7 +1278,7 @@ void LLAppearanceMgrHttpHandler::onCompleted(LLCore::HttpHandle handle, LLCore:: LLHttpSDHandler::onCompleted(handle, response); } -void LLAppearanceMgrHttpHandler::onSuccess(LLCore::HttpResponse * response, LLSD &content) +void LLAppearanceMgrHttpHandler::onSuccess(LLCore::HttpResponse * response, const LLSD &content) { if (!content.isMap()) { @@ -3443,7 +3443,7 @@ void LLAppearanceMgr::requestServerAppearanceUpdate() gAgentAvatarp->mLastUpdateRequestCOFVersion = cof_version; - LLCore::HttpHandle handle = gAgent.requestPostCapibility("UpdateAvatarAppearance", url, postData, handler); + LLCore::HttpHandle handle = gAgent.requestPostCapability("UpdateAvatarAppearance", url, postData, handler); if (handle == LLCORE_HTTP_HANDLE_INVALID) { diff --git a/indra/newview/llavatarrenderinfoaccountant.cpp b/indra/newview/llavatarrenderinfoaccountant.cpp index 38e153137c..aeaa832bc7 100644 --- a/indra/newview/llavatarrenderinfoaccountant.cpp +++ b/indra/newview/llavatarrenderinfoaccountant.cpp @@ -43,7 +43,9 @@ #include "llviewerregion.h" #include "llvoavatar.h" #include "llworld.h" - +#include "llhttpsdhandler.h" +#include "httpheaders.h" +#include "httpoptions.h" static const std::string KEY_AGENTS = "agents"; // map static const std::string KEY_WEIGHT = "weight"; // integer @@ -55,8 +57,113 @@ static const std::string KEY_ERROR = "error"; // Send data updates about once per minute, only need per-frame resolution LLFrameTimer LLAvatarRenderInfoAccountant::sRenderInfoReportTimer; +//LLCore::HttpRequest::ptr_t LLAvatarRenderInfoAccountant::sHttpRequest; + +#if 0 +//========================================================================= +class LLAvatarRenderInfoHandler : public LLHttpSDHandler +{ +public: + LLAvatarRenderInfoHandler(const LLURI &uri, U64 regionHandle); + +protected: + virtual void onSuccess(LLCore::HttpResponse * response, LLSD &content); + virtual void onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status); + +private: + U64 mRegionHandle; +}; + +LLAvatarRenderInfoHandler::LLAvatarRenderInfoHandler(const LLURI &uri, U64 regionHandle) : + LLHttpSDHandler(uri), + mRegionHandle(regionHandle) +{ +} + +void LLAvatarRenderInfoHandler::onSuccess(LLCore::HttpResponse * response, LLSD &content) +{ + LLViewerRegion * regionp = LLWorld::getInstance()->getRegionFromHandle(mRegionHandle); + if (regionp) + { + if (LLAvatarRenderInfoAccountant::logRenderInfo()) + { + LL_INFOS() << "LRI: Result for avatar weights request for region " << regionp->getName() << ":" << LL_ENDL; + } + + if (content.isMap()) + { + if (content.has(KEY_AGENTS)) + { + const LLSD & agents = content[KEY_AGENTS]; + if (agents.isMap()) + { + LLSD::map_const_iterator report_iter = agents.beginMap(); + while (report_iter != agents.endMap()) + { + LLUUID target_agent_id = LLUUID(report_iter->first); + const LLSD & agent_info_map = report_iter->second; + LLViewerObject* avatarp = gObjectList.findObject(target_agent_id); + if (avatarp && + avatarp->isAvatar() && + agent_info_map.isMap()) + { // Extract the data for this avatar + + if (LLAvatarRenderInfoAccountant::logRenderInfo()) + { + LL_INFOS() << "LRI: Agent " << target_agent_id + << ": " << agent_info_map << LL_ENDL; + } + + if (agent_info_map.has(KEY_WEIGHT)) + { + ((LLVOAvatar *)avatarp)->setReportedVisualComplexity(agent_info_map[KEY_WEIGHT].asInteger()); + } + } + report_iter++; + } + } + } // has "agents" + else if (content.has(KEY_ERROR)) + { + const LLSD & error = content[KEY_ERROR]; + LL_WARNS() << "Avatar render info GET error: " + << error[KEY_IDENTIFIER] + << ": " << error[KEY_MESSAGE] + << " from region " << regionp->getName() + << LL_ENDL; + } + } + } + else + { + LL_INFOS() << "Avatar render weight info received but region not found for " + << mRegionHandle << LL_ENDL; + } +} +void LLAvatarRenderInfoHandler::onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status) +{ + LLViewerRegion * regionp = LLWorld::getInstance()->getRegionFromHandle(mRegionHandle); + if (regionp) + { + LL_WARNS() << "HTTP error result for avatar weight GET: " << status.toULong() + << ", " << status.toString() + << " returned by region " << regionp->getName() + << LL_ENDL; + } + else + { + LL_WARNS() << "Avatar render weight GET error received but region not found for " + << mRegionHandle + << ", error " << status.toULong() + << ", " << status.toString() + << LL_ENDL; + } +} + +//------------------------------------------------------------------------- +#else // HTTP responder class for GET request for avatar render weight information class LLAvatarRenderInfoGetResponder : public LLHTTPClient::Responder { @@ -142,7 +249,7 @@ public: } else { - LL_INFOS() << "Avatar render weight info recieved but region not found for " + LL_INFOS() << "Avatar render weight info received but region not found for " << mRegionHandle << LL_ENDL; } } @@ -150,7 +257,7 @@ public: private: U64 mRegionHandle; }; - +#endif // HTTP responder class for POST request for avatar render weight information class LLAvatarRenderInfoPostResponder : public LLHTTPClient::Responder @@ -172,7 +279,7 @@ public: } else { - LL_WARNS() << "Avatar render weight POST error recieved but region not found for " + LL_WARNS() << "Avatar render weight POST error received but region not found for " << mRegionHandle << ", error " << statusNum << ", " << reason @@ -215,7 +322,6 @@ private: U64 mRegionHandle; }; - // static // Send request for one region, no timer checks void LLAvatarRenderInfoAccountant::sendRenderInfoToRegion(LLViewerRegion * regionp) @@ -292,7 +398,19 @@ void LLAvatarRenderInfoAccountant::getRenderInfoFromRegion(LLViewerRegion * regi } // First send a request to get the latest data +#if 0 + if (!LLAvatarRenderInfoAccountant::sHttpRequest) + sHttpRequest = LLCore::HttpRequest::ptr_t(new LLCore::HttpRequest()); + LLAppCoreHttp & app_core_http(LLAppViewer::instance()->getAppCoreHttp()); + + LLCore::HttpHeaders::ptr_t httpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false); + LLCore::HttpOptions::ptr_t httpOptions = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false); + LLCore::HttpRequest::policy_t httpPolicy = app_core_http.getPolicy(LLAppCoreHttp::AP_AGENT); + + LLCore::HttpHandle handle = sHttpRequest-> +#else LLHTTPClient::get(url, new LLAvatarRenderInfoGetResponder(regionp->getHandle())); +#endif } } @@ -301,6 +419,9 @@ void LLAvatarRenderInfoAccountant::getRenderInfoFromRegion(LLViewerRegion * regi // Called every frame - send render weight requests to every region void LLAvatarRenderInfoAccountant::idle() { +// if (!LLAvatarRenderInfoAccountant::sHttpRequest) +// sHttpRequest = LLCore::HttpRequest::ptr_t(new LLCore::HttpRequest()); + if (sRenderInfoReportTimer.hasExpired()) { const F32 SECS_BETWEEN_REGION_SCANS = 5.f; // Scan the region list every 5 seconds diff --git a/indra/newview/llavatarrenderinfoaccountant.h b/indra/newview/llavatarrenderinfoaccountant.h index d68f2dccfb..13054f5e2f 100644 --- a/indra/newview/llavatarrenderinfoaccountant.h +++ b/indra/newview/llavatarrenderinfoaccountant.h @@ -29,6 +29,8 @@ #if ! defined(LL_llavatarrenderinfoaccountant_H) #define LL_llavatarrenderinfoaccountant_H +#include "httpcommon.h" + class LLViewerRegion; // Class to gather avatar rendering information @@ -36,8 +38,6 @@ class LLViewerRegion; class LLAvatarRenderInfoAccountant { public: - LLAvatarRenderInfoAccountant() {}; - ~LLAvatarRenderInfoAccountant() {}; static void sendRenderInfoToRegion(LLViewerRegion * regionp); static void getRenderInfoFromRegion(LLViewerRegion * regionp); @@ -49,8 +49,14 @@ public: static bool logRenderInfo(); private: + LLAvatarRenderInfoAccountant() {}; + ~LLAvatarRenderInfoAccountant() {}; + // Send data updates about once per minute, only need per-frame resolution static LLFrameTimer sRenderInfoReportTimer; + +// static LLCore::HttpRequest::ptr_t sHttpRequest; + }; #endif /* ! defined(LL_llavatarrenderinfoaccountant_H) */ diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index 065d763596..78fbe9af0a 100755 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -75,7 +75,7 @@ public: virtual ~LLMaterialHttpHandler(); protected: - virtual void onSuccess(LLCore::HttpResponse * response, LLSD &content); + virtual void onSuccess(LLCore::HttpResponse * response, const LLSD &content); virtual void onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status); private: @@ -95,7 +95,7 @@ LLMaterialHttpHandler::~LLMaterialHttpHandler() { } -void LLMaterialHttpHandler::onSuccess(LLCore::HttpResponse * response, LLSD &content) +void LLMaterialHttpHandler::onSuccess(LLCore::HttpResponse * response, const LLSD &content) { LL_DEBUGS("Materials") << LL_ENDL; mCallback(true, content); -- cgit v1.2.3 From 0b02b36b651987d5d24c225fa9472e0d35803559 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 27 Mar 2015 17:38:00 -0700 Subject: Remove test for size of HttpStatus --- indra/llcorehttp/tests/test_httpstatus.hpp | 36 +++++++++++++++--------------- 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'indra') diff --git a/indra/llcorehttp/tests/test_httpstatus.hpp b/indra/llcorehttp/tests/test_httpstatus.hpp index 5f8ed14c51..4502d32fe1 100755 --- a/indra/llcorehttp/tests/test_httpstatus.hpp +++ b/indra/llcorehttp/tests/test_httpstatus.hpp @@ -83,21 +83,21 @@ void HttpStatusTestObjectType::test<1>() } -template <> template <> -void HttpStatusTestObjectType::test<2>() -{ - set_test_name("HttpStatus memory structure"); - - // Require that an HttpStatus object can be trivially - // returned as a function return value in registers. - // One should fit in an int on all platforms. - - ensure(sizeof(HttpStatus) <= sizeof(int)); -} +// template <> template <> +// void HttpStatusTestObjectType::test<2>() +// { +// set_test_name("HttpStatus memory structure"); +// +// // Require that an HttpStatus object can be trivially +// // returned as a function return value in registers. +// // One should fit in an int on all platforms. +// +// //ensure(sizeof(HttpStatus) <= sizeof(int)); +// } template <> template <> -void HttpStatusTestObjectType::test<3>() +void HttpStatusTestObjectType::test<2>() { set_test_name("HttpStatus valid status string conversion"); @@ -124,7 +124,7 @@ void HttpStatusTestObjectType::test<3>() template <> template <> -void HttpStatusTestObjectType::test<4>() +void HttpStatusTestObjectType::test<3>() { set_test_name("HttpStatus invalid status string conversion"); @@ -145,7 +145,7 @@ void HttpStatusTestObjectType::test<4>() } template <> template <> -void HttpStatusTestObjectType::test<5>() +void HttpStatusTestObjectType::test<4>() { set_test_name("HttpStatus equality/inequality testing"); @@ -164,7 +164,7 @@ void HttpStatusTestObjectType::test<5>() } template <> template <> -void HttpStatusTestObjectType::test<6>() +void HttpStatusTestObjectType::test<5>() { set_test_name("HttpStatus basic HTTP status encoding"); @@ -205,7 +205,7 @@ void HttpStatusTestObjectType::test<6>() } template <> template <> -void HttpStatusTestObjectType::test<7>() +void HttpStatusTestObjectType::test<6>() { set_test_name("HttpStatus HTTP status text strings"); @@ -237,7 +237,7 @@ void HttpStatusTestObjectType::test<7>() template <> template <> -void HttpStatusTestObjectType::test<8>() +void HttpStatusTestObjectType::test<7>() { set_test_name("HttpStatus toHex() nominal function"); @@ -249,7 +249,7 @@ void HttpStatusTestObjectType::test<8>() template <> template <> -void HttpStatusTestObjectType::test<9>() +void HttpStatusTestObjectType::test<8>() { set_test_name("HttpStatus toTerseString() nominal function"); -- cgit v1.2.3 From edc1439bd633bdac183fbecc131edd55074b5442 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 1 Apr 2015 16:37:00 -0700 Subject: Added AvatarNameCache as coroutine, with LLCore::HttpHandler to respond correctly to Event Pumps. Added get/setRequestURL() to LLCore::HttpResponse Removed URI from the HttpSDHandler. --- indra/llcorehttp/_httpoprequest.cpp | 4 +- indra/llcorehttp/httpresponse.cpp | 3 +- indra/llcorehttp/httpresponse.h | 11 ++ indra/llmessage/llavatarnamecache.cpp | 286 +++++++++++++++++++++++----------- indra/llmessage/llavatarnamecache.h | 7 +- indra/llmessage/llcorehttputil.cpp | 96 +++++++++++- indra/llmessage/llcorehttputil.h | 30 ++++ indra/llmessage/llhttpsdhandler.cpp | 12 +- indra/llmessage/llhttpsdhandler.h | 11 +- indra/newview/llagent.cpp | 55 ++++--- indra/newview/llagent.h | 10 +- indra/newview/llappearancemgr.cpp | 8 +- indra/newview/llmaterialmgr.cpp | 14 +- 13 files changed, 405 insertions(+), 142 deletions(-) (limited to 'indra') diff --git a/indra/llcorehttp/_httpoprequest.cpp b/indra/llcorehttp/_httpoprequest.cpp index 5768fe5a90..7c2309b31d 100755 --- a/indra/llcorehttp/_httpoprequest.cpp +++ b/indra/llcorehttp/_httpoprequest.cpp @@ -260,7 +260,9 @@ void HttpOpRequest::visitNotifier(HttpRequest * request) response->setStatus(mStatus); response->setBody(mReplyBody); response->setHeaders(mReplyHeaders); - if (mReplyOffset || mReplyLength) + response->setRequestURL(mReqURL); + + if (mReplyOffset || mReplyLength) { // Got an explicit offset/length in response response->setRange(mReplyOffset, mReplyLength, mReplyFullLength); diff --git a/indra/llcorehttp/httpresponse.cpp b/indra/llcorehttp/httpresponse.cpp index 87e3426415..7d88f02527 100755 --- a/indra/llcorehttp/httpresponse.cpp +++ b/indra/llcorehttp/httpresponse.cpp @@ -41,7 +41,8 @@ HttpResponse::HttpResponse() mBufferArray(NULL), mHeaders(NULL), mRetries(0U), - m503Retries(0U) + m503Retries(0U), + mRequestUrl() {} diff --git a/indra/llcorehttp/httpresponse.h b/indra/llcorehttp/httpresponse.h index 39b582ff85..6c3b4da5e6 100755 --- a/indra/llcorehttp/httpresponse.h +++ b/indra/llcorehttp/httpresponse.h @@ -194,6 +194,16 @@ public: return mStats; } + void setRequestURL(const std::string &url) + { + mRequestUrl = url; + } + + const std::string &getRequestURL() const + { + return mRequestUrl; + } + protected: // Response data here @@ -206,6 +216,7 @@ protected: std::string mContentType; unsigned int mRetries; unsigned int m503Retries; + std::string mRequestUrl; TransferStats::ptr_t mStats; }; diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index d02a60b7b2..88859819e0 100755 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -33,9 +33,18 @@ #include "llhttpclient.h" #include "llsd.h" #include "llsdserialize.h" - +#include "httpresponse.h" +#include "llhttpsdhandler.h" #include +#include "httpcommon.h" +#include "httprequest.h" +#include "httpheaders.h" +#include "httpoptions.h" +#include "llcoros.h" +#include "lleventcoro.h" +#include "llcorehttputil.h" + #include #include @@ -90,6 +99,12 @@ namespace LLAvatarNameCache // Time-to-live for a temp cache entry. const F64 TEMP_CACHE_ENTRY_LIFETIME = 60.0; + LLCore::HttpRequest::ptr_t sHttpRequest; + LLCore::HttpHeaders::ptr_t sHttpHeaders; + LLCore::HttpOptions::ptr_t sHttpOptions; + LLCore::HttpRequest::policy_t sHttpPolicy; + LLCore::HttpRequest::priority_t sHttpPriority; + //----------------------------------------------------------------------- // Internal methods //----------------------------------------------------------------------- @@ -121,7 +136,13 @@ namespace LLAvatarNameCache // Erase expired names from cache void eraseUnrefreshed(); - bool expirationFromCacheControl(const LLSD& headers, F64 *expires); + //bool expirationFromCacheControl(LLCore::HttpHeaders *headers, F64 *expires); + bool expirationFromCacheControl(const LLSD& headers, F64 *expires); + + // This is a coroutine. The only parameter that can be specified as a reference is the self + void requestAvatarNameCache_(LLCoros::self& self, std::string url, std::vector agentIds); + + void handleAvNameCacheSuccess(const LLSD &data, const LLSD &httpResult); } /* Sample response: @@ -163,94 +184,125 @@ namespace LLAvatarNameCache */ -class LLAvatarNameResponder : public LLHTTPClient::Responder +// Coroutine for sending and processing avatar name cache requests. +// Do not call directly. See documentation in lleventcoro.h and llcoro.h for +// further explanation. +void LLAvatarNameCache::requestAvatarNameCache_(LLCoros::self& self, std::string url, std::vector agentIds) { - LOG_CLASS(LLAvatarNameResponder); -private: - // need to store agent ids that are part of this request in case of - // an error, so we can flag them as unavailable - std::vector mAgentIDs; - -public: - LLAvatarNameResponder(const std::vector& agent_ids) - : mAgentIDs(agent_ids) - { } - -protected: - /*virtual*/ void httpSuccess() - { - const LLSD& content = getContent(); - if (!content.isMap()) - { - failureResult(HTTP_INTERNAL_ERROR, "Malformed response contents", content); - return; - } - // Pull expiration out of headers if available - F64 expires = LLAvatarNameCache::nameExpirationFromHeaders(getResponseHeaders()); - F64 now = LLFrameTimer::getTotalSeconds(); + LLEventStream replyPump("NameCacheReply", true); + LLCoreHttpUtil::HttpCoroHandler::ptr_t httpHandler = + LLCoreHttpUtil::HttpCoroHandler::ptr_t(new LLCoreHttpUtil::HttpCoroHandler(replyPump)); - const LLSD& agents = content["agents"]; - LLSD::array_const_iterator it = agents.beginArray(); - for ( ; it != agents.endArray(); ++it) - { - const LLSD& row = *it; - LLUUID agent_id = row["id"].asUUID(); + LL_DEBUGS("AvNameCache") << "Entering coroutine " << LLCoros::instance().getName(self) + << " with url '" << url << "', requesting " << agentIds.size() << " Agent Ids" << LL_ENDL; - LLAvatarName av_name; - av_name.fromLLSD(row); + try + { + bool success = true; - // Use expiration time from header - av_name.mExpires = expires; + LLAvatarNameCache::sHttpRequest->requestGet( + LLAvatarNameCache::sHttpPolicy, LLAvatarNameCache::sHttpPriority, + url, LLAvatarNameCache::sHttpOptions.get(), + LLAvatarNameCache::sHttpHeaders.get(), httpHandler.get()); - LL_DEBUGS("AvNameCache") << "LLAvatarNameResponder::result for " << agent_id << LL_ENDL; - av_name.dump(); - - // cache it and fire signals - LLAvatarNameCache::processName(agent_id, av_name); - } + LLSD results = waitForEventOn(self, replyPump); + LLSD httpResults; - // Same logic as error response case - const LLSD& unresolved_agents = content["bad_ids"]; - S32 num_unresolved = unresolved_agents.size(); - if (num_unresolved > 0) - { - LL_WARNS("AvNameCache") << "LLAvatarNameResponder::result " << num_unresolved << " unresolved ids; " - << "expires in " << expires - now << " seconds" - << LL_ENDL; - it = unresolved_agents.beginArray(); - for ( ; it != unresolved_agents.endArray(); ++it) - { - const LLUUID& agent_id = *it; + LL_DEBUGS() << results << LL_ENDL; - LL_WARNS("AvNameCache") << "LLAvatarNameResponder::result " - << "failed id " << agent_id - << LL_ENDL; + if (!results.isMap()) + { + LL_WARNS("AvNameCache") << " Invalid result returned from LLCoreHttpUtil::HttpCoroHandler." << LL_ENDL; + success = false; + } + else + { + httpResults = results["http_result"]; + success = httpResults["success"].asBoolean(); + if (!success) + { + LL_WARNS("AvNameCache") << "Error result from LLCoreHttpUtil::HttpCoroHandler. Code " + << httpResults["status"] << ": '" << httpResults["message"] << "'" << LL_ENDL; + } + } + if (!success) + { // on any sort of failure add dummy records for any agent IDs + // in this request that we do not have cached already + std::vector::const_iterator it = agentIds.begin(); + for ( ; it != agentIds.end(); ++it) + { + const LLUUID& agent_id = *it; LLAvatarNameCache::handleAgentError(agent_id); - } - } - LL_DEBUGS("AvNameCache") << "LLAvatarNameResponder::result " - << LLAvatarNameCache::sCache.size() << " cached names" - << LL_ENDL; + } + return; + } + + LLAvatarNameCache::handleAvNameCacheSuccess(results, httpResults); + } + catch (std::exception e) + { + LL_WARNS() << "Caught exception '" << e.what() << "'" << LL_ENDL; + } + catch (...) + { + LL_WARNS() << "Caught unknown exception." << LL_ENDL; + } +} - /*virtual*/ void httpFailure() - { - // If there's an error, it might be caused by PeopleApi, - // or when loading textures on startup and using a very slow - // network, this query may time out. - // What we should do depends on whether or not we have a cached name - LL_WARNS("AvNameCache") << dumpResponse() << LL_ENDL; - - // Add dummy records for any agent IDs in this request that we do not have cached already - std::vector::const_iterator it = mAgentIDs.begin(); - for ( ; it != mAgentIDs.end(); ++it) - { - const LLUUID& agent_id = *it; - LLAvatarNameCache::handleAgentError(agent_id); - } - } -}; +void LLAvatarNameCache::handleAvNameCacheSuccess(const LLSD &data, const LLSD &httpResult) +{ + + LLSD headers = httpResult["headers"]; + // Pull expiration out of headers if available + F64 expires = LLAvatarNameCache::nameExpirationFromHeaders(headers); + F64 now = LLFrameTimer::getTotalSeconds(); + + const LLSD& agents = data["agents"]; + LLSD::array_const_iterator it = agents.beginArray(); + for (; it != agents.endArray(); ++it) + { + const LLSD& row = *it; + LLUUID agent_id = row["id"].asUUID(); + + LLAvatarName av_name; + av_name.fromLLSD(row); + + // Use expiration time from header + av_name.mExpires = expires; + + LL_DEBUGS("AvNameCache") << "LLAvatarNameResponder::result for " << agent_id << LL_ENDL; + av_name.dump(); + + // cache it and fire signals + LLAvatarNameCache::processName(agent_id, av_name); + } + + // Same logic as error response case + const LLSD& unresolved_agents = data["bad_ids"]; + S32 num_unresolved = unresolved_agents.size(); + if (num_unresolved > 0) + { + LL_WARNS("AvNameCache") << "LLAvatarNameResponder::result " << num_unresolved << " unresolved ids; " + << "expires in " << expires - now << " seconds" + << LL_ENDL; + it = unresolved_agents.beginArray(); + for (; it != unresolved_agents.endArray(); ++it) + { + const LLUUID& agent_id = *it; + + LL_WARNS("AvNameCache") << "LLAvatarNameResponder::result " + << "failed id " << agent_id + << LL_ENDL; + + LLAvatarNameCache::handleAgentError(agent_id); + } + } + LL_DEBUGS("AvNameCache") << "LLAvatarNameResponder::result " + << LLAvatarNameCache::sCache.size() << " cached names" + << LL_ENDL; +} // Provide some fallback for agents that return errors void LLAvatarNameCache::handleAgentError(const LLUUID& agent_id) @@ -353,12 +405,17 @@ void LLAvatarNameCache::requestNamesViaCapability() } } - if (!url.empty()) - { - LL_DEBUGS("AvNameCache") << "LLAvatarNameCache::requestNamesViaCapability requested " - << ids << " ids" - << LL_ENDL; - LLHTTPClient::get(url, new LLAvatarNameResponder(agent_ids)); + if (!url.empty()) + { + LL_DEBUGS("AvNameCache") << "LLAvatarNameCache::requestNamesViaCapability requested " + << ids << " ids" + << LL_ENDL; + + std::string coroname = + LLCoros::instance().launch("LLAvatarNameCache::requestAvatarNameCache_", + boost::bind(&LLAvatarNameCache::requestAvatarNameCache_, _1, url, agent_ids)); + LL_DEBUGS("AvNameCache") << coroname << " with url '" << url << "', agent_ids.size()=" << agent_ids.size() << LL_ENDL; + } } @@ -422,11 +479,20 @@ void LLAvatarNameCache::initClass(bool running, bool usePeopleAPI) { sRunning = running; sUsePeopleAPI = usePeopleAPI; + + sHttpRequest = LLCore::HttpRequest::ptr_t(new LLCore::HttpRequest()); + sHttpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false); + sHttpOptions = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false); + sHttpPolicy = LLCore::HttpRequest::DEFAULT_POLICY_ID; + sHttpPriority = 0; } void LLAvatarNameCache::cleanupClass() { - sCache.clear(); + sHttpRequest.reset(); + sHttpHeaders.reset(); + sHttpOptions.reset(); + sCache.clear(); } void LLAvatarNameCache::importFile(std::istream& istr) @@ -498,6 +564,8 @@ void LLAvatarNameCache::idle() // By convention, start running at first idle() call sRunning = true; + sHttpRequest->update(0L); + // *TODO: Possibly re-enabled this based on People API load measurements // 100 ms is the threshold for "user speed" operations, so we can // stall for about that long to batch up requests. @@ -697,6 +765,50 @@ void LLAvatarNameCache::insert(const LLUUID& agent_id, const LLAvatarName& av_na sCache[agent_id] = av_name; } +#if 0 +F64 LLAvatarNameCache::nameExpirationFromHeaders(LLCore::HttpHeaders *headers) +{ + F64 expires = 0.0; + if (expirationFromCacheControl(headers, &expires)) + { + return expires; + } + else + { + // With no expiration info, default to an hour + const F64 DEFAULT_EXPIRES = 60.0 * 60.0; + F64 now = LLFrameTimer::getTotalSeconds(); + return now + DEFAULT_EXPIRES; + } +} + +bool LLAvatarNameCache::expirationFromCacheControl(LLCore::HttpHeaders *headers, F64 *expires) +{ + bool fromCacheControl = false; + F64 now = LLFrameTimer::getTotalSeconds(); + + // Allow the header to override the default + const std::string *cache_control; + + cache_control = headers->find(HTTP_IN_HEADER_CACHE_CONTROL); + + if (cache_control && !cache_control->empty()) + { + S32 max_age = 0; + if (max_age_from_cache_control(*cache_control, &max_age)) + { + *expires = now + (F64)max_age; + fromCacheControl = true; + } + } + LL_DEBUGS("AvNameCache") + << ( fromCacheControl ? "expires based on cache control " : "default expiration " ) + << "in " << *expires - now << " seconds" + << LL_ENDL; + + return fromCacheControl; +} +#else F64 LLAvatarNameCache::nameExpirationFromHeaders(const LLSD& headers) { F64 expires = 0.0; @@ -741,7 +853,7 @@ bool LLAvatarNameCache::expirationFromCacheControl(const LLSD& headers, F64 *exp return fromCacheControl; } - +#endif void LLAvatarNameCache::addUseDisplayNamesCallback(const use_display_name_signal_t::slot_type& cb) { diff --git a/indra/llmessage/llavatarnamecache.h b/indra/llmessage/llavatarnamecache.h index ea016b3125..fdfd4e972d 100755 --- a/indra/llmessage/llavatarnamecache.h +++ b/indra/llmessage/llavatarnamecache.h @@ -29,7 +29,8 @@ #define LLAVATARNAMECACHE_H #include "llavatarname.h" // for convenience - +//#include "httpcommon.h" +//#include "httpheaders.h" #include class LLSD; @@ -49,7 +50,7 @@ namespace LLAvatarNameCache void importFile(std::istream& istr); void exportFile(std::ostream& ostr); - // On the viewer, usually a simulator capabilitity. + // On the viewer, usually a simulator capabilities. // If empty, name cache will fall back to using legacy name lookup system. void setNameLookupURL(const std::string& name_lookup_url); @@ -90,7 +91,7 @@ namespace LLAvatarNameCache // Compute name expiration time from HTTP Cache-Control header, // or return default value, in seconds from epoch. - F64 nameExpirationFromHeaders(const LLSD& headers); + F64 nameExpirationFromHeaders(const LLSD& headers); void addUseDisplayNamesCallback(const use_display_name_signal_t::slot_type& cb); } diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index 366a0b9460..991985b1cf 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -30,15 +30,17 @@ #include #include "llcorehttputil.h" +#include "llhttpconstants.h" #include "llsdserialize.h" - using namespace LLCore; namespace LLCoreHttpUtil { + + // *TODO: Currently converts only from XML content. A mode // to convert using fromBinary() might be useful as well. Mesh // headers could use it. @@ -186,5 +188,97 @@ std::string responseToString(LLCore::HttpResponse * response) } +HttpCoroHandler::HttpCoroHandler(LLEventStream &reply) : + mReplyPump(reply) +{ +} + +void HttpCoroHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpResponse * response) +{ + LLSD result; + + LLCore::HttpStatus status = response->getStatus(); + + if (!status) + { + result = LLSD::emptyMap(); + LL_WARNS() + << "\n--------------------------------------------------------------------------\n" + << " Error[" << status.toULong() << "] cannot access url '" << response->getRequestURL() + << "' because " << status.toString() + << "\n--------------------------------------------------------------------------" + << LL_ENDL; + + } + else + { + const bool emit_parse_errors = false; + + bool parsed = !((response->getBodySize() == 0) || + !LLCoreHttpUtil::responseToLLSD(response, emit_parse_errors, result)); + + if (!parsed) + { + // Only emit a warning if we failed to parse when 'content-type' == 'application/llsd+xml' + LLCore::HttpHeaders::ptr_t headers(response->getHeaders()); + const std::string *contentType = (headers) ? headers->find(HTTP_IN_HEADER_CONTENT_TYPE) : NULL; + + if (contentType && (HTTP_CONTENT_LLSD_XML == *contentType)) + { + std::string thebody = LLCoreHttpUtil::responseToString(response); + LL_WARNS() << "Failed to deserialize . " << response->getRequestURL() << " [status:" << response->getStatus().toString() << "] " + << " body: " << thebody << LL_ENDL; + + // Replace the status with a new one indicating the failure. + status = LLCore::HttpStatus(499, "Failed to deserialize LLSD."); + } + } + + if (result.isUndefined()) + { + // If we've gotten to this point and the result LLSD is still undefined + // either there was an issue deserializing the body or the response was + // blank. Create an empty map to hold the result either way. + result = LLSD::emptyMap(); + } + } + + buildStatusEntry(response, status, result); + mReplyPump.post(result); +} + +void HttpCoroHandler::buildStatusEntry(LLCore::HttpResponse *response, LLCore::HttpStatus status, LLSD &result) +{ + LLSD httpresults = LLSD::emptyMap(); + + httpresults["success"] = static_cast(status); + httpresults["type"] = static_cast(status.getType()); + httpresults["status"] = static_cast(status.getStatus()); + httpresults["message"] = static_cast(status.getMessage()); + httpresults["url"] = static_cast(response->getRequestURL()); + + LLSD httpHeaders = LLSD::emptyMap(); + LLCore::HttpHeaders * hdrs = response->getHeaders(); + + if (hdrs) + { + for (LLCore::HttpHeaders::iterator it = hdrs->begin(); it != hdrs->end(); ++it) + { + if (!(*it).second.empty()) + { + httpHeaders[(*it).first] = (*it).second; + } + else + { + httpHeaders[(*it).first] = static_cast(true); + } + } + } + + httpresults["headers"] = httpHeaders; + result["http_result"] = httpresults; +} + + } // end namespace LLCoreHttpUtil diff --git a/indra/llmessage/llcorehttputil.h b/indra/llmessage/llcorehttputil.h index 8e26f413fe..0bc102a0a3 100644 --- a/indra/llmessage/llcorehttputil.h +++ b/indra/llmessage/llcorehttputil.h @@ -39,6 +39,7 @@ #include "bufferarray.h" #include "bufferstream.h" #include "llsd.h" +#include "llevents.h" /// /// The base llcorehttp library implements many HTTP idioms @@ -152,6 +153,35 @@ LLCore::HttpHandle requestPutWithLLSD(LLCore::HttpRequest::ptr_t & request, LLCore::HttpHeaders::ptr_t & headers, LLCore::HttpHandler * handler); +/// The HttpCoroHandler is a specialization of the LLCore::HttpHandler for +/// interacting with coroutines. When the request is completed the response +/// will be posted onto the supplied Event Pump. +/// +/// The LLSD posted back to the coroutine will have the following additions: +/// llsd["http_result"] -+- ["message"] - An error message returned from the HTTP status +/// +- ["status"] - The status code associated with the HTTP call +/// +- ["success"] - Success of failure of the HTTP call and LLSD parsing. +/// +- ["type"] - The LLCore::HttpStatus type associted with the HTTP call +/// +- ["url"] - The URL used to make the call. +/// +- ["headers"] - A map of name name value pairs with the HTTP headers. +/// + +/// +class HttpCoroHandler : public LLCore::HttpHandler +{ +public: + HttpCoroHandler(LLEventStream &reply); + + virtual void onCompleted(LLCore::HttpHandle handle, LLCore::HttpResponse * response); + + typedef boost::shared_ptr ptr_t; + +private: + void buildStatusEntry(LLCore::HttpResponse *response, LLCore::HttpStatus status, LLSD &result); + + LLEventStream &mReplyPump; +}; + } // end namespace LLCoreHttpUtil diff --git a/indra/llmessage/llhttpsdhandler.cpp b/indra/llmessage/llhttpsdhandler.cpp index 72ecfe77e2..159d03b176 100644 --- a/indra/llmessage/llhttpsdhandler.cpp +++ b/indra/llmessage/llhttpsdhandler.cpp @@ -36,10 +36,8 @@ #include "llcorehttputil.h" //======================================================================== -LLHttpSDHandler::LLHttpSDHandler(const LLURI &uri): - mUri(uri) +LLHttpSDHandler::LLHttpSDHandler() { - } void LLHttpSDHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpResponse * response) @@ -68,7 +66,7 @@ void LLHttpSDHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRespons { std::string thebody = LLCoreHttpUtil::responseToString(response); - LL_WARNS() << "Failed to deserialize . " << getUri() << " [status:" << response->getStatus().toString() << "] " + LL_WARNS() << "Failed to deserialize . " << response->getRequestURL() << " [status:" << response->getStatus().toString() << "] " << " body: " << thebody << LL_ENDL; } } @@ -83,8 +81,8 @@ void LLHttpSDHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRespons } //======================================================================== -LLHttpSDGenericHandler::LLHttpSDGenericHandler(const LLURI &uri, const std::string &caps) : - LLHttpSDHandler(uri), +LLHttpSDGenericHandler::LLHttpSDGenericHandler(const std::string &caps) : + LLHttpSDHandler(), mCaps(caps) { } @@ -99,7 +97,7 @@ void LLHttpSDGenericHandler::onFailure(LLCore::HttpResponse * response, LLCore:: LL_WARNS() << "\n--------------------------------------------------------------------------\n" << mCaps << " Error[" << status.toULong() << "] cannot access cap with url '" - << getUri() << "' because " << status.toString() + << response->getRequestURL() << "' because " << status.toString() << "\n--------------------------------------------------------------------------" << LL_ENDL; } diff --git a/indra/llmessage/llhttpsdhandler.h b/indra/llmessage/llhttpsdhandler.h index a2598c9709..7c28dbcab6 100644 --- a/indra/llmessage/llhttpsdhandler.h +++ b/indra/llmessage/llhttpsdhandler.h @@ -39,21 +39,14 @@ class LLHttpSDHandler : public LLCore::HttpHandler { public: - LLHttpSDHandler(const LLURI &uri); + LLHttpSDHandler(); virtual void onCompleted(LLCore::HttpHandle handle, LLCore::HttpResponse * response); - inline const LLURI &getUri() const - { - return mUri; - } - protected: virtual void onSuccess(LLCore::HttpResponse * response, const LLSD &content) = 0; virtual void onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status) = 0; -private: - LLURI mUri; }; /// A trivial implementation of LLHttpSDHandler. This success and failure @@ -62,7 +55,7 @@ private: class LLHttpSDGenericHandler : public LLHttpSDHandler { public: - LLHttpSDGenericHandler(const LLURI &uri, const std::string &action); + LLHttpSDGenericHandler(const std::string &action); protected: virtual void onSuccess(LLCore::HttpResponse * response, const LLSD &content); 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 CallbackFunction; typedef boost::shared_ptr 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) ); -- cgit v1.2.3 From 02b90efa946f20a4699f7ad7a8b3ccfd1bbb8abc Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 2 Apr 2015 09:13:15 -0700 Subject: Adding boost libs and LLCoreHttp to the unit test linkage. --- indra/llmessage/CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/llmessage/CMakeLists.txt b/indra/llmessage/CMakeLists.txt index c5b6024b89..ac6ff7ab64 100755 --- a/indra/llmessage/CMakeLists.txt +++ b/indra/llmessage/CMakeLists.txt @@ -226,7 +226,7 @@ target_link_libraries( llmessage ${CURL_LIBRARIES} ${LLCOMMON_LIBRARIES} - ${LLVFS_LIBRARES} + ${LLVFS_LIBRARIES} ${LLMATH_LIBRARIES} ${CARES_LIBRARIES} ${OPENSSL_LIBRARIES} @@ -247,10 +247,13 @@ if (LL_TESTS) set(test_libs ${CURL_LIBRARIES} ${LLMESSAGE_LIBRARIES} + ${LLCOREHTTP_LIBRARIES} ${WINDOWS_LIBRARIES} ${LLVFS_LIBRARIES} ${LLMATH_LIBRARIES} ${LLCOMMON_LIBRARIES} + ${BOOST_CONTEXT_LIBRARY} + ${BOOST_COROUTINE_LIBRARY} ${GOOGLEMOCK_LIBRARIES} ) -- cgit v1.2.3 From 9d8df53717f00945ae48cda2834b4deb9004efbe Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 2 Apr 2015 13:20:49 -0700 Subject: Adjusting link order --- indra/llmessage/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra') diff --git a/indra/llmessage/CMakeLists.txt b/indra/llmessage/CMakeLists.txt index ac6ff7ab64..4bb99083fe 100755 --- a/indra/llmessage/CMakeLists.txt +++ b/indra/llmessage/CMakeLists.txt @@ -245,13 +245,13 @@ if (LL_TESTS) # set(TEST_DEBUG on) set(test_libs - ${CURL_LIBRARIES} - ${LLMESSAGE_LIBRARIES} ${LLCOREHTTP_LIBRARIES} ${WINDOWS_LIBRARIES} ${LLVFS_LIBRARIES} ${LLMATH_LIBRARIES} ${LLCOMMON_LIBRARIES} + ${LLMESSAGE_LIBRARIES} + ${CURL_LIBRARIES} ${BOOST_CONTEXT_LIBRARY} ${BOOST_COROUTINE_LIBRARY} ${GOOGLEMOCK_LIBRARIES} -- cgit v1.2.3 From 90db0e9943853530c403280a87538e1247e0d356 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 2 Apr 2015 13:56:44 -0700 Subject: More link order --- indra/llmessage/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/llmessage/CMakeLists.txt b/indra/llmessage/CMakeLists.txt index 4bb99083fe..ad732d6194 100755 --- a/indra/llmessage/CMakeLists.txt +++ b/indra/llmessage/CMakeLists.txt @@ -245,12 +245,12 @@ if (LL_TESTS) # set(TEST_DEBUG on) set(test_libs - ${LLCOREHTTP_LIBRARIES} ${WINDOWS_LIBRARIES} ${LLVFS_LIBRARIES} ${LLMATH_LIBRARIES} ${LLCOMMON_LIBRARIES} ${LLMESSAGE_LIBRARIES} + ${LLCOREHTTP_LIBRARIES} ${CURL_LIBRARIES} ${BOOST_CONTEXT_LIBRARY} ${BOOST_COROUTINE_LIBRARY} -- cgit v1.2.3 From e981588845512163bc4efea2bb0ec175d416ae9d Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 2 Apr 2015 14:31:28 -0700 Subject: Move CURL libs up... --- indra/llmessage/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/llmessage/CMakeLists.txt b/indra/llmessage/CMakeLists.txt index ad732d6194..66b710b2f3 100755 --- a/indra/llmessage/CMakeLists.txt +++ b/indra/llmessage/CMakeLists.txt @@ -248,10 +248,10 @@ if (LL_TESTS) ${WINDOWS_LIBRARIES} ${LLVFS_LIBRARIES} ${LLMATH_LIBRARIES} + ${CURL_LIBRARIES} ${LLCOMMON_LIBRARIES} ${LLMESSAGE_LIBRARIES} ${LLCOREHTTP_LIBRARIES} - ${CURL_LIBRARIES} ${BOOST_CONTEXT_LIBRARY} ${BOOST_COROUTINE_LIBRARY} ${GOOGLEMOCK_LIBRARIES} -- cgit v1.2.3 From a3be08057c6a5b424e49c85a21d42ff8fe806815 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 2 Apr 2015 14:48:20 -0700 Subject: Explicitly include LIBRT --- indra/llmessage/CMakeLists.txt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/llmessage/CMakeLists.txt b/indra/llmessage/CMakeLists.txt index 66b710b2f3..ce324cabaa 100755 --- a/indra/llmessage/CMakeLists.txt +++ b/indra/llmessage/CMakeLists.txt @@ -243,7 +243,17 @@ if (LL_TESTS) ) LL_ADD_PROJECT_UNIT_TESTS(llmessage "${llmessage_TEST_SOURCE_FILES}") + # set(TEST_DEBUG on) +if (LINUX) + # llcommon uses `clock_gettime' which is provided by librt on linux. + set(LIBRT_LIBRARY + rt + ) +#else + set (LIBRT_LIBRARY ) +endif (LINUX) + set(test_libs ${WINDOWS_LIBRARIES} ${LLVFS_LIBRARIES} @@ -252,9 +262,10 @@ if (LL_TESTS) ${LLCOMMON_LIBRARIES} ${LLMESSAGE_LIBRARIES} ${LLCOREHTTP_LIBRARIES} + ${LIBRT_LIBRARY} ${BOOST_CONTEXT_LIBRARY} ${BOOST_COROUTINE_LIBRARY} - ${GOOGLEMOCK_LIBRARIES} + ${GOOGLEMOCK_LIBRARIES} ) LL_ADD_INTEGRATION_TEST( -- cgit v1.2.3 From ca6087ea208517cce2e1aea3dd3ed1e191ac1afd Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 2 Apr 2015 15:26:24 -0700 Subject: Move RT aronud --- indra/llmessage/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/llmessage/CMakeLists.txt b/indra/llmessage/CMakeLists.txt index ce324cabaa..56bcf76ee8 100755 --- a/indra/llmessage/CMakeLists.txt +++ b/indra/llmessage/CMakeLists.txt @@ -256,13 +256,13 @@ endif (LINUX) set(test_libs ${WINDOWS_LIBRARIES} + ${LIBRT_LIBRARY} ${LLVFS_LIBRARIES} ${LLMATH_LIBRARIES} ${CURL_LIBRARIES} ${LLCOMMON_LIBRARIES} ${LLMESSAGE_LIBRARIES} ${LLCOREHTTP_LIBRARIES} - ${LIBRT_LIBRARY} ${BOOST_CONTEXT_LIBRARY} ${BOOST_COROUTINE_LIBRARY} ${GOOGLEMOCK_LIBRARIES} -- cgit v1.2.3 From bd69aa7be2aa23c991278c80f1ad6a339a541ff9 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 2 Apr 2015 15:58:24 -0700 Subject: Linux linker order. --- indra/llmessage/CMakeLists.txt | 9 --------- indra/newview/CMakeLists.txt | 6 ++++-- 2 files changed, 4 insertions(+), 11 deletions(-) (limited to 'indra') diff --git a/indra/llmessage/CMakeLists.txt b/indra/llmessage/CMakeLists.txt index 56bcf76ee8..f6ca6a3634 100755 --- a/indra/llmessage/CMakeLists.txt +++ b/indra/llmessage/CMakeLists.txt @@ -245,18 +245,9 @@ if (LL_TESTS) # set(TEST_DEBUG on) -if (LINUX) - # llcommon uses `clock_gettime' which is provided by librt on linux. - set(LIBRT_LIBRARY - rt - ) -#else - set (LIBRT_LIBRARY ) -endif (LINUX) set(test_libs ${WINDOWS_LIBRARIES} - ${LIBRT_LIBRARY} ${LLVFS_LIBRARIES} ${LLMATH_LIBRARIES} ${CURL_LIBRARIES} diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 8c5bc9777c..7a6bf0a5bf 100755 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -2329,15 +2329,17 @@ if (LL_TESTS) ) set(test_libs - ${LLMESSAGE_LIBRARIES} - ${LLCOREHTTP_LIBRARIES} ${WINDOWS_LIBRARIES} ${LLVFS_LIBRARIES} ${LLMATH_LIBRARIES} ${LLCOMMON_LIBRARIES} + ${LLMESSAGE_LIBRARIES} + ${LLCOREHTTP_LIBRARIES} ${GOOGLEMOCK_LIBRARIES} ${OPENSSL_LIBRARIES} ${CRYPTO_LIBRARIES} + ${BOOST_CONTEXT_LIBRARY} + ${BOOST_COROUTINE_LIBRARY} ) LL_ADD_INTEGRATION_TEST(llsechandler_basic -- cgit v1.2.3 From d1db1440802fdd435c58f64ebb0060cab971b16b Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 2 Apr 2015 16:26:08 -0700 Subject: Explicitly call out the RT library for tests in Linux --- indra/newview/CMakeLists.txt | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'indra') diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 7a6bf0a5bf..4fb3537eec 100755 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -2328,8 +2328,16 @@ if (LL_TESTS) "${CMAKE_SOURCE_DIR}/llmessage/tests/test_llsdmessage_peer.py" ) + if (LINUX) + # llcommon uses `clock_gettime' which is provided by librt on linux. + set(LIBRT_LIBRARY + rt + ) + endif (LINUX) + set(test_libs ${WINDOWS_LIBRARIES} + ${LIBRT_LIBRARY} ${LLVFS_LIBRARIES} ${LLMATH_LIBRARIES} ${LLCOMMON_LIBRARIES} -- cgit v1.2.3 From fbd58959c2ac2216fb451bd687558763ceb2ab30 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 2 Apr 2015 16:47:52 -0700 Subject: Ordering --- indra/newview/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 4fb3537eec..bb9238054d 100755 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -2337,7 +2337,6 @@ if (LL_TESTS) set(test_libs ${WINDOWS_LIBRARIES} - ${LIBRT_LIBRARY} ${LLVFS_LIBRARIES} ${LLMATH_LIBRARIES} ${LLCOMMON_LIBRARIES} @@ -2346,6 +2345,7 @@ if (LL_TESTS) ${GOOGLEMOCK_LIBRARIES} ${OPENSSL_LIBRARIES} ${CRYPTO_LIBRARIES} + ${LIBRT_LIBRARY} ${BOOST_CONTEXT_LIBRARY} ${BOOST_COROUTINE_LIBRARY} ) -- cgit v1.2.3 From 17641c8427d05c4cde1fadd2ca059264d89bc818 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 3 Apr 2015 14:23:31 -0700 Subject: Added a class to automate pumping the HttpRequest on the mainloop. Converted AccountingCostManager to use the new LLCore::Http library and coroutines. --- indra/llmessage/llavatarnamecache.h | 2 - indra/llmessage/llcorehttputil.cpp | 21 +++ indra/llmessage/llcorehttputil.h | 18 +- indra/newview/llaccountingcostmanager.cpp | 284 +++++++++++++++++------------- indra/newview/llaccountingcostmanager.h | 15 ++ 5 files changed, 215 insertions(+), 125 deletions(-) (limited to 'indra') diff --git a/indra/llmessage/llavatarnamecache.h b/indra/llmessage/llavatarnamecache.h index fdfd4e972d..17b948f799 100755 --- a/indra/llmessage/llavatarnamecache.h +++ b/indra/llmessage/llavatarnamecache.h @@ -29,8 +29,6 @@ #define LLAVATARNAMECACHE_H #include "llavatarname.h" // for convenience -//#include "httpcommon.h" -//#include "httpheaders.h" #include class LLSD; diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index 991985b1cf..30f5f3d3ed 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -279,6 +279,27 @@ void HttpCoroHandler::buildStatusEntry(LLCore::HttpResponse *response, LLCore::H result["http_result"] = httpresults; } +HttpRequestPumper::HttpRequestPumper(const LLCore::HttpRequest::ptr_t &request): + mHttpRequest(request) +{ + mBoundListener = LLEventPumps::instance().obtain("mainloop"). + listen(LLEventPump::inventName(), boost::bind(&HttpRequestPumper::pollRequest, this, _1)); +} + +HttpRequestPumper::~HttpRequestPumper() +{ + if (mBoundListener.connected()) + { + mBoundListener.disconnect(); + } +} + +bool HttpRequestPumper::pollRequest(const LLSD&) +{ + mHttpRequest->update(0L); + return false; +} + } // end namespace LLCoreHttpUtil diff --git a/indra/llmessage/llcorehttputil.h b/indra/llmessage/llcorehttputil.h index 0bc102a0a3..4ae6e112b3 100644 --- a/indra/llmessage/llcorehttputil.h +++ b/indra/llmessage/llcorehttputil.h @@ -165,8 +165,6 @@ LLCore::HttpHandle requestPutWithLLSD(LLCore::HttpRequest::ptr_t & request, /// +- ["url"] - The URL used to make the call. /// +- ["headers"] - A map of name name value pairs with the HTTP headers. /// - -/// class HttpCoroHandler : public LLCore::HttpHandler { public: @@ -182,6 +180,22 @@ private: LLEventStream &mReplyPump; }; +/// The HttpRequestPumper is a utility class. When constructed it will poll the +/// supplied HttpRequest once per frame until it is destroyed. +/// +class HttpRequestPumper +{ +public: + HttpRequestPumper(const LLCore::HttpRequest::ptr_t &request); + ~HttpRequestPumper(); + +private: + bool pollRequest(const LLSD&); + + LLTempBoundListener mBoundListener; + LLCore::HttpRequest::ptr_t mHttpRequest; +}; + } // end namespace LLCoreHttpUtil diff --git a/indra/newview/llaccountingcostmanager.cpp b/indra/newview/llaccountingcostmanager.cpp index a42286a9e4..c52e6e1172 100755 --- a/indra/newview/llaccountingcostmanager.cpp +++ b/indra/newview/llaccountingcostmanager.cpp @@ -27,90 +27,171 @@ #include "llviewerprecompiledheaders.h" #include "llaccountingcostmanager.h" #include "llagent.h" -#include "llcurl.h" -#include "llhttpclient.h" +#include "httpcommon.h" +#include "llcoros.h" +#include "lleventcoro.h" +#include "llcorehttputil.h" + //=============================================================================== -LLAccountingCostManager::LLAccountingCostManager() +LLAccountingCostManager::LLAccountingCostManager(): + mHttpRequest(), + mHttpHeaders(), + mHttpOptions(), + mHttpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID), + mHttpPriority(0) { + mHttpRequest = LLCore::HttpRequest::ptr_t(new LLCore::HttpRequest()); + mHttpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false); + mHttpOptions = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false); + //mHttpPolicy = LLCore::HttpRequest::DEFAULT_POLICY_ID; + } -//=============================================================================== -class LLAccountingCostResponder : public LLCurl::Responder + +// Coroutine for sending and processing avatar name cache requests. +// Do not call directly. See documentation in lleventcoro.h and llcoro.h for +// further explanation. +void LLAccountingCostManager::accountingCostCoro(LLCoros::self& self, std::string url, + eSelectionType selectionType, const LLHandle observerHandle) { - LOG_CLASS(LLAccountingCostResponder); -public: - LLAccountingCostResponder( const LLSD& objectIDs, const LLHandle& observer_handle ) - : mObjectIDs( objectIDs ), - mObserverHandle( observer_handle ) - { - LLAccountingCostObserver* observer = mObserverHandle.get(); - if (observer) - { - mTransactionID = observer->getTransactionID(); - } - } + LLEventStream replyPump("AccountingCostReply", true); + LLCoreHttpUtil::HttpCoroHandler::ptr_t httpHandler = + LLCoreHttpUtil::HttpCoroHandler::ptr_t(new LLCoreHttpUtil::HttpCoroHandler(replyPump)); - void clearPendingRequests ( void ) - { - for ( LLSD::array_iterator iter = mObjectIDs.beginArray(); iter != mObjectIDs.endArray(); ++iter ) - { - LLAccountingCostManager::getInstance()->removePendingObject( iter->asUUID() ); - } - } - -protected: - void httpFailure() - { - LL_WARNS() << dumpResponse() << LL_ENDL; - clearPendingRequests(); - - LLAccountingCostObserver* observer = mObserverHandle.get(); - if (observer && observer->getTransactionID() == mTransactionID) - { - observer->setErrorStatus(getStatus(), getReason()); - } - } - - void httpSuccess() - { - const LLSD& content = getContent(); - //Check for error - if ( !content.isMap() || content.has("error") ) - { - failureResult(HTTP_INTERNAL_ERROR, "Error on fetched data", content); - return; - } - else if (content.has("selected")) - { - F32 physicsCost = 0.0f; - F32 networkCost = 0.0f; - F32 simulationCost = 0.0f; - - physicsCost = content["selected"]["physics"].asReal(); - networkCost = content["selected"]["streaming"].asReal(); - simulationCost = content["selected"]["simulation"].asReal(); - - SelectionCost selectionCost( /*transactionID,*/ physicsCost, networkCost, simulationCost ); - - LLAccountingCostObserver* observer = mObserverHandle.get(); - if (observer && observer->getTransactionID() == mTransactionID) - { - observer->onWeightsUpdate(selectionCost); - } - } - - clearPendingRequests(); - } - -private: - //List of posted objects - LLSD mObjectIDs; + LL_DEBUGS("LLAccountingCostManager") << "Entering coroutine " << LLCoros::instance().getName(self) + << " with url '" << url << LL_ENDL; + + try + { + LLSD objectList; + U32 objectIndex = 0; + + IDIt IDIter = mObjectList.begin(); + IDIt IDIterEnd = mObjectList.end(); + + for (; IDIter != IDIterEnd; ++IDIter) + { + // Check to see if a request for this object has already been made. + if (mPendingObjectQuota.find(*IDIter) == mPendingObjectQuota.end()) + { + mPendingObjectQuota.insert(*IDIter); + objectList[objectIndex++] = *IDIter; + } + } + + mObjectList.clear(); + + //Post results + if (objectList.size() == 0) + return; + + std::string keystr; + if (selectionType == Roots) + { + keystr = "selected_roots"; + } + else if (selectionType == Prims) + { + keystr = "selected_prims"; + } + else + { + LL_INFOS() << "Invalid selection type " << LL_ENDL; + mObjectList.clear(); + mPendingObjectQuota.clear(); + return; + } - // Current request ID - LLUUID mTransactionID; + LLSD dataToPost = LLSD::emptyMap(); + dataToPost[keystr.c_str()] = objectList; + + LLAccountingCostObserver* observer = observerHandle.get(); + LLUUID transactionId = observer->getTransactionID(); + observer = NULL; + + LLSD results; + { // Scoping block for pumper object + LL_INFOS() << "Requesting transaction " << transactionId << LL_ENDL; + LLCoreHttpUtil::HttpRequestPumper pumper(mHttpRequest); + LLCore::HttpHandle hhandle = LLCoreHttpUtil::requestPostWithLLSD(mHttpRequest, + mHttpPolicy, mHttpPriority, url, dataToPost, mHttpOptions, mHttpHeaders, + httpHandler.get()); + + if (hhandle == LLCORE_HTTP_HANDLE_INVALID) + { + LLCore::HttpStatus status = mHttpRequest->getStatus(); + LL_WARNS() << "Error posting to " << url << " Status=" << status.getStatus() << + " message = " << status.getMessage() << LL_ENDL; + mPendingObjectQuota.clear(); + return; + } + + results = waitForEventOn(self, replyPump); + LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; + } + LLSD httpResults; + httpResults = results["http_result"]; + + do + { + observer = observerHandle.get(); + if ((!observer) || (observer->getTransactionID() != transactionId)) + { + if (!observer) + break; + LL_WARNS() << "Request transaction Id(" << transactionId + << ") does not match observer's transaction Id(" + << observer->getTransactionID() << ")." << LL_ENDL; + break; + } + + if (!httpResults["success"].asBoolean()) + { + LL_WARNS() << "Error result from LLCoreHttpUtil::HttpCoroHandler. Code " + << httpResults["status"] << ": '" << httpResults["message"] << "'" << LL_ENDL; + if (observer) + { + observer->setErrorStatus(httpResults["status"].asInteger(), httpResults["message"].asStringRef()); + } + break; + } + + if (!results.isMap() || results.has("error")) + { + LL_WARNS() << "Error on fetched data" << LL_ENDL; + observer->setErrorStatus(499, "Error on fetched data"); + break; + } + + if (results.has("selected")) + { + F32 physicsCost = 0.0f; + F32 networkCost = 0.0f; + F32 simulationCost = 0.0f; + + physicsCost = results["selected"]["physics"].asReal(); + networkCost = results["selected"]["streaming"].asReal(); + simulationCost = results["selected"]["simulation"].asReal(); + + SelectionCost selectionCost( physicsCost, networkCost, simulationCost); + + observer->onWeightsUpdate(selectionCost); + } + + } while (false); + + } + catch (std::exception e) + { + LL_WARNS() << "Caught exception '" << e.what() << "'" << LL_ENDL; + } + catch (...) + { + LL_WARNS() << "Caught unknown exception." << LL_ENDL; + } + + mPendingObjectQuota.clear(); +} - // Cost update observer handle - LLHandle mObserverHandle; -}; //=============================================================================== void LLAccountingCostManager::fetchCosts( eSelectionType selectionType, const std::string& url, @@ -119,50 +200,11 @@ void LLAccountingCostManager::fetchCosts( eSelectionType selectionType, // Invoking system must have already determined capability availability if ( !url.empty() ) { - LLSD objectList; - U32 objectIndex = 0; - - IDIt IDIter = mObjectList.begin(); - IDIt IDIterEnd = mObjectList.end(); - - for ( ; IDIter != IDIterEnd; ++IDIter ) - { - // Check to see if a request for this object has already been made. - if ( mPendingObjectQuota.find( *IDIter ) == mPendingObjectQuota.end() ) - { - mPendingObjectQuota.insert( *IDIter ); - objectList[objectIndex++] = *IDIter; - } - } - - mObjectList.clear(); - - //Post results - if ( objectList.size() > 0 ) - { - std::string keystr; - if ( selectionType == Roots ) - { - keystr="selected_roots"; - } - else - if ( selectionType == Prims ) - { - keystr="selected_prims"; - } - else - { - LL_INFOS()<<"Invalid selection type "< mPendingObjectQuota; typedef std::set::iterator IDIt; + + void accountingCostCoro(LLCoros::self& self, std::string url, eSelectionType selectionType, const LLHandle observerHandle); + + LLCore::HttpRequest::ptr_t mHttpRequest; + LLCore::HttpHeaders::ptr_t mHttpHeaders; + LLCore::HttpOptions::ptr_t mHttpOptions; + LLCore::HttpRequest::policy_t mHttpPolicy; + LLCore::HttpRequest::priority_t mHttpPriority; }; //=============================================================================== -- cgit v1.2.3 From a25f4b49676e5a371d185bfb222e47893dd78b75 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 3 Apr 2015 14:50:15 -0700 Subject: Comment out debug LL_INFOs and added TODO comment. --- indra/newview/llaccountingcostmanager.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'indra') diff --git a/indra/newview/llaccountingcostmanager.cpp b/indra/newview/llaccountingcostmanager.cpp index c52e6e1172..a80715dad5 100755 --- a/indra/newview/llaccountingcostmanager.cpp +++ b/indra/newview/llaccountingcostmanager.cpp @@ -110,7 +110,7 @@ void LLAccountingCostManager::accountingCostCoro(LLCoros::self& self, std::strin LLSD results; { // Scoping block for pumper object - LL_INFOS() << "Requesting transaction " << transactionId << LL_ENDL; + //LL_INFOS() << "Requesting transaction " << transactionId << LL_ENDL; LLCoreHttpUtil::HttpRequestPumper pumper(mHttpRequest); LLCore::HttpHandle hhandle = LLCoreHttpUtil::requestPostWithLLSD(mHttpRequest, mHttpPolicy, mHttpPriority, url, dataToPost, mHttpOptions, mHttpHeaders, @@ -126,7 +126,7 @@ void LLAccountingCostManager::accountingCostCoro(LLCoros::self& self, std::strin } results = waitForEventOn(self, replyPump); - LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; + //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; } LLSD httpResults; httpResults = results["http_result"]; @@ -135,7 +135,9 @@ void LLAccountingCostManager::accountingCostCoro(LLCoros::self& self, std::strin { observer = observerHandle.get(); if ((!observer) || (observer->getTransactionID() != transactionId)) - { + { // *TODO: Rider: I've noticed that getTransactionID() does not + // always match transactionId (the new transaction Id does not show a + // corresponding request.) if (!observer) break; LL_WARNS() << "Request transaction Id(" << transactionId -- cgit v1.2.3 From 8a76284e488227b9ff83917cdec2ea011c088527 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 7 Apr 2015 10:30:10 -0700 Subject: Results from code review with Nat. Consolidate some of the coroutine/http code into a single adapter. --- indra/llmessage/llavatarnamecache.cpp | 14 +- indra/llmessage/llcorehttputil.cpp | 422 +++++++++++++++++++++--------- indra/llmessage/llcorehttputil.h | 47 +++- indra/newview/llaccountingcostmanager.cpp | 28 +- 4 files changed, 349 insertions(+), 162 deletions(-) (limited to 'indra') diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index 88859819e0..616bd60f07 100755 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -189,10 +189,6 @@ namespace LLAvatarNameCache // further explanation. void LLAvatarNameCache::requestAvatarNameCache_(LLCoros::self& self, std::string url, std::vector agentIds) { - LLEventStream replyPump("NameCacheReply", true); - LLCoreHttpUtil::HttpCoroHandler::ptr_t httpHandler = - LLCoreHttpUtil::HttpCoroHandler::ptr_t(new LLCoreHttpUtil::HttpCoroHandler(replyPump)); - LL_DEBUGS("AvNameCache") << "Entering coroutine " << LLCoros::instance().getName(self) << " with url '" << url << "', requesting " << agentIds.size() << " Agent Ids" << LL_ENDL; @@ -200,12 +196,8 @@ void LLAvatarNameCache::requestAvatarNameCache_(LLCoros::self& self, std::string { bool success = true; - LLAvatarNameCache::sHttpRequest->requestGet( - LLAvatarNameCache::sHttpPolicy, LLAvatarNameCache::sHttpPriority, - url, LLAvatarNameCache::sHttpOptions.get(), - LLAvatarNameCache::sHttpHeaders.get(), httpHandler.get()); - - LLSD results = waitForEventOn(self, replyPump); + LLCoreHttpUtil::HttpCoroutineAdapter httpAdapter("NameCache", LLAvatarNameCache::sHttpPolicy); + LLSD results = httpAdapter.getAndYield(self, sHttpRequest, url); LLSD httpResults; LL_DEBUGS() << results << LL_ENDL; @@ -564,8 +556,6 @@ void LLAvatarNameCache::idle() // By convention, start running at first idle() call sRunning = true; - sHttpRequest->update(0L); - // *TODO: Possibly re-enabled this based on People API load measurements // 100 ms is the threshold for "user speed" operations, so we can // stall for about that long to batch up requests. diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index 30f5f3d3ed..882fef66bc 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -46,148 +46,148 @@ namespace LLCoreHttpUtil // headers could use it. bool responseToLLSD(HttpResponse * response, bool log, LLSD & out_llsd) { - // Convert response to LLSD - BufferArray * body(response->getBody()); - if (! body || ! body->size()) - { - return false; - } - - LLCore::BufferArrayStream bas(body); - LLSD body_llsd; - S32 parse_status(LLSDSerialize::fromXML(body_llsd, bas, log)); - if (LLSDParser::PARSE_FAILURE == parse_status){ - return false; - } - out_llsd = body_llsd; - return true; + // Convert response to LLSD + BufferArray * body(response->getBody()); + if (!body || !body->size()) + { + return false; + } + + LLCore::BufferArrayStream bas(body); + LLSD body_llsd; + S32 parse_status(LLSDSerialize::fromXML(body_llsd, bas, log)); + if (LLSDParser::PARSE_FAILURE == parse_status){ + return false; + } + out_llsd = body_llsd; + return true; } HttpHandle requestPostWithLLSD(HttpRequest * request, - HttpRequest::policy_t policy_id, - HttpRequest::priority_t priority, - const std::string & url, - const LLSD & body, - HttpOptions * options, - HttpHeaders * headers, - HttpHandler * handler) + HttpRequest::policy_t policy_id, + HttpRequest::priority_t priority, + const std::string & url, + const LLSD & body, + HttpOptions * options, + HttpHeaders * headers, + HttpHandler * handler) { - HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); - - BufferArray * ba = new BufferArray(); - BufferArrayStream bas(ba); - LLSDSerialize::toXML(body, bas); - - handle = request->requestPost(policy_id, - priority, - url, - ba, - options, - headers, - handler); - ba->release(); - return handle; + HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); + + BufferArray * ba = new BufferArray(); + BufferArrayStream bas(ba); + LLSDSerialize::toXML(body, bas); + + handle = request->requestPost(policy_id, + priority, + url, + ba, + options, + headers, + handler); + ba->release(); + return handle; } HttpHandle requestPostWithLLSD(HttpRequest::ptr_t & request, - HttpRequest::policy_t policy_id, - HttpRequest::priority_t priority, - const std::string & url, - const LLSD & body, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers, - HttpHandler * handler) + HttpRequest::policy_t policy_id, + HttpRequest::priority_t priority, + const std::string & url, + const LLSD & body, + HttpOptions::ptr_t & options, + HttpHeaders::ptr_t & headers, + HttpHandler * handler) { - return requestPostWithLLSD(request.get(), policy_id, priority, - url, body, options.get(), headers.get(), handler); + return requestPostWithLLSD(request.get(), policy_id, priority, + url, body, options.get(), headers.get(), handler); } HttpHandle requestPutWithLLSD(HttpRequest * request, - HttpRequest::policy_t policy_id, - HttpRequest::priority_t priority, - const std::string & url, - const LLSD & body, - HttpOptions * options, - HttpHeaders * headers, - HttpHandler * handler) + HttpRequest::policy_t policy_id, + HttpRequest::priority_t priority, + const std::string & url, + const LLSD & body, + HttpOptions * options, + HttpHeaders * headers, + HttpHandler * handler) { - HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); - - BufferArray * ba = new BufferArray(); - BufferArrayStream bas(ba); - LLSDSerialize::toXML(body, bas); - - handle = request->requestPut(policy_id, - priority, - url, - ba, - options, - headers, - handler); - ba->release(); - return handle; + HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); + + BufferArray * ba = new BufferArray(); + BufferArrayStream bas(ba); + LLSDSerialize::toXML(body, bas); + + handle = request->requestPut(policy_id, + priority, + url, + ba, + options, + headers, + handler); + ba->release(); + return handle; } HttpHandle requestPutWithLLSD(HttpRequest::ptr_t & request, - HttpRequest::policy_t policy_id, - HttpRequest::priority_t priority, - const std::string & url, - const LLSD & body, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers, - HttpHandler * handler) + HttpRequest::policy_t policy_id, + HttpRequest::priority_t priority, + const std::string & url, + const LLSD & body, + HttpOptions::ptr_t & options, + HttpHeaders::ptr_t & headers, + HttpHandler * handler) { - return requestPutWithLLSD(request.get(), policy_id, priority, - url, body, options.get(), headers.get(), handler); + return requestPutWithLLSD(request.get(), policy_id, priority, + url, body, options.get(), headers.get(), handler); } std::string responseToString(LLCore::HttpResponse * response) { - static const std::string empty("[Empty]"); - - if (! response) - { - return empty; - } - - BufferArray * body(response->getBody()); - if (! body || ! body->size()) - { - return empty; - } - - // Attempt to parse as LLSD regardless of content-type - LLSD body_llsd; - if (responseToLLSD(response, false, body_llsd)) - { - std::ostringstream tmp; - - LLSDSerialize::toPrettyNotation(body_llsd, tmp); - std::size_t temp_len(tmp.tellp()); - - if (temp_len) - { - return tmp.str().substr(0, std::min(temp_len, std::size_t(1024))); - } - } - else - { - // *TODO: More elaborate forms based on Content-Type as needed. - char content[1024]; - - size_t len(body->read(0, content, sizeof(content))); - if (len) - { - return std::string(content, 0, len); - } - } - - // Default - return empty; -} + static const std::string empty("[Empty]"); + + if (!response) + { + return empty; + } + + BufferArray * body(response->getBody()); + if (!body || !body->size()) + { + return empty; + } + + // Attempt to parse as LLSD regardless of content-type + LLSD body_llsd; + if (responseToLLSD(response, false, body_llsd)) + { + std::ostringstream tmp; + + LLSDSerialize::toPrettyNotation(body_llsd, tmp); + std::size_t temp_len(tmp.tellp()); + + if (temp_len) + { + return tmp.str().substr(0, std::min(temp_len, std::size_t(1024))); + } + } + else + { + // *TODO: More elaborate forms based on Content-Type as needed. + char content[1024]; + + size_t len(body->read(0, content, sizeof(content))); + if (len) + { + return std::string(content, 0, len); + } + } + // Default + return empty; +} +//======================================================================== HttpCoroHandler::HttpCoroHandler(LLEventStream &reply) : mReplyPump(reply) { @@ -204,7 +204,7 @@ void HttpCoroHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRespons result = LLSD::emptyMap(); LL_WARNS() << "\n--------------------------------------------------------------------------\n" - << " Error[" << status.toULong() << "] cannot access url '" << response->getRequestURL() + << " Error[" << status.toULong() << "] cannot access url '" << response->getRequestURL() << "' because " << status.toString() << "\n--------------------------------------------------------------------------" << LL_ENDL; @@ -251,11 +251,12 @@ void HttpCoroHandler::buildStatusEntry(LLCore::HttpResponse *response, LLCore::H { LLSD httpresults = LLSD::emptyMap(); - httpresults["success"] = static_cast(status); - httpresults["type"] = static_cast(status.getType()); - httpresults["status"] = static_cast(status.getStatus()); - httpresults["message"] = static_cast(status.getMessage()); - httpresults["url"] = static_cast(response->getRequestURL()); + writeStatusCodes(status, response->getRequestURL(), httpresults); + // httpresults["success"] = static_cast(status); + // httpresults["type"] = static_cast(status.getType()); + // httpresults["status"] = static_cast(status.getStatus()); + // httpresults["message"] = static_cast(status.getMessage()); + // httpresults["url"] = static_cast(response->getRequestURL()); LLSD httpHeaders = LLSD::emptyMap(); LLCore::HttpHeaders * hdrs = response->getHeaders(); @@ -279,7 +280,18 @@ void HttpCoroHandler::buildStatusEntry(LLCore::HttpResponse *response, LLCore::H result["http_result"] = httpresults; } -HttpRequestPumper::HttpRequestPumper(const LLCore::HttpRequest::ptr_t &request): +void HttpCoroHandler::writeStatusCodes(LLCore::HttpStatus status, const std::string &url, LLSD &result) +{ + result["success"] = static_cast(status); + result["type"] = static_cast(status.getType()); + result["status"] = static_cast(status.getStatus()); + result["message"] = static_cast(status.getMessage()); + result["url"] = static_cast(url); + +} + +//======================================================================== +HttpRequestPumper::HttpRequestPumper(const LLCore::HttpRequest::ptr_t &request) : mHttpRequest(request) { mBoundListener = LLEventPumps::instance().obtain("mainloop"). @@ -300,6 +312,164 @@ bool HttpRequestPumper::pollRequest(const LLSD&) return false; } +//======================================================================== +HttpCoroutineAdapter::HttpCoroutineAdapter(const std::string &name, + LLCore::HttpRequest::policy_t policyId, LLCore::HttpRequest::priority_t priority) : + mAdapterName(name), + mPolicyId(policyId), + mPriority(priority) +{ +} + +HttpCoroutineAdapter::~HttpCoroutineAdapter() +{ +} + +LLSD HttpCoroutineAdapter::postAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, + const std::string & url, const LLSD & body, + LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) +{ + if (!options) + { + options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false); + } + + if (!headers) + { + headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false); + } + + LLEventStream replyPump(mAdapterName, true); + LLCoreHttpUtil::HttpCoroHandler::ptr_t httpHandler = + LLCoreHttpUtil::HttpCoroHandler::ptr_t(new LLCoreHttpUtil::HttpCoroHandler(replyPump)); + + //LL_INFOS() << "Requesting transaction " << transactionId << LL_ENDL; + LLCoreHttpUtil::HttpRequestPumper pumper(request); + // The HTTPCoroHandler does not self delete, so retrieval of a the contained + // pointer from the smart pointer is safe in this case. + LLCore::HttpHandle hhandle = requestPostWithLLSD(request, + mPolicyId, mPriority, url, body, options, headers, + httpHandler.get()); + + if (hhandle == LLCORE_HTTP_HANDLE_INVALID) + { + LLCore::HttpStatus status = request->getStatus(); + LL_WARNS() << "Error posting to " << url << " Status=" << status.getStatus() << + " message = " << status.getMessage() << LL_ENDL; + + // Mimic the status results returned from an http error that we had + // to wait on + LLSD httpresults = LLSD::emptyMap(); + + httpHandler->writeStatusCodes(status, url, httpresults); + + LLSD errorres = LLSD::emptyMap(); + errorres["http_result"] = httpresults; + + return errorres; + } + + LLSD results = waitForEventOn(self, replyPump); + //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; + return results; +} + +LLSD HttpCoroutineAdapter::putAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t & request, + const std::string & url, const LLSD & body, + LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) +{ + if (!options) + { + options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false); + } + + if (!headers) + { + headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false); + } + + LLEventStream replyPump(mAdapterName, true); + LLCoreHttpUtil::HttpCoroHandler::ptr_t httpHandler = + LLCoreHttpUtil::HttpCoroHandler::ptr_t(new LLCoreHttpUtil::HttpCoroHandler(replyPump)); + + //LL_INFOS() << "Requesting transaction " << transactionId << LL_ENDL; + LLCoreHttpUtil::HttpRequestPumper pumper(request); + // The HTTPCoroHandler does not self delete, so retrieval of a the contained + // pointer from the smart pointer is safe in this case. + LLCore::HttpHandle hhandle = requestPutWithLLSD(request, + mPolicyId, mPriority, url, body, options, headers, + httpHandler.get()); + + if (hhandle == LLCORE_HTTP_HANDLE_INVALID) + { + LLCore::HttpStatus status = request->getStatus(); + LL_WARNS() << "Error posting to " << url << " Status=" << status.getStatus() << + " message = " << status.getMessage() << LL_ENDL; + + // Mimic the status results returned from an http error that we had + // to wait on + LLSD httpresults = LLSD::emptyMap(); + + httpHandler->writeStatusCodes(status, url, httpresults); + + LLSD errorres = LLSD::emptyMap(); + errorres["http_result"] = httpresults; + + return errorres; + } + + LLSD results = waitForEventOn(self, replyPump); + //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; + return results; +} + +LLSD HttpCoroutineAdapter::getAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t & request, + const std::string & url, + LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) +{ + if (!options) + { + options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false); + } + + if (!headers) + { + headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false); + } + + LLEventStream replyPump(mAdapterName + "Reply", true); + LLCoreHttpUtil::HttpCoroHandler::ptr_t httpHandler = + LLCoreHttpUtil::HttpCoroHandler::ptr_t(new LLCoreHttpUtil::HttpCoroHandler(replyPump)); + + //LL_INFOS() << "Requesting transaction " << transactionId << LL_ENDL; + LLCoreHttpUtil::HttpRequestPumper pumper(request); + // The HTTPCoroHandler does not self delete, so retrieval of a the contained + // pointer from the smart pointer is safe in this case. + LLCore::HttpHandle hhandle = request->requestGet(mPolicyId, mPriority, + url, options.get(), headers.get(), httpHandler.get()); + + if (hhandle == LLCORE_HTTP_HANDLE_INVALID) + { + LLCore::HttpStatus status = request->getStatus(); + LL_WARNS() << "Error posting to " << url << " Status=" << status.getStatus() << + " message = " << status.getMessage() << LL_ENDL; + + // Mimic the status results returned from an http error that we had + // to wait on + LLSD httpresults = LLSD::emptyMap(); + + httpHandler->writeStatusCodes(status, url, httpresults); + + LLSD errorres = LLSD::emptyMap(); + errorres["http_result"] = httpresults; + + return errorres; + } + + LLSD results = waitForEventOn(self, replyPump); + //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; + return results; +} } // end namespace LLCoreHttpUtil diff --git a/indra/llmessage/llcorehttputil.h b/indra/llmessage/llcorehttputil.h index 4ae6e112b3..10f46dd477 100644 --- a/indra/llmessage/llcorehttputil.h +++ b/indra/llmessage/llcorehttputil.h @@ -40,6 +40,8 @@ #include "bufferstream.h" #include "llsd.h" #include "llevents.h" +#include "llcoros.h" +#include "lleventcoro.h" /// /// The base llcorehttp library implements many HTTP idioms @@ -174,6 +176,7 @@ public: typedef boost::shared_ptr ptr_t; + void writeStatusCodes(LLCore::HttpStatus status, const std::string &url, LLSD &result); private: void buildStatusEntry(LLCore::HttpResponse *response, LLCore::HttpStatus status, LLSD &result); @@ -196,7 +199,49 @@ private: LLCore::HttpRequest::ptr_t mHttpRequest; }; -} // end namespace LLCoreHttpUtil +/// An adapter to handle some of the boilerplate code surrounding HTTP and coroutine +/// interaction. +/// +/// Construct an HttpCoroutineAdapter giving it a name and policy Id. After +/// any application specific setup call the post, put or get method. The request +/// will be automatically pumped and the method will return with an LLSD describing +/// the result of the operation. See HttpCoroHandler for a description of the +/// decoration done to the returned LLSD. +class HttpCoroutineAdapter +{ +public: + HttpCoroutineAdapter(const std::string &name, LLCore::HttpRequest::policy_t policyId, + LLCore::HttpRequest::priority_t priority = 0L); + ~HttpCoroutineAdapter(); + + /// Execute a Post transaction on the supplied URL and yield execution of + /// the coroutine until a result is available. + LLSD postAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t & request, + const std::string & url, const LLSD & body, + LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(), + LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t()); + + /// Execute a Put transaction on the supplied URL and yield execution of + /// the coroutine until a result is available. + LLSD putAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t & request, + const std::string & url, const LLSD & body, + LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(), + LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t()); + + /// Execute a Get transaction on the supplied URL and yield execution of + /// the coroutine until a result is available. + LLSD getAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t & request, + const std::string & url, + LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(), + LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t()); +private: + + std::string mAdapterName; + LLCore::HttpRequest::priority_t mPriority; + LLCore::HttpRequest::policy_t mPolicyId; +}; + +} // end namespace LLCoreHttpUtil #endif // LL_LLCOREHTTPUTIL_H diff --git a/indra/newview/llaccountingcostmanager.cpp b/indra/newview/llaccountingcostmanager.cpp index a80715dad5..f33f67e76d 100755 --- a/indra/newview/llaccountingcostmanager.cpp +++ b/indra/newview/llaccountingcostmanager.cpp @@ -53,10 +53,6 @@ LLAccountingCostManager::LLAccountingCostManager(): void LLAccountingCostManager::accountingCostCoro(LLCoros::self& self, std::string url, eSelectionType selectionType, const LLHandle observerHandle) { - LLEventStream replyPump("AccountingCostReply", true); - LLCoreHttpUtil::HttpCoroHandler::ptr_t httpHandler = - LLCoreHttpUtil::HttpCoroHandler::ptr_t(new LLCoreHttpUtil::HttpCoroHandler(replyPump)); - LL_DEBUGS("LLAccountingCostManager") << "Entering coroutine " << LLCoros::instance().getName(self) << " with url '" << url << LL_ENDL; @@ -108,36 +104,22 @@ void LLAccountingCostManager::accountingCostCoro(LLCoros::self& self, std::strin LLUUID transactionId = observer->getTransactionID(); observer = NULL; - LLSD results; - { // Scoping block for pumper object - //LL_INFOS() << "Requesting transaction " << transactionId << LL_ENDL; - LLCoreHttpUtil::HttpRequestPumper pumper(mHttpRequest); - LLCore::HttpHandle hhandle = LLCoreHttpUtil::requestPostWithLLSD(mHttpRequest, - mHttpPolicy, mHttpPriority, url, dataToPost, mHttpOptions, mHttpHeaders, - httpHandler.get()); + LLCoreHttpUtil::HttpCoroutineAdapter httpAdapter("AccountingCost", mHttpPolicy); - if (hhandle == LLCORE_HTTP_HANDLE_INVALID) - { - LLCore::HttpStatus status = mHttpRequest->getStatus(); - LL_WARNS() << "Error posting to " << url << " Status=" << status.getStatus() << - " message = " << status.getMessage() << LL_ENDL; - mPendingObjectQuota.clear(); - return; - } + LLSD results = httpAdapter.postAndYield(self, mHttpRequest, url, dataToPost); - results = waitForEventOn(self, replyPump); - //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; - } LLSD httpResults; httpResults = results["http_result"]; + // do/while(false) allows error conditions to break out of following + // block while normal flow goes forward once. do { observer = observerHandle.get(); if ((!observer) || (observer->getTransactionID() != transactionId)) { // *TODO: Rider: I've noticed that getTransactionID() does not // always match transactionId (the new transaction Id does not show a - // corresponding request.) + // corresponding request.) (ask Vir) if (!observer) break; LL_WARNS() << "Request transaction Id(" << transactionId -- cgit v1.2.3 From fe34b3ef725b83af0deeffcf8bf6ef9769224e8d Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 7 Apr 2015 11:23:20 -0700 Subject: Remove unused mHttpPriority --- indra/newview/llaccountingcostmanager.cpp | 3 +-- indra/newview/llaccountingcostmanager.h | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) (limited to 'indra') diff --git a/indra/newview/llaccountingcostmanager.cpp b/indra/newview/llaccountingcostmanager.cpp index f33f67e76d..6337fbe444 100755 --- a/indra/newview/llaccountingcostmanager.cpp +++ b/indra/newview/llaccountingcostmanager.cpp @@ -37,8 +37,7 @@ LLAccountingCostManager::LLAccountingCostManager(): mHttpRequest(), mHttpHeaders(), mHttpOptions(), - mHttpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID), - mHttpPriority(0) + mHttpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID) { mHttpRequest = LLCore::HttpRequest::ptr_t(new LLCore::HttpRequest()); mHttpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false); diff --git a/indra/newview/llaccountingcostmanager.h b/indra/newview/llaccountingcostmanager.h index 7d544b15e8..f4d45d43cb 100755 --- a/indra/newview/llaccountingcostmanager.h +++ b/indra/newview/llaccountingcostmanager.h @@ -83,7 +83,6 @@ private: LLCore::HttpHeaders::ptr_t mHttpHeaders; LLCore::HttpOptions::ptr_t mHttpOptions; LLCore::HttpRequest::policy_t mHttpPolicy; - LLCore::HttpRequest::priority_t mHttpPriority; }; //=============================================================================== -- cgit v1.2.3 From 1c91c8a106a78f2087a3fb4312e428a0128283b4 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 8 Apr 2015 10:17:34 -0700 Subject: Adding weak pointer support. Event polling as a coroutine. (incomplete) Groundwork for canceling HttpCoroutineAdapter yields. --- indra/llcorehttp/httpcommon.h | 1 + indra/llcorehttp/httprequest.h | 1 + indra/llmessage/llcorehttputil.cpp | 81 ++--- indra/llmessage/llcorehttputil.h | 30 +- indra/newview/lleventpoll.cpp | 688 ++++++++++++++++++++++++------------- indra/newview/lleventpoll.h | 17 +- 6 files changed, 524 insertions(+), 294 deletions(-) (limited to 'indra') diff --git a/indra/llcorehttp/httpcommon.h b/indra/llcorehttp/httpcommon.h index ada5c1bbe7..898d3d47fa 100755 --- a/indra/llcorehttp/httpcommon.h +++ b/indra/llcorehttp/httpcommon.h @@ -190,6 +190,7 @@ #include "linden_common.h" // Modifies curl/curl.h interfaces #include "boost/intrusive_ptr.hpp" #include "boost/shared_ptr.hpp" +#include "boost/weak_ptr.hpp" #include "boost/function.hpp" #include diff --git a/indra/llcorehttp/httprequest.h b/indra/llcorehttp/httprequest.h index f7ce82d412..6688f06eb5 100755 --- a/indra/llcorehttp/httprequest.h +++ b/indra/llcorehttp/httprequest.h @@ -98,6 +98,7 @@ public: typedef unsigned int priority_t; typedef boost::shared_ptr ptr_t; + typedef boost::weak_ptr wptr_t; public: /// @name PolicyMethods /// @{ diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index 882fef66bc..d560ec8462 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -317,15 +317,18 @@ HttpCoroutineAdapter::HttpCoroutineAdapter(const std::string &name, LLCore::HttpRequest::policy_t policyId, LLCore::HttpRequest::priority_t priority) : mAdapterName(name), mPolicyId(policyId), - mPriority(priority) + mPriority(priority), + mYieldingHandle(LLCORE_HTTP_HANDLE_INVALID), + mWeakRequest() { } HttpCoroutineAdapter::~HttpCoroutineAdapter() { + } -LLSD HttpCoroutineAdapter::postAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, +LLSD HttpCoroutineAdapter::postAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, const std::string & url, const LLSD & body, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { @@ -353,28 +356,17 @@ LLSD HttpCoroutineAdapter::postAndYield(LLCoros::self & self, LLCore::HttpReques if (hhandle == LLCORE_HTTP_HANDLE_INVALID) { - LLCore::HttpStatus status = request->getStatus(); - LL_WARNS() << "Error posting to " << url << " Status=" << status.getStatus() << - " message = " << status.getMessage() << LL_ENDL; - - // Mimic the status results returned from an http error that we had - // to wait on - LLSD httpresults = LLSD::emptyMap(); - - httpHandler->writeStatusCodes(status, url, httpresults); - - LLSD errorres = LLSD::emptyMap(); - errorres["http_result"] = httpresults; - - return errorres; + return HttpCoroutineAdapter::buildImmediateErrorResult(request, url, httpHandler); } + mYieldingHandle = hhandle; LLSD results = waitForEventOn(self, replyPump); + mYieldingHandle = LLCORE_HTTP_HANDLE_INVALID; //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; } -LLSD HttpCoroutineAdapter::putAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t & request, +LLSD HttpCoroutineAdapter::putAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, const std::string & url, const LLSD & body, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { @@ -402,28 +394,17 @@ LLSD HttpCoroutineAdapter::putAndYield(LLCoros::self & self, LLCore::HttpRequest if (hhandle == LLCORE_HTTP_HANDLE_INVALID) { - LLCore::HttpStatus status = request->getStatus(); - LL_WARNS() << "Error posting to " << url << " Status=" << status.getStatus() << - " message = " << status.getMessage() << LL_ENDL; - - // Mimic the status results returned from an http error that we had - // to wait on - LLSD httpresults = LLSD::emptyMap(); - - httpHandler->writeStatusCodes(status, url, httpresults); - - LLSD errorres = LLSD::emptyMap(); - errorres["http_result"] = httpresults; - - return errorres; + return HttpCoroutineAdapter::buildImmediateErrorResult(request, url, httpHandler); } + mYieldingHandle = hhandle; LLSD results = waitForEventOn(self, replyPump); + mYieldingHandle = LLCORE_HTTP_HANDLE_INVALID; //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; } -LLSD HttpCoroutineAdapter::getAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t & request, +LLSD HttpCoroutineAdapter::getAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, const std::string & url, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { @@ -450,26 +431,34 @@ LLSD HttpCoroutineAdapter::getAndYield(LLCoros::self & self, LLCore::HttpRequest if (hhandle == LLCORE_HTTP_HANDLE_INVALID) { - LLCore::HttpStatus status = request->getStatus(); - LL_WARNS() << "Error posting to " << url << " Status=" << status.getStatus() << - " message = " << status.getMessage() << LL_ENDL; - - // Mimic the status results returned from an http error that we had - // to wait on - LLSD httpresults = LLSD::emptyMap(); - - httpHandler->writeStatusCodes(status, url, httpresults); - - LLSD errorres = LLSD::emptyMap(); - errorres["http_result"] = httpresults; - - return errorres; + return HttpCoroutineAdapter::buildImmediateErrorResult(request, url, httpHandler); } + mYieldingHandle = hhandle; LLSD results = waitForEventOn(self, replyPump); + mYieldingHandle = LLCORE_HTTP_HANDLE_INVALID; //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; } +LLSD HttpCoroutineAdapter::buildImmediateErrorResult(const LLCore::HttpRequest::ptr_t &request, + const std::string &url, LLCoreHttpUtil::HttpCoroHandler::ptr_t &httpHandler) +{ + LLCore::HttpStatus status = request->getStatus(); + LL_WARNS() << "Error posting to " << url << " Status=" << status.getStatus() << + " message = " << status.getMessage() << LL_ENDL; + + // Mimic the status results returned from an http error that we had + // to wait on + LLSD httpresults = LLSD::emptyMap(); + + httpHandler->writeStatusCodes(status, url, httpresults); + + LLSD errorres = LLSD::emptyMap(); + errorres["http_result"] = httpresults; + + return errorres; +} + } // end namespace LLCoreHttpUtil diff --git a/indra/llmessage/llcorehttputil.h b/indra/llmessage/llcorehttputil.h index 10f46dd477..33cc389c49 100644 --- a/indra/llmessage/llcorehttputil.h +++ b/indra/llmessage/llcorehttputil.h @@ -210,36 +210,54 @@ private: class HttpCoroutineAdapter { public: + typedef boost::shared_ptr ptr_t; + typedef boost::weak_ptr wptr_t; + HttpCoroutineAdapter(const std::string &name, LLCore::HttpRequest::policy_t policyId, LLCore::HttpRequest::priority_t priority = 0L); ~HttpCoroutineAdapter(); /// Execute a Post transaction on the supplied URL and yield execution of - /// the coroutine until a result is available. - LLSD postAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t & request, + /// the coroutine until a result is available. + /// Note: the request's smart pointer is passed by value so that it will + /// not be deallocated during the yield. + LLSD postAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, const std::string & url, const LLSD & body, - LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(), - LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t()); + LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false), + LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false)); /// Execute a Put transaction on the supplied URL and yield execution of /// the coroutine until a result is available. - LLSD putAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t & request, + /// Note: the request's smart pointer is passed by value so that it will + /// not be deallocated during the yield. + LLSD putAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, const std::string & url, const LLSD & body, LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(), LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t()); /// Execute a Get transaction on the supplied URL and yield execution of /// the coroutine until a result is available. - LLSD getAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t & request, + /// Note: the request's smart pointer is passed by value so that it will + /// not be deallocated during the yield. + LLSD getAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, const std::string & url, LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(), LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t()); + /// + void cancelYieldingOperation(); + private: + static LLSD buildImmediateErrorResult(const LLCore::HttpRequest::ptr_t &request, + const std::string &url, LLCoreHttpUtil::HttpCoroHandler::ptr_t &httpHandler); std::string mAdapterName; LLCore::HttpRequest::priority_t mPriority; LLCore::HttpRequest::policy_t mPolicyId; + + LLCore::HttpHandle mYieldingHandle; + LLCore::HttpRequest::wptr_t mWeakRequest; + }; } // end namespace LLCoreHttpUtil diff --git a/indra/newview/lleventpoll.cpp b/indra/newview/lleventpoll.cpp index 4de6ad4d2f..493ee06083 100755 --- a/indra/newview/lleventpoll.cpp +++ b/indra/newview/lleventpoll.cpp @@ -37,254 +37,460 @@ #include "llviewerregion.h" #include "message.h" #include "lltrans.h" +#include "llcoros.h" +#include "lleventcoro.h" +#include "llcorehttputil.h" namespace { - // We will wait RETRY_SECONDS + (errorCount * RETRY_SECONDS_INC) before retrying after an error. - // This means we attempt to recover relatively quickly but back off giving more time to recover - // until we finally give up after MAX_EVENT_POLL_HTTP_ERRORS attempts. - const F32 EVENT_POLL_ERROR_RETRY_SECONDS = 15.f; // ~ half of a normal timeout. - const F32 EVENT_POLL_ERROR_RETRY_SECONDS_INC = 5.f; // ~ half of a normal timeout. - const S32 MAX_EVENT_POLL_HTTP_ERRORS = 10; // ~5 minutes, by the above rules. - - class LLEventPollResponder : public LLHTTPClient::Responder - { - LOG_CLASS(LLEventPollResponder); - public: - - static LLHTTPClient::ResponderPtr start(const std::string& pollURL, const LLHost& sender); - void stop(); - - void makeRequest(); - - /* virtual */ void completedRaw(const LLChannelDescriptors& channels, - const LLIOPipe::buffer_ptr_t& buffer); - - private: - LLEventPollResponder(const std::string& pollURL, const LLHost& sender); - ~LLEventPollResponder(); - - - void handleMessage(const LLSD& content); - - /* virtual */ void httpFailure(); - /* virtual */ void httpSuccess(); - - private: - - bool mDone; - - std::string mPollURL; - std::string mSender; - - LLSD mAcknowledge; - - // these are only here for debugging so we can see which poller is which - static int sCount; - int mCount; - S32 mErrorCount; - }; - - class LLEventPollEventTimer : public LLEventTimer - { - typedef LLPointer EventPollResponderPtr; - - public: - LLEventPollEventTimer(F32 period, EventPollResponderPtr responder) - : LLEventTimer(period), mResponder(responder) - { } - - virtual BOOL tick() - { - mResponder->makeRequest(); - return TRUE; // Causes this instance to be deleted. - } - - private: - - EventPollResponderPtr mResponder; - }; - - //static - LLHTTPClient::ResponderPtr LLEventPollResponder::start( - const std::string& pollURL, const LLHost& sender) - { - LLHTTPClient::ResponderPtr result = new LLEventPollResponder(pollURL, sender); - LL_INFOS() << "LLEventPollResponder::start <" << sCount << "> " - << pollURL << LL_ENDL; - return result; - } - - void LLEventPollResponder::stop() - { - LL_INFOS() << "LLEventPollResponder::stop <" << mCount << "> " - << mPollURL << LL_ENDL; - // there should be a way to stop a LLHTTPClient request in progress - mDone = true; - } - - int LLEventPollResponder::sCount = 0; - - LLEventPollResponder::LLEventPollResponder(const std::string& pollURL, const LLHost& sender) - : mDone(false), - mPollURL(pollURL), - mCount(++sCount), - mErrorCount(0) - { - //extract host and port of simulator to set as sender - LLViewerRegion *regionp = gAgent.getRegion(); - if (!regionp) - { - LL_ERRS() << "LLEventPoll initialized before region is added." << LL_ENDL; - } - mSender = sender.getIPandPort(); - LL_INFOS() << "LLEventPoll initialized with sender " << mSender << LL_ENDL; - makeRequest(); - } - - LLEventPollResponder::~LLEventPollResponder() - { - stop(); - LL_DEBUGS() << "LLEventPollResponder::~Impl <" << mCount << "> " - << mPollURL << LL_ENDL; - } - - // virtual - void LLEventPollResponder::completedRaw(const LLChannelDescriptors& channels, - const LLIOPipe::buffer_ptr_t& buffer) - { - if (getStatus() == HTTP_BAD_GATEWAY) - { - // These errors are not parsable as LLSD, - // which LLHTTPClient::Responder::completedRaw will try to do. - httpCompleted(); - } - else - { - LLHTTPClient::Responder::completedRaw(channels,buffer); - } - } - - void LLEventPollResponder::makeRequest() - { - LLSD request; - request["ack"] = mAcknowledge; - request["done"] = mDone; - - LL_DEBUGS() << "LLEventPollResponder::makeRequest <" << mCount << "> ack = " - << LLSDXMLStreamer(mAcknowledge) << LL_ENDL; - LLHTTPClient::post(mPollURL, request, this); - } - - void LLEventPollResponder::handleMessage(const LLSD& content) - { - std::string msg_name = content["message"]; - LLSD message; - message["sender"] = mSender; - message["body"] = content["body"]; - LLMessageSystem::dispatch(msg_name, message); - } - - //virtual - void LLEventPollResponder::httpFailure() - { - if (mDone) return; - - // A HTTP_BAD_GATEWAY (502) error is our standard timeout response - // we get this when there are no events. - if ( getStatus() == HTTP_BAD_GATEWAY ) - { - mErrorCount = 0; - makeRequest(); - } - else if (mErrorCount < MAX_EVENT_POLL_HTTP_ERRORS) - { - ++mErrorCount; - - // The 'tick' will return TRUE causing the timer to delete this. - new LLEventPollEventTimer(EVENT_POLL_ERROR_RETRY_SECONDS - + mErrorCount * EVENT_POLL_ERROR_RETRY_SECONDS_INC - , this); - - LL_WARNS() << dumpResponse() << LL_ENDL; - } - else - { - LL_WARNS() << dumpResponse() - << " [count:" << mCount << "] " - << (mDone ? " -- done" : "") << LL_ENDL; - stop(); - - // At this point we have given up and the viewer will not receive HTTP messages from the simulator. - // IMs, teleports, about land, selecing land, region crossing and more will all fail. - // They are essentially disconnected from the region even though some things may still work. - // Since things won't get better until they relog we force a disconnect now. - - // *NOTE:Mani - The following condition check to see if this failing event poll - // is attached to the Agent's main region. If so we disconnect the viewer. - // Else... its a child region and we just leave the dead event poll stopped and - // continue running. - if(gAgent.getRegion() && gAgent.getRegion()->getHost().getIPandPort() == mSender) - { - LL_WARNS() << "Forcing disconnect due to stalled main region event poll." << LL_ENDL; - LLAppViewer::instance()->forceDisconnect(LLTrans::getString("AgentLostConnection")); - } - } - } - - //virtual - void LLEventPollResponder::httpSuccess() - { - LL_DEBUGS() << "LLEventPollResponder::result <" << mCount << ">" - << (mDone ? " -- done" : "") << LL_ENDL; - - if (mDone) return; - - mErrorCount = 0; - - const LLSD& content = getContent(); - if (!content.isMap() || - !content.get("events") || - !content.get("id")) - { - LL_WARNS() << "received event poll with no events or id key: " << dumpResponse() << LL_ENDL; - makeRequest(); - return; - } - - mAcknowledge = content["id"]; - LLSD events = content["events"]; - - if(mAcknowledge.isUndefined()) - { - LL_WARNS() << "LLEventPollResponder: id undefined" << LL_ENDL; - } - - // was LL_INFOS() but now that CoarseRegionUpdate is TCP @ 1/second, it'd be too verbose for viewer logs. -MG - LL_DEBUGS() << "LLEventPollResponder::httpSuccess <" << mCount << "> " << events.size() << "events (id " - << LLSDXMLStreamer(mAcknowledge) << ")" << LL_ENDL; - - LLSD::array_const_iterator i = events.beginArray(); - LLSD::array_const_iterator end = events.endArray(); - for (; i != end; ++i) - { - if (i->has("message")) - { - handleMessage(*i); - } - } - - makeRequest(); - } + // We will wait RETRY_SECONDS + (errorCount * RETRY_SECONDS_INC) before retrying after an error. + // This means we attempt to recover relatively quickly but back off giving more time to recover + // until we finally give up after MAX_EVENT_POLL_HTTP_ERRORS attempts. + const F32 EVENT_POLL_ERROR_RETRY_SECONDS = 15.f; // ~ half of a normal timeout. + const F32 EVENT_POLL_ERROR_RETRY_SECONDS_INC = 5.f; // ~ half of a normal timeout. + const S32 MAX_EVENT_POLL_HTTP_ERRORS = 10; // ~5 minutes, by the above rules. + +#if 1 + + class LLEventPollImpl + { + public: + LLEventPollImpl(const LLHost &sender); + + void start(const std::string &url); + void stop(); + private: + void eventPollCoro(LLCoros::self& self, std::string url); + + void handleMessage(const LLSD &content); + + bool mDone; + LLCore::HttpRequest::ptr_t mHttpRequest; + LLCore::HttpRequest::policy_t mHttpPolicy; + std::string mSenderIp; + int mCounter; + + static int sNextCounter; + }; + + + int LLEventPollImpl::sNextCounter = 1; + + + LLEventPollImpl::LLEventPollImpl(const LLHost &sender) : + mDone(false), + mHttpRequest(), + mHttpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID), + mSenderIp(), + mCounter(sNextCounter++) + + { + mHttpRequest = LLCore::HttpRequest::ptr_t(new LLCore::HttpRequest); + mSenderIp = sender.getIPandPort(); + } + + void LLEventPollImpl::handleMessage(const LLSD& content) + { + std::string msg_name = content["message"]; + LLSD message; + message["sender"] = mSenderIp; + message["body"] = content["body"]; + LLMessageSystem::dispatch(msg_name, message); + } + + void LLEventPollImpl::start(const std::string &url) + { + if (!url.empty()) + { + std::string coroname = + LLCoros::instance().launch("LLAccountingCostManager::accountingCostCoro", + boost::bind(&LLEventPollImpl::eventPollCoro, this, _1, url)); + LL_DEBUGS() << coroname << " with url '" << url << LL_ENDL; + } + } + + void LLEventPollImpl::stop() + { + mDone = true; + } + + void LLEventPollImpl::eventPollCoro(LLCoros::self& self, std::string url) + { + LLCoreHttpUtil::HttpCoroutineAdapter httpAdapter("EventPoller", mHttpPolicy); + LLSD acknowledge; + int errorCount = 0; + int counter = mCounter; // saved on the stack for debugging. + + LL_INFOS("LLEventPollImpl::eventPollCoro") << " <" << counter << "> entering coroutine." << LL_ENDL; + + while (!mDone) + { + LLSD request; + request["ack"] = acknowledge; + request["done"] = mDone; + +// LL_DEBUGS("LLEventPollImpl::eventPollCoro") << "<" << counter << "> request = " +// << LLSDXMLStreamer(request) << LL_ENDL; + + LL_INFOS("LLEventPollImpl::eventPollCoro") << " <" << counter << "> posting and yielding." << LL_ENDL; + LLSD result = httpAdapter.postAndYield(self, mHttpRequest, url, request); + +// LL_DEBUGS("LLEventPollImpl::eventPollCoro") << "<" << counter << "> result = " +// << LLSDXMLStreamer(result) << LL_ENDL; + + if (mDone) + break; + + LLSD httpResults; + httpResults = result["http_result"]; + + + if (!httpResults["success"].asBoolean()) + { + LL_WARNS("LLEventPollImpl::eventPollCoro") << "<" << counter << "> Error result from LLCoreHttpUtil::HttpCoroHandler. Code " + << httpResults["status"] << ": '" << httpResults["message"] << "'" << LL_ENDL; + + if (httpResults["status"].asInteger() == HTTP_BAD_GATEWAY) + { + // A HTTP_BAD_GATEWAY (502) error is our standard timeout response + // we get this when there are no events. + errorCount = 0; + continue; + } + + LL_WARNS("LLEventPollImpl::eventPollCoro") << "<" << counter << "> " << LLSDXMLStreamer(result) << (mDone ? " -- done" : "") << LL_ENDL; + + if (errorCount < MAX_EVENT_POLL_HTTP_ERRORS) + { + ++errorCount; + + // The 'tick' will return TRUE causing the timer to delete this. + int waitToRetry = EVENT_POLL_ERROR_RETRY_SECONDS + + errorCount * EVENT_POLL_ERROR_RETRY_SECONDS_INC; + + LL_WARNS() << "Retrying in " << waitToRetry << + " seconds, error count is now " << errorCount << LL_ENDL; + + // *TODO: Wait for a timeout here + // new LLEventPollEventTimer( + // , this); + continue; + } + else + { + // At this point we have given up and the viewer will not receive HTTP messages from the simulator. + // IMs, teleports, about land, selecting land, region crossing and more will all fail. + // They are essentially disconnected from the region even though some things may still work. + // Since things won't get better until they relog we force a disconnect now. + + mDone = true; + + // *NOTE:Mani - The following condition check to see if this failing event poll + // is attached to the Agent's main region. If so we disconnect the viewer. + // Else... its a child region and we just leave the dead event poll stopped and + // continue running. + if (gAgent.getRegion() && gAgent.getRegion()->getHost().getIPandPort() == mSenderIp) + { + LL_WARNS("LLEventPollImpl::eventPollCoro") << "< " << counter << "> Forcing disconnect due to stalled main region event poll." << LL_ENDL; + LLAppViewer::instance()->forceDisconnect(LLTrans::getString("AgentLostConnection")); + } + break; + } + } + + LL_DEBUGS("LLEventPollImpl::eventPollCoro") << " <" << counter << ">" + << (mDone ? " -- done" : "") << LL_ENDL; + + errorCount = 0; + + if (!result.isMap() || + !result.get("events") || + !result.get("id")) + { + LL_WARNS("LLEventPollImpl::eventPollCoro") << " <" << counter << "> received event poll with no events or id key: " << LLSDXMLStreamer(result) << LL_ENDL; + continue; + } + + acknowledge = result["id"]; + LLSD events = result["events"]; + + if (acknowledge.isUndefined()) + { + LL_WARNS("LLEventPollImpl::eventPollCoro") << " id undefined" << LL_ENDL; + } + + // was LL_INFOS() but now that CoarseRegionUpdate is TCP @ 1/second, it'd be too verbose for viewer logs. -MG + LL_DEBUGS() << "LLEventPollResponder::httpSuccess <" << counter << "> " << events.size() << "events (id " + << LLSDXMLStreamer(acknowledge) << ")" << LL_ENDL; + + LLSD::array_const_iterator i = events.beginArray(); + LLSD::array_const_iterator end = events.endArray(); + for (; i != end; ++i) + { + if (i->has("message")) + { + handleMessage(*i); + } + } + } + LL_INFOS("LLEventPollImpl::eventPollCoro") << " <" << counter << "> Leaving coroutine." << LL_ENDL; + + } + +#else + class LLEventPollResponder : public LLHTTPClient::Responder + { + LOG_CLASS(LLEventPollResponder); + public: + + static LLHTTPClient::ResponderPtr start(const std::string& pollURL, const LLHost& sender); + void stop(); + + void makeRequest(); + + /* virtual */ void completedRaw(const LLChannelDescriptors& channels, + const LLIOPipe::buffer_ptr_t& buffer); + + private: + LLEventPollResponder(const std::string& pollURL, const LLHost& sender); + ~LLEventPollResponder(); + + + void handleMessage(const LLSD& content); + + /* virtual */ void httpFailure(); + /* virtual */ void httpSuccess(); + + private: + + bool mDone; + + std::string mPollURL; + std::string mSender; + + LLSD mAcknowledge; + + // these are only here for debugging so we can see which poller is which + static int sCount; + int mCount; + S32 mErrorCount; + }; + + class LLEventPollEventTimer : public LLEventTimer + { + typedef LLPointer EventPollResponderPtr; + + public: + LLEventPollEventTimer(F32 period, EventPollResponderPtr responder) + : LLEventTimer(period), mResponder(responder) + { } + + virtual BOOL tick() + { + mResponder->makeRequest(); + return TRUE; // Causes this instance to be deleted. + } + + private: + + EventPollResponderPtr mResponder; + }; + + //static + LLHTTPClient::ResponderPtr LLEventPollResponder::start( + const std::string& pollURL, const LLHost& sender) + { + LLHTTPClient::ResponderPtr result = new LLEventPollResponder(pollURL, sender); + LL_INFOS() << "LLEventPollResponder::start <" << sCount << "> " + << pollURL << LL_ENDL; + return result; + } + + void LLEventPollResponder::stop() + { + LL_INFOS() << "LLEventPollResponder::stop <" << mCount << "> " + << mPollURL << LL_ENDL; + // there should be a way to stop a LLHTTPClient request in progress + mDone = true; + } + + int LLEventPollResponder::sCount = 0; + + LLEventPollResponder::LLEventPollResponder(const std::string& pollURL, const LLHost& sender) + : mDone(false), + mPollURL(pollURL), + mCount(++sCount), + mErrorCount(0) + { + //extract host and port of simulator to set as sender + LLViewerRegion *regionp = gAgent.getRegion(); + if (!regionp) + { + LL_ERRS() << "LLEventPoll initialized before region is added." << LL_ENDL; + } + mSender = sender.getIPandPort(); + LL_INFOS() << "LLEventPoll initialized with sender " << mSender << LL_ENDL; + makeRequest(); + } + + LLEventPollResponder::~LLEventPollResponder() + { + stop(); + LL_DEBUGS() << "LLEventPollResponder::~Impl <" << mCount << "> " + << mPollURL << LL_ENDL; + } + + // virtual + void LLEventPollResponder::completedRaw(const LLChannelDescriptors& channels, + const LLIOPipe::buffer_ptr_t& buffer) + { + if (getStatus() == HTTP_BAD_GATEWAY) + { + // These errors are not parsable as LLSD, + // which LLHTTPClient::Responder::completedRaw will try to do. + httpCompleted(); + } + else + { + LLHTTPClient::Responder::completedRaw(channels,buffer); + } + } + + void LLEventPollResponder::makeRequest() + { + LLSD request; + request["ack"] = mAcknowledge; + request["done"] = mDone; + + LL_DEBUGS() << "LLEventPollResponder::makeRequest <" << mCount << "> ack = " + << LLSDXMLStreamer(mAcknowledge) << LL_ENDL; + LLHTTPClient::post(mPollURL, request, this); + } + + void LLEventPollResponder::handleMessage(const LLSD& content) + { + std::string msg_name = content["message"]; + LLSD message; + message["sender"] = mSender; + message["body"] = content["body"]; + LLMessageSystem::dispatch(msg_name, message); + } + + //virtual + void LLEventPollResponder::httpFailure() + { + if (mDone) return; + + // A HTTP_BAD_GATEWAY (502) error is our standard timeout response + // we get this when there are no events. + if ( getStatus() == HTTP_BAD_GATEWAY ) + { + mErrorCount = 0; + makeRequest(); + } + else if (mErrorCount < MAX_EVENT_POLL_HTTP_ERRORS) + { + ++mErrorCount; + + // The 'tick' will return TRUE causing the timer to delete this. + new LLEventPollEventTimer(EVENT_POLL_ERROR_RETRY_SECONDS + + mErrorCount * EVENT_POLL_ERROR_RETRY_SECONDS_INC + , this); + + LL_WARNS() << dumpResponse() << LL_ENDL; + } + else + { + LL_WARNS() << dumpResponse() + << " [count:" << mCount << "] " + << (mDone ? " -- done" : "") << LL_ENDL; + stop(); + + // At this point we have given up and the viewer will not receive HTTP messages from the simulator. + // IMs, teleports, about land, selecing land, region crossing and more will all fail. + // They are essentially disconnected from the region even though some things may still work. + // Since things won't get better until they relog we force a disconnect now. + + // *NOTE:Mani - The following condition check to see if this failing event poll + // is attached to the Agent's main region. If so we disconnect the viewer. + // Else... its a child region and we just leave the dead event poll stopped and + // continue running. + if(gAgent.getRegion() && gAgent.getRegion()->getHost().getIPandPort() == mSender) + { + LL_WARNS() << "Forcing disconnect due to stalled main region event poll." << LL_ENDL; + LLAppViewer::instance()->forceDisconnect(LLTrans::getString("AgentLostConnection")); + } + } + } + + //virtual + void LLEventPollResponder::httpSuccess() + { + LL_DEBUGS() << "LLEventPollResponder::result <" << mCount << ">" + << (mDone ? " -- done" : "") << LL_ENDL; + + if (mDone) return; + + mErrorCount = 0; + + const LLSD& content = getContent(); + if (!content.isMap() || + !content.get("events") || + !content.get("id")) + { + LL_WARNS() << "received event poll with no events or id key: " << dumpResponse() << LL_ENDL; + makeRequest(); + return; + } + + mAcknowledge = content["id"]; + LLSD events = content["events"]; + + if(mAcknowledge.isUndefined()) + { + LL_WARNS() << "LLEventPollResponder: id undefined" << LL_ENDL; + } + + // was LL_INFOS() but now that CoarseRegionUpdate is TCP @ 1/second, it'd be too verbose for viewer logs. -MG + LL_DEBUGS() << "LLEventPollResponder::httpSuccess <" << mCount << "> " << events.size() << "events (id " + << LLSDXMLStreamer(mAcknowledge) << ")" << LL_ENDL; + + LLSD::array_const_iterator i = events.beginArray(); + LLSD::array_const_iterator end = events.endArray(); + for (; i != end; ++i) + { + if (i->has("message")) + { + handleMessage(*i); + } + } + + makeRequest(); + } } LLEventPoll::LLEventPoll(const std::string& poll_url, const LLHost& sender) - : mImpl(LLEventPollResponder::start(poll_url, sender)) - { } + : mImpl(LLEventPollResponder::start(poll_url, sender)) +{ } LLEventPoll::~LLEventPoll() { - LLHTTPClient::Responder* responderp = mImpl.get(); - LLEventPollResponder* event_poll_responder = dynamic_cast(responderp); - if (event_poll_responder) event_poll_responder->stop(); + LLHTTPClient::Responder* responderp = mImpl.get(); + LLEventPollResponder* event_poll_responder = dynamic_cast(responderp); + if (event_poll_responder) event_poll_responder->stop(); +} +#endif +} + +LLEventPoll::LLEventPoll(const std::string& poll_url, const LLHost& sender): + mImpl() +{ + mImpl = boost::unique_ptr(new LLEventPollImpl(sender)); + mImpl->start(poll_url); +} + +LLEventPoll::~LLEventPoll() +{ + mImpl->stop(); + } diff --git a/indra/newview/lleventpoll.h b/indra/newview/lleventpoll.h index e8d98062aa..4b9944724d 100755 --- a/indra/newview/lleventpoll.h +++ b/indra/newview/lleventpoll.h @@ -28,9 +28,20 @@ #define LL_LLEVENTPOLL_H #include "llhttpclient.h" +#include "boost/move/unique_ptr.hpp" + +namespace boost +{ + using ::boost::movelib::unique_ptr; // move unique_ptr into the boost namespace. +} class LLHost; +namespace +{ + class LLEventPollImpl; +} + class LLEventPoll ///< implements the viewer side of server-to-viewer pushed events. @@ -40,11 +51,15 @@ public: ///< Start polling the URL. virtual ~LLEventPoll(); - ///< will stop polling, cancelling any poll in progress. + ///< will stop polling, canceling any poll in progress. private: +#if 1 + boost::unique_ptr mImpl; +#else LLHTTPClient::ResponderPtr mImpl; +#endif }; -- cgit v1.2.3 From 93382ee0c0c570e58b17af5f43f9738d773e8add Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 8 Apr 2015 14:29:37 -0700 Subject: Moved some LLEventPolling internal classes to a named namespace Canceling outstanding polling transactions --- indra/llmessage/llcorehttputil.cpp | 104 +++++++++++++++++++++---------------- indra/llmessage/llcorehttputil.h | 37 ++++++++----- indra/newview/lleventpoll.cpp | 50 ++++++++++++------ indra/newview/lleventpoll.h | 8 ++- 4 files changed, 124 insertions(+), 75 deletions(-) (limited to 'indra') diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index d560ec8462..dd9cb2032a 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -199,6 +199,12 @@ void HttpCoroHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRespons LLCore::HttpStatus status = response->getStatus(); + if (status == LLCore::HttpStatus(LLCore::HttpStatus::LLCORE, LLCore::HE_HANDLE_NOT_FOUND)) + { // A response came in for a canceled request and we have not processed the + // cancel yet. Patience! + return; + } + if (!status) { result = LLSD::emptyMap(); @@ -290,6 +296,14 @@ void HttpCoroHandler::writeStatusCodes(LLCore::HttpStatus status, const std::str } +LLCore::HttpStatus HttpCoroHandler::getStatusFromLLSD(const LLSD &httpResults) +{ + LLCore::HttpStatus::type_enum_t type = static_cast(httpResults["type"].asInteger()); + short code = static_cast(httpResults["status"].asInteger()); + + return LLCore::HttpStatus(type, code); +} + //======================================================================== HttpRequestPumper::HttpRequestPumper(const LLCore::HttpRequest::ptr_t &request) : mHttpRequest(request) @@ -308,7 +322,10 @@ HttpRequestPumper::~HttpRequestPumper() bool HttpRequestPumper::pollRequest(const LLSD&) { - mHttpRequest->update(0L); + if (mHttpRequest->getStatus() != HttpStatus(HttpStatus::LLCORE, HE_OP_CANCELED)) + { + mHttpRequest->update(0L); + } return false; } @@ -319,29 +336,20 @@ HttpCoroutineAdapter::HttpCoroutineAdapter(const std::string &name, mPolicyId(policyId), mPriority(priority), mYieldingHandle(LLCORE_HTTP_HANDLE_INVALID), - mWeakRequest() + mWeakRequest(), + mWeakHandler() { } HttpCoroutineAdapter::~HttpCoroutineAdapter() { - + cancelYieldingOperation(); } LLSD HttpCoroutineAdapter::postAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, const std::string & url, const LLSD & body, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { - if (!options) - { - options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false); - } - - if (!headers) - { - headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false); - } - LLEventStream replyPump(mAdapterName, true); LLCoreHttpUtil::HttpCoroHandler::ptr_t httpHandler = LLCoreHttpUtil::HttpCoroHandler::ptr_t(new LLCoreHttpUtil::HttpCoroHandler(replyPump)); @@ -356,12 +364,13 @@ LLSD HttpCoroutineAdapter::postAndYield(LLCoros::self & self, LLCore::HttpReques if (hhandle == LLCORE_HTTP_HANDLE_INVALID) { - return HttpCoroutineAdapter::buildImmediateErrorResult(request, url, httpHandler); + return HttpCoroutineAdapter::buildImmediateErrorResult(request, url); } - mYieldingHandle = hhandle; + saveState(hhandle, request, httpHandler); LLSD results = waitForEventOn(self, replyPump); - mYieldingHandle = LLCORE_HTTP_HANDLE_INVALID; + cleanState(); + //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; } @@ -370,16 +379,6 @@ LLSD HttpCoroutineAdapter::putAndYield(LLCoros::self & self, LLCore::HttpRequest const std::string & url, const LLSD & body, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { - if (!options) - { - options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false); - } - - if (!headers) - { - headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false); - } - LLEventStream replyPump(mAdapterName, true); LLCoreHttpUtil::HttpCoroHandler::ptr_t httpHandler = LLCoreHttpUtil::HttpCoroHandler::ptr_t(new LLCoreHttpUtil::HttpCoroHandler(replyPump)); @@ -394,12 +393,12 @@ LLSD HttpCoroutineAdapter::putAndYield(LLCoros::self & self, LLCore::HttpRequest if (hhandle == LLCORE_HTTP_HANDLE_INVALID) { - return HttpCoroutineAdapter::buildImmediateErrorResult(request, url, httpHandler); + return HttpCoroutineAdapter::buildImmediateErrorResult(request, url); } - mYieldingHandle = hhandle; + saveState(hhandle, request, httpHandler); LLSD results = waitForEventOn(self, replyPump); - mYieldingHandle = LLCORE_HTTP_HANDLE_INVALID; + cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; } @@ -408,16 +407,6 @@ LLSD HttpCoroutineAdapter::getAndYield(LLCoros::self & self, LLCore::HttpRequest const std::string & url, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { - if (!options) - { - options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false); - } - - if (!headers) - { - headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false); - } - LLEventStream replyPump(mAdapterName + "Reply", true); LLCoreHttpUtil::HttpCoroHandler::ptr_t httpHandler = LLCoreHttpUtil::HttpCoroHandler::ptr_t(new LLCoreHttpUtil::HttpCoroHandler(replyPump)); @@ -431,18 +420,45 @@ LLSD HttpCoroutineAdapter::getAndYield(LLCoros::self & self, LLCore::HttpRequest if (hhandle == LLCORE_HTTP_HANDLE_INVALID) { - return HttpCoroutineAdapter::buildImmediateErrorResult(request, url, httpHandler); + return HttpCoroutineAdapter::buildImmediateErrorResult(request, url); } - mYieldingHandle = hhandle; + saveState(hhandle, request, httpHandler); LLSD results = waitForEventOn(self, replyPump); - mYieldingHandle = LLCORE_HTTP_HANDLE_INVALID; + cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; } +void HttpCoroutineAdapter::cancelYieldingOperation() +{ + LLCore::HttpRequest::ptr_t request = mWeakRequest.lock(); + HttpCoroHandler::ptr_t handler = mWeakHandler.lock(); + if ((request) && (handler) && (mYieldingHandle != LLCORE_HTTP_HANDLE_INVALID)) + { + cleanState(); + LL_INFOS() << "Canceling yielding request!" << LL_ENDL; + request->requestCancel(mYieldingHandle, handler.get()); + } +} + +void HttpCoroutineAdapter::saveState(LLCore::HttpHandle yieldingHandle, + LLCore::HttpRequest::ptr_t &request, HttpCoroHandler::ptr_t &handler) +{ + mWeakRequest = request; + mWeakHandler = handler; + mYieldingHandle = yieldingHandle; +} + +void HttpCoroutineAdapter::cleanState() +{ + mWeakRequest.reset(); + mWeakHandler.reset(); + mYieldingHandle = LLCORE_HTTP_HANDLE_INVALID; +} + LLSD HttpCoroutineAdapter::buildImmediateErrorResult(const LLCore::HttpRequest::ptr_t &request, - const std::string &url, LLCoreHttpUtil::HttpCoroHandler::ptr_t &httpHandler) + const std::string &url) { LLCore::HttpStatus status = request->getStatus(); LL_WARNS() << "Error posting to " << url << " Status=" << status.getStatus() << @@ -452,7 +468,7 @@ LLSD HttpCoroutineAdapter::buildImmediateErrorResult(const LLCore::HttpRequest:: // to wait on LLSD httpresults = LLSD::emptyMap(); - httpHandler->writeStatusCodes(status, url, httpresults); + HttpCoroHandler::writeStatusCodes(status, url, httpresults); LLSD errorres = LLSD::emptyMap(); errorres["http_result"] = httpresults; diff --git a/indra/llmessage/llcorehttputil.h b/indra/llmessage/llcorehttputil.h index 33cc389c49..471710f61b 100644 --- a/indra/llmessage/llcorehttputil.h +++ b/indra/llmessage/llcorehttputil.h @@ -170,13 +170,16 @@ LLCore::HttpHandle requestPutWithLLSD(LLCore::HttpRequest::ptr_t & request, class HttpCoroHandler : public LLCore::HttpHandler { public: + typedef boost::shared_ptr ptr_t; + typedef boost::weak_ptr wptr_t; + HttpCoroHandler(LLEventStream &reply); virtual void onCompleted(LLCore::HttpHandle handle, LLCore::HttpResponse * response); - typedef boost::shared_ptr ptr_t; + static void writeStatusCodes(LLCore::HttpStatus status, const std::string &url, LLSD &result); + static LLCore::HttpStatus getStatusFromLLSD(const LLSD &httpResults); - void writeStatusCodes(LLCore::HttpStatus status, const std::string &url, LLSD &result); private: void buildStatusEntry(LLCore::HttpResponse *response, LLCore::HttpStatus status, LLSD &result); @@ -219,7 +222,8 @@ public: /// Execute a Post transaction on the supplied URL and yield execution of /// the coroutine until a result is available. - /// Note: the request's smart pointer is passed by value so that it will + /// + /// @Note: the request's smart pointer is passed by value so that it will /// not be deallocated during the yield. LLSD postAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, const std::string & url, const LLSD & body, @@ -228,28 +232,34 @@ public: /// Execute a Put transaction on the supplied URL and yield execution of /// the coroutine until a result is available. - /// Note: the request's smart pointer is passed by value so that it will + /// + /// @Note: the request's smart pointer is passed by value so that it will /// not be deallocated during the yield. LLSD putAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, const std::string & url, const LLSD & body, - LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(), - LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t()); + LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false), + LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false)); /// Execute a Get transaction on the supplied URL and yield execution of /// the coroutine until a result is available. - /// Note: the request's smart pointer is passed by value so that it will + /// + /// @Note: the request's smart pointer is passed by value so that it will /// not be deallocated during the yield. LLSD getAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, const std::string & url, - LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(), - LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t()); + LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false), + LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false)); /// void cancelYieldingOperation(); private: - static LLSD buildImmediateErrorResult(const LLCore::HttpRequest::ptr_t &request, - const std::string &url, LLCoreHttpUtil::HttpCoroHandler::ptr_t &httpHandler); + static LLSD buildImmediateErrorResult(const LLCore::HttpRequest::ptr_t &request, const std::string &url); + + void saveState(LLCore::HttpHandle yieldingHandle, LLCore::HttpRequest::ptr_t &request, + HttpCoroHandler::ptr_t &handler); + void cleanState(); + std::string mAdapterName; LLCore::HttpRequest::priority_t mPriority; @@ -257,9 +267,12 @@ private: LLCore::HttpHandle mYieldingHandle; LLCore::HttpRequest::wptr_t mWeakRequest; - + HttpCoroHandler::wptr_t mWeakHandler; }; +//------------------------------------------------------------------------- +LLCore::HttpStatus getStatusFromLLSD(const LLSD &httpResults); + } // end namespace LLCoreHttpUtil #endif // LL_LLCOREHTTPUTIL_H diff --git a/indra/newview/lleventpoll.cpp b/indra/newview/lleventpoll.cpp index 493ee06083..625bbfae0c 100755 --- a/indra/newview/lleventpoll.cpp +++ b/indra/newview/lleventpoll.cpp @@ -41,9 +41,11 @@ #include "lleventcoro.h" #include "llcorehttputil.h" -namespace +namespace LLEventPolling { - // We will wait RETRY_SECONDS + (errorCount * RETRY_SECONDS_INC) before retrying after an error. +namespace Details +{ + // We will wait RETRY_SECONDS + (errorCount * RETRY_SECONDS_INC) before retrying after an error. // This means we attempt to recover relatively quickly but back off giving more time to recover // until we finally give up after MAX_EVENT_POLL_HTTP_ERRORS attempts. const F32 EVENT_POLL_ERROR_RETRY_SECONDS = 15.f; // ~ half of a normal timeout. @@ -69,6 +71,7 @@ namespace LLCore::HttpRequest::policy_t mHttpPolicy; std::string mSenderIp; int mCounter; + LLCoreHttpUtil::HttpCoroutineAdapter::wptr_t mAdapter; static int sNextCounter; }; @@ -105,24 +108,33 @@ namespace std::string coroname = LLCoros::instance().launch("LLAccountingCostManager::accountingCostCoro", boost::bind(&LLEventPollImpl::eventPollCoro, this, _1, url)); - LL_DEBUGS() << coroname << " with url '" << url << LL_ENDL; + LL_INFOS() << coroname << " with url '" << url << LL_ENDL; } } void LLEventPollImpl::stop() { + LL_INFOS() << "requesting stop for event poll coroutine <" << mCounter << ">" << LL_ENDL; mDone = true; + + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t adapter = mAdapter.lock(); + if (adapter) + { + // cancel the yielding operation if any. + adapter->cancelYieldingOperation(); + } } void LLEventPollImpl::eventPollCoro(LLCoros::self& self, std::string url) { - LLCoreHttpUtil::HttpCoroutineAdapter httpAdapter("EventPoller", mHttpPolicy); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("EventPoller", mHttpPolicy)); LLSD acknowledge; int errorCount = 0; int counter = mCounter; // saved on the stack for debugging. LL_INFOS("LLEventPollImpl::eventPollCoro") << " <" << counter << "> entering coroutine." << LL_ENDL; + mAdapter = httpAdapter; while (!mDone) { LLSD request; @@ -132,33 +144,35 @@ namespace // LL_DEBUGS("LLEventPollImpl::eventPollCoro") << "<" << counter << "> request = " // << LLSDXMLStreamer(request) << LL_ENDL; - LL_INFOS("LLEventPollImpl::eventPollCoro") << " <" << counter << "> posting and yielding." << LL_ENDL; - LLSD result = httpAdapter.postAndYield(self, mHttpRequest, url, request); + LL_DEBUGS("LLEventPollImpl::eventPollCoro") << " <" << counter << "> posting and yielding." << LL_ENDL; + LLSD result = httpAdapter->postAndYield(self, mHttpRequest, url, request); // LL_DEBUGS("LLEventPollImpl::eventPollCoro") << "<" << counter << "> result = " // << LLSDXMLStreamer(result) << LL_ENDL; - if (mDone) - break; - LLSD httpResults; httpResults = result["http_result"]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); - - if (!httpResults["success"].asBoolean()) + if (!status) { - LL_WARNS("LLEventPollImpl::eventPollCoro") << "<" << counter << "> Error result from LLCoreHttpUtil::HttpCoroHandler. Code " - << httpResults["status"] << ": '" << httpResults["message"] << "'" << LL_ENDL; - if (httpResults["status"].asInteger() == HTTP_BAD_GATEWAY) + if (status == LLCore::HttpStatus(HTTP_BAD_GATEWAY)) { // A HTTP_BAD_GATEWAY (502) error is our standard timeout response // we get this when there are no events. errorCount = 0; continue; } - - LL_WARNS("LLEventPollImpl::eventPollCoro") << "<" << counter << "> " << LLSDXMLStreamer(result) << (mDone ? " -- done" : "") << LL_ENDL; + + if ((status == LLCore::HttpStatus(LLCore::HttpStatus::LLCORE, LLCore::HE_OP_CANCELED)) || + (status == LLCore::HttpStatus(HTTP_NOT_FOUND))) + { + LL_WARNS() << "Canceling coroutine" << LL_ENDL; + break; + } + LL_WARNS("LLEventPollImpl::eventPollCoro") << "<" << counter << "> Error result from LLCoreHttpUtil::HttpCoroHandler. Code " + << status.toTerseString() << ": '" << httpResults["message"] << "'" << LL_ENDL; if (errorCount < MAX_EVENT_POLL_HTTP_ERRORS) { @@ -481,11 +495,13 @@ LLEventPoll::~LLEventPoll() } #endif } +} LLEventPoll::LLEventPoll(const std::string& poll_url, const LLHost& sender): mImpl() { - mImpl = boost::unique_ptr(new LLEventPollImpl(sender)); + mImpl = boost::unique_ptr + (new LLEventPolling::Details::LLEventPollImpl(sender)); mImpl->start(poll_url); } diff --git a/indra/newview/lleventpoll.h b/indra/newview/lleventpoll.h index 4b9944724d..0be48be6b4 100755 --- a/indra/newview/lleventpoll.h +++ b/indra/newview/lleventpoll.h @@ -37,10 +37,13 @@ namespace boost class LLHost; -namespace +namespace LLEventPolling +{ +namespace Details { class LLEventPollImpl; } +} class LLEventPoll @@ -56,7 +59,8 @@ public: private: #if 1 - boost::unique_ptr mImpl; + boost::unique_ptr mImpl; + #else LLHTTPClient::ResponderPtr mImpl; #endif -- cgit v1.2.3 From 9965e13e83e30065ba01f936153d9a82326f1685 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 8 Apr 2015 15:54:34 -0700 Subject: Added timeout on failure. --- indra/newview/lleventpoll.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'indra') diff --git a/indra/newview/lleventpoll.cpp b/indra/newview/lleventpoll.cpp index 625bbfae0c..bf07e1b4ab 100755 --- a/indra/newview/lleventpoll.cpp +++ b/indra/newview/lleventpoll.cpp @@ -40,6 +40,7 @@ #include "llcoros.h" #include "lleventcoro.h" #include "llcorehttputil.h" +#include "lleventfilter.h" namespace LLEventPolling { @@ -164,8 +165,7 @@ namespace Details errorCount = 0; continue; } - - if ((status == LLCore::HttpStatus(LLCore::HttpStatus::LLCORE, LLCore::HE_OP_CANCELED)) || + else if ((status == LLCore::HttpStatus(LLCore::HttpStatus::LLCORE, LLCore::HE_OP_CANCELED)) || (status == LLCore::HttpStatus(HTTP_NOT_FOUND))) { LL_WARNS() << "Canceling coroutine" << LL_ENDL; @@ -178,16 +178,18 @@ namespace Details { ++errorCount; - // The 'tick' will return TRUE causing the timer to delete this. int waitToRetry = EVENT_POLL_ERROR_RETRY_SECONDS + errorCount * EVENT_POLL_ERROR_RETRY_SECONDS_INC; - LL_WARNS() << "Retrying in " << waitToRetry << - " seconds, error count is now " << errorCount << LL_ENDL; - - // *TODO: Wait for a timeout here - // new LLEventPollEventTimer( - // , this); + { + LL_WARNS() << "<" << counter << "> Retrying in " << waitToRetry << + " seconds, error count is now " << errorCount << LL_ENDL; + LLEventTimeout timeout; + timeout.eventAfter(waitToRetry, LLSD()); + waitForEventOn(self, timeout); + } + if (mDone) + break; continue; } else -- cgit v1.2.3 From 6aa2812fad7746d5072c8b16311872666624a33d Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 8 Apr 2015 15:56:25 -0700 Subject: Removed dead code --- indra/newview/lleventpoll.cpp | 245 ------------------------------------------ indra/newview/lleventpoll.h | 5 - 2 files changed, 250 deletions(-) (limited to 'indra') diff --git a/indra/newview/lleventpoll.cpp b/indra/newview/lleventpoll.cpp index bf07e1b4ab..5cd99a83b7 100755 --- a/indra/newview/lleventpoll.cpp +++ b/indra/newview/lleventpoll.cpp @@ -53,8 +53,6 @@ namespace Details const F32 EVENT_POLL_ERROR_RETRY_SECONDS_INC = 5.f; // ~ half of a normal timeout. const S32 MAX_EVENT_POLL_HTTP_ERRORS = 10; // ~5 minutes, by the above rules. -#if 1 - class LLEventPollImpl { public: @@ -253,249 +251,6 @@ namespace Details } -#else - class LLEventPollResponder : public LLHTTPClient::Responder - { - LOG_CLASS(LLEventPollResponder); - public: - - static LLHTTPClient::ResponderPtr start(const std::string& pollURL, const LLHost& sender); - void stop(); - - void makeRequest(); - - /* virtual */ void completedRaw(const LLChannelDescriptors& channels, - const LLIOPipe::buffer_ptr_t& buffer); - - private: - LLEventPollResponder(const std::string& pollURL, const LLHost& sender); - ~LLEventPollResponder(); - - - void handleMessage(const LLSD& content); - - /* virtual */ void httpFailure(); - /* virtual */ void httpSuccess(); - - private: - - bool mDone; - - std::string mPollURL; - std::string mSender; - - LLSD mAcknowledge; - - // these are only here for debugging so we can see which poller is which - static int sCount; - int mCount; - S32 mErrorCount; - }; - - class LLEventPollEventTimer : public LLEventTimer - { - typedef LLPointer EventPollResponderPtr; - - public: - LLEventPollEventTimer(F32 period, EventPollResponderPtr responder) - : LLEventTimer(period), mResponder(responder) - { } - - virtual BOOL tick() - { - mResponder->makeRequest(); - return TRUE; // Causes this instance to be deleted. - } - - private: - - EventPollResponderPtr mResponder; - }; - - //static - LLHTTPClient::ResponderPtr LLEventPollResponder::start( - const std::string& pollURL, const LLHost& sender) - { - LLHTTPClient::ResponderPtr result = new LLEventPollResponder(pollURL, sender); - LL_INFOS() << "LLEventPollResponder::start <" << sCount << "> " - << pollURL << LL_ENDL; - return result; - } - - void LLEventPollResponder::stop() - { - LL_INFOS() << "LLEventPollResponder::stop <" << mCount << "> " - << mPollURL << LL_ENDL; - // there should be a way to stop a LLHTTPClient request in progress - mDone = true; - } - - int LLEventPollResponder::sCount = 0; - - LLEventPollResponder::LLEventPollResponder(const std::string& pollURL, const LLHost& sender) - : mDone(false), - mPollURL(pollURL), - mCount(++sCount), - mErrorCount(0) - { - //extract host and port of simulator to set as sender - LLViewerRegion *regionp = gAgent.getRegion(); - if (!regionp) - { - LL_ERRS() << "LLEventPoll initialized before region is added." << LL_ENDL; - } - mSender = sender.getIPandPort(); - LL_INFOS() << "LLEventPoll initialized with sender " << mSender << LL_ENDL; - makeRequest(); - } - - LLEventPollResponder::~LLEventPollResponder() - { - stop(); - LL_DEBUGS() << "LLEventPollResponder::~Impl <" << mCount << "> " - << mPollURL << LL_ENDL; - } - - // virtual - void LLEventPollResponder::completedRaw(const LLChannelDescriptors& channels, - const LLIOPipe::buffer_ptr_t& buffer) - { - if (getStatus() == HTTP_BAD_GATEWAY) - { - // These errors are not parsable as LLSD, - // which LLHTTPClient::Responder::completedRaw will try to do. - httpCompleted(); - } - else - { - LLHTTPClient::Responder::completedRaw(channels,buffer); - } - } - - void LLEventPollResponder::makeRequest() - { - LLSD request; - request["ack"] = mAcknowledge; - request["done"] = mDone; - - LL_DEBUGS() << "LLEventPollResponder::makeRequest <" << mCount << "> ack = " - << LLSDXMLStreamer(mAcknowledge) << LL_ENDL; - LLHTTPClient::post(mPollURL, request, this); - } - - void LLEventPollResponder::handleMessage(const LLSD& content) - { - std::string msg_name = content["message"]; - LLSD message; - message["sender"] = mSender; - message["body"] = content["body"]; - LLMessageSystem::dispatch(msg_name, message); - } - - //virtual - void LLEventPollResponder::httpFailure() - { - if (mDone) return; - - // A HTTP_BAD_GATEWAY (502) error is our standard timeout response - // we get this when there are no events. - if ( getStatus() == HTTP_BAD_GATEWAY ) - { - mErrorCount = 0; - makeRequest(); - } - else if (mErrorCount < MAX_EVENT_POLL_HTTP_ERRORS) - { - ++mErrorCount; - - // The 'tick' will return TRUE causing the timer to delete this. - new LLEventPollEventTimer(EVENT_POLL_ERROR_RETRY_SECONDS - + mErrorCount * EVENT_POLL_ERROR_RETRY_SECONDS_INC - , this); - - LL_WARNS() << dumpResponse() << LL_ENDL; - } - else - { - LL_WARNS() << dumpResponse() - << " [count:" << mCount << "] " - << (mDone ? " -- done" : "") << LL_ENDL; - stop(); - - // At this point we have given up and the viewer will not receive HTTP messages from the simulator. - // IMs, teleports, about land, selecing land, region crossing and more will all fail. - // They are essentially disconnected from the region even though some things may still work. - // Since things won't get better until they relog we force a disconnect now. - - // *NOTE:Mani - The following condition check to see if this failing event poll - // is attached to the Agent's main region. If so we disconnect the viewer. - // Else... its a child region and we just leave the dead event poll stopped and - // continue running. - if(gAgent.getRegion() && gAgent.getRegion()->getHost().getIPandPort() == mSender) - { - LL_WARNS() << "Forcing disconnect due to stalled main region event poll." << LL_ENDL; - LLAppViewer::instance()->forceDisconnect(LLTrans::getString("AgentLostConnection")); - } - } - } - - //virtual - void LLEventPollResponder::httpSuccess() - { - LL_DEBUGS() << "LLEventPollResponder::result <" << mCount << ">" - << (mDone ? " -- done" : "") << LL_ENDL; - - if (mDone) return; - - mErrorCount = 0; - - const LLSD& content = getContent(); - if (!content.isMap() || - !content.get("events") || - !content.get("id")) - { - LL_WARNS() << "received event poll with no events or id key: " << dumpResponse() << LL_ENDL; - makeRequest(); - return; - } - - mAcknowledge = content["id"]; - LLSD events = content["events"]; - - if(mAcknowledge.isUndefined()) - { - LL_WARNS() << "LLEventPollResponder: id undefined" << LL_ENDL; - } - - // was LL_INFOS() but now that CoarseRegionUpdate is TCP @ 1/second, it'd be too verbose for viewer logs. -MG - LL_DEBUGS() << "LLEventPollResponder::httpSuccess <" << mCount << "> " << events.size() << "events (id " - << LLSDXMLStreamer(mAcknowledge) << ")" << LL_ENDL; - - LLSD::array_const_iterator i = events.beginArray(); - LLSD::array_const_iterator end = events.endArray(); - for (; i != end; ++i) - { - if (i->has("message")) - { - handleMessage(*i); - } - } - - makeRequest(); - } -} - -LLEventPoll::LLEventPoll(const std::string& poll_url, const LLHost& sender) - : mImpl(LLEventPollResponder::start(poll_url, sender)) -{ } - -LLEventPoll::~LLEventPoll() -{ - LLHTTPClient::Responder* responderp = mImpl.get(); - LLEventPollResponder* event_poll_responder = dynamic_cast(responderp); - if (event_poll_responder) event_poll_responder->stop(); -} -#endif } } diff --git a/indra/newview/lleventpoll.h b/indra/newview/lleventpoll.h index 0be48be6b4..e32b4ed322 100755 --- a/indra/newview/lleventpoll.h +++ b/indra/newview/lleventpoll.h @@ -58,12 +58,7 @@ public: private: -#if 1 boost::unique_ptr mImpl; - -#else - LLHTTPClient::ResponderPtr mImpl; -#endif }; -- cgit v1.2.3 From fb082a185d9988a5ced8b92c9d2a89e24739cbcf Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 8 Apr 2015 17:25:01 -0700 Subject: Couple of cleanup items. Switch to Long poll HTTP policy for event polling. --- indra/newview/lleventpoll.cpp | 62 ++++++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 27 deletions(-) (limited to 'indra') diff --git a/indra/newview/lleventpoll.cpp b/indra/newview/lleventpoll.cpp index 5cd99a83b7..a35140a6a7 100755 --- a/indra/newview/lleventpoll.cpp +++ b/indra/newview/lleventpoll.cpp @@ -46,12 +46,6 @@ namespace LLEventPolling { namespace Details { - // We will wait RETRY_SECONDS + (errorCount * RETRY_SECONDS_INC) before retrying after an error. - // This means we attempt to recover relatively quickly but back off giving more time to recover - // until we finally give up after MAX_EVENT_POLL_HTTP_ERRORS attempts. - const F32 EVENT_POLL_ERROR_RETRY_SECONDS = 15.f; // ~ half of a normal timeout. - const F32 EVENT_POLL_ERROR_RETRY_SECONDS_INC = 5.f; // ~ half of a normal timeout. - const S32 MAX_EVENT_POLL_HTTP_ERRORS = 10; // ~5 minutes, by the above rules. class LLEventPollImpl { @@ -60,7 +54,15 @@ namespace Details void start(const std::string &url); void stop(); + private: + // We will wait RETRY_SECONDS + (errorCount * RETRY_SECONDS_INC) before retrying after an error. + // This means we attempt to recover relatively quickly but back off giving more time to recover + // until we finally give up after MAX_EVENT_POLL_HTTP_ERRORS attempts. + static const F32 EVENT_POLL_ERROR_RETRY_SECONDS; + static const F32 EVENT_POLL_ERROR_RETRY_SECONDS_INC; + static const S32 MAX_EVENT_POLL_HTTP_ERRORS; + void eventPollCoro(LLCoros::self& self, std::string url); void handleMessage(const LLSD &content); @@ -76,6 +78,10 @@ namespace Details }; + const F32 LLEventPollImpl::EVENT_POLL_ERROR_RETRY_SECONDS = 15.f; // ~ half of a normal timeout. + const F32 LLEventPollImpl::EVENT_POLL_ERROR_RETRY_SECONDS_INC = 5.f; // ~ half of a normal timeout. + const S32 LLEventPollImpl::MAX_EVENT_POLL_HTTP_ERRORS = 10; // ~5 minutes, by the above rules. + int LLEventPollImpl::sNextCounter = 1; @@ -87,7 +93,10 @@ namespace Details mCounter(sNextCounter++) { + LLAppCoreHttp & app_core_http(LLAppViewer::instance()->getAppCoreHttp()); + mHttpRequest = LLCore::HttpRequest::ptr_t(new LLCore::HttpRequest); + mHttpPolicy = app_core_http.getPolicy(LLAppCoreHttp::AP_LONG_POLL); mSenderIp = sender.getIPandPort(); } @@ -105,9 +114,9 @@ namespace Details if (!url.empty()) { std::string coroname = - LLCoros::instance().launch("LLAccountingCostManager::accountingCostCoro", + LLCoros::instance().launch("LLEventPollImpl::eventPollCoro", boost::bind(&LLEventPollImpl::eventPollCoro, this, _1, url)); - LL_INFOS() << coroname << " with url '" << url << LL_ENDL; + LL_INFOS("LLEventPollImpl") << coroname << " with url '" << url << LL_ENDL; } } @@ -131,7 +140,7 @@ namespace Details int errorCount = 0; int counter = mCounter; // saved on the stack for debugging. - LL_INFOS("LLEventPollImpl::eventPollCoro") << " <" << counter << "> entering coroutine." << LL_ENDL; + LL_INFOS("LLEventPollImpl") << " <" << counter << "> entering coroutine." << LL_ENDL; mAdapter = httpAdapter; while (!mDone) @@ -140,14 +149,14 @@ namespace Details request["ack"] = acknowledge; request["done"] = mDone; -// LL_DEBUGS("LLEventPollImpl::eventPollCoro") << "<" << counter << "> request = " -// << LLSDXMLStreamer(request) << LL_ENDL; +// LL_DEBUGS("LLEventPollImpl::eventPollCoro") << "<" << counter << "> request = " +// << LLSDXMLStreamer(request) << LL_ENDL; - LL_DEBUGS("LLEventPollImpl::eventPollCoro") << " <" << counter << "> posting and yielding." << LL_ENDL; + LL_DEBUGS("LLEventPollImpl") << " <" << counter << "> posting and yielding." << LL_ENDL; LLSD result = httpAdapter->postAndYield(self, mHttpRequest, url, request); -// LL_DEBUGS("LLEventPollImpl::eventPollCoro") << "<" << counter << "> result = " -// << LLSDXMLStreamer(result) << LL_ENDL; +// LL_DEBUGS("LLEventPollImpl::eventPollCoro") << "<" << counter << "> result = " +// << LLSDXMLStreamer(result) << LL_ENDL; LLSD httpResults; httpResults = result["http_result"]; @@ -169,25 +178,28 @@ namespace Details LL_WARNS() << "Canceling coroutine" << LL_ENDL; break; } - LL_WARNS("LLEventPollImpl::eventPollCoro") << "<" << counter << "> Error result from LLCoreHttpUtil::HttpCoroHandler. Code " + LL_WARNS("LLEventPollImpl") << "<" << counter << "> Error result from LLCoreHttpUtil::HttpCoroHandler. Code " << status.toTerseString() << ": '" << httpResults["message"] << "'" << LL_ENDL; if (errorCount < MAX_EVENT_POLL_HTTP_ERRORS) { ++errorCount; - int waitToRetry = EVENT_POLL_ERROR_RETRY_SECONDS + F32 waitToRetry = EVENT_POLL_ERROR_RETRY_SECONDS + errorCount * EVENT_POLL_ERROR_RETRY_SECONDS_INC; + LL_WARNS("LLEventPollImpl") << "<" << counter << "> Retrying in " << waitToRetry << + " seconds, error count is now " << errorCount << LL_ENDL; + { - LL_WARNS() << "<" << counter << "> Retrying in " << waitToRetry << - " seconds, error count is now " << errorCount << LL_ENDL; LLEventTimeout timeout; timeout.eventAfter(waitToRetry, LLSD()); waitForEventOn(self, timeout); } if (mDone) break; + LL_INFOS("LLEventPollImpl") << "<" << counter << "> About to retry request." << LL_ENDL; + continue; } else @@ -205,23 +217,20 @@ namespace Details // continue running. if (gAgent.getRegion() && gAgent.getRegion()->getHost().getIPandPort() == mSenderIp) { - LL_WARNS("LLEventPollImpl::eventPollCoro") << "< " << counter << "> Forcing disconnect due to stalled main region event poll." << LL_ENDL; + LL_WARNS("LLEventPollImpl") << "< " << counter << "> Forcing disconnect due to stalled main region event poll." << LL_ENDL; LLAppViewer::instance()->forceDisconnect(LLTrans::getString("AgentLostConnection")); } break; } } - LL_DEBUGS("LLEventPollImpl::eventPollCoro") << " <" << counter << ">" - << (mDone ? " -- done" : "") << LL_ENDL; - errorCount = 0; if (!result.isMap() || !result.get("events") || !result.get("id")) { - LL_WARNS("LLEventPollImpl::eventPollCoro") << " <" << counter << "> received event poll with no events or id key: " << LLSDXMLStreamer(result) << LL_ENDL; + LL_WARNS("LLEventPollImpl") << " <" << counter << "> received event poll with no events or id key: " << LLSDXMLStreamer(result) << LL_ENDL; continue; } @@ -230,12 +239,11 @@ namespace Details if (acknowledge.isUndefined()) { - LL_WARNS("LLEventPollImpl::eventPollCoro") << " id undefined" << LL_ENDL; + LL_WARNS("LLEventPollImpl") << " id undefined" << LL_ENDL; } // was LL_INFOS() but now that CoarseRegionUpdate is TCP @ 1/second, it'd be too verbose for viewer logs. -MG - LL_DEBUGS() << "LLEventPollResponder::httpSuccess <" << counter << "> " << events.size() << "events (id " - << LLSDXMLStreamer(acknowledge) << ")" << LL_ENDL; + LL_DEBUGS("LLEventPollImpl") << " <" << counter << "> " << events.size() << "events (id " << LLSDXMLStreamer(acknowledge) << ")" << LL_ENDL; LLSD::array_const_iterator i = events.beginArray(); LLSD::array_const_iterator end = events.endArray(); @@ -247,7 +255,7 @@ namespace Details } } } - LL_INFOS("LLEventPollImpl::eventPollCoro") << " <" << counter << "> Leaving coroutine." << LL_ENDL; + LL_INFOS("LLEventPollImpl") << " <" << counter << "> Leaving coroutine." << LL_ENDL; } -- cgit v1.2.3 From e28a5b6eadd4c38498665b44f1c7e197615139f2 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 9 Apr 2015 16:46:41 -0700 Subject: Added LL_WARNS_IF to llerror.h If the coro is given something other than a map from the http then move the return into a body section. Changed windlight to use a coroutine and the new LLCore::Http libarary. Extra comments into Event Polling. --- indra/llcommon/llerror.h | 1 + indra/llmessage/llcorehttputil.cpp | 11 +- indra/newview/lleventpoll.cpp | 47 ++++---- indra/newview/llwlhandlers.cpp | 215 ++++++++++++++++++++++--------------- indra/newview/llwlhandlers.h | 20 ++-- 5 files changed, 168 insertions(+), 126 deletions(-) (limited to 'indra') diff --git a/indra/llcommon/llerror.h b/indra/llcommon/llerror.h index 63040e1772..b1b5e9be7d 100755 --- a/indra/llcommon/llerror.h +++ b/indra/llcommon/llerror.h @@ -354,6 +354,7 @@ typedef LLError::NoClassInfo _LL_CLASS_TO_LOG; #define LL_WARNS(...) lllog(LLError::LEVEL_WARN, false, ##__VA_ARGS__) #define LL_ERRS(...) lllog(LLError::LEVEL_ERROR, false, ##__VA_ARGS__) // alternative to llassert_always that prints explanatory message +#define LL_WARNS_IF(exp, ...) if (exp) LL_WARNS(##__VA_ARGS__) << "(" #exp ")" #define LL_ERRS_IF(exp, ...) if (exp) LL_ERRS(##__VA_ARGS__) << "(" #exp ")" // Only print the log message once (good for warnings or infos that would otherwise diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index dd9cb2032a..a32c4cad22 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -241,12 +241,19 @@ void HttpCoroHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRespons } if (result.isUndefined()) - { - // If we've gotten to this point and the result LLSD is still undefined + { // If we've gotten to this point and the result LLSD is still undefined // either there was an issue deserializing the body or the response was // blank. Create an empty map to hold the result either way. result = LLSD::emptyMap(); } + else if (!result.isMap()) + { // The results are not themselves a map. Move them down so that + // this method can return a map to the caller. + // *TODO: Should it always do this? + LLSD newResult = LLSD::emptyMap(); + newResult["content"] = result; + result = newResult; + } } buildStatusEntry(response, status, result); diff --git a/indra/newview/lleventpoll.cpp b/indra/newview/lleventpoll.cpp index a35140a6a7..25504e7cbf 100755 --- a/indra/newview/lleventpoll.cpp +++ b/indra/newview/lleventpoll.cpp @@ -59,11 +59,11 @@ namespace Details // We will wait RETRY_SECONDS + (errorCount * RETRY_SECONDS_INC) before retrying after an error. // This means we attempt to recover relatively quickly but back off giving more time to recover // until we finally give up after MAX_EVENT_POLL_HTTP_ERRORS attempts. - static const F32 EVENT_POLL_ERROR_RETRY_SECONDS; - static const F32 EVENT_POLL_ERROR_RETRY_SECONDS_INC; - static const S32 MAX_EVENT_POLL_HTTP_ERRORS; + static const F32 EVENT_POLL_ERROR_RETRY_SECONDS; + static const F32 EVENT_POLL_ERROR_RETRY_SECONDS_INC; + static const S32 MAX_EVENT_POLL_HTTP_ERRORS; - void eventPollCoro(LLCoros::self& self, std::string url); + void eventPollCoro(LLCoros::self& self, std::string url); void handleMessage(const LLSD &content); @@ -138,11 +138,14 @@ namespace Details LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("EventPoller", mHttpPolicy)); LLSD acknowledge; int errorCount = 0; - int counter = mCounter; // saved on the stack for debugging. + int counter = mCounter; // saved on the stack for logging. LL_INFOS("LLEventPollImpl") << " <" << counter << "> entering coroutine." << LL_ENDL; mAdapter = httpAdapter; + + // continually poll for a server update until we've been flagged as + // finished while (!mDone) { LLSD request; @@ -158,23 +161,23 @@ namespace Details // LL_DEBUGS("LLEventPollImpl::eventPollCoro") << "<" << counter << "> result = " // << LLSDXMLStreamer(result) << LL_ENDL; - LLSD httpResults; - httpResults = result["http_result"]; + LLSD httpResults = result["http_result"]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); if (!status) { - if (status == LLCore::HttpStatus(HTTP_BAD_GATEWAY)) - { - // A HTTP_BAD_GATEWAY (502) error is our standard timeout response + { // A HTTP_BAD_GATEWAY (502) error is our standard timeout response // we get this when there are no events. errorCount = 0; continue; } else if ((status == LLCore::HttpStatus(LLCore::HttpStatus::LLCORE, LLCore::HE_OP_CANCELED)) || (status == LLCore::HttpStatus(HTTP_NOT_FOUND))) - { + { // Event polling for this server has been canceled. In + // some cases the server gets ahead of the viewer and will + // return a 404 error (Not Found) before the cancel event + // comes back in the queue LL_WARNS() << "Canceling coroutine" << LL_ENDL; break; } @@ -182,7 +185,11 @@ namespace Details << status.toTerseString() << ": '" << httpResults["message"] << "'" << LL_ENDL; if (errorCount < MAX_EVENT_POLL_HTTP_ERRORS) - { + { // An unanticipated error has been received from our poll + // request. Calculate a timeout and wait for it to expire(sleep) + // before trying again. The sleep time is increased by 5 seconds + // for each consecutive error. + LLEventTimeout timeout; ++errorCount; F32 waitToRetry = EVENT_POLL_ERROR_RETRY_SECONDS @@ -191,15 +198,12 @@ namespace Details LL_WARNS("LLEventPollImpl") << "<" << counter << "> Retrying in " << waitToRetry << " seconds, error count is now " << errorCount << LL_ENDL; - { - LLEventTimeout timeout; - timeout.eventAfter(waitToRetry, LLSD()); - waitForEventOn(self, timeout); - } + timeout.eventAfter(waitToRetry, LLSD()); + waitForEventOn(self, timeout); + if (mDone) break; LL_INFOS("LLEventPollImpl") << "<" << counter << "> About to retry request." << LL_ENDL; - continue; } else @@ -208,7 +212,6 @@ namespace Details // IMs, teleports, about land, selecting land, region crossing and more will all fail. // They are essentially disconnected from the region even though some things may still work. // Since things won't get better until they relog we force a disconnect now. - mDone = true; // *NOTE:Mani - The following condition check to see if this failing event poll @@ -237,10 +240,7 @@ namespace Details acknowledge = result["id"]; LLSD events = result["events"]; - if (acknowledge.isUndefined()) - { - LL_WARNS("LLEventPollImpl") << " id undefined" << LL_ENDL; - } + LL_WARNS_IF((acknowledge.isUndefined()), "LLEventPollImpl") << " id undefined" << LL_ENDL; // was LL_INFOS() but now that CoarseRegionUpdate is TCP @ 1/second, it'd be too verbose for viewer logs. -MG LL_DEBUGS("LLEventPollImpl") << " <" << counter << "> " << events.size() << "events (id " << LLSDXMLStreamer(acknowledge) << ")" << LL_ENDL; @@ -256,7 +256,6 @@ namespace Details } } LL_INFOS("LLEventPollImpl") << " <" << counter << "> Leaving coroutine." << LL_ENDL; - } } diff --git a/indra/newview/llwlhandlers.cpp b/indra/newview/llwlhandlers.cpp index 3bedfbe502..c05486b173 100755 --- a/indra/newview/llwlhandlers.cpp +++ b/indra/newview/llwlhandlers.cpp @@ -32,6 +32,7 @@ #include "llviewerregion.h" #include "llenvmanager.h" #include "llnotificationsutil.h" +#include "llcorehttputil.h" /**** * LLEnvironmentRequest @@ -81,55 +82,62 @@ bool LLEnvironmentRequest::doRequest() return false; } - LL_INFOS("WindlightCaps") << "Requesting region windlight settings via " << url << LL_ENDL; - LLHTTPClient::get(url, new LLEnvironmentRequestResponder()); - return true; -} - -/**** - * LLEnvironmentRequestResponder - ****/ -int LLEnvironmentRequestResponder::sCount = 0; // init to 0 + std::string coroname = + LLCoros::instance().launch("LLEnvironmentRequest::environmentRequestCoro", + boost::bind(&LLEnvironmentRequest::environmentRequestCoro, _1, url)); -LLEnvironmentRequestResponder::LLEnvironmentRequestResponder() -{ - mID = ++sCount; + LL_INFOS("WindlightCaps") << "Requesting region windlight settings via " << url << LL_ENDL; + return true; } -/*virtual*/ void LLEnvironmentRequestResponder::httpSuccess() -{ - const LLSD& unvalidated_content = getContent(); - LL_INFOS("WindlightCaps") << "Received region windlight settings" << LL_ENDL; - if (mID != sCount) - { - LL_INFOS("WindlightCaps") << "Got superseded by another responder; ignoring..." << LL_ENDL; - return; - } - - LLUUID regionId; - if( gAgent.getRegion() ) - { - regionId = gAgent.getRegion()->getRegionID(); - } - - if (unvalidated_content[0]["regionID"].asUUID() != regionId ) - { - LL_WARNS("WindlightCaps") << "Not in the region from where this data was received (wanting " - << regionId << " but got " << unvalidated_content[0]["regionID"].asUUID() - << ") - ignoring..." << LL_ENDL; - return; - } +S32 LLEnvironmentRequest::sLastRequest = 0; - LLEnvManagerNew::getInstance()->onRegionSettingsResponse(unvalidated_content); -} -/*virtual*/ -void LLEnvironmentRequestResponder::httpFailure() +//static +void LLEnvironmentRequest::environmentRequestCoro(LLCoros::self& self, std::string url) { - LL_WARNS("WindlightCaps") << "Got an error, not using region windlight... " - << dumpResponse() << LL_ENDL; - LLEnvManagerNew::getInstance()->onRegionSettingsResponse(LLSD()); + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + S32 requestId = ++LLEnvironmentRequest::sLastRequest; + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("EnvironmentRequest", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + + LLSD result = httpAdapter->getAndYield(self, httpRequest, url); + + if (requestId != LLEnvironmentRequest::sLastRequest) + { + LL_INFOS("WindlightCaps") << "Got superseded by another responder; ignoring..." << LL_ENDL; + return; + } + + LLSD httpResults = result["http_result"]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + if (!status) + { + LL_WARNS("WindlightCaps") << "Got an error, not using region windlight... " << LL_ENDL; + LLEnvManagerNew::getInstance()->onRegionSettingsResponse(LLSD()); + return; + } + result = result["content"]; + LL_INFOS("WindlightCaps") << "Received region windlight settings" << LL_ENDL; + + LLUUID regionId; + if (gAgent.getRegion()) + { + regionId = gAgent.getRegion()->getRegionID(); + } + + if (result[0]["regionID"].asUUID() != regionId) + { + LL_WARNS("WindlightCaps") << "Not in the region from where this data was received (wanting " + << regionId << " but got " << result[0]["regionID"].asUUID() + << ") - ignoring..." << LL_ENDL; + return; + } + + LLEnvManagerNew::getInstance()->onRegionSettingsResponse(result); } + /**** * LLEnvironmentApply ****/ @@ -161,53 +169,86 @@ bool LLEnvironmentApply::initiateRequest(const LLSD& content) return false; } - LL_INFOS("WindlightCaps") << "Sending windlight settings to " << url << LL_ENDL; - LL_DEBUGS("WindlightCaps") << "content: " << content << LL_ENDL; - LLHTTPClient::post(url, content, new LLEnvironmentApplyResponder()); + LL_INFOS("WindlightCaps") << "Sending windlight settings to " << url << LL_ENDL; + LL_DEBUGS("WindlightCaps") << "content: " << content << LL_ENDL; + + std::string coroname = + LLCoros::instance().launch("LLEnvironmentApply::environmentApplyCoro", + boost::bind(&LLEnvironmentApply::environmentApplyCoro, _1, url, content)); return true; } -/**** - * LLEnvironmentApplyResponder - ****/ -/*virtual*/ void LLEnvironmentApplyResponder::httpSuccess() -{ - const LLSD& content = getContent(); - if (!content.isMap() || !content.has("regionID")) - { - failureResult(HTTP_INTERNAL_ERROR, "Malformed response contents", content); - return; - } - if (content["regionID"].asUUID() != gAgent.getRegion()->getRegionID()) - { - LL_WARNS("WindlightCaps") << "No longer in the region where data was sent (currently " - << gAgent.getRegion()->getRegionID() << ", reply is from " << content["regionID"].asUUID() - << "); ignoring..." << LL_ENDL; - return; - } - else if (content["success"].asBoolean()) - { - LL_DEBUGS("WindlightCaps") << "Success in applying windlight settings to region " << content["regionID"].asUUID() << LL_ENDL; - LLEnvManagerNew::instance().onRegionSettingsApplyResponse(true); - } - else - { - LL_WARNS("WindlightCaps") << "Region couldn't apply windlight settings! " << dumpResponse() << LL_ENDL; - LLSD args(LLSD::emptyMap()); - args["FAIL_REASON"] = content["fail_reason"].asString(); - LLNotificationsUtil::add("WLRegionApplyFail", args); - LLEnvManagerNew::instance().onRegionSettingsApplyResponse(false); - } -} -/*virtual*/ -void LLEnvironmentApplyResponder::httpFailure() +void LLEnvironmentApply::environmentApplyCoro(LLCoros::self& self, std::string url, LLSD content) { - LL_WARNS("WindlightCaps") << "Couldn't apply windlight settings to region! " - << dumpResponse() << LL_ENDL; - - LLSD args(LLSD::emptyMap()); - std::stringstream msg; - msg << getReason() << " (Code " << getStatus() << ")"; - args["FAIL_REASON"] = msg.str(); - LLNotificationsUtil::add("WLRegionApplyFail", args); + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("EnvironmentApply", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + + LLSD result = httpAdapter->postAndYield(self, httpRequest, url, content); + + LLSD notify; // for error reporting. If there is something to report to user this will be defined. + /* + * Expecting reply from sim in form of: + * { + * regionID : uuid, + * messageID: uuid, + * success : true + * } + * or + * { + * regionID : uuid, + * success : false, + * fail_reason : string + * } + */ + + do // while false. + { // Breaks from loop in the case of an error. + + LLSD httpResults = result["http_result"]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + if (!status) + { + LL_WARNS("WindlightCaps") << "Couldn't apply windlight settings to region! " << LL_ENDL; + + std::stringstream msg; + msg << status.toString() << " (Code " << status.toTerseString() << ")"; + notify = LLSD::emptyMap(); + notify["FAIL_REASON"] = msg.str(); + break; + } + + if (!result.has("regionID")) + { + notify = LLSD::emptyMap(); + notify["FAIL_REASON"] = "Missing regionID, malformed response"; + break; + } + else if (result["regionID"].asUUID() != gAgent.getRegion()->getRegionID()) + { + // note that there is no report to the user in this failure case. + LL_WARNS("WindlightCaps") << "No longer in the region where data was sent (currently " + << gAgent.getRegion()->getRegionID() << ", reply is from " << result["regionID"].asUUID() + << "); ignoring..." << LL_ENDL; + break; + } + else if (!result["success"].asBoolean()) + { + LL_WARNS("WindlightCaps") << "Region couldn't apply windlight settings! " << LL_ENDL; + notify = LLSD::emptyMap(); + notify["FAIL_REASON"] = result["fail_reason"].asString(); + break; + } + + LL_DEBUGS("WindlightCaps") << "Success in applying windlight settings to region " << result["regionID"].asUUID() << LL_ENDL; + LLEnvManagerNew::instance().onRegionSettingsApplyResponse(true); + + } while (false); + + if (!notify.isUndefined()) + { + LLNotificationsUtil::add("WLRegionApplyFail", notify); + LLEnvManagerNew::instance().onRegionSettingsApplyResponse(false); + } } diff --git a/indra/newview/llwlhandlers.h b/indra/newview/llwlhandlers.h index 089c799da7..6c093c733d 100755 --- a/indra/newview/llwlhandlers.h +++ b/indra/newview/llwlhandlers.h @@ -29,6 +29,7 @@ #include "llviewerprecompiledheaders.h" #include "llhttpclient.h" +#include "llcoros.h" class LLEnvironmentRequest { @@ -40,21 +41,10 @@ public: private: static void onRegionCapsReceived(const LLUUID& region_id); static bool doRequest(); -}; - -class LLEnvironmentRequestResponder: public LLHTTPClient::Responder -{ - LOG_CLASS(LLEnvironmentRequestResponder); -private: - /* virtual */ void httpSuccess(); - /* virtual */ void httpFailure(); -private: - friend class LLEnvironmentRequest; + static void environmentRequestCoro(LLCoros::self& self, std::string url); - LLEnvironmentRequestResponder(); - static int sCount; - int mID; + static S32 sLastRequest; }; class LLEnvironmentApply @@ -67,8 +57,11 @@ public: private: static clock_t sLastUpdate; static clock_t UPDATE_WAIT_SECONDS; + + static void environmentApplyCoro(LLCoros::self& self, std::string url, LLSD content); }; +#if 0 class LLEnvironmentApplyResponder: public LLHTTPClient::Responder { LOG_CLASS(LLEnvironmentApplyResponder); @@ -97,5 +90,6 @@ private: LLEnvironmentApplyResponder() {} }; +#endif #endif // LL_LLWLHANDLERS_H -- cgit v1.2.3 From 794cdbc2ae2d7078a7af5319e84667f0d6b15297 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 9 Apr 2015 17:14:39 -0700 Subject: Issue with LL_WARNS_IF sort out later. --- indra/newview/lleventpoll.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/lleventpoll.cpp b/indra/newview/lleventpoll.cpp index 25504e7cbf..d731428464 100755 --- a/indra/newview/lleventpoll.cpp +++ b/indra/newview/lleventpoll.cpp @@ -240,7 +240,10 @@ namespace Details acknowledge = result["id"]; LLSD events = result["events"]; - LL_WARNS_IF((acknowledge.isUndefined()), "LLEventPollImpl") << " id undefined" << LL_ENDL; + if (acknowledge.isUndefined()) + { + LL_WARNS("LLEventPollImpl") << " id undefined" << LL_ENDL; + } // was LL_INFOS() but now that CoarseRegionUpdate is TCP @ 1/second, it'd be too verbose for viewer logs. -MG LL_DEBUGS("LLEventPollImpl") << " <" << counter << "> " << events.size() << "events (id " << LLSDXMLStreamer(acknowledge) << ")" << LL_ENDL; -- cgit v1.2.3 From d0c85b6dd964164b6d92103ad65b5cd859197de2 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 10 Apr 2015 17:23:58 -0700 Subject: Adding support for DELETE, PATCH and COPY --- indra/llcorehttp/_httpoprequest.cpp | 68 +++++++++++++++++++++++---- indra/llcorehttp/_httpoprequest.h | 26 +++++++++- indra/llcorehttp/httprequest.cpp | 94 +++++++++++++++++++++++++++++++++++++ indra/llcorehttp/httprequest.h | 63 ++++++++++++++++++++++++- indra/llmessage/llcorehttputil.cpp | 40 ++++++++++++++++ indra/llmessage/llcorehttputil.h | 35 ++++++++++++++ 6 files changed, 315 insertions(+), 11 deletions(-) (limited to 'indra') diff --git a/indra/llcorehttp/_httpoprequest.cpp b/indra/llcorehttp/_httpoprequest.cpp index 7c2309b31d..b1b05dc285 100755 --- a/indra/llcorehttp/_httpoprequest.cpp +++ b/indra/llcorehttp/_httpoprequest.cpp @@ -357,6 +357,46 @@ HttpStatus HttpOpRequest::setupPut(HttpRequest::policy_t policy_id, } +HttpStatus HttpOpRequest::setupDelete(HttpRequest::policy_t policy_id, + HttpRequest::priority_t priority, + const std::string & url, + HttpOptions * options, + HttpHeaders * headers) +{ + setupCommon(policy_id, priority, url, NULL, options, headers); + mReqMethod = HOR_DELETE; + + return HttpStatus(); +} + + +HttpStatus HttpOpRequest::setupPatch(HttpRequest::policy_t policy_id, + HttpRequest::priority_t priority, + const std::string & url, + BufferArray * body, + HttpOptions * options, + HttpHeaders * headers) +{ + setupCommon(policy_id, priority, url, body, options, headers); + mReqMethod = HOR_PATCH; + + return HttpStatus(); +} + + +HttpStatus HttpOpRequest::setupCopy(HttpRequest::policy_t policy_id, + HttpRequest::priority_t priority, + const std::string & url, + HttpOptions * options, + HttpHeaders * headers) +{ + setupCommon(policy_id, priority, url, NULL, options, headers); + mReqMethod = HOR_COPY; + + return HttpStatus(); +} + + void HttpOpRequest::setupCommon(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, @@ -549,8 +589,6 @@ HttpStatus HttpOpRequest::prepareRequest(HttpService * service) case HOR_GET: code = curl_easy_setopt(mCurlHandle, CURLOPT_HTTPGET, 1); check_curl_easy_code(code, CURLOPT_HTTPGET); - mCurlHeaders = curl_slist_append(mCurlHeaders, "Connection: keep-alive"); - mCurlHeaders = curl_slist_append(mCurlHeaders, "Keep-alive: 300"); break; case HOR_POST: @@ -569,12 +607,14 @@ HttpStatus HttpOpRequest::prepareRequest(HttpService * service) code = curl_easy_setopt(mCurlHandle, CURLOPT_POSTFIELDSIZE, data_size); check_curl_easy_code(code, CURLOPT_POSTFIELDSIZE); mCurlHeaders = curl_slist_append(mCurlHeaders, "Expect:"); - mCurlHeaders = curl_slist_append(mCurlHeaders, "Connection: keep-alive"); - mCurlHeaders = curl_slist_append(mCurlHeaders, "Keep-alive: 300"); } break; - case HOR_PUT: + case HOR_PATCH: + code = curl_easy_setopt(mCurlHandle, CURLOPT_CUSTOMREQUEST, "PATCH"); + check_curl_easy_code(code, CURLOPT_CUSTOMREQUEST); + // fall through. The rest is the same as PUT + case HOR_PUT: { code = curl_easy_setopt(mCurlHandle, CURLOPT_UPLOAD, 1); check_curl_easy_code(code, CURLOPT_UPLOAD); @@ -588,12 +628,19 @@ HttpStatus HttpOpRequest::prepareRequest(HttpService * service) code = curl_easy_setopt(mCurlHandle, CURLOPT_POSTFIELDS, (void *) NULL); check_curl_easy_code(code, CURLOPT_POSTFIELDS); mCurlHeaders = curl_slist_append(mCurlHeaders, "Expect:"); - // *TODO: Should this be 'Keep-Alive' ? - mCurlHeaders = curl_slist_append(mCurlHeaders, "Connection: keep-alive"); - mCurlHeaders = curl_slist_append(mCurlHeaders, "Keep-alive: 300"); } break; + case HOR_DELETE: + code = curl_easy_setopt(mCurlHandle, CURLOPT_CUSTOMREQUEST, "DELETE"); + check_curl_easy_code(code, CURLOPT_CUSTOMREQUEST); + break; + + case HOR_COPY: + code = curl_easy_setopt(mCurlHandle, CURLOPT_CUSTOMREQUEST, "COPY"); + check_curl_easy_code(code, CURLOPT_CUSTOMREQUEST); + break; + default: LL_ERRS(LOG_CORE) << "Invalid HTTP method in request: " << int(mReqMethod) << ". Can't recover." @@ -601,6 +648,11 @@ HttpStatus HttpOpRequest::prepareRequest(HttpService * service) break; } + + // *TODO: Should this be 'Keep-Alive' ? + mCurlHeaders = curl_slist_append(mCurlHeaders, "Connection: keep-alive"); + mCurlHeaders = curl_slist_append(mCurlHeaders, "Keep-alive: 300"); + // Tracing if (mTracing >= HTTP_TRACE_CURL_HEADERS) { diff --git a/indra/llcorehttp/_httpoprequest.h b/indra/llcorehttp/_httpoprequest.h index e71d1d1edf..ca40898a81 100755 --- a/indra/llcorehttp/_httpoprequest.h +++ b/indra/llcorehttp/_httpoprequest.h @@ -80,7 +80,10 @@ public: { HOR_GET, HOR_POST, - HOR_PUT + HOR_PUT, + HOR_DELETE, + HOR_PATCH, + HOR_COPY }; virtual void stageFromRequest(HttpService *); @@ -126,7 +129,26 @@ public: HttpOptions * options, HttpHeaders * headers); - // Internal method used to setup the libcurl options for a request. + HttpStatus setupDelete(HttpRequest::policy_t policy_id, + HttpRequest::priority_t priority, + const std::string & url, + HttpOptions * options, + HttpHeaders * headers); + + HttpStatus setupPatch(HttpRequest::policy_t policy_id, + HttpRequest::priority_t priority, + const std::string & url, + BufferArray * body, + HttpOptions * options, + HttpHeaders * headers); + + HttpStatus setupCopy(HttpRequest::policy_t policy_id, + HttpRequest::priority_t priority, + const std::string & url, + HttpOptions * options, + HttpHeaders * headers); + + // Internal method used to setup the libcurl options for a request. // Does all the libcurl handle setup in one place. // // Threading: called by worker thread diff --git a/indra/llcorehttp/httprequest.cpp b/indra/llcorehttp/httprequest.cpp index df8502b947..d4c60a6f14 100755 --- a/indra/llcorehttp/httprequest.cpp +++ b/indra/llcorehttp/httprequest.cpp @@ -325,6 +325,100 @@ HttpHandle HttpRequest::requestPut(policy_t policy_id, return handle; } +HttpHandle HttpRequest::requestDelete(policy_t policy_id, + priority_t priority, + const std::string & url, + HttpOptions * options, + HttpHeaders * headers, + HttpHandler * user_handler) +{ + HttpStatus status; + HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); + + HttpOpRequest * op = new HttpOpRequest(); + if (!(status = op->setupDelete(policy_id, priority, url, options, headers))) + { + op->release(); + mLastReqStatus = status; + return handle; + } + op->setReplyPath(mReplyQueue, user_handler); + if (!(status = mRequestQueue->addOp(op))) // transfers refcount + { + op->release(); + mLastReqStatus = status; + return handle; + } + + mLastReqStatus = status; + handle = static_cast(op); + + return handle; +} + +HttpHandle HttpRequest::requestPatch(policy_t policy_id, + priority_t priority, + const std::string & url, + BufferArray * body, + HttpOptions * options, + HttpHeaders * headers, + HttpHandler * user_handler) +{ + HttpStatus status; + HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); + + HttpOpRequest * op = new HttpOpRequest(); + if (!(status = op->setupPatch(policy_id, priority, url, body, options, headers))) + { + op->release(); + mLastReqStatus = status; + return handle; + } + op->setReplyPath(mReplyQueue, user_handler); + if (!(status = mRequestQueue->addOp(op))) // transfers refcount + { + op->release(); + mLastReqStatus = status; + return handle; + } + + mLastReqStatus = status; + handle = static_cast(op); + + return handle; +} + +HttpHandle HttpRequest::requestCopy(policy_t policy_id, + priority_t priority, + const std::string & url, + HttpOptions * options, + HttpHeaders * headers, + HttpHandler * user_handler) +{ + HttpStatus status; + HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); + + HttpOpRequest * op = new HttpOpRequest(); + if (!(status = op->setupCopy(policy_id, priority, url, options, headers))) + { + op->release(); + mLastReqStatus = status; + return handle; + } + op->setReplyPath(mReplyQueue, user_handler); + if (!(status = mRequestQueue->addOp(op))) // transfers refcount + { + op->release(); + mLastReqStatus = status; + return handle; + } + + mLastReqStatus = status; + handle = static_cast(op); + + return handle; +} + HttpHandle HttpRequest::requestNoOp(HttpHandler * user_handler) { diff --git a/indra/llcorehttp/httprequest.h b/indra/llcorehttp/httprequest.h index 6688f06eb5..e87a8b691a 100755 --- a/indra/llcorehttp/httprequest.h +++ b/indra/llcorehttp/httprequest.h @@ -478,7 +478,68 @@ public: HttpHandler * handler); - /// Queue a NoOp request. + /// Queue a full HTTP PUT. Query arguments and body may + /// be provided. Caller is responsible for escaping and + /// encoding and communicating the content types. + /// + /// @param policy_id @see requestGet() + /// @param priority " + /// @param url " + /// @param options @see requestGet()K(optional) + /// @param headers " + /// @param handler " + /// @return " + /// + HttpHandle requestDelete(policy_t policy_id, + priority_t priority, + const std::string & url, + HttpOptions * options, + HttpHeaders * headers, + HttpHandler * user_handler); + + /// Queue a full HTTP PUT. Query arguments and body may + /// be provided. Caller is responsible for escaping and + /// encoding and communicating the content types. + /// + /// @param policy_id @see requestGet() + /// @param priority " + /// @param url " + /// @param body Byte stream to be sent as the body. No + /// further encoding or escaping will be done + /// to the content. + /// @param options @see requestGet()K(optional) + /// @param headers " + /// @param handler " + /// @return " + /// + HttpHandle requestPatch(policy_t policy_id, + priority_t priority, + const std::string & url, + BufferArray * body, + HttpOptions * options, + HttpHeaders * headers, + HttpHandler * user_handler); + + /// Queue a full HTTP PUT. Query arguments and body may + /// be provided. Caller is responsible for escaping and + /// encoding and communicating the content types. + /// + /// @param policy_id @see requestGet() + /// @param priority " + /// @param url " + /// @param options @see requestGet()K(optional) + /// @param headers " + /// @param handler " + /// @return " + /// + HttpHandle requestCopy(policy_t policy_id, + priority_t priority, + const std::string & url, + HttpOptions * options, + HttpHeaders * headers, + HttpHandler * user_handler); + + /// Queue a NoOp request. /// The request is queued and serviced by the working thread which /// immediately processes it and returns the request to the reply /// queue. diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index a32c4cad22..2d6cca214c 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -142,6 +142,46 @@ HttpHandle requestPutWithLLSD(HttpRequest::ptr_t & request, url, body, options.get(), headers.get(), handler); } +HttpHandle requestPatchWithLLSD(HttpRequest * request, + HttpRequest::policy_t policy_id, + HttpRequest::priority_t priority, + const std::string & url, + const LLSD & body, + HttpOptions * options, + HttpHeaders * headers, + HttpHandler * handler) +{ + HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); + + BufferArray * ba = new BufferArray(); + BufferArrayStream bas(ba); + LLSDSerialize::toXML(body, bas); + + handle = request->requestPatch(policy_id, + priority, + url, + ba, + options, + headers, + handler); + ba->release(); + return handle; +} + +HttpHandle requestPatchWithLLSD(HttpRequest::ptr_t & request, + HttpRequest::policy_t policy_id, + HttpRequest::priority_t priority, + const std::string & url, + const LLSD & body, + HttpOptions::ptr_t & options, + HttpHeaders::ptr_t & headers, + HttpHandler * handler) +{ + return requestPatchWithLLSD(request.get(), policy_id, priority, + url, body, options.get(), headers.get(), handler); +} + + std::string responseToString(LLCore::HttpResponse * response) { static const std::string empty("[Empty]"); diff --git a/indra/llmessage/llcorehttputil.h b/indra/llmessage/llcorehttputil.h index 471710f61b..6fcf03b95c 100644 --- a/indra/llmessage/llcorehttputil.h +++ b/indra/llmessage/llcorehttputil.h @@ -155,6 +155,41 @@ LLCore::HttpHandle requestPutWithLLSD(LLCore::HttpRequest::ptr_t & request, LLCore::HttpHeaders::ptr_t & headers, LLCore::HttpHandler * handler); +/// Issue a standard HttpRequest::requestPatch() call but using +/// and LLSD object as the request body. Conventions are the +/// same as with that method. Caller is expected to provide +/// an HttpHeaders object with a correct 'Content-Type:' header. +/// One will not be provided by this call. +/// +/// @return If request is successfully issued, the +/// HttpHandle representing the request. +/// On error, LLCORE_HTTP_HANDLE_INVALID +/// is returned and caller can fetch detailed +/// status with the getStatus() method on the +/// request object. In case of error, no +/// request is queued and caller may need to +/// perform additional cleanup such as freeing +/// a now-useless HttpHandler object. +/// +LLCore::HttpHandle requestPatchWithLLSD(LLCore::HttpRequest * request, + LLCore::HttpRequest::policy_t policy_id, + LLCore::HttpRequest::priority_t priority, + const std::string & url, + const LLSD & body, + LLCore::HttpOptions * options, + LLCore::HttpHeaders * headers, + LLCore::HttpHandler * handler); + +LLCore::HttpHandle requestPatchWithLLSD(LLCore::HttpRequest::ptr_t & request, + LLCore::HttpRequest::policy_t policy_id, + LLCore::HttpRequest::priority_t priority, + const std::string & url, + const LLSD & body, + LLCore::HttpOptions::ptr_t & options, + LLCore::HttpHeaders::ptr_t & headers, + LLCore::HttpHandler * handler); + + /// The HttpCoroHandler is a specialization of the LLCore::HttpHandler for /// interacting with coroutines. When the request is completed the response /// will be posted onto the supplied Event Pump. -- cgit v1.2.3 From 2d3e4576d7a1f6d5f2a9c0596cefe3f62753b2fa Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 13 Apr 2015 09:20:54 -0700 Subject: Formatting change to get past merge conflict. --- indra/llmessage/llavatarnamecache.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'indra') diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index 616bd60f07..ef097c70f2 100755 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -399,9 +399,7 @@ void LLAvatarNameCache::requestNamesViaCapability() if (!url.empty()) { - LL_DEBUGS("AvNameCache") << "LLAvatarNameCache::requestNamesViaCapability requested " - << ids << " ids" - << LL_ENDL; + LL_DEBUGS("AvNameCache") << "LLAvatarNameCache::requestNamesViaCapability requested " << ids << " ids" << LL_ENDL; std::string coroname = LLCoros::instance().launch("LLAvatarNameCache::requestAvatarNameCache_", -- cgit v1.2.3 From b8805c8964d45ee9141bcc131473bc4e663e93bf Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 13 Apr 2015 10:25:21 -0700 Subject: Forgot to remove some commented code. --- indra/newview/llwlhandlers.h | 31 ------------------------------- 1 file changed, 31 deletions(-) (limited to 'indra') diff --git a/indra/newview/llwlhandlers.h b/indra/newview/llwlhandlers.h index 6c093c733d..e8908410d9 100755 --- a/indra/newview/llwlhandlers.h +++ b/indra/newview/llwlhandlers.h @@ -61,35 +61,4 @@ private: static void environmentApplyCoro(LLCoros::self& self, std::string url, LLSD content); }; -#if 0 -class LLEnvironmentApplyResponder: public LLHTTPClient::Responder -{ - LOG_CLASS(LLEnvironmentApplyResponder); -private: - /* - * Expecting reply from sim in form of: - * { - * regionID : uuid, - * messageID: uuid, - * success : true - * } - * or - * { - * regionID : uuid, - * success : false, - * fail_reason : string - * } - */ - /* virtual */ void httpSuccess(); - - // non-2xx errors only - /* virtual */ void httpFailure(); - -private: - friend class LLEnvironmentApply; - - LLEnvironmentApplyResponder() {} -}; -#endif - #endif // LL_LLWLHANDLERS_H -- cgit v1.2.3 From 176d8cd268611e28c07a462df3027f4872456e5a Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 15 Apr 2015 11:51:48 -0700 Subject: Region caps and sim features converted to coroutine. --- indra/newview/llagent.cpp | 2 + indra/newview/llappearancemgr.cpp | 193 +++++++------ indra/newview/llviewerregion.cpp | 569 +++++++++++++++++++------------------- indra/newview/llviewerregion.h | 3 +- 4 files changed, 399 insertions(+), 368 deletions(-) (limited to 'indra') diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index eeedda5c6d..7f38e4b79f 100755 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -2788,6 +2788,8 @@ void LLAgent::sendMaturityPreferenceToServer(U8 pPreferredMaturity) } } +// *TODO:RIDER Convert this system to using the coroutine scheme for HTTP communications +// LLCore::HttpHandle LLAgent::requestPostCapability(const std::string &cap, const std::string &url, LLSD &postData, LLHttpSDHandler *usrhndlr) { LLHttpSDHandler * handler = (usrhndlr) ? usrhndlr : new LLHttpSDGenericHandler(cap); diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp index 4fbcd90baa..42c8c0fb1c 100755 --- a/indra/newview/llappearancemgr.cpp +++ b/indra/newview/llappearancemgr.cpp @@ -1246,6 +1246,38 @@ static void removeDuplicateItems(LLInventoryModel::item_array_t& items) } //========================================================================= +#if 0 +// *TODO: +class LLAppearanceMgrHttpHandler +{ +public: + + static void apperanceMgrRequestCoro(LLCoros::self& self, std::string url); + +private: + LLAppearanceMgrHttpHandler(); + + static void debugCOF(const LLSD& content); + + +}; + +void LLAppearanceMgrHttpHandler::apperanceMgrRequestCoro(LLCoros::self& self, std::string url) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("EnvironmentRequest", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + + + +} + +#else + +// *TODO: Convert this and llavatar over to using the coroutine scheme rather +// than the responder for communications. (see block above for start...) + class LLAppearanceMgrHttpHandler : public LLHttpSDHandler { public: @@ -1319,89 +1351,90 @@ void LLAppearanceMgrHttpHandler::onFailure(LLCore::HttpResponse * response, LLCo << status.toString() << LL_ENDL; } +#endif + void LLAppearanceMgrHttpHandler::debugCOF(const LLSD& content) { - dump_sequential_xml(gAgentAvatarp->getFullname() + "_appearance_request_error", content); - - LL_INFOS("Avatar") << "AIS COF, version received: " << content["expected"].asInteger() - << " ================================= " << LL_ENDL; - std::set ais_items, local_items; - const LLSD& cof_raw = content["cof_raw"]; - for (LLSD::array_const_iterator it = cof_raw.beginArray(); - it != cof_raw.endArray(); ++it) - { - const LLSD& item = *it; - if (item["parent_id"].asUUID() == LLAppearanceMgr::instance().getCOF()) - { - ais_items.insert(item["item_id"].asUUID()); - if (item["type"].asInteger() == 24) // link - { - LL_INFOS("Avatar") << "AIS Link: item_id: " << item["item_id"].asUUID() - << " linked_item_id: " << item["asset_id"].asUUID() - << " name: " << item["name"].asString() - << LL_ENDL; - } - else if (item["type"].asInteger() == 25) // folder link - { - LL_INFOS("Avatar") << "AIS Folder link: item_id: " << item["item_id"].asUUID() - << " linked_item_id: " << item["asset_id"].asUUID() - << " name: " << item["name"].asString() - << LL_ENDL; - } - else - { - LL_INFOS("Avatar") << "AIS Other: item_id: " << item["item_id"].asUUID() - << " linked_item_id: " << item["asset_id"].asUUID() - << " name: " << item["name"].asString() - << " type: " << item["type"].asInteger() - << LL_ENDL; - } - } - } - LL_INFOS("Avatar") << LL_ENDL; - LL_INFOS("Avatar") << "Local COF, version requested: " << content["observed"].asInteger() - << " ================================= " << LL_ENDL; - LLInventoryModel::cat_array_t cat_array; - LLInventoryModel::item_array_t item_array; - gInventory.collectDescendents(LLAppearanceMgr::instance().getCOF(), - cat_array, item_array, LLInventoryModel::EXCLUDE_TRASH); - for (S32 i = 0; i < item_array.size(); i++) - { - const LLViewerInventoryItem* inv_item = item_array.at(i).get(); - local_items.insert(inv_item->getUUID()); - LL_INFOS("Avatar") << "LOCAL: item_id: " << inv_item->getUUID() - << " linked_item_id: " << inv_item->getLinkedUUID() - << " name: " << inv_item->getName() - << " parent: " << inv_item->getParentUUID() - << LL_ENDL; - } - LL_INFOS("Avatar") << " ================================= " << LL_ENDL; - S32 local_only = 0, ais_only = 0; - for (std::set::iterator it = local_items.begin(); it != local_items.end(); ++it) - { - if (ais_items.find(*it) == ais_items.end()) - { - LL_INFOS("Avatar") << "LOCAL ONLY: " << *it << LL_ENDL; - local_only++; - } - } - for (std::set::iterator it = ais_items.begin(); it != ais_items.end(); ++it) - { - if (local_items.find(*it) == local_items.end()) - { - LL_INFOS("Avatar") << "AIS ONLY: " << *it << LL_ENDL; - ais_only++; - } - } - if (local_only == 0 && ais_only == 0) - { - LL_INFOS("Avatar") << "COF contents identical, only version numbers differ (req " - << content["observed"].asInteger() - << " rcv " << content["expected"].asInteger() - << ")" << LL_ENDL; - } + dump_sequential_xml(gAgentAvatarp->getFullname() + "_appearance_request_error", content); + + LL_INFOS("Avatar") << "AIS COF, version received: " << content["expected"].asInteger() + << " ================================= " << LL_ENDL; + std::set ais_items, local_items; + const LLSD& cof_raw = content["cof_raw"]; + for (LLSD::array_const_iterator it = cof_raw.beginArray(); + it != cof_raw.endArray(); ++it) + { + const LLSD& item = *it; + if (item["parent_id"].asUUID() == LLAppearanceMgr::instance().getCOF()) + { + ais_items.insert(item["item_id"].asUUID()); + if (item["type"].asInteger() == 24) // link + { + LL_INFOS("Avatar") << "AIS Link: item_id: " << item["item_id"].asUUID() + << " linked_item_id: " << item["asset_id"].asUUID() + << " name: " << item["name"].asString() + << LL_ENDL; + } + else if (item["type"].asInteger() == 25) // folder link + { + LL_INFOS("Avatar") << "AIS Folder link: item_id: " << item["item_id"].asUUID() + << " linked_item_id: " << item["asset_id"].asUUID() + << " name: " << item["name"].asString() + << LL_ENDL; + } + else + { + LL_INFOS("Avatar") << "AIS Other: item_id: " << item["item_id"].asUUID() + << " linked_item_id: " << item["asset_id"].asUUID() + << " name: " << item["name"].asString() + << " type: " << item["type"].asInteger() + << LL_ENDL; + } + } + } + LL_INFOS("Avatar") << LL_ENDL; + LL_INFOS("Avatar") << "Local COF, version requested: " << content["observed"].asInteger() + << " ================================= " << LL_ENDL; + LLInventoryModel::cat_array_t cat_array; + LLInventoryModel::item_array_t item_array; + gInventory.collectDescendents(LLAppearanceMgr::instance().getCOF(), + cat_array, item_array, LLInventoryModel::EXCLUDE_TRASH); + for (S32 i = 0; i < item_array.size(); i++) + { + const LLViewerInventoryItem* inv_item = item_array.at(i).get(); + local_items.insert(inv_item->getUUID()); + LL_INFOS("Avatar") << "LOCAL: item_id: " << inv_item->getUUID() + << " linked_item_id: " << inv_item->getLinkedUUID() + << " name: " << inv_item->getName() + << " parent: " << inv_item->getParentUUID() + << LL_ENDL; + } + LL_INFOS("Avatar") << " ================================= " << LL_ENDL; + S32 local_only = 0, ais_only = 0; + for (std::set::iterator it = local_items.begin(); it != local_items.end(); ++it) + { + if (ais_items.find(*it) == ais_items.end()) + { + LL_INFOS("Avatar") << "LOCAL ONLY: " << *it << LL_ENDL; + local_only++; + } + } + for (std::set::iterator it = ais_items.begin(); it != ais_items.end(); ++it) + { + if (local_items.find(*it) == local_items.end()) + { + LL_INFOS("Avatar") << "AIS ONLY: " << *it << LL_ENDL; + ais_only++; + } + } + if (local_only == 0 && ais_only == 0) + { + LL_INFOS("Avatar") << "COF contents identical, only version numbers differ (req " + << content["observed"].asInteger() + << " rcv " << content["expected"].asInteger() + << ")" << LL_ENDL; + } } - //========================================================================= const LLUUID LLAppearanceMgr::getCOF() const diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index 4bfea81182..bebbf4ea56 100755 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -78,6 +78,9 @@ #include "llviewerdisplay.h" #include "llviewerwindow.h" #include "llprogressview.h" +#include "llcoros.h" +#include "lleventcoro.h" +#include "llcorehttputil.h" #ifdef LL_WINDOWS #pragma warning(disable:4355) @@ -105,7 +108,8 @@ typedef std::map CapabilityMap; static void log_capabilities(const CapabilityMap &capmap); -class LLViewerRegionImpl { +class LLViewerRegionImpl +{ public: LLViewerRegionImpl(LLViewerRegion * region, LLHost const & host) : mHost(host), @@ -189,212 +193,281 @@ public: //spatial partitions for objects in this region std::vector mObjectPartition; - LLVector3 mLastCameraOrigin; - U32 mLastCameraUpdate; -}; - -// support for secondlife:///app/region/{REGION} SLapps -// N.B. this is defined to work exactly like the classic secondlife://{REGION} -// However, the later syntax cannot support spaces in the region name because -// spaces (and %20 chars) are illegal in the hostname of an http URL. Some -// browsers let you get away with this, but some do not (such as Qt's Webkit). -// Hence we introduced the newer secondlife:///app/region alternative. -class LLRegionHandler : public LLCommandHandler -{ -public: - // requests will be throttled from a non-trusted browser - LLRegionHandler() : LLCommandHandler("region", UNTRUSTED_THROTTLE) {} - - bool handle(const LLSD& params, const LLSD& query_map, LLMediaCtrl* web) - { - // make sure that we at least have a region name - int num_params = params.size(); - if (num_params < 1) - { - return false; - } + LLVector3 mLastCameraOrigin; + U32 mLastCameraUpdate; - // build a secondlife://{PLACE} SLurl from this SLapp - std::string url = "secondlife://"; - for (int i = 0; i < num_params; i++) - { - if (i > 0) - { - url += "/"; - } - url += params[i].asString(); - } - - // Process the SLapp as if it was a secondlife://{PLACE} SLurl - LLURLDispatcher::dispatch(url, "clicked", web, true); - return true; - } + void requestBaseCapabilitiesCoro(LLCoros::self& self, U64 regionHandle); + void requestBaseCapabilitiesCompleteCoro(LLCoros::self& self, U64 regionHandle); + void requestSimulatorFeatureCoro(LLCoros::self& self, std::string url, U64 regionHandle); }; -LLRegionHandler gRegionHandler; -class BaseCapabilitiesComplete : public LLHTTPClient::Responder +void LLViewerRegionImpl::requestBaseCapabilitiesCoro(LLCoros::self& self, U64 regionHandle) { - LOG_CLASS(BaseCapabilitiesComplete); -public: - BaseCapabilitiesComplete(U64 region_handle, S32 id) - : mRegionHandle(region_handle), mID(id) - { } - virtual ~BaseCapabilitiesComplete() - { } - - static BaseCapabilitiesComplete* build( U64 region_handle, S32 id ) - { - return new BaseCapabilitiesComplete(region_handle, id); - } - -private: - /* virtual */void httpFailure() - { - LL_WARNS("AppInit", "Capabilities") << dumpResponse() << LL_ENDL; - LLViewerRegion *regionp = LLWorld::getInstance()->getRegionFromHandle(mRegionHandle); - if (regionp) - { - regionp->failedSeedCapability(); - } - } - - /* virtual */ void httpSuccess() - { - LLViewerRegion *regionp = LLWorld::getInstance()->getRegionFromHandle(mRegionHandle); - if(!regionp) //region was removed - { - LL_WARNS("AppInit", "Capabilities") << "Received results for region that no longer exists!" << LL_ENDL; - return ; - } - if( mID != regionp->getHttpResponderID() ) // region is no longer referring to this responder - { - LL_WARNS("AppInit", "Capabilities") << "Received results for a stale http responder!" << LL_ENDL; - regionp->failedSeedCapability(); - return ; - } - - const LLSD& content = getContent(); - if (!content.isMap()) - { - failureResult(HTTP_INTERNAL_ERROR, "Malformed response contents", content); - return; - } - LLSD::map_const_iterator iter; - for(iter = content.beginMap(); iter != content.endMap(); ++iter) - { - regionp->setCapability(iter->first, iter->second); + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("BaseCapabilitiesRequest", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LL_DEBUGS("AppInit", "Capabilities") - << "Capability '" << iter->first << "' is '" << iter->second << "'" << LL_ENDL; + LLSD result; + LLViewerRegion *regionp = NULL; - /* HACK we're waiting for the ServerReleaseNotes */ - if (iter->first == "ServerReleaseNotes" && regionp->getReleaseNotesRequested()) - { - regionp->showReleaseNotes(); - } - } - - regionp->setCapabilitiesReceived(true); + // This loop is used for retrying a capabilities request. + do + { + regionp = LLWorld::getInstance()->getRegionFromHandle(regionHandle); + if (!regionp) //region was removed + { + LL_WARNS("AppInit", "Capabilities") << "Attempting to get capabilities for region that no longer exists!" << LL_ENDL; + return; // this error condition is not recoverable. + } + + std::string url = regionp->getCapability("Seed"); + if (url.empty()) + { + LL_WARNS("AppInit", "Capabilities") << "Failed to get seed capabilities, and can not determine url!" << LL_ENDL; + return; // this error condition is not recoverable. + } + + // After a few attempts, continue login. But keep trying to get the caps: + if (mSeedCapAttempts >= mSeedCapMaxAttemptsBeforeLogin && + STATE_SEED_GRANTED_WAIT == LLStartUp::getStartupState()) + { + LLStartUp::setStartupState(STATE_SEED_CAP_GRANTED); + } + + if (mSeedCapAttempts > mSeedCapMaxAttempts) + { + // *TODO: Give a user pop-up about this error? + LL_WARNS("AppInit", "Capabilities") << "Failed to get seed capabilities from '" << url << "' after " << mSeedCapAttempts << " attempts. Giving up!" << LL_ENDL; + return; // this error condition is not recoverable. + } + + S32 id = ++mHttpResponderID; + ++mSeedCapAttempts; + + LLSD capabilityNames = LLSD::emptyArray(); + buildCapabilityNames(capabilityNames); + + LL_INFOS("AppInit", "Capabilities") << "Requesting seed from " << url + << " (attempt #" << mSeedCapAttempts << ")" << LL_ENDL; + + regionp = NULL; + result = httpAdapter->postAndYield(self, httpRequest, url, capabilityNames); + + regionp = LLWorld::getInstance()->getRegionFromHandle(regionHandle); + if (!regionp) //region was removed + { + LL_WARNS("AppInit", "Capabilities") << "Received capabilities for region that no longer exists!" << LL_ENDL; + return; // this error condition is not recoverable. + } + + if (id != mHttpResponderID) // region is no longer referring to this request + { + LL_WARNS("AppInit", "Capabilities") << "Received results for a stale capabilities request!" << LL_ENDL; + // setup for retry. + continue; + } + + LLSD httpResults = result["http_result"]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + if (!status) + { + LL_WARNS("AppInit", "Capabilities") << "HttpStatus error " << LL_ENDL; + // setup for retry. + continue; + } + + // remove the http_result from the llsd + result.erase("http_result"); + + LLSD::map_const_iterator iter; + for (iter = result.beginMap(); iter != result.endMap(); ++iter) + { + regionp->setCapability(iter->first, iter->second); + + LL_DEBUGS("AppInit", "Capabilities") + << "Capability '" << iter->first << "' is '" << iter->second << "'" << LL_ENDL; + } + + regionp->setCapabilitiesReceived(true); + + if (STATE_SEED_GRANTED_WAIT == LLStartUp::getStartupState()) + { + LLStartUp::setStartupState(STATE_SEED_CAP_GRANTED); + } + + break; + } + while (true); + + if (regionp && regionp->isCapabilityAvailable("ServerReleaseNotes") && + regionp->getReleaseNotesRequested()) + { // *HACK: we're waiting for the ServerReleaseNotes + regionp->showReleaseNotes(); + } - if (STATE_SEED_GRANTED_WAIT == LLStartUp::getStartupState()) - { - LLStartUp::setStartupState( STATE_SEED_CAP_GRANTED ); - } - } +} -private: - U64 mRegionHandle; - S32 mID; -}; -class BaseCapabilitiesCompleteTracker : public LLHTTPClient::Responder +void LLViewerRegionImpl::requestBaseCapabilitiesCompleteCoro(LLCoros::self& self, U64 regionHandle) { - LOG_CLASS(BaseCapabilitiesCompleteTracker); -public: - BaseCapabilitiesCompleteTracker( U64 region_handle) - : mRegionHandle(region_handle) - { } - - virtual ~BaseCapabilitiesCompleteTracker() - { } + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("BaseCapabilitiesRequest", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - static BaseCapabilitiesCompleteTracker* build( U64 region_handle ) - { - return new BaseCapabilitiesCompleteTracker( region_handle ); - } - -private: - /* virtual */ void httpFailure() - { - LL_WARNS() << dumpResponse() << LL_ENDL; - } - - /* virtual */ void httpSuccess() - { - LLViewerRegion *regionp = LLWorld::getInstance()->getRegionFromHandle(mRegionHandle); - if( !regionp ) - { - LL_WARNS("AppInit", "Capabilities") << "Received results for region that no longer exists!" << LL_ENDL; - return ; - } + LLSD result; + LLViewerRegion *regionp = NULL; - const LLSD& content = getContent(); - if (!content.isMap()) - { - failureResult(HTTP_INTERNAL_ERROR, "Malformed response contents", content); - return; - } - LLSD::map_const_iterator iter; - for(iter = content.beginMap(); iter != content.endMap(); ++iter) - { - regionp->setCapabilityDebug(iter->first, iter->second); - //LL_INFOS()<<"BaseCapabilitiesCompleteTracker New Caps "<first<<" "<< iter->second<getRegionImpl()->mCapabilities.size() != regionp->getRegionImpl()->mSecondCapabilitiesTracker.size() ) - { - LL_WARNS("AppInit", "Capabilities") - << "Sim sent duplicate base caps that differ in size from what we initially received - most likely content. " - << "mCapabilities == " << regionp->getRegionImpl()->mCapabilities.size() - << " mSecondCapabilitiesTracker == " << regionp->getRegionImpl()->mSecondCapabilitiesTracker.size() - << LL_ENDL; + // This loop is used for retrying a capabilities request. + do + { + regionp = LLWorld::getInstance()->getRegionFromHandle(regionHandle); + if (!regionp) //region was removed + { + LL_WARNS("AppInit", "Capabilities") << "Attempting to get capabilities for region that no longer exists!" << LL_ENDL; + break; // this error condition is not recoverable. + } + + std::string url = regionp->getCapabilityDebug("Seed"); + if (url.empty()) + { + LL_WARNS("AppInit", "Capabilities") << "Failed to get seed capabilities, and can not determine url!" << LL_ENDL; + break; // this error condition is not recoverable. + } + + LLSD capabilityNames = LLSD::emptyArray(); + buildCapabilityNames(capabilityNames); + + LL_INFOS("AppInit", "Capabilities") << "Requesting second Seed from " << url << LL_ENDL; + + regionp = NULL; + result = httpAdapter->postAndYield(self, httpRequest, url, capabilityNames); + + LLSD httpResults = result["http_result"]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + if (!status) + { + LL_WARNS("AppInit", "Capabilities") << "HttpStatus error " << LL_ENDL; + break; // no retry + } + + regionp = LLWorld::getInstance()->getRegionFromHandle(regionHandle); + if (!regionp) //region was removed + { + LL_WARNS("AppInit", "Capabilities") << "Received capabilities for region that no longer exists!" << LL_ENDL; + break; // this error condition is not recoverable. + } + + // remove the http_result from the llsd + result.erase("http_result"); + + LLSD::map_const_iterator iter; + for (iter = result.beginMap(); iter != result.endMap(); ++iter) + { + regionp->setCapabilityDebug(iter->first, iter->second); + //LL_INFOS()<<"BaseCapabilitiesCompleteTracker New Caps "<first<<" "<< iter->second<getRegionImpl()->mCapabilities); + log_capabilities(mCapabilities); - LL_WARNS("AppInit", "Capabilities") - << "Latest base capabilities: " << LL_ENDL; + LL_WARNS("AppInit", "Capabilities") + << "Latest base capabilities: " << LL_ENDL; - log_capabilities(regionp->getRegionImpl()->mSecondCapabilitiesTracker); + log_capabilities(mSecondCapabilitiesTracker); #endif - if (regionp->getRegionImpl()->mSecondCapabilitiesTracker.size() > regionp->getRegionImpl()->mCapabilities.size() ) - { - // *HACK Since we were granted more base capabilities in this grant request than the initial, replace - // the old with the new. This shouldn't happen i.e. we should always get the same capabilities from a - // sim. The simulator fix from SH-3895 should prevent it from happening, at least in the case of the - // inventory api capability grants. - - // Need to clear a std::map before copying into it because old keys take precedence. - regionp->getRegionImplNC()->mCapabilities.clear(); - regionp->getRegionImplNC()->mCapabilities = regionp->getRegionImpl()->mSecondCapabilitiesTracker; - } - } - else - { - LL_DEBUGS("CrossingCaps") << "Sim sent multiple base cap grants with matching sizes." << LL_ENDL; - } - regionp->getRegionImplNC()->mSecondCapabilitiesTracker.clear(); - } + if (mSecondCapabilitiesTracker.size() > mCapabilities.size()) + { + // *HACK Since we were granted more base capabilities in this grant request than the initial, replace + // the old with the new. This shouldn't happen i.e. we should always get the same capabilities from a + // sim. The simulator fix from SH-3895 should prevent it from happening, at least in the case of the + // inventory api capability grants. + // Need to clear a std::map before copying into it because old keys take precedence. + mCapabilities.clear(); + mCapabilities = mSecondCapabilitiesTracker; + } + } + else + { + LL_DEBUGS("CrossingCaps") << "Sim sent multiple base cap grants with matching sizes." << LL_ENDL; + } + mSecondCapabilitiesTracker.clear(); + } + while (false); -private: - U64 mRegionHandle; -}; +} + +void LLViewerRegionImpl::requestSimulatorFeatureCoro(LLCoros::self& self, std::string url, U64 regionHandle) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("BaseCapabilitiesRequest", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + + LLViewerRegion *regionp = NULL; + S32 attemptNumber = 0; + // This loop is used for retrying a capabilities request. + do + { + ++attemptNumber; + + if (attemptNumber > MAX_CAP_REQUEST_ATTEMPTS) + { + LL_WARNS("AppInit", "SimulatorFeatures") << "Retries count exceeded attempting to get Simulator feature from " + << url << LL_ENDL; + break; + } + + regionp = LLWorld::getInstance()->getRegionFromHandle(regionHandle); + if (!regionp) //region was removed + { + LL_WARNS("AppInit", "SimulatorFeatures") << "Attempting to request Sim Feature for region that no longer exists!" << LL_ENDL; + break; // this error condition is not recoverable. + } + + regionp = NULL; + LLSD result = httpAdapter->getAndYield(self, httpRequest, url); + + LLSD httpResults = result["http_result"]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + if (!status) + { + LL_WARNS("AppInit", "SimulatorFeatures") << "HttpStatus error retrying" << LL_ENDL; + continue; + } + + // remove the http_result from the llsd + result.erase("http_result"); + + regionp = LLWorld::getInstance()->getRegionFromHandle(regionHandle); + if (!regionp) //region was removed + { + LL_WARNS("AppInit", "SimulatorFeatures") << "Attempting to set Sim Feature for region that no longer exists!" << LL_ENDL; + break; // this error condition is not recoverable. + } + + regionp->setSimulatorFeatures(result); + + break; + } + while (true); + +} LLViewerRegion::LLViewerRegion(const U64 &handle, const LLHost &host, @@ -2800,15 +2873,14 @@ void LLViewerRegion::setSeedCapability(const std::string& url) if (getCapability("Seed") == url) { setCapabilityDebug("Seed", url); - LL_DEBUGS("CrossingCaps") << "Received duplicate seed capability, posting to seed " << + LL_WARNS("CrossingCaps") << "Received duplicate seed capability, posting to seed " << url << LL_ENDL; //Instead of just returning we build up a second set of seed caps and compare them //to the "original" seed cap received and determine why there is problem! - LLSD capabilityNames = LLSD::emptyArray(); - mImpl->buildCapabilityNames( capabilityNames ); - LLHTTPClient::post( url, capabilityNames, BaseCapabilitiesCompleteTracker::build(getHandle() ), - LLSD(), CAP_REQUEST_TIMEOUT ); + std::string coroname = + LLCoros::instance().launch("LLEnvironmentRequest::requestBaseCapabilitiesCompleteCoro", + boost::bind(&LLViewerRegionImpl::requestBaseCapabilitiesCompleteCoro, mImpl, _1, getHandle())); return; } @@ -2818,15 +2890,11 @@ void LLViewerRegion::setSeedCapability(const std::string& url) mImpl->mCapabilities.clear(); setCapability("Seed", url); - LLSD capabilityNames = LLSD::emptyArray(); - mImpl->buildCapabilityNames(capabilityNames); - - LL_INFOS() << "posting to seed " << url << LL_ENDL; + std::string coroname = + LLCoros::instance().launch("LLEnvironmentRequest::environmentRequestCoro", + boost::bind(&LLViewerRegionImpl::requestBaseCapabilitiesCoro, mImpl, _1, getHandle())); - S32 id = ++mImpl->mHttpResponderID; - LLHTTPClient::post(url, capabilityNames, - BaseCapabilitiesComplete::build(getHandle(), id), - LLSD(), CAP_REQUEST_TIMEOUT); + LL_INFOS("AppInit", "Capabilities") << "Launching " << coroname << " requesting seed capabilities from " << url << LL_ENDL; } S32 LLViewerRegion::getNumSeedCapRetries() @@ -2834,94 +2902,6 @@ S32 LLViewerRegion::getNumSeedCapRetries() return mImpl->mSeedCapAttempts; } -void LLViewerRegion::failedSeedCapability() -{ - // Should we retry asking for caps? - mImpl->mSeedCapAttempts++; - std::string url = getCapability("Seed"); - if ( url.empty() ) - { - LL_WARNS("AppInit", "Capabilities") << "Failed to get seed capabilities, and can not determine url for retries!" << LL_ENDL; - return; - } - // After a few attempts, continue login. We will keep trying once in-world: - if ( mImpl->mSeedCapAttempts >= mImpl->mSeedCapMaxAttemptsBeforeLogin && - STATE_SEED_GRANTED_WAIT == LLStartUp::getStartupState() ) - { - LLStartUp::setStartupState( STATE_SEED_CAP_GRANTED ); - } - - if ( mImpl->mSeedCapAttempts < mImpl->mSeedCapMaxAttempts) - { - LLSD capabilityNames = LLSD::emptyArray(); - mImpl->buildCapabilityNames(capabilityNames); - - LL_INFOS() << "posting to seed " << url << " (retry " - << mImpl->mSeedCapAttempts << ")" << LL_ENDL; - - S32 id = ++mImpl->mHttpResponderID; - LLHTTPClient::post(url, capabilityNames, - BaseCapabilitiesComplete::build(getHandle(), id), - LLSD(), CAP_REQUEST_TIMEOUT); - } - else - { - // *TODO: Give a user pop-up about this error? - LL_WARNS("AppInit", "Capabilities") << "Failed to get seed capabilities from '" << url << "' after " << mImpl->mSeedCapAttempts << " attempts. Giving up!" << LL_ENDL; - } -} - -class SimulatorFeaturesReceived : public LLHTTPClient::Responder -{ - LOG_CLASS(SimulatorFeaturesReceived); -public: - SimulatorFeaturesReceived(const std::string& retry_url, U64 region_handle, - S32 attempt = 0, S32 max_attempts = MAX_CAP_REQUEST_ATTEMPTS) - : mRetryURL(retry_url), mRegionHandle(region_handle), mAttempt(attempt), mMaxAttempts(max_attempts) - { } - - /* virtual */ void httpFailure() - { - LL_WARNS("AppInit", "SimulatorFeatures") << dumpResponse() << LL_ENDL; - retry(); - } - - /* virtual */ void httpSuccess() - { - LLViewerRegion *regionp = LLWorld::getInstance()->getRegionFromHandle(mRegionHandle); - if(!regionp) //region is removed or responder is not created. - { - LL_WARNS("AppInit", "SimulatorFeatures") - << "Received results for region that no longer exists!" << LL_ENDL; - return ; - } - - const LLSD& content = getContent(); - if (!content.isMap()) - { - failureResult(HTTP_INTERNAL_ERROR, "Malformed response contents", content); - return; - } - regionp->setSimulatorFeatures(content); - } - - void retry() - { - if (mAttempt < mMaxAttempts) - { - mAttempt++; - LL_WARNS("AppInit", "SimulatorFeatures") << "Re-trying '" << mRetryURL << "'. Retry #" << mAttempt << LL_ENDL; - LLHTTPClient::get(mRetryURL, new SimulatorFeaturesReceived(*this), LLSD(), CAP_REQUEST_TIMEOUT); - } - } - - std::string mRetryURL; - U64 mRegionHandle; - S32 mAttempt; - S32 mMaxAttempts; -}; - - void LLViewerRegion::setCapability(const std::string& name, const std::string& url) { if(name == "EventQueueGet") @@ -2937,7 +2917,11 @@ void LLViewerRegion::setCapability(const std::string& name, const std::string& u else if (name == "SimulatorFeatures") { // kick off a request for simulator features - LLHTTPClient::get(url, new SimulatorFeaturesReceived(url, getHandle()), LLSD(), CAP_REQUEST_TIMEOUT); + std::string coroname = + LLCoros::instance().launch("LLViewerRegionImpl::requestSimulatorFeatureCoro", + boost::bind(&LLViewerRegionImpl::requestSimulatorFeatureCoro, mImpl, _1, url, getHandle())); + + LL_INFOS("AppInit", "SimulatorFeatures") << "Launching " << coroname << " requesting simulator features from " << url << LL_ENDL; } else { @@ -2960,9 +2944,20 @@ void LLViewerRegion::setCapabilityDebug(const std::string& name, const std::stri mHttpUrl = url ; } } +} + +std::string LLViewerRegion::getCapabilityDebug(const std::string& name) const +{ + CapabilityMap::const_iterator iter = mImpl->mSecondCapabilitiesTracker.find(name); + if (iter == mImpl->mSecondCapabilitiesTracker.end()) + { + return ""; + } + return iter->second; } + bool LLViewerRegion::isSpecialCapabilityName(const std::string &name) { return name == "EventQueueGet" || name == "UntrustedSimulatorMessage"; diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h index c14fa5aee8..d15f2eab20 100755 --- a/indra/newview/llviewerregion.h +++ b/indra/newview/llviewerregion.h @@ -253,13 +253,14 @@ public: // Get/set named capability URLs for this region. void setSeedCapability(const std::string& url); - void failedSeedCapability(); S32 getNumSeedCapRetries(); void setCapability(const std::string& name, const std::string& url); void setCapabilityDebug(const std::string& name, const std::string& url); bool isCapabilityAvailable(const std::string& name) const; // implements LLCapabilityProvider virtual std::string getCapability(const std::string& name) const; + std::string getCapabilityDebug(const std::string& name) const; + // has region received its final (not seed) capability list? bool capabilitiesReceived() const; -- cgit v1.2.3 From 0d302e692fd25e5dd7a37b5ac4c9d14f3e5d470d Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 15 Apr 2015 16:40:01 -0700 Subject: Avatar rendering accountant upgrade. --- indra/newview/llavatarrenderinfoaccountant.cpp | 486 +++++++++---------------- indra/newview/llavatarrenderinfoaccountant.h | 5 +- indra/newview/llviewerregion.cpp | 40 ++ 3 files changed, 215 insertions(+), 316 deletions(-) (limited to 'indra') diff --git a/indra/newview/llavatarrenderinfoaccountant.cpp b/indra/newview/llavatarrenderinfoaccountant.cpp index aeaa832bc7..d532dbc6b1 100644 --- a/indra/newview/llavatarrenderinfoaccountant.cpp +++ b/indra/newview/llavatarrenderinfoaccountant.cpp @@ -46,6 +46,7 @@ #include "llhttpsdhandler.h" #include "httpheaders.h" #include "httpoptions.h" +#include "llcorehttputil.h" static const std::string KEY_AGENTS = "agents"; // map static const std::string KEY_WEIGHT = "weight"; // integer @@ -59,268 +60,176 @@ static const std::string KEY_ERROR = "error"; LLFrameTimer LLAvatarRenderInfoAccountant::sRenderInfoReportTimer; //LLCore::HttpRequest::ptr_t LLAvatarRenderInfoAccountant::sHttpRequest; -#if 0 //========================================================================= -class LLAvatarRenderInfoHandler : public LLHttpSDHandler +void LLAvatarRenderInfoAccountant::avatarRenderInfoGetCoro(LLCoros::self& self, std::string url, U64 regionHandle) { -public: - LLAvatarRenderInfoHandler(const LLURI &uri, U64 regionHandle); + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("EnvironmentRequest", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + + LLSD result = httpAdapter->getAndYield(self, httpRequest, url); + + LLViewerRegion * regionp = LLWorld::getInstance()->getRegionFromHandle(regionHandle); + if (!regionp) + { + LL_WARNS("AvatarRenderInfoAccountant") << "Avatar render weight info received but region not found for " + << regionHandle << LL_ENDL; + return; + } + + LLSD httpResults = result["http_result"]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + + if (!status) + { + LL_WARNS("AvatarRenderInfoAccountant") << "HTTP status, " << status.toTerseString() << LL_ENDL; + return; + } + + if (result.has(KEY_AGENTS)) + { + const LLSD & agents = result[KEY_AGENTS]; + if (agents.isMap()) + { + LLSD::map_const_iterator report_iter = agents.beginMap(); + while (report_iter != agents.endMap()) + { + LLUUID target_agent_id = LLUUID(report_iter->first); + const LLSD & agent_info_map = report_iter->second; + LLViewerObject* avatarp = gObjectList.findObject(target_agent_id); + if (avatarp && + avatarp->isAvatar() && + agent_info_map.isMap()) + { // Extract the data for this avatar + + if (LLAvatarRenderInfoAccountant::logRenderInfo()) + { + LL_INFOS() << "LRI: Agent " << target_agent_id + << ": " << agent_info_map << LL_ENDL; + } + + if (agent_info_map.has(KEY_WEIGHT)) + { + ((LLVOAvatar *) avatarp)->setReportedVisualComplexity(agent_info_map[KEY_WEIGHT].asInteger()); + } + } + report_iter++; + } + } + } // has "agents" + else if (result.has(KEY_ERROR)) + { + const LLSD & error = result[KEY_ERROR]; + LL_WARNS() << "Avatar render info GET error: " + << error[KEY_IDENTIFIER] + << ": " << error[KEY_MESSAGE] + << " from region " << regionp->getName() + << LL_ENDL; + } -protected: - virtual void onSuccess(LLCore::HttpResponse * response, LLSD &content); - virtual void onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status); - -private: - U64 mRegionHandle; -}; - -LLAvatarRenderInfoHandler::LLAvatarRenderInfoHandler(const LLURI &uri, U64 regionHandle) : - LLHttpSDHandler(uri), - mRegionHandle(regionHandle) -{ -} - -void LLAvatarRenderInfoHandler::onSuccess(LLCore::HttpResponse * response, LLSD &content) -{ - LLViewerRegion * regionp = LLWorld::getInstance()->getRegionFromHandle(mRegionHandle); - if (regionp) - { - if (LLAvatarRenderInfoAccountant::logRenderInfo()) - { - LL_INFOS() << "LRI: Result for avatar weights request for region " << regionp->getName() << ":" << LL_ENDL; - } - - if (content.isMap()) - { - if (content.has(KEY_AGENTS)) - { - const LLSD & agents = content[KEY_AGENTS]; - if (agents.isMap()) - { - LLSD::map_const_iterator report_iter = agents.beginMap(); - while (report_iter != agents.endMap()) - { - LLUUID target_agent_id = LLUUID(report_iter->first); - const LLSD & agent_info_map = report_iter->second; - LLViewerObject* avatarp = gObjectList.findObject(target_agent_id); - if (avatarp && - avatarp->isAvatar() && - agent_info_map.isMap()) - { // Extract the data for this avatar - - if (LLAvatarRenderInfoAccountant::logRenderInfo()) - { - LL_INFOS() << "LRI: Agent " << target_agent_id - << ": " << agent_info_map << LL_ENDL; - } - - if (agent_info_map.has(KEY_WEIGHT)) - { - ((LLVOAvatar *)avatarp)->setReportedVisualComplexity(agent_info_map[KEY_WEIGHT].asInteger()); - } - } - report_iter++; - } - } - } // has "agents" - else if (content.has(KEY_ERROR)) - { - const LLSD & error = content[KEY_ERROR]; - LL_WARNS() << "Avatar render info GET error: " - << error[KEY_IDENTIFIER] - << ": " << error[KEY_MESSAGE] - << " from region " << regionp->getName() - << LL_ENDL; - } - } - } - else - { - LL_INFOS() << "Avatar render weight info received but region not found for " - << mRegionHandle << LL_ENDL; - } } -void LLAvatarRenderInfoHandler::onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status) -{ - LLViewerRegion * regionp = LLWorld::getInstance()->getRegionFromHandle(mRegionHandle); - if (regionp) - { - LL_WARNS() << "HTTP error result for avatar weight GET: " << status.toULong() - << ", " << status.toString() - << " returned by region " << regionp->getName() - << LL_ENDL; - } - else - { - LL_WARNS() << "Avatar render weight GET error received but region not found for " - << mRegionHandle - << ", error " << status.toULong() - << ", " << status.toString() - << LL_ENDL; - } -} - - //------------------------------------------------------------------------- -#else -// HTTP responder class for GET request for avatar render weight information -class LLAvatarRenderInfoGetResponder : public LLHTTPClient::Responder -{ -public: - LLAvatarRenderInfoGetResponder(U64 region_handle) : mRegionHandle(region_handle) - { - } - - virtual void error(U32 statusNum, const std::string& reason) - { - LLViewerRegion * regionp = LLWorld::getInstance()->getRegionFromHandle(mRegionHandle); - if (regionp) - { - LL_WARNS() << "HTTP error result for avatar weight GET: " << statusNum - << ", " << reason - << " returned by region " << regionp->getName() - << LL_ENDL; - } - else - { - LL_WARNS() << "Avatar render weight GET error recieved but region not found for " - << mRegionHandle - << ", error " << statusNum - << ", " << reason - << LL_ENDL; - } - - } - - virtual void result(const LLSD& content) - { - LLViewerRegion * regionp = LLWorld::getInstance()->getRegionFromHandle(mRegionHandle); - if (regionp) - { - if (LLAvatarRenderInfoAccountant::logRenderInfo()) - { - LL_INFOS() << "LRI: Result for avatar weights request for region " << regionp->getName() << ":" << LL_ENDL; - } - - if (content.isMap()) - { - if (content.has(KEY_AGENTS)) - { - const LLSD & agents = content[KEY_AGENTS]; - if (agents.isMap()) - { - LLSD::map_const_iterator report_iter = agents.beginMap(); - while (report_iter != agents.endMap()) - { - LLUUID target_agent_id = LLUUID(report_iter->first); - const LLSD & agent_info_map = report_iter->second; - LLViewerObject* avatarp = gObjectList.findObject(target_agent_id); - if (avatarp && - avatarp->isAvatar() && - agent_info_map.isMap()) - { // Extract the data for this avatar - - if (LLAvatarRenderInfoAccountant::logRenderInfo()) - { - LL_INFOS() << "LRI: Agent " << target_agent_id - << ": " << agent_info_map << LL_ENDL; - } - - if (agent_info_map.has(KEY_WEIGHT)) - { - ((LLVOAvatar *) avatarp)->setReportedVisualComplexity(agent_info_map[KEY_WEIGHT].asInteger()); - } - } - report_iter++; - } - } - } // has "agents" - else if (content.has(KEY_ERROR)) - { - const LLSD & error = content[KEY_ERROR]; - LL_WARNS() << "Avatar render info GET error: " - << error[KEY_IDENTIFIER] - << ": " << error[KEY_MESSAGE] - << " from region " << regionp->getName() - << LL_ENDL; - } - } - } - else - { - LL_INFOS() << "Avatar render weight info received but region not found for " - << mRegionHandle << LL_ENDL; - } - } - -private: - U64 mRegionHandle; -}; -#endif - -// HTTP responder class for POST request for avatar render weight information -class LLAvatarRenderInfoPostResponder : public LLHTTPClient::Responder +void LLAvatarRenderInfoAccountant::avatarRenderInfoReportCoro(LLCoros::self& self, std::string url, U64 regionHandle) { -public: - LLAvatarRenderInfoPostResponder(U64 region_handle) : mRegionHandle(region_handle) - { - } + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("EnvironmentRequest", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + + LLViewerRegion * regionp = LLWorld::getInstance()->getRegionFromHandle(regionHandle); + if (!regionp) + { + LL_WARNS("AvatarRenderInfoAccountant") << "Avatar render weight calculation but region not found for " + << regionHandle << LL_ENDL; + return; + } + + if (logRenderInfo()) + { + LL_INFOS("AvatarRenderInfoAccountant") << "LRI: Sending avatar render info to region " << regionp->getName() + << " from " << url << LL_ENDL; + } + + // Build the render info to POST to the region + LLSD report = LLSD::emptyMap(); + LLSD agents = LLSD::emptyMap(); + + std::vector::iterator iter = LLCharacter::sInstances.begin(); + while( iter != LLCharacter::sInstances.end() ) + { + LLVOAvatar* avatar = dynamic_cast(*iter); + if (avatar && + avatar->getRezzedStatus() >= 2 && // Mostly rezzed (maybe without baked textures downloaded) + !avatar->isDead() && // Not dead yet + avatar->getObjectHost() == regionp->getHost()) // Ensure it's on the same region + { + avatar->calculateUpdateRenderCost(); // Make sure the numbers are up-to-date + + LLSD info = LLSD::emptyMap(); + if (avatar->getVisualComplexity() > 0) + { + info[KEY_WEIGHT] = avatar->getVisualComplexity(); + agents[avatar->getID().asString()] = info; + + if (logRenderInfo()) + { + LL_INFOS("AvatarRenderInfoAccountant") << "LRI: Sending avatar render info for " << avatar->getID() + << ": " << info << LL_ENDL; + LL_INFOS("AvatarRenderInfoAccountant") << "LRI: other info geometry " << avatar->getAttachmentGeometryBytes() + << ", area " << avatar->getAttachmentSurfaceArea() + << LL_ENDL; + } + } + } + iter++; + } + + if (agents.size() == 0) + return; + + report[KEY_AGENTS] = agents; + regionp = NULL; + LLSD result = httpAdapter->postAndYield(self, httpRequest, url, report); + + regionp = LLWorld::getInstance()->getRegionFromHandle(regionHandle); + if (!regionp) + { + LL_INFOS("AvatarRenderInfoAccountant") << "Avatar render weight POST result received but region not found for " + << regionHandle << LL_ENDL; + return; + } + + LLSD httpResults = result["http_result"]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + if (!status) + { + LL_WARNS("AvatarRenderInfoAccountant") << "HTTP status, " << status.toTerseString() << LL_ENDL; + return; + } + + if (LLAvatarRenderInfoAccountant::logRenderInfo()) + { + LL_INFOS("AvatarRenderInfoAccountant") << "LRI: Result for avatar weights POST for region " << regionp->getName() + << ": " << result << LL_ENDL; + } + + if (result.isMap()) + { + if (result.has(KEY_ERROR)) + { + const LLSD & error = result[KEY_ERROR]; + LL_WARNS("AvatarRenderInfoAccountant") << "Avatar render info POST error: " + << error[KEY_IDENTIFIER] + << ": " << error[KEY_MESSAGE] + << " from region " << regionp->getName() + << LL_ENDL; + } + } - virtual void error(U32 statusNum, const std::string& reason) - { - LLViewerRegion * regionp = LLWorld::getInstance()->getRegionFromHandle(mRegionHandle); - if (regionp) - { - LL_WARNS() << "HTTP error result for avatar weight POST: " << statusNum - << ", " << reason - << " returned by region " << regionp->getName() - << LL_ENDL; - } - else - { - LL_WARNS() << "Avatar render weight POST error received but region not found for " - << mRegionHandle - << ", error " << statusNum - << ", " << reason - << LL_ENDL; - } - } - virtual void result(const LLSD& content) - { - LLViewerRegion * regionp = LLWorld::getInstance()->getRegionFromHandle(mRegionHandle); - if (regionp) - { - if (LLAvatarRenderInfoAccountant::logRenderInfo()) - { - LL_INFOS() << "LRI: Result for avatar weights POST for region " << regionp->getName() - << ": " << content << LL_ENDL; - } - - if (content.isMap()) - { - if (content.has(KEY_ERROR)) - { - const LLSD & error = content[KEY_ERROR]; - LL_WARNS() << "Avatar render info POST error: " - << error[KEY_IDENTIFIER] - << ": " << error[KEY_MESSAGE] - << " from region " << regionp->getName() - << LL_ENDL; - } - } - } - else - { - LL_INFOS() << "Avatar render weight POST result recieved but region not found for " - << mRegionHandle << LL_ENDL; - } - } - -private: - U64 mRegionHandle; -}; +} // static // Send request for one region, no timer checks @@ -329,53 +238,9 @@ void LLAvatarRenderInfoAccountant::sendRenderInfoToRegion(LLViewerRegion * regio std::string url = regionp->getCapability("AvatarRenderInfo"); if (!url.empty()) { - if (logRenderInfo()) - { - LL_INFOS() << "LRI: Sending avatar render info to region " - << regionp->getName() - << " from " << url - << LL_ENDL; - } - - // Build the render info to POST to the region - LLSD report = LLSD::emptyMap(); - LLSD agents = LLSD::emptyMap(); - - std::vector::iterator iter = LLCharacter::sInstances.begin(); - while( iter != LLCharacter::sInstances.end() ) - { - LLVOAvatar* avatar = dynamic_cast(*iter); - if (avatar && - avatar->getRezzedStatus() >= 2 && // Mostly rezzed (maybe without baked textures downloaded) - !avatar->isDead() && // Not dead yet - avatar->getObjectHost() == regionp->getHost()) // Ensure it's on the same region - { - avatar->calculateUpdateRenderCost(); // Make sure the numbers are up-to-date - - LLSD info = LLSD::emptyMap(); - if (avatar->getVisualComplexity() > 0) - { - info[KEY_WEIGHT] = avatar->getVisualComplexity(); - agents[avatar->getID().asString()] = info; - - if (logRenderInfo()) - { - LL_INFOS() << "LRI: Sending avatar render info for " << avatar->getID() - << ": " << info << LL_ENDL; - LL_INFOS() << "LRI: other info geometry " << avatar->getAttachmentGeometryBytes() - << ", area " << avatar->getAttachmentSurfaceArea() - << LL_ENDL; - } - } - } - iter++; - } - - report[KEY_AGENTS] = agents; - if (agents.size() > 0) - { - LLHTTPClient::post(url, report, new LLAvatarRenderInfoPostResponder(regionp->getHandle())); - } + std::string coroname = + LLCoros::instance().launch("LLAvatarRenderInfoAccountant::avatarRenderInfoReportCoro", + boost::bind(&LLAvatarRenderInfoAccountant::avatarRenderInfoReportCoro, _1, url, regionp->getHandle())); } } @@ -398,19 +263,9 @@ void LLAvatarRenderInfoAccountant::getRenderInfoFromRegion(LLViewerRegion * regi } // First send a request to get the latest data -#if 0 - if (!LLAvatarRenderInfoAccountant::sHttpRequest) - sHttpRequest = LLCore::HttpRequest::ptr_t(new LLCore::HttpRequest()); - LLAppCoreHttp & app_core_http(LLAppViewer::instance()->getAppCoreHttp()); - - LLCore::HttpHeaders::ptr_t httpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false); - LLCore::HttpOptions::ptr_t httpOptions = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false); - LLCore::HttpRequest::policy_t httpPolicy = app_core_http.getPolicy(LLAppCoreHttp::AP_AGENT); - - LLCore::HttpHandle handle = sHttpRequest-> -#else - LLHTTPClient::get(url, new LLAvatarRenderInfoGetResponder(regionp->getHandle())); -#endif + std::string coroname = + LLCoros::instance().launch("LLAvatarRenderInfoAccountant::avatarRenderInfoGetCoro", + boost::bind(&LLAvatarRenderInfoAccountant::avatarRenderInfoGetCoro, _1, url, regionp->getHandle())); } } @@ -514,6 +369,7 @@ void LLAvatarRenderInfoAccountant::expireRenderInfoReportTimer(const LLUUID& reg // static bool LLAvatarRenderInfoAccountant::logRenderInfo() { - static LLCachedControl render_mute_logging_enabled(gSavedSettings, "RenderAutoMuteLogging", false); - return render_mute_logging_enabled; + return true; +// static LLCachedControl render_mute_logging_enabled(gSavedSettings, "RenderAutoMuteLogging", false); +// return render_mute_logging_enabled; } diff --git a/indra/newview/llavatarrenderinfoaccountant.h b/indra/newview/llavatarrenderinfoaccountant.h index 13054f5e2f..1736f03772 100644 --- a/indra/newview/llavatarrenderinfoaccountant.h +++ b/indra/newview/llavatarrenderinfoaccountant.h @@ -30,6 +30,7 @@ #define LL_llavatarrenderinfoaccountant_H #include "httpcommon.h" +#include "llcoros.h" class LLViewerRegion; @@ -55,7 +56,9 @@ private: // Send data updates about once per minute, only need per-frame resolution static LLFrameTimer sRenderInfoReportTimer; -// static LLCore::HttpRequest::ptr_t sHttpRequest; + static void avatarRenderInfoGetCoro(LLCoros::self& self, std::string url, U64 regionHandle); + static void avatarRenderInfoReportCoro(LLCoros::self& self, std::string url, U64 regionHandle); + }; diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index 36dd778746..f78b08eb70 100755 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -201,6 +201,46 @@ public: void requestSimulatorFeatureCoro(LLCoros::self& self, std::string url, U64 regionHandle); }; +// support for secondlife:///app/region/{REGION} SLapps +// N.B. this is defined to work exactly like the classic secondlife://{REGION} +// However, the later syntax cannot support spaces in the region name because +// spaces (and %20 chars) are illegal in the hostname of an http URL. Some +// browsers let you get away with this, but some do not (such as Qt's Webkit). +// Hence we introduced the newer secondlife:///app/region alternative. +class LLRegionHandler : public LLCommandHandler +{ +public: + // requests will be throttled from a non-trusted browser + LLRegionHandler() : LLCommandHandler("region", UNTRUSTED_THROTTLE) {} + + bool handle(const LLSD& params, const LLSD& query_map, LLMediaCtrl* web) + { + // make sure that we at least have a region name + int num_params = params.size(); + if (num_params < 1) + { + return false; + } + + // build a secondlife://{PLACE} SLurl from this SLapp + std::string url = "secondlife://"; + for (int i = 0; i < num_params; i++) + { + if (i > 0) + { + url += "/"; + } + url += params[i].asString(); + } + + // Process the SLapp as if it was a secondlife://{PLACE} SLurl + LLURLDispatcher::dispatch(url, "clicked", web, true); + return true; + } + +}; +LLRegionHandler gRegionHandler; + void LLViewerRegionImpl::requestBaseCapabilitiesCoro(LLCoros::self& self, U64 regionHandle) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); -- cgit v1.2.3 From c4bcc83336c623b97e982443ce2f91d82d1a187d Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 16 Apr 2015 17:01:10 -0700 Subject: Facebook conversion. --- indra/llmessage/llcorehttputil.cpp | 91 +++++- indra/llmessage/llcorehttputil.h | 39 +++ indra/llxml/llcontrol.h | 2 +- indra/newview/llavatarrenderinfoaccountant.cpp | 4 +- indra/newview/llfacebookconnect.cpp | 396 ++++++++++++++++++++++++- indra/newview/llfacebookconnect.h | 11 + indra/newview/llviewerregion.cpp | 40 --- 7 files changed, 522 insertions(+), 61 deletions(-) (limited to 'indra') diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index 2d6cca214c..a3226ee2c3 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -291,7 +291,7 @@ void HttpCoroHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRespons // this method can return a map to the caller. // *TODO: Should it always do this? LLSD newResult = LLSD::emptyMap(); - newResult["content"] = result; + newResult[HttpCoroutineAdapter::HTTP_RESULTS_CONTENT] = result; result = newResult; } } @@ -305,11 +305,6 @@ void HttpCoroHandler::buildStatusEntry(LLCore::HttpResponse *response, LLCore::H LLSD httpresults = LLSD::emptyMap(); writeStatusCodes(status, response->getRequestURL(), httpresults); - // httpresults["success"] = static_cast(status); - // httpresults["type"] = static_cast(status.getType()); - // httpresults["status"] = static_cast(status.getStatus()); - // httpresults["message"] = static_cast(status.getMessage()); - // httpresults["url"] = static_cast(response->getRequestURL()); LLSD httpHeaders = LLSD::emptyMap(); LLCore::HttpHeaders * hdrs = response->getHeaders(); @@ -329,24 +324,24 @@ void HttpCoroHandler::buildStatusEntry(LLCore::HttpResponse *response, LLCore::H } } - httpresults["headers"] = httpHeaders; - result["http_result"] = httpresults; + httpresults[HttpCoroutineAdapter::HTTP_RESULTS_HEADERS] = httpHeaders; + result[HttpCoroutineAdapter::HTTP_RESULTS] = httpresults; } void HttpCoroHandler::writeStatusCodes(LLCore::HttpStatus status, const std::string &url, LLSD &result) { - result["success"] = static_cast(status); - result["type"] = static_cast(status.getType()); - result["status"] = static_cast(status.getStatus()); - result["message"] = static_cast(status.getMessage()); - result["url"] = static_cast(url); + result[HttpCoroutineAdapter::HTTP_RESULTS_SUCCESS] = static_cast(status); + result[HttpCoroutineAdapter::HTTP_RESULTS_TYPE] = static_cast(status.getType()); + result[HttpCoroutineAdapter::HTTP_RESULTS_STATUS] = static_cast(status.getStatus()); + result[HttpCoroutineAdapter::HTTP_RESULTS_MESSAGE] = static_cast(status.getMessage()); + result[HttpCoroutineAdapter::HTTP_RESULTS_URL] = static_cast(url); } LLCore::HttpStatus HttpCoroHandler::getStatusFromLLSD(const LLSD &httpResults) { - LLCore::HttpStatus::type_enum_t type = static_cast(httpResults["type"].asInteger()); - short code = static_cast(httpResults["status"].asInteger()); + LLCore::HttpStatus::type_enum_t type = static_cast(httpResults[HttpCoroutineAdapter::HTTP_RESULTS_TYPE].asInteger()); + short code = static_cast(httpResults[HttpCoroutineAdapter::HTTP_RESULTS_STATUS].asInteger()); return LLCore::HttpStatus(type, code); } @@ -377,6 +372,16 @@ bool HttpRequestPumper::pollRequest(const LLSD&) } //======================================================================== +const std::string HttpCoroutineAdapter::HTTP_RESULTS("http_result"); +const std::string HttpCoroutineAdapter::HTTP_RESULTS_SUCCESS("success"); +const std::string HttpCoroutineAdapter::HTTP_RESULTS_TYPE("type"); +const std::string HttpCoroutineAdapter::HTTP_RESULTS_STATUS("status"); +const std::string HttpCoroutineAdapter::HTTP_RESULTS_MESSAGE("message"); +const std::string HttpCoroutineAdapter::HTTP_RESULTS_URL("url"); +const std::string HttpCoroutineAdapter::HTTP_RESULTS_HEADERS("headers"); +const std::string HttpCoroutineAdapter::HTTP_RESULTS_CONTENT("content"); + + HttpCoroutineAdapter::HttpCoroutineAdapter(const std::string &name, LLCore::HttpRequest::policy_t policyId, LLCore::HttpRequest::priority_t priority) : mAdapterName(name), @@ -422,6 +427,34 @@ LLSD HttpCoroutineAdapter::postAndYield(LLCoros::self & self, LLCore::HttpReques return results; } +LLSD HttpCoroutineAdapter::postAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, + const std::string & url, LLCore::BufferArray::ptr_t rawbody, + LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) +{ + LLEventStream replyPump(mAdapterName, true); + LLCoreHttpUtil::HttpCoroHandler::ptr_t httpHandler = + LLCoreHttpUtil::HttpCoroHandler::ptr_t(new LLCoreHttpUtil::HttpCoroHandler(replyPump)); + + //LL_INFOS() << "Requesting transaction " << transactionId << LL_ENDL; + LLCoreHttpUtil::HttpRequestPumper pumper(request); + // The HTTPCoroHandler does not self delete, so retrieval of a the contained + // pointer from the smart pointer is safe in this case. + LLCore::HttpHandle hhandle = request->requestPost(mPolicyId, mPriority, url, rawbody.get(), + options.get(), headers.get(), httpHandler.get()); + + if (hhandle == LLCORE_HTTP_HANDLE_INVALID) + { + return HttpCoroutineAdapter::buildImmediateErrorResult(request, url); + } + + saveState(hhandle, request, httpHandler); + LLSD results = waitForEventOn(self, replyPump); + cleanState(); + + //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; + return results; +} + LLSD HttpCoroutineAdapter::putAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, const std::string & url, const LLSD & body, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) @@ -477,6 +510,34 @@ LLSD HttpCoroutineAdapter::getAndYield(LLCoros::self & self, LLCore::HttpRequest return results; } +LLSD HttpCoroutineAdapter::deleteAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, + const std::string & url, + LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) +{ + LLEventStream replyPump(mAdapterName + "Reply", true); + LLCoreHttpUtil::HttpCoroHandler::ptr_t httpHandler = + LLCoreHttpUtil::HttpCoroHandler::ptr_t(new LLCoreHttpUtil::HttpCoroHandler(replyPump)); + + //LL_INFOS() << "Requesting transaction " << transactionId << LL_ENDL; + LLCoreHttpUtil::HttpRequestPumper pumper(request); + // The HTTPCoroHandler does not self delete, so retrieval of a the contained + // pointer from the smart pointer is safe in this case. + LLCore::HttpHandle hhandle = request->requestDelete(mPolicyId, mPriority, + url, options.get(), headers.get(), httpHandler.get()); + + if (hhandle == LLCORE_HTTP_HANDLE_INVALID) + { + return HttpCoroutineAdapter::buildImmediateErrorResult(request, url); + } + + saveState(hhandle, request, httpHandler); + LLSD results = waitForEventOn(self, replyPump); + cleanState(); + //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; + return results; +} + + void HttpCoroutineAdapter::cancelYieldingOperation() { LLCore::HttpRequest::ptr_t request = mWeakRequest.lock(); diff --git a/indra/llmessage/llcorehttputil.h b/indra/llmessage/llcorehttputil.h index 6fcf03b95c..cd137dbbe1 100644 --- a/indra/llmessage/llcorehttputil.h +++ b/indra/llmessage/llcorehttputil.h @@ -205,6 +205,7 @@ LLCore::HttpHandle requestPatchWithLLSD(LLCore::HttpRequest::ptr_t & request, class HttpCoroHandler : public LLCore::HttpHandler { public: + typedef boost::shared_ptr ptr_t; typedef boost::weak_ptr wptr_t; @@ -248,6 +249,15 @@ private: class HttpCoroutineAdapter { public: + static const std::string HTTP_RESULTS; + static const std::string HTTP_RESULTS_SUCCESS; + static const std::string HTTP_RESULTS_TYPE; + static const std::string HTTP_RESULTS_STATUS; + static const std::string HTTP_RESULTS_MESSAGE; + static const std::string HTTP_RESULTS_URL; + static const std::string HTTP_RESULTS_HEADERS; + static const std::string HTTP_RESULTS_CONTENT; + typedef boost::shared_ptr ptr_t; typedef boost::weak_ptr wptr_t; @@ -264,6 +274,25 @@ public: const std::string & url, const LLSD & body, LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false), LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false)); + LLSD postAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, + const std::string & url, LLCore::BufferArray::ptr_t rawbody, + LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false), + LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false)); + LLSD postAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, + const std::string & url, const LLSD & body, + LLCore::HttpHeaders::ptr_t &headers) + { + return postAndYield(self, request, url, body, + LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false), headers); + } + + LLSD postAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, + const std::string & url, LLCore::BufferArray::ptr_t &rawbody, + LLCore::HttpHeaders::ptr_t &headers) + { + return postAndYield(self, request, url, rawbody, + LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false), headers); + } /// Execute a Put transaction on the supplied URL and yield execution of /// the coroutine until a result is available. @@ -285,6 +314,16 @@ public: LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false), LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false)); + /// Execute a DELETE transaction on the supplied URL and yield execution of + /// the coroutine until a result is available. + /// + /// @Note: the request's smart pointer is passed by value so that it will + /// not be deallocated during the yield. + LLSD deleteAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, + const std::string & url, + LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false), + LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false)); + /// void cancelYieldingOperation(); diff --git a/indra/llxml/llcontrol.h b/indra/llxml/llcontrol.h index 04575d81e0..8116adeae2 100755 --- a/indra/llxml/llcontrol.h +++ b/indra/llxml/llcontrol.h @@ -256,7 +256,7 @@ public: } else { - LL_WARNS() << "Control " << name << " not found." << LL_ENDL; + LL_WARNS_ONCE() << "Control " << name << " not found." << LL_ENDL; return T(); } return convert_from_llsd(value, type, name); diff --git a/indra/newview/llavatarrenderinfoaccountant.cpp b/indra/newview/llavatarrenderinfoaccountant.cpp index d532dbc6b1..4436fe74d6 100644 --- a/indra/newview/llavatarrenderinfoaccountant.cpp +++ b/indra/newview/llavatarrenderinfoaccountant.cpp @@ -65,7 +65,7 @@ void LLAvatarRenderInfoAccountant::avatarRenderInfoGetCoro(LLCoros::self& self, { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t - httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("EnvironmentRequest", httpPolicy)); + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("AvatarRenderInfoAccountant", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); LLSD result = httpAdapter->getAndYield(self, httpRequest, url); @@ -135,7 +135,7 @@ void LLAvatarRenderInfoAccountant::avatarRenderInfoReportCoro(LLCoros::self& sel { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t - httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("EnvironmentRequest", httpPolicy)); + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("AvatarRenderInfoAccountant", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); LLViewerRegion * regionp = LLWorld::getInstance()->getRegionFromHandle(regionHandle); diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index 28319564e4..dc50ec81f1 100755 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -45,6 +45,7 @@ #include "llfloaterwebcontent.h" #include "llfloaterreg.h" +#include "llcorehttputil.h" boost::scoped_ptr LLFacebookConnect::sStateWatcher(new LLEventStream("FacebookConnectState")); boost::scoped_ptr LLFacebookConnect::sInfoWatcher(new LLEventStream("FacebookConnectInfo")); @@ -125,6 +126,58 @@ LLFacebookConnectHandler gFacebookConnectHandler; /////////////////////////////////////////////////////////////////////////////// // +#if 1 + +void LLFacebookConnect::facebookConnectCoro(LLCoros::self& self, std::string authCode, std::string authState) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FacebookConnect", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); + + LLSD putData; + if (!authCode.empty()) + { + putData["code"] = authCode; + } + if (!authState.empty()) + { + putData["state"] = authState; + } + + httpOpts->setWantHeaders(true); + + setConnectionState(LLFacebookConnect::FB_CONNECTION_IN_PROGRESS); + + LLSD result = httpAdapter->putAndYield(self, httpRequest, getFacebookConnectURL("/connection"), putData, httpOpts); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + if (!status) + { + if (status == LLCore::HttpStatus(HTTP_FOUND)) + { + std::string location = httpResults[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS_HEADERS][HTTP_IN_HEADER_LOCATION]; + if (location.empty()) + { + LL_WARNS("FacebookConnect") << "Missing Location header " << LL_ENDL; + } + else + { + openFacebookWeb(location); + } + } + } + else + { + LL_INFOS("FacebookConnect") << "Connect successful. " << LL_ENDL; + setConnectionState(LLFacebookConnect::FB_CONNECTED); + } + +} + +#else class LLFacebookConnectResponder : public LLHTTPClient::Responder { LOG_CLASS(LLFacebookConnectResponder); @@ -166,9 +219,129 @@ public: } } }; +#endif /////////////////////////////////////////////////////////////////////////////// // +#if 1 +bool LLFacebookConnect::testShareStatus(LLSD &result) +{ + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + + if (status) + return true; + + if (status == LLCore::HttpStatus(HTTP_FOUND)) + { + std::string location = httpResults[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS_HEADERS][HTTP_IN_HEADER_LOCATION]; + if (location.empty()) + { + LL_WARNS("FacebookConnect") << "Missing Location header " << LL_ENDL; + } + else + { + openFacebookWeb(location); + } + } + if (status == LLCore::HttpStatus(HTTP_NOT_FOUND)) + { + LL_DEBUGS("FacebookConnect") << "Not connected. " << LL_ENDL; + connectToFacebook(); + } + else + { + LL_WARNS("FacebookConnect") << "HTTP Status error " << status.toString() << LL_ENDL; + setConnectionState(LLFacebookConnect::FB_POST_FAILED); + log_facebook_connect_error("Share", status.getStatus(), status.toString(), + result.get("error_code"), result.get("error_description")); + } + return false; +} + +void LLFacebookConnect::facebookShareCoro(LLCoros::self& self, std::string route, LLSD share) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FacebookConnect", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + + setConnectionState(LLFacebookConnect::FB_POSTING); + + LLSD result = httpAdapter->postAndYield(self, httpRequest, getFacebookConnectURL(route, true), share); + + if (testShareStatus(result)) + { + toast_user_for_facebook_success(); + LL_DEBUGS("FacebookConnect") << "Post successful. " << LL_ENDL; + setConnectionState(LLFacebookConnect::FB_POSTED); + } +} + +void LLFacebookConnect::facebookShareImageCoro(LLCoros::self& self, std::string route, LLPointer image, std::string caption) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FacebookConnect", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + LLCore::HttpHeaders::ptr_t httpHeaders(new LLCore::HttpHeaders); + + std::string imageFormat; + if (dynamic_cast(image.get())) + { + imageFormat = "png"; + } + else if (dynamic_cast(image.get())) + { + imageFormat = "jpg"; + } + else + { + LL_WARNS() << "Image to upload is not a PNG or JPEG" << LL_ENDL; + return; + } + + // All this code is mostly copied from LLWebProfile::post() + static const std::string boundary = "----------------------------0123abcdefab"; + + std::string contentType = "multipart/form-data; boundary=" + boundary; + httpHeaders->append("Content-Type", contentType.c_str()); + + LLCore::BufferArray::ptr_t raw = LLCore::BufferArray::ptr_t(new LLCore::BufferArray(), false); // + LLCore::BufferArrayStream body(raw.get()); + + // *NOTE: The order seems to matter. + body << "--" << boundary << "\r\n" + << "Content-Disposition: form-data; name=\"caption\"\r\n\r\n" + << caption << "\r\n"; + + body << "--" << boundary << "\r\n" + << "Content-Disposition: form-data; name=\"image\"; filename=\"Untitled." << imageFormat << "\"\r\n" + << "Content-Type: image/" << imageFormat << "\r\n\r\n"; + + // Insert the image data. + // *FIX: Treating this as a string will probably screw it up ... + U8* image_data = image->getData(); + for (S32 i = 0; i < image->getDataSize(); ++i) + { + body << image_data[i]; + } + + body << "\r\n--" << boundary << "--\r\n"; + + setConnectionState(LLFacebookConnect::FB_POSTING); + + LLSD result = httpAdapter->postAndYield(self, httpRequest, getFacebookConnectURL(route, true), raw, httpHeaders); + + if (testShareStatus(result)) + { + toast_user_for_facebook_success(); + LL_DEBUGS("FacebookConnect") << "Post successful. " << LL_ENDL; + setConnectionState(LLFacebookConnect::FB_POSTED); + } +} + +#else class LLFacebookShareResponder : public LLHTTPClient::Responder { LOG_CLASS(LLFacebookShareResponder); @@ -215,9 +388,43 @@ public: } } }; +#endif /////////////////////////////////////////////////////////////////////////////// // +#if 1 +void LLFacebookConnect::facebookDisconnectCoro(LLCoros::self& self) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FacebookConnect", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + + setConnectionState(LLFacebookConnect::FB_DISCONNECTING); + + LLSD result = httpAdapter->deleteAndYield(self, httpRequest, getFacebookConnectURL("/connection")); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + if (!status && (status != LLCore::HttpStatus(HTTP_FOUND))) + { + LL_WARNS("FacebookConnect") << "Failed to disconnect:" << status.toTerseString() << LL_ENDL; + setConnectionState(LLFacebookConnect::FB_DISCONNECT_FAILED); + log_facebook_connect_error("Disconnect", status.getStatus(), status.toString(), + result.get("error_code"), result.get("error_description")); + } + else + { + LL_DEBUGS("FacebookConnect") << "Facebook Disconnect successful. " << LL_ENDL; + clearInfo(); + clearContent(); + //Notify state change + setConnectionState(LLFacebookConnect::FB_NOT_CONNECTED); + } + +} + +#else class LLFacebookDisconnectResponder : public LLHTTPClient::Responder { LOG_CLASS(LLFacebookDisconnectResponder); @@ -261,9 +468,56 @@ public: } } }; +#endif /////////////////////////////////////////////////////////////////////////////// // +#if 1 +void LLFacebookConnect::facebookConnectedCheckCoro(LLCoros::self& self, bool autoConnect) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FacebookConnect", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + + setConnectionState(LLFacebookConnect::FB_CONNECTION_IN_PROGRESS); + + LLSD result = httpAdapter->getAndYield(self, httpRequest, getFacebookConnectURL("/connection", true)); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + + if (!status) + { + if ( status == LLCore::HttpStatus(HTTP_NOT_FOUND) ) + { + LL_DEBUGS("FacebookConnect") << "Not connected. " << LL_ENDL; + if (autoConnect) + { + connectToFacebook(); + } + else + { + setConnectionState(LLFacebookConnect::FB_NOT_CONNECTED); + } + } + else + { + LL_WARNS("FacebookConnect") << "Failed to test connection:" << status.toTerseString() << LL_ENDL; + + setConnectionState(LLFacebookConnect::FB_DISCONNECT_FAILED); + log_facebook_connect_error("Connected", status.getStatus(), status.toString(), + result.get("error_code"), result.get("error_description")); + } + } + else + { + LL_DEBUGS("FacebookConnect") << "Connect successful. " << LL_ENDL; + setConnectionState(LLFacebookConnect::FB_CONNECTED); + } +} + +#else class LLFacebookConnectedResponder : public LLHTTPClient::Responder { LOG_CLASS(LLFacebookConnectedResponder); @@ -308,9 +562,50 @@ public: private: bool mAutoConnect; }; +#endif /////////////////////////////////////////////////////////////////////////////// // +#if 1 +void LLFacebookConnect::facebookConnectInfoCoro(LLCoros::self& self) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FacebookConnect", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + + LLSD result = httpAdapter->getAndYield(self, httpRequest, getFacebookConnectURL("/info", true)); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + + if (status == LLCore::HttpStatus(HTTP_FOUND)) + { + std::string location = httpResults[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS_HEADERS][HTTP_IN_HEADER_LOCATION]; + if (location.empty()) + { + LL_WARNS("FacebookConnect") << "Missing Location header " << LL_ENDL; + } + else + { + openFacebookWeb(location); + } + } + else if (!status) + { + LL_WARNS("FacebookConnect") << "Facebook Info failed: " << status.toString() << LL_ENDL; + log_facebook_connect_error("Info", status.getStatus(), status.toString(), + result.get("error_code"), result.get("error_description")); + } + else + { + LL_INFOS("FacebookConnect") << "Facebook: Info received" << LL_ENDL; + result.erase(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS); + storeInfo(result); + } +} + +#else class LLFacebookInfoResponder : public LLHTTPClient::Responder { LOG_CLASS(LLFacebookInfoResponder); @@ -347,9 +642,51 @@ public: } } }; +#endif /////////////////////////////////////////////////////////////////////////////// // +#if 1 +void LLFacebookConnect::facebookConnectFriendsCoro(LLCoros::self& self) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FacebookConnect", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + + LLSD result = httpAdapter->getAndYield(self, httpRequest, getFacebookConnectURL("/friends", true)); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + + if (status == LLCore::HttpStatus(HTTP_FOUND)) + { + std::string location = httpResults[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS_HEADERS][HTTP_IN_HEADER_LOCATION]; + if (location.empty()) + { + LL_WARNS("FacebookConnect") << "Missing Location header " << LL_ENDL; + } + else + { + openFacebookWeb(location); + } + } + else if (!status) + { + LL_WARNS("FacebookConnect") << "Facebook Friends failed: " << status.toString() << LL_ENDL; + log_facebook_connect_error("Info", status.getStatus(), status.toString(), + result.get("error_code"), result.get("error_description")); + } + else + { + LL_INFOS("FacebookConnect") << "Facebook: Friends received" << LL_ENDL; + result.erase(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS); + LLSD content = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS_CONTENT]; + storeContent(content); + } +} + +#else class LLFacebookFriendsResponder : public LLHTTPClient::Responder { LOG_CLASS(LLFacebookFriendsResponder); @@ -385,6 +722,7 @@ public: } } }; +#endif /////////////////////////////////////////////////////////////////////////////// // @@ -439,6 +777,11 @@ std::string LLFacebookConnect::getFacebookConnectURL(const std::string& route, b void LLFacebookConnect::connectToFacebook(const std::string& auth_code, const std::string& auth_state) { +#if 1 + LLCoros::instance().launch("LLFacebookConnect::facebookConnectCoro", + boost::bind(&LLFacebookConnect::facebookConnectCoro, this, _1, auth_code, auth_state)); + +#else LLSD body; if (!auth_code.empty()) { @@ -450,29 +793,48 @@ void LLFacebookConnect::connectToFacebook(const std::string& auth_code, const st } LLHTTPClient::put(getFacebookConnectURL("/connection"), body, new LLFacebookConnectResponder()); +#endif } void LLFacebookConnect::disconnectFromFacebook() { - LLHTTPClient::del(getFacebookConnectURL("/connection"), new LLFacebookDisconnectResponder()); +#if 1 + LLCoros::instance().launch("LLFacebookConnect::facebookDisconnectCoro", + boost::bind(&LLFacebookConnect::facebookDisconnectCoro, this, _1)); + +#else + LLHTTPClient::del(getFacebookConnectURL("/connection"), new LLFacebookDisconnectResponder()); +#endif } void LLFacebookConnect::checkConnectionToFacebook(bool auto_connect) { +#if 1 + LLCoros::instance().launch("LLFacebookConnect::facebookConnectedCheckCoro", + boost::bind(&LLFacebookConnect::facebookConnectedCheckCoro, this, _1, auto_connect)); + +#else const bool follow_redirects = false; const F32 timeout = HTTP_REQUEST_EXPIRY_SECS; LLHTTPClient::get(getFacebookConnectURL("/connection", true), new LLFacebookConnectedResponder(auto_connect), LLSD(), timeout, follow_redirects); +#endif } void LLFacebookConnect::loadFacebookInfo() { if(mRefreshInfo) { +#if 1 + LLCoros::instance().launch("LLFacebookConnect::facebookConnectInfoCoro", + boost::bind(&LLFacebookConnect::facebookConnectInfoCoro, this, _1)); + +#else const bool follow_redirects = false; const F32 timeout = HTTP_REQUEST_EXPIRY_SECS; LLHTTPClient::get(getFacebookConnectURL("/info", true), new LLFacebookInfoResponder(), LLSD(), timeout, follow_redirects); +#endif } } @@ -480,14 +842,21 @@ void LLFacebookConnect::loadFacebookFriends() { if(mRefreshContent) { +#if 1 + LLCoros::instance().launch("LLFacebookConnect::facebookConnectFriendsCoro", + boost::bind(&LLFacebookConnect::facebookConnectFriendsCoro, this, _1)); +#else + const bool follow_redirects = false; const F32 timeout = HTTP_REQUEST_EXPIRY_SECS; LLHTTPClient::get(getFacebookConnectURL("/friends", true), new LLFacebookFriendsResponder(), LLSD(), timeout, follow_redirects); +#endif } } -void LLFacebookConnect::postCheckin(const std::string& location, const std::string& name, const std::string& description, const std::string& image, const std::string& message) +void LLFacebookConnect::postCheckin(const std::string& location, const std::string& name, + const std::string& description, const std::string& image, const std::string& message) { LLSD body; if (!location.empty()) @@ -511,22 +880,37 @@ void LLFacebookConnect::postCheckin(const std::string& location, const std::stri body["message"] = message; } +#if 1 + LLCoros::instance().launch("LLFacebookConnect::facebookShareCoro", + boost::bind(&LLFacebookConnect::facebookShareCoro, this, _1, "/share/checkin", body)); +#else // Note: we can use that route for different publish action. We should be able to use the same responder. LLHTTPClient::post(getFacebookConnectURL("/share/checkin", true), body, new LLFacebookShareResponder()); +#endif } void LLFacebookConnect::sharePhoto(const std::string& image_url, const std::string& caption) { + // *TODO: I could not find an instace where this method is used. Remove? LLSD body; body["image"] = image_url; body["caption"] = caption; +#if 1 + LLCoros::instance().launch("LLFacebookConnect::facebookShareCoro", + boost::bind(&LLFacebookConnect::facebookShareCoro, this, _1, "/share/photo", body)); +#else // Note: we can use that route for different publish action. We should be able to use the same responder. LLHTTPClient::post(getFacebookConnectURL("/share/photo", true), body, new LLFacebookShareResponder()); +#endif } void LLFacebookConnect::sharePhoto(LLPointer image, const std::string& caption) { +#if 1 + LLCoros::instance().launch("LLFacebookConnect::facebookShareImageCoro", + boost::bind(&LLFacebookConnect::facebookShareImageCoro, this, _1, "/share/photo", image, caption)); +#else std::string imageFormat; if (dynamic_cast(image.get())) { @@ -576,15 +960,21 @@ void LLFacebookConnect::sharePhoto(LLPointer image, const std: // Note: we can use that route for different publish action. We should be able to use the same responder. LLHTTPClient::postRaw(getFacebookConnectURL("/share/photo", true), data, size, new LLFacebookShareResponder(), headers); +#endif } void LLFacebookConnect::updateStatus(const std::string& message) { LLSD body; body["message"] = message; - + +#if 1 + LLCoros::instance().launch("LLFacebookConnect::facebookShareCoro", + boost::bind(&LLFacebookConnect::facebookShareCoro, this, _1, "/share/wall", body)); +#else // Note: we can use that route for different publish action. We should be able to use the same responder. LLHTTPClient::post(getFacebookConnectURL("/share/wall", true), body, new LLFacebookShareResponder()); +#endif } void LLFacebookConnect::storeInfo(const LLSD& info) diff --git a/indra/newview/llfacebookconnect.h b/indra/newview/llfacebookconnect.h index c157db2178..f569c2f486 100644 --- a/indra/newview/llfacebookconnect.h +++ b/indra/newview/llfacebookconnect.h @@ -30,6 +30,8 @@ #include "llsingleton.h" #include "llimage.h" +#include "llcoros.h" +#include "lleventcoro.h" class LLEventPump; @@ -101,6 +103,15 @@ private: static boost::scoped_ptr sStateWatcher; static boost::scoped_ptr sInfoWatcher; static boost::scoped_ptr sContentWatcher; + + bool testShareStatus(LLSD &results); + void facebookConnectCoro(LLCoros::self& self, std::string authCode, std::string authState); + void facebookConnectedCheckCoro(LLCoros::self& self, bool autoConnect); + void facebookDisconnectCoro(LLCoros::self& self); + void facebookShareCoro(LLCoros::self& self, std::string route, LLSD share); + void facebookShareImageCoro(LLCoros::self& self, std::string route, LLPointer image, std::string caption); + void facebookConnectInfoCoro(LLCoros::self& self); + void facebookConnectFriendsCoro(LLCoros::self& self); }; #endif // LL_LLFACEBOOKCONNECT_H diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index f78b08eb70..36dd778746 100755 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -201,46 +201,6 @@ public: void requestSimulatorFeatureCoro(LLCoros::self& self, std::string url, U64 regionHandle); }; -// support for secondlife:///app/region/{REGION} SLapps -// N.B. this is defined to work exactly like the classic secondlife://{REGION} -// However, the later syntax cannot support spaces in the region name because -// spaces (and %20 chars) are illegal in the hostname of an http URL. Some -// browsers let you get away with this, but some do not (such as Qt's Webkit). -// Hence we introduced the newer secondlife:///app/region alternative. -class LLRegionHandler : public LLCommandHandler -{ -public: - // requests will be throttled from a non-trusted browser - LLRegionHandler() : LLCommandHandler("region", UNTRUSTED_THROTTLE) {} - - bool handle(const LLSD& params, const LLSD& query_map, LLMediaCtrl* web) - { - // make sure that we at least have a region name - int num_params = params.size(); - if (num_params < 1) - { - return false; - } - - // build a secondlife://{PLACE} SLurl from this SLapp - std::string url = "secondlife://"; - for (int i = 0; i < num_params; i++) - { - if (i > 0) - { - url += "/"; - } - url += params[i].asString(); - } - - // Process the SLapp as if it was a secondlife://{PLACE} SLurl - LLURLDispatcher::dispatch(url, "clicked", web, true); - return true; - } - -}; -LLRegionHandler gRegionHandler; - void LLViewerRegionImpl::requestBaseCapabilitiesCoro(LLCoros::self& self, U64 regionHandle) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); -- cgit v1.2.3 From 6b8fecb8b084ebe054fb0314d34e04f48fe48b1e Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 17 Apr 2015 08:53:08 -0700 Subject: Removed the excluded code blocks. --- indra/newview/llfacebookconnect.cpp | 381 ------------------------------------ 1 file changed, 381 deletions(-) (limited to 'indra') diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index dc50ec81f1..680b7677af 100755 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -126,8 +126,6 @@ LLFacebookConnectHandler gFacebookConnectHandler; /////////////////////////////////////////////////////////////////////////////// // -#if 1 - void LLFacebookConnect::facebookConnectCoro(LLCoros::self& self, std::string authCode, std::string authState) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); @@ -177,53 +175,8 @@ void LLFacebookConnect::facebookConnectCoro(LLCoros::self& self, std::string aut } -#else -class LLFacebookConnectResponder : public LLHTTPClient::Responder -{ - LOG_CLASS(LLFacebookConnectResponder); -public: - - LLFacebookConnectResponder() - { - LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_CONNECTION_IN_PROGRESS); - } - - /* virtual */ void httpSuccess() - { - LL_DEBUGS("FacebookConnect") << "Connect successful. " << dumpResponse() << LL_ENDL; - LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_CONNECTED); - } - - /* virtual */ void httpFailure() - { - if ( HTTP_FOUND == getStatus() ) - { - const std::string& location = getResponseHeader(HTTP_IN_HEADER_LOCATION); - if (location.empty()) - { - LL_WARNS("FacebookConnect") << "Missing Location header " << dumpResponse() - << "[headers:" << getResponseHeaders() << "]" << LL_ENDL; - } - else - { - LLFacebookConnect::instance().openFacebookWeb(location); - } - } - else - { - LL_WARNS("FacebookConnect") << dumpResponse() << LL_ENDL; - LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_CONNECTION_FAILED); - const LLSD& content = getContent(); - log_facebook_connect_error("Connect", getStatus(), getReason(), - content.get("error_code"), content.get("error_description")); - } - } -}; -#endif - /////////////////////////////////////////////////////////////////////////////// // -#if 1 bool LLFacebookConnect::testShareStatus(LLSD &result) { LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; @@ -341,58 +294,8 @@ void LLFacebookConnect::facebookShareImageCoro(LLCoros::self& self, std::string } } -#else -class LLFacebookShareResponder : public LLHTTPClient::Responder -{ - LOG_CLASS(LLFacebookShareResponder); -public: - - LLFacebookShareResponder() - { - LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_POSTING); - } - - /* virtual */ void httpSuccess() - { - toast_user_for_facebook_success(); - LL_DEBUGS("FacebookConnect") << "Post successful. " << dumpResponse() << LL_ENDL; - LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_POSTED); - } - - /* virtual */ void httpFailure() - { - if ( HTTP_FOUND == getStatus() ) - { - const std::string& location = getResponseHeader(HTTP_IN_HEADER_LOCATION); - if (location.empty()) - { - LL_WARNS("FacebookConnect") << "Missing Location header " << dumpResponse() - << "[headers:" << getResponseHeaders() << "]" << LL_ENDL; - } - else - { - LLFacebookConnect::instance().openFacebookWeb(location); - } - } - else if ( HTTP_NOT_FOUND == getStatus() ) - { - LLFacebookConnect::instance().connectToFacebook(); - } - else - { - LL_WARNS("FacebookConnect") << dumpResponse() << LL_ENDL; - LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_POST_FAILED); - const LLSD& content = getContent(); - log_facebook_connect_error("Share", getStatus(), getReason(), - content.get("error_code"), content.get("error_description")); - } - } -}; -#endif - /////////////////////////////////////////////////////////////////////////////// // -#if 1 void LLFacebookConnect::facebookDisconnectCoro(LLCoros::self& self) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); @@ -424,55 +327,8 @@ void LLFacebookConnect::facebookDisconnectCoro(LLCoros::self& self) } -#else -class LLFacebookDisconnectResponder : public LLHTTPClient::Responder -{ - LOG_CLASS(LLFacebookDisconnectResponder); -public: - - LLFacebookDisconnectResponder() - { - LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_DISCONNECTING); - } - - void setUserDisconnected() - { - // Clear data - LLFacebookConnect::instance().clearInfo(); - LLFacebookConnect::instance().clearContent(); - //Notify state change - LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_NOT_CONNECTED); - } - - /* virtual */ void httpSuccess() - { - LL_DEBUGS("FacebookConnect") << "Disconnect successful. " << dumpResponse() << LL_ENDL; - setUserDisconnected(); - } - - /* virtual */ void httpFailure() - { - //User not found so already disconnected - if ( HTTP_NOT_FOUND == getStatus() ) - { - LL_DEBUGS("FacebookConnect") << "Already disconnected. " << dumpResponse() << LL_ENDL; - setUserDisconnected(); - } - else - { - LL_WARNS("FacebookConnect") << dumpResponse() << LL_ENDL; - LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_DISCONNECT_FAILED); - const LLSD& content = getContent(); - log_facebook_connect_error("Disconnect", getStatus(), getReason(), - content.get("error_code"), content.get("error_description")); - } - } -}; -#endif - /////////////////////////////////////////////////////////////////////////////// // -#if 1 void LLFacebookConnect::facebookConnectedCheckCoro(LLCoros::self& self, bool autoConnect) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); @@ -517,56 +373,8 @@ void LLFacebookConnect::facebookConnectedCheckCoro(LLCoros::self& self, bool aut } } -#else -class LLFacebookConnectedResponder : public LLHTTPClient::Responder -{ - LOG_CLASS(LLFacebookConnectedResponder); -public: - - LLFacebookConnectedResponder(bool auto_connect) : mAutoConnect(auto_connect) - { - LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_CONNECTION_IN_PROGRESS); - } - - /* virtual */ void httpSuccess() - { - LL_DEBUGS("FacebookConnect") << "Connect successful. " << dumpResponse() << LL_ENDL; - LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_CONNECTED); - } - - /* virtual */ void httpFailure() - { - // show the facebook login page if not connected yet - if ( HTTP_NOT_FOUND == getStatus() ) - { - LL_DEBUGS("FacebookConnect") << "Not connected. " << dumpResponse() << LL_ENDL; - if (mAutoConnect) - { - LLFacebookConnect::instance().connectToFacebook(); - } - else - { - LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_NOT_CONNECTED); - } - } - else - { - LL_WARNS("FacebookConnect") << dumpResponse() << LL_ENDL; - LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_DISCONNECT_FAILED); - const LLSD& content = getContent(); - log_facebook_connect_error("Connected", getStatus(), getReason(), - content.get("error_code"), content.get("error_description")); - } - } - -private: - bool mAutoConnect; -}; -#endif - /////////////////////////////////////////////////////////////////////////////// // -#if 1 void LLFacebookConnect::facebookConnectInfoCoro(LLCoros::self& self) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); @@ -605,48 +413,8 @@ void LLFacebookConnect::facebookConnectInfoCoro(LLCoros::self& self) } } -#else -class LLFacebookInfoResponder : public LLHTTPClient::Responder -{ - LOG_CLASS(LLFacebookInfoResponder); -public: - - /* virtual */ void httpSuccess() - { - LL_INFOS("FacebookConnect") << "Facebook: Info received" << LL_ENDL; - LL_DEBUGS("FacebookConnect") << "Getting Facebook info successful. " << dumpResponse() << LL_ENDL; - LLFacebookConnect::instance().storeInfo(getContent()); - } - - /* virtual */ void httpFailure() - { - if ( HTTP_FOUND == getStatus() ) - { - const std::string& location = getResponseHeader(HTTP_IN_HEADER_LOCATION); - if (location.empty()) - { - LL_WARNS("FacebookConnect") << "Missing Location header " << dumpResponse() - << "[headers:" << getResponseHeaders() << "]" << LL_ENDL; - } - else - { - LLFacebookConnect::instance().openFacebookWeb(location); - } - } - else - { - LL_WARNS("FacebookConnect") << dumpResponse() << LL_ENDL; - const LLSD& content = getContent(); - log_facebook_connect_error("Info", getStatus(), getReason(), - content.get("error_code"), content.get("error_description")); - } - } -}; -#endif - /////////////////////////////////////////////////////////////////////////////// // -#if 1 void LLFacebookConnect::facebookConnectFriendsCoro(LLCoros::self& self) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); @@ -686,44 +454,6 @@ void LLFacebookConnect::facebookConnectFriendsCoro(LLCoros::self& self) } } -#else -class LLFacebookFriendsResponder : public LLHTTPClient::Responder -{ - LOG_CLASS(LLFacebookFriendsResponder); -public: - - /* virtual */ void httpSuccess() - { - LL_DEBUGS("FacebookConnect") << "Getting Facebook friends successful. " << dumpResponse() << LL_ENDL; - LLFacebookConnect::instance().storeContent(getContent()); - } - - /* virtual */ void httpFailure() - { - if ( HTTP_FOUND == getStatus() ) - { - const std::string& location = getResponseHeader(HTTP_IN_HEADER_LOCATION); - if (location.empty()) - { - LL_WARNS("FacebookConnect") << "Missing Location header " << dumpResponse() - << "[headers:" << getResponseHeaders() << "]" << LL_ENDL; - } - else - { - LLFacebookConnect::instance().openFacebookWeb(location); - } - } - else - { - LL_WARNS("FacebookConnect") << dumpResponse() << LL_ENDL; - const LLSD& content = getContent(); - log_facebook_connect_error("Friends", getStatus(), getReason(), - content.get("error_code"), content.get("error_description")); - } - } -}; -#endif - /////////////////////////////////////////////////////////////////////////////// // LLFacebookConnect::LLFacebookConnect() @@ -777,64 +507,28 @@ std::string LLFacebookConnect::getFacebookConnectURL(const std::string& route, b void LLFacebookConnect::connectToFacebook(const std::string& auth_code, const std::string& auth_state) { -#if 1 LLCoros::instance().launch("LLFacebookConnect::facebookConnectCoro", boost::bind(&LLFacebookConnect::facebookConnectCoro, this, _1, auth_code, auth_state)); - -#else - LLSD body; - if (!auth_code.empty()) - { - body["code"] = auth_code; - } - if (!auth_state.empty()) - { - body["state"] = auth_state; - } - - LLHTTPClient::put(getFacebookConnectURL("/connection"), body, new LLFacebookConnectResponder()); -#endif } void LLFacebookConnect::disconnectFromFacebook() { -#if 1 LLCoros::instance().launch("LLFacebookConnect::facebookDisconnectCoro", boost::bind(&LLFacebookConnect::facebookDisconnectCoro, this, _1)); - -#else - LLHTTPClient::del(getFacebookConnectURL("/connection"), new LLFacebookDisconnectResponder()); -#endif } void LLFacebookConnect::checkConnectionToFacebook(bool auto_connect) { -#if 1 LLCoros::instance().launch("LLFacebookConnect::facebookConnectedCheckCoro", boost::bind(&LLFacebookConnect::facebookConnectedCheckCoro, this, _1, auto_connect)); - -#else - const bool follow_redirects = false; - const F32 timeout = HTTP_REQUEST_EXPIRY_SECS; - LLHTTPClient::get(getFacebookConnectURL("/connection", true), new LLFacebookConnectedResponder(auto_connect), - LLSD(), timeout, follow_redirects); -#endif } void LLFacebookConnect::loadFacebookInfo() { if(mRefreshInfo) { -#if 1 LLCoros::instance().launch("LLFacebookConnect::facebookConnectInfoCoro", boost::bind(&LLFacebookConnect::facebookConnectInfoCoro, this, _1)); - -#else - const bool follow_redirects = false; - const F32 timeout = HTTP_REQUEST_EXPIRY_SECS; - LLHTTPClient::get(getFacebookConnectURL("/info", true), new LLFacebookInfoResponder(), - LLSD(), timeout, follow_redirects); -#endif } } @@ -842,16 +536,8 @@ void LLFacebookConnect::loadFacebookFriends() { if(mRefreshContent) { -#if 1 LLCoros::instance().launch("LLFacebookConnect::facebookConnectFriendsCoro", boost::bind(&LLFacebookConnect::facebookConnectFriendsCoro, this, _1)); -#else - - const bool follow_redirects = false; - const F32 timeout = HTTP_REQUEST_EXPIRY_SECS; - LLHTTPClient::get(getFacebookConnectURL("/friends", true), new LLFacebookFriendsResponder(), - LLSD(), timeout, follow_redirects); -#endif } } @@ -880,13 +566,8 @@ void LLFacebookConnect::postCheckin(const std::string& location, const std::stri body["message"] = message; } -#if 1 LLCoros::instance().launch("LLFacebookConnect::facebookShareCoro", boost::bind(&LLFacebookConnect::facebookShareCoro, this, _1, "/share/checkin", body)); -#else - // Note: we can use that route for different publish action. We should be able to use the same responder. - LLHTTPClient::post(getFacebookConnectURL("/share/checkin", true), body, new LLFacebookShareResponder()); -#endif } void LLFacebookConnect::sharePhoto(const std::string& image_url, const std::string& caption) @@ -896,71 +577,14 @@ void LLFacebookConnect::sharePhoto(const std::string& image_url, const std::stri body["image"] = image_url; body["caption"] = caption; -#if 1 LLCoros::instance().launch("LLFacebookConnect::facebookShareCoro", boost::bind(&LLFacebookConnect::facebookShareCoro, this, _1, "/share/photo", body)); -#else - // Note: we can use that route for different publish action. We should be able to use the same responder. - LLHTTPClient::post(getFacebookConnectURL("/share/photo", true), body, new LLFacebookShareResponder()); -#endif } void LLFacebookConnect::sharePhoto(LLPointer image, const std::string& caption) { -#if 1 LLCoros::instance().launch("LLFacebookConnect::facebookShareImageCoro", boost::bind(&LLFacebookConnect::facebookShareImageCoro, this, _1, "/share/photo", image, caption)); -#else - std::string imageFormat; - if (dynamic_cast(image.get())) - { - imageFormat = "png"; - } - else if (dynamic_cast(image.get())) - { - imageFormat = "jpg"; - } - else - { - LL_WARNS() << "Image to upload is not a PNG or JPEG" << LL_ENDL; - return; - } - - // All this code is mostly copied from LLWebProfile::post() - const std::string boundary = "----------------------------0123abcdefab"; - - LLSD headers; - headers["Content-Type"] = "multipart/form-data; boundary=" + boundary; - - std::ostringstream body; - - // *NOTE: The order seems to matter. - body << "--" << boundary << "\r\n" - << "Content-Disposition: form-data; name=\"caption\"\r\n\r\n" - << caption << "\r\n"; - - body << "--" << boundary << "\r\n" - << "Content-Disposition: form-data; name=\"image\"; filename=\"Untitled." << imageFormat << "\"\r\n" - << "Content-Type: image/" << imageFormat << "\r\n\r\n"; - - // Insert the image data. - // *FIX: Treating this as a string will probably screw it up ... - U8* image_data = image->getData(); - for (S32 i = 0; i < image->getDataSize(); ++i) - { - body << image_data[i]; - } - - body << "\r\n--" << boundary << "--\r\n"; - - // postRaw() takes ownership of the buffer and releases it later. - size_t size = body.str().size(); - U8 *data = new U8[size]; - memcpy(data, body.str().data(), size); - - // Note: we can use that route for different publish action. We should be able to use the same responder. - LLHTTPClient::postRaw(getFacebookConnectURL("/share/photo", true), data, size, new LLFacebookShareResponder(), headers); -#endif } void LLFacebookConnect::updateStatus(const std::string& message) @@ -968,13 +592,8 @@ void LLFacebookConnect::updateStatus(const std::string& message) LLSD body; body["message"] = message; -#if 1 LLCoros::instance().launch("LLFacebookConnect::facebookShareCoro", boost::bind(&LLFacebookConnect::facebookShareCoro, this, _1, "/share/wall", body)); -#else - // Note: we can use that route for different publish action. We should be able to use the same responder. - LLHTTPClient::post(getFacebookConnectURL("/share/wall", true), body, new LLFacebookShareResponder()); -#endif } void LLFacebookConnect::storeInfo(const LLSD& info) -- cgit v1.2.3 From 737037309fd4ca3ccc0f03bc5bc9a02a1d610a96 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 17 Apr 2015 08:59:25 -0700 Subject: Replace a couple of changes that I didn't mean to remove. --- indra/llxml/llcontrol.h | 2 +- indra/newview/llviewerregion.cpp | 41 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/llxml/llcontrol.h b/indra/llxml/llcontrol.h index 8116adeae2..04575d81e0 100755 --- a/indra/llxml/llcontrol.h +++ b/indra/llxml/llcontrol.h @@ -256,7 +256,7 @@ public: } else { - LL_WARNS_ONCE() << "Control " << name << " not found." << LL_ENDL; + LL_WARNS() << "Control " << name << " not found." << LL_ENDL; return T(); } return convert_from_llsd(value, type, name); diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index 36dd778746..9b26f5c2e1 100755 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -108,6 +108,47 @@ typedef std::map CapabilityMap; static void log_capabilities(const CapabilityMap &capmap); +// support for secondlife:///app/region/{REGION} SLapps +// N.B. this is defined to work exactly like the classic secondlife://{REGION} +// However, the later syntax cannot support spaces in the region name because +// spaces (and %20 chars) are illegal in the hostname of an http URL. Some +// browsers let you get away with this, but some do not (such as Qt's Webkit). +// Hence we introduced the newer secondlife:///app/region alternative. +class LLRegionHandler : public LLCommandHandler +{ +public: + // requests will be throttled from a non-trusted browser + LLRegionHandler() : LLCommandHandler("region", UNTRUSTED_THROTTLE) {} + + bool handle(const LLSD& params, const LLSD& query_map, LLMediaCtrl* web) + { + // make sure that we at least have a region name + int num_params = params.size(); + if (num_params < 1) + { + return false; + } + + // build a secondlife://{PLACE} SLurl from this SLapp + std::string url = "secondlife://"; + for (int i = 0; i < num_params; i++) + { + if (i > 0) + { + url += "/"; + } + url += params[i].asString(); + } + + // Process the SLapp as if it was a secondlife://{PLACE} SLurl + LLURLDispatcher::dispatch(url, "clicked", web, true); + return true; + } + +}; +LLRegionHandler gRegionHandler; + + class LLViewerRegionImpl { public: -- cgit v1.2.3 From 75a6ed716cfe0b5c1ea15c53026999474d55b550 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 17 Apr 2015 09:05:50 -0700 Subject: Remove unused global for mac build. --- indra/newview/llviewerregion.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index 9b26f5c2e1..8cd71e6510 100755 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -95,7 +95,6 @@ // We want to allow for seed cap retry, but its not useful after that 60 seconds. // Give it 3 chances, each at 18 seconds to give ourselves a few seconds to connect anyways if we give up. const S32 MAX_SEED_CAP_ATTEMPTS_BEFORE_LOGIN = 3; -const F32 CAP_REQUEST_TIMEOUT = 18; // Even though we gave up on login, keep trying for caps after we are logged in: const S32 MAX_CAP_REQUEST_ATTEMPTS = 30; const U32 DEFAULT_MAX_REGION_WIDE_PRIM_COUNT = 15000; -- cgit v1.2.3 From 27258d370be634630299a59ab9bea51e55b37bbb Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 20 Apr 2015 11:57:51 -0700 Subject: Flickr conversion. --- indra/llmessage/llcorehttputil.h | 15 +- indra/newview/llfacebookconnect.cpp | 15 +- indra/newview/llflickrconnect.cpp | 573 +++++++++++++++++++----------------- indra/newview/llflickrconnect.h | 11 + 4 files changed, 332 insertions(+), 282 deletions(-) (limited to 'indra') diff --git a/indra/llmessage/llcorehttputil.h b/indra/llmessage/llcorehttputil.h index cd137dbbe1..1e2b50e189 100644 --- a/indra/llmessage/llcorehttputil.h +++ b/indra/llmessage/llcorehttputil.h @@ -261,8 +261,8 @@ public: typedef boost::shared_ptr ptr_t; typedef boost::weak_ptr wptr_t; - HttpCoroutineAdapter(const std::string &name, LLCore::HttpRequest::policy_t policyId, - LLCore::HttpRequest::priority_t priority = 0L); + HttpCoroutineAdapter(const std::string &name, LLCore::HttpRequest::policy_t policyId, + LLCore::HttpRequest::priority_t priority = 0L); ~HttpCoroutineAdapter(); /// Execute a Post transaction on the supplied URL and yield execution of @@ -271,7 +271,7 @@ public: /// @Note: the request's smart pointer is passed by value so that it will /// not be deallocated during the yield. LLSD postAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, - const std::string & url, const LLSD & body, + const std::string & url, const LLSD & body, LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false), LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false)); LLSD postAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, @@ -290,7 +290,7 @@ public: const std::string & url, LLCore::BufferArray::ptr_t &rawbody, LLCore::HttpHeaders::ptr_t &headers) { - return postAndYield(self, request, url, rawbody, + return postAndYield(self, request, url, rawbody, LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false), headers); } @@ -313,6 +313,13 @@ public: const std::string & url, LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false), LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false)); + LLSD getAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, + const std::string & url, LLCore::HttpHeaders::ptr_t &headers) + { + return getAndYield(self, request, url, + LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false), + headers); + } /// Execute a DELETE transaction on the supplied URL and yield execution of /// the coroutine until a result is available. diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index 680b7677af..ec9efe0c7d 100755 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -218,10 +218,13 @@ void LLFacebookConnect::facebookShareCoro(LLCoros::self& self, std::string route LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FacebookConnect", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); + + httpOpts->setWantHeaders(true); setConnectionState(LLFacebookConnect::FB_POSTING); - LLSD result = httpAdapter->postAndYield(self, httpRequest, getFacebookConnectURL(route, true), share); + LLSD result = httpAdapter->postAndYield(self, httpRequest, getFacebookConnectURL(route, true), share, httpOpts); if (testShareStatus(result)) { @@ -238,6 +241,9 @@ void LLFacebookConnect::facebookShareImageCoro(LLCoros::self& self, std::string httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FacebookConnect", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); LLCore::HttpHeaders::ptr_t httpHeaders(new LLCore::HttpHeaders); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); + + httpOpts->setWantHeaders(true); std::string imageFormat; if (dynamic_cast(image.get())) @@ -284,7 +290,7 @@ void LLFacebookConnect::facebookShareImageCoro(LLCoros::self& self, std::string setConnectionState(LLFacebookConnect::FB_POSTING); - LLSD result = httpAdapter->postAndYield(self, httpRequest, getFacebookConnectURL(route, true), raw, httpHeaders); + LLSD result = httpAdapter->postAndYield(self, httpRequest, getFacebookConnectURL(route, true), raw, httpOpts, httpHeaders); if (testShareStatus(result)) { @@ -381,8 +387,11 @@ void LLFacebookConnect::facebookConnectInfoCoro(LLCoros::self& self) LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FacebookConnect", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); + + httpOpts->setWantHeaders(true); - LLSD result = httpAdapter->getAndYield(self, httpRequest, getFacebookConnectURL("/info", true)); + LLSD result = httpAdapter->getAndYield(self, httpRequest, getFacebookConnectURL("/info", true), httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); diff --git a/indra/newview/llflickrconnect.cpp b/indra/newview/llflickrconnect.cpp index b75660ea00..bad37bef6e 100644 --- a/indra/newview/llflickrconnect.cpp +++ b/indra/newview/llflickrconnect.cpp @@ -43,6 +43,7 @@ #include "llfloaterwebcontent.h" #include "llfloaterreg.h" +#include "llcorehttputil.h" boost::scoped_ptr LLFlickrConnect::sStateWatcher(new LLEventStream("FlickrConnectState")); boost::scoped_ptr LLFlickrConnect::sInfoWatcher(new LLEventStream("FlickrConnectInfo")); @@ -67,228 +68,315 @@ void toast_user_for_flickr_success() /////////////////////////////////////////////////////////////////////////////// // -class LLFlickrConnectResponder : public LLHTTPClient::Responder +void LLFlickrConnect::flickrConnectCoro(LLCoros::self& self, std::string requestToken, std::string oauthVerifier) { - LOG_CLASS(LLFlickrConnectResponder); -public: - - LLFlickrConnectResponder() + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FlickrConnect", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); + + httpOpts->setWantHeaders(true); + + LLSD body; + if (!requestToken.empty()) + body["request_token"] = requestToken; + if (!oauthVerifier.empty()) + body["oauth_verifier"] = oauthVerifier; + + setConnectionState(LLFlickrConnect::FLICKR_CONNECTION_IN_PROGRESS); + + LLSD result = httpAdapter->putAndYield(self, httpRequest, getFlickrConnectURL("/connection"), body, httpOpts); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + + if (!status) + { + if ( status == LLCore::HttpStatus(HTTP_FOUND) ) + { + std::string location = httpResults[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS_HEADERS][HTTP_IN_HEADER_LOCATION]; + if (location.empty()) + { + LL_WARNS("FlickrConnect") << "Missing Location header " << LL_ENDL; + } + else + { + openFlickrWeb(location); + } + } + else + { + LL_WARNS("FlickrConnect") << "Connection failed " << status.toString() << LL_ENDL; + setConnectionState(LLFlickrConnect::FLICKR_CONNECTION_FAILED); + log_flickr_connect_error("Connect", status.getStatus(), status.toString(), + result.get("error_code"), result.get("error_description")); + } + } + else { - LLFlickrConnect::instance().setConnectionState(LLFlickrConnect::FLICKR_CONNECTION_IN_PROGRESS); + LL_DEBUGS("FlickrConnect") << "Connect successful. " << LL_ENDL; + setConnectionState(LLFlickrConnect::FLICKR_CONNECTED); } - - /* virtual */ void httpSuccess() - { - LL_DEBUGS("FlickrConnect") << "Connect successful. " << dumpResponse() << LL_ENDL; - LLFlickrConnect::instance().setConnectionState(LLFlickrConnect::FLICKR_CONNECTED); - } - - /* virtual */ void httpFailure() - { - if ( HTTP_FOUND == getStatus() ) - { - const std::string& location = getResponseHeader(HTTP_IN_HEADER_LOCATION); - if (location.empty()) - { - LL_WARNS("FlickrConnect") << "Missing Location header " << dumpResponse() - << "[headers:" << getResponseHeaders() << "]" << LL_ENDL; - } - else - { - LLFlickrConnect::instance().openFlickrWeb(location); - } - } - else - { - LL_WARNS("FlickrConnect") << dumpResponse() << LL_ENDL; - LLFlickrConnect::instance().setConnectionState(LLFlickrConnect::FLICKR_CONNECTION_FAILED); - const LLSD& content = getContent(); - log_flickr_connect_error("Connect", getStatus(), getReason(), - content.get("error_code"), content.get("error_description")); - } - } -}; +} /////////////////////////////////////////////////////////////////////////////// // -class LLFlickrShareResponder : public LLHTTPClient::Responder +bool LLFlickrConnect::testShareStatus(LLSD &result) { - LOG_CLASS(LLFlickrShareResponder); -public: - - LLFlickrShareResponder() - { - LLFlickrConnect::instance().setConnectionState(LLFlickrConnect::FLICKR_POSTING); - } - - /* virtual */ void httpSuccess() - { + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + + if (status) + return true; + + if (status == LLCore::HttpStatus(HTTP_FOUND)) + { + std::string location = httpResults[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS_HEADERS][HTTP_IN_HEADER_LOCATION]; + if (location.empty()) + { + LL_WARNS("FlickrConnect") << "Missing Location header " << LL_ENDL; + } + else + { + openFlickrWeb(location); + } + } + if (status == LLCore::HttpStatus(HTTP_NOT_FOUND)) + { + LL_DEBUGS("FlickrConnect") << "Not connected. " << LL_ENDL; + connectToFlickr(); + } + else + { + LL_WARNS("FlickrConnect") << "HTTP Status error " << status.toString() << LL_ENDL; + setConnectionState(LLFlickrConnect::FLICKR_POST_FAILED); + log_flickr_connect_error("Share", status.getStatus(), status.toString(), + result.get("error_code"), result.get("error_description")); + } + return false; +} + +void LLFlickrConnect::flickrShareCoro(LLCoros::self& self, LLSD share) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FlickrConnect", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); + + httpOpts->setWantHeaders(true); + + setConnectionState(LLFlickrConnect::FLICKR_POSTING); + + LLSD result = httpAdapter->postAndYield(self, httpRequest, getFlickrConnectURL("/share/photo", true), share, httpOpts); + + if (testShareStatus(result)) + { toast_user_for_flickr_success(); - LL_DEBUGS("FlickrConnect") << "Post successful. " << dumpResponse() << LL_ENDL; - LLFlickrConnect::instance().setConnectionState(LLFlickrConnect::FLICKR_POSTED); - } - - /* virtual */ void httpFailure() - { - if ( HTTP_FOUND == getStatus() ) - { - const std::string& location = getResponseHeader(HTTP_IN_HEADER_LOCATION); - if (location.empty()) - { - LL_WARNS("FlickrConnect") << "Missing Location header " << dumpResponse() - << "[headers:" << getResponseHeaders() << "]" << LL_ENDL; - } - else - { - LLFlickrConnect::instance().openFlickrWeb(location); - } - } - else if ( HTTP_NOT_FOUND == getStatus() ) - { - LLFlickrConnect::instance().connectToFlickr(); - } - else - { - LL_WARNS("FlickrConnect") << dumpResponse() << LL_ENDL; - LLFlickrConnect::instance().setConnectionState(LLFlickrConnect::FLICKR_POST_FAILED); - const LLSD& content = getContent(); - log_flickr_connect_error("Share", getStatus(), getReason(), - content.get("error_code"), content.get("error_description")); - } - } -}; + LL_DEBUGS("FlickrConnect") << "Post successful. " << LL_ENDL; + setConnectionState(LLFlickrConnect::FLICKR_POSTED); + } + +} + +void LLFlickrConnect::flickrShareImageCoro(LLCoros::self& self, LLPointer image, std::string title, std::string description, std::string tags, int safetyLevel) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FlickrConnect", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + LLCore::HttpHeaders::ptr_t httpHeaders(new LLCore::HttpHeaders); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); + + httpOpts->setWantHeaders(true); + + std::string imageFormat; + if (dynamic_cast(image.get())) + { + imageFormat = "png"; + } + else if (dynamic_cast(image.get())) + { + imageFormat = "jpg"; + } + else + { + LL_WARNS() << "Image to upload is not a PNG or JPEG" << LL_ENDL; + return; + } + + // All this code is mostly copied from LLWebProfile::post() + const std::string boundary = "----------------------------0123abcdefab"; + + std::string contentType = "multipart/form-data; boundary=" + boundary; + httpHeaders->append("Content-Type", contentType.c_str()); + + LLCore::BufferArray::ptr_t raw = LLCore::BufferArray::ptr_t(new LLCore::BufferArray(), false); // + LLCore::BufferArrayStream body(raw.get()); + + // *NOTE: The order seems to matter. + body << "--" << boundary << "\r\n" + << "Content-Disposition: form-data; name=\"title\"\r\n\r\n" + << title << "\r\n"; + + body << "--" << boundary << "\r\n" + << "Content-Disposition: form-data; name=\"description\"\r\n\r\n" + << description << "\r\n"; + + body << "--" << boundary << "\r\n" + << "Content-Disposition: form-data; name=\"tags\"\r\n\r\n" + << tags << "\r\n"; + + body << "--" << boundary << "\r\n" + << "Content-Disposition: form-data; name=\"safety_level\"\r\n\r\n" + << safetyLevel << "\r\n"; + + body << "--" << boundary << "\r\n" + << "Content-Disposition: form-data; name=\"image\"; filename=\"Untitled." << imageFormat << "\"\r\n" + << "Content-Type: image/" << imageFormat << "\r\n\r\n"; + + // Insert the image data. + // *FIX: Treating this as a string will probably screw it up ... + U8* image_data = image->getData(); + for (S32 i = 0; i < image->getDataSize(); ++i) + { + body << image_data[i]; + } + + body << "\r\n--" << boundary << "--\r\n"; + + LLSD result = httpAdapter->postAndYield(self, httpRequest, getFlickrConnectURL("/share/photo", true), raw, httpOpts, httpHeaders); + + if (testShareStatus(result)) + { + toast_user_for_flickr_success(); + LL_DEBUGS("FlickrConnect") << "Post successful. " << LL_ENDL; + setConnectionState(LLFlickrConnect::FLICKR_POSTED); + } +} /////////////////////////////////////////////////////////////////////////////// // -class LLFlickrDisconnectResponder : public LLHTTPClient::Responder +void LLFlickrConnect::flickrDisconnectCoro(LLCoros::self& self) { - LOG_CLASS(LLFlickrDisconnectResponder); -public: - - LLFlickrDisconnectResponder() - { - LLFlickrConnect::instance().setConnectionState(LLFlickrConnect::FLICKR_DISCONNECTING); - } + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FlickrConnect", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - void setUserDisconnected() - { - // Clear data - LLFlickrConnect::instance().clearInfo(); + setConnectionState(LLFlickrConnect::FLICKR_DISCONNECTING); - //Notify state change - LLFlickrConnect::instance().setConnectionState(LLFlickrConnect::FLICKR_NOT_CONNECTED); - } + LLSD result = httpAdapter->deleteAndYield(self, httpRequest, getFlickrConnectURL("/connection")); - /* virtual */ void httpSuccess() - { - LL_DEBUGS("FlickrConnect") << "Disconnect successful. " << dumpResponse() << LL_ENDL; - setUserDisconnected(); - } - - /* virtual */ void httpFailure() - { - //User not found so already disconnected - if ( HTTP_NOT_FOUND == getStatus() ) - { - LL_DEBUGS("FlickrConnect") << "Already disconnected. " << dumpResponse() << LL_ENDL; - setUserDisconnected(); - } - else - { - LL_WARNS("FlickrConnect") << dumpResponse() << LL_ENDL; - LLFlickrConnect::instance().setConnectionState(LLFlickrConnect::FLICKR_DISCONNECT_FAILED); - const LLSD& content = getContent(); - log_flickr_connect_error("Disconnect", getStatus(), getReason(), - content.get("error_code"), content.get("error_description")); - } - } -}; + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + + if (!status && (status != LLCore::HttpStatus(HTTP_NOT_FOUND))) + { + LL_WARNS("FlickrConnect") << "Disconnect failed!" << LL_ENDL; + setConnectionState(LLFlickrConnect::FLICKR_DISCONNECT_FAILED); + + log_flickr_connect_error("Disconnect", status.getStatus(), status.toString(), + result.get("error_code"), result.get("error_description")); + } + else + { + LL_DEBUGS("FlickrConnect") << "Disconnect successful. " << LL_ENDL; + clearInfo(); + setConnectionState(LLFlickrConnect::FLICKR_NOT_CONNECTED); + } +} /////////////////////////////////////////////////////////////////////////////// // -class LLFlickrConnectedResponder : public LLHTTPClient::Responder +void LLFlickrConnect::flickrConnectedCoro(LLCoros::self& self, bool autoConnect) { - LOG_CLASS(LLFlickrConnectedResponder); -public: - - LLFlickrConnectedResponder(bool auto_connect) : mAutoConnect(auto_connect) + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FacebookConnect", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + + setConnectionState(LLFlickrConnect::FLICKR_CONNECTION_IN_PROGRESS); + + LLSD result = httpAdapter->getAndYield(self, httpRequest, getFlickrConnectURL("/connection", true)); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + + if (!status) { - LLFlickrConnect::instance().setConnectionState(LLFlickrConnect::FLICKR_CONNECTION_IN_PROGRESS); + if (status == LLCore::HttpStatus(HTTP_NOT_FOUND)) + { + LL_DEBUGS("FlickrConnect") << "Not connected. " << LL_ENDL; + if (autoConnect) + { + connectToFlickr(); + } + else + { + setConnectionState(LLFlickrConnect::FLICKR_NOT_CONNECTED); + } + } + else + { + LL_WARNS("FlickrConnect") << "Failed to test connection:" << status.toTerseString() << LL_ENDL; + + setConnectionState(LLFlickrConnect::FLICKR_CONNECTION_FAILED); + log_flickr_connect_error("Connected", status.getStatus(), status.toString(), + result.get("error_code"), result.get("error_description")); + } } - - /* virtual */ void httpSuccess() - { - LL_DEBUGS("FlickrConnect") << "Connect successful. " << dumpResponse() << LL_ENDL; - LLFlickrConnect::instance().setConnectionState(LLFlickrConnect::FLICKR_CONNECTED); - } - - /* virtual */ void httpFailure() - { - // show the facebook login page if not connected yet - if ( HTTP_NOT_FOUND == getStatus() ) - { - LL_DEBUGS("FlickrConnect") << "Not connected. " << dumpResponse() << LL_ENDL; - if (mAutoConnect) - { - LLFlickrConnect::instance().connectToFlickr(); - } - else - { - LLFlickrConnect::instance().setConnectionState(LLFlickrConnect::FLICKR_NOT_CONNECTED); - } - } - else - { - LL_WARNS("FlickrConnect") << dumpResponse() << LL_ENDL; - LLFlickrConnect::instance().setConnectionState(LLFlickrConnect::FLICKR_CONNECTION_FAILED); - const LLSD& content = getContent(); - log_flickr_connect_error("Connected", getStatus(), getReason(), - content.get("error_code"), content.get("error_description")); - } - } - -private: - bool mAutoConnect; -}; + else + { + LL_DEBUGS("FlickrConnect") << "Connect successful. " << LL_ENDL; + setConnectionState(LLFlickrConnect::FLICKR_CONNECTED); + } + +} /////////////////////////////////////////////////////////////////////////////// // -class LLFlickrInfoResponder : public LLHTTPClient::Responder +void LLFlickrConnect::flickrInfoCoro(LLCoros::self& self) { - LOG_CLASS(LLFlickrInfoResponder); -public: + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FacebookConnect", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); - /* virtual */ void httpSuccess() - { - LL_INFOS("FlickrConnect") << "Flickr: Info received" << LL_ENDL; - LL_DEBUGS("FlickrConnect") << "Getting Flickr info successful. " << dumpResponse() << LL_ENDL; - LLFlickrConnect::instance().storeInfo(getContent()); - } - - /* virtual */ void httpFailure() - { - if ( HTTP_FOUND == getStatus() ) - { - const std::string& location = getResponseHeader(HTTP_IN_HEADER_LOCATION); - if (location.empty()) - { - LL_WARNS("FlickrConnect") << "Missing Location header " << dumpResponse() - << "[headers:" << getResponseHeaders() << "]" << LL_ENDL; - } - else - { - LLFlickrConnect::instance().openFlickrWeb(location); - } - } - else - { - LL_WARNS("FlickrConnect") << dumpResponse() << LL_ENDL; - const LLSD& content = getContent(); - log_flickr_connect_error("Info", getStatus(), getReason(), - content.get("error_code"), content.get("error_description")); - } - } -}; + httpOpts->setWantHeaders(true); + + LLSD result = httpAdapter->getAndYield(self, httpRequest, getFlickrConnectURL("/info", true), httpOpts); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + + if (status == LLCore::HttpStatus(HTTP_FOUND)) + { + std::string location = httpResults[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS_HEADERS][HTTP_IN_HEADER_LOCATION]; + if (location.empty()) + { + LL_WARNS("FlickrConnect") << "Missing Location header " << LL_ENDL; + } + else + { + openFlickrWeb(location); + } + } + else if (!status) + { + LL_WARNS("FlickrConnect") << "Flickr Info failed: " << status.toString() << LL_ENDL; + log_flickr_connect_error("Info", status.getStatus(), status.toString(), + result.get("error_code"), result.get("error_description")); + } + else + { + LL_INFOS("FlickrConnect") << "Flickr: Info received" << LL_ENDL; + result.erase(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS); + storeInfo(result); + } +} /////////////////////////////////////////////////////////////////////////////// // @@ -341,36 +429,28 @@ std::string LLFlickrConnect::getFlickrConnectURL(const std::string& route, bool void LLFlickrConnect::connectToFlickr(const std::string& request_token, const std::string& oauth_verifier) { - LLSD body; - if (!request_token.empty()) - body["request_token"] = request_token; - if (!oauth_verifier.empty()) - body["oauth_verifier"] = oauth_verifier; - - LLHTTPClient::put(getFlickrConnectURL("/connection"), body, new LLFlickrConnectResponder()); + LLCoros::instance().launch("LLFlickrConnect::flickrConnectCoro", + boost::bind(&LLFlickrConnect::flickrConnectCoro, this, _1, request_token, oauth_verifier)); } void LLFlickrConnect::disconnectFromFlickr() { - LLHTTPClient::del(getFlickrConnectURL("/connection"), new LLFlickrDisconnectResponder()); + LLCoros::instance().launch("LLFlickrConnect::flickrDisconnectCoro", + boost::bind(&LLFlickrConnect::flickrDisconnectCoro, this, _1)); } void LLFlickrConnect::checkConnectionToFlickr(bool auto_connect) { - const bool follow_redirects = false; - const F32 timeout = HTTP_REQUEST_EXPIRY_SECS; - LLHTTPClient::get(getFlickrConnectURL("/connection", true), new LLFlickrConnectedResponder(auto_connect), - LLSD(), timeout, follow_redirects); + LLCoros::instance().launch("LLFlickrConnect::flickrConnectedCoro", + boost::bind(&LLFlickrConnect::flickrConnectedCoro, this, _1, auto_connect)); } void LLFlickrConnect::loadFlickrInfo() { if(mRefreshInfo) { - const bool follow_redirects = false; - const F32 timeout = HTTP_REQUEST_EXPIRY_SECS; - LLHTTPClient::get(getFlickrConnectURL("/info", true), new LLFlickrInfoResponder(), - LLSD(), timeout, follow_redirects); + LLCoros::instance().launch("LLFlickrConnect::flickrInfoCoro", + boost::bind(&LLFlickrConnect::flickrInfoCoro, this, _1)); } } @@ -382,74 +462,17 @@ void LLFlickrConnect::uploadPhoto(const std::string& image_url, const std::strin body["description"] = description; body["tags"] = tags; body["safety_level"] = safety_level; - - // Note: we can use that route for different publish action. We should be able to use the same responder. - LLHTTPClient::post(getFlickrConnectURL("/share/photo", true), body, new LLFlickrShareResponder()); + + LLCoros::instance().launch("LLFlickrConnect::flickrShareCoro", + boost::bind(&LLFlickrConnect::flickrShareCoro, this, _1, body)); } void LLFlickrConnect::uploadPhoto(LLPointer image, const std::string& title, const std::string& description, const std::string& tags, int safety_level) { - std::string imageFormat; - if (dynamic_cast(image.get())) - { - imageFormat = "png"; - } - else if (dynamic_cast(image.get())) - { - imageFormat = "jpg"; - } - else - { - LL_WARNS() << "Image to upload is not a PNG or JPEG" << LL_ENDL; - return; - } - - // All this code is mostly copied from LLWebProfile::post() - const std::string boundary = "----------------------------0123abcdefab"; - - LLSD headers; - headers["Content-Type"] = "multipart/form-data; boundary=" + boundary; - - std::ostringstream body; - - // *NOTE: The order seems to matter. - body << "--" << boundary << "\r\n" - << "Content-Disposition: form-data; name=\"title\"\r\n\r\n" - << title << "\r\n"; - - body << "--" << boundary << "\r\n" - << "Content-Disposition: form-data; name=\"description\"\r\n\r\n" - << description << "\r\n"; - - body << "--" << boundary << "\r\n" - << "Content-Disposition: form-data; name=\"tags\"\r\n\r\n" - << tags << "\r\n"; - - body << "--" << boundary << "\r\n" - << "Content-Disposition: form-data; name=\"safety_level\"\r\n\r\n" - << safety_level << "\r\n"; - - body << "--" << boundary << "\r\n" - << "Content-Disposition: form-data; name=\"image\"; filename=\"Untitled." << imageFormat << "\"\r\n" - << "Content-Type: image/" << imageFormat << "\r\n\r\n"; - - // Insert the image data. - // *FIX: Treating this as a string will probably screw it up ... - U8* image_data = image->getData(); - for (S32 i = 0; i < image->getDataSize(); ++i) - { - body << image_data[i]; - } - - body << "\r\n--" << boundary << "--\r\n"; - // postRaw() takes ownership of the buffer and releases it later. - size_t size = body.str().size(); - U8 *data = new U8[size]; - memcpy(data, body.str().data(), size); - - // Note: we can use that route for different publish action. We should be able to use the same responder. - LLHTTPClient::postRaw(getFlickrConnectURL("/share/photo", true), data, size, new LLFlickrShareResponder(), headers); + LLCoros::instance().launch("LLFlickrConnect::flickrShareImageCoro", + boost::bind(&LLFlickrConnect::flickrShareImageCoro, this, _1, image, + title, description, tags, safety_level)); } void LLFlickrConnect::storeInfo(const LLSD& info) diff --git a/indra/newview/llflickrconnect.h b/indra/newview/llflickrconnect.h index b127e6e104..26c63f8b08 100644 --- a/indra/newview/llflickrconnect.h +++ b/indra/newview/llflickrconnect.h @@ -30,6 +30,8 @@ #include "llsingleton.h" #include "llimage.h" +#include "llcoros.h" +#include "lleventcoro.h" class LLEventPump; @@ -93,6 +95,15 @@ private: static boost::scoped_ptr sStateWatcher; static boost::scoped_ptr sInfoWatcher; static boost::scoped_ptr sContentWatcher; + + bool testShareStatus(LLSD &result); + void flickrConnectCoro(LLCoros::self& self, std::string requestToken, std::string oauthVerifier); + void flickrShareCoro(LLCoros::self& self, LLSD share); + void flickrShareImageCoro(LLCoros::self& self, LLPointer image, std::string title, std::string description, std::string tags, int safetyLevel); + void flickrDisconnectCoro(LLCoros::self& self); + void flickrConnectedCoro(LLCoros::self& self, bool autoConnect); + void flickrInfoCoro(LLCoros::self& self); + }; #endif // LL_LLFLICKRCONNECT_H -- cgit v1.2.3 From e295dc20e06c4004963ad9549a835c3db66ebddb Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 20 Apr 2015 14:48:41 -0700 Subject: Convert twitter to coroutines. --- indra/newview/llflickrconnect.cpp | 4 +- indra/newview/lltwitterconnect.cpp | 552 +++++++++++++++++++------------------ indra/newview/lltwitterconnect.h | 10 + 3 files changed, 298 insertions(+), 268 deletions(-) (limited to 'indra') diff --git a/indra/newview/llflickrconnect.cpp b/indra/newview/llflickrconnect.cpp index bad37bef6e..d76665a1d5 100644 --- a/indra/newview/llflickrconnect.cpp +++ b/indra/newview/llflickrconnect.cpp @@ -294,7 +294,7 @@ void LLFlickrConnect::flickrConnectedCoro(LLCoros::self& self, bool autoConnect) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t - httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FacebookConnect", httpPolicy)); + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FlickrConnect", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); setConnectionState(LLFlickrConnect::FLICKR_CONNECTION_IN_PROGRESS); @@ -341,7 +341,7 @@ void LLFlickrConnect::flickrInfoCoro(LLCoros::self& self) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t - httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FacebookConnect", httpPolicy)); + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FlickrConnect", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); diff --git a/indra/newview/lltwitterconnect.cpp b/indra/newview/lltwitterconnect.cpp index e983bc883f..cc608fbc2f 100644 --- a/indra/newview/lltwitterconnect.cpp +++ b/indra/newview/lltwitterconnect.cpp @@ -43,6 +43,7 @@ #include "llfloaterwebcontent.h" #include "llfloaterreg.h" +#include "llcorehttputil.h" boost::scoped_ptr LLTwitterConnect::sStateWatcher(new LLEventStream("TwitterConnectState")); boost::scoped_ptr LLTwitterConnect::sInfoWatcher(new LLEventStream("TwitterConnectInfo")); @@ -67,228 +68,302 @@ void toast_user_for_twitter_success() /////////////////////////////////////////////////////////////////////////////// // -class LLTwitterConnectResponder : public LLHTTPClient::Responder +void LLTwitterConnect::twitterConnectCoro(LLCoros::self& self, std::string requestToken, std::string oauthVerifier) { - LOG_CLASS(LLTwitterConnectResponder); -public: - - LLTwitterConnectResponder() + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("TwitterConnect", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); + + httpOpts->setWantHeaders(true); + + LLSD body; + if (!requestToken.empty()) + body["request_token"] = requestToken; + if (!oauthVerifier.empty()) + body["oauth_verifier"] = oauthVerifier; + + setConnectionState(LLTwitterConnect::TWITTER_CONNECTION_IN_PROGRESS); + + LLSD result = httpAdapter->putAndYield(self, httpRequest, getTwitterConnectURL("/connection"), body, httpOpts); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + + if (!status) + { + if ( status == LLCore::HttpStatus(HTTP_FOUND) ) + { + std::string location = httpResults[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS_HEADERS][HTTP_IN_HEADER_LOCATION]; + if (location.empty()) + { + LL_WARNS("FlickrConnect") << "Missing Location header " << LL_ENDL; + } + else + { + openTwitterWeb(location); + } + } + else + { + LL_WARNS("TwitterConnect") << "Connection failed " << status.toString() << LL_ENDL; + setConnectionState(LLTwitterConnect::TWITTER_CONNECTION_FAILED); + log_twitter_connect_error("Connect", status.getStatus(), status.toString(), + result.get("error_code"), result.get("error_description")); + } + } + else { - LLTwitterConnect::instance().setConnectionState(LLTwitterConnect::TWITTER_CONNECTION_IN_PROGRESS); + LL_DEBUGS("TwitterConnect") << "Connect successful. " << LL_ENDL; + setConnectionState(LLTwitterConnect::TWITTER_CONNECTED); } - - /* virtual */ void httpSuccess() - { - LL_DEBUGS("TwitterConnect") << "Connect successful. " << dumpResponse() << LL_ENDL; - LLTwitterConnect::instance().setConnectionState(LLTwitterConnect::TWITTER_CONNECTED); - } - - /* virtual */ void httpFailure() - { - if ( HTTP_FOUND == getStatus() ) - { - const std::string& location = getResponseHeader(HTTP_IN_HEADER_LOCATION); - if (location.empty()) - { - LL_WARNS("TwitterConnect") << "Missing Location header " << dumpResponse() - << "[headers:" << getResponseHeaders() << "]" << LL_ENDL; - } - else - { - LLTwitterConnect::instance().openTwitterWeb(location); - } - } - else - { - LL_WARNS("TwitterConnect") << dumpResponse() << LL_ENDL; - LLTwitterConnect::instance().setConnectionState(LLTwitterConnect::TWITTER_CONNECTION_FAILED); - const LLSD& content = getContent(); - log_twitter_connect_error("Connect", getStatus(), getReason(), - content.get("error_code"), content.get("error_description")); - } - } -}; +} /////////////////////////////////////////////////////////////////////////////// // -class LLTwitterShareResponder : public LLHTTPClient::Responder +bool LLTwitterConnect::testShareStatus(LLSD &result) { - LOG_CLASS(LLTwitterShareResponder); -public: - - LLTwitterShareResponder() - { - LLTwitterConnect::instance().setConnectionState(LLTwitterConnect::TWITTER_POSTING); - } - - /* virtual */ void httpSuccess() - { + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + + if (status) + return true; + + if (status == LLCore::HttpStatus(HTTP_FOUND)) + { + std::string location = httpResults[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS_HEADERS][HTTP_IN_HEADER_LOCATION]; + if (location.empty()) + { + LL_WARNS("TwitterConnect") << "Missing Location header " << LL_ENDL; + } + else + { + openTwitterWeb(location); + } + } + if (status == LLCore::HttpStatus(HTTP_NOT_FOUND)) + { + LL_DEBUGS("TwitterConnect") << "Not connected. " << LL_ENDL; + connectToTwitter(); + } + else + { + LL_WARNS("TwitterConnect") << "HTTP Status error " << status.toString() << LL_ENDL; + setConnectionState(LLTwitterConnect::TWITTER_POST_FAILED); + log_twitter_connect_error("Share", status.getStatus(), status.toString(), + result.get("error_code"), result.get("error_description")); + } + return false; +} + +void LLTwitterConnect::twitterShareCoro(LLCoros::self& self, std::string route, LLSD share) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("TwitterConnect", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); + + httpOpts->setWantHeaders(true); + + setConnectionState(LLTwitterConnect::TWITTER_POSTING); + + LLSD result = httpAdapter->postAndYield(self, httpRequest, getTwitterConnectURL(route, true), share, httpOpts); + + if (testShareStatus(result)) + { toast_user_for_twitter_success(); - LL_DEBUGS("TwitterConnect") << "Post successful. " << dumpResponse() << LL_ENDL; - LLTwitterConnect::instance().setConnectionState(LLTwitterConnect::TWITTER_POSTED); - } - - /* virtual */ void httpFailure() - { - if ( HTTP_FOUND == getStatus() ) - { - const std::string& location = getResponseHeader(HTTP_IN_HEADER_LOCATION); - if (location.empty()) - { - LL_WARNS("TwitterConnect") << "Missing Location header " << dumpResponse() - << "[headers:" << getResponseHeaders() << "]" << LL_ENDL; - } - else - { - LLTwitterConnect::instance().openTwitterWeb(location); - } - } - else if ( HTTP_NOT_FOUND == getStatus() ) - { - LLTwitterConnect::instance().connectToTwitter(); - } - else - { - LL_WARNS("TwitterConnect") << dumpResponse() << LL_ENDL; - LLTwitterConnect::instance().setConnectionState(LLTwitterConnect::TWITTER_POST_FAILED); - const LLSD& content = getContent(); - log_twitter_connect_error("Share", getStatus(), getReason(), - content.get("error_code"), content.get("error_description")); - } - } -}; + LL_DEBUGS("TwitterConnect") << "Post successful. " << LL_ENDL; + setConnectionState(LLTwitterConnect::TWITTER_POSTED); + } +} + +void LLTwitterConnect::twitterShareImageCoro(LLCoros::self& self, LLPointer image, std::string status) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FlickrConnect", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + LLCore::HttpHeaders::ptr_t httpHeaders(new LLCore::HttpHeaders); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); + + httpOpts->setWantHeaders(true); + + std::string imageFormat; + if (dynamic_cast(image.get())) + { + imageFormat = "png"; + } + else if (dynamic_cast(image.get())) + { + imageFormat = "jpg"; + } + else + { + LL_WARNS() << "Image to upload is not a PNG or JPEG" << LL_ENDL; + return; + } + + // All this code is mostly copied from LLWebProfile::post() + const std::string boundary = "----------------------------0123abcdefab"; + + std::string contentType = "multipart/form-data; boundary=" + boundary; + httpHeaders->append("Content-Type", contentType.c_str()); + + LLCore::BufferArray::ptr_t raw = LLCore::BufferArray::ptr_t(new LLCore::BufferArray(), false); // + LLCore::BufferArrayStream body(raw.get()); + + // *NOTE: The order seems to matter. + body << "--" << boundary << "\r\n" + << "Content-Disposition: form-data; name=\"status\"\r\n\r\n" + << status << "\r\n"; + + body << "--" << boundary << "\r\n" + << "Content-Disposition: form-data; name=\"image\"; filename=\"Untitled." << imageFormat << "\"\r\n" + << "Content-Type: image/" << imageFormat << "\r\n\r\n"; + + // Insert the image data. + // *FIX: Treating this as a string will probably screw it up ... + U8* image_data = image->getData(); + for (S32 i = 0; i < image->getDataSize(); ++i) + { + body << image_data[i]; + } + + body << "\r\n--" << boundary << "--\r\n"; + + LLSD result = httpAdapter->postAndYield(self, httpRequest, getTwitterConnectURL("/share/photo", true), raw, httpOpts, httpHeaders); + + if (testShareStatus(result)) + { + toast_user_for_twitter_success(); + LL_DEBUGS("TwitterConnect") << "Post successful. " << LL_ENDL; + setConnectionState(LLTwitterConnect::TWITTER_POSTED); + } +} /////////////////////////////////////////////////////////////////////////////// // -class LLTwitterDisconnectResponder : public LLHTTPClient::Responder +void LLTwitterConnect::twitterDisconnectCoro(LLCoros::self& self) { - LOG_CLASS(LLTwitterDisconnectResponder); -public: - - LLTwitterDisconnectResponder() - { - LLTwitterConnect::instance().setConnectionState(LLTwitterConnect::TWITTER_DISCONNECTING); - } + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("TwitterConnect", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - void setUserDisconnected() - { - // Clear data - LLTwitterConnect::instance().clearInfo(); + setConnectionState(LLTwitterConnect::TWITTER_DISCONNECTING); - //Notify state change - LLTwitterConnect::instance().setConnectionState(LLTwitterConnect::TWITTER_NOT_CONNECTED); - } + LLSD result = httpAdapter->deleteAndYield(self, httpRequest, getTwitterConnectURL("/connection")); - /* virtual */ void httpSuccess() - { - LL_DEBUGS("TwitterConnect") << "Disconnect successful. " << dumpResponse() << LL_ENDL; - setUserDisconnected(); - } - - /* virtual */ void httpFailure() - { - //User not found so already disconnected - if ( HTTP_NOT_FOUND == getStatus() ) - { - LL_DEBUGS("TwitterConnect") << "Already disconnected. " << dumpResponse() << LL_ENDL; - setUserDisconnected(); - } - else - { - LL_WARNS("TwitterConnect") << dumpResponse() << LL_ENDL; - LLTwitterConnect::instance().setConnectionState(LLTwitterConnect::TWITTER_DISCONNECT_FAILED); - const LLSD& content = getContent(); - log_twitter_connect_error("Disconnect", getStatus(), getReason(), - content.get("error_code"), content.get("error_description")); - } - } -}; + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + + if (!status && (status != LLCore::HttpStatus(HTTP_NOT_FOUND))) + { + LL_WARNS("TwitterConnect") << "Disconnect failed!" << LL_ENDL; + setConnectionState(LLTwitterConnect::TWITTER_DISCONNECT_FAILED); + + log_twitter_connect_error("Disconnect", status.getStatus(), status.toString(), + result.get("error_code"), result.get("error_description")); + } + else + { + LL_DEBUGS("TwitterConnect") << "Disconnect successful. " << LL_ENDL; + clearInfo(); + setConnectionState(LLTwitterConnect::TWITTER_NOT_CONNECTED); + } +} /////////////////////////////////////////////////////////////////////////////// // -class LLTwitterConnectedResponder : public LLHTTPClient::Responder +void LLTwitterConnect::twitterConnectedCoro(LLCoros::self& self, bool autoConnect) { - LOG_CLASS(LLTwitterConnectedResponder); -public: - - LLTwitterConnectedResponder(bool auto_connect) : mAutoConnect(auto_connect) + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("TwitterConnect", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + + setConnectionState(LLTwitterConnect::TWITTER_CONNECTION_IN_PROGRESS); + + LLSD result = httpAdapter->getAndYield(self, httpRequest, getTwitterConnectURL("/connection", true)); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + + if (!status) { - LLTwitterConnect::instance().setConnectionState(LLTwitterConnect::TWITTER_CONNECTION_IN_PROGRESS); + if (status == LLCore::HttpStatus(HTTP_NOT_FOUND)) + { + LL_DEBUGS("TwitterConnect") << "Not connected. " << LL_ENDL; + if (autoConnect) + { + connectToTwitter(); + } + else + { + setConnectionState(LLTwitterConnect::TWITTER_NOT_CONNECTED); + } + } + else + { + LL_WARNS("TwitterConnect") << "Failed to test connection:" << status.toTerseString() << LL_ENDL; + + setConnectionState(LLTwitterConnect::TWITTER_CONNECTION_FAILED); + log_twitter_connect_error("Connected", status.getStatus(), status.toString(), + result.get("error_code"), result.get("error_description")); + } + } + else + { + LL_DEBUGS("TwitterConnect") << "Connect successful. " << LL_ENDL; + setConnectionState(LLTwitterConnect::TWITTER_CONNECTED); } - - /* virtual */ void httpSuccess() - { - LL_DEBUGS("TwitterConnect") << "Connect successful. " << dumpResponse() << LL_ENDL; - LLTwitterConnect::instance().setConnectionState(LLTwitterConnect::TWITTER_CONNECTED); - } - - /* virtual */ void httpFailure() - { - // show the facebook login page if not connected yet - if ( HTTP_NOT_FOUND == getStatus() ) - { - LL_DEBUGS("TwitterConnect") << "Not connected. " << dumpResponse() << LL_ENDL; - if (mAutoConnect) - { - LLTwitterConnect::instance().connectToTwitter(); - } - else - { - LLTwitterConnect::instance().setConnectionState(LLTwitterConnect::TWITTER_NOT_CONNECTED); - } - } - else - { - LL_WARNS("TwitterConnect") << dumpResponse() << LL_ENDL; - LLTwitterConnect::instance().setConnectionState(LLTwitterConnect::TWITTER_CONNECTION_FAILED); - const LLSD& content = getContent(); - log_twitter_connect_error("Connected", getStatus(), getReason(), - content.get("error_code"), content.get("error_description")); - } - } - -private: - bool mAutoConnect; -}; + +} /////////////////////////////////////////////////////////////////////////////// // -class LLTwitterInfoResponder : public LLHTTPClient::Responder +void LLTwitterConnect::twitterInfoCoro(LLCoros::self& self) { - LOG_CLASS(LLTwitterInfoResponder); -public: + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("TwitterConnect", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); - /* virtual */ void httpSuccess() - { - LL_INFOS("TwitterConnect") << "Twitter: Info received" << LL_ENDL; - LL_DEBUGS("TwitterConnect") << "Getting Twitter info successful. " << dumpResponse() << LL_ENDL; - LLTwitterConnect::instance().storeInfo(getContent()); - } - - /* virtual */ void httpFailure() - { - if ( HTTP_FOUND == getStatus() ) - { - const std::string& location = getResponseHeader(HTTP_IN_HEADER_LOCATION); - if (location.empty()) - { - LL_WARNS("TwitterConnect") << "Missing Location header " << dumpResponse() - << "[headers:" << getResponseHeaders() << "]" << LL_ENDL; - } - else - { - LLTwitterConnect::instance().openTwitterWeb(location); - } - } - else - { - LL_WARNS("TwitterConnect") << dumpResponse() << LL_ENDL; - const LLSD& content = getContent(); - log_twitter_connect_error("Info", getStatus(), getReason(), - content.get("error_code"), content.get("error_description")); - } - } -}; + httpOpts->setWantHeaders(true); + + LLSD result = httpAdapter->getAndYield(self, httpRequest, getTwitterConnectURL("/info", true), httpOpts); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + + if (status == LLCore::HttpStatus(HTTP_FOUND)) + { + std::string location = httpResults[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS_HEADERS][HTTP_IN_HEADER_LOCATION]; + if (location.empty()) + { + LL_WARNS("TwitterConnect") << "Missing Location header " << LL_ENDL; + } + else + { + openTwitterWeb(location); + } + } + else if (!status) + { + LL_WARNS("TwitterConnect") << "Twitter Info failed: " << status.toString() << LL_ENDL; + log_twitter_connect_error("Info", status.getStatus(), status.toString(), + result.get("error_code"), result.get("error_description")); + } + else + { + LL_INFOS("TwitterConnect") << "Twitter: Info received" << LL_ENDL; + result.erase(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS); + storeInfo(result); + } +} /////////////////////////////////////////////////////////////////////////////// // @@ -341,36 +416,28 @@ std::string LLTwitterConnect::getTwitterConnectURL(const std::string& route, boo void LLTwitterConnect::connectToTwitter(const std::string& request_token, const std::string& oauth_verifier) { - LLSD body; - if (!request_token.empty()) - body["request_token"] = request_token; - if (!oauth_verifier.empty()) - body["oauth_verifier"] = oauth_verifier; - - LLHTTPClient::put(getTwitterConnectURL("/connection"), body, new LLTwitterConnectResponder()); + LLCoros::instance().launch("LLFlickrConnect::flickrConnectCoro", + boost::bind(&LLTwitterConnect::twitterConnectCoro, this, _1, request_token, oauth_verifier)); } void LLTwitterConnect::disconnectFromTwitter() { - LLHTTPClient::del(getTwitterConnectURL("/connection"), new LLTwitterDisconnectResponder()); + LLCoros::instance().launch("LLTwitterConnect::twitterDisconnectCoro", + boost::bind(&LLTwitterConnect::twitterDisconnectCoro, this, _1)); } void LLTwitterConnect::checkConnectionToTwitter(bool auto_connect) { - const bool follow_redirects = false; - const F32 timeout = HTTP_REQUEST_EXPIRY_SECS; - LLHTTPClient::get(getTwitterConnectURL("/connection", true), new LLTwitterConnectedResponder(auto_connect), - LLSD(), timeout, follow_redirects); + LLCoros::instance().launch("LLTwitterConnect::twitterConnectedCoro", + boost::bind(&LLTwitterConnect::twitterConnectedCoro, this, _1, auto_connect)); } void LLTwitterConnect::loadTwitterInfo() { if(mRefreshInfo) { - const bool follow_redirects = false; - const F32 timeout = HTTP_REQUEST_EXPIRY_SECS; - LLHTTPClient::get(getTwitterConnectURL("/info", true), new LLTwitterInfoResponder(), - LLSD(), timeout, follow_redirects); + LLCoros::instance().launch("LLTwitterConnect::twitterInfoCoro", + boost::bind(&LLTwitterConnect::twitterInfoCoro, this, _1)); } } @@ -379,62 +446,15 @@ void LLTwitterConnect::uploadPhoto(const std::string& image_url, const std::stri LLSD body; body["image"] = image_url; body["status"] = status; - - // Note: we can use that route for different publish action. We should be able to use the same responder. - LLHTTPClient::post(getTwitterConnectURL("/share/photo", true), body, new LLTwitterShareResponder()); + + LLCoros::instance().launch("LLTwitterConnect::twitterShareCoro", + boost::bind(&LLTwitterConnect::twitterShareCoro, this, _1, "/share/photo", body)); } void LLTwitterConnect::uploadPhoto(LLPointer image, const std::string& status) { - std::string imageFormat; - if (dynamic_cast(image.get())) - { - imageFormat = "png"; - } - else if (dynamic_cast(image.get())) - { - imageFormat = "jpg"; - } - else - { - LL_WARNS() << "Image to upload is not a PNG or JPEG" << LL_ENDL; - return; - } - - // All this code is mostly copied from LLWebProfile::post() - const std::string boundary = "----------------------------0123abcdefab"; - - LLSD headers; - headers["Content-Type"] = "multipart/form-data; boundary=" + boundary; - - std::ostringstream body; - - // *NOTE: The order seems to matter. - body << "--" << boundary << "\r\n" - << "Content-Disposition: form-data; name=\"status\"\r\n\r\n" - << status << "\r\n"; - - body << "--" << boundary << "\r\n" - << "Content-Disposition: form-data; name=\"image\"; filename=\"Untitled." << imageFormat << "\"\r\n" - << "Content-Type: image/" << imageFormat << "\r\n\r\n"; - - // Insert the image data. - // *FIX: Treating this as a string will probably screw it up ... - U8* image_data = image->getData(); - for (S32 i = 0; i < image->getDataSize(); ++i) - { - body << image_data[i]; - } - - body << "\r\n--" << boundary << "--\r\n"; - - // postRaw() takes ownership of the buffer and releases it later. - size_t size = body.str().size(); - U8 *data = new U8[size]; - memcpy(data, body.str().data(), size); - - // Note: we can use that route for different publish action. We should be able to use the same responder. - LLHTTPClient::postRaw(getTwitterConnectURL("/share/photo", true), data, size, new LLTwitterShareResponder(), headers); + LLCoros::instance().launch("LLTwitterConnect::twitterShareImageCoro", + boost::bind(&LLTwitterConnect::twitterShareImageCoro, this, _1, image, status)); } void LLTwitterConnect::updateStatus(const std::string& status) @@ -442,8 +462,8 @@ void LLTwitterConnect::updateStatus(const std::string& status) LLSD body; body["status"] = status; - // Note: we can use that route for different publish action. We should be able to use the same responder. - LLHTTPClient::post(getTwitterConnectURL("/share/status", true), body, new LLTwitterShareResponder()); + LLCoros::instance().launch("LLTwitterConnect::twitterShareCoro", + boost::bind(&LLTwitterConnect::twitterShareCoro, this, _1, "/share/status", body)); } void LLTwitterConnect::storeInfo(const LLSD& info) diff --git a/indra/newview/lltwitterconnect.h b/indra/newview/lltwitterconnect.h index c1df13f18c..4d11118143 100644 --- a/indra/newview/lltwitterconnect.h +++ b/indra/newview/lltwitterconnect.h @@ -30,6 +30,8 @@ #include "llsingleton.h" #include "llimage.h" +#include "llcoros.h" +#include "lleventcoro.h" class LLEventPump; @@ -94,6 +96,14 @@ private: static boost::scoped_ptr sStateWatcher; static boost::scoped_ptr sInfoWatcher; static boost::scoped_ptr sContentWatcher; + + bool testShareStatus(LLSD &result); + void twitterConnectCoro(LLCoros::self& self, std::string requestToken, std::string oauthVerifier); + void twitterDisconnectCoro(LLCoros::self& self); + void twitterConnectedCoro(LLCoros::self& self, bool autoConnect); + void twitterInfoCoro(LLCoros::self& self); + void twitterShareCoro(LLCoros::self& self, std::string route, LLSD share); + void twitterShareImageCoro(LLCoros::self& self, LLPointer image, std::string status); }; #endif // LL_LLTWITTERCONNECT_H -- cgit v1.2.3 From 11aa05b2869c5ef44f823e7d4948e796a97b9b82 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 20 Apr 2015 15:37:48 -0700 Subject: Fix the EOL --- indra/newview/llviewerregion.cpp | 78 ++++++++++++++++++++-------------------- 1 file changed, 39 insertions(+), 39 deletions(-) (limited to 'indra') diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index 8cd71e6510..4fea51e61d 100755 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -107,45 +107,45 @@ typedef std::map CapabilityMap; static void log_capabilities(const CapabilityMap &capmap); -// support for secondlife:///app/region/{REGION} SLapps -// N.B. this is defined to work exactly like the classic secondlife://{REGION} -// However, the later syntax cannot support spaces in the region name because -// spaces (and %20 chars) are illegal in the hostname of an http URL. Some -// browsers let you get away with this, but some do not (such as Qt's Webkit). -// Hence we introduced the newer secondlife:///app/region alternative. -class LLRegionHandler : public LLCommandHandler -{ -public: - // requests will be throttled from a non-trusted browser - LLRegionHandler() : LLCommandHandler("region", UNTRUSTED_THROTTLE) {} - - bool handle(const LLSD& params, const LLSD& query_map, LLMediaCtrl* web) - { - // make sure that we at least have a region name - int num_params = params.size(); - if (num_params < 1) - { - return false; - } - - // build a secondlife://{PLACE} SLurl from this SLapp - std::string url = "secondlife://"; - for (int i = 0; i < num_params; i++) - { - if (i > 0) - { - url += "/"; - } - url += params[i].asString(); - } - - // Process the SLapp as if it was a secondlife://{PLACE} SLurl - LLURLDispatcher::dispatch(url, "clicked", web, true); - return true; - } - -}; -LLRegionHandler gRegionHandler; +// support for secondlife:///app/region/{REGION} SLapps +// N.B. this is defined to work exactly like the classic secondlife://{REGION} +// However, the later syntax cannot support spaces in the region name because +// spaces (and %20 chars) are illegal in the hostname of an http URL. Some +// browsers let you get away with this, but some do not (such as Qt's Webkit). +// Hence we introduced the newer secondlife:///app/region alternative. +class LLRegionHandler : public LLCommandHandler +{ +public: + // requests will be throttled from a non-trusted browser + LLRegionHandler() : LLCommandHandler("region", UNTRUSTED_THROTTLE) {} + + bool handle(const LLSD& params, const LLSD& query_map, LLMediaCtrl* web) + { + // make sure that we at least have a region name + int num_params = params.size(); + if (num_params < 1) + { + return false; + } + + // build a secondlife://{PLACE} SLurl from this SLapp + std::string url = "secondlife://"; + for (int i = 0; i < num_params; i++) + { + if (i > 0) + { + url += "/"; + } + url += params[i].asString(); + } + + // Process the SLapp as if it was a secondlife://{PLACE} SLurl + LLURLDispatcher::dispatch(url, "clicked", web, true); + return true; + } + +}; +LLRegionHandler gRegionHandler; class LLViewerRegionImpl -- cgit v1.2.3 From e5c281025d941996b94a27c28139d4aacbf68bce Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 23 Apr 2015 13:35:03 -0700 Subject: Convert pathfinding api to coro with new LLCore::Http --- indra/newview/llpathfindingmanager.cpp | 666 ++++++++++++++------------------- indra/newview/llpathfindingmanager.h | 16 +- 2 files changed, 284 insertions(+), 398 deletions(-) (limited to 'indra') diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index 4977a72dc6..303abdb4d0 100755 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -55,6 +55,8 @@ #include "lluuid.h" #include "llviewerregion.h" #include "llweb.h" +#include "llcorehttputil.h" +#include "llworld.h" #define CAP_SERVICE_RETRIEVE_NAVMESH "RetrieveNavMeshSrc" @@ -97,82 +99,6 @@ public: LLHTTPRegistration gHTTPRegistrationAgentStateChangeNode(SIM_MESSAGE_AGENT_STATE_UPDATE); -//--------------------------------------------------------------------------- -// NavMeshStatusResponder -//--------------------------------------------------------------------------- - -class NavMeshStatusResponder : public LLHTTPClient::Responder -{ - LOG_CLASS(NavMeshStatusResponder); -public: - NavMeshStatusResponder(LLViewerRegion *pRegion, bool pIsGetStatusOnly); - virtual ~NavMeshStatusResponder(); - -protected: - virtual void httpSuccess(); - virtual void httpFailure(); - -private: - LLViewerRegion *mRegion; - LLUUID mRegionUUID; - bool mIsGetStatusOnly; -}; - -//--------------------------------------------------------------------------- -// NavMeshResponder -//--------------------------------------------------------------------------- - -class NavMeshResponder : public LLHTTPClient::Responder -{ - LOG_CLASS(NavMeshResponder); -public: - NavMeshResponder(U32 pNavMeshVersion, LLPathfindingNavMeshPtr pNavMeshPtr); - virtual ~NavMeshResponder(); - -protected: - virtual void httpSuccess(); - virtual void httpFailure(); - -private: - U32 mNavMeshVersion; - LLPathfindingNavMeshPtr mNavMeshPtr; -}; - -//--------------------------------------------------------------------------- -// AgentStateResponder -//--------------------------------------------------------------------------- - -class AgentStateResponder : public LLHTTPClient::Responder -{ - LOG_CLASS(AgentStateResponder); -public: - AgentStateResponder(); - virtual ~AgentStateResponder(); - -protected: - virtual void httpSuccess(); - virtual void httpFailure(); -}; - - -//--------------------------------------------------------------------------- -// NavMeshRebakeResponder -//--------------------------------------------------------------------------- -class NavMeshRebakeResponder : public LLHTTPClient::Responder -{ - LOG_CLASS(NavMeshRebakeResponder); -public: - NavMeshRebakeResponder(LLPathfindingManager::rebake_navmesh_callback_t pRebakeNavMeshCallback); - virtual ~NavMeshRebakeResponder(); - -protected: - virtual void httpSuccess(); - virtual void httpFailure(); - -private: - LLPathfindingManager::rebake_navmesh_callback_t mRebakeNavMeshCallback; -}; - //--------------------------------------------------------------------------- // LinksetsResponder //--------------------------------------------------------------------------- @@ -188,6 +114,8 @@ public: void handleTerrainLinksetsResult(const LLSD &pContent); void handleTerrainLinksetsError(); + typedef boost::shared_ptr ptr_t; + protected: private: @@ -213,64 +141,6 @@ private: typedef boost::shared_ptr LinksetsResponderPtr; -//--------------------------------------------------------------------------- -// ObjectLinksetsResponder -//--------------------------------------------------------------------------- - -class ObjectLinksetsResponder : public LLHTTPClient::Responder -{ - LOG_CLASS(ObjectLinksetsResponder); -public: - ObjectLinksetsResponder(LinksetsResponderPtr pLinksetsResponsderPtr); - virtual ~ObjectLinksetsResponder(); - -protected: - virtual void httpSuccess(); - virtual void httpFailure(); - -private: - LinksetsResponderPtr mLinksetsResponsderPtr; -}; - -//--------------------------------------------------------------------------- -// TerrainLinksetsResponder -//--------------------------------------------------------------------------- - -class TerrainLinksetsResponder : public LLHTTPClient::Responder -{ - LOG_CLASS(TerrainLinksetsResponder); -public: - TerrainLinksetsResponder(LinksetsResponderPtr pLinksetsResponsderPtr); - virtual ~TerrainLinksetsResponder(); - -protected: - virtual void httpSuccess(); - virtual void httpFailure(); - -private: - LinksetsResponderPtr mLinksetsResponsderPtr; -}; - -//--------------------------------------------------------------------------- -// CharactersResponder -//--------------------------------------------------------------------------- - -class CharactersResponder : public LLHTTPClient::Responder -{ - LOG_CLASS(TerrainLinksetsResponder); -public: - CharactersResponder(LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::object_request_callback_t pCharactersCallback); - virtual ~CharactersResponder(); - -protected: - virtual void httpSuccess(); - virtual void httpFailure(); - -private: - LLPathfindingManager::request_id_t mRequestId; - LLPathfindingManager::object_request_callback_t mCharactersCallback; -}; - //--------------------------------------------------------------------------- // LLPathfindingManager //--------------------------------------------------------------------------- @@ -350,11 +220,13 @@ void LLPathfindingManager::requestGetNavMeshForRegion(LLViewerRegion *pRegion, b } else { - std::string navMeshStatusURL = getNavMeshStatusURLForRegion(pRegion); - llassert(!navMeshStatusURL.empty()); - navMeshPtr->handleNavMeshCheckVersion(); - LLHTTPClient::ResponderPtr navMeshStatusResponder = new NavMeshStatusResponder(pRegion, pIsGetStatusOnly); - LLHTTPClient::get(navMeshStatusURL, navMeshStatusResponder); + std::string navMeshStatusURL = getNavMeshStatusURLForRegion(pRegion); + llassert(!navMeshStatusURL.empty()); + navMeshPtr->handleNavMeshCheckVersion(); + + U64 regionHandle = pRegion->getHandle(); + std::string coroname = LLCoros::instance().launch("LLPathfindingManager::navMeshStatusRequestCoro", + boost::bind(&LLPathfindingManager::navMeshStatusRequestCoro, this, _1, navMeshStatusURL, regionHandle, pIsGetStatusOnly)); } } @@ -385,15 +257,15 @@ void LLPathfindingManager::requestGetLinksets(request_id_t pRequestId, object_re pLinksetsCallback(pRequestId, kRequestStarted, emptyLinksetListPtr); bool doRequestTerrain = isAllowViewTerrainProperties(); - LinksetsResponderPtr linksetsResponderPtr(new LinksetsResponder(pRequestId, pLinksetsCallback, true, doRequestTerrain)); + LinksetsResponder::ptr_t linksetsResponderPtr(new LinksetsResponder(pRequestId, pLinksetsCallback, true, doRequestTerrain)); - LLHTTPClient::ResponderPtr objectLinksetsResponder = new ObjectLinksetsResponder(linksetsResponderPtr); - LLHTTPClient::get(objectLinksetsURL, objectLinksetsResponder); + std::string coroname = LLCoros::instance().launch("LLPathfindingManager::linksetObjectsCoro", + boost::bind(&LLPathfindingManager::linksetObjectsCoro, this, _1, objectLinksetsURL, linksetsResponderPtr, LLSD())); - if (doRequestTerrain) + if (doRequestTerrain) { - LLHTTPClient::ResponderPtr terrainLinksetsResponder = new TerrainLinksetsResponder(linksetsResponderPtr); - LLHTTPClient::get(terrainLinksetsURL, terrainLinksetsResponder); + std::string coroname = LLCoros::instance().launch("LLPathfindingManager::linksetTerrainCoro", + boost::bind(&LLPathfindingManager::linksetTerrainCoro, this, _1, terrainLinksetsURL, linksetsResponderPtr, LLSD())); } } } @@ -432,18 +304,18 @@ void LLPathfindingManager::requestSetLinksets(request_id_t pRequestId, const LLP { pLinksetsCallback(pRequestId, kRequestStarted, emptyLinksetListPtr); - LinksetsResponderPtr linksetsResponderPtr(new LinksetsResponder(pRequestId, pLinksetsCallback, !objectPostData.isUndefined(), !terrainPostData.isUndefined())); + LinksetsResponder::ptr_t linksetsResponderPtr(new LinksetsResponder(pRequestId, pLinksetsCallback, !objectPostData.isUndefined(), !terrainPostData.isUndefined())); if (!objectPostData.isUndefined()) { - LLHTTPClient::ResponderPtr objectLinksetsResponder = new ObjectLinksetsResponder(linksetsResponderPtr); - LLHTTPClient::put(objectLinksetsURL, objectPostData, objectLinksetsResponder); + std::string coroname = LLCoros::instance().launch("LLPathfindingManager::linksetObjectsCoro", + boost::bind(&LLPathfindingManager::linksetObjectsCoro, this, _1, objectLinksetsURL, linksetsResponderPtr, objectPostData)); } if (!terrainPostData.isUndefined()) { - LLHTTPClient::ResponderPtr terrainLinksetsResponder = new TerrainLinksetsResponder(linksetsResponderPtr); - LLHTTPClient::put(terrainLinksetsURL, terrainPostData, terrainLinksetsResponder); + std::string coroname = LLCoros::instance().launch("LLPathfindingManager::linksetTerrainCoro", + boost::bind(&LLPathfindingManager::linksetTerrainCoro, this, _1, terrainLinksetsURL, linksetsResponderPtr, terrainPostData)); } } } @@ -475,8 +347,8 @@ void LLPathfindingManager::requestGetCharacters(request_id_t pRequestId, object_ { pCharactersCallback(pRequestId, kRequestStarted, emptyCharacterListPtr); - LLHTTPClient::ResponderPtr charactersResponder = new CharactersResponder(pRequestId, pCharactersCallback); - LLHTTPClient::get(charactersURL, charactersResponder); + std::string coroname = LLCoros::instance().launch("LLPathfindingManager::charactersCoro", + boost::bind(&LLPathfindingManager::charactersCoro, this, _1, charactersURL, pRequestId, pCharactersCallback)); } } } @@ -508,8 +380,9 @@ void LLPathfindingManager::requestGetAgentState() { std::string agentStateURL = getAgentStateURLForRegion(currentRegion); llassert(!agentStateURL.empty()); - LLHTTPClient::ResponderPtr responder = new AgentStateResponder(); - LLHTTPClient::get(agentStateURL, responder); + + std::string coroname = LLCoros::instance().launch("LLPathfindingManager::navAgentStateRequestCoro", + boost::bind(&LLPathfindingManager::navAgentStateRequestCoro, this, _1, agentStateURL)); } } } @@ -530,35 +403,9 @@ void LLPathfindingManager::requestRebakeNavMesh(rebake_navmesh_callback_t pRebak { std::string navMeshStatusURL = getNavMeshStatusURLForCurrentRegion(); llassert(!navMeshStatusURL.empty()); - LLSD postData; - postData["command"] = "rebuild"; - LLHTTPClient::ResponderPtr responder = new NavMeshRebakeResponder(pRebakeNavMeshCallback); - LLHTTPClient::post(navMeshStatusURL, postData, responder); - } -} - -void LLPathfindingManager::sendRequestGetNavMeshForRegion(LLPathfindingNavMeshPtr navMeshPtr, LLViewerRegion *pRegion, const LLPathfindingNavMeshStatus &pNavMeshStatus) -{ - if ((pRegion == NULL) || !pRegion->isAlive()) - { - navMeshPtr->handleNavMeshNotEnabled(); - } - else - { - std::string navMeshURL = getRetrieveNavMeshURLForRegion(pRegion); - - if (navMeshURL.empty()) - { - navMeshPtr->handleNavMeshNotEnabled(); - } - else - { - navMeshPtr->handleNavMeshStart(pNavMeshStatus); - LLHTTPClient::ResponderPtr responder = new NavMeshResponder(pNavMeshStatus.getVersion(), navMeshPtr); - LLSD postData; - LLHTTPClient::post(navMeshURL, postData, responder); - } + std::string coroname = LLCoros::instance().launch("LLPathfindingManager::navMeshRebakeCoro", + boost::bind(&LLPathfindingManager::navMeshRebakeCoro, this, _1, navMeshStatusURL, pRebakeNavMeshCallback)); } } @@ -602,29 +449,250 @@ void LLPathfindingManager::handleDeferredGetCharactersForRegion(const LLUUID &pR } } -void LLPathfindingManager::handleNavMeshStatusRequest(const LLPathfindingNavMeshStatus &pNavMeshStatus, LLViewerRegion *pRegion, bool pIsGetStatusOnly) +void LLPathfindingManager::navMeshStatusRequestCoro(LLCoros::self& self, std::string url, U64 regionHandle, bool isGetStatusOnly) { - LLPathfindingNavMeshPtr navMeshPtr = getNavMeshForRegion(pNavMeshStatus.getRegionUUID()); + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("NavMeshStatusRequest", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + + LLViewerRegion *region = LLWorld::getInstance()->getRegionFromHandle(regionHandle); + if (!region) + { + LL_WARNS("PathfindingManager") << "Attempting to retrieve navmesh status for region that has gone away." << LL_ENDL; + return; + } + LLUUID regionUUID = region->getRegionID(); + + region = NULL; + LLSD result = httpAdapter->getAndYield(self, httpRequest, url); + + region = LLWorld::getInstance()->getRegionFromHandle(regionHandle); - if (!pNavMeshStatus.isValid()) - { - navMeshPtr->handleNavMeshError(); - } - else - { - if (navMeshPtr->hasNavMeshVersion(pNavMeshStatus)) - { - navMeshPtr->handleRefresh(pNavMeshStatus); - } - else if (pIsGetStatusOnly) - { - navMeshPtr->handleNavMeshNewVersion(pNavMeshStatus); - } - else - { - sendRequestGetNavMeshForRegion(navMeshPtr, pRegion, pNavMeshStatus); - } - } + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + + LLPathfindingNavMeshStatus navMeshStatus(regionUUID); + if (!status) + { + LL_WARNS("PathfindingManager") << "HTTP status, " << status.toTerseString() << + ". Building using empty status." << LL_ENDL; + } + else + { + result.erase(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS); + navMeshStatus = LLPathfindingNavMeshStatus(regionUUID, result); + } + + LLPathfindingNavMeshPtr navMeshPtr = getNavMeshForRegion(regionUUID); + + if (!navMeshStatus.isValid()) + { + navMeshPtr->handleNavMeshError(); + return; + } + else if (navMeshPtr->hasNavMeshVersion(navMeshStatus)) + { + navMeshPtr->handleRefresh(navMeshStatus); + return; + } + else if (isGetStatusOnly) + { + navMeshPtr->handleNavMeshNewVersion(navMeshStatus); + return; + } + + if ((!region) || !region->isAlive()) + { + LL_WARNS("PathfindingManager") << "About to update navmesh status for region that has gone away." << LL_ENDL; + navMeshPtr->handleNavMeshNotEnabled(); + return; + } + + std::string navMeshURL = getRetrieveNavMeshURLForRegion(region); + + if (navMeshURL.empty()) + { + navMeshPtr->handleNavMeshNotEnabled(); + return; + } + + navMeshPtr->handleNavMeshStart(navMeshStatus); + + LLSD postData; + result = httpAdapter->postAndYield(self, httpRequest, navMeshURL, postData); + + U32 navMeshVersion = navMeshStatus.getVersion(); + + if (!status) + { + LL_WARNS("PathfindingManager") << "HTTP status, " << status.toTerseString() << + ". reporting error." << LL_ENDL; + navMeshPtr->handleNavMeshError(navMeshVersion); + } + else + { + result.erase(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS); + navMeshPtr->handleNavMeshResult(result, navMeshVersion); + + } + +} + +void LLPathfindingManager::navAgentStateRequestCoro(LLCoros::self& self, std::string url) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("NavAgentStateRequest", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + + LLSD result = httpAdapter->getAndYield(self, httpRequest, url); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + + bool canRebake = false; + if (!status) + { + LL_WARNS("PathfindingManager") << "HTTP status, " << status.toTerseString() << + ". Building using empty status." << LL_ENDL; + } + else + { + llassert(result.has(AGENT_STATE_CAN_REBAKE_REGION_FIELD)); + llassert(result.get(AGENT_STATE_CAN_REBAKE_REGION_FIELD).isBoolean()); + canRebake = result.get(AGENT_STATE_CAN_REBAKE_REGION_FIELD).asBoolean(); + } + + handleAgentState(canRebake); +} + +void LLPathfindingManager::navMeshRebakeCoro(LLCoros::self& self, std::string url, rebake_navmesh_callback_t rebakeNavMeshCallback) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("NavMeshRebake", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + + + LLSD postData = LLSD::emptyMap(); + postData["command"] = "rebuild"; + + LLSD result = httpAdapter->postAndYield(self, httpRequest, url, postData); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + + bool success = true; + if (!status) + { + LL_WARNS("PathfindingManager") << "HTTP status, " << status.toTerseString() << + ". Rebake failed." << LL_ENDL; + success = false; + } + + rebakeNavMeshCallback(success); +} + +// If called with putData undefined this coroutine will issue a get. If there +// is data in putData it will be PUT to the URL. +void LLPathfindingManager::linksetObjectsCoro(LLCoros::self &self, std::string url, LinksetsResponder::ptr_t linksetsResponsderPtr, LLSD putData) const +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("LinksetObjects", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + + LLSD result; + + if (putData.isUndefined()) + { + result = httpAdapter->getAndYield(self, httpRequest, url); + } + else + { + result = httpAdapter->putAndYield(self, httpRequest, url, putData); + } + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + + if (!status) + { + LL_WARNS("PathfindingManager") << "HTTP status, " << status.toTerseString() << + ". linksetObjects failed." << LL_ENDL; + linksetsResponsderPtr->handleObjectLinksetsError(); + } + else + { + result.erase(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS); + linksetsResponsderPtr->handleObjectLinksetsResult(result); + } +} + +// If called with putData undefined this coroutine will issue a GET. If there +// is data in putData it will be PUT to the URL. +void LLPathfindingManager::linksetTerrainCoro(LLCoros::self &self, std::string url, LinksetsResponder::ptr_t linksetsResponsderPtr, LLSD putData) const +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("LinksetTerrain", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + + LLSD result; + + if (putData.isUndefined()) + { + result = httpAdapter->getAndYield(self, httpRequest, url); + } + else + { + result = httpAdapter->putAndYield(self, httpRequest, url, putData); + } + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + + if (!status) + { + LL_WARNS("PathfindingManager") << "HTTP status, " << status.toTerseString() << + ". linksetTerrain failed." << LL_ENDL; + linksetsResponsderPtr->handleTerrainLinksetsError(); + } + else + { + result.erase(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS); + linksetsResponsderPtr->handleTerrainLinksetsResult(result); + } + +} + +void LLPathfindingManager::charactersCoro(LLCoros::self &self, std::string url, request_id_t requestId, object_request_callback_t callback) const +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("LinksetTerrain", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + + LLSD result = httpAdapter->getAndYield(self, httpRequest, url); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + + if (!status) + { + LL_WARNS("PathfindingManager") << "HTTP status, " << status.toTerseString() << + ". characters failed." << LL_ENDL; + + LLPathfindingObjectListPtr characterListPtr = LLPathfindingObjectListPtr(new LLPathfindingCharacterList()); + callback(requestId, LLPathfindingManager::kRequestError, characterListPtr); + } + else + { + result.erase(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS); + LLPathfindingObjectListPtr characterListPtr = LLPathfindingObjectListPtr(new LLPathfindingCharacterList(result)); + callback(requestId, LLPathfindingManager::kRequestCompleted, characterListPtr); + } } void LLPathfindingManager::handleNavMeshStatusUpdate(const LLPathfindingNavMeshStatus &pNavMeshStatus) @@ -764,122 +832,9 @@ void LLAgentStateChangeNode::post(ResponsePtr pResponse, const LLSD &pContext, c LLPathfindingManager::getInstance()->handleAgentState(canRebakeRegion); } -//--------------------------------------------------------------------------- -// NavMeshStatusResponder -//--------------------------------------------------------------------------- - -NavMeshStatusResponder::NavMeshStatusResponder(LLViewerRegion *pRegion, bool pIsGetStatusOnly) - : LLHTTPClient::Responder(), - mRegion(pRegion), - mRegionUUID(), - mIsGetStatusOnly(pIsGetStatusOnly) -{ - if (mRegion != NULL) - { - mRegionUUID = mRegion->getRegionID(); - } -} - -NavMeshStatusResponder::~NavMeshStatusResponder() -{ -} - -void NavMeshStatusResponder::httpSuccess() -{ - LLPathfindingNavMeshStatus navMeshStatus(mRegionUUID, getContent()); - LLPathfindingManager::getInstance()->handleNavMeshStatusRequest(navMeshStatus, mRegion, mIsGetStatusOnly); -} - -void NavMeshStatusResponder::httpFailure() -{ - LL_WARNS() << dumpResponse() << LL_ENDL; - LLPathfindingNavMeshStatus navMeshStatus(mRegionUUID); - LLPathfindingManager::getInstance()->handleNavMeshStatusRequest(navMeshStatus, mRegion, mIsGetStatusOnly); -} - -//--------------------------------------------------------------------------- -// NavMeshResponder -//--------------------------------------------------------------------------- - -NavMeshResponder::NavMeshResponder(U32 pNavMeshVersion, LLPathfindingNavMeshPtr pNavMeshPtr) - : LLHTTPClient::Responder(), - mNavMeshVersion(pNavMeshVersion), - mNavMeshPtr(pNavMeshPtr) -{ -} - -NavMeshResponder::~NavMeshResponder() -{ -} - -void NavMeshResponder::httpSuccess() -{ - mNavMeshPtr->handleNavMeshResult(getContent(), mNavMeshVersion); -} - -void NavMeshResponder::httpFailure() -{ - LL_WARNS() << dumpResponse() << LL_ENDL; - mNavMeshPtr->handleNavMeshError(mNavMeshVersion); -} - -//--------------------------------------------------------------------------- -// AgentStateResponder -//--------------------------------------------------------------------------- - -AgentStateResponder::AgentStateResponder() -: LLHTTPClient::Responder() -{ -} - -AgentStateResponder::~AgentStateResponder() -{ -} - -void AgentStateResponder::httpSuccess() -{ - const LLSD& pContent = getContent(); - llassert(pContent.has(AGENT_STATE_CAN_REBAKE_REGION_FIELD)); - llassert(pContent.get(AGENT_STATE_CAN_REBAKE_REGION_FIELD).isBoolean()); - BOOL canRebakeRegion = pContent.get(AGENT_STATE_CAN_REBAKE_REGION_FIELD).asBoolean(); - LLPathfindingManager::getInstance()->handleAgentState(canRebakeRegion); -} - -void AgentStateResponder::httpFailure() -{ - LL_WARNS() << dumpResponse() << LL_ENDL; - LLPathfindingManager::getInstance()->handleAgentState(FALSE); -} - - -//--------------------------------------------------------------------------- -// navmesh rebake responder -//--------------------------------------------------------------------------- -NavMeshRebakeResponder::NavMeshRebakeResponder(LLPathfindingManager::rebake_navmesh_callback_t pRebakeNavMeshCallback) - : LLHTTPClient::Responder(), - mRebakeNavMeshCallback(pRebakeNavMeshCallback) -{ -} - -NavMeshRebakeResponder::~NavMeshRebakeResponder() -{ -} - -void NavMeshRebakeResponder::httpSuccess() -{ - mRebakeNavMeshCallback(true); -} - -void NavMeshRebakeResponder::httpFailure() -{ - LL_WARNS() << dumpResponse() << LL_ENDL; - mRebakeNavMeshCallback(false); -} - //--------------------------------------------------------------------------- // LinksetsResponder //--------------------------------------------------------------------------- - LinksetsResponder::LinksetsResponder(LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::object_request_callback_t pLinksetsCallback, bool pIsObjectRequested, bool pIsTerrainRequested) : mRequestId(pRequestId), mLinksetsCallback(pLinksetsCallback), @@ -957,82 +912,3 @@ void LinksetsResponder::sendCallback() mLinksetsCallback(mRequestId, requestStatus, mObjectLinksetListPtr); } - -//--------------------------------------------------------------------------- -// ObjectLinksetsResponder -//--------------------------------------------------------------------------- - -ObjectLinksetsResponder::ObjectLinksetsResponder(LinksetsResponderPtr pLinksetsResponsderPtr) - : LLHTTPClient::Responder(), - mLinksetsResponsderPtr(pLinksetsResponsderPtr) -{ -} - -ObjectLinksetsResponder::~ObjectLinksetsResponder() -{ -} - -void ObjectLinksetsResponder::httpSuccess() -{ - mLinksetsResponsderPtr->handleObjectLinksetsResult(getContent()); -} - -void ObjectLinksetsResponder::httpFailure() -{ - LL_WARNS() << dumpResponse() << LL_ENDL; - mLinksetsResponsderPtr->handleObjectLinksetsError(); -} - -//--------------------------------------------------------------------------- -// TerrainLinksetsResponder -//--------------------------------------------------------------------------- - -TerrainLinksetsResponder::TerrainLinksetsResponder(LinksetsResponderPtr pLinksetsResponsderPtr) - : LLHTTPClient::Responder(), - mLinksetsResponsderPtr(pLinksetsResponsderPtr) -{ -} - -TerrainLinksetsResponder::~TerrainLinksetsResponder() -{ -} - -void TerrainLinksetsResponder::httpSuccess() -{ - mLinksetsResponsderPtr->handleTerrainLinksetsResult(getContent()); -} - -void TerrainLinksetsResponder::httpFailure() -{ - LL_WARNS() << dumpResponse() << LL_ENDL; - mLinksetsResponsderPtr->handleTerrainLinksetsError(); -} - -//--------------------------------------------------------------------------- -// CharactersResponder -//--------------------------------------------------------------------------- - -CharactersResponder::CharactersResponder(LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::object_request_callback_t pCharactersCallback) - : LLHTTPClient::Responder(), - mRequestId(pRequestId), - mCharactersCallback(pCharactersCallback) -{ -} - -CharactersResponder::~CharactersResponder() -{ -} - -void CharactersResponder::httpSuccess() -{ - LLPathfindingObjectListPtr characterListPtr = LLPathfindingObjectListPtr(new LLPathfindingCharacterList(getContent())); - mCharactersCallback(mRequestId, LLPathfindingManager::kRequestCompleted, characterListPtr); -} - -void CharactersResponder::httpFailure() -{ - LL_WARNS() << dumpResponse() << LL_ENDL; - - LLPathfindingObjectListPtr characterListPtr = LLPathfindingObjectListPtr(new LLPathfindingCharacterList()); - mCharactersCallback(mRequestId, LLPathfindingManager::kRequestError, characterListPtr); -} diff --git a/indra/newview/llpathfindingmanager.h b/indra/newview/llpathfindingmanager.h index c61ff244fc..abf611801c 100755 --- a/indra/newview/llpathfindingmanager.h +++ b/indra/newview/llpathfindingmanager.h @@ -37,11 +37,15 @@ #include "llpathfindingobjectlist.h" #include "llpathfindingnavmesh.h" #include "llsingleton.h" +#include "llcoros.h" +#include "lleventcoro.h" class LLPathfindingNavMeshStatus; class LLUUID; class LLViewerRegion; +class LinksetsResponder; + class LLPathfindingManager : public LLSingleton { friend class LLNavMeshSimStateChangeNode; @@ -92,16 +96,22 @@ public: protected: private: - typedef std::map NavMeshMap; - void sendRequestGetNavMeshForRegion(LLPathfindingNavMeshPtr navMeshPtr, LLViewerRegion *pRegion, const LLPathfindingNavMeshStatus &pNavMeshStatus); + typedef std::map NavMeshMap; void handleDeferredGetAgentStateForRegion(const LLUUID &pRegionUUID); void handleDeferredGetNavMeshForRegion(const LLUUID &pRegionUUID, bool pIsGetStatusOnly); void handleDeferredGetLinksetsForRegion(const LLUUID &pRegionUUID, request_id_t pRequestId, object_request_callback_t pLinksetsCallback) const; void handleDeferredGetCharactersForRegion(const LLUUID &pRegionUUID, request_id_t pRequestId, object_request_callback_t pCharactersCallback) const; - void handleNavMeshStatusRequest(const LLPathfindingNavMeshStatus &pNavMeshStatus, LLViewerRegion *pRegion, bool pIsGetStatusOnly); + void navMeshStatusRequestCoro(LLCoros::self& self, std::string url, U64 regionHandle, bool isGetStatusOnly); + void navAgentStateRequestCoro(LLCoros::self& self, std::string url); + void navMeshRebakeCoro(LLCoros::self& self, std::string url, rebake_navmesh_callback_t rebakeNavMeshCallback); + void linksetObjectsCoro(LLCoros::self &self, std::string url, boost::shared_ptr linksetsResponsderPtr, LLSD putData) const; + void linksetTerrainCoro(LLCoros::self &self, std::string url, boost::shared_ptr linksetsResponsderPtr, LLSD putData) const; + void charactersCoro(LLCoros::self &self, std::string url, request_id_t requestId, object_request_callback_t callback) const; + + //void handleNavMeshStatusRequest(const LLPathfindingNavMeshStatus &pNavMeshStatus, LLViewerRegion *pRegion, bool pIsGetStatusOnly); void handleNavMeshStatusUpdate(const LLPathfindingNavMeshStatus &pNavMeshStatus); void handleAgentState(BOOL pCanRebakeRegion); -- cgit v1.2.3 From da32de179d50d85cd815c545282d274d18c9dc3e Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 28 Apr 2015 09:39:47 -0700 Subject: Converting llmediaclient to new order. Temp disable llmediaclient's unit tests for link issues. --- indra/llcorehttp/httphandler.h | 5 +- indra/llmessage/llhttpsdhandler.cpp | 16 +- indra/llmessage/llhttpsdhandler.h | 15 +- indra/newview/CMakeLists.txt | 4 +- indra/newview/llmediadataclient.cpp | 378 ++++++++++++++++++------------------ indra/newview/llmediadataclient.h | 80 ++++---- 6 files changed, 262 insertions(+), 236 deletions(-) (limited to 'indra') diff --git a/indra/llcorehttp/httphandler.h b/indra/llcorehttp/httphandler.h index 740e986dec..7bc9096703 100755 --- a/indra/llcorehttp/httphandler.h +++ b/indra/llcorehttp/httphandler.h @@ -53,8 +53,9 @@ class HttpResponse; /// that is rarely a good idea. Queued requests and replies keep /// a naked pointer to the handler and this can result in a /// dangling pointer if lifetimes aren't managed correctly. - -class HttpHandler +/// +/// *TODO: public std::enable_shared_from_this +class HttpHandler { public: virtual ~HttpHandler() diff --git a/indra/llmessage/llhttpsdhandler.cpp b/indra/llmessage/llhttpsdhandler.cpp index 159d03b176..d99bdd3f66 100644 --- a/indra/llmessage/llhttpsdhandler.cpp +++ b/indra/llmessage/llhttpsdhandler.cpp @@ -36,7 +36,8 @@ #include "llcorehttputil.h" //======================================================================== -LLHttpSDHandler::LLHttpSDHandler() +LLHttpSDHandler::LLHttpSDHandler(bool selfDelete): + mSelfDelete(selfDelete) { } @@ -77,26 +78,27 @@ void LLHttpSDHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRespons // The handler must destroy itself when it is done. // *TODO: I'm not fond of this pattern. A class shooting itself in the head // outside of a smart pointer always makes me nervous. - delete this; + if (mSelfDelete) + delete this; } //======================================================================== -LLHttpSDGenericHandler::LLHttpSDGenericHandler(const std::string &caps) : - LLHttpSDHandler(), - mCaps(caps) +LLHttpSDGenericHandler::LLHttpSDGenericHandler(const std::string &name, bool selfDelete): + LLHttpSDHandler(selfDelete), + mName(name) { } void LLHttpSDGenericHandler::onSuccess(LLCore::HttpResponse * response, const LLSD &content) { - LL_DEBUGS() << mCaps << " Success." << LL_ENDL; + LL_DEBUGS() << mName << " Success." << LL_ENDL; } void LLHttpSDGenericHandler::onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status) { LL_WARNS() << "\n--------------------------------------------------------------------------\n" - << mCaps << " Error[" << status.toULong() << "] cannot access cap with url '" + << mName << " Error[" << status.toULong() << "] cannot access cap with url '" << response->getRequestURL() << "' because " << status.toString() << "\n--------------------------------------------------------------------------" << LL_ENDL; diff --git a/indra/llmessage/llhttpsdhandler.h b/indra/llmessage/llhttpsdhandler.h index 7c28dbcab6..814d1c22b5 100644 --- a/indra/llmessage/llhttpsdhandler.h +++ b/indra/llmessage/llhttpsdhandler.h @@ -36,32 +36,37 @@ /// // *TODO: This class self deletes at the end of onCompleted method. This is // less than ideal and should be revisited. -class LLHttpSDHandler : public LLCore::HttpHandler +class LLHttpSDHandler : public LLCore::HttpHandler //, +// public std::enable_shared_from_this { public: - LLHttpSDHandler(); virtual void onCompleted(LLCore::HttpHandle handle, LLCore::HttpResponse * response); protected: + LLHttpSDHandler(bool selfDelete = true); + virtual void onSuccess(LLCore::HttpResponse * response, const LLSD &content) = 0; virtual void onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status) = 0; +private: + bool mSelfDelete; + }; /// A trivial implementation of LLHttpSDHandler. This success and failure -/// methods log the action taken, the URI accessed and the status code retuned +/// methods log the action taken, the URI accessed and the status code returned /// in the response. class LLHttpSDGenericHandler : public LLHttpSDHandler { public: - LLHttpSDGenericHandler(const std::string &action); + LLHttpSDGenericHandler(const std::string &name, bool selfDelete = true); protected: virtual void onSuccess(LLCore::HttpResponse * response, const LLSD &content); virtual void onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status); private: - std::string mCaps; + std::string mName; }; #endif \ No newline at end of file diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 3858383e39..13436ecb16 100755 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -2218,7 +2218,7 @@ if (LL_TESTS) SET(viewer_TEST_SOURCE_FILES llagentaccess.cpp lldateutil.cpp - llmediadataclient.cpp +# llmediadataclient.cpp lllogininstance.cpp llremoteparcelrequest.cpp lltranslate.cpp @@ -2251,7 +2251,7 @@ if (LL_TESTS) set_source_files_properties( llmediadataclient.cpp PROPERTIES - LL_TEST_ADDITIONAL_LIBRARIES "${CURL_LIBRARIES}" + LL_TEST_ADDITIONAL_LIBRARIES "${test_libs}" ) set_source_files_properties( diff --git a/indra/newview/llmediadataclient.cpp b/indra/newview/llmediadataclient.cpp index 2fb9e60b29..2a53e3fe78 100755 --- a/indra/newview/llmediadataclient.cpp +++ b/indra/newview/llmediadataclient.cpp @@ -40,6 +40,7 @@ #include "llmediaentry.h" #include "lltextureentry.h" #include "llviewerregion.h" +#include "llcorehttputil.h" // // When making a request @@ -145,18 +146,20 @@ void remove_matching_requests(T &c, const LLUUID &id, LLMediaDataClient::Request // ////////////////////////////////////////////////////////////////////////////////////// -LLMediaDataClient::LLMediaDataClient(F32 queue_timer_delay, - F32 retry_timer_delay, - U32 max_retries, - U32 max_sorted_queue_size, - U32 max_round_robin_queue_size) - : mQueueTimerDelay(queue_timer_delay), - mRetryTimerDelay(retry_timer_delay), - mMaxNumRetries(max_retries), - mMaxSortedQueueSize(max_sorted_queue_size), - mMaxRoundRobinQueueSize(max_round_robin_queue_size), - mQueueTimerIsRunning(false) +LLMediaDataClient::LLMediaDataClient(F32 queue_timer_delay, F32 retry_timer_delay, + U32 max_retries, U32 max_sorted_queue_size, U32 max_round_robin_queue_size): + mQueueTimerDelay(queue_timer_delay), + mRetryTimerDelay(retry_timer_delay), + mMaxNumRetries(max_retries), + mMaxSortedQueueSize(max_sorted_queue_size), + mMaxRoundRobinQueueSize(max_round_robin_queue_size), + mQueueTimerIsRunning(false), + mHttpRequest(new LLCore::HttpRequest()), + mHttpHeaders(new LLCore::HttpHeaders(), false), + mHttpOpts(new LLCore::HttpOptions(), false), + mHttpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID) { + // *TODO: Look up real Policy ID } LLMediaDataClient::~LLMediaDataClient() @@ -207,18 +210,19 @@ void LLMediaDataClient::stopQueueTimer() bool LLMediaDataClient::processQueueTimer() { - if(isEmpty()) + if (isDoneProcessing()) return true; LL_DEBUGS("LLMediaDataClient") << "QueueTimer::tick() started, queue size is: " << mQueue.size() << LL_ENDL; LL_DEBUGS("LLMediaDataClientQueue") << "QueueTimer::tick() started, SORTED queue is: " << mQueue << LL_ENDL; serviceQueue(); - + serviceHttp(); + LL_DEBUGS("LLMediaDataClient") << "QueueTimer::tick() finished, queue size is: " << mQueue.size() << LL_ENDL; LL_DEBUGS("LLMediaDataClientQueue") << "QueueTimer::tick() finished, SORTED queue is: " << mQueue << LL_ENDL; - return isEmpty(); + return isDoneProcessing(); } LLMediaDataClient::request_ptr_t LLMediaDataClient::dequeue() @@ -283,6 +287,12 @@ void LLMediaDataClient::stopTrackingRequest(request_ptr_t request) } } +bool LLMediaDataClient::isDoneProcessing() const +{ + return (isEmpty() && mUnQueuedRequests.empty()); +} + + void LLMediaDataClient::serviceQueue() { // Peel one off of the items from the queue and execute it @@ -317,7 +327,18 @@ void LLMediaDataClient::serviceQueue() trackRequest(request); // and make the post - LLHTTPClient::post(url, sd_payload, request->createResponder()); + LLHttpSDHandler *handler = request->createHandler(); + LLCore::HttpHandle handle = LLCoreHttpUtil::requestPostWithLLSD(mHttpRequest, mHttpPolicy, 0, + url, sd_payload, mHttpOpts, mHttpHeaders, handler); + + if (handle == LLCORE_HTTP_HANDLE_INVALID) + { + // *TODO: Change this metaphore to use boost::shared_ptr<> for handlers. Requires change in LLCore::HTTP + delete handler; + LLCore::HttpStatus status = mHttpRequest->getStatus(); + LL_WARNS("LLMediaDataClient") << "'" << url << "' request POST failed. Reason " + << status.toTerseString() << " \"" << status.toString() << "\"" << LL_ENDL; + } } else { @@ -332,13 +353,17 @@ void LLMediaDataClient::serviceQueue() } else { - // This request has exceeded its maxumim retry count. It will be dropped. + // This request has exceeded its maximum retry count. It will be dropped. LL_WARNS("LLMediaDataClient") << "Could not send request " << *request << " for " << mMaxNumRetries << " tries, dropping request." << LL_ENDL; } } } +void LLMediaDataClient::serviceHttp() +{ + mHttpRequest->update(0); +} // dump the queue std::ostream& operator<<(std::ostream &s, const LLMediaDataClient::request_queue_t &q) @@ -551,79 +576,67 @@ std::ostream& operator<<(std::ostream &s, const LLMediaDataClient::Request &r) << " #retries=" << r.getRetryCount(); return s; } - -////////////////////////////////////////////////////////////////////////////////////// -// -// LLMediaDataClient::Responder -// -////////////////////////////////////////////////////////////////////////////////////// -LLMediaDataClient::Responder::Responder(const request_ptr_t &request) -: mRequest(request) +//======================================================================== + +LLMediaDataClient::Handler::Handler(const request_ptr_t &request): + mRequest(request) { } -/*virtual*/ -void LLMediaDataClient::Responder::httpFailure() + +void LLMediaDataClient::Handler::onSuccess(LLCore::HttpResponse * response, const LLSD &content) { - mRequest->stopTracking(); + mRequest->stopTracking(); - if(mRequest->isDead()) - { - LL_WARNS("LLMediaDataClient") << "dead request " << *mRequest << LL_ENDL; - return; - } - - if (getStatus() == HTTP_SERVICE_UNAVAILABLE) - { - F32 retry_timeout; -#if 0 - // *TODO: Honor server Retry-After header. - if (!hasResponseHeader(HTTP_IN_HEADER_RETRY_AFTER) - || !getSecondsUntilRetryAfter(getResponseHeader(HTTP_IN_HEADER_RETRY_AFTER), retry_timeout)) -#endif - { - retry_timeout = mRequest->getRetryTimerDelay(); - } - - mRequest->incRetryCount(); - - if (mRequest->getRetryCount() < mRequest->getMaxNumRetries()) - { - LL_INFOS("LLMediaDataClient") << *mRequest << " got SERVICE_UNAVAILABLE...retrying in " << retry_timeout << " seconds" << LL_ENDL; - - // Start timer (instances are automagically tracked by - // InstanceTracker<> and LLEventTimer) - new RetryTimer(F32(retry_timeout/*secs*/), mRequest); - } - else - { - LL_INFOS("LLMediaDataClient") << *mRequest << " got SERVICE_UNAVAILABLE...retry count " - << mRequest->getRetryCount() << " exceeds " << mRequest->getMaxNumRetries() << ", not retrying" << LL_ENDL; - } - } - // *TODO: Redirect on 3xx status codes. - else - { - LL_WARNS("LLMediaDataClient") << *mRequest << " http failure " - << dumpResponse() << LL_ENDL; - } + if (mRequest->isDead()) + { + LL_WARNS("LLMediaDataClient") << "dead request " << *mRequest << LL_ENDL; + return; + } + + LL_DEBUGS("LLMediaDataClientResponse") << *mRequest << LL_ENDL; } -/*virtual*/ -void LLMediaDataClient::Responder::httpSuccess() +void LLMediaDataClient::Handler::onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status) { - mRequest->stopTracking(); + mRequest->stopTracking(); - if(mRequest->isDead()) - { - LL_WARNS("LLMediaDataClient") << "dead request " << *mRequest << LL_ENDL; - return; - } + if (status == LLCore::HttpStatus(HTTP_SERVICE_UNAVAILABLE)) + { + F32 retry_timeout; +#if 0 + // *TODO: Honor server Retry-After header. + if (!hasResponseHeader(HTTP_IN_HEADER_RETRY_AFTER) + || !getSecondsUntilRetryAfter(getResponseHeader(HTTP_IN_HEADER_RETRY_AFTER), retry_timeout)) +#endif + { + retry_timeout = mRequest->getRetryTimerDelay(); + } + + mRequest->incRetryCount(); - LL_DEBUGS("LLMediaDataClientResponse") << *mRequest << " " << dumpResponse() << LL_ENDL; + if (mRequest->getRetryCount() < mRequest->getMaxNumRetries()) + { + LL_INFOS("LLMediaDataClient") << *mRequest << " got SERVICE_UNAVAILABLE...retrying in " << retry_timeout << " seconds" << LL_ENDL; + + // Start timer (instances are automagically tracked by + // InstanceTracker<> and LLEventTimer) + new RetryTimer(F32(retry_timeout/*secs*/), mRequest); + } + else + { + LL_INFOS("LLMediaDataClient") << *mRequest << " got SERVICE_UNAVAILABLE...retry count " + << mRequest->getRetryCount() << " exceeds " << mRequest->getMaxNumRetries() << ", not retrying" << LL_ENDL; + } + } + else + { + LL_WARNS("LLMediaDataClient") << *mRequest << " HTTP failure " << LL_ENDL; + } } + ////////////////////////////////////////////////////////////////////////////////////// // // LLObjectMediaDataClient @@ -801,7 +814,7 @@ void LLObjectMediaDataClient::removeFromQueue(const LLMediaDataClientObject::ptr bool LLObjectMediaDataClient::processQueueTimer() { - if(isEmpty()) + if (isDoneProcessing()) return true; LL_DEBUGS("LLMediaDataClient") << "started, SORTED queue size is: " << mQueue.size() @@ -816,6 +829,7 @@ bool LLObjectMediaDataClient::processQueueTimer() LL_DEBUGS("LLMediaDataClientQueue") << "after sort, SORTED queue is: " << mQueue << LL_ENDL; serviceQueue(); + serviceHttp(); swapCurrentQueue(); @@ -824,7 +838,7 @@ bool LLObjectMediaDataClient::processQueueTimer() LL_DEBUGS("LLMediaDataClientQueue") << " SORTED queue is: " << mQueue << LL_ENDL; LL_DEBUGS("LLMediaDataClientQueue") << " RR queue is: " << mRoundRobinQueue << LL_ENDL; - return isEmpty(); + return isDoneProcessing(); } LLObjectMediaDataClient::RequestGet::RequestGet(LLMediaDataClientObject *obj, LLMediaDataClient *mdc): @@ -841,9 +855,9 @@ LLSD LLObjectMediaDataClient::RequestGet::getPayload() const return result; } -LLMediaDataClient::Responder *LLObjectMediaDataClient::RequestGet::createResponder() +LLHttpSDHandler *LLObjectMediaDataClient::RequestGet::createHandler() { - return new LLObjectMediaDataClient::Responder(this); + return new LLObjectMediaDataClient::Handler(this); } @@ -877,60 +891,58 @@ LLSD LLObjectMediaDataClient::RequestUpdate::getPayload() const return result; } -LLMediaDataClient::Responder *LLObjectMediaDataClient::RequestUpdate::createResponder() +LLHttpSDHandler *LLObjectMediaDataClient::RequestUpdate::createHandler() { // This just uses the base class's responder. - return new LLMediaDataClient::Responder(this); + return new LLMediaDataClient::Handler(this); } - -/*virtual*/ -void LLObjectMediaDataClient::Responder::httpSuccess() +void LLObjectMediaDataClient::Handler::onSuccess(LLCore::HttpResponse * response, const LLSD &content) { - getRequest()->stopTracking(); + LLMediaDataClient::Handler::onSuccess(response, content); + + if (getRequest()->isDead()) + { // warning emitted from base method. + return; + } + + if (!content.isMap()) + { + onFailure(response, LLCore::HttpStatus(HTTP_INTERNAL_ERROR, "Malformed response contents")); + return; + } + + // This responder is only used for GET requests, not UPDATE. + LL_DEBUGS("LLMediaDataClientResponse") << *(getRequest()) << " " << LL_ENDL; + + // Look for an error + if (content.has("error")) + { + const LLSD &error = content["error"]; + LL_WARNS("LLMediaDataClient") << *(getRequest()) << " Error getting media data for object: code=" << + error["code"].asString() << ": " << error["message"].asString() << LL_ENDL; + + // XXX Warn user? + } + else + { + // Check the data + const LLUUID &object_id = content[LLTextureEntry::OBJECT_ID_KEY]; + if (object_id != getRequest()->getObject()->getID()) + { + // NOT good, wrong object id!! + LL_WARNS("LLMediaDataClient") << *(getRequest()) << " DROPPING response with wrong object id (" << object_id << ")" << LL_ENDL; + return; + } + + // Otherwise, update with object media data + getRequest()->getObject()->updateObjectMediaData(content[LLTextureEntry::OBJECT_MEDIA_DATA_KEY], + content[LLTextureEntry::MEDIA_VERSION_KEY]); + } - if(getRequest()->isDead()) - { - LL_WARNS("LLMediaDataClient") << "dead request " << *(getRequest()) << LL_ENDL; - return; - } - - const LLSD& content = getContent(); - if (!content.isMap()) - { - failureResult(HTTP_INTERNAL_ERROR, "Malformed response contents", content); - return; - } - - // This responder is only used for GET requests, not UPDATE. - LL_DEBUGS("LLMediaDataClientResponse") << *(getRequest()) << " " << dumpResponse() << LL_ENDL; - - // Look for an error - if (content.has("error")) - { - const LLSD &error = content["error"]; - LL_WARNS("LLMediaDataClient") << *(getRequest()) << " Error getting media data for object: code=" << - error["code"].asString() << ": " << error["message"].asString() << LL_ENDL; - - // XXX Warn user? - } - else - { - // Check the data - const LLUUID &object_id = content[LLTextureEntry::OBJECT_ID_KEY]; - if (object_id != getRequest()->getObject()->getID()) - { - // NOT good, wrong object id!! - LL_WARNS("LLMediaDataClient") << *(getRequest()) << " DROPPING response with wrong object id (" << object_id << ")" << LL_ENDL; - return; - } - - // Otherwise, update with object media data - getRequest()->getObject()->updateObjectMediaData(content[LLTextureEntry::OBJECT_MEDIA_DATA_KEY], - content[LLTextureEntry::MEDIA_VERSION_KEY]); - } } + ////////////////////////////////////////////////////////////////////////////////////// // // LLObjectMediaNavigateClient @@ -947,7 +959,7 @@ void LLObjectMediaNavigateClient::enqueue(Request *request) { if(request->isDead()) { - LL_DEBUGS("LLMediaDataClient") << "not queueing dead request " << *request << LL_ENDL; + LL_DEBUGS("LLMediaDataClient") << "not queuing dead request " << *request << LL_ENDL; return; } @@ -979,7 +991,7 @@ void LLObjectMediaNavigateClient::enqueue(Request *request) else #endif { - LL_DEBUGS("LLMediaDataClient") << "queueing new request " << (*request) << LL_ENDL; + LL_DEBUGS("LLMediaDataClient") << "queuing new request " << (*request) << LL_ENDL; mQueue.push_back(request); // Start the timer if not already running @@ -1012,75 +1024,67 @@ LLSD LLObjectMediaNavigateClient::RequestNavigate::getPayload() const return result; } -LLMediaDataClient::Responder *LLObjectMediaNavigateClient::RequestNavigate::createResponder() +LLHttpSDHandler *LLObjectMediaNavigateClient::RequestNavigate::createHandler() { - return new LLObjectMediaNavigateClient::Responder(this); + return new LLObjectMediaNavigateClient::Handler(this); } -/*virtual*/ -void LLObjectMediaNavigateClient::Responder::httpFailure() +void LLObjectMediaNavigateClient::Handler::onSuccess(LLCore::HttpResponse * response, const LLSD &content) { - getRequest()->stopTracking(); + LLMediaDataClient::Handler::onSuccess(response, content); - if(getRequest()->isDead()) - { - LL_WARNS("LLMediaDataClient") << "dead request " << *(getRequest()) << LL_ENDL; - return; - } + if (getRequest()->isDead()) + { // already warned. + return; + } + + LL_INFOS("LLMediaDataClient") << *(getRequest()) << " NAVIGATE returned" << LL_ENDL; + + if (content.has("error")) + { + const LLSD &error = content["error"]; + int error_code = error["code"]; + + if (ERROR_PERMISSION_DENIED_CODE == error_code) + { + mediaNavigateBounceBack(); + } + else + { + LL_WARNS("LLMediaDataClient") << *(getRequest()) << " Error navigating: code=" << + error["code"].asString() << ": " << error["message"].asString() << LL_ENDL; + } + + // XXX Warn user? + } + else + { + // No action required. + LL_DEBUGS("LLMediaDataClientResponse") << *(getRequest()) << LL_ENDL; + } - // Bounce back (unless HTTP_SERVICE_UNAVAILABLE, in which case call base - // class - if (getStatus() == HTTP_SERVICE_UNAVAILABLE) - { - LLMediaDataClient::Responder::httpFailure(); - } - else - { - // bounce the face back - LL_WARNS("LLMediaDataClient") << *(getRequest()) << " Error navigating: " << dumpResponse() << LL_ENDL; - const LLSD &payload = getRequest()->getPayload(); - // bounce the face back - getRequest()->getObject()->mediaNavigateBounceBack((LLSD::Integer)payload[LLTextureEntry::TEXTURE_INDEX_KEY]); - } } -/*virtual*/ -void LLObjectMediaNavigateClient::Responder::httpSuccess() +void LLObjectMediaNavigateClient::Handler::onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status) { - getRequest()->stopTracking(); + LLMediaDataClient::Handler::onFailure(response, status); - if(getRequest()->isDead()) - { - LL_WARNS("LLMediaDataClient") << "dead request " << *(getRequest()) << LL_ENDL; - return; - } + if (getRequest()->isDead()) + { // already warned. + return; + } - LL_INFOS("LLMediaDataClient") << *(getRequest()) << " NAVIGATE returned " << dumpResponse() << LL_ENDL; - - const LLSD& content = getContent(); - if (content.has("error")) - { - const LLSD &error = content["error"]; - int error_code = error["code"]; - - if (ERROR_PERMISSION_DENIED_CODE == error_code) - { - LL_WARNS("LLMediaDataClient") << *(getRequest()) << " Navigation denied: bounce back" << LL_ENDL; - const LLSD &payload = getRequest()->getPayload(); - // bounce the face back - getRequest()->getObject()->mediaNavigateBounceBack((LLSD::Integer)payload[LLTextureEntry::TEXTURE_INDEX_KEY]); - } - else - { - LL_WARNS("LLMediaDataClient") << *(getRequest()) << " Error navigating: code=" << - error["code"].asString() << ": " << error["message"].asString() << LL_ENDL; - } + if (status != LLCore::HttpStatus(HTTP_SERVICE_UNAVAILABLE)) + { + mediaNavigateBounceBack(); + } +} - // XXX Warn user? - } - else - { - // No action required. - LL_DEBUGS("LLMediaDataClientResponse") << *(getRequest()) << " " << dumpResponse() << LL_ENDL; - } +void LLObjectMediaNavigateClient::Handler::mediaNavigateBounceBack() +{ + LL_WARNS("LLMediaDataClient") << *(getRequest()) << " Error navigating or denied." << LL_ENDL; + const LLSD &payload = getRequest()->getPayload(); + + // bounce the face back + getRequest()->getObject()->mediaNavigateBounceBack((LLSD::Integer)payload[LLTextureEntry::TEXTURE_INDEX_KEY]); } diff --git a/indra/newview/llmediadataclient.h b/indra/newview/llmediadataclient.h index 80dd519812..d123aa7a11 100755 --- a/indra/newview/llmediadataclient.h +++ b/indra/newview/llmediadataclient.h @@ -32,7 +32,11 @@ #include "llrefcount.h" #include "llpointer.h" #include "lleventtimer.h" - +#include "llhttpsdhandler.h" +#include "httpcommon.h" +#include "httprequest.h" +#include "httpoptions.h" +#include "httpheaders.h" // Link seam for LLVOVolume class LLMediaDataClientObject : public LLRefCount @@ -109,8 +113,6 @@ protected: // Destructor virtual ~LLMediaDataClient(); // use unref - class Responder; - // Request (pure virtual base class for requests in the queue) class Request : public LLRefCount { @@ -118,7 +120,7 @@ protected: // Subclasses must implement this to build a payload for their request type. virtual LLSD getPayload() const = 0; // and must create the correct type of responder. - virtual Responder *createResponder() = 0; + virtual LLHttpSDHandler *createHandler() = 0; virtual std::string getURL() { return ""; } @@ -190,23 +192,21 @@ protected: }; typedef LLPointer request_ptr_t; - // Responder - class Responder : public LLHTTPClient::Responder - { - LOG_CLASS(Responder); - public: - Responder(const request_ptr_t &request); - request_ptr_t &getRequest() { return mRequest; } + class Handler : public LLHttpSDHandler + { + LOG_CLASS(Handler); + public: + Handler(const request_ptr_t &request); + request_ptr_t getRequest() const { return mRequest; } - protected: - //If we get back an error (not found, etc...), handle it here - virtual void httpFailure(); - //If we get back a normal response, handle it here. Default just logs it. - virtual void httpSuccess(); + protected: + virtual void onSuccess(LLCore::HttpResponse * response, const LLSD &content); + virtual void onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status); + + private: + request_ptr_t mRequest; + }; - private: - request_ptr_t mRequest; - }; class RetryTimer : public LLEventTimer { @@ -230,6 +230,7 @@ protected: virtual void enqueue(Request*) = 0; virtual void serviceQueue(); + virtual void serviceHttp(); virtual request_queue_t *getQueue() { return &mQueue; }; @@ -243,6 +244,8 @@ protected: void trackRequest(request_ptr_t request); void stopTrackingRequest(request_ptr_t request); + + bool isDoneProcessing() const; request_queue_t mQueue; @@ -260,6 +263,11 @@ protected: void startQueueTimer(); void stopQueueTimer(); + LLCore::HttpRequest::ptr_t mHttpRequest; + LLCore::HttpHeaders::ptr_t mHttpHeaders; + LLCore::HttpOptions::ptr_t mHttpOpts; + LLCore::HttpRequest::policy_t mHttpPolicy; + private: static F64 getObjectScore(const LLMediaDataClientObject::ptr_t &obj); @@ -309,7 +317,7 @@ public: public: RequestGet(LLMediaDataClientObject *obj, LLMediaDataClient *mdc); /*virtual*/ LLSD getPayload() const; - /*virtual*/ Responder *createResponder(); + /*virtual*/ LLHttpSDHandler *createHandler(); }; class RequestUpdate: public Request @@ -317,7 +325,7 @@ public: public: RequestUpdate(LLMediaDataClientObject *obj, LLMediaDataClient *mdc); /*virtual*/ LLSD getPayload() const; - /*virtual*/ Responder *createResponder(); + /*virtual*/ LLHttpSDHandler *createHandler(); }; // Returns true iff the queue is empty @@ -342,15 +350,18 @@ protected: // Puts the request into the appropriate queue virtual void enqueue(Request*); - class Responder : public LLMediaDataClient::Responder + class Handler: public LLMediaDataClient::Handler { - LOG_CLASS(Responder); + LOG_CLASS(Handler); public: - Responder(const request_ptr_t &request) - : LLMediaDataClient::Responder(request) {} + Handler(const request_ptr_t &request): + LLMediaDataClient::Handler(request) + {} + protected: - virtual void httpSuccess(); + virtual void onSuccess(LLCore::HttpResponse * response, const LLSD &content); }; + private: // The Get/Update data client needs a second queue to avoid object updates starving load-ins. void swapCurrentQueue(); @@ -391,7 +402,7 @@ public: public: RequestNavigate(LLMediaDataClientObject *obj, LLMediaDataClient *mdc, U8 texture_index, const std::string &url); /*virtual*/ LLSD getPayload() const; - /*virtual*/ Responder *createResponder(); + /*virtual*/ LLHttpSDHandler *createHandler(); /*virtual*/ std::string getURL() { return mURL; } private: std::string mURL; @@ -401,15 +412,18 @@ protected: // Subclasses must override to return a cap name virtual const char *getCapabilityName() const; - class Responder : public LLMediaDataClient::Responder + class Handler : public LLMediaDataClient::Handler { - LOG_CLASS(Responder); + LOG_CLASS(Handler); public: - Responder(const request_ptr_t &request) - : LLMediaDataClient::Responder(request) {} + Handler(const request_ptr_t &request): + LLMediaDataClient::Handler(request) + {} + protected: - virtual void httpFailure(); - virtual void httpSuccess(); + virtual void onSuccess(LLCore::HttpResponse * response, const LLSD &content); + virtual void onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status); + private: void mediaNavigateBounceBack(); }; -- cgit v1.2.3 From 39d62529269d0e19ec3f43999b69e9c33ac748c2 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 28 Apr 2015 16:50:42 -0700 Subject: Convert some elements to STL --- indra/newview/CMakeLists.txt | 2 +- indra/newview/llmediadataclient.cpp | 194 ++++++++++++++----------- indra/newview/llmediadataclient.h | 68 +++++---- indra/newview/tests/llmediadataclient_test.cpp | 3 +- 4 files changed, 153 insertions(+), 114 deletions(-) (limited to 'indra') diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 13436ecb16..c9bcd17d96 100755 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -2352,7 +2352,7 @@ if (LL_TESTS) ${BOOST_COROUTINE_LIBRARY} ) - LL_ADD_INTEGRATION_TEST(llsechandler_basic + LL_ADD_INTEGRATION_TEST(llsechandler_basic llsechandler_basic.cpp "${test_libs}" ) diff --git a/indra/newview/llmediadataclient.cpp b/indra/newview/llmediadataclient.cpp index 2a53e3fe78..770a37c275 100755 --- a/indra/newview/llmediadataclient.cpp +++ b/indra/newview/llmediadataclient.cpp @@ -33,6 +33,7 @@ #pragma warning (disable:4702) #endif +#include #include #include "llhttpconstants.h" @@ -92,52 +93,73 @@ const U32 LLMediaDataClient::MAX_ROUND_ROBIN_QUEUE_SIZE = 10000; std::ostream& operator<<(std::ostream &s, const LLMediaDataClient::request_queue_t &q); std::ostream& operator<<(std::ostream &s, const LLMediaDataClient::Request &q); -template -typename T::iterator find_matching_request(T &c, const LLMediaDataClient::Request *request, LLMediaDataClient::Request::Type match_type) + +//========================================================================= +/// Uniary Predicate for matching requests in collections by either the request +/// or by UUID +/// +class PredicateMatchRequest { - for(typename T::iterator iter = c.begin(); iter != c.end(); ++iter) - { - if(request->isMatch(*iter, match_type)) - { - return iter; - } - } - - return c.end(); +public: + PredicateMatchRequest(const LLMediaDataClient::Request::ptr_t &request, LLMediaDataClient::Request::Type matchType = LLMediaDataClient::Request::ANY); + PredicateMatchRequest(const LLUUID &id, LLMediaDataClient::Request::Type matchType = LLMediaDataClient::Request::ANY); + + PredicateMatchRequest(const PredicateMatchRequest &other); + + bool operator()(const LLMediaDataClient::Request::ptr_t &test) const; + +private: + LLMediaDataClient::Request::ptr_t mRequest; + LLMediaDataClient::Request::Type mMatchType; + LLUUID mId; +}; + + +PredicateMatchRequest::PredicateMatchRequest(const LLMediaDataClient::Request::ptr_t &request, LLMediaDataClient::Request::Type matchType) : + mRequest(request), + mMatchType(matchType), + mId() +{} + +PredicateMatchRequest::PredicateMatchRequest(const LLUUID &id, LLMediaDataClient::Request::Type matchType) : + mRequest(), + mMatchType(matchType), + mId(id) +{} + +PredicateMatchRequest::PredicateMatchRequest(const PredicateMatchRequest &other) +{ + mRequest = other.mRequest; + mMatchType = other.mMatchType; + mId = other.mId; } -template -typename T::iterator find_matching_request(T &c, const LLUUID &id, LLMediaDataClient::Request::Type match_type) +bool PredicateMatchRequest::operator()(const LLMediaDataClient::Request::ptr_t &test) const { - for(typename T::iterator iter = c.begin(); iter != c.end(); ++iter) - { - if(((*iter)->getID() == id) && ((match_type == LLMediaDataClient::Request::ANY) || (match_type == (*iter)->getType()))) - { - return iter; - } - } - - return c.end(); + if (mRequest) + return (mRequest->isMatch(test, mMatchType)); + else if (!mId.isNull()) + return ((test->getID() == mId) && ((mMatchType == LLMediaDataClient::Request::ANY) || (mMatchType == test->getType()))); + return false; } -// NOTE: remove_matching_requests will not work correctly for containers where deleting an element may invalidate iterators -// to other elements in the container (such as std::vector). -// If the implementation is changed to use a container with this property, this will need to be revisited. +//========================================================================= +/// template -void remove_matching_requests(T &c, const LLUUID &id, LLMediaDataClient::Request::Type match_type) +void mark_dead_and_remove_if(T &c, const PredicateMatchRequest &matchPred) { - for(typename T::iterator iter = c.begin(); iter != c.end();) - { - typename T::value_type i = *iter; - typename T::iterator next = iter; - next++; - if((i->getID() == id) && ((match_type == LLMediaDataClient::Request::ANY) || (match_type == i->getType()))) - { - i->markDead(); - c.erase(iter); - } - iter = next; - } + for (typename T::iterator it = c.begin(); it != c.end();) + { + if (matchPred(*it)) + { + (*it)->markDead(); + it = c.erase(it); + } + else + { + ++it; + } + } } ////////////////////////////////////////////////////////////////////////////////////// @@ -174,20 +196,23 @@ bool LLMediaDataClient::isEmpty() const bool LLMediaDataClient::isInQueue(const LLMediaDataClientObject::ptr_t &object) { - if(find_matching_request(mQueue, object->getID(), LLMediaDataClient::Request::ANY) != mQueue.end()) - return true; - - if(find_matching_request(mUnQueuedRequests, object->getID(), LLMediaDataClient::Request::ANY) != mUnQueuedRequests.end()) - return true; - + PredicateMatchRequest upred(object->getID()); + + if (std::find_if(mQueue.begin(), mQueue.end(), upred) != mQueue.end()) + return true; + if (std::find_if(mUnQueuedRequests.begin(), mUnQueuedRequests.end(), upred) != mUnQueuedRequests.end()) + return true; + return false; } void LLMediaDataClient::removeFromQueue(const LLMediaDataClientObject::ptr_t &object) { LL_DEBUGS("LLMediaDataClient") << "removing requests matching ID " << object->getID() << LL_ENDL; - remove_matching_requests(mQueue, object->getID(), LLMediaDataClient::Request::ANY); - remove_matching_requests(mUnQueuedRequests, object->getID(), LLMediaDataClient::Request::ANY); + PredicateMatchRequest upred(object->getID()); + + mark_dead_and_remove_if(mQueue, upred); + mark_dead_and_remove_if(mUnQueuedRequests, upred); } void LLMediaDataClient::startQueueTimer() @@ -225,9 +250,9 @@ bool LLMediaDataClient::processQueueTimer() return isDoneProcessing(); } -LLMediaDataClient::request_ptr_t LLMediaDataClient::dequeue() +LLMediaDataClient::Request::ptr_t LLMediaDataClient::dequeue() { - request_ptr_t request; + Request::ptr_t request; request_queue_t *queue_p = getQueue(); if (queue_p->empty()) @@ -253,13 +278,13 @@ LLMediaDataClient::request_ptr_t LLMediaDataClient::dequeue() return request; } -void LLMediaDataClient::pushBack(request_ptr_t request) +void LLMediaDataClient::pushBack(Request::ptr_t request) { request_queue_t *queue_p = getQueue(); queue_p->push_front(request); } -void LLMediaDataClient::trackRequest(request_ptr_t request) +void LLMediaDataClient::trackRequest(Request::ptr_t request) { request_set_t::iterator iter = mUnQueuedRequests.find(request); @@ -273,7 +298,7 @@ void LLMediaDataClient::trackRequest(request_ptr_t request) } } -void LLMediaDataClient::stopTrackingRequest(request_ptr_t request) +void LLMediaDataClient::stopTrackingRequest(Request::ptr_t request) { request_set_t::iterator iter = mUnQueuedRequests.find(request); @@ -296,13 +321,13 @@ bool LLMediaDataClient::isDoneProcessing() const void LLMediaDataClient::serviceQueue() { // Peel one off of the items from the queue and execute it - request_ptr_t request; + Request::ptr_t request; do { request = dequeue(); - if(request.isNull()) + if(!request) { // Queue is empty. return; @@ -420,7 +445,7 @@ BOOL LLMediaDataClient::QueueTimer::tick() // ////////////////////////////////////////////////////////////////////////////////////// -LLMediaDataClient::RetryTimer::RetryTimer(F32 time, request_ptr_t request) +LLMediaDataClient::RetryTimer::RetryTimer(F32 time, Request::ptr_t request) : LLEventTimer(time), mRequest(request) { mRequest->startTracking(); @@ -515,7 +540,7 @@ void LLMediaDataClient::Request::reEnqueue() { if(mMDC) { - mMDC->enqueue(this); + mMDC->enqueue(shared_from_this()); } } @@ -558,13 +583,13 @@ bool LLMediaDataClient::Request::isDead() void LLMediaDataClient::Request::startTracking() { if(mMDC) - mMDC->trackRequest(this); + mMDC->trackRequest(shared_from_this()); } void LLMediaDataClient::Request::stopTracking() { if(mMDC) - mMDC->stopTrackingRequest(this); + mMDC->stopTrackingRequest(shared_from_this()); } std::ostream& operator<<(std::ostream &s, const LLMediaDataClient::Request &r) @@ -579,7 +604,7 @@ std::ostream& operator<<(std::ostream &s, const LLMediaDataClient::Request &r) //======================================================================== -LLMediaDataClient::Handler::Handler(const request_ptr_t &request): +LLMediaDataClient::Handler::Handler(const Request::ptr_t &request): mRequest(request) { } @@ -647,7 +672,7 @@ void LLMediaDataClient::Handler::onFailure(LLCore::HttpResponse * response, LLCo void LLObjectMediaDataClient::fetchMedia(LLMediaDataClientObject *object) { // Create a get request and put it in the queue. - enqueue(new RequestGet(object, this)); + enqueue(Request::ptr_t(new RequestGet(object, this))); } const char *LLObjectMediaDataClient::getCapabilityName() const @@ -691,14 +716,14 @@ void LLObjectMediaDataClient::sortQueue() } // static -bool LLObjectMediaDataClient::compareRequestScores(const request_ptr_t &o1, const request_ptr_t &o2) +bool LLObjectMediaDataClient::compareRequestScores(const Request::ptr_t &o1, const Request::ptr_t &o2) { - if (o2.isNull()) return true; - if (o1.isNull()) return false; + if (!o2) return true; + if (!o1) return false; return ( o1->getScore() > o2->getScore() ); } -void LLObjectMediaDataClient::enqueue(Request *request) +void LLObjectMediaDataClient::enqueue(Request::ptr_t request) { if(request->isDead()) { @@ -716,9 +741,10 @@ void LLObjectMediaDataClient::enqueue(Request *request) { // For GET requests that are not new, if a matching request is already in the round robin queue, // in flight, or being retried, leave it at its current position. - request_queue_t::iterator iter = find_matching_request(mRoundRobinQueue, request->getID(), Request::GET); - request_set_t::iterator iter2 = find_matching_request(mUnQueuedRequests, request->getID(), Request::GET); - + PredicateMatchRequest upred(request->getID(), Request::GET); + request_queue_t::iterator iter = std::find_if(mRoundRobinQueue.begin(), mRoundRobinQueue.end(), upred); + request_set_t::iterator iter2 = std::find_if(mUnQueuedRequests.begin(), mUnQueuedRequests.end(), upred); + if( (iter != mRoundRobinQueue.end()) || (iter2 != mUnQueuedRequests.end()) ) { LL_DEBUGS("LLMediaDataClient") << "ALREADY THERE: NOT Queuing request for " << *request << LL_ENDL; @@ -731,9 +757,11 @@ void LLObjectMediaDataClient::enqueue(Request *request) // IF the update will cause an object update message to be sent out at some point in the future, it probably should. // Remove any existing requests of this type for this object - remove_matching_requests(mQueue, request->getID(), request->getType()); - remove_matching_requests(mRoundRobinQueue, request->getID(), request->getType()); - remove_matching_requests(mUnQueuedRequests, request->getID(), request->getType()); + PredicateMatchRequest upred(request->getID(), request->getType()); + + mark_dead_and_remove_if(mQueue, upred); + mark_dead_and_remove_if(mRoundRobinQueue, upred); + mark_dead_and_remove_if(mUnQueuedRequests, upred); if (is_new) { @@ -762,7 +790,7 @@ void LLObjectMediaDataClient::enqueue(Request *request) startQueueTimer(); } -bool LLObjectMediaDataClient::canServiceRequest(request_ptr_t request) +bool LLObjectMediaDataClient::canServiceRequest(Request::ptr_t request) { if(mCurrentQueueIsTheSortedQueue) { @@ -798,9 +826,9 @@ bool LLObjectMediaDataClient::isInQueue(const LLMediaDataClientObject::ptr_t &ob if(LLMediaDataClient::isInQueue(object)) return true; - if(find_matching_request(mRoundRobinQueue, object->getID(), LLMediaDataClient::Request::ANY) != mRoundRobinQueue.end()) - return true; - + if (std::find_if(mRoundRobinQueue.begin(), mRoundRobinQueue.end(), PredicateMatchRequest(object->getID())) != mRoundRobinQueue.end()) + return true; + return false; } @@ -809,7 +837,7 @@ void LLObjectMediaDataClient::removeFromQueue(const LLMediaDataClientObject::ptr // First, call parent impl. LLMediaDataClient::removeFromQueue(object); - remove_matching_requests(mRoundRobinQueue, object->getID(), LLMediaDataClient::Request::ANY); + mark_dead_and_remove_if(mRoundRobinQueue, PredicateMatchRequest(object->getID())); } bool LLObjectMediaDataClient::processQueueTimer() @@ -857,14 +885,14 @@ LLSD LLObjectMediaDataClient::RequestGet::getPayload() const LLHttpSDHandler *LLObjectMediaDataClient::RequestGet::createHandler() { - return new LLObjectMediaDataClient::Handler(this); + return new LLObjectMediaDataClient::Handler(shared_from_this()); } void LLObjectMediaDataClient::updateMedia(LLMediaDataClientObject *object) { // Create an update request and put it in the queue. - enqueue(new RequestUpdate(object, this)); + enqueue(Request::ptr_t(new RequestUpdate(object, this))); } LLObjectMediaDataClient::RequestUpdate::RequestUpdate(LLMediaDataClientObject *obj, LLMediaDataClient *mdc): @@ -894,7 +922,7 @@ LLSD LLObjectMediaDataClient::RequestUpdate::getPayload() const LLHttpSDHandler *LLObjectMediaDataClient::RequestUpdate::createHandler() { // This just uses the base class's responder. - return new LLMediaDataClient::Handler(this); + return new LLMediaDataClient::Handler(shared_from_this()); } void LLObjectMediaDataClient::Handler::onSuccess(LLCore::HttpResponse * response, const LLSD &content) @@ -955,7 +983,7 @@ const char *LLObjectMediaNavigateClient::getCapabilityName() const return "ObjectMediaNavigate"; } -void LLObjectMediaNavigateClient::enqueue(Request *request) +void LLObjectMediaNavigateClient::enqueue(Request::ptr_t request) { if(request->isDead()) { @@ -963,8 +991,10 @@ void LLObjectMediaNavigateClient::enqueue(Request *request) return; } + PredicateMatchRequest upred(request); + // If there's already a matching request in the queue, remove it. - request_queue_t::iterator iter = find_matching_request(mQueue, request, LLMediaDataClient::Request::ANY); + request_queue_t::iterator iter = std::find_if(mQueue.begin(), mQueue.end(), upred); if(iter != mQueue.end()) { LL_DEBUGS("LLMediaDataClient") << "removing matching queued request " << (**iter) << LL_ENDL; @@ -972,7 +1002,7 @@ void LLObjectMediaNavigateClient::enqueue(Request *request) } else { - request_set_t::iterator set_iter = find_matching_request(mUnQueuedRequests, request, LLMediaDataClient::Request::ANY); + request_set_t::iterator set_iter = std::find_if(mUnQueuedRequests.begin(), mUnQueuedRequests.end(), upred); if(set_iter != mUnQueuedRequests.end()) { LL_DEBUGS("LLMediaDataClient") << "removing matching unqueued request " << (**set_iter) << LL_ENDL; @@ -1005,7 +1035,7 @@ void LLObjectMediaNavigateClient::navigate(LLMediaDataClientObject *object, U8 t // LL_INFOS("LLMediaDataClient") << "navigate() initiated: " << ll_print_sd(sd_payload) << LL_ENDL; // Create a get request and put it in the queue. - enqueue(new RequestNavigate(object, this, texture_index, url)); + enqueue(Request::ptr_t(new RequestNavigate(object, this, texture_index, url))); } LLObjectMediaNavigateClient::RequestNavigate::RequestNavigate(LLMediaDataClientObject *obj, LLMediaDataClient *mdc, U8 texture_index, const std::string &url): @@ -1026,7 +1056,7 @@ LLSD LLObjectMediaNavigateClient::RequestNavigate::getPayload() const LLHttpSDHandler *LLObjectMediaNavigateClient::RequestNavigate::createHandler() { - return new LLObjectMediaNavigateClient::Handler(this); + return new LLObjectMediaNavigateClient::Handler(shared_from_this()); } void LLObjectMediaNavigateClient::Handler::onSuccess(LLCore::HttpResponse * response, const LLSD &content) diff --git a/indra/newview/llmediadataclient.h b/indra/newview/llmediadataclient.h index d123aa7a11..2c0aedb1d9 100755 --- a/indra/newview/llmediadataclient.h +++ b/indra/newview/llmediadataclient.h @@ -78,6 +78,8 @@ public: // Abstracts the Cap URL, the request, and the responder class LLMediaDataClient : public LLRefCount { + friend class PredicateMatchRequest; + protected: LOG_CLASS(LLMediaDataClient); public: @@ -114,23 +116,29 @@ protected: virtual ~LLMediaDataClient(); // use unref // Request (pure virtual base class for requests in the queue) - class Request : public LLRefCount - { - public: - // Subclasses must implement this to build a payload for their request type. - virtual LLSD getPayload() const = 0; - // and must create the correct type of responder. + class Request: + public boost::enable_shared_from_this + { + public: + typedef boost::shared_ptr ptr_t; + + // Subclasses must implement this to build a payload for their request type. + virtual LLSD getPayload() const = 0; + // and must create the correct type of responder. virtual LLHttpSDHandler *createHandler() = 0; - virtual std::string getURL() { return ""; } + virtual std::string getURL() { return ""; } enum Type { GET, UPDATE, NAVIGATE, - ANY + ANY }; - + + virtual ~Request() + { } + protected: // The only way to create one of these is through a subclass. Request(Type in_type, LLMediaDataClientObject *obj, LLMediaDataClient *mdc, S32 face = -1); @@ -168,7 +176,7 @@ protected: const LLUUID &getID() const { return mObjectID; } S32 getFace() const { return mFace; } - bool isMatch (const Request* other, Type match_type = ANY) const + bool isMatch (const Request::ptr_t &other, Type match_type = ANY) const { return ((match_type == ANY) || (mType == other->mType)) && (mFace == other->mFace) && @@ -190,44 +198,44 @@ protected: // Back pointer to the MDC...not a ref! LLMediaDataClient *mMDC; }; - typedef LLPointer request_ptr_t; + //typedef LLPointer request_ptr_t; class Handler : public LLHttpSDHandler { LOG_CLASS(Handler); public: - Handler(const request_ptr_t &request); - request_ptr_t getRequest() const { return mRequest; } + Handler(const Request::ptr_t &request); + Request::ptr_t getRequest() const { return mRequest; } protected: virtual void onSuccess(LLCore::HttpResponse * response, const LLSD &content); virtual void onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status); private: - request_ptr_t mRequest; + Request::ptr_t mRequest; }; class RetryTimer : public LLEventTimer { public: - RetryTimer(F32 time, request_ptr_t); + RetryTimer(F32 time, Request::ptr_t); virtual BOOL tick(); private: // back-pointer - request_ptr_t mRequest; + Request::ptr_t mRequest; }; protected: - typedef std::list request_queue_t; - typedef std::set request_set_t; + typedef std::list request_queue_t; + typedef std::set request_set_t; // Subclasses must override to return a cap name virtual const char *getCapabilityName() const = 0; // Puts the request into a queue, appropriately handling duplicates, etc. - virtual void enqueue(Request*) = 0; + virtual void enqueue(Request::ptr_t) = 0; virtual void serviceQueue(); virtual void serviceHttp(); @@ -235,15 +243,15 @@ protected: virtual request_queue_t *getQueue() { return &mQueue; }; // Gets the next request, removing it from the queue - virtual request_ptr_t dequeue(); + virtual Request::ptr_t dequeue(); - virtual bool canServiceRequest(request_ptr_t request) { return true; }; + virtual bool canServiceRequest(Request::ptr_t request) { return true; }; // Returns a request to the head of the queue (should only be used for requests that came from dequeue - virtual void pushBack(request_ptr_t request); + virtual void pushBack(Request::ptr_t request); - void trackRequest(request_ptr_t request); - void stopTrackingRequest(request_ptr_t request); + void trackRequest(Request::ptr_t request); + void stopTrackingRequest(Request::ptr_t request); bool isDoneProcessing() const; @@ -339,7 +347,7 @@ public: virtual bool processQueueTimer(); - virtual bool canServiceRequest(request_ptr_t request); + virtual bool canServiceRequest(Request::ptr_t request); protected: // Subclasses must override to return a cap name @@ -348,13 +356,13 @@ protected: virtual request_queue_t *getQueue(); // Puts the request into the appropriate queue - virtual void enqueue(Request*); + virtual void enqueue(Request::ptr_t); class Handler: public LLMediaDataClient::Handler { LOG_CLASS(Handler); public: - Handler(const request_ptr_t &request): + Handler(const Request::ptr_t &request): LLMediaDataClient::Handler(request) {} @@ -370,7 +378,7 @@ private: bool mCurrentQueueIsTheSortedQueue; // Comparator for sorting - static bool compareRequestScores(const request_ptr_t &o1, const request_ptr_t &o2); + static bool compareRequestScores(const Request::ptr_t &o1, const Request::ptr_t &o2); void sortQueue(); }; @@ -395,7 +403,7 @@ public: void navigate(LLMediaDataClientObject *object, U8 texture_index, const std::string &url); // Puts the request into the appropriate queue - virtual void enqueue(Request*); + virtual void enqueue(Request::ptr_t); class RequestNavigate: public Request { @@ -416,7 +424,7 @@ protected: { LOG_CLASS(Handler); public: - Handler(const request_ptr_t &request): + Handler(const Request::ptr_t &request): LLMediaDataClient::Handler(request) {} diff --git a/indra/newview/tests/llmediadataclient_test.cpp b/indra/newview/tests/llmediadataclient_test.cpp index 6f57daf151..61120686e4 100755 --- a/indra/newview/tests/llmediadataclient_test.cpp +++ b/indra/newview/tests/llmediadataclient_test.cpp @@ -106,7 +106,7 @@ const char *DATA = _DATA(VALID_OBJECT_ID,"1.0","true"); LLSD *gPostRecords = NULL; F64 gMinimumInterestLevel = (F64)0.0; - +#if 0 // stubs: void LLHTTPClient::post( const std::string& url, @@ -140,6 +140,7 @@ void LLHTTPClient::post( } responder->successResult(result); } +#endif const F32 HTTP_REQUEST_EXPIRY_SECS = 60.0f; -- cgit v1.2.3 From 56d6e32b450c81829555a4cecfac6b96ce09ebdc Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 29 Apr 2015 09:11:27 -0700 Subject: Remove C++11 erase() replace = NULL with .reset() on smart pointers. --- indra/newview/llmediadataclient.cpp | 7 ++++--- indra/newview/llmediadataclient.h | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'indra') diff --git a/indra/newview/llmediadataclient.cpp b/indra/newview/llmediadataclient.cpp index 770a37c275..ac742e0ce6 100755 --- a/indra/newview/llmediadataclient.cpp +++ b/indra/newview/llmediadataclient.cpp @@ -153,7 +153,8 @@ void mark_dead_and_remove_if(T &c, const PredicateMatchRequest &matchPred) if (matchPred(*it)) { (*it)->markDead(); - it = c.erase(it); + // *TDOO: When C++11 is in change the following line to: it = c.erase(it); + c.erase(it++); } else { @@ -271,7 +272,7 @@ LLMediaDataClient::Request::ptr_t LLMediaDataClient::dequeue() else { // Don't return this request -- it's not ready to be serviced. - request = NULL; + request.reset(); } } @@ -467,7 +468,7 @@ BOOL LLMediaDataClient::RetryTimer::tick() } // Release the ref to the request. - mRequest = NULL; + mRequest.reset() // Don't fire again return TRUE; diff --git a/indra/newview/llmediadataclient.h b/indra/newview/llmediadataclient.h index 2c0aedb1d9..0b81a6ab22 100755 --- a/indra/newview/llmediadataclient.h +++ b/indra/newview/llmediadataclient.h @@ -297,9 +297,9 @@ private: bool mQueueTimerIsRunning; - template friend typename T::iterator find_matching_request(T &c, const LLMediaDataClient::Request *request, LLMediaDataClient::Request::Type match_type); - template friend typename T::iterator find_matching_request(T &c, const LLUUID &id, LLMediaDataClient::Request::Type match_type); - template friend void remove_matching_requests(T &c, const LLUUID &id, LLMediaDataClient::Request::Type match_type); +// template friend typename T::iterator find_matching_request(T &c, const LLMediaDataClient::Request *request, LLMediaDataClient::Request::Type match_type); +// template friend typename T::iterator find_matching_request(T &c, const LLUUID &id, LLMediaDataClient::Request::Type match_type); +// template friend void remove_matching_requests(T &c, const LLUUID &id, LLMediaDataClient::Request::Type match_type); }; // MediaDataClient specific for the ObjectMedia cap -- cgit v1.2.3 From b0c64d5cbfdeda9a1bbc2fbc63a9afca397b49f1 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 29 Apr 2015 09:30:37 -0700 Subject: Forgot a ';' --- indra/llxml/llcontrol.h | 2 +- indra/newview/llmediadataclient.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'indra') diff --git a/indra/llxml/llcontrol.h b/indra/llxml/llcontrol.h index 04575d81e0..8116adeae2 100755 --- a/indra/llxml/llcontrol.h +++ b/indra/llxml/llcontrol.h @@ -256,7 +256,7 @@ public: } else { - LL_WARNS() << "Control " << name << " not found." << LL_ENDL; + LL_WARNS_ONCE() << "Control " << name << " not found." << LL_ENDL; return T(); } return convert_from_llsd(value, type, name); diff --git a/indra/newview/llmediadataclient.cpp b/indra/newview/llmediadataclient.cpp index ac742e0ce6..f996e7b26e 100755 --- a/indra/newview/llmediadataclient.cpp +++ b/indra/newview/llmediadataclient.cpp @@ -468,7 +468,7 @@ BOOL LLMediaDataClient::RetryTimer::tick() } // Release the ref to the request. - mRequest.reset() + mRequest.reset(); // Don't fire again return TRUE; -- cgit v1.2.3 From 885dc2bbabb985d61569fa664eafd8d4985a67c0 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 29 Apr 2015 09:33:00 -0700 Subject: This was not supposed to get checked in. --- indra/llxml/llcontrol.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/llxml/llcontrol.h b/indra/llxml/llcontrol.h index 8116adeae2..04575d81e0 100755 --- a/indra/llxml/llcontrol.h +++ b/indra/llxml/llcontrol.h @@ -256,7 +256,7 @@ public: } else { - LL_WARNS_ONCE() << "Control " << name << " not found." << LL_ENDL; + LL_WARNS() << "Control " << name << " not found." << LL_ENDL; return T(); } return convert_from_llsd(value, type, name); -- cgit v1.2.3 From 82b671dadc52ae2caca9c5b2ad0f1110c15754af Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 29 Apr 2015 14:48:55 -0700 Subject: Convert IM invitation to coroutines. --- indra/newview/llimview.cpp | 328 ++++++++++++++++++++------------------------- indra/newview/llimview.h | 4 + 2 files changed, 148 insertions(+), 184 deletions(-) (limited to 'indra') diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp index 5d3a11e245..abf206d2d7 100755 --- a/indra/newview/llimview.cpp +++ b/indra/newview/llimview.cpp @@ -69,6 +69,7 @@ #include "llconversationlog.h" #include "message.h" #include "llviewerregion.h" +#include "llcorehttputil.h" const static std::string ADHOC_NAME_SUFFIX(" Conference"); @@ -79,6 +80,10 @@ const static std::string NEARBY_P2P_BY_AGENT("nearby_P2P_by_agent"); /** Timeout of outgoing session initialization (in seconds) */ const static U32 SESSION_INITIALIZATION_TIMEOUT = 30; +void startConfrenceCoro(LLCoros::self& self, std::string url, LLUUID tempSessionId, LLUUID creatorId, LLUUID otherParticipantId, LLSD agents); +void chatterBoxInvitationCoro(LLCoros::self& self, std::string url, LLUUID sessionId, LLIMMgr::EInvitationType invitationType); +void start_deprecated_conference_chat(const LLUUID& temp_session_id, const LLUUID& creator_id, const LLUUID& other_participant_id, const LLSD& agents_to_invite); + std::string LLCallDialogManager::sPreviousSessionlName = ""; LLIMModel::LLIMSession::SType LLCallDialogManager::sPreviousSessionType = LLIMModel::LLIMSession::P2P_SESSION; std::string LLCallDialogManager::sCurrentSessionlName = ""; @@ -110,7 +115,7 @@ void process_dnd_im(const LLSD& notification) { LLSD data = notification["substitutions"]; LLUUID sessionID = data["SESSION_ID"].asUUID(); - LLUUID fromID = data["FROM_ID"].asUUID(); + LLUUID fromID = data["FROM_ID"].asUUID(); //re-create the IM session if needed //(when coming out of DND mode upon app restart) @@ -131,12 +136,10 @@ void process_dnd_im(const LLSD& notification) fromID, false, false); //will need slight refactor to retrieve whether offline message or not (assume online for now) - } - - notify_of_message(data, true); } - + notify_of_message(data, true); +} static void on_avatar_name_cache_toast(const LLUUID& agent_id, @@ -387,6 +390,130 @@ void on_new_message(const LLSD& msg) notify_of_message(msg, false); } +void startConfrenceCoro(LLCoros::self& self, std::string url, + LLUUID tempSessionId, LLUUID creatorId, LLUUID otherParticipantId, LLSD agents) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("TwitterConnect", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + + LLSD postData; + postData["method"] = "start conference"; + postData["session-id"] = tempSessionId; + postData["params"] = agents; + + LLSD result = httpAdapter->postAndYield(self, httpRequest, url, postData); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + + if (!status) + { + LL_WARNS("LLIMModel") << "Failed to start conference" << LL_ENDL; + //try an "old school" way. + // *TODO: What about other error status codes? 4xx 5xx? + if (status == LLCore::HttpStatus(HTTP_BAD_REQUEST)) + { + start_deprecated_conference_chat( + tempSessionId, + creatorId, + otherParticipantId, + agents); + } + + //else throw an error back to the client? + //in theory we should have just have these error strings + //etc. set up in this file as opposed to the IMMgr, + //but the error string were unneeded here previously + //and it is not worth the effort switching over all + //the possible different language translations + } +} + +void chatterBoxInvitationCoro(LLCoros::self& self, std::string url, LLUUID sessionId, LLIMMgr::EInvitationType invitationType) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("TwitterConnect", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + + LLSD postData; + postData["method"] = "accept invitation"; + postData["session-id"] = sessionId; + + LLSD result = httpAdapter->postAndYield(self, httpRequest, url, postData); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + + if (!gIMMgr) + { + LL_WARNS("") << "Global IM Manager is NULL" << LL_ENDL; + return; + } + + if (!status) + { + LL_WARNS("LLIMModel") << "Bad HTTP response in chatterBoxInvitationCoro" << LL_ENDL; + //throw something back to the viewer here? + + gIMMgr->clearPendingAgentListUpdates(sessionId); + gIMMgr->clearPendingInvitation(sessionId); + + if (status == LLCore::HttpStatus(HTTP_NOT_FOUND)) + { + static const std::string error_string("session_does_not_exist_error"); + gIMMgr->showSessionStartError(error_string, sessionId); + } + return; + } + + result.erase(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS); + + LLIMSpeakerMgr* speakerMgr = LLIMModel::getInstance()->getSpeakerManager(sessionId); + if (speakerMgr) + { + //we've accepted our invitation + //and received a list of agents that were + //currently in the session when the reply was sent + //to us. Now, it is possible that there were some agents + //to slip in/out between when that message was sent to us + //and now. + + //the agent list updates we've received have been + //accurate from the time we were added to the session + //but unfortunately, our base that we are receiving here + //may not be the most up to date. It was accurate at + //some point in time though. + speakerMgr->setSpeakers(result); + + //we now have our base of users in the session + //that was accurate at some point, but maybe not now + //so now we apply all of the updates we've received + //in case of race conditions + speakerMgr->updateSpeakers(gIMMgr->getPendingAgentListUpdates(sessionId)); + } + + if (LLIMMgr::INVITATION_TYPE_VOICE == invitationType) + { + gIMMgr->startCall(sessionId, LLVoiceChannel::INCOMING_CALL); + } + + if ((invitationType == LLIMMgr::INVITATION_TYPE_VOICE + || invitationType == LLIMMgr::INVITATION_TYPE_IMMEDIATE) + && LLIMModel::getInstance()->findIMSession(sessionId)) + { + // TODO remove in 2010, for voice calls we do not open an IM window + //LLFloaterIMSession::show(mSessionID); + } + + gIMMgr->clearPendingAgentListUpdates(sessionId); + gIMMgr->clearPendingInvitation(sessionId); + +} + + LLIMModel::LLIMModel() { addNewMsgCallback(boost::bind(&LLFloaterIMSession::newIMCallback, _1)); @@ -1459,54 +1586,6 @@ void start_deprecated_conference_chat( delete[] bucket; } -class LLStartConferenceChatResponder : public LLHTTPClient::Responder -{ - LOG_CLASS(LLStartConferenceChatResponder); -public: - LLStartConferenceChatResponder( - const LLUUID& temp_session_id, - const LLUUID& creator_id, - const LLUUID& other_participant_id, - const LLSD& agents_to_invite) - { - mTempSessionID = temp_session_id; - mCreatorID = creator_id; - mOtherParticipantID = other_participant_id; - mAgents = agents_to_invite; - } - -protected: - virtual void httpFailure() - { - //try an "old school" way. - // *TODO: What about other error status codes? 4xx 5xx? - if ( getStatus() == HTTP_BAD_REQUEST ) - { - start_deprecated_conference_chat( - mTempSessionID, - mCreatorID, - mOtherParticipantID, - mAgents); - } - - LL_WARNS() << dumpResponse() << LL_ENDL; - - //else throw an error back to the client? - //in theory we should have just have these error strings - //etc. set up in this file as opposed to the IMMgr, - //but the error string were unneeded here previously - //and it is not worth the effort switching over all - //the possible different language translations - } - -private: - LLUUID mTempSessionID; - LLUUID mCreatorID; - LLUUID mOtherParticipantID; - - LLSD mAgents; -}; - // Returns true if any messages were sent, false otherwise. // Is sort of equivalent to "does the server need to do anything?" bool LLIMModel::sendStartSession( @@ -1543,20 +1622,10 @@ bool LLIMModel::sendStartSession( { std::string url = region->getCapability( "ChatSessionRequest"); - LLSD data; - data["method"] = "start conference"; - data["session-id"] = temp_session_id; - data["params"] = agents; - - LLHTTPClient::post( - url, - data, - new LLStartConferenceChatResponder( - temp_session_id, - gAgent.getID(), - other_participant_id, - data["params"])); + LLCoros::instance().launch("startConfrenceCoro", + boost::bind(&startConfrenceCoro, _1, url, + temp_session_id, gAgent.getID(), other_participant_id, agents)); } else { @@ -1574,97 +1643,6 @@ bool LLIMModel::sendStartSession( return false; } -// -// Helper Functions -// - -class LLViewerChatterBoxInvitationAcceptResponder : - public LLHTTPClient::Responder -{ - LOG_CLASS(LLViewerChatterBoxInvitationAcceptResponder); -public: - LLViewerChatterBoxInvitationAcceptResponder( - const LLUUID& session_id, - LLIMMgr::EInvitationType invitation_type) - { - mSessionID = session_id; - mInvitiationType = invitation_type; - } - -private: - void httpSuccess() - { - const LLSD& content = getContent(); - if (!content.isMap()) - { - failureResult(HTTP_INTERNAL_ERROR, "Malformed response contents", content); - return; - } - if ( gIMMgr) - { - LLIMSpeakerMgr* speaker_mgr = LLIMModel::getInstance()->getSpeakerManager(mSessionID); - if (speaker_mgr) - { - //we've accepted our invitation - //and received a list of agents that were - //currently in the session when the reply was sent - //to us. Now, it is possible that there were some agents - //to slip in/out between when that message was sent to us - //and now. - - //the agent list updates we've received have been - //accurate from the time we were added to the session - //but unfortunately, our base that we are receiving here - //may not be the most up to date. It was accurate at - //some point in time though. - speaker_mgr->setSpeakers(content); - - //we now have our base of users in the session - //that was accurate at some point, but maybe not now - //so now we apply all of the udpates we've received - //in case of race conditions - speaker_mgr->updateSpeakers(gIMMgr->getPendingAgentListUpdates(mSessionID)); - } - - if (LLIMMgr::INVITATION_TYPE_VOICE == mInvitiationType) - { - gIMMgr->startCall(mSessionID, LLVoiceChannel::INCOMING_CALL); - } - - if ((mInvitiationType == LLIMMgr::INVITATION_TYPE_VOICE - || mInvitiationType == LLIMMgr::INVITATION_TYPE_IMMEDIATE) - && LLIMModel::getInstance()->findIMSession(mSessionID)) - { - // TODO remove in 2010, for voice calls we do not open an IM window - //LLFloaterIMSession::show(mSessionID); - } - - gIMMgr->clearPendingAgentListUpdates(mSessionID); - gIMMgr->clearPendingInvitation(mSessionID); - } - } - - void httpFailure() - { - LL_WARNS() << dumpResponse() << LL_ENDL; - //throw something back to the viewer here? - if ( gIMMgr ) - { - gIMMgr->clearPendingAgentListUpdates(mSessionID); - gIMMgr->clearPendingInvitation(mSessionID); - if ( HTTP_NOT_FOUND == getStatus() ) - { - static const std::string error_string("session_does_not_exist_error"); - gIMMgr->showSessionStartError(error_string, mSessionID); - } - } - } - -private: - LLUUID mSessionID; - LLIMMgr::EInvitationType mInvitiationType; -}; - // the other_participant_id is either an agent_id, a group_id, or an inventory // folder item_id (collection of calling cards) @@ -2490,15 +2468,9 @@ void LLIncomingCallDialog::processCallResponse(S32 response, const LLSD &payload if (voice) { - LLSD data; - data["method"] = "accept invitation"; - data["session-id"] = session_id; - LLHTTPClient::post( - url, - data, - new LLViewerChatterBoxInvitationAcceptResponder( - session_id, - inv_type)); + LLCoros::instance().launch("chatterBoxInvitationCoro", + boost::bind(&chatterBoxInvitationCoro, _1, url, + session_id, inv_type)); // send notification message to the corresponding chat if (payload["notify_box_type"].asString() == "VoiceInviteGroup" || payload["notify_box_type"].asString() == "VoiceInviteAdHoc") @@ -2583,15 +2555,9 @@ bool inviteUserResponse(const LLSD& notification, const LLSD& response) std::string url = gAgent.getRegion()->getCapability( "ChatSessionRequest"); - LLSD data; - data["method"] = "accept invitation"; - data["session-id"] = session_id; - LLHTTPClient::post( - url, - data, - new LLViewerChatterBoxInvitationAcceptResponder( - session_id, - inv_type)); + LLCoros::instance().launch("chatterBoxInvitationCoro", + boost::bind(&chatterBoxInvitationCoro, _1, url, + session_id, inv_type)); } } break; @@ -3681,15 +3647,9 @@ public: if ( url != "" ) { - LLSD data; - data["method"] = "accept invitation"; - data["session-id"] = session_id; - LLHTTPClient::post( - url, - data, - new LLViewerChatterBoxInvitationAcceptResponder( - session_id, - LLIMMgr::INVITATION_TYPE_INSTANT_MESSAGE)); + LLCoros::instance().launch("chatterBoxInvitationCoro", + boost::bind(&chatterBoxInvitationCoro, _1, url, + session_id, LLIMMgr::INVITATION_TYPE_INSTANT_MESSAGE)); } } //end if invitation has instant message else if ( input["body"].has("voice") ) diff --git a/indra/newview/llimview.h b/indra/newview/llimview.h index f92eff4845..41a8813acb 100755 --- a/indra/newview/llimview.h +++ b/indra/newview/llimview.h @@ -34,6 +34,9 @@ #include "lllogchat.h" #include "llvoicechannel.h" +#include "llcoros.h" +#include "lleventcoro.h" + class LLAvatarName; class LLFriendObserver; class LLCallDialogManager; @@ -292,6 +295,7 @@ private: * Add message to a list of message associated with session specified by session_id */ bool addToHistory(const LLUUID& session_id, const std::string& from, const LLUUID& from_id, const std::string& utf8_text); + }; class LLIMSessionObserver -- cgit v1.2.3 From cd55655592b7518451d78b1ef229bce3316af420 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 30 Apr 2015 13:12:09 -0700 Subject: Crash logger changes to LLCore::Http --- indra/llcrashlogger/CMakeLists.txt | 2 + indra/llcrashlogger/llcrashlogger.cpp | 125 ++++++++++++++++++++++++++-------- indra/llcrashlogger/llcrashlogger.h | 10 +++ indra/llmessage/llcorehttputil.cpp | 39 +---------- indra/llmessage/llcorehttputil.h | 57 ++++++++++++++-- indra/mac_crash_logger/CMakeLists.txt | 6 ++ indra/win_crash_logger/CMakeLists.txt | 6 ++ 7 files changed, 173 insertions(+), 72 deletions(-) (limited to 'indra') diff --git a/indra/llcrashlogger/CMakeLists.txt b/indra/llcrashlogger/CMakeLists.txt index ba4e34d92b..c41e61c497 100755 --- a/indra/llcrashlogger/CMakeLists.txt +++ b/indra/llcrashlogger/CMakeLists.txt @@ -3,6 +3,7 @@ project(llcrashlogger) include(00-Common) +include(LLCoreHttp) include(LLCommon) include(LLMath) include(LLMessage) @@ -10,6 +11,7 @@ include(LLVFS) include(LLXML) include_directories( + ${LLCOREHTTP_INCLUDE_DIRS} ${LLCOMMON_INCLUDE_DIRS} ${LLMATH_INCLUDE_DIRS} ${LLMESSAGE_INCLUDE_DIRS} diff --git a/indra/llcrashlogger/llcrashlogger.cpp b/indra/llcrashlogger/llcrashlogger.cpp index 7a97c16ea7..ec794ac478 100755 --- a/indra/llcrashlogger/llcrashlogger.cpp +++ b/indra/llcrashlogger/llcrashlogger.cpp @@ -40,38 +40,45 @@ #include "lldir.h" #include "llfile.h" #include "llsdserialize.h" -#include "lliopipe.h" -#include "llpumpio.h" -#include "llhttpclient.h" #include "llsdserialize.h" #include "llproxy.h" - -LLPumpIO* gServicePump = NULL; +#include "llcorehttputil.h" +#include "llhttpsdhandler.h" +#include "httpcommon.h" +#include "httpresponse.h" + +#include +#include + BOOL gBreak = false; BOOL gSent = false; -class LLCrashLoggerResponder : public LLHTTPClient::Responder +int LLCrashLogger::ssl_mutex_count = 0; +LLCoreInt::HttpMutex ** LLCrashLogger::ssl_mutex_list = NULL; + +class LLCrashLoggerHandler : public LLHttpSDHandler { - LOG_CLASS(LLCrashLoggerResponder); + LOG_CLASS(LLCrashLoggerHandler); public: - LLCrashLoggerResponder() - { - } + LLCrashLoggerHandler() {} protected: - virtual void httpFailure() - { - LL_WARNS() << dumpResponse() << LL_ENDL; - gBreak = true; - } + virtual void onSuccess(LLCore::HttpResponse * response, const LLSD &content); + virtual void onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status); - virtual void httpSuccess() - { - gBreak = true; - gSent = true; - } }; +void LLCrashLoggerHandler::onSuccess(LLCore::HttpResponse * response, const LLSD &content) +{ + gBreak = true; + gSent = true; +} + +void LLCrashLoggerHandler::onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status) +{ + gBreak = true; +} + LLCrashLogger::LLCrashLogger() : mCrashBehavior(CRASH_BEHAVIOR_ALWAYS_SEND), mCrashInPreviousExec(false), @@ -389,14 +396,20 @@ bool LLCrashLogger::saveCrashBehaviorSetting(S32 crash_behavior) bool LLCrashLogger::runCrashLogPost(std::string host, LLSD data, std::string msg, int retries, int timeout) { + LLCore::HttpRequest httpRequest; + gBreak = false; for(int i = 0; i < retries; ++i) { updateApplication(llformat("%s, try %d...", msg.c_str(), i+1)); - LLHTTPClient::post(host, data, new LLCrashLoggerResponder(), timeout); - while(!gBreak) + + LLCoreHttpUtil::requestPostWithLLSD(&httpRequest, LLCore::HttpRequest::DEFAULT_POLICY_ID, 0, + host, data, NULL, NULL, new LLCrashLoggerHandler); + + while(!gBreak) { updateApplication(); // No new message, just pump the IO + httpRequest.update(0L); } if(gSent) { @@ -510,8 +523,6 @@ bool LLCrashLogger::sendCrashLogs() void LLCrashLogger::updateApplication(const std::string& message) { - gServicePump->pump(); - gServicePump->callback(); if (!message.empty()) LL_INFOS() << message << LL_ENDL; } @@ -576,16 +587,74 @@ bool LLCrashLogger::init() return false; } - gServicePump = new LLPumpIO(gAPRPoolp); - gServicePump->prime(gAPRPoolp); - LLHTTPClient::setPump(*gServicePump); - + init_curl(); + LLCore::HttpRequest::createService(); + LLCore::HttpRequest::startThread(); + return true; } // For cleanup code common to all platforms. void LLCrashLogger::commonCleanup() { + term_curl(); LLError::logToFile(""); //close crashreport.log LLProxy::cleanupClass(); } + +void LLCrashLogger::init_curl() +{ + curl_global_init(CURL_GLOBAL_ALL); + + ssl_mutex_count = CRYPTO_num_locks(); + if (ssl_mutex_count > 0) + { + ssl_mutex_list = new LLCoreInt::HttpMutex *[ssl_mutex_count]; + + for (int i(0); i < ssl_mutex_count; ++i) + { + ssl_mutex_list[i] = new LLCoreInt::HttpMutex; + } + + CRYPTO_set_locking_callback(ssl_locking_callback); + CRYPTO_set_id_callback(ssl_thread_id_callback); + } +} + + +void LLCrashLogger::term_curl() +{ + CRYPTO_set_locking_callback(NULL); + for (int i(0); i < ssl_mutex_count; ++i) + { + delete ssl_mutex_list[i]; + } + delete[] ssl_mutex_list; +} + + +unsigned long LLCrashLogger::ssl_thread_id_callback(void) +{ +#if LL_WINDOWS + return (unsigned long)GetCurrentThread(); +#else + return (unsigned long)pthread_self(); +#endif +} + + +void LLCrashLogger::ssl_locking_callback(int mode, int type, const char * /* file */, int /* line */) +{ + if (type >= 0 && type < ssl_mutex_count) + { + if (mode & CRYPTO_LOCK) + { + ssl_mutex_list[type]->lock(); + } + else + { + ssl_mutex_list[type]->unlock(); + } + } +} + diff --git a/indra/llcrashlogger/llcrashlogger.h b/indra/llcrashlogger/llcrashlogger.h index a06bf1d6ac..f5383daefc 100755 --- a/indra/llcrashlogger/llcrashlogger.h +++ b/indra/llcrashlogger/llcrashlogger.h @@ -34,6 +34,7 @@ #include "llsd.h" #include "llcontrol.h" #include "llcrashlock.h" +#include "_mutex.h" // Crash reporter behavior const S32 CRASH_BEHAVIOR_ASK = 0; @@ -66,6 +67,11 @@ public: bool readMinidump(std::string minidump_path); protected: + static void init_curl(); + static void term_curl(); + static unsigned long ssl_thread_id_callback(void); + static void ssl_locking_callback(int mode, int type, const char * file, int line); + S32 mCrashBehavior; BOOL mCrashInPreviousExec; std::map mFileMap; @@ -78,6 +84,10 @@ protected: LLSD mDebugLog; bool mSentCrashLogs; LLCrashLock mKeyMaster; + + static int ssl_mutex_count; + static LLCoreInt::HttpMutex ** ssl_mutex_list; + }; #endif //LLCRASHLOGGER_H diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index a3226ee2c3..1f9d4d15cd 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -90,18 +90,7 @@ HttpHandle requestPostWithLLSD(HttpRequest * request, return handle; } -HttpHandle requestPostWithLLSD(HttpRequest::ptr_t & request, - HttpRequest::policy_t policy_id, - HttpRequest::priority_t priority, - const std::string & url, - const LLSD & body, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers, - HttpHandler * handler) -{ - return requestPostWithLLSD(request.get(), policy_id, priority, - url, body, options.get(), headers.get(), handler); -} + HttpHandle requestPutWithLLSD(HttpRequest * request, HttpRequest::policy_t policy_id, @@ -129,19 +118,6 @@ HttpHandle requestPutWithLLSD(HttpRequest * request, return handle; } -HttpHandle requestPutWithLLSD(HttpRequest::ptr_t & request, - HttpRequest::policy_t policy_id, - HttpRequest::priority_t priority, - const std::string & url, - const LLSD & body, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers, - HttpHandler * handler) -{ - return requestPutWithLLSD(request.get(), policy_id, priority, - url, body, options.get(), headers.get(), handler); -} - HttpHandle requestPatchWithLLSD(HttpRequest * request, HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, @@ -168,19 +144,6 @@ HttpHandle requestPatchWithLLSD(HttpRequest * request, return handle; } -HttpHandle requestPatchWithLLSD(HttpRequest::ptr_t & request, - HttpRequest::policy_t policy_id, - HttpRequest::priority_t priority, - const std::string & url, - const LLSD & body, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers, - HttpHandler * handler) -{ - return requestPatchWithLLSD(request.get(), policy_id, priority, - url, body, options.get(), headers.get(), handler); -} - std::string responseToString(LLCore::HttpResponse * response) { diff --git a/indra/llmessage/llcorehttputil.h b/indra/llmessage/llcorehttputil.h index 1e2b50e189..77b9163492 100644 --- a/indra/llmessage/llcorehttputil.h +++ b/indra/llmessage/llcorehttputil.h @@ -112,14 +112,30 @@ LLCore::HttpHandle requestPostWithLLSD(LLCore::HttpRequest * request, LLCore::HttpHeaders * headers, LLCore::HttpHandler * handler); -LLCore::HttpHandle requestPostWithLLSD(LLCore::HttpRequest::ptr_t & request, +inline LLCore::HttpHandle requestPostWithLLSD(LLCore::HttpRequest::ptr_t & request, LLCore::HttpRequest::policy_t policy_id, LLCore::HttpRequest::priority_t priority, const std::string & url, const LLSD & body, LLCore::HttpOptions::ptr_t & options, LLCore::HttpHeaders::ptr_t & headers, - LLCore::HttpHandler * handler); + LLCore::HttpHandler * handler) +{ + return requestPostWithLLSD(request.get(), policy_id, priority, + url, body, options.get(), headers.get(), handler); +} + +inline LLCore::HttpHandle requestPostWithLLSD(LLCore::HttpRequest::ptr_t & request, + LLCore::HttpRequest::policy_t policy_id, + LLCore::HttpRequest::priority_t priority, + const std::string & url, + const LLSD & body, + LLCore::HttpHandler * handler) +{ + return requestPostWithLLSD(request.get(), policy_id, priority, + url, body, NULL, NULL, handler); +} + /// Issue a standard HttpRequest::requestPut() call but using /// and LLSD object as the request body. Conventions are the @@ -146,14 +162,29 @@ LLCore::HttpHandle requestPutWithLLSD(LLCore::HttpRequest * request, LLCore::HttpHeaders * headers, LLCore::HttpHandler * handler); -LLCore::HttpHandle requestPutWithLLSD(LLCore::HttpRequest::ptr_t & request, +inline LLCore::HttpHandle requestPutWithLLSD(LLCore::HttpRequest::ptr_t & request, LLCore::HttpRequest::policy_t policy_id, LLCore::HttpRequest::priority_t priority, const std::string & url, const LLSD & body, LLCore::HttpOptions::ptr_t & options, LLCore::HttpHeaders::ptr_t & headers, - LLCore::HttpHandler * handler); + LLCore::HttpHandler * handler) +{ + return requestPutWithLLSD(request.get(), policy_id, priority, + url, body, options.get(), headers.get(), handler); +} + +inline LLCore::HttpHandle requestPutWithLLSD(LLCore::HttpRequest::ptr_t & request, + LLCore::HttpRequest::policy_t policy_id, + LLCore::HttpRequest::priority_t priority, + const std::string & url, + const LLSD & body, + LLCore::HttpHandler * handler) +{ + return requestPutWithLLSD(request.get(), policy_id, priority, + url, body, NULL, NULL, handler); +} /// Issue a standard HttpRequest::requestPatch() call but using /// and LLSD object as the request body. Conventions are the @@ -180,15 +211,29 @@ LLCore::HttpHandle requestPatchWithLLSD(LLCore::HttpRequest * request, LLCore::HttpHeaders * headers, LLCore::HttpHandler * handler); -LLCore::HttpHandle requestPatchWithLLSD(LLCore::HttpRequest::ptr_t & request, +inline LLCore::HttpHandle requestPatchWithLLSD(LLCore::HttpRequest::ptr_t & request, LLCore::HttpRequest::policy_t policy_id, LLCore::HttpRequest::priority_t priority, const std::string & url, const LLSD & body, LLCore::HttpOptions::ptr_t & options, LLCore::HttpHeaders::ptr_t & headers, - LLCore::HttpHandler * handler); + LLCore::HttpHandler * handler) +{ + return requestPatchWithLLSD(request.get(), policy_id, priority, + url, body, options.get(), headers.get(), handler); +} +inline LLCore::HttpHandle requestPatchWithLLSD(LLCore::HttpRequest::ptr_t & request, + LLCore::HttpRequest::policy_t policy_id, + LLCore::HttpRequest::priority_t priority, + const std::string & url, + const LLSD & body, + LLCore::HttpHandler * handler) +{ + return requestPatchWithLLSD(request.get(), policy_id, priority, + url, body, NULL, NULL, handler); +} /// The HttpCoroHandler is a specialization of the LLCore::HttpHandler for /// interacting with coroutines. When the request is completed the response diff --git a/indra/mac_crash_logger/CMakeLists.txt b/indra/mac_crash_logger/CMakeLists.txt index c59645bd70..ce20284b59 100755 --- a/indra/mac_crash_logger/CMakeLists.txt +++ b/indra/mac_crash_logger/CMakeLists.txt @@ -4,6 +4,7 @@ project(mac_crash_logger) include(00-Common) include(LLCommon) +include(LLCoreHttp) include(LLCrashLogger) include(LLMath) include(LLMessage) @@ -11,8 +12,10 @@ include(LLVFS) include(LLXML) include(Linking) include(LLSharedLibs) +include(Boost) include_directories( + ${LLCOREHTTP_INCLUDE_DIRS} ${LLCOMMON_INCLUDE_DIRS} ${LLCRASHLOGGER_INCLUDE_DIRS} ${LLMATH_INCLUDE_DIRS} @@ -71,7 +74,10 @@ target_link_libraries(mac-crash-logger ${LLMESSAGE_LIBRARIES} ${LLVFS_LIBRARIES} ${LLMATH_LIBRARIES} + ${LLCOREHTTP_LIBRARIES} ${LLCOMMON_LIBRARIES} + ${BOOST_CONTEXT_LIBRARY} + ${BOOST_COROUTINE_LIBRARY} ) add_custom_command( diff --git a/indra/win_crash_logger/CMakeLists.txt b/indra/win_crash_logger/CMakeLists.txt index c6070020db..a52c8cc42b 100755 --- a/indra/win_crash_logger/CMakeLists.txt +++ b/indra/win_crash_logger/CMakeLists.txt @@ -4,6 +4,7 @@ project(win_crash_logger) include(00-Common) include(LLCommon) +include(LLCoreHttp) include(LLCrashLogger) include(LLMath) include(LLMessage) @@ -13,8 +14,10 @@ include(LLXML) include(Linking) include(LLSharedLibs) include(GoogleBreakpad) +include(Boost) include_directories( + ${LLCOREHTTP_INCLUDE_DIRS} ${LLCOMMON_INCLUDE_DIRS} ${LLCRASHLOGGER_INCLUDE_DIRS} ${LLMATH_INCLUDE_DIRS} @@ -77,7 +80,10 @@ target_link_libraries(windows-crash-logger ${LLXML_LIBRARIES} ${LLMESSAGE_LIBRARIES} ${LLMATH_LIBRARIES} + ${LLCOREHTTP_LIBRARIES} ${LLCOMMON_LIBRARIES} + ${BOOST_CONTEXT_LIBRARY} + ${BOOST_COROUTINE_LIBRARY} ${WINDOWS_LIBRARIES} ${DXGUID_LIBRARY} ${GOOGLE_PERFTOOLS_LIBRARIES} -- cgit v1.2.3 From f577f7164142769ae9c45e6d734dfbf60ff3ba3c Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 30 Apr 2015 13:16:02 -0700 Subject: Missed the linux crash logger. --- indra/linux_crash_logger/CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'indra') diff --git a/indra/linux_crash_logger/CMakeLists.txt b/indra/linux_crash_logger/CMakeLists.txt index c0fc1b2be0..3253c79ed3 100755 --- a/indra/linux_crash_logger/CMakeLists.txt +++ b/indra/linux_crash_logger/CMakeLists.txt @@ -4,6 +4,7 @@ project(linux_crash_logger) include(00-Common) include(GLH) +include(LLCoreHttp) include(LLCommon) include(LLCrashLogger) include(LLMath) @@ -13,8 +14,10 @@ include(LLXML) include(Linking) include(UI) include(FreeType) +include(Boost) include_directories( + ${LLCOREHTTP_INCLUDE_DIRS} ${LLCOMMON_INCLUDE_DIRS} ${LLCRASHLOGGER_INCLUDE_DIRS} ${LLMATH_INCLUDE_DIRS} @@ -60,7 +63,10 @@ target_link_libraries(linux-crash-logger ${LLMESSAGE_LIBRARIES} ${LLVFS_LIBRARIES} ${LLMATH_LIBRARIES} + ${LLCOREHTTP_LIBRARIES} ${LLCOMMON_LIBRARIES} + ${BOOST_CONTEXT_LIBRARY} + ${BOOST_COROUTINE_LIBRARY} ${UI_LIBRARIES} ${DB_LIBRARIES} ${FREETYPE_LIBRARIES} -- cgit v1.2.3 From cc26fb5b24c0276e01c66d0eb6c695831809ad69 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 30 Apr 2015 14:06:03 -0700 Subject: Add LIBRT to libraries in linux crash logger. --- indra/linux_crash_logger/CMakeLists.txt | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'indra') diff --git a/indra/linux_crash_logger/CMakeLists.txt b/indra/linux_crash_logger/CMakeLists.txt index 3253c79ed3..67b3ed109a 100755 --- a/indra/linux_crash_logger/CMakeLists.txt +++ b/indra/linux_crash_logger/CMakeLists.txt @@ -56,6 +56,14 @@ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--as-needed") add_executable(linux-crash-logger ${linux_crash_logger_SOURCE_FILES}) +if (LINUX) + # llcommon uses `clock_gettime' which is provided by librt on linux. + set(LIBRT_LIBRARY + rt + ) +endif (LINUX) + + target_link_libraries(linux-crash-logger ${LLCRASHLOGGER_LIBRARIES} ${LLVFS_LIBRARIES} @@ -65,6 +73,7 @@ target_link_libraries(linux-crash-logger ${LLMATH_LIBRARIES} ${LLCOREHTTP_LIBRARIES} ${LLCOMMON_LIBRARIES} + ${LIBRT_LIBRARY} ${BOOST_CONTEXT_LIBRARY} ${BOOST_COROUTINE_LIBRARY} ${UI_LIBRARIES} -- cgit v1.2.3 From 7c639f11a6a4bb0b194d97e9932310561e11df71 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 30 Apr 2015 14:52:20 -0700 Subject: Change link order --- indra/linux_crash_logger/CMakeLists.txt | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'indra') diff --git a/indra/linux_crash_logger/CMakeLists.txt b/indra/linux_crash_logger/CMakeLists.txt index 67b3ed109a..480a55a709 100755 --- a/indra/linux_crash_logger/CMakeLists.txt +++ b/indra/linux_crash_logger/CMakeLists.txt @@ -56,12 +56,8 @@ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--as-needed") add_executable(linux-crash-logger ${linux_crash_logger_SOURCE_FILES}) -if (LINUX) - # llcommon uses `clock_gettime' which is provided by librt on linux. - set(LIBRT_LIBRARY - rt - ) -endif (LINUX) +# llcommon uses `clock_gettime' which is provided by librt on linux. +set(LIBRT_LIBRARY rt) target_link_libraries(linux-crash-logger @@ -72,8 +68,8 @@ target_link_libraries(linux-crash-logger ${LLVFS_LIBRARIES} ${LLMATH_LIBRARIES} ${LLCOREHTTP_LIBRARIES} - ${LLCOMMON_LIBRARIES} ${LIBRT_LIBRARY} + ${LLCOMMON_LIBRARIES} ${BOOST_CONTEXT_LIBRARY} ${BOOST_COROUTINE_LIBRARY} ${UI_LIBRARIES} -- cgit v1.2.3 From ef1b709c99c9fc496bb127be749fababdf9c3bb3 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 30 Apr 2015 15:21:49 -0700 Subject: Fix to linux link Put timeout back into crashlogger post. --- indra/linux_crash_logger/CMakeLists.txt | 2 +- indra/llcrashlogger/llcrashlogger.cpp | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'indra') diff --git a/indra/linux_crash_logger/CMakeLists.txt b/indra/linux_crash_logger/CMakeLists.txt index 480a55a709..3db83f9d29 100755 --- a/indra/linux_crash_logger/CMakeLists.txt +++ b/indra/linux_crash_logger/CMakeLists.txt @@ -61,6 +61,7 @@ set(LIBRT_LIBRARY rt) target_link_libraries(linux-crash-logger + ${LIBRT_LIBRARY} ${LLCRASHLOGGER_LIBRARIES} ${LLVFS_LIBRARIES} ${LLXML_LIBRARIES} @@ -68,7 +69,6 @@ target_link_libraries(linux-crash-logger ${LLVFS_LIBRARIES} ${LLMATH_LIBRARIES} ${LLCOREHTTP_LIBRARIES} - ${LIBRT_LIBRARY} ${LLCOMMON_LIBRARIES} ${BOOST_CONTEXT_LIBRARY} ${BOOST_COROUTINE_LIBRARY} diff --git a/indra/llcrashlogger/llcrashlogger.cpp b/indra/llcrashlogger/llcrashlogger.cpp index ec794ac478..90f70c0d1c 100755 --- a/indra/llcrashlogger/llcrashlogger.cpp +++ b/indra/llcrashlogger/llcrashlogger.cpp @@ -396,20 +396,23 @@ bool LLCrashLogger::saveCrashBehaviorSetting(S32 crash_behavior) bool LLCrashLogger::runCrashLogPost(std::string host, LLSD data, std::string msg, int retries, int timeout) { - LLCore::HttpRequest httpRequest; + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions, false); gBreak = false; + httpOpts->setTimeout(timeout); + for(int i = 0; i < retries; ++i) { updateApplication(llformat("%s, try %d...", msg.c_str(), i+1)); - LLCoreHttpUtil::requestPostWithLLSD(&httpRequest, LLCore::HttpRequest::DEFAULT_POLICY_ID, 0, - host, data, NULL, NULL, new LLCrashLoggerHandler); + LLCoreHttpUtil::requestPostWithLLSD(httpRequest.get(), LLCore::HttpRequest::DEFAULT_POLICY_ID, 0, + host, data, httpOpts.get(), NULL, new LLCrashLoggerHandler); while(!gBreak) { updateApplication(); // No new message, just pump the IO - httpRequest.update(0L); + httpRequest->update(0L); } if(gSent) { -- cgit v1.2.3 From 0b76b318db8bd3233595fb4164fd2e38a3d4553f Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 30 Apr 2015 15:45:04 -0700 Subject: Move librt. --- indra/linux_crash_logger/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/linux_crash_logger/CMakeLists.txt b/indra/linux_crash_logger/CMakeLists.txt index 3db83f9d29..44dddd0034 100755 --- a/indra/linux_crash_logger/CMakeLists.txt +++ b/indra/linux_crash_logger/CMakeLists.txt @@ -61,7 +61,6 @@ set(LIBRT_LIBRARY rt) target_link_libraries(linux-crash-logger - ${LIBRT_LIBRARY} ${LLCRASHLOGGER_LIBRARIES} ${LLVFS_LIBRARIES} ${LLXML_LIBRARIES} @@ -75,6 +74,7 @@ target_link_libraries(linux-crash-logger ${UI_LIBRARIES} ${DB_LIBRARIES} ${FREETYPE_LIBRARIES} + ${LIBRT_LIBRARY} ) add_custom_target(linux-crash-logger-target ALL -- cgit v1.2.3 From 3abd8eaee82b4823fc20861fe520f4f54a3f10cc Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 1 May 2015 14:38:57 -0700 Subject: Move remote parcel request to a coro in LLRemoteParcelInfoProcessor Fix typo in twitter. Disable unit test for remote parcel info request until test infrastructure for new core is done. --- indra/newview/CMakeLists.txt | 2 +- indra/newview/llfloaterscriptlimits.cpp | 13 +-- indra/newview/llpanellandmarks.cpp | 13 +-- indra/newview/llpanelplaceinfo.cpp | 13 +-- indra/newview/llremoteparcelrequest.cpp | 107 +++++++++++++-------- indra/newview/llremoteparcelrequest.h | 23 ++--- indra/newview/lltwitterconnect.cpp | 2 +- indra/newview/tests/llremoteparcelrequest_test.cpp | 2 + 8 files changed, 82 insertions(+), 93 deletions(-) (limited to 'indra') diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index c9bcd17d96..5defc2b16e 100755 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -2220,7 +2220,7 @@ if (LL_TESTS) lldateutil.cpp # llmediadataclient.cpp lllogininstance.cpp - llremoteparcelrequest.cpp +# llremoteparcelrequest.cpp lltranslate.cpp llviewerhelputil.cpp llversioninfo.cpp diff --git a/indra/newview/llfloaterscriptlimits.cpp b/indra/newview/llfloaterscriptlimits.cpp index 5fbdd75e97..166ef5ed7a 100755 --- a/indra/newview/llfloaterscriptlimits.cpp +++ b/indra/newview/llfloaterscriptlimits.cpp @@ -935,17 +935,8 @@ BOOL LLPanelScriptLimitsRegionMemory::StartRequestChain() std::string url = region->getCapability("RemoteParcelRequest"); if (!url.empty()) { - body["location"] = ll_sd_from_vector3(parcel_center); - if (!region_id.isNull()) - { - body["region_id"] = region_id; - } - if (!pos_global.isExactlyZero()) - { - U64 region_handle = to_region_handle(pos_global); - body["region_handle"] = ll_sd_from_U64(region_handle); - } - LLHTTPClient::post(url, body, new LLRemoteParcelRequestResponder(getObserverHandle())); + LLRemoteParcelInfoProcessor::getInstance()->requestRegionParcelInfo(url, + region_id, parcel_center, pos_global, getObserverHandle()); } else { diff --git a/indra/newview/llpanellandmarks.cpp b/indra/newview/llpanellandmarks.cpp index 1d73d4bd6e..cd1dc0f070 100755 --- a/indra/newview/llpanellandmarks.cpp +++ b/indra/newview/llpanellandmarks.cpp @@ -1352,17 +1352,8 @@ void LLLandmarksPanel::doCreatePick(LLLandmark* landmark) std::string url = region->getCapability("RemoteParcelRequest"); if (!url.empty()) { - body["location"] = ll_sd_from_vector3(region_pos); - if (!region_id.isNull()) - { - body["region_id"] = region_id; - } - if (!pos_global.isExactlyZero()) - { - U64 region_handle = to_region_handle(pos_global); - body["region_handle"] = ll_sd_from_U64(region_handle); - } - LLHTTPClient::post(url, body, new LLRemoteParcelRequestResponder(getObserverHandle())); + LLRemoteParcelInfoProcessor::getInstance()->requestRegionParcelInfo(url, + region_id, region_pos, pos_global, getObserverHandle()); } else { diff --git a/indra/newview/llpanelplaceinfo.cpp b/indra/newview/llpanelplaceinfo.cpp index e62b5a4f1d..9725e7f5fe 100755 --- a/indra/newview/llpanelplaceinfo.cpp +++ b/indra/newview/llpanelplaceinfo.cpp @@ -150,17 +150,8 @@ void LLPanelPlaceInfo::displayParcelInfo(const LLUUID& region_id, std::string url = region->getCapability("RemoteParcelRequest"); if (!url.empty()) { - body["location"] = ll_sd_from_vector3(mPosRegion); - if (!region_id.isNull()) - { - body["region_id"] = region_id; - } - if (!pos_global.isExactlyZero()) - { - U64 region_handle = to_region_handle(pos_global); - body["region_handle"] = ll_sd_from_U64(region_handle); - } - LLHTTPClient::post(url, body, new LLRemoteParcelRequestResponder(getObserverHandle())); + LLRemoteParcelInfoProcessor::getInstance()->requestRegionParcelInfo(url, + region_id, mPosRegion, pos_global, getObserverHandle()); } else { diff --git a/indra/newview/llremoteparcelrequest.cpp b/indra/newview/llremoteparcelrequest.cpp index 29dcc12f9e..149277a3a9 100755 --- a/indra/newview/llremoteparcelrequest.cpp +++ b/indra/newview/llremoteparcelrequest.cpp @@ -36,50 +36,12 @@ #include "llurlentry.h" #include "llviewerregion.h" #include "llview.h" - +#include "llsdutil.h" +#include "llsdutil_math.h" +#include "llregionhandle.h" #include "llagent.h" #include "llremoteparcelrequest.h" - - -LLRemoteParcelRequestResponder::LLRemoteParcelRequestResponder(LLHandle observer_handle) - : mObserverHandle(observer_handle) -{} - -//If we get back a normal response, handle it here -//virtual -void LLRemoteParcelRequestResponder::httpSuccess() -{ - const LLSD& content = getContent(); - if (!content.isMap() || !content.has("parcel_id")) - { - failureResult(HTTP_INTERNAL_ERROR, "Malformed response contents", content); - return; - } - LLUUID parcel_id = getContent()["parcel_id"]; - - // Panel inspecting the information may be closed and destroyed - // before this response is received. - LLRemoteParcelInfoObserver* observer = mObserverHandle.get(); - if (observer) - { - observer->setParcelID(parcel_id); - } -} - -//If we get back an error (not found, etc...), handle it here -//virtual -void LLRemoteParcelRequestResponder::httpFailure() -{ - LL_WARNS() << dumpResponse() << LL_ENDL; - - // Panel inspecting the information may be closed and destroyed - // before this response is received. - LLRemoteParcelInfoObserver* observer = mObserverHandle.get(); - if (observer) - { - observer->setErrorStatus(getStatus(), getReason()); - } -} +#include "llcorehttputil.h" void LLRemoteParcelInfoProcessor::addObserver(const LLUUID& parcel_id, LLRemoteParcelInfoObserver* observer) { @@ -200,3 +162,64 @@ void LLRemoteParcelInfoProcessor::sendParcelInfoRequest(const LLUUID& parcel_id) msg->addUUID("ParcelID", parcel_id); gAgent.sendReliableMessage(); } + +bool LLRemoteParcelInfoProcessor::requestRegionParcelInfo(const std::string &url, + const LLUUID ®ionId, const LLVector3 ®ionPos, const LLVector3d&globalPos, + LLHandle observerHandle) +{ + + if (!url.empty()) + { + LLCoros::instance().launch("LLRemoteParcelInfoProcessor::regionParcelInfoCoro", + boost::bind(&LLRemoteParcelInfoProcessor::regionParcelInfoCoro, this, _1, url, + regionId, regionPos, globalPos, observerHandle)); + return true; + } + + return false; +} + +void LLRemoteParcelInfoProcessor::regionParcelInfoCoro(LLCoros::self& self, std::string url, + LLUUID regionId, LLVector3 posRegion, LLVector3d posGlobal, + LLHandle observerHandle) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("RemoteParcelRequest", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + + LLSD bodyData; + + bodyData["location"] = ll_sd_from_vector3(posRegion); + if (!regionId.isNull()) + { + bodyData["region_id"] = regionId; + } + if (!posGlobal.isExactlyZero()) + { + U64 regionHandle = to_region_handle(posGlobal); + bodyData["region_handle"] = ll_sd_from_U64(regionHandle); + } + + LLSD result = httpAdapter->postAndYield(self, httpRequest, url, bodyData); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + + LLRemoteParcelInfoObserver* observer = observerHandle.get(); + // Panel inspecting the information may be closed and destroyed + // before this response is received. + if (!observer) + return; + + if (!status) + { + observer->setErrorStatus(status.getStatus(), status.getMessage()); + } + else + { + LLUUID parcel_id = result["parcel_id"]; + observer->setParcelID(parcel_id); + } + +} diff --git a/indra/newview/llremoteparcelrequest.h b/indra/newview/llremoteparcelrequest.h index 35348b69ff..75819174c4 100755 --- a/indra/newview/llremoteparcelrequest.h +++ b/indra/newview/llremoteparcelrequest.h @@ -32,26 +32,12 @@ #include "llhttpclient.h" #include "llhandle.h" #include "llsingleton.h" +#include "llcoros.h" +#include "lleventcoro.h" class LLMessageSystem; class LLRemoteParcelInfoObserver; -class LLRemoteParcelRequestResponder : public LLHTTPClient::Responder -{ - LOG_CLASS(LLRemoteParcelRequestResponder); -public: - LLRemoteParcelRequestResponder(LLHandle observer_handle); - -private: - //If we get back a normal response, handle it here - /*virtual*/ void httpSuccess(); - - //If we get back an error (not found, etc...), handle it here - /*virtual*/ void httpFailure(); - - LLHandle mObserverHandle; -}; - struct LLParcelData { LLUUID parcel_id; @@ -99,9 +85,14 @@ public: static void processParcelInfoReply(LLMessageSystem* msg, void**); + bool requestRegionParcelInfo(const std::string &url, const LLUUID ®ionId, + const LLVector3 ®ionPos, const LLVector3d& globalPos, LLHandle observerHandle); + private: typedef std::multimap > observer_multimap_t; observer_multimap_t mObservers; + + void regionParcelInfoCoro(LLCoros::self& self, std::string url, LLUUID regionId, LLVector3 posRegion, LLVector3d posGlobal, LLHandle observerHandle); }; #endif // LL_LLREMOTEPARCELREQUEST_H diff --git a/indra/newview/lltwitterconnect.cpp b/indra/newview/lltwitterconnect.cpp index cc608fbc2f..66a63510b0 100644 --- a/indra/newview/lltwitterconnect.cpp +++ b/indra/newview/lltwitterconnect.cpp @@ -416,7 +416,7 @@ std::string LLTwitterConnect::getTwitterConnectURL(const std::string& route, boo void LLTwitterConnect::connectToTwitter(const std::string& request_token, const std::string& oauth_verifier) { - LLCoros::instance().launch("LLFlickrConnect::flickrConnectCoro", + LLCoros::instance().launch("LLTwitterConnect::twitterConnectCoro", boost::bind(&LLTwitterConnect::twitterConnectCoro, this, _1, request_token, oauth_verifier)); } diff --git a/indra/newview/tests/llremoteparcelrequest_test.cpp b/indra/newview/tests/llremoteparcelrequest_test.cpp index c49b0350e9..ea5014a59c 100755 --- a/indra/newview/tests/llremoteparcelrequest_test.cpp +++ b/indra/newview/tests/llremoteparcelrequest_test.cpp @@ -27,6 +27,7 @@ #include "linden_common.h" #include "../test/lltut.h" +#if 0 #include "../llremoteparcelrequest.h" @@ -134,3 +135,4 @@ namespace tut processor.processParcelInfoReply(gMessageSystem, NULL); } } +#endif -- cgit v1.2.3 From 8d9282fca16d6118bc484b97fa905bcc616e0b9e Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 8 May 2015 15:00:32 -0700 Subject: Updated llfloatermodeluploadbase to LLCore::Http --- indra/newview/CMakeLists.txt | 1 - indra/newview/llfloatermodeluploadbase.cpp | 35 ++++++++++++++++- indra/newview/llfloatermodeluploadbase.h | 4 ++ indra/newview/lluploadfloaterobservers.cpp | 63 ------------------------------ indra/newview/lluploadfloaterobservers.h | 14 ------- 5 files changed, 38 insertions(+), 79 deletions(-) delete mode 100755 indra/newview/lluploadfloaterobservers.cpp (limited to 'indra') diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 5defc2b16e..628c47b92a 100755 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -594,7 +594,6 @@ set(viewer_SOURCE_FILES lltwitterconnect.cpp lluilistener.cpp lluploaddialog.cpp - lluploadfloaterobservers.cpp llurl.cpp llurldispatcher.cpp llurldispatcherlistener.cpp diff --git a/indra/newview/llfloatermodeluploadbase.cpp b/indra/newview/llfloatermodeluploadbase.cpp index 22a8ac4705..efc8fae768 100755 --- a/indra/newview/llfloatermodeluploadbase.cpp +++ b/indra/newview/llfloatermodeluploadbase.cpp @@ -30,6 +30,7 @@ #include "llagent.h" #include "llviewerregion.h" #include "llnotificationsutil.h" +#include "llcorehttputil.h" LLFloaterModelUploadBase::LLFloaterModelUploadBase(const LLSD& key) :LLFloater(key), @@ -47,7 +48,8 @@ void LLFloaterModelUploadBase::requestAgentUploadPermissions() LL_INFOS()<< typeid(*this).name() << "::requestAgentUploadPermissions() requesting for upload model permissions from: " << url << LL_ENDL; - LLHTTPClient::get(url, new LLUploadModelPermissionsResponder(getPermObserverHandle())); + LLCoros::instance().launch("LLFloaterModelUploadBase::requestAgentUploadPermissionsCoro", + boost::bind(&LLFloaterModelUploadBase::requestAgentUploadPermissionsCoro, this, _1, url, getPermObserverHandle())); } else { @@ -58,3 +60,34 @@ void LLFloaterModelUploadBase::requestAgentUploadPermissions() mHasUploadPerm = true; } } + +void LLFloaterModelUploadBase::requestAgentUploadPermissionsCoro(LLCoros::self& self, std::string url, + LLHandle observerHandle) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("MeshUploadFlag", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + + + LLSD result = httpAdapter->getAndYield(self, httpRequest, url); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + + LLUploadPermissionsObserver* observer = observerHandle.get(); + + if (!observer) + { + LL_WARNS("MeshUploadFlag") << "Unable to get observer after call to '" << url << "' aborting." << LL_ENDL; + } + + if (!status) + { + observer->setPermissonsErrorStatus(status.getStatus(), status.getMessage()); + return; + } + + result.erase(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS); + observer->onPermissionsReceived(result); +} \ No newline at end of file diff --git a/indra/newview/llfloatermodeluploadbase.h b/indra/newview/llfloatermodeluploadbase.h index d9a8879687..9bb9959af0 100755 --- a/indra/newview/llfloatermodeluploadbase.h +++ b/indra/newview/llfloatermodeluploadbase.h @@ -28,6 +28,8 @@ #define LL_LLFLOATERMODELUPLOADBASE_H #include "lluploadfloaterobservers.h" +#include "llcoros.h" +#include "lleventcoro.h" class LLFloaterModelUploadBase : public LLFloater, public LLUploadPermissionsObserver, public LLWholeModelFeeObserver, public LLWholeModelUploadObserver { @@ -54,6 +56,8 @@ protected: // requests agent's permissions to upload model void requestAgentUploadPermissions(); + void requestAgentUploadPermissionsCoro(LLCoros::self& self, std::string url, LLHandle observerHandle); + std::string mUploadModelUrl; bool mHasUploadPerm; }; diff --git a/indra/newview/lluploadfloaterobservers.cpp b/indra/newview/lluploadfloaterobservers.cpp deleted file mode 100755 index 69b9b1f9f1..0000000000 --- a/indra/newview/lluploadfloaterobservers.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/** - * @file lluploadfloaterobservers.cpp - * @brief LLUploadModelPermissionsResponder definition - * - * $LicenseInfo:firstyear=2011&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2011, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#include "llviewerprecompiledheaders.h" - -#include "lluploadfloaterobservers.h" - -LLUploadModelPermissionsResponder::LLUploadModelPermissionsResponder(const LLHandle& observer) -:mObserverHandle(observer) -{ -} - -void LLUploadModelPermissionsResponder::httpFailure() -{ - LL_WARNS() << dumpResponse() << LL_ENDL; - - LLUploadPermissionsObserver* observer = mObserverHandle.get(); - - if (observer) - { - observer->setPermissonsErrorStatus(getStatus(), getReason()); - } -} - -void LLUploadModelPermissionsResponder::httpSuccess() -{ - const LLSD& content = getContent(); - if (!content.isMap()) - { - failureResult(HTTP_INTERNAL_ERROR, "Malformed response contents", content); - return; - } - LLUploadPermissionsObserver* observer = mObserverHandle.get(); - - if (observer) - { - observer->onPermissionsReceived(content); - } -} - diff --git a/indra/newview/lluploadfloaterobservers.h b/indra/newview/lluploadfloaterobservers.h index 4ff4a827a5..02baf8f1c0 100755 --- a/indra/newview/lluploadfloaterobservers.h +++ b/indra/newview/lluploadfloaterobservers.h @@ -79,18 +79,4 @@ protected: LLRootHandle mWholeModelUploadObserverHandle; }; - -class LLUploadModelPermissionsResponder : public LLHTTPClient::Responder -{ - LOG_CLASS(LLUploadModelPermissionsResponder); -public: - LLUploadModelPermissionsResponder(const LLHandle& observer); - -private: - /* virtual */ void httpSuccess(); - /* virtual */ void httpFailure(); - - LLHandle mObserverHandle; -}; - #endif /* LL_LLUPLOADFLOATEROBSERVERS_H */ -- cgit v1.2.3 From 6cba35d3c0a07843fe1254448fc122ecd3854424 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 8 May 2015 16:15:27 -0700 Subject: Updated llestateinfomodel --- indra/newview/llestateinfomodel.cpp | 82 ++++++++++++++++++++----------------- indra/newview/llestateinfomodel.h | 5 ++- 2 files changed, 49 insertions(+), 38 deletions(-) (limited to 'indra') diff --git a/indra/newview/llestateinfomodel.cpp b/indra/newview/llestateinfomodel.cpp index 78d619a315..152c17eb0f 100755 --- a/indra/newview/llestateinfomodel.cpp +++ b/indra/newview/llestateinfomodel.cpp @@ -38,6 +38,8 @@ #include "llfloaterregioninfo.h" // for invoice id #include "llviewerregion.h" +#include "llcorehttputil.h" + LLEstateInfoModel::LLEstateInfoModel() : mID(0) , mFlags(0) @@ -110,24 +112,6 @@ void LLEstateInfoModel::notifyCommit() //== PRIVATE STUFF ============================================================ -class LLEstateChangeInfoResponder : public LLHTTPClient::Responder -{ - LOG_CLASS(LLEstateChangeInfoResponder); -protected: - // if we get a normal response, handle it here - virtual void httpSuccesss() - { - LL_INFOS() << "Committed estate info" << LL_ENDL; - LLEstateInfoModel::instance().notifyCommit(); - } - - // if we get an error response - virtual void httpFailure() - { - LL_WARNS() << "Failed to commit estate info " << dumpResponse() << LL_ENDL; - } -}; - // tries to send estate info using a cap; returns true if it succeeded bool LLEstateInfoModel::commitEstateInfoCaps() { @@ -139,29 +123,53 @@ bool LLEstateInfoModel::commitEstateInfoCaps() return false; } - LLSD body; - body["estate_name" ] = getName(); - body["sun_hour" ] = getSunHour(); + LLCoros::instance().launch("LLEstateInfoModel::commitEstateInfoCapsCoro", + boost::bind(&LLEstateInfoModel::commitEstateInfoCapsCoro, this, _1, url)); - body["is_sun_fixed" ] = getUseFixedSun(); - body["is_externally_visible"] = getIsExternallyVisible(); - body["allow_direct_teleport"] = getAllowDirectTeleport(); - body["deny_anonymous" ] = getDenyAnonymous(); - body["deny_age_unverified" ] = getDenyAgeUnverified(); - body["allow_voice_chat" ] = getAllowVoiceChat(); - - body["invoice" ] = LLFloaterRegionInfo::getLastInvoice(); - - LL_DEBUGS("Windlight Sync") << "Sending estate caps: " - << "is_sun_fixed = " << getUseFixedSun() - << ", sun_hour = " << getSunHour() << LL_ENDL; - LL_DEBUGS() << body << LL_ENDL; - - // we use a responder so that we can re-get the data after committing to the database - LLHTTPClient::post(url, body, new LLEstateChangeInfoResponder); return true; } +void LLEstateInfoModel::commitEstateInfoCapsCoro(LLCoros::self& self, std::string url) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("EstateChangeInfo", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + + LLSD body; + body["estate_name"] = getName(); + body["sun_hour"] = getSunHour(); + + body["is_sun_fixed"] = getUseFixedSun(); + body["is_externally_visible"] = getIsExternallyVisible(); + body["allow_direct_teleport"] = getAllowDirectTeleport(); + body["deny_anonymous"] = getDenyAnonymous(); + body["deny_age_unverified"] = getDenyAgeUnverified(); + body["allow_voice_chat"] = getAllowVoiceChat(); + + body["invoice"] = LLFloaterRegionInfo::getLastInvoice(); + + LL_DEBUGS("Windlight Sync") << "Sending estate caps: " + << "is_sun_fixed = " << getUseFixedSun() + << ", sun_hour = " << getSunHour() << LL_ENDL; + LL_DEBUGS() << body << LL_ENDL; + + LLSD result = httpAdapter->postAndYield(self, httpRequest, url, body); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + + if (status) + { + LL_INFOS() << "Committed estate info" << LL_ENDL; + LLEstateInfoModel::instance().notifyCommit(); + } + else + { + LL_WARNS() << "Failed to commit estate info " << LL_ENDL; + } +} + /* This is the old way of doing things, is deprecated, and should be deleted when the dataserver model can be removed */ // key = "estatechangeinfo" diff --git a/indra/newview/llestateinfomodel.h b/indra/newview/llestateinfomodel.h index 538f2f7c75..2deae7e322 100755 --- a/indra/newview/llestateinfomodel.h +++ b/indra/newview/llestateinfomodel.h @@ -30,6 +30,8 @@ class LLMessageSystem; #include "llsingleton.h" +#include "llcoros.h" +#include "lleventcoro.h" /** * Contains estate info, notifies interested parties of its changes. @@ -73,7 +75,6 @@ protected: friend class LLSingleton; friend class LLDispatchEstateUpdateInfo; - friend class LLEstateChangeInfoResponder; LLEstateInfoModel(); @@ -99,6 +100,8 @@ private: update_signal_t mUpdateSignal; /// emitted when we receive update from sim update_signal_t mCommitSignal; /// emitted when our update gets applied to sim + + void commitEstateInfoCapsCoro(LLCoros::self& self, std::string url); }; inline bool LLEstateInfoModel::getFlag(U64 flag) const -- cgit v1.2.3 From 7ec58ee04789a8cc819d1151529d843045651bc8 Mon Sep 17 00:00:00 2001 From: Bjoseph Wombat Date: Mon, 11 May 2015 04:49:12 +0100 Subject: Added application identifier and testing a bug for for group and P2P calling --- indra/newview/llvoicevivox.cpp | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) (limited to 'indra') diff --git a/indra/newview/llvoicevivox.cpp b/indra/newview/llvoicevivox.cpp index 6ac8d84771..5e92d3f340 100755 --- a/indra/newview/llvoicevivox.cpp +++ b/indra/newview/llvoicevivox.cpp @@ -60,6 +60,7 @@ #include "lltrans.h" #include "llviewerwindow.h" #include "llviewercamera.h" +#include "llversioninfo.h" #include "llviewernetwork.h" #include "llnotificationsutil.h" @@ -506,7 +507,8 @@ void LLVivoxVoiceClient::connectorCreate() << ".log" << "" << loglevel << "" << "" - << "" //Name can cause problems per vivox. + << "" << LLVersionInfo::getChannel().c_str() << " " << LLVersionInfo::getVersion().c_str() << "" + //<< "" //Name can cause problems per vivox. << "12" << "\n\n\n"; @@ -1761,21 +1763,31 @@ void LLVivoxVoiceClient::sessionCreateSendMessage(sessionState *session, bool st LL_DEBUGS("Voice") << "With voice font: " << session->mVoiceFontID << " (" << font_index << ")" << LL_ENDL; session->mCreateInProgress = true; - if(startAudio) + if (startAudio) { session->mMediaConnectInProgress = true; } std::ostringstream stream; - stream - << "mSIPURI << "\" action=\"Session.Create.1\">" - << "" << mAccountHandle << "" - << "" << session->mSIPURI << ""; + + if (!session->mGroupHandle.empty()) { + // reuse the current session group + stream + << "mSIPURI << "\" action=\"SessionGroup.AddSession.1\">" + << "" << session->mGroupHandle << ""; + } + else { + stream + << "mSIPURI << "\" action=\"Session.Create.1\">" + << "" << mAccountHandle << ""; + } + + stream << "" << session->mSIPURI << ""; static const std::string allowed_chars = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" - "0123456789" - "-._~"; + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" + "0123456789" + "-._~"; if(!session->mHash.empty()) { @@ -2523,6 +2535,7 @@ void LLVivoxVoiceClient::sendPositionalUpdate(void) stream << ""; + stream << "1"; //do not generate responses for update requests stream << "\n\n\n"; } @@ -3072,11 +3085,12 @@ void LLVivoxVoiceClient::reapSession(sessionState *session) { if(session) { - if(!session->mHandle.empty()) +/* if(!session->mHandle.empty()) { LL_DEBUGS("Voice") << "NOT deleting session " << session->mSIPURI << " (non-null session handle)" << LL_ENDL; } - else if(session->mCreateInProgress) + else*/ + if(session->mCreateInProgress) { LL_DEBUGS("Voice") << "NOT deleting session " << session->mSIPURI << " (create in progress)" << LL_ENDL; } -- cgit v1.2.3 From bb43a5226b3136317bb13b7d4f4116d0e68d5bb4 Mon Sep 17 00:00:00 2001 From: Bjoseph Wombat Date: Mon, 11 May 2015 10:23:29 -0400 Subject: Backed out changeset: 5eee69247775 --- indra/newview/llvoicevivox.cpp | 36 +++++++++++------------------------- 1 file changed, 11 insertions(+), 25 deletions(-) (limited to 'indra') diff --git a/indra/newview/llvoicevivox.cpp b/indra/newview/llvoicevivox.cpp index 5e92d3f340..6ac8d84771 100755 --- a/indra/newview/llvoicevivox.cpp +++ b/indra/newview/llvoicevivox.cpp @@ -60,7 +60,6 @@ #include "lltrans.h" #include "llviewerwindow.h" #include "llviewercamera.h" -#include "llversioninfo.h" #include "llviewernetwork.h" #include "llnotificationsutil.h" @@ -507,8 +506,7 @@ void LLVivoxVoiceClient::connectorCreate() << ".log" << "" << loglevel << "" << "" - << "" << LLVersionInfo::getChannel().c_str() << " " << LLVersionInfo::getVersion().c_str() << "" - //<< "" //Name can cause problems per vivox. + << "" //Name can cause problems per vivox. << "12" << "\n\n\n"; @@ -1763,31 +1761,21 @@ void LLVivoxVoiceClient::sessionCreateSendMessage(sessionState *session, bool st LL_DEBUGS("Voice") << "With voice font: " << session->mVoiceFontID << " (" << font_index << ")" << LL_ENDL; session->mCreateInProgress = true; - if (startAudio) + if(startAudio) { session->mMediaConnectInProgress = true; } std::ostringstream stream; - - if (!session->mGroupHandle.empty()) { - // reuse the current session group - stream - << "mSIPURI << "\" action=\"SessionGroup.AddSession.1\">" - << "" << session->mGroupHandle << ""; - } - else { - stream - << "mSIPURI << "\" action=\"Session.Create.1\">" - << "" << mAccountHandle << ""; - } - - stream << "" << session->mSIPURI << ""; + stream + << "mSIPURI << "\" action=\"Session.Create.1\">" + << "" << mAccountHandle << "" + << "" << session->mSIPURI << ""; static const std::string allowed_chars = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" - "0123456789" - "-._~"; + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" + "0123456789" + "-._~"; if(!session->mHash.empty()) { @@ -2535,7 +2523,6 @@ void LLVivoxVoiceClient::sendPositionalUpdate(void) stream << ""; - stream << "1"; //do not generate responses for update requests stream << "\n\n\n"; } @@ -3085,12 +3072,11 @@ void LLVivoxVoiceClient::reapSession(sessionState *session) { if(session) { -/* if(!session->mHandle.empty()) + if(!session->mHandle.empty()) { LL_DEBUGS("Voice") << "NOT deleting session " << session->mSIPURI << " (non-null session handle)" << LL_ENDL; } - else*/ - if(session->mCreateInProgress) + else if(session->mCreateInProgress) { LL_DEBUGS("Voice") << "NOT deleting session " << session->mSIPURI << " (create in progress)" << LL_ENDL; } -- cgit v1.2.3 From bb3763ca84981139bbdb9291757946a95198ce55 Mon Sep 17 00:00:00 2001 From: Bjoseph Wombat Date: Mon, 11 May 2015 16:29:00 +0100 Subject: Application name added to connector create and a test fix for a race conition in group and P2P calling. --- indra/newview/llvoicevivox.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'indra') diff --git a/indra/newview/llvoicevivox.cpp b/indra/newview/llvoicevivox.cpp index 6ac8d84771..5d1e5327ad 100755 --- a/indra/newview/llvoicevivox.cpp +++ b/indra/newview/llvoicevivox.cpp @@ -60,6 +60,7 @@ #include "lltrans.h" #include "llviewerwindow.h" #include "llviewercamera.h" +#include "llversioninfo.h" #include "llviewernetwork.h" #include "llnotificationsutil.h" @@ -501,14 +502,15 @@ void LLVivoxVoiceClient::connectorCreate() << "" << mVoiceAccountServerURI << "" << "Normal" << "" - << "" << logpath << "" - << "Connector" - << ".log" - << "" << loglevel << "" + << "" << logpath << "" + << "Connector" + << ".log" + << "" << loglevel << "" << "" - << "" //Name can cause problems per vivox. - << "12" - << "\n\n\n"; + << "" << LLVersionInfo::getChannel().c_str() << " " << LLVersionInfo::getVersion().c_str() << "" + //<< "" //Name can cause problems per vivox. + << "12" + << "\n\n\n"; writeString(stream.str()); } @@ -2523,6 +2525,7 @@ void LLVivoxVoiceClient::sendPositionalUpdate(void) stream << ""; + stream << "1"; //do not generate responses for update requests stream << "\n\n\n"; } @@ -3072,11 +3075,12 @@ void LLVivoxVoiceClient::reapSession(sessionState *session) { if(session) { - if(!session->mHandle.empty()) + /*if(!session->mHandle.empty()) { LL_DEBUGS("Voice") << "NOT deleting session " << session->mSIPURI << " (non-null session handle)" << LL_ENDL; } - else if(session->mCreateInProgress) + else*/ + if(session->mCreateInProgress) { LL_DEBUGS("Voice") << "NOT deleting session " << session->mSIPURI << " (create in progress)" << LL_ENDL; } -- cgit v1.2.3 From 3e004ce66e1fa07421c138a20eb0dba61c5b26b3 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 11 May 2015 16:52:02 -0700 Subject: Updated feature manager downloader to coroutine. Added "raw" coroutine handler (returns raw result as LLSD::Binary) and split out the guts of the get, put, etc methods. Moved getStatusFromLLSD from HttpCoroHandler into HttpCorutineAdapter --- indra/llmessage/llcorehttputil.cpp | 303 ++++++++++++++++++------- indra/llmessage/llcorehttputil.h | 70 ++++-- indra/newview/llavatarrenderinfoaccountant.cpp | 4 +- indra/newview/llestateinfomodel.cpp | 2 +- indra/newview/lleventpoll.cpp | 2 +- indra/newview/llfacebookconnect.cpp | 12 +- indra/newview/llfeaturemanager.cpp | 118 ++++------ indra/newview/llfeaturemanager.h | 3 + indra/newview/llflickrconnect.cpp | 10 +- indra/newview/llfloatermodeluploadbase.cpp | 2 +- indra/newview/llimview.cpp | 4 +- indra/newview/llpathfindingmanager.cpp | 12 +- indra/newview/llremoteparcelrequest.cpp | 2 +- indra/newview/lltwitterconnect.cpp | 10 +- indra/newview/llviewerregion.cpp | 6 +- indra/newview/llwlhandlers.cpp | 4 +- 16 files changed, 360 insertions(+), 204 deletions(-) (limited to 'indra') diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index 1f9d4d15cd..a79bb62bb8 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -28,7 +28,8 @@ #include "linden_common.h" #include - +#include +#include #include "llcorehttputil.h" #include "llhttpconstants.h" #include "llsdserialize.h" @@ -38,9 +39,25 @@ using namespace LLCore; namespace LLCoreHttpUtil { +//========================================================================= +/// The HttpRequestPumper is a utility class. When constructed it will poll the +/// supplied HttpRequest once per frame until it is destroyed. +/// +class HttpRequestPumper +{ +public: + HttpRequestPumper(const LLCore::HttpRequest::ptr_t &request); + ~HttpRequestPumper(); +private: + bool pollRequest(const LLSD&); + LLTempBoundListener mBoundListener; + LLCore::HttpRequest::ptr_t mHttpRequest; +}; + +//========================================================================= // *TODO: Currently converts only from XML content. A mode // to convert using fromBinary() might be useful as well. Mesh // headers could use it. @@ -91,7 +108,6 @@ HttpHandle requestPostWithLLSD(HttpRequest * request, } - HttpHandle requestPutWithLLSD(HttpRequest * request, HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, @@ -191,6 +207,7 @@ std::string responseToString(LLCore::HttpResponse * response) } //======================================================================== + HttpCoroHandler::HttpCoroHandler(LLEventStream &reply) : mReplyPump(reply) { @@ -221,42 +238,7 @@ void HttpCoroHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRespons } else { - const bool emit_parse_errors = false; - - bool parsed = !((response->getBodySize() == 0) || - !LLCoreHttpUtil::responseToLLSD(response, emit_parse_errors, result)); - - if (!parsed) - { - // Only emit a warning if we failed to parse when 'content-type' == 'application/llsd+xml' - LLCore::HttpHeaders::ptr_t headers(response->getHeaders()); - const std::string *contentType = (headers) ? headers->find(HTTP_IN_HEADER_CONTENT_TYPE) : NULL; - - if (contentType && (HTTP_CONTENT_LLSD_XML == *contentType)) - { - std::string thebody = LLCoreHttpUtil::responseToString(response); - LL_WARNS() << "Failed to deserialize . " << response->getRequestURL() << " [status:" << response->getStatus().toString() << "] " - << " body: " << thebody << LL_ENDL; - - // Replace the status with a new one indicating the failure. - status = LLCore::HttpStatus(499, "Failed to deserialize LLSD."); - } - } - - if (result.isUndefined()) - { // If we've gotten to this point and the result LLSD is still undefined - // either there was an issue deserializing the body or the response was - // blank. Create an empty map to hold the result either way. - result = LLSD::emptyMap(); - } - else if (!result.isMap()) - { // The results are not themselves a map. Move them down so that - // this method can return a map to the caller. - // *TODO: Should it always do this? - LLSD newResult = LLSD::emptyMap(); - newResult[HttpCoroutineAdapter::HTTP_RESULTS_CONTENT] = result; - result = newResult; - } + result = this->handleSuccess(response, status); } buildStatusEntry(response, status, result); @@ -301,12 +283,126 @@ void HttpCoroHandler::writeStatusCodes(LLCore::HttpStatus status, const std::str } -LLCore::HttpStatus HttpCoroHandler::getStatusFromLLSD(const LLSD &httpResults) +//========================================================================= +/// The HttpCoroLLSDHandler is a specialization of the LLCore::HttpHandler for +/// interacting with coroutines. When the request is completed the response +/// will be posted onto the supplied Event Pump. +/// +/// The LLSD posted back to the coroutine will have the following additions: +/// llsd["http_result"] -+- ["message"] - An error message returned from the HTTP status +/// +- ["status"] - The status code associated with the HTTP call +/// +- ["success"] - Success of failure of the HTTP call and LLSD parsing. +/// +- ["type"] - The LLCore::HttpStatus type associted with the HTTP call +/// +- ["url"] - The URL used to make the call. +/// +- ["headers"] - A map of name name value pairs with the HTTP headers. +/// +class HttpCoroLLSDHandler : public HttpCoroHandler { - LLCore::HttpStatus::type_enum_t type = static_cast(httpResults[HttpCoroutineAdapter::HTTP_RESULTS_TYPE].asInteger()); - short code = static_cast(httpResults[HttpCoroutineAdapter::HTTP_RESULTS_STATUS].asInteger()); +public: + HttpCoroLLSDHandler(LLEventStream &reply); - return LLCore::HttpStatus(type, code); +protected: + virtual LLSD handleSuccess(LLCore::HttpResponse * response, LLCore::HttpStatus &status); +}; + +//------------------------------------------------------------------------- +HttpCoroLLSDHandler::HttpCoroLLSDHandler(LLEventStream &reply): + HttpCoroHandler(reply) +{ +} + + +LLSD HttpCoroLLSDHandler::handleSuccess(LLCore::HttpResponse * response, LLCore::HttpStatus &status) +{ + LLSD result; + + const bool emit_parse_errors = false; + + bool parsed = !((response->getBodySize() == 0) || + !LLCoreHttpUtil::responseToLLSD(response, emit_parse_errors, result)); + + if (!parsed) + { + // Only emit a warning if we failed to parse when 'content-type' == 'application/llsd+xml' + LLCore::HttpHeaders::ptr_t headers(response->getHeaders()); + const std::string *contentType = (headers) ? headers->find(HTTP_IN_HEADER_CONTENT_TYPE) : NULL; + + if (contentType && (HTTP_CONTENT_LLSD_XML == *contentType)) + { + std::string thebody = LLCoreHttpUtil::responseToString(response); + LL_WARNS() << "Failed to deserialize . " << response->getRequestURL() << " [status:" << response->getStatus().toString() << "] " + << " body: " << thebody << LL_ENDL; + + // Replace the status with a new one indicating the failure. + status = LLCore::HttpStatus(499, "Failed to deserialize LLSD."); + } + } + + if (result.isUndefined()) + { // If we've gotten to this point and the result LLSD is still undefined + // either there was an issue deserializing the body or the response was + // blank. Create an empty map to hold the result either way. + result = LLSD::emptyMap(); + } + else if (!result.isMap()) + { // The results are not themselves a map. Move them down so that + // this method can return a map to the caller. + // *TODO: Should it always do this? + LLSD newResult = LLSD::emptyMap(); + newResult[HttpCoroutineAdapter::HTTP_RESULTS_CONTENT] = result; + result = newResult; + } + + return result; +} + +//======================================================================== +/// The HttpCoroRawHandler is a specialization of the LLCore::HttpHandler for +/// interacting with coroutines. +/// +/// In addition to the normal "http_results" the returned LLSD will contain +/// an entry keyed with "raw" containing the unprocessed results of the HTTP +/// call. +/// +class HttpCoroRawHandler : public HttpCoroHandler +{ +public: + HttpCoroRawHandler(LLEventStream &reply); + + virtual LLSD handleSuccess(LLCore::HttpResponse * response, LLCore::HttpStatus &status); +}; + +//------------------------------------------------------------------------- +HttpCoroRawHandler::HttpCoroRawHandler(LLEventStream &reply): + HttpCoroHandler(reply) +{ +} + +LLSD HttpCoroRawHandler::handleSuccess(LLCore::HttpResponse * response, LLCore::HttpStatus &status) +{ + LLSD result = LLSD::emptyMap(); + + BufferArray * body(response->getBody()); + if (!body || !body->size()) + { + return result; + } + + size_t size = body->size(); + + LLCore::BufferArrayStream bas(body); + + // We create a new LLSD::Binary object and assign it to the result map. + // The LLSD has created it's own copy so we retrieve it asBinary and const cast + // the reference so that we can modify it. + result[HttpCoroutineAdapter::HTTP_RESULTS_RAW] = LLSD::Binary(); + LLSD::Binary &data = const_cast( result[HttpCoroutineAdapter::HTTP_RESULTS_RAW].asBinary() ); + + data.reserve(size); + bas >> std::noskipws; + data.assign(std::istream_iterator(bas), std::istream_iterator()); + + return result; } //======================================================================== @@ -343,7 +439,7 @@ const std::string HttpCoroutineAdapter::HTTP_RESULTS_MESSAGE("message"); const std::string HttpCoroutineAdapter::HTTP_RESULTS_URL("url"); const std::string HttpCoroutineAdapter::HTTP_RESULTS_HEADERS("headers"); const std::string HttpCoroutineAdapter::HTTP_RESULTS_CONTENT("content"); - +const std::string HttpCoroutineAdapter::HTTP_RESULTS_RAW("raw"); HttpCoroutineAdapter::HttpCoroutineAdapter(const std::string &name, LLCore::HttpRequest::policy_t policyId, LLCore::HttpRequest::priority_t priority) : @@ -366,27 +462,33 @@ LLSD HttpCoroutineAdapter::postAndYield(LLCoros::self & self, LLCore::HttpReques LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { LLEventStream replyPump(mAdapterName, true); - LLCoreHttpUtil::HttpCoroHandler::ptr_t httpHandler = - LLCoreHttpUtil::HttpCoroHandler::ptr_t(new LLCoreHttpUtil::HttpCoroHandler(replyPump)); + HttpCoroHandler::ptr_t httpHandler = HttpCoroHandler::ptr_t(new HttpCoroLLSDHandler(replyPump)); + return postAndYield_(self, request, url, body, options, headers, httpHandler); +} + +LLSD HttpCoroutineAdapter::postAndYield_(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, + const std::string & url, const LLSD & body, + LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, + HttpCoroHandler::ptr_t &handler) +{ //LL_INFOS() << "Requesting transaction " << transactionId << LL_ENDL; - LLCoreHttpUtil::HttpRequestPumper pumper(request); + HttpRequestPumper pumper(request); // The HTTPCoroHandler does not self delete, so retrieval of a the contained // pointer from the smart pointer is safe in this case. LLCore::HttpHandle hhandle = requestPostWithLLSD(request, mPolicyId, mPriority, url, body, options, headers, - httpHandler.get()); + handler.get()); if (hhandle == LLCORE_HTTP_HANDLE_INVALID) { return HttpCoroutineAdapter::buildImmediateErrorResult(request, url); } - saveState(hhandle, request, httpHandler); - LLSD results = waitForEventOn(self, replyPump); + saveState(hhandle, request, handler); + LLSD results = waitForEventOn(self, handler->getReplyPump()); cleanState(); - //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; } @@ -395,23 +497,30 @@ LLSD HttpCoroutineAdapter::postAndYield(LLCoros::self & self, LLCore::HttpReques LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { LLEventStream replyPump(mAdapterName, true); - LLCoreHttpUtil::HttpCoroHandler::ptr_t httpHandler = - LLCoreHttpUtil::HttpCoroHandler::ptr_t(new LLCoreHttpUtil::HttpCoroHandler(replyPump)); + HttpCoroHandler::ptr_t httpHandler = HttpCoroHandler::ptr_t(new HttpCoroLLSDHandler(replyPump)); + + return postAndYield_(self, request, url, rawbody, options, headers, httpHandler); +} +LLSD HttpCoroutineAdapter::postAndYield_(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, + const std::string & url, LLCore::BufferArray::ptr_t &rawbody, + LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, + HttpCoroHandler::ptr_t &handler) +{ //LL_INFOS() << "Requesting transaction " << transactionId << LL_ENDL; - LLCoreHttpUtil::HttpRequestPumper pumper(request); + HttpRequestPumper pumper(request); // The HTTPCoroHandler does not self delete, so retrieval of a the contained // pointer from the smart pointer is safe in this case. - LLCore::HttpHandle hhandle = request->requestPost(mPolicyId, mPriority, url, rawbody.get(), - options.get(), headers.get(), httpHandler.get()); + LLCore::HttpHandle hhandle = request->requestPost(mPolicyId, mPriority, url, rawbody.get(), + options.get(), headers.get(), handler.get()); if (hhandle == LLCORE_HTTP_HANDLE_INVALID) { return HttpCoroutineAdapter::buildImmediateErrorResult(request, url); } - saveState(hhandle, request, httpHandler); - LLSD results = waitForEventOn(self, replyPump); + saveState(hhandle, request, handler); + LLSD results = waitForEventOn(self, handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; @@ -422,25 +531,32 @@ LLSD HttpCoroutineAdapter::putAndYield(LLCoros::self & self, LLCore::HttpRequest const std::string & url, const LLSD & body, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { - LLEventStream replyPump(mAdapterName, true); - LLCoreHttpUtil::HttpCoroHandler::ptr_t httpHandler = - LLCoreHttpUtil::HttpCoroHandler::ptr_t(new LLCoreHttpUtil::HttpCoroHandler(replyPump)); + LLEventStream replyPump(mAdapterName + "Reply", true); + HttpCoroHandler::ptr_t httpHandler = HttpCoroHandler::ptr_t(new HttpCoroLLSDHandler(replyPump)); + return putAndYield_(self, request, url, body, options, headers, httpHandler); +} + +LLSD HttpCoroutineAdapter::putAndYield_(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, + const std::string & url, const LLSD & body, + LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, + HttpCoroHandler::ptr_t &handler) +{ //LL_INFOS() << "Requesting transaction " << transactionId << LL_ENDL; - LLCoreHttpUtil::HttpRequestPumper pumper(request); + HttpRequestPumper pumper(request); // The HTTPCoroHandler does not self delete, so retrieval of a the contained // pointer from the smart pointer is safe in this case. LLCore::HttpHandle hhandle = requestPutWithLLSD(request, mPolicyId, mPriority, url, body, options, headers, - httpHandler.get()); + handler.get()); if (hhandle == LLCORE_HTTP_HANDLE_INVALID) { return HttpCoroutineAdapter::buildImmediateErrorResult(request, url); } - saveState(hhandle, request, httpHandler); - LLSD results = waitForEventOn(self, replyPump); + saveState(hhandle, request, handler); + LLSD results = waitForEventOn(self, handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; @@ -451,50 +567,74 @@ LLSD HttpCoroutineAdapter::getAndYield(LLCoros::self & self, LLCore::HttpRequest LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { LLEventStream replyPump(mAdapterName + "Reply", true); - LLCoreHttpUtil::HttpCoroHandler::ptr_t httpHandler = - LLCoreHttpUtil::HttpCoroHandler::ptr_t(new LLCoreHttpUtil::HttpCoroHandler(replyPump)); + HttpCoroHandler::ptr_t httpHandler = HttpCoroHandler::ptr_t(new HttpCoroLLSDHandler(replyPump)); + + return getAndYield_(self, request, url, options, headers, httpHandler); +} + +LLSD HttpCoroutineAdapter::getRawAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, + const std::string & url, + LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) +{ + LLEventStream replyPump(mAdapterName + "Reply", true); + HttpCoroHandler::ptr_t httpHandler = HttpCoroHandler::ptr_t(new HttpCoroRawHandler(replyPump)); + + return getAndYield_(self, request, url, options, headers, httpHandler); +} +LLSD HttpCoroutineAdapter::getAndYield_(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, + const std::string & url, + LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, + HttpCoroHandler::ptr_t &handler) +{ //LL_INFOS() << "Requesting transaction " << transactionId << LL_ENDL; - LLCoreHttpUtil::HttpRequestPumper pumper(request); + HttpRequestPumper pumper(request); // The HTTPCoroHandler does not self delete, so retrieval of a the contained // pointer from the smart pointer is safe in this case. - LLCore::HttpHandle hhandle = request->requestGet(mPolicyId, mPriority, - url, options.get(), headers.get(), httpHandler.get()); + LLCore::HttpHandle hhandle = request->requestGet(mPolicyId, mPriority, + url, options.get(), headers.get(), handler.get()); if (hhandle == LLCORE_HTTP_HANDLE_INVALID) { return HttpCoroutineAdapter::buildImmediateErrorResult(request, url); } - saveState(hhandle, request, httpHandler); - LLSD results = waitForEventOn(self, replyPump); + saveState(hhandle, request, handler); + LLSD results = waitForEventOn(self, handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; } + LLSD HttpCoroutineAdapter::deleteAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, const std::string & url, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { LLEventStream replyPump(mAdapterName + "Reply", true); - LLCoreHttpUtil::HttpCoroHandler::ptr_t httpHandler = - LLCoreHttpUtil::HttpCoroHandler::ptr_t(new LLCoreHttpUtil::HttpCoroHandler(replyPump)); + HttpCoroHandler::ptr_t httpHandler = HttpCoroHandler::ptr_t(new HttpCoroLLSDHandler(replyPump)); + + return deleteAndYield_(self, request, url, options, headers, httpHandler); +} +LLSD HttpCoroutineAdapter::deleteAndYield_(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, + const std::string & url, LLCore::HttpOptions::ptr_t &options, + LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler) +{ //LL_INFOS() << "Requesting transaction " << transactionId << LL_ENDL; - LLCoreHttpUtil::HttpRequestPumper pumper(request); + HttpRequestPumper pumper(request); // The HTTPCoroHandler does not self delete, so retrieval of a the contained // pointer from the smart pointer is safe in this case. LLCore::HttpHandle hhandle = request->requestDelete(mPolicyId, mPriority, - url, options.get(), headers.get(), httpHandler.get()); + url, options.get(), headers.get(), handler.get()); if (hhandle == LLCORE_HTTP_HANDLE_INVALID) { return HttpCoroutineAdapter::buildImmediateErrorResult(request, url); } - saveState(hhandle, request, httpHandler); - LLSD results = waitForEventOn(self, replyPump); + saveState(hhandle, request, handler); + LLSD results = waitForEventOn(self, handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; @@ -547,5 +687,14 @@ LLSD HttpCoroutineAdapter::buildImmediateErrorResult(const LLCore::HttpRequest:: return errorres; } +LLCore::HttpStatus HttpCoroutineAdapter::getStatusFromLLSD(const LLSD &httpResults) +{ + LLCore::HttpStatus::type_enum_t type = static_cast(httpResults[HttpCoroutineAdapter::HTTP_RESULTS_TYPE].asInteger()); + short code = static_cast(httpResults[HttpCoroutineAdapter::HTTP_RESULTS_STATUS].asInteger()); + + return LLCore::HttpStatus(type, code); +} + + } // end namespace LLCoreHttpUtil diff --git a/indra/llmessage/llcorehttputil.h b/indra/llmessage/llcorehttputil.h index 77b9163492..e8e5f1b1aa 100644 --- a/indra/llmessage/llcorehttputil.h +++ b/indra/llmessage/llcorehttputil.h @@ -235,6 +235,7 @@ inline LLCore::HttpHandle requestPatchWithLLSD(LLCore::HttpRequest::ptr_t & requ url, body, NULL, NULL, handler); } +//========================================================================= /// The HttpCoroHandler is a specialization of the LLCore::HttpHandler for /// interacting with coroutines. When the request is completed the response /// will be posted onto the supplied Event Pump. @@ -256,33 +257,26 @@ public: HttpCoroHandler(LLEventStream &reply); - virtual void onCompleted(LLCore::HttpHandle handle, LLCore::HttpResponse * response); - static void writeStatusCodes(LLCore::HttpStatus status, const std::string &url, LLSD &result); - static LLCore::HttpStatus getStatusFromLLSD(const LLSD &httpResults); -private: - void buildStatusEntry(LLCore::HttpResponse *response, LLCore::HttpStatus status, LLSD &result); + virtual void onCompleted(LLCore::HttpHandle handle, LLCore::HttpResponse * response); - LLEventStream &mReplyPump; -}; + inline LLEventStream &getReplyPump() + { + return mReplyPump; + } -/// The HttpRequestPumper is a utility class. When constructed it will poll the -/// supplied HttpRequest once per frame until it is destroyed. -/// -class HttpRequestPumper -{ -public: - HttpRequestPumper(const LLCore::HttpRequest::ptr_t &request); - ~HttpRequestPumper(); +protected: + /// this method may modify the status value + virtual LLSD handleSuccess(LLCore::HttpResponse * response, LLCore::HttpStatus &status) = 0; private: - bool pollRequest(const LLSD&); + void buildStatusEntry(LLCore::HttpResponse *response, LLCore::HttpStatus status, LLSD &result); - LLTempBoundListener mBoundListener; - LLCore::HttpRequest::ptr_t mHttpRequest; + LLEventStream &mReplyPump; }; +//========================================================================= /// An adapter to handle some of the boilerplate code surrounding HTTP and coroutine /// interaction. /// @@ -302,6 +296,7 @@ public: static const std::string HTTP_RESULTS_URL; static const std::string HTTP_RESULTS_HEADERS; static const std::string HTTP_RESULTS_CONTENT; + static const std::string HTTP_RESULTS_RAW; typedef boost::shared_ptr ptr_t; typedef boost::weak_ptr wptr_t; @@ -366,6 +361,19 @@ public: headers); } + LLSD getRawAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, + const std::string & url, + LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false), + LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false)); + LLSD getRawAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, + const std::string & url, LLCore::HttpHeaders::ptr_t &headers) + { + return getRawAndYield(self, request, url, + LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false), + headers); + } + + /// Execute a DELETE transaction on the supplied URL and yield execution of /// the coroutine until a result is available. /// @@ -379,6 +387,8 @@ public: /// void cancelYieldingOperation(); + static LLCore::HttpStatus getStatusFromLLSD(const LLSD &httpResults); + private: static LLSD buildImmediateErrorResult(const LLCore::HttpRequest::ptr_t &request, const std::string &url); @@ -386,6 +396,28 @@ private: HttpCoroHandler::ptr_t &handler); void cleanState(); + LLSD postAndYield_(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, + const std::string & url, const LLSD & body, + LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, + HttpCoroHandler::ptr_t &handler); + + LLSD postAndYield_(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, + const std::string & url, LLCore::BufferArray::ptr_t &rawbody, + LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, + HttpCoroHandler::ptr_t &handler); + + LLSD putAndYield_(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, + const std::string & url, const LLSD & body, + LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, + HttpCoroHandler::ptr_t &handler); + + LLSD getAndYield_(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, + const std::string & url, LLCore::HttpOptions::ptr_t &options, + LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler); + + LLSD deleteAndYield_(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, + const std::string & url, LLCore::HttpOptions::ptr_t &options, + LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler); std::string mAdapterName; LLCore::HttpRequest::priority_t mPriority; @@ -396,8 +428,6 @@ private: HttpCoroHandler::wptr_t mWeakHandler; }; -//------------------------------------------------------------------------- -LLCore::HttpStatus getStatusFromLLSD(const LLSD &httpResults); } // end namespace LLCoreHttpUtil diff --git a/indra/newview/llavatarrenderinfoaccountant.cpp b/indra/newview/llavatarrenderinfoaccountant.cpp index 4436fe74d6..45be4dfbc9 100644 --- a/indra/newview/llavatarrenderinfoaccountant.cpp +++ b/indra/newview/llavatarrenderinfoaccountant.cpp @@ -79,7 +79,7 @@ void LLAvatarRenderInfoAccountant::avatarRenderInfoGetCoro(LLCoros::self& self, } LLSD httpResults = result["http_result"]; - LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); if (!status) { @@ -202,7 +202,7 @@ void LLAvatarRenderInfoAccountant::avatarRenderInfoReportCoro(LLCoros::self& sel } LLSD httpResults = result["http_result"]; - LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); if (!status) { LL_WARNS("AvatarRenderInfoAccountant") << "HTTP status, " << status.toTerseString() << LL_ENDL; diff --git a/indra/newview/llestateinfomodel.cpp b/indra/newview/llestateinfomodel.cpp index 152c17eb0f..6597d3ad46 100755 --- a/indra/newview/llestateinfomodel.cpp +++ b/indra/newview/llestateinfomodel.cpp @@ -157,7 +157,7 @@ void LLEstateInfoModel::commitEstateInfoCapsCoro(LLCoros::self& self, std::strin LLSD result = httpAdapter->postAndYield(self, httpRequest, url, body); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; - LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); if (status) { diff --git a/indra/newview/lleventpoll.cpp b/indra/newview/lleventpoll.cpp index d731428464..9ba3e7ef5b 100755 --- a/indra/newview/lleventpoll.cpp +++ b/indra/newview/lleventpoll.cpp @@ -162,7 +162,7 @@ namespace Details // << LLSDXMLStreamer(result) << LL_ENDL; LLSD httpResults = result["http_result"]; - LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); if (!status) { diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index ec9efe0c7d..2a1614a422 100755 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -151,7 +151,7 @@ void LLFacebookConnect::facebookConnectCoro(LLCoros::self& self, std::string aut LLSD result = httpAdapter->putAndYield(self, httpRequest, getFacebookConnectURL("/connection"), putData, httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; - LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); if (!status) { if (status == LLCore::HttpStatus(HTTP_FOUND)) @@ -180,7 +180,7 @@ void LLFacebookConnect::facebookConnectCoro(LLCoros::self& self, std::string aut bool LLFacebookConnect::testShareStatus(LLSD &result) { LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; - LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); if (status) return true; @@ -314,7 +314,7 @@ void LLFacebookConnect::facebookDisconnectCoro(LLCoros::self& self) LLSD result = httpAdapter->deleteAndYield(self, httpRequest, getFacebookConnectURL("/connection")); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; - LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); if (!status && (status != LLCore::HttpStatus(HTTP_FOUND))) { LL_WARNS("FacebookConnect") << "Failed to disconnect:" << status.toTerseString() << LL_ENDL; @@ -347,7 +347,7 @@ void LLFacebookConnect::facebookConnectedCheckCoro(LLCoros::self& self, bool aut LLSD result = httpAdapter->getAndYield(self, httpRequest, getFacebookConnectURL("/connection", true)); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; - LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); if (!status) { @@ -394,7 +394,7 @@ void LLFacebookConnect::facebookConnectInfoCoro(LLCoros::self& self) LLSD result = httpAdapter->getAndYield(self, httpRequest, getFacebookConnectURL("/info", true), httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; - LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); if (status == LLCore::HttpStatus(HTTP_FOUND)) { @@ -434,7 +434,7 @@ void LLFacebookConnect::facebookConnectFriendsCoro(LLCoros::self& self) LLSD result = httpAdapter->getAndYield(self, httpRequest, getFacebookConnectURL("/friends", true)); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; - LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); if (status == LLCore::HttpStatus(HTTP_FOUND)) { diff --git a/indra/newview/llfeaturemanager.cpp b/indra/newview/llfeaturemanager.cpp index ea39f812fd..c9404f6a0c 100755 --- a/indra/newview/llfeaturemanager.cpp +++ b/indra/newview/llfeaturemanager.cpp @@ -55,6 +55,7 @@ #include "llviewershadermgr.h" #include "llstring.h" #include "stringize.h" +#include "llcorehttputil.h" #if LL_WINDOWS #include "lldxhardware.h" @@ -492,95 +493,68 @@ bool LLFeatureManager::loadGPUClass() return true; // indicates that a gpu value was established } - -// responder saves table into file -class LLHTTPFeatureTableResponder : public LLHTTPClient::Responder +void LLFeatureManager::fetchFeatureTableCoro(LLCoros::self& self, std::string tableName) { - LOG_CLASS(LLHTTPFeatureTableResponder); -public: + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FeatureManagerHTTPTable", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLHTTPFeatureTableResponder(std::string filename) : - mFilename(filename) - { - } + const std::string base = gSavedSettings.getString("FeatureManagerHTTPTable"); - - virtual void completedRaw(const LLChannelDescriptors& channels, - const LLIOPipe::buffer_ptr_t& buffer) - { - if (isGoodStatus()) - { - // write to file - - LL_INFOS() << "writing feature table to " << mFilename << LL_ENDL; - - S32 file_size = buffer->countAfter(channels.in(), NULL); - if (file_size > 0) - { - // read from buffer - U8* copy_buffer = new U8[file_size]; - buffer->readAfter(channels.in(), NULL, copy_buffer, file_size); - - // write to file - LLAPRFile out(mFilename, LL_APR_WB); - out.write(copy_buffer, file_size); - out.close(); - } - } - else - { - char body[1025]; - body[1024] = '\0'; - LLBufferStream istr(channels, buffer.get()); - istr.get(body,1024); - if (strlen(body) > 0) - { - mContent["body"] = body; - } - LL_WARNS() << dumpResponse() << LL_ENDL; - } - } - -private: - std::string mFilename; -}; - -void fetch_feature_table(std::string table) -{ - const std::string base = gSavedSettings.getString("FeatureManagerHTTPTable"); #if LL_WINDOWS - std::string os_string = LLAppViewer::instance()->getOSInfo().getOSStringSimple(); - std::string filename; - if (os_string.find("Microsoft Windows XP") == 0) - { - filename = llformat(table.c_str(), "_xp", LLVersionInfo::getVersion().c_str()); - } - else - { - filename = llformat(table.c_str(), "", LLVersionInfo::getVersion().c_str()); - } + std::string os_string = LLAppViewer::instance()->getOSInfo().getOSStringSimple(); + std::string filename; + + if (os_string.find("Microsoft Windows XP") == 0) + { + filename = llformat(tableName.c_str(), "_xp", LLVersionInfo::getVersion().c_str()); + } + else + { + filename = llformat(tableName.c_str(), "", LLVersionInfo::getVersion().c_str()); + } #else - const std::string filename = llformat(table.c_str(), LLVersionInfo::getVersion().c_str()); + const std::string filename = llformat(table.c_str(), LLVersionInfo::getVersion().c_str()); #endif - const std::string url = base + "/" + filename; + std::string url = base + "/" + filename; + const std::string path = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, filename); - const std::string path = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, filename); - LL_INFOS() << "LLFeatureManager fetching " << url << " into " << path << LL_ENDL; - - LLHTTPClient::get(url, new LLHTTPFeatureTableResponder(path)); -} + LL_INFOS() << "LLFeatureManager fetching " << url << " into " << path << LL_ENDL; + + LLSD result = httpAdapter->getRawAndYield(self, httpRequest, url); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + + if (status) + { // There was a newer feature table on the server. We've grabbed it and now should write it. + // write to file + const LLSD::Binary &raw = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS_RAW].asBinary(); + LL_INFOS() << "writing feature table to " << filename << LL_ENDL; + + S32 size = raw.size(); + if (size > 0) + { + // write to file + LLAPRFile out(filename, LL_APR_WB); + out.write(raw.data(), size); + out.close(); + } + } +} // fetch table(s) from a website (S3) void LLFeatureManager::fetchHTTPTables() { - fetch_feature_table(FEATURE_TABLE_VER_FILENAME); + LLCoros::instance().launch("LLFeatureManager::fetchFeatureTableCoro", + boost::bind(&LLFeatureManager::fetchFeatureTableCoro, this, _1, FEATURE_TABLE_VER_FILENAME)); } - void LLFeatureManager::cleanupFeatureTables() { std::for_each(mMaskList.begin(), mMaskList.end(), DeletePairedPointer()); diff --git a/indra/newview/llfeaturemanager.h b/indra/newview/llfeaturemanager.h index 69078ccc21..1490c2122c 100755 --- a/indra/newview/llfeaturemanager.h +++ b/indra/newview/llfeaturemanager.h @@ -32,6 +32,8 @@ #include "llsingleton.h" #include "llstring.h" #include +#include "llcoros.h" +#include "lleventcoro.h" typedef enum EGPUClass { @@ -164,6 +166,7 @@ protected: void initBaseMask(); + void fetchFeatureTableCoro(LLCoros::self& self, std::string name); std::map mMaskList; std::set mSkippedFeatures; diff --git a/indra/newview/llflickrconnect.cpp b/indra/newview/llflickrconnect.cpp index d76665a1d5..933e4691a2 100644 --- a/indra/newview/llflickrconnect.cpp +++ b/indra/newview/llflickrconnect.cpp @@ -89,7 +89,7 @@ void LLFlickrConnect::flickrConnectCoro(LLCoros::self& self, std::string request LLSD result = httpAdapter->putAndYield(self, httpRequest, getFlickrConnectURL("/connection"), body, httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; - LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); if (!status) { @@ -125,7 +125,7 @@ void LLFlickrConnect::flickrConnectCoro(LLCoros::self& self, std::string request bool LLFlickrConnect::testShareStatus(LLSD &result) { LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; - LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); if (status) return true; @@ -270,7 +270,7 @@ void LLFlickrConnect::flickrDisconnectCoro(LLCoros::self& self) LLSD result = httpAdapter->deleteAndYield(self, httpRequest, getFlickrConnectURL("/connection")); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; - LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); if (!status && (status != LLCore::HttpStatus(HTTP_NOT_FOUND))) { @@ -302,7 +302,7 @@ void LLFlickrConnect::flickrConnectedCoro(LLCoros::self& self, bool autoConnect) LLSD result = httpAdapter->getAndYield(self, httpRequest, getFlickrConnectURL("/connection", true)); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; - LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); if (!status) { @@ -350,7 +350,7 @@ void LLFlickrConnect::flickrInfoCoro(LLCoros::self& self) LLSD result = httpAdapter->getAndYield(self, httpRequest, getFlickrConnectURL("/info", true), httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; - LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); if (status == LLCore::HttpStatus(HTTP_FOUND)) { diff --git a/indra/newview/llfloatermodeluploadbase.cpp b/indra/newview/llfloatermodeluploadbase.cpp index efc8fae768..644d45c16e 100755 --- a/indra/newview/llfloatermodeluploadbase.cpp +++ b/indra/newview/llfloatermodeluploadbase.cpp @@ -73,7 +73,7 @@ void LLFloaterModelUploadBase::requestAgentUploadPermissionsCoro(LLCoros::self& LLSD result = httpAdapter->getAndYield(self, httpRequest, url); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; - LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); LLUploadPermissionsObserver* observer = observerHandle.get(); diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp index abf206d2d7..814015c0ed 100755 --- a/indra/newview/llimview.cpp +++ b/indra/newview/llimview.cpp @@ -406,7 +406,7 @@ void startConfrenceCoro(LLCoros::self& self, std::string url, LLSD result = httpAdapter->postAndYield(self, httpRequest, url, postData); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; - LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); if (!status) { @@ -445,7 +445,7 @@ void chatterBoxInvitationCoro(LLCoros::self& self, std::string url, LLUUID sessi LLSD result = httpAdapter->postAndYield(self, httpRequest, url, postData); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; - LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); if (!gIMMgr) { diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index 303abdb4d0..e5c7627334 100755 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -470,7 +470,7 @@ void LLPathfindingManager::navMeshStatusRequestCoro(LLCoros::self& self, std::st region = LLWorld::getInstance()->getRegionFromHandle(regionHandle); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; - LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); LLPathfindingNavMeshStatus navMeshStatus(regionUUID); if (!status) @@ -549,7 +549,7 @@ void LLPathfindingManager::navAgentStateRequestCoro(LLCoros::self& self, std::st LLSD result = httpAdapter->getAndYield(self, httpRequest, url); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; - LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); bool canRebake = false; if (!status) @@ -581,7 +581,7 @@ void LLPathfindingManager::navMeshRebakeCoro(LLCoros::self& self, std::string ur LLSD result = httpAdapter->postAndYield(self, httpRequest, url, postData); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; - LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); bool success = true; if (!status) @@ -615,7 +615,7 @@ void LLPathfindingManager::linksetObjectsCoro(LLCoros::self &self, std::string u } LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; - LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); if (!status) { @@ -651,7 +651,7 @@ void LLPathfindingManager::linksetTerrainCoro(LLCoros::self &self, std::string u } LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; - LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); if (!status) { @@ -677,7 +677,7 @@ void LLPathfindingManager::charactersCoro(LLCoros::self &self, std::string url, LLSD result = httpAdapter->getAndYield(self, httpRequest, url); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; - LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); if (!status) { diff --git a/indra/newview/llremoteparcelrequest.cpp b/indra/newview/llremoteparcelrequest.cpp index 149277a3a9..9d750c1ee4 100755 --- a/indra/newview/llremoteparcelrequest.cpp +++ b/indra/newview/llremoteparcelrequest.cpp @@ -204,7 +204,7 @@ void LLRemoteParcelInfoProcessor::regionParcelInfoCoro(LLCoros::self& self, std: LLSD result = httpAdapter->postAndYield(self, httpRequest, url, bodyData); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; - LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); LLRemoteParcelInfoObserver* observer = observerHandle.get(); // Panel inspecting the information may be closed and destroyed diff --git a/indra/newview/lltwitterconnect.cpp b/indra/newview/lltwitterconnect.cpp index 66a63510b0..66500b5455 100644 --- a/indra/newview/lltwitterconnect.cpp +++ b/indra/newview/lltwitterconnect.cpp @@ -89,7 +89,7 @@ void LLTwitterConnect::twitterConnectCoro(LLCoros::self& self, std::string reque LLSD result = httpAdapter->putAndYield(self, httpRequest, getTwitterConnectURL("/connection"), body, httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; - LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); if (!status) { @@ -125,7 +125,7 @@ void LLTwitterConnect::twitterConnectCoro(LLCoros::self& self, std::string reque bool LLTwitterConnect::testShareStatus(LLSD &result) { LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; - LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); if (status) return true; @@ -257,7 +257,7 @@ void LLTwitterConnect::twitterDisconnectCoro(LLCoros::self& self) LLSD result = httpAdapter->deleteAndYield(self, httpRequest, getTwitterConnectURL("/connection")); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; - LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); if (!status && (status != LLCore::HttpStatus(HTTP_NOT_FOUND))) { @@ -289,7 +289,7 @@ void LLTwitterConnect::twitterConnectedCoro(LLCoros::self& self, bool autoConnec LLSD result = httpAdapter->getAndYield(self, httpRequest, getTwitterConnectURL("/connection", true)); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; - LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); if (!status) { @@ -337,7 +337,7 @@ void LLTwitterConnect::twitterInfoCoro(LLCoros::self& self) LLSD result = httpAdapter->getAndYield(self, httpRequest, getTwitterConnectURL("/info", true), httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; - LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); if (status == LLCore::HttpStatus(HTTP_FOUND)) { diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index 4fea51e61d..ddf64aa08b 100755 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -309,7 +309,7 @@ void LLViewerRegionImpl::requestBaseCapabilitiesCoro(LLCoros::self& self, U64 re } LLSD httpResults = result["http_result"]; - LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); if (!status) { LL_WARNS("AppInit", "Capabilities") << "HttpStatus error " << LL_ENDL; @@ -385,7 +385,7 @@ void LLViewerRegionImpl::requestBaseCapabilitiesCompleteCoro(LLCoros::self& self result = httpAdapter->postAndYield(self, httpRequest, url, capabilityNames); LLSD httpResults = result["http_result"]; - LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); if (!status) { LL_WARNS("AppInit", "Capabilities") << "HttpStatus error " << LL_ENDL; @@ -484,7 +484,7 @@ void LLViewerRegionImpl::requestSimulatorFeatureCoro(LLCoros::self& self, std::s LLSD result = httpAdapter->getAndYield(self, httpRequest, url); LLSD httpResults = result["http_result"]; - LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); if (!status) { LL_WARNS("AppInit", "SimulatorFeatures") << "HttpStatus error retrying" << LL_ENDL; diff --git a/indra/newview/llwlhandlers.cpp b/indra/newview/llwlhandlers.cpp index c05486b173..3145c3f38d 100755 --- a/indra/newview/llwlhandlers.cpp +++ b/indra/newview/llwlhandlers.cpp @@ -110,7 +110,7 @@ void LLEnvironmentRequest::environmentRequestCoro(LLCoros::self& self, std::stri } LLSD httpResults = result["http_result"]; - LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); if (!status) { LL_WARNS("WindlightCaps") << "Got an error, not using region windlight... " << LL_ENDL; @@ -207,7 +207,7 @@ void LLEnvironmentApply::environmentApplyCoro(LLCoros::self& self, std::string u { // Breaks from loop in the case of an error. LLSD httpResults = result["http_result"]; - LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroHandler::getStatusFromLLSD(httpResults); + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); if (!status) { LL_WARNS("WindlightCaps") << "Couldn't apply windlight settings to region! " << LL_ENDL; -- cgit v1.2.3 From dcac06d7d2cf966915779256007e46a6fe6885de Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 11 May 2015 17:36:58 -0700 Subject: table -> tableName for non windows builds. --- indra/newview/llfeaturemanager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/llfeaturemanager.cpp b/indra/newview/llfeaturemanager.cpp index c9404f6a0c..b701fece5a 100755 --- a/indra/newview/llfeaturemanager.cpp +++ b/indra/newview/llfeaturemanager.cpp @@ -516,7 +516,7 @@ void LLFeatureManager::fetchFeatureTableCoro(LLCoros::self& self, std::string ta filename = llformat(tableName.c_str(), "", LLVersionInfo::getVersion().c_str()); } #else - const std::string filename = llformat(table.c_str(), LLVersionInfo::getVersion().c_str()); + const std::string filename = llformat(tableName.c_str(), LLVersionInfo::getVersion().c_str()); #endif std::string url = base + "/" + filename; -- cgit v1.2.3 From c4e26ac04dd8fc5cc48266c4a07ec2bd25af00b1 Mon Sep 17 00:00:00 2001 From: Bjoseph Wombat Date: Tue, 12 May 2015 21:05:09 +0100 Subject: Deleted some obsolete comments --- indra/newview/llvoicevivox.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'indra') diff --git a/indra/newview/llvoicevivox.cpp b/indra/newview/llvoicevivox.cpp index 5d1e5327ad..fc96b9e21d 100755 --- a/indra/newview/llvoicevivox.cpp +++ b/indra/newview/llvoicevivox.cpp @@ -3075,11 +3075,7 @@ void LLVivoxVoiceClient::reapSession(sessionState *session) { if(session) { - /*if(!session->mHandle.empty()) - { - LL_DEBUGS("Voice") << "NOT deleting session " << session->mSIPURI << " (non-null session handle)" << LL_ENDL; - } - else*/ + if(session->mCreateInProgress) { LL_DEBUGS("Voice") << "NOT deleting session " << session->mSIPURI << " (create in progress)" << LL_ENDL; @@ -3098,7 +3094,6 @@ void LLVivoxVoiceClient::reapSession(sessionState *session) } else { - // TODO: Question: Should we check for queued text messages here? // We don't have a reason to keep tracking this session, so just delete it. LL_DEBUGS("Voice") << "deleting session " << session->mSIPURI << LL_ENDL; deleteSession(session); -- cgit v1.2.3 From 723834737dc8bdb608f73c5d7fe5bdebfdaa59e5 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 12 May 2015 14:32:43 -0700 Subject: Added trivial case GET and POST to the CoreHTTP Utils converted llfloaterregioninfo to use coroutine's and new LLCore::HTTP --- indra/llmessage/llcorehttputil.cpp | 73 +++++++++++++++++++++++++++++++++++ indra/llmessage/llcorehttputil.h | 12 ++++++ indra/newview/llfloaterregioninfo.cpp | 64 +++--------------------------- indra/newview/llfloaterregioninfo.h | 3 ++ 4 files changed, 93 insertions(+), 59 deletions(-) (limited to 'indra') diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index a79bb62bb8..2ef9f59e2f 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -668,6 +668,7 @@ void HttpCoroutineAdapter::cleanState() mYieldingHandle = LLCORE_HTTP_HANDLE_INVALID; } +/*static*/ LLSD HttpCoroutineAdapter::buildImmediateErrorResult(const LLCore::HttpRequest::ptr_t &request, const std::string &url) { @@ -687,6 +688,7 @@ LLSD HttpCoroutineAdapter::buildImmediateErrorResult(const LLCore::HttpRequest:: return errorres; } +/*static*/ LLCore::HttpStatus HttpCoroutineAdapter::getStatusFromLLSD(const LLSD &httpResults) { LLCore::HttpStatus::type_enum_t type = static_cast(httpResults[HttpCoroutineAdapter::HTTP_RESULTS_TYPE].asInteger()); @@ -695,6 +697,77 @@ LLCore::HttpStatus HttpCoroutineAdapter::getStatusFromLLSD(const LLSD &httpResul return LLCore::HttpStatus(type, code); } +/*static*/ +void HttpCoroutineAdapter::genericHttpGet(const std::string &url, const std::string &success, const std::string &failure) +{ + LLCoros::instance().launch("HttpCoroutineAdapter::genericGetCoro", + boost::bind(&HttpCoroutineAdapter::genericGetCoro, _1, url, success, failure)); +} + +/*static*/ +void HttpCoroutineAdapter::genericGetCoro(LLCoros::self& self, std::string &url, std::string success, std::string failure) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("genericGetCoro", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + + LL_INFOS("HttpCoroutineAdapter", "genericGetCoro") << "Generic GET for " << url << LL_ENDL; + + LLSD result = httpAdapter->getAndYield(self, httpRequest, url); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + + if (status) + { + LL_INFOS("HttpCoroutineAdapter", "genericGetCoro") << "Success for " << url << std::endl << + "Message: '" << success << "'" << LL_ENDL; + } + else + { + LL_WARNS("HttpCoroutineAdapter", "genericGetCoro") << "Failure for " << url << std::endl << + "Message: '" << failure << "'" << std::endl << + "Status: " << status.toTerseString() << ": " << status.getMessage() << LL_ENDL; + } +} + +/*static*/ +void HttpCoroutineAdapter::genericHttpPost(const std::string &url, const LLSD &postData, const std::string &success, const std::string &failure) +{ + LLCoros::instance().launch("HttpCoroutineAdapter::genericPostCoro", + boost::bind(&HttpCoroutineAdapter::genericPostCoro, _1, url, postData, success, failure)); +} + +/*static*/ +void HttpCoroutineAdapter::genericPostCoro(LLCoros::self& self, std::string &url, LLSD postData, std::string success, std::string failure) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("genericPostCoro", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + + LL_INFOS("HttpCoroutineAdapter", "genericPostCoro") << "Generic POST for " << url << LL_ENDL; + + LLSD result = httpAdapter->postAndYield(self, httpRequest, url, postData); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + + if (status) + { + LL_INFOS("HttpCoroutineAdapter", "genericPostCoro") << "Success for " << url << std::endl << + "Message: '" << success << "'" << LL_ENDL; + } + else + { + LL_WARNS("HttpCoroutineAdapter", "genericPostCoro") << "Failure for " << url << std::endl << + "Message: '" << failure << "'" << std::endl << + "Status: " << status.toTerseString() << ": " << status.getMessage() << LL_ENDL; + } +} + + } // end namespace LLCoreHttpUtil diff --git a/indra/llmessage/llcorehttputil.h b/indra/llmessage/llcorehttputil.h index e8e5f1b1aa..7d60bfbbaf 100644 --- a/indra/llmessage/llcorehttputil.h +++ b/indra/llmessage/llcorehttputil.h @@ -387,8 +387,17 @@ public: /// void cancelYieldingOperation(); + static LLCore::HttpStatus getStatusFromLLSD(const LLSD &httpResults); + /// Generic Get and post routines for HTTP via coroutines. + /// These static methods do all required setup for the GET or POST operation. + /// When the operation completes successfully they will put the success message in the log at INFO level, + /// If the operation fails the failure message is written to the log at WARN level. + /// + static void genericHttpGet(const std::string &url, const std::string &success = std::string(), const std::string &failure = std::string()); + static void genericHttpPost(const std::string &url, const LLSD &postData, const std::string &success, const std::string &failure); + private: static LLSD buildImmediateErrorResult(const LLCore::HttpRequest::ptr_t &request, const std::string &url); @@ -419,6 +428,9 @@ private: const std::string & url, LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler); + static void genericGetCoro(LLCoros::self& self, std::string &url, std::string success, std::string failure); + static void genericPostCoro(LLCoros::self& self, std::string &url, LLSD postData, std::string success, std::string failure); + std::string mAdapterName; LLCore::HttpRequest::priority_t mPriority; LLCore::HttpRequest::policy_t mPolicyId; diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp index a2af9da670..42c03e22eb 100755 --- a/indra/newview/llfloaterregioninfo.cpp +++ b/indra/newview/llfloaterregioninfo.cpp @@ -92,6 +92,7 @@ #include "llagentui.h" #include "llmeshrepository.h" #include "llfloaterregionrestarting.h" +#include "llcorehttputil.h" const S32 TERRAIN_TEXTURE_COUNT = 4; const S32 CORNER_COUNT = 4; @@ -768,30 +769,6 @@ bool LLPanelRegionGeneralInfo::onMessageCommit(const LLSD& notification, const L return false; } -class ConsoleRequestResponder : public LLHTTPClient::Responder -{ - LOG_CLASS(ConsoleRequestResponder); -protected: - /*virtual*/ - void httpFailure() - { - LL_WARNS() << "error requesting mesh_rez_enabled " << dumpResponse() << LL_ENDL; - } -}; - - -// called if this request times out. -class ConsoleUpdateResponder : public LLHTTPClient::Responder -{ - LOG_CLASS(ConsoleUpdateResponder); -protected: - /* virtual */ - void httpFailure() - { - LL_WARNS() << "error updating mesh enabled region setting " << dumpResponse() << LL_ENDL; - } -}; - void LLFloaterRegionInfo::requestMeshRezInfo() { std::string sim_console_url = gAgent.getRegion()->getCapability("SimConsoleAsync"); @@ -800,10 +777,8 @@ void LLFloaterRegionInfo::requestMeshRezInfo() { std::string request_str = "get mesh_rez_enabled"; - LLHTTPClient::post( - sim_console_url, - LLSD(request_str), - new ConsoleRequestResponder); + LLCoreHttpUtil::HttpCoroutineAdapter::genericHttpPost(sim_console_url, LLSD(request_str), + "Requested mesh_rez_enabled", "Error requesting mesh_rez_enabled"); } } @@ -839,7 +814,8 @@ BOOL LLPanelRegionGeneralInfo::sendUpdate() body["allow_parcel_changes"] = getChild("allow_parcel_changes_check")->getValue(); body["block_parcel_search"] = getChild("block_parcel_search_check")->getValue(); - LLHTTPClient::post(url, body, new LLHTTPClient::Responder()); + LLCoreHttpUtil::HttpCoroutineAdapter::genericHttpPost(url, body, + "Region info update posted.", "Region info update not posted."); } else { @@ -2263,36 +2239,6 @@ void LLPanelEstateInfo::getEstateOwner() } */ -class LLEstateChangeInfoResponder : public LLHTTPClient::Responder -{ - LOG_CLASS(LLEstateChangeInfoResponder); -public: - LLEstateChangeInfoResponder(LLPanelEstateInfo* panel) - { - mpPanel = panel->getHandle(); - } - -protected: - // if we get a normal response, handle it here - virtual void httpSuccess() - { - LL_INFOS("Windlight") << "Successfully committed estate info" << LL_ENDL; - - // refresh the panel from the database - LLPanelEstateInfo* panel = dynamic_cast(mpPanel.get()); - if (panel) - panel->refresh(); - } - - // if we get an error response - virtual void httpFailure() - { - LL_WARNS("Windlight") << dumpResponse() << LL_ENDL; - } -private: - LLHandle mpPanel; -}; - const std::string LLPanelEstateInfo::getOwnerName() const { return getChild("estate_owner")->getValue().asString(); diff --git a/indra/newview/llfloaterregioninfo.h b/indra/newview/llfloaterregioninfo.h index 792f60ebc8..4042df21c7 100755 --- a/indra/newview/llfloaterregioninfo.h +++ b/indra/newview/llfloaterregioninfo.h @@ -36,6 +36,7 @@ #include "llextendedstatus.h" #include "llenvmanager.h" // for LLEnvironmentSettings +#include "lleventcoro.h" class LLAvatarName; class LLDispatcher; @@ -103,6 +104,8 @@ private: LLFloaterRegionInfo(const LLSD& seed); ~LLFloaterRegionInfo(); + + protected: void onTabSelected(const LLSD& param); -- cgit v1.2.3 From 77cd190633abfb10f5bd66a36035e45382242aad Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 12 May 2015 16:59:51 -0700 Subject: Use Coros to post viewer stats. --- indra/newview/llviewerstats.cpp | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) (limited to 'indra') diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp index f60829e9e8..c6292cec5b 100755 --- a/indra/newview/llviewerstats.cpp +++ b/indra/newview/llviewerstats.cpp @@ -60,6 +60,7 @@ #include "llfeaturemanager.h" #include "llviewernetwork.h" #include "llmeshrepository.h" //for LLMeshRepository::sBytesReceived +#include "llcorehttputil.h" namespace LLStatViewer { @@ -410,24 +411,6 @@ void update_statistics() } } -class ViewerStatsResponder : public LLHTTPClient::Responder -{ - LOG_CLASS(ViewerStatsResponder); -public: - ViewerStatsResponder() { } - -private: - /* virtual */ void httpFailure() - { - LL_WARNS() << dumpResponse() << LL_ENDL; - } - - /* virtual */ void httpSuccess() - { - LL_INFOS() << "OK" << LL_ENDL; - } -}; - /* * The sim-side LLSD is in newsim/llagentinfo.cpp:forwardViewerStats. * @@ -618,8 +601,8 @@ void send_stats() body["MinimalSkin"] = false; LLViewerStats::getInstance()->addToMessage(body); - LLHTTPClient::post(url, body, new ViewerStatsResponder()); - + LLCoreHttpUtil::HttpCoroutineAdapter::genericHttpPost(url, body, + "Statistics posted to sim", "Failed to post statistics to sim"); LLViewerStats::instance().getRecording().resume(); } -- cgit v1.2.3 From 9ec050a0673c28b25eeb28ae7926ff1070cbb4c3 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 14 May 2015 10:33:46 -0700 Subject: Make generic callback version of trivial GET/PUT methods. Make message use these methods. --- indra/llmessage/llcorehttputil.cpp | 75 ++++++++++++++++++++++++++--------- indra/llmessage/llcorehttputil.h | 20 +++++++--- indra/newview/llfloaterregioninfo.cpp | 4 +- indra/newview/llviewerstats.cpp | 2 +- 4 files changed, 75 insertions(+), 26 deletions(-) (limited to 'indra') diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index 2ef9f59e2f..521131a986 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -39,6 +39,16 @@ using namespace LLCore; namespace LLCoreHttpUtil { +void logMessageSuccess(std::string logAuth, std::string url, std::string message) +{ + LL_INFOS() << logAuth << " Success '" << message << "' for " << url << LL_ENDL; +} + +void logMessageFail(std::string logAuth, std::string url, std::string message) +{ + LL_WARNS() << logAuth << " Failure '" << message << "' for " << url << LL_ENDL; +} + //========================================================================= /// The HttpRequestPumper is a utility class. When constructed it will poll the /// supplied HttpRequest once per frame until it is destroyed. @@ -698,14 +708,24 @@ LLCore::HttpStatus HttpCoroutineAdapter::getStatusFromLLSD(const LLSD &httpResul } /*static*/ -void HttpCoroutineAdapter::genericHttpGet(const std::string &url, const std::string &success, const std::string &failure) +void HttpCoroutineAdapter::callbackHttpGet(const std::string &url, completionCallback_t success, completionCallback_t failure) { LLCoros::instance().launch("HttpCoroutineAdapter::genericGetCoro", - boost::bind(&HttpCoroutineAdapter::genericGetCoro, _1, url, success, failure)); + boost::bind(&HttpCoroutineAdapter::trivialGetCoro, _1, url, success, failure)); } /*static*/ -void HttpCoroutineAdapter::genericGetCoro(LLCoros::self& self, std::string &url, std::string success, std::string failure) +void HttpCoroutineAdapter::messageHttpGet(const std::string &url, const std::string &success, const std::string &failure) +{ + completionCallback_t cbSuccess = (success.empty()) ? NULL : + static_cast(boost::bind(&logMessageSuccess, "HttpCoroutineAdapter", url, success)); + completionCallback_t cbFailure = (failure.empty()) ? NULL : + static_cast(boost::bind(&logMessageFail, "HttpCoroutineAdapter", url, failure)); + callbackHttpGet(url, cbSuccess, cbFailure); +} + +/*static*/ +void HttpCoroutineAdapter::trivialGetCoro(LLCoros::self& self, std::string &url, completionCallback_t success, completionCallback_t failure) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -719,28 +739,43 @@ void HttpCoroutineAdapter::genericGetCoro(LLCoros::self& self, std::string &url, LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); - if (status) + if (!status) { - LL_INFOS("HttpCoroutineAdapter", "genericGetCoro") << "Success for " << url << std::endl << - "Message: '" << success << "'" << LL_ENDL; + if (failure) + { + failure(httpResults); + } } else { - LL_WARNS("HttpCoroutineAdapter", "genericGetCoro") << "Failure for " << url << std::endl << - "Message: '" << failure << "'" << std::endl << - "Status: " << status.toTerseString() << ": " << status.getMessage() << LL_ENDL; + if (success) + { // remove the added http_result entry from the results before calling the callback. + result.erase(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS); + success(result); + } } } /*static*/ -void HttpCoroutineAdapter::genericHttpPost(const std::string &url, const LLSD &postData, const std::string &success, const std::string &failure) +void HttpCoroutineAdapter::callbackHttpPost(const std::string &url, const LLSD &postData, completionCallback_t success, completionCallback_t failure) { LLCoros::instance().launch("HttpCoroutineAdapter::genericPostCoro", - boost::bind(&HttpCoroutineAdapter::genericPostCoro, _1, url, postData, success, failure)); + boost::bind(&HttpCoroutineAdapter::trivialPostCoro, _1, url, postData, success, failure)); } /*static*/ -void HttpCoroutineAdapter::genericPostCoro(LLCoros::self& self, std::string &url, LLSD postData, std::string success, std::string failure) +void HttpCoroutineAdapter::messageHttpPost(const std::string &url, const LLSD &postData, const std::string &success, const std::string &failure) +{ + completionCallback_t cbSuccess = (success.empty()) ? NULL : + static_cast(boost::bind(&logMessageSuccess, "HttpCoroutineAdapter", url, success)); + completionCallback_t cbFailure = (failure.empty()) ? NULL : + static_cast(boost::bind(&logMessageFail, "HttpCoroutineAdapter", url, failure)); + + callbackHttpPost(url, postData, cbSuccess, cbFailure); +} + +/*static*/ +void HttpCoroutineAdapter::trivialPostCoro(LLCoros::self& self, std::string &url, LLSD postData, completionCallback_t success, completionCallback_t failure) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -754,16 +789,20 @@ void HttpCoroutineAdapter::genericPostCoro(LLCoros::self& self, std::string &url LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); - if (status) + if (!status) { - LL_INFOS("HttpCoroutineAdapter", "genericPostCoro") << "Success for " << url << std::endl << - "Message: '" << success << "'" << LL_ENDL; + if (failure) + { + failure(httpResults); + } } else { - LL_WARNS("HttpCoroutineAdapter", "genericPostCoro") << "Failure for " << url << std::endl << - "Message: '" << failure << "'" << std::endl << - "Status: " << status.toTerseString() << ": " << status.getMessage() << LL_ENDL; + if (success) + { // remove the added http_result entry from the results before calling the callback. + result.erase(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS); + success(result); + } } } diff --git a/indra/llmessage/llcorehttputil.h b/indra/llmessage/llcorehttputil.h index 7d60bfbbaf..73a51fe83a 100644 --- a/indra/llmessage/llcorehttputil.h +++ b/indra/llmessage/llcorehttputil.h @@ -387,16 +387,26 @@ public: /// void cancelYieldingOperation(); - static LLCore::HttpStatus getStatusFromLLSD(const LLSD &httpResults); + /// The convenience routines below can be provided with callback functors + /// which will be invoked in the case of success or failure. These callbacks + /// should match this form. + /// @sa callbackHttpGet + /// @sa callbackHttpPost + typedef boost::function completionCallback_t; + + static void callbackHttpGet(const std::string &url, completionCallback_t success = NULL, completionCallback_t failure = NULL); + static void callbackHttpPost(const std::string &url, const LLSD &postData, completionCallback_t success = NULL, completionCallback_t failure = NULL); + /// Generic Get and post routines for HTTP via coroutines. /// These static methods do all required setup for the GET or POST operation. /// When the operation completes successfully they will put the success message in the log at INFO level, /// If the operation fails the failure message is written to the log at WARN level. /// - static void genericHttpGet(const std::string &url, const std::string &success = std::string(), const std::string &failure = std::string()); - static void genericHttpPost(const std::string &url, const LLSD &postData, const std::string &success, const std::string &failure); + static void messageHttpGet(const std::string &url, const std::string &success = std::string(), const std::string &failure = std::string()); + static void messageHttpPost(const std::string &url, const LLSD &postData, const std::string &success, const std::string &failure); + private: static LLSD buildImmediateErrorResult(const LLCore::HttpRequest::ptr_t &request, const std::string &url); @@ -428,8 +438,8 @@ private: const std::string & url, LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler); - static void genericGetCoro(LLCoros::self& self, std::string &url, std::string success, std::string failure); - static void genericPostCoro(LLCoros::self& self, std::string &url, LLSD postData, std::string success, std::string failure); + static void trivialGetCoro(LLCoros::self& self, std::string &url, completionCallback_t success, completionCallback_t failure); + static void trivialPostCoro(LLCoros::self& self, std::string &url, LLSD postData, completionCallback_t success, completionCallback_t failure); std::string mAdapterName; LLCore::HttpRequest::priority_t mPriority; diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp index 42c03e22eb..3b1de45697 100755 --- a/indra/newview/llfloaterregioninfo.cpp +++ b/indra/newview/llfloaterregioninfo.cpp @@ -777,7 +777,7 @@ void LLFloaterRegionInfo::requestMeshRezInfo() { std::string request_str = "get mesh_rez_enabled"; - LLCoreHttpUtil::HttpCoroutineAdapter::genericHttpPost(sim_console_url, LLSD(request_str), + LLCoreHttpUtil::HttpCoroutineAdapter::messageHttpPost(sim_console_url, LLSD(request_str), "Requested mesh_rez_enabled", "Error requesting mesh_rez_enabled"); } } @@ -814,7 +814,7 @@ BOOL LLPanelRegionGeneralInfo::sendUpdate() body["allow_parcel_changes"] = getChild("allow_parcel_changes_check")->getValue(); body["block_parcel_search"] = getChild("block_parcel_search_check")->getValue(); - LLCoreHttpUtil::HttpCoroutineAdapter::genericHttpPost(url, body, + LLCoreHttpUtil::HttpCoroutineAdapter::messageHttpPost(url, body, "Region info update posted.", "Region info update not posted."); } else diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp index c6292cec5b..2c3067cd3a 100755 --- a/indra/newview/llviewerstats.cpp +++ b/indra/newview/llviewerstats.cpp @@ -601,7 +601,7 @@ void send_stats() body["MinimalSkin"] = false; LLViewerStats::getInstance()->addToMessage(body); - LLCoreHttpUtil::HttpCoroutineAdapter::genericHttpPost(url, body, + LLCoreHttpUtil::HttpCoroutineAdapter::messageHttpPost(url, body, "Statistics posted to sim", "Failed to post statistics to sim"); LLViewerStats::instance().getRecording().resume(); } -- cgit v1.2.3 From 21701459ee26e821931d6bebf975df59b35d8fd9 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 14 May 2015 15:47:36 -0700 Subject: Converted the Server release notes URL, classified and click tracker, Avatar hover height Pass the http_results on successfull call back style completion as well. --- indra/llmessage/llcorehttputil.cpp | 23 +++++-- indra/newview/CMakeLists.txt | 2 - indra/newview/llclassifiedstatsresponder.cpp | 72 -------------------- indra/newview/llclassifiedstatsresponder.h | 50 -------------- indra/newview/llfloaterabout.cpp | 99 ++++++++++++++-------------- indra/newview/llpanelclassified.cpp | 41 +++++++----- indra/newview/llpanelclassified.h | 5 ++ indra/newview/llvoavatarself.cpp | 26 ++------ 8 files changed, 101 insertions(+), 217 deletions(-) delete mode 100755 indra/newview/llclassifiedstatsresponder.cpp delete mode 100755 indra/newview/llclassifiedstatsresponder.h (limited to 'indra') diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index 521131a986..8da62ca839 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -298,6 +298,9 @@ void HttpCoroHandler::writeStatusCodes(LLCore::HttpStatus status, const std::str /// interacting with coroutines. When the request is completed the response /// will be posted onto the supplied Event Pump. /// +/// If the LLSD retrieved from through the HTTP connection is not in the form +/// of a LLSD::map it will be returned as in an llsd["content"] element. +/// /// The LLSD posted back to the coroutine will have the following additions: /// llsd["http_result"] -+- ["message"] - An error message returned from the HTTP status /// +- ["status"] - The status code associated with the HTTP call @@ -405,6 +408,8 @@ LLSD HttpCoroRawHandler::handleSuccess(LLCore::HttpResponse * response, LLCore:: // We create a new LLSD::Binary object and assign it to the result map. // The LLSD has created it's own copy so we retrieve it asBinary and const cast // the reference so that we can modify it. + // *TODO: This is potentially dangerous... but I am trying to avoid a potentially + // large copy. result[HttpCoroutineAdapter::HTTP_RESULTS_RAW] = LLSD::Binary(); LLSD::Binary &data = const_cast( result[HttpCoroutineAdapter::HTTP_RESULTS_RAW].asBinary() ); @@ -731,10 +736,13 @@ void HttpCoroutineAdapter::trivialGetCoro(LLCoros::self& self, std::string &url, LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("genericGetCoro", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + LLCore::HttpOptions::ptr_t httpOpts = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions); + + httpOpts->setWantHeaders(true); LL_INFOS("HttpCoroutineAdapter", "genericGetCoro") << "Generic GET for " << url << LL_ENDL; - LLSD result = httpAdapter->getAndYield(self, httpRequest, url); + LLSD result = httpAdapter->getAndYield(self, httpRequest, url, httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -749,8 +757,7 @@ void HttpCoroutineAdapter::trivialGetCoro(LLCoros::self& self, std::string &url, else { if (success) - { // remove the added http_result entry from the results before calling the callback. - result.erase(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS); + { success(result); } } @@ -781,16 +788,20 @@ void HttpCoroutineAdapter::trivialPostCoro(LLCoros::self& self, std::string &url LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("genericPostCoro", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + LLCore::HttpOptions::ptr_t httpOpts = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions); + + httpOpts->setWantHeaders(true); LL_INFOS("HttpCoroutineAdapter", "genericPostCoro") << "Generic POST for " << url << LL_ENDL; - LLSD result = httpAdapter->postAndYield(self, httpRequest, url, postData); + LLSD result = httpAdapter->postAndYield(self, httpRequest, url, postData, httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); if (!status) { + // If a failure routine is provided do it. if (failure) { failure(httpResults); @@ -798,9 +809,9 @@ void HttpCoroutineAdapter::trivialPostCoro(LLCoros::self& self, std::string &url } else { + // If a success routine is provided do it. if (success) - { // remove the added http_result entry from the results before calling the callback. - result.erase(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS); + { success(result); } } diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 628c47b92a..ada27c0282 100755 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -152,7 +152,6 @@ set(viewer_SOURCE_FILES llchiclet.cpp llchicletbar.cpp llclassifiedinfo.cpp - llclassifiedstatsresponder.cpp llcofwearables.cpp llcolorswatch.cpp llcommanddispatcherlistener.cpp @@ -757,7 +756,6 @@ set(viewer_HEADER_FILES llchiclet.h llchicletbar.h llclassifiedinfo.h - llclassifiedstatsresponder.h llcofwearables.h llcolorswatch.h llcommanddispatcherlistener.h diff --git a/indra/newview/llclassifiedstatsresponder.cpp b/indra/newview/llclassifiedstatsresponder.cpp deleted file mode 100755 index f1ef8e9a03..0000000000 --- a/indra/newview/llclassifiedstatsresponder.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/** - * @file llclassifiedstatsresponder.cpp - * @brief Receives information about classified ad click-through - * counts for display in the classified information UI. - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#include "llviewerprecompiledheaders.h" - -#include "llclassifiedstatsresponder.h" - -#include "llpanelclassified.h" -#include "llpanel.h" -#include "llhttpclient.h" -#include "llsdserialize.h" -#include "llviewerregion.h" -#include "llview.h" -#include "message.h" - -LLClassifiedStatsResponder::LLClassifiedStatsResponder(LLUUID classified_id) -: mClassifiedID(classified_id) -{} - -/*virtual*/ -void LLClassifiedStatsResponder::httpSuccess() -{ - const LLSD& content = getContent(); - if (!content.isMap()) - { - failureResult(HTTP_INTERNAL_ERROR, "Malformed response contents", content); - return; - } - S32 teleport = content["teleport_clicks"].asInteger(); - S32 map = content["map_clicks"].asInteger(); - S32 profile = content["profile_clicks"].asInteger(); - S32 search_teleport = content["search_teleport_clicks"].asInteger(); - S32 search_map = content["search_map_clicks"].asInteger(); - S32 search_profile = content["search_profile_clicks"].asInteger(); - - LLPanelClassifiedInfo::setClickThrough( mClassifiedID, - teleport + search_teleport, - map + search_map, - profile + search_profile, - true); -} - -/*virtual*/ -void LLClassifiedStatsResponder::httpFailure() -{ - LL_WARNS() << dumpResponse() << LL_ENDL; -} - diff --git a/indra/newview/llclassifiedstatsresponder.h b/indra/newview/llclassifiedstatsresponder.h deleted file mode 100755 index efa4d82411..0000000000 --- a/indra/newview/llclassifiedstatsresponder.h +++ /dev/null @@ -1,50 +0,0 @@ -/** - * @file llclassifiedstatsresponder.h - * @brief Receives information about classified ad click-through - * counts for display in the classified information UI. - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ -#ifndef LL_LLCLASSIFIEDSTATSRESPONDER_H -#define LL_LLCLASSIFIEDSTATSRESPONDER_H - -#include "llhttpclient.h" -#include "llview.h" -#include "lluuid.h" - -class LLClassifiedStatsResponder : public LLHTTPClient::Responder -{ - LOG_CLASS(LLClassifiedStatsResponder); -public: - LLClassifiedStatsResponder(LLUUID classified_id); - -protected: - //If we get back a normal response, handle it here - virtual void httpSuccess(); - //If we get back an error (not found, etc...), handle it here - virtual void httpFailure(); - -protected: - LLUUID mClassifiedID; -}; - -#endif // LL_LLCLASSIFIEDSTATSRESPONDER_H diff --git a/indra/newview/llfloaterabout.cpp b/indra/newview/llfloaterabout.cpp index b342d8fdf3..952bc204b8 100755 --- a/indra/newview/llfloaterabout.cpp +++ b/indra/newview/llfloaterabout.cpp @@ -61,6 +61,7 @@ #include "stringize.h" #include "llsdutil_math.h" #include "lleventapi.h" +#include "llcorehttputil.h" #if LL_WINDOWS #include "lldxhardware.h" @@ -69,18 +70,6 @@ extern LLMemoryInfo gSysMemory; extern U32 gPacketsIn; -///---------------------------------------------------------------------------- -/// Class LLServerReleaseNotesURLFetcher -///---------------------------------------------------------------------------- -class LLServerReleaseNotesURLFetcher : public LLHTTPClient::Responder -{ - LOG_CLASS(LLServerReleaseNotesURLFetcher); -public: - static void startFetch(); -private: - /* virtual */ void httpCompleted(); -}; - ///---------------------------------------------------------------------------- /// Class LLFloaterAbout ///---------------------------------------------------------------------------- @@ -102,6 +91,9 @@ public: private: void setSupportText(const std::string& server_release_notes_url); + + static void startFetchServerReleaseNotes(); + static void handleServerReleaseNotes(LLSD results); }; @@ -138,7 +130,7 @@ BOOL LLFloaterAbout::postBuild() { // start fetching server release notes URL setSupportText(LLTrans::getString("RetrievingData")); - LLServerReleaseNotesURLFetcher::startFetch(); + startFetchServerReleaseNotes(); } else // not logged in { @@ -201,6 +193,50 @@ LLSD LLFloaterAbout::getInfo() return LLAppViewer::instance()->getViewerInfo(); } +/*static*/ +void LLFloaterAbout::startFetchServerReleaseNotes() +{ + LLViewerRegion* region = gAgent.getRegion(); + if (!region) return; + + // We cannot display the URL returned by the ServerReleaseNotes capability + // because opening it in an external browser will trigger a warning about untrusted + // SSL certificate. + // So we query the URL ourselves, expecting to find + // an URL suitable for external browsers in the "Location:" HTTP header. + std::string cap_url = region->getCapability("ServerReleaseNotes"); + //LLHTTPClient::get(cap_url, new LLServerReleaseNotesURLFetcher); + LLCoreHttpUtil::HttpCoroutineAdapter::callbackHttpGet(cap_url, + &LLFloaterAbout::handleServerReleaseNotes, &LLFloaterAbout::handleServerReleaseNotes); + +} + +/*static*/ +void LLFloaterAbout::handleServerReleaseNotes(LLSD results) +{ + LLFloaterAbout* floater_about = LLFloaterReg::getTypedInstance("sl_about"); + if (floater_about) + { + LLSD http_headers; + if (results.has(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS)) + { + LLSD http_results = results[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + http_headers = http_results[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS_HEADERS]; + } + else + { + http_headers = results[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS_HEADERS]; + } + + std::string location = http_headers[HTTP_IN_HEADER_LOCATION].asString(); + if (location.empty()) + { + location = LLTrans::getString("ErrorFetchingServerReleaseNotesURL"); + } + LLAppViewer::instance()->setServerReleaseNotesURL(location); + } +} + class LLFloaterAboutListener: public LLEventAPI { public: @@ -264,40 +300,3 @@ void LLFloaterAboutUtil::registerFloater() &LLFloaterReg::build); } - -///---------------------------------------------------------------------------- -/// Class LLServerReleaseNotesURLFetcher implementation -///---------------------------------------------------------------------------- -// static -void LLServerReleaseNotesURLFetcher::startFetch() -{ - LLViewerRegion* region = gAgent.getRegion(); - if (!region) return; - - // We cannot display the URL returned by the ServerReleaseNotes capability - // because opening it in an external browser will trigger a warning about untrusted - // SSL certificate. - // So we query the URL ourselves, expecting to find - // an URL suitable for external browsers in the "Location:" HTTP header. - std::string cap_url = region->getCapability("ServerReleaseNotes"); - LLHTTPClient::get(cap_url, new LLServerReleaseNotesURLFetcher); -} - -// virtual -void LLServerReleaseNotesURLFetcher::httpCompleted() -{ - LL_DEBUGS("ServerReleaseNotes") << dumpResponse() - << " [headers:" << getResponseHeaders() << "]" << LL_ENDL; - - LLFloaterAbout* floater_about = LLFloaterReg::getTypedInstance("sl_about"); - if (floater_about) - { - std::string location = getResponseHeader(HTTP_IN_HEADER_LOCATION); - if (location.empty()) - { - location = LLTrans::getString("ErrorFetchingServerReleaseNotesURL"); - } - LLAppViewer::instance()->setServerReleaseNotesURL(location); - } -} - diff --git a/indra/newview/llpanelclassified.cpp b/indra/newview/llpanelclassified.cpp index 878f1af9ef..2689420c00 100755 --- a/indra/newview/llpanelclassified.cpp +++ b/indra/newview/llpanelclassified.cpp @@ -41,7 +41,6 @@ #include "llagent.h" #include "llclassifiedflags.h" -#include "llclassifiedstatsresponder.h" #include "llcommandhandler.h" // for classified HTML detail page click tracking #include "lliconctrl.h" #include "lllineeditor.h" @@ -57,6 +56,7 @@ #include "llscrollcontainer.h" #include "llstatusbar.h" #include "llviewertexture.h" +#include "llcorehttputil.h" const S32 MINIMUM_PRICE_FOR_LISTING = 50; // L$ @@ -91,19 +91,6 @@ public: }; static LLDispatchClassifiedClickThrough sClassifiedClickThrough; -// Just to debug errors. Can be thrown away later. -class LLClassifiedClickMessageResponder : public LLHTTPClient::Responder -{ - LOG_CLASS(LLClassifiedClickMessageResponder); - -protected: - // If we get back an error (not found, etc...), handle it here - virtual void httpFailure() - { - LL_WARNS() << "Sending click message failed " << dumpResponse() << LL_ENDL; - } -}; - ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// @@ -229,8 +216,10 @@ void LLPanelClassifiedInfo::onOpen(const LLSD& key) { LL_INFOS() << "Classified stat request via capability" << LL_ENDL; LLSD body; - body["classified_id"] = getClassifiedId(); - LLHTTPClient::post(url, body, new LLClassifiedStatsResponder(getClassifiedId())); + LLUUID classifiedId = getClassifiedId(); + body["classified_id"] = classifiedId; + LLCoreHttpUtil::HttpCoroutineAdapter::callbackHttpPost(url, body, + boost::bind(&LLPanelClassifiedInfo::handleSearchStatResponse, classifiedId, _1)); } // Update classified click stats. @@ -240,6 +229,23 @@ void LLPanelClassifiedInfo::onOpen(const LLSD& key) setInfoLoaded(false); } +/*static*/ +void LLPanelClassifiedInfo::handleSearchStatResponse(LLUUID classifiedId, LLSD result) +{ + S32 teleport = result["teleport_clicks"].asInteger(); + S32 map = result["map_clicks"].asInteger(); + S32 profile = result["profile_clicks"].asInteger(); + S32 search_teleport = result["search_teleport_clicks"].asInteger(); + S32 search_map = result["search_map_clicks"].asInteger(); + S32 search_profile = result["search_profile_clicks"].asInteger(); + + LLPanelClassifiedInfo::setClickThrough(classifiedId, + teleport + search_teleport, + map + search_map, + profile + search_profile, + true); +} + void LLPanelClassifiedInfo::processProperties(void* data, EAvatarProcessorType type) { if(APT_CLASSIFIED_INFO == type) @@ -548,7 +554,8 @@ void LLPanelClassifiedInfo::sendClickMessage( std::string url = gAgent.getRegion()->getCapability("SearchStatTracking"); LL_INFOS() << "Sending click msg via capability (url=" << url << ")" << LL_ENDL; LL_INFOS() << "body: [" << body << "]" << LL_ENDL; - LLHTTPClient::post(url, body, new LLClassifiedClickMessageResponder()); + LLCoreHttpUtil::HttpCoroutineAdapter::messageHttpPost(url, body, + "SearchStatTracking Click report sent.", "SearchStatTracking Click report NOT sent."); } void LLPanelClassifiedInfo::sendClickMessage(const std::string& type) diff --git a/indra/newview/llpanelclassified.h b/indra/newview/llpanelclassified.h index cedd65c405..b292782615 100755 --- a/indra/newview/llpanelclassified.h +++ b/indra/newview/llpanelclassified.h @@ -37,6 +37,8 @@ #include "llrect.h" #include "lluuid.h" #include "v3dmath.h" +#include "llcoros.h" +#include "lleventcoro.h" class LLScrollContainer; class LLTextureCtrl; @@ -193,6 +195,9 @@ private: S32 mMapClicksNew; S32 mProfileClicksNew; + static void handleSearchStatResponse(LLUUID classifiedId, LLSD result); + + typedef std::list panel_list_t; static panel_list_t sAllPanels; }; diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp index f9160b6d60..836ac0609b 100755 --- a/indra/newview/llvoavatarself.cpp +++ b/indra/newview/llvoavatarself.cpp @@ -64,6 +64,7 @@ #include "llsdutil.h" #include "llstartup.h" #include "llsdserialize.h" +#include "llcorehttputil.h" #if LL_MSVC // disable boost::lexical_cast warning @@ -127,25 +128,6 @@ struct LocalTextureData LLTextureEntry *mTexEntry; }; -// TODO - this class doesn't really do anything, could just use a base -// class responder if nothing else gets added. -class LLHoverHeightResponder: public LLHTTPClient::Responder -{ -public: - LLHoverHeightResponder(): LLHTTPClient::Responder() {} - -private: - void httpFailure() - { - LL_WARNS() << dumpResponse() << LL_ENDL; - } - - void httpSuccess() - { - LL_INFOS() << dumpResponse() << LL_ENDL; - } -}; - //----------------------------------------------------------------------------- // Callback data //----------------------------------------------------------------------------- @@ -2789,8 +2771,12 @@ void LLVOAvatarSelf::sendHoverHeight() const update["hover_height"] = hover_offset[2]; LL_DEBUGS("Avatar") << avString() << "sending hover height value " << hover_offset[2] << LL_ENDL; - LLHTTPClient::post(url, update, new LLHoverHeightResponder); + // *TODO: - this class doesn't really do anything, could just use a base + // class responder if nothing else gets added. + // (comment from removed Responder) + LLCoreHttpUtil::HttpCoroutineAdapter::messageHttpPost(url, update, + "Hover hight sent to sim", "Hover hight not sent to sim"); mLastHoverOffsetSent = hover_offset; } } -- cgit v1.2.3 From 2d79079414f61ad7a6e336e039353c030aa559c8 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 15 May 2015 11:52:05 -0700 Subject: Avatar statistics as a coroutine. --- indra/newview/llvoavatarself.cpp | 169 ++++++++++++++++++--------------------- indra/newview/llvoavatarself.h | 5 ++ 2 files changed, 85 insertions(+), 89 deletions(-) (limited to 'indra') diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp index 836ac0609b..3c18d11248 100755 --- a/indra/newview/llvoavatarself.cpp +++ b/indra/newview/llvoavatarself.cpp @@ -106,6 +106,9 @@ void selfClearPhases() using namespace LLAvatarAppearanceDefines; + +LLSD summarize_by_buckets(std::vector in_records, std::vector by_fields, std::string val_field); + /********************************************************************************* ** ** ** Begin private LLVOAvatarSelf Support classes @@ -162,7 +165,9 @@ LLVOAvatarSelf::LLVOAvatarSelf(const LLUUID& id, mRegionCrossingCount(0), // Value outside legal range, so will always be a mismatch the // first time through. - mLastHoverOffsetSent(LLVector3(0.0f, 0.0f, -999.0f)) + mLastHoverOffsetSent(LLVector3(0.0f, 0.0f, -999.0f)), + mInitialMetric(true), + mMetricSequence(0) { mMotionController.mIsSelf = TRUE; @@ -2177,43 +2182,76 @@ const std::string LLVOAvatarSelf::debugDumpAllLocalTextureDataInfo() const return text; } -class ViewerAppearanceChangeMetricsResponder: public LLCurl::Responder -{ - LOG_CLASS(ViewerAppearanceChangeMetricsResponder); -public: - ViewerAppearanceChangeMetricsResponder( S32 expected_sequence, - volatile const S32 & live_sequence, - volatile bool & reporting_started): - mExpectedSequence(expected_sequence), - mLiveSequence(live_sequence), - mReportingStarted(reporting_started) - { - } - -private: - /* virtual */ void httpSuccess() - { - LL_DEBUGS("Avatar") << "OK" << LL_ENDL; - - gPendingMetricsUploads--; - if (mLiveSequence == mExpectedSequence) - { - mReportingStarted = true; - } - } - - /* virtual */ void httpFailure() - { - // if we add retry, this should be removed from the httpFailure case - LL_WARNS("Avatar") << dumpResponse() << LL_ENDL; - gPendingMetricsUploads--; - } - -private: - S32 mExpectedSequence; - volatile const S32 & mLiveSequence; - volatile bool & mReportingStarted; -}; +void LLVOAvatarSelf::appearanceChangeMetricsCoro(LLCoros::self& self, std::string &url) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("appearanceChangeMetrics", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + LLCore::HttpOptions::ptr_t httpOpts = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions); + + S32 currentSequence = mMetricSequence; + if (S32_MAX == ++mMetricSequence) + mMetricSequence = 0; + + LLSD msg; + msg["message"] = "ViewerAppearanceChangeMetrics"; + msg["session_id"] = gAgentSessionID; + msg["agent_id"] = gAgentID; + msg["sequence"] = currentSequence; + msg["initial"] = mInitialMetric; + msg["break"] = false; + msg["duration"] = mTimeSinceLastRezMessage.getElapsedTimeF32(); + + // Status of our own rezzing. + msg["rez_status"] = LLVOAvatar::rezStatusToString(getRezzedStatus()); + + // Status of all nearby avs including ourself. + msg["nearby"] = LLSD::emptyArray(); + std::vector rez_counts; + LLVOAvatar::getNearbyRezzedStats(rez_counts); + for (S32 rez_stat = 0; rez_stat < rez_counts.size(); ++rez_stat) + { + std::string rez_status_name = LLVOAvatar::rezStatusToString(rez_stat); + msg["nearby"][rez_status_name] = rez_counts[rez_stat]; + } + + // std::vector bucket_fields("timer_name","is_self","grid_x","grid_y","is_using_server_bake"); + std::vector by_fields; + by_fields.push_back("timer_name"); + by_fields.push_back("completed"); + by_fields.push_back("grid_x"); + by_fields.push_back("grid_y"); + by_fields.push_back("is_using_server_bakes"); + by_fields.push_back("is_self"); + by_fields.push_back("central_bake_version"); + LLSD summary = summarize_by_buckets(mPendingTimerRecords, by_fields, std::string("elapsed")); + msg["timers"] = summary; + + mPendingTimerRecords.clear(); + + LL_DEBUGS("Avatar") << avString() << "message: " << ll_pretty_print_sd(msg) << LL_ENDL; + + gPendingMetricsUploads++; + + LLSD result = httpAdapter->postAndYield(self, httpRequest, url, msg); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + + gPendingMetricsUploads--; + + if (!status) + { + LL_WARNS("Avatar") << "Unable to upload statistics" << LL_ENDL; + return; + } + else + { + LL_INFOS("Avatar") << "Statistics upload OK" << LL_ENDL; + mInitialMetric = false; + } +} bool LLVOAvatarSelf::updateAvatarRezMetrics(bool force_send) { @@ -2291,51 +2329,7 @@ LLSD summarize_by_buckets(std::vector in_records, void LLVOAvatarSelf::sendViewerAppearanceChangeMetrics() { - static volatile bool reporting_started(false); - static volatile S32 report_sequence(0); - - LLSD msg; - msg["message"] = "ViewerAppearanceChangeMetrics"; - msg["session_id"] = gAgentSessionID; - msg["agent_id"] = gAgentID; - msg["sequence"] = report_sequence; - msg["initial"] = !reporting_started; - msg["break"] = false; - msg["duration"] = mTimeSinceLastRezMessage.getElapsedTimeF32(); - - // Status of our own rezzing. - msg["rez_status"] = LLVOAvatar::rezStatusToString(getRezzedStatus()); - - // Status of all nearby avs including ourself. - msg["nearby"] = LLSD::emptyArray(); - std::vector rez_counts; - LLVOAvatar::getNearbyRezzedStats(rez_counts); - for (S32 rez_stat=0; rez_stat < rez_counts.size(); ++rez_stat) - { - std::string rez_status_name = LLVOAvatar::rezStatusToString(rez_stat); - msg["nearby"][rez_status_name] = rez_counts[rez_stat]; - } - - // std::vector bucket_fields("timer_name","is_self","grid_x","grid_y","is_using_server_bake"); - std::vector by_fields; - by_fields.push_back("timer_name"); - by_fields.push_back("completed"); - by_fields.push_back("grid_x"); - by_fields.push_back("grid_y"); - by_fields.push_back("is_using_server_bakes"); - by_fields.push_back("is_self"); - by_fields.push_back("central_bake_version"); - LLSD summary = summarize_by_buckets(mPendingTimerRecords, by_fields, std::string("elapsed")); - msg["timers"] = summary; - - mPendingTimerRecords.clear(); - - // Update sequence number - if (S32_MAX == ++report_sequence) - report_sequence = 0; - - LL_DEBUGS("Avatar") << avString() << "message: " << ll_pretty_print_sd(msg) << LL_ENDL; - std::string caps_url; + std::string caps_url; if (getRegion()) { // runway - change here to activate. @@ -2343,12 +2337,9 @@ void LLVOAvatarSelf::sendViewerAppearanceChangeMetrics() } if (!caps_url.empty()) { - gPendingMetricsUploads++; - LLHTTPClient::post(caps_url, - msg, - new ViewerAppearanceChangeMetricsResponder(report_sequence, - report_sequence, - reporting_started)); + + LLCoros::instance().launch("LLVOAvatarSelf::appearanceChangeMetricsCoro", + boost::bind(&LLVOAvatarSelf::appearanceChangeMetricsCoro, this, _1, caps_url)); mTimeSinceLastRezMessage.reset(); } } diff --git a/indra/newview/llvoavatarself.h b/indra/newview/llvoavatarself.h index dc5e64d547..46f92763a2 100755 --- a/indra/newview/llvoavatarself.h +++ b/indra/newview/llvoavatarself.h @@ -31,6 +31,8 @@ #include "llviewertexture.h" #include "llvoavatar.h" #include +#include "lleventcoro.h" +#include "llcoros.h" struct LocalTextureData; class LLInventoryCallback; @@ -400,6 +402,9 @@ private: F32 mDebugBakedTextureTimes[LLAvatarAppearanceDefines::BAKED_NUM_INDICES][2]; // time to start upload and finish upload of each baked texture void debugTimingLocalTexLoaded(BOOL success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata); + void appearanceChangeMetricsCoro(LLCoros::self& self, std::string &url); + bool mInitialMetric; + S32 mMetricSequence; /** Diagnostics ** ** *******************************************************************************/ -- cgit v1.2.3 From f26fb73dd8a7794df580e6a58744d76dde293569 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 15 May 2015 12:51:18 -0700 Subject: Address Nat's concerns about the const_cast<> and modification of a binary object wrapped in an LLSD object. --- indra/llmessage/llcorehttputil.cpp | 17 +++++++++++++++++ indra/newview/llfeaturemanager.cpp | 2 ++ 2 files changed, 19 insertions(+) (limited to 'indra') diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index 8da62ca839..f8f5866355 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -405,6 +405,22 @@ LLSD HttpCoroRawHandler::handleSuccess(LLCore::HttpResponse * response, LLCore:: LLCore::BufferArrayStream bas(body); +#if 1 + // This is the slower implementation. It is safe vis-a-vi the const_cast<> and modification + // of a LLSD managed array but contains an extra (potentially large) copy. + // + // *TODO: https://jira.secondlife.com/browse/MAINT-5221 + + LLSD::Binary data; + data.reserve(size); + bas >> std::noskipws; + data.assign(std::istream_iterator(bas), std::istream_iterator()); + + result[HttpCoroutineAdapter::HTTP_RESULTS_RAW] = data; + +#else + // This is disabled because it's dangerous. See the other case for an + // alternate implementation. // We create a new LLSD::Binary object and assign it to the result map. // The LLSD has created it's own copy so we retrieve it asBinary and const cast // the reference so that we can modify it. @@ -416,6 +432,7 @@ LLSD HttpCoroRawHandler::handleSuccess(LLCore::HttpResponse * response, LLCore:: data.reserve(size); bas >> std::noskipws; data.assign(std::istream_iterator(bas), std::istream_iterator()); +#endif return result; } diff --git a/indra/newview/llfeaturemanager.cpp b/indra/newview/llfeaturemanager.cpp index b701fece5a..c61e11b912 100755 --- a/indra/newview/llfeaturemanager.cpp +++ b/indra/newview/llfeaturemanager.cpp @@ -520,6 +520,8 @@ void LLFeatureManager::fetchFeatureTableCoro(LLCoros::self& self, std::string ta #endif std::string url = base + "/" + filename; + // testing url below + //url = "http://viewer-settings.secondlife.com/featuretable.2.1.1.208406.txt"; const std::string path = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, filename); -- cgit v1.2.3 From 4fc12def1e921848ab9f965b2e8e538761d4c966 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 15 May 2015 15:04:28 -0700 Subject: Group voice chat coro --- indra/newview/llvoicechannel.cpp | 136 ++++++++++++++++++--------------------- indra/newview/llvoicechannel.h | 4 ++ 2 files changed, 68 insertions(+), 72 deletions(-) (limited to 'indra') diff --git a/indra/newview/llvoicechannel.cpp b/indra/newview/llvoicechannel.cpp index 426ca332e4..a609f02710 100755 --- a/indra/newview/llvoicechannel.cpp +++ b/indra/newview/llvoicechannel.cpp @@ -37,7 +37,7 @@ #include "llviewercontrol.h" #include "llviewerregion.h" #include "llvoicechannel.h" - +#include "llcorehttputil.h" LLVoiceChannel::voice_channel_map_t LLVoiceChannel::sVoiceChannelMap; LLVoiceChannel::voice_channel_map_uri_t LLVoiceChannel::sVoiceChannelURIMap; @@ -52,71 +52,6 @@ BOOL LLVoiceChannel::sSuspended = FALSE; // const U32 DEFAULT_RETRIES_COUNT = 3; - -class LLVoiceCallCapResponder : public LLHTTPClient::Responder -{ - LOG_CLASS(LLVoiceCallCapResponder); -public: - LLVoiceCallCapResponder(const LLUUID& session_id) : mSessionID(session_id) {}; - -protected: - // called with bad status codes - virtual void httpFailure(); - virtual void httpSuccess(); - -private: - LLUUID mSessionID; -}; - - -void LLVoiceCallCapResponder::httpFailure() -{ - LL_WARNS("Voice") << dumpResponse() << LL_ENDL; - LLVoiceChannel* channelp = LLVoiceChannel::getChannelByID(mSessionID); - if ( channelp ) - { - if ( HTTP_FORBIDDEN == getStatus() ) - { - //403 == no ability - LLNotificationsUtil::add( - "VoiceNotAllowed", - channelp->getNotifyArgs()); - } - else - { - LLNotificationsUtil::add( - "VoiceCallGenericError", - channelp->getNotifyArgs()); - } - channelp->deactivate(); - } -} - -void LLVoiceCallCapResponder::httpSuccess() -{ - LLVoiceChannel* channelp = LLVoiceChannel::getChannelByID(mSessionID); - if (channelp) - { - //*TODO: DEBUG SPAM - const LLSD& content = getContent(); - if (!content.isMap()) - { - failureResult(HTTP_INTERNAL_ERROR, "Malformed response contents", content); - return; - } - LLSD::map_const_iterator iter; - for(iter = content.beginMap(); iter != content.endMap(); ++iter) - { - LL_DEBUGS("Voice") << "LLVoiceCallCapResponder::result got " - << iter->first << LL_ENDL; - } - - channelp->setChannelInfo( - content["voice_credentials"]["channel_uri"].asString(), - content["voice_credentials"]["channel_credentials"].asString()); - } -} - // // LLVoiceChannel // @@ -545,12 +480,9 @@ void LLVoiceChannelGroup::getChannelInfo() if (region) { std::string url = region->getCapability("ChatSessionRequest"); - LLSD data; - data["method"] = "call"; - data["session-id"] = mSessionID; - LLHTTPClient::post(url, - data, - new LLVoiceCallCapResponder(mSessionID)); + + LLCoros::instance().launch("LLVoiceChannelGroup::voiceCallCapCoro", + boost::bind(&LLVoiceChannelGroup::voiceCallCapCoro, this, _1, url)); } } @@ -673,6 +605,66 @@ void LLVoiceChannelGroup::setState(EState state) } } +void LLVoiceChannelGroup::voiceCallCapCoro(LLCoros::self& self, std::string &url) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("voiceCallCapCoro", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + + LLSD postData; + postData["method"] = "call"; + postData["session-id"] = mSessionID; + + LL_INFOS("Voice", "voiceCallCapCoro") << "Generic POST for " << url << LL_ENDL; + + LLSD result = httpAdapter->postAndYield(self, httpRequest, url, postData); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + + LLVoiceChannel* channelp = LLVoiceChannel::getChannelByID(mSessionID); + if (!channelp) + { + LL_WARNS("Voice") << "Unable to retrieve channel with Id = " << mSessionID << LL_ENDL; + return; + } + + if (!status) + { + if (status == LLCore::HttpStatus(HTTP_FORBIDDEN)) + { + //403 == no ability + LLNotificationsUtil::add( + "VoiceNotAllowed", + channelp->getNotifyArgs()); + } + else + { + LLNotificationsUtil::add( + "VoiceCallGenericError", + channelp->getNotifyArgs()); + } + channelp->deactivate(); + return; + } + + result.erase(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS); + + LLSD::map_const_iterator iter; + for (iter = result.beginMap(); iter != result.endMap(); ++iter) + { + LL_DEBUGS("Voice") << "LLVoiceCallCapResponder::result got " + << iter->first << LL_ENDL; + } + + channelp->setChannelInfo( + result["voice_credentials"]["channel_uri"].asString(), + result["voice_credentials"]["channel_credentials"].asString()); + +} + + // // LLVoiceChannelProximal // diff --git a/indra/newview/llvoicechannel.h b/indra/newview/llvoicechannel.h index fed44974fd..13d73a51f8 100755 --- a/indra/newview/llvoicechannel.h +++ b/indra/newview/llvoicechannel.h @@ -29,6 +29,8 @@ #include "llhandle.h" #include "llvoiceclient.h" +#include "lleventcoro.h" +#include "llcoros.h" class LLPanel; @@ -157,6 +159,8 @@ protected: virtual void setState(EState state); private: + void voiceCallCapCoro(LLCoros::self& self, std::string &url); + U32 mRetries; BOOL mIsRetrying; }; -- cgit v1.2.3 From e2d68193742014c43dd98646903a18bb12f9c16b Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 15 May 2015 16:20:01 -0700 Subject: Voice client state to coro. --- indra/newview/llvoicevivox.cpp | 109 ++++++++++++++++++++--------------------- indra/newview/llvoicevivox.h | 4 ++ 2 files changed, 56 insertions(+), 57 deletions(-) (limited to 'indra') diff --git a/indra/newview/llvoicevivox.cpp b/indra/newview/llvoicevivox.cpp index a6a7a35b03..8b24ce1c47 100755 --- a/indra/newview/llvoicevivox.cpp +++ b/indra/newview/llvoicevivox.cpp @@ -64,6 +64,8 @@ #include "llviewernetwork.h" #include "llnotificationsutil.h" +#include "llcorehttputil.h" + #include "stringize.h" // for base64 decoding @@ -194,59 +196,6 @@ static LLVivoxVoiceClientMuteListObserver mutelist_listener; static bool sMuteListListener_listening = false; /////////////////////////////////////////////////////////////////////////////////////////////// - -class LLVivoxVoiceClientCapResponder : public LLHTTPClient::Responder -{ - LOG_CLASS(LLVivoxVoiceClientCapResponder); -public: - LLVivoxVoiceClientCapResponder(LLVivoxVoiceClient::state requesting_state) : mRequestingState(requesting_state) {}; - -private: - // called with bad status codes - /* virtual */ void httpFailure(); - /* virtual */ void httpSuccess(); - - LLVivoxVoiceClient::state mRequestingState; // state -}; - -void LLVivoxVoiceClientCapResponder::httpFailure() -{ - LL_WARNS("Voice") << dumpResponse() << LL_ENDL; - LLVivoxVoiceClient::getInstance()->sessionTerminate(); -} - -void LLVivoxVoiceClientCapResponder::httpSuccess() -{ - LLSD::map_const_iterator iter; - - LL_DEBUGS("Voice") << "ParcelVoiceInfoRequest response:" << dumpResponse() << LL_ENDL; - - std::string uri; - std::string credentials; - - const LLSD& content = getContent(); - if ( content.has("voice_credentials") ) - { - LLSD voice_credentials = content["voice_credentials"]; - if ( voice_credentials.has("channel_uri") ) - { - uri = voice_credentials["channel_uri"].asString(); - } - if ( voice_credentials.has("channel_credentials") ) - { - credentials = - voice_credentials["channel_credentials"].asString(); - } - } - - // set the spatial channel. If no voice credentials or uri are - // available, then we simply drop out of voice spatially. - if(LLVivoxVoiceClient::getInstance()->parcelVoiceInfoReceived(mRequestingState)) - { - LLVivoxVoiceClient::getInstance()->setSpatialChannel(uri, credentials); - } -} - static LLProcessPtr sGatewayPtr; static bool isGatewayRunning() @@ -4003,14 +3952,60 @@ bool LLVivoxVoiceClient::requestParcelVoiceInfo() LLSD data; LL_DEBUGS("Voice") << "sending ParcelVoiceInfoRequest (" << mCurrentRegionName << ", " << mCurrentParcelLocalID << ")" << LL_ENDL; - LLHTTPClient::post( - url, - data, - new LLVivoxVoiceClientCapResponder(getState())); + LLCoros::instance().launch("LLVivoxVoiceClient::parcelVoiceInfoRequestCoro", + boost::bind(&LLVivoxVoiceClient::parcelVoiceInfoRequestCoro, this, _1, url)); return true; } } +void LLVivoxVoiceClient::parcelVoiceInfoRequestCoro(LLCoros::self& self, std::string &url) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("parcelVoiceInfoRequest", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + state requestingState = getState(); + + LLSD result = httpAdapter->postAndYield(self, httpRequest, url, LLSD()); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + + if (!status) + { + LL_WARNS("Voice") << "No voice on parcel" << LL_ENDL; + sessionTerminate(); + return; + } + + std::string uri; + std::string credentials; + + if (result.has("voice_credentials")) + { + LLSD voice_credentials = result["voice_credentials"]; + if (voice_credentials.has("channel_uri")) + { + uri = voice_credentials["channel_uri"].asString(); + } + if (voice_credentials.has("channel_credentials")) + { + credentials = + voice_credentials["channel_credentials"].asString(); + } + } + + LL_INFOS("Voice") << "Voice URI is " << uri << LL_ENDL; + + // set the spatial channel. If no voice credentials or uri are + // available, then we simply drop out of voice spatially. + if (parcelVoiceInfoReceived(requestingState)) + { + setSpatialChannel(uri, credentials); + } + +} + void LLVivoxVoiceClient::switchChannel( std::string uri, bool spatial, diff --git a/indra/newview/llvoicevivox.h b/indra/newview/llvoicevivox.h index a4ec9f2a69..8fd3d955fe 100755 --- a/indra/newview/llvoicevivox.h +++ b/indra/newview/llvoicevivox.h @@ -37,6 +37,8 @@ class LLVivoxProtocolParser; #include "llframetimer.h" #include "llviewerregion.h" #include "llcallingcard.h" // for LLFriendObserver +#include "lleventcoro.h" +#include "llcoros.h" #ifdef LL_USESYSTEMLIBS # include "expat.h" @@ -635,6 +637,8 @@ protected: void accountGetTemplateFontsResponse(int statusCode, const std::string &statusString); private: + void parcelVoiceInfoRequestCoro(LLCoros::self& self, std::string &url); + LLVoiceVersionInfo mVoiceVersion; /// Clean up objects created during a voice session. -- cgit v1.2.3 From 732fceca673c4d33253e1f49353eaa40b7079339 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 15 May 2015 16:48:03 -0700 Subject: Coroutine voice account provision --- indra/newview/llvoicevivox.cpp | 105 ++++++++++++++++------------------------- indra/newview/llvoicevivox.h | 4 +- 2 files changed, 42 insertions(+), 67 deletions(-) (limited to 'indra') diff --git a/indra/newview/llvoicevivox.cpp b/indra/newview/llvoicevivox.cpp index 8b24ce1c47..6d8f48b705 100755 --- a/indra/newview/llvoicevivox.cpp +++ b/indra/newview/llvoicevivox.cpp @@ -124,66 +124,6 @@ static int scale_speaker_volume(float volume) } -class LLVivoxVoiceAccountProvisionResponder : - public LLHTTPClient::Responder -{ - LOG_CLASS(LLVivoxVoiceAccountProvisionResponder); -public: - LLVivoxVoiceAccountProvisionResponder(int retries) - { - mRetries = retries; - } - -private: - /* virtual */ void httpFailure() - { - LL_WARNS("Voice") << "ProvisionVoiceAccountRequest returned an error, " - << ( (mRetries > 0) ? "retrying" : "too many retries (giving up)" ) - << " " << dumpResponse() << LL_ENDL; - - if ( mRetries > 0 ) - { - LLVivoxVoiceClient::getInstance()->requestVoiceAccountProvision(mRetries - 1); - } - else - { - LLVivoxVoiceClient::getInstance()->giveUp(); - } - } - - /* virtual */ void httpSuccess() - { - std::string voice_sip_uri_hostname; - std::string voice_account_server_uri; - - LL_DEBUGS("Voice") << "ProvisionVoiceAccountRequest response:" << dumpResponse() << LL_ENDL; - - const LLSD& content = getContent(); - if (!content.isMap()) - { - failureResult(HTTP_INTERNAL_ERROR, "Malformed response contents", content); - return; - } - if(content.has("voice_sip_uri_hostname")) - voice_sip_uri_hostname = content["voice_sip_uri_hostname"].asString(); - - // this key is actually misnamed -- it will be an entire URI, not just a hostname. - if(content.has("voice_account_server_name")) - voice_account_server_uri = content["voice_account_server_name"].asString(); - - LLVivoxVoiceClient::getInstance()->login( - content["username"].asString(), - content["password"].asString(), - voice_sip_uri_hostname, - voice_account_server_uri); - } - -private: - int mRetries; -}; - - - /////////////////////////////////////////////////////////////////////////////////////////////// class LLVivoxVoiceClientMuteListObserver : public LLMuteListObserver @@ -505,16 +445,51 @@ void LLVivoxVoiceClient::requestVoiceAccountProvision(S32 retries) if ( !url.empty() ) { - LLHTTPClient::post( - url, - LLSD(), - new LLVivoxVoiceAccountProvisionResponder(retries)); - + LLCoros::instance().launch("LLVivoxVoiceClient::voiceAccountProvisionCoro", + boost::bind(&LLVivoxVoiceClient::voiceAccountProvisionCoro, this, _1, url, retries)); setState(stateConnectorStart); } } } +void LLVivoxVoiceClient::voiceAccountProvisionCoro(LLCoros::self& self, std::string &url, S32 retries) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("voiceAccountProvision", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + LLCore::HttpOptions::ptr_t httpOpts = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions); + + httpOpts->setRetries(retries); + + LLSD result = httpAdapter->postAndYield(self, httpRequest, url, LLSD(), httpOpts); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + + if (!status) + { + LL_WARNS("Voice") << "Unable to provision voice account." << LL_ENDL; + giveUp(); + return; + } + + std::string voice_sip_uri_hostname; + std::string voice_account_server_uri; + + //LL_DEBUGS("Voice") << "ProvisionVoiceAccountRequest response:" << dumpResponse() << LL_ENDL; + + if (result.has("voice_sip_uri_hostname")) + voice_sip_uri_hostname = result["voice_sip_uri_hostname"].asString(); + + // this key is actually misnamed -- it will be an entire URI, not just a hostname. + if (result.has("voice_account_server_name")) + voice_account_server_uri = result["voice_account_server_name"].asString(); + + login(result["username"].asString(), result["password"].asString(), + voice_sip_uri_hostname, voice_account_server_uri); +} + void LLVivoxVoiceClient::login( const std::string& account_name, const std::string& password, diff --git a/indra/newview/llvoicevivox.h b/indra/newview/llvoicevivox.h index 8fd3d955fe..5e20351e73 100755 --- a/indra/newview/llvoicevivox.h +++ b/indra/newview/llvoicevivox.h @@ -48,7 +48,6 @@ class LLVivoxProtocolParser; #include "llvoiceclient.h" class LLAvatarName; -class LLVivoxVoiceAccountProvisionResponder; class LLVivoxVoiceClientMuteListObserver; @@ -253,7 +252,6 @@ protected: ////////////////////// // Vivox Specific definitions - friend class LLVivoxVoiceAccountProvisionResponder; friend class LLVivoxVoiceClientMuteListObserver; friend class LLVivoxVoiceClientFriendsObserver; @@ -637,6 +635,8 @@ protected: void accountGetTemplateFontsResponse(int statusCode, const std::string &statusString); private: + + void voiceAccountProvisionCoro(LLCoros::self& self, std::string &url, S32 retries); void parcelVoiceInfoRequestCoro(LLCoros::self& self, std::string &url); LLVoiceVersionInfo mVoiceVersion; -- cgit v1.2.3 From 225612ea77b843e58e11ccb00165155cc907ae1b Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 18 May 2015 11:48:50 -0700 Subject: Updater to coroutines. --- indra/viewer_components/updater/CMakeLists.txt | 3 + .../viewer_components/updater/llupdatechecker.cpp | 88 +++++++-------- indra/viewer_components/updater/llupdatechecker.h | 121 ++++++++++----------- 3 files changed, 104 insertions(+), 108 deletions(-) (limited to 'indra') diff --git a/indra/viewer_components/updater/CMakeLists.txt b/indra/viewer_components/updater/CMakeLists.txt index 61fd4220e0..2e284bf993 100755 --- a/indra/viewer_components/updater/CMakeLists.txt +++ b/indra/viewer_components/updater/CMakeLists.txt @@ -9,12 +9,14 @@ endif(LL_TESTS) include(CMakeCopyIfDifferent) include(CURL) include(LLCommon) +include(LLCoreHttp) include(LLMessage) include(LLPlugin) include(LLVFS) include_directories( ${LLCOMMON_INCLUDE_DIRS} + ${LLCOREHTTP_INCLUDE_DIRS} ${LLMESSAGE_INCLUDE_DIRS} ${LLPLUGIN_INCLUDE_DIRS} ${LLVFS_INCLUDE_DIRS} @@ -59,6 +61,7 @@ add_library(llupdaterservice target_link_libraries(llupdaterservice ${LLCOMMON_LIBRARIES} + ${LLCOREHTTP_LIBRARIES} ${LLMESSAGE_LIBRARIES} ${LLPLUGIN_LIBRARIES} ${LLVFS_LIBRARIES} diff --git a/indra/viewer_components/updater/llupdatechecker.cpp b/indra/viewer_components/updater/llupdatechecker.cpp index 8da4f88905..caeab35999 100755 --- a/indra/viewer_components/updater/llupdatechecker.cpp +++ b/indra/viewer_components/updater/llupdatechecker.cpp @@ -30,6 +30,7 @@ #include "llsd.h" #include "llupdatechecker.h" #include "lluri.h" +#include "llcorehttputil.h" #if LL_DARWIN #include #endif @@ -53,15 +54,12 @@ public: // LLUpdateChecker //----------------------------------------------------------------------------- - - LLUpdateChecker::LLUpdateChecker(LLUpdateChecker::Client & client): mImplementation(new LLUpdateChecker::Implementation(client)) { ; // No op. } - void LLUpdateChecker::checkVersion(std::string const & urlBase, std::string const & channel, std::string const & version, @@ -74,11 +72,8 @@ void LLUpdateChecker::checkVersion(std::string const & urlBase, } - // LLUpdateChecker::Implementation //----------------------------------------------------------------------------- - - const char * LLUpdateChecker::Implementation::sProtocolVersion = "v1.1"; @@ -121,57 +116,58 @@ void LLUpdateChecker::Implementation::checkVersion(std::string const & urlBase, std::string checkUrl = buildUrl(urlBase, channel, version, platform, platform_version, uniqueid, willing_to_test); LL_INFOS("UpdaterService") << "checking for updates at " << checkUrl << LL_ENDL; - - mHttpClient.get(checkUrl, this); - } - else - { - LL_WARNS("UpdaterService") << "attempting to restart a check when one is in progress; ignored" << LL_ENDL; - } -} -void LLUpdateChecker::Implementation::httpCompleted() -{ - mInProgress = false; + LLCoros::instance().launch("LLUpdateChecker::Implementation::checkVersionCoro", + boost::bind(&Implementation::checkVersionCoro, this, _1, checkUrl)); - S32 status = getStatus(); - const LLSD& content = getContent(); - const std::string& reason = getReason(); - if(status != 200) - { - std::string server_error; - if ( content.has("error_code") ) - { - server_error += content["error_code"].asString(); - } - if ( content.has("error_text") ) - { - server_error += server_error.empty() ? "" : ": "; - server_error += content["error_text"].asString(); - } - - LL_WARNS("UpdaterService") << "response error " << status - << " " << reason - << " (" << server_error << ")" - << LL_ENDL; - mClient.error(reason); } else { - mClient.response(content); + LL_WARNS("UpdaterService") << "attempting to restart a check when one is in progress; ignored" << LL_ENDL; } } - -void LLUpdateChecker::Implementation::httpFailure() +void LLUpdateChecker::Implementation::checkVersionCoro(LLCoros::self& self, std::string &url) { - const std::string& reason = getReason(); - mInProgress = false; - LL_WARNS("UpdaterService") << "update check failed; " << reason << LL_ENDL; - mClient.error(reason); + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("checkVersionCoro", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + + LL_INFOS("checkVersionCoro") << "Getting update information from " << url << LL_ENDL; + + LLSD result = httpAdapter->getAndYield(self, httpRequest, url); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + + mInProgress = false; + + if (status != LLCore::HttpStatus(HTTP_OK)) + { + std::string server_error; + if (result.has("error_code")) + { + server_error += result["error_code"].asString(); + } + if (result.has("error_text")) + { + server_error += server_error.empty() ? "" : ": "; + server_error += result["error_text"].asString(); + } + + LL_WARNS("UpdaterService") << "response error " << status.getStatus() + << " " << status.toString() + << " (" << server_error << ")" + << LL_ENDL; + mClient.error(status.toString()); + return; + } + + result.erase(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS); + mClient.response(result); } - std::string LLUpdateChecker::Implementation::buildUrl(std::string const & urlBase, std::string const & channel, std::string const & version, diff --git a/indra/viewer_components/updater/llupdatechecker.h b/indra/viewer_components/updater/llupdatechecker.h index 3163a6d53c..74af718a15 100755 --- a/indra/viewer_components/updater/llupdatechecker.h +++ b/indra/viewer_components/updater/llupdatechecker.h @@ -31,60 +31,27 @@ #include "llmd5.h" #include "llhttpclient.h" +#include "lleventcoro.h" +#include "llcoros.h" // // Implements asynchronous checking for updates. // class LLUpdateChecker { public: - class Client; - class Implementation: public LLHTTPClient::Responder - { - public: - Implementation(Client & client); - ~Implementation(); - void checkVersion(std::string const & urlBase, - std::string const & channel, - std::string const & version, - std::string const & platform, - std::string const & platform_version, - unsigned char uniqueid[MD5HEX_STR_SIZE], - bool willing_to_test - ); - - protected: - // Responder: - virtual void httpCompleted(); - virtual void httpFailure(); - - private: - static const char * sLegacyProtocolVersion; - static const char * sProtocolVersion; - const char* mProtocol; - - Client & mClient; - LLHTTPClient mHttpClient; - bool mInProgress; - std::string mVersion; - std::string mUrlBase; - std::string mChannel; - std::string mPlatform; - std::string mPlatformVersion; - unsigned char mUniqueId[MD5HEX_STR_SIZE]; - bool mWillingToTest; - - std::string buildUrl(std::string const & urlBase, - std::string const & channel, - std::string const & version, - std::string const & platform, - std::string const & platform_version, - unsigned char uniqueid[MD5HEX_STR_SIZE], - bool willing_to_test); - - LOG_CLASS(LLUpdateChecker::Implementation); - }; + // + // The client interface implemented by a requestor checking for an update. + // + class Client + { + public: + // An error occurred while checking for an update. + virtual void error(std::string const & message) = 0; + + // A successful response was received from the viewer version manager + virtual void response(LLSD const & content) = 0; + }; - // An exception that may be raised on check errors. class CheckError; @@ -100,25 +67,55 @@ public: bool willing_to_test); private: - LLPointer mImplementation; -}; + class Implementation + { + public: + typedef boost::shared_ptr ptr_t; + Implementation(Client & client); + ~Implementation(); + void checkVersion(std::string const & urlBase, + std::string const & channel, + std::string const & version, + std::string const & platform, + std::string const & platform_version, + unsigned char uniqueid[MD5HEX_STR_SIZE], + bool willing_to_test + ); -class LLURI; // From lluri.h + private: + static const char * sLegacyProtocolVersion; + static const char * sProtocolVersion; + const char* mProtocol; -// -// The client interface implemented by a requestor checking for an update. -// -class LLUpdateChecker::Client -{ -public: - // An error occurred while checking for an update. - virtual void error(std::string const & message) = 0; - - // A successful response was received from the viewer version manager - virtual void response(LLSD const & content) = 0; -}; + Client & mClient; + LLHTTPClient mHttpClient; + bool mInProgress; + std::string mVersion; + std::string mUrlBase; + std::string mChannel; + std::string mPlatform; + std::string mPlatformVersion; + unsigned char mUniqueId[MD5HEX_STR_SIZE]; + bool mWillingToTest; + + std::string buildUrl(std::string const & urlBase, + std::string const & channel, + std::string const & version, + std::string const & platform, + std::string const & platform_version, + unsigned char uniqueid[MD5HEX_STR_SIZE], + bool willing_to_test); + + void checkVersionCoro(LLCoros::self& self, std::string &url); + LOG_CLASS(LLUpdateChecker::Implementation); + }; + + + Implementation::ptr_t mImplementation; + //LLPointer mImplementation; +}; #endif -- cgit v1.2.3 From 46a86ddb7a59c2b82135c66e8855cfa84d25bf25 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 18 May 2015 13:39:48 -0700 Subject: Remove an unused variable from the updatechecker. --- indra/viewer_components/updater/llupdatechecker.h | 1 - 1 file changed, 1 deletion(-) (limited to 'indra') diff --git a/indra/viewer_components/updater/llupdatechecker.h b/indra/viewer_components/updater/llupdatechecker.h index 74af718a15..0f9be14524 100755 --- a/indra/viewer_components/updater/llupdatechecker.h +++ b/indra/viewer_components/updater/llupdatechecker.h @@ -90,7 +90,6 @@ private: const char* mProtocol; Client & mClient; - LLHTTPClient mHttpClient; bool mInProgress; std::string mVersion; std::string mUrlBase; -- cgit v1.2.3 From 5fbd84a210e84be165d2e5bcf85daf5a22b32f96 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 18 May 2015 14:15:51 -0700 Subject: Parcel Media and Viewer Parcel Mgr to generic coroutines. --- indra/newview/llviewerparcelmedia.cpp | 6 +++++- indra/newview/llviewerparcelmgr.cpp | 12 +++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) (limited to 'indra') diff --git a/indra/newview/llviewerparcelmedia.cpp b/indra/newview/llviewerparcelmedia.cpp index 37b249dddd..828271da7a 100755 --- a/indra/newview/llviewerparcelmedia.cpp +++ b/indra/newview/llviewerparcelmedia.cpp @@ -43,6 +43,7 @@ //#include "llfirstuse.h" #include "llpluginclassmedia.h" #include "llviewertexture.h" +#include "llcorehttputil.h" // Static Variables @@ -457,6 +458,7 @@ void LLViewerParcelMedia::processParcelMediaUpdate( LLMessageSystem *msg, void * } // Static ///////////////////////////////////////////////////////////////////////////////////////// +// *TODO: I can not find any active code where this method is called... void LLViewerParcelMedia::sendMediaNavigateMessage(const std::string& url) { std::string region_url = gAgent.getRegion()->getCapability("ParcelNavigateMedia"); @@ -467,7 +469,9 @@ void LLViewerParcelMedia::sendMediaNavigateMessage(const std::string& url) body["agent-id"] = gAgent.getID(); body["local-id"] = LLViewerParcelMgr::getInstance()->getAgentParcel()->getLocalID(); body["url"] = url; - LLHTTPClient::post(region_url, body, new LLHTTPClient::Responder); + + LLCoreHttpUtil::HttpCoroutineAdapter::messageHttpPost(region_url, body, + "Media Navigation sent to sim.", "Media Navigation failed to send to sim."); } else { diff --git a/indra/newview/llviewerparcelmgr.cpp b/indra/newview/llviewerparcelmgr.cpp index d9d4c34fb0..95a6a7f617 100755 --- a/indra/newview/llviewerparcelmgr.cpp +++ b/indra/newview/llviewerparcelmgr.cpp @@ -67,6 +67,7 @@ #include "roles_constants.h" #include "llweb.h" #include "llvieweraudio.h" +#include "llcorehttputil.h" const F32 PARCEL_COLLISION_DRAW_SECS = 1.f; @@ -1278,10 +1279,13 @@ const std::string& LLViewerParcelMgr::getAgentParcelName() const void LLViewerParcelMgr::sendParcelPropertiesUpdate(LLParcel* parcel, bool use_agent_region) { - if(!parcel) return; + if(!parcel) + return; LLViewerRegion *region = use_agent_region ? gAgent.getRegion() : LLWorld::getInstance()->getRegionFromPosGlobal( mWestSouth ); - if (!region) return; + if (!region) + return; + //LL_INFOS() << "found region: " << region->getName() << LL_ENDL; LLSD body; @@ -1294,7 +1298,9 @@ void LLViewerParcelMgr::sendParcelPropertiesUpdate(LLParcel* parcel, bool use_ag parcel->packMessage(body); LL_INFOS() << "Sending parcel properties update via capability to: " << url << LL_ENDL; - LLHTTPClient::post(url, body, new LLHTTPClient::Responder()); + + LLCoreHttpUtil::HttpCoroutineAdapter::messageHttpPost(url, body, + "Parcel Properties sent to sim.", "Parcel Properties failed to send to sim."); } else { -- cgit v1.2.3 From a4741cecb2112f418c1d98ca63a261e707a856c3 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 18 May 2015 16:18:07 -0700 Subject: Changed Avatar picker to use coroutine for find. Fixed a stray reference (&) on URL that had crept into some coroutine definitions. --- indra/llmessage/llcorehttputil.cpp | 4 +- indra/llmessage/llcorehttputil.h | 4 +- indra/newview/llfloateravatarpicker.cpp | 57 ++++++++++------------ indra/newview/llfloateravatarpicker.h | 3 ++ indra/newview/llvoavatarself.cpp | 2 +- indra/newview/llvoavatarself.h | 2 +- indra/newview/llvoicechannel.cpp | 2 +- indra/newview/llvoicechannel.h | 2 +- indra/newview/llvoicevivox.cpp | 4 +- indra/newview/llvoicevivox.h | 4 +- .../viewer_components/updater/llupdatechecker.cpp | 2 +- indra/viewer_components/updater/llupdatechecker.h | 2 +- 12 files changed, 44 insertions(+), 44 deletions(-) (limited to 'indra') diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index f8f5866355..cf34029dfe 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -747,7 +747,7 @@ void HttpCoroutineAdapter::messageHttpGet(const std::string &url, const std::str } /*static*/ -void HttpCoroutineAdapter::trivialGetCoro(LLCoros::self& self, std::string &url, completionCallback_t success, completionCallback_t failure) +void HttpCoroutineAdapter::trivialGetCoro(LLCoros::self& self, std::string url, completionCallback_t success, completionCallback_t failure) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -799,7 +799,7 @@ void HttpCoroutineAdapter::messageHttpPost(const std::string &url, const LLSD &p } /*static*/ -void HttpCoroutineAdapter::trivialPostCoro(LLCoros::self& self, std::string &url, LLSD postData, completionCallback_t success, completionCallback_t failure) +void HttpCoroutineAdapter::trivialPostCoro(LLCoros::self& self, std::string url, LLSD postData, completionCallback_t success, completionCallback_t failure) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t diff --git a/indra/llmessage/llcorehttputil.h b/indra/llmessage/llcorehttputil.h index 73a51fe83a..35e5b0aa2d 100644 --- a/indra/llmessage/llcorehttputil.h +++ b/indra/llmessage/llcorehttputil.h @@ -438,8 +438,8 @@ private: const std::string & url, LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler); - static void trivialGetCoro(LLCoros::self& self, std::string &url, completionCallback_t success, completionCallback_t failure); - static void trivialPostCoro(LLCoros::self& self, std::string &url, LLSD postData, completionCallback_t success, completionCallback_t failure); + static void trivialGetCoro(LLCoros::self& self, std::string url, completionCallback_t success, completionCallback_t failure); + static void trivialPostCoro(LLCoros::self& self, std::string url, LLSD postData, completionCallback_t success, completionCallback_t failure); std::string mAdapterName; LLCore::HttpRequest::priority_t mPriority; diff --git a/indra/newview/llfloateravatarpicker.cpp b/indra/newview/llfloateravatarpicker.cpp index 566a3c9cd3..84e3584331 100755 --- a/indra/newview/llfloateravatarpicker.cpp +++ b/indra/newview/llfloateravatarpicker.cpp @@ -52,6 +52,7 @@ #include "llfocusmgr.h" #include "lldraghandle.h" #include "message.h" +#include "llcorehttputil.h" //#include "llsdserialize.h" @@ -456,39 +457,33 @@ BOOL LLFloaterAvatarPicker::visibleItemsSelected() const return FALSE; } -class LLAvatarPickerResponder : public LLHTTPClient::Responder +/*static*/ +void LLFloaterAvatarPicker::findCoro(LLCoros::self& self, std::string url, LLUUID queryID, std::string name) { - LOG_CLASS(LLAvatarPickerResponder); -public: - LLUUID mQueryID; - std::string mName; + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("genericPostCoro", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLAvatarPickerResponder(const LLUUID& id, const std::string& name) : mQueryID(id), mName(name) { } + LL_INFOS("HttpCoroutineAdapter", "genericPostCoro") << "Generic POST for " << url << LL_ENDL; -protected: - /*virtual*/ void httpCompleted() - { - //std::ostringstream ss; - //LLSDSerialize::toPrettyXML(content, ss); - //LL_INFOS() << ss.str() << LL_ENDL; + LLSD result = httpAdapter->getAndYield(self, httpRequest, url); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + + if (status || (status == LLCore::HttpStatus(HTTP_BAD_REQUEST))) + { + LLFloaterAvatarPicker* floater = + LLFloaterReg::findTypedInstance("avatar_picker", name); + if (floater) + { + result.erase(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS); + floater->processResponse(queryID, result); + } + } +} - // in case of invalid characters, the avatar picker returns a 400 - // just set it to process so it displays 'not found' - if (isGoodStatus() || getStatus() == HTTP_BAD_REQUEST) - { - LLFloaterAvatarPicker* floater = - LLFloaterReg::findTypedInstance("avatar_picker", mName); - if (floater) - { - floater->processResponse(mQueryID, getContent()); - } - } - else - { - LL_WARNS() << "avatar picker failed " << dumpResponse() << LL_ENDL; - } - } -}; void LLFloaterAvatarPicker::find() { @@ -517,7 +512,9 @@ void LLFloaterAvatarPicker::find() std::replace(text.begin(), text.end(), '.', ' '); url += LLURI::escape(text); LL_INFOS() << "avatar picker " << url << LL_ENDL; - LLHTTPClient::get(url, new LLAvatarPickerResponder(mQueryID, getKey().asString())); + + LLCoros::instance().launch("LLFloaterAvatarPicker::findCoro", + boost::bind(&LLFloaterAvatarPicker::findCoro, _1, url, mQueryID, getKey().asString())); } else { diff --git a/indra/newview/llfloateravatarpicker.h b/indra/newview/llfloateravatarpicker.h index ed3e51c56f..200f74278e 100755 --- a/indra/newview/llfloateravatarpicker.h +++ b/indra/newview/llfloateravatarpicker.h @@ -28,6 +28,8 @@ #define LLFLOATERAVATARPICKER_H #include "llfloater.h" +#include "lleventcoro.h" +#include "llcoros.h" #include @@ -84,6 +86,7 @@ private: void populateFriend(); BOOL visibleItemsSelected() const; // Returns true if any items in the current tab are selected. + static void findCoro(LLCoros::self& self, std::string url, LLUUID mQueryID, std::string mName); void find(); void setAllowMultiple(BOOL allow_multiple); LLScrollListCtrl* getActiveList(); diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp index 3c18d11248..0d99c9ac14 100755 --- a/indra/newview/llvoavatarself.cpp +++ b/indra/newview/llvoavatarself.cpp @@ -2182,7 +2182,7 @@ const std::string LLVOAvatarSelf::debugDumpAllLocalTextureDataInfo() const return text; } -void LLVOAvatarSelf::appearanceChangeMetricsCoro(LLCoros::self& self, std::string &url) +void LLVOAvatarSelf::appearanceChangeMetricsCoro(LLCoros::self& self, std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t diff --git a/indra/newview/llvoavatarself.h b/indra/newview/llvoavatarself.h index 46f92763a2..b3b5fe6c2f 100755 --- a/indra/newview/llvoavatarself.h +++ b/indra/newview/llvoavatarself.h @@ -402,7 +402,7 @@ private: F32 mDebugBakedTextureTimes[LLAvatarAppearanceDefines::BAKED_NUM_INDICES][2]; // time to start upload and finish upload of each baked texture void debugTimingLocalTexLoaded(BOOL success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata); - void appearanceChangeMetricsCoro(LLCoros::self& self, std::string &url); + void appearanceChangeMetricsCoro(LLCoros::self& self, std::string url); bool mInitialMetric; S32 mMetricSequence; /** Diagnostics diff --git a/indra/newview/llvoicechannel.cpp b/indra/newview/llvoicechannel.cpp index a609f02710..fd1892e94b 100755 --- a/indra/newview/llvoicechannel.cpp +++ b/indra/newview/llvoicechannel.cpp @@ -605,7 +605,7 @@ void LLVoiceChannelGroup::setState(EState state) } } -void LLVoiceChannelGroup::voiceCallCapCoro(LLCoros::self& self, std::string &url) +void LLVoiceChannelGroup::voiceCallCapCoro(LLCoros::self& self, std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t diff --git a/indra/newview/llvoicechannel.h b/indra/newview/llvoicechannel.h index 13d73a51f8..0dac0b1f6a 100755 --- a/indra/newview/llvoicechannel.h +++ b/indra/newview/llvoicechannel.h @@ -159,7 +159,7 @@ protected: virtual void setState(EState state); private: - void voiceCallCapCoro(LLCoros::self& self, std::string &url); + void voiceCallCapCoro(LLCoros::self& self, std::string url); U32 mRetries; BOOL mIsRetrying; diff --git a/indra/newview/llvoicevivox.cpp b/indra/newview/llvoicevivox.cpp index 6d8f48b705..c70ce5801d 100755 --- a/indra/newview/llvoicevivox.cpp +++ b/indra/newview/llvoicevivox.cpp @@ -452,7 +452,7 @@ void LLVivoxVoiceClient::requestVoiceAccountProvision(S32 retries) } } -void LLVivoxVoiceClient::voiceAccountProvisionCoro(LLCoros::self& self, std::string &url, S32 retries) +void LLVivoxVoiceClient::voiceAccountProvisionCoro(LLCoros::self& self, std::string url, S32 retries) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -3933,7 +3933,7 @@ bool LLVivoxVoiceClient::requestParcelVoiceInfo() } } -void LLVivoxVoiceClient::parcelVoiceInfoRequestCoro(LLCoros::self& self, std::string &url) +void LLVivoxVoiceClient::parcelVoiceInfoRequestCoro(LLCoros::self& self, std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t diff --git a/indra/newview/llvoicevivox.h b/indra/newview/llvoicevivox.h index 5e20351e73..f00108050b 100755 --- a/indra/newview/llvoicevivox.h +++ b/indra/newview/llvoicevivox.h @@ -636,8 +636,8 @@ protected: private: - void voiceAccountProvisionCoro(LLCoros::self& self, std::string &url, S32 retries); - void parcelVoiceInfoRequestCoro(LLCoros::self& self, std::string &url); + void voiceAccountProvisionCoro(LLCoros::self& self, std::string url, S32 retries); + void parcelVoiceInfoRequestCoro(LLCoros::self& self, std::string url); LLVoiceVersionInfo mVoiceVersion; diff --git a/indra/viewer_components/updater/llupdatechecker.cpp b/indra/viewer_components/updater/llupdatechecker.cpp index caeab35999..e5d7d345cb 100755 --- a/indra/viewer_components/updater/llupdatechecker.cpp +++ b/indra/viewer_components/updater/llupdatechecker.cpp @@ -127,7 +127,7 @@ void LLUpdateChecker::Implementation::checkVersion(std::string const & urlBase, } } -void LLUpdateChecker::Implementation::checkVersionCoro(LLCoros::self& self, std::string &url) +void LLUpdateChecker::Implementation::checkVersionCoro(LLCoros::self& self, std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t diff --git a/indra/viewer_components/updater/llupdatechecker.h b/indra/viewer_components/updater/llupdatechecker.h index 0f9be14524..09ed306ca7 100755 --- a/indra/viewer_components/updater/llupdatechecker.h +++ b/indra/viewer_components/updater/llupdatechecker.h @@ -107,7 +107,7 @@ private: unsigned char uniqueid[MD5HEX_STR_SIZE], bool willing_to_test); - void checkVersionCoro(LLCoros::self& self, std::string &url); + void checkVersionCoro(LLCoros::self& self, std::string url); LOG_CLASS(LLUpdateChecker::Implementation); }; -- cgit v1.2.3 From 239bff71827c2467c953b4ee803a8e0b0348e32a Mon Sep 17 00:00:00 2001 From: Bjoseph Wombat Date: Tue, 19 May 2015 20:18:24 -0400 Subject: Changes to remove zlib and vivoxplatform dlls from the windows build --- indra/cmake/Copy3rdPartyLibs.cmake | 2 -- indra/newview/CMakeLists.txt | 2 -- indra/newview/llvoicevivox.cpp | 9 ++++++--- indra/newview/viewer_manifest.py | 2 -- 4 files changed, 6 insertions(+), 9 deletions(-) (limited to 'indra') diff --git a/indra/cmake/Copy3rdPartyLibs.cmake b/indra/cmake/Copy3rdPartyLibs.cmake index 84947adaae..79fbc90fbc 100755 --- a/indra/cmake/Copy3rdPartyLibs.cmake +++ b/indra/cmake/Copy3rdPartyLibs.cmake @@ -22,10 +22,8 @@ if(WINDOWS) SLVoice.exe ca-bundle.crt libsndfile-1.dll - vivoxplatform.dll vivoxsdk.dll ortp.dll - zlib1.dll vivoxoal.dll ) diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 13040ea423..0e3b802fc7 100755 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -1735,8 +1735,6 @@ if (WINDOWS) ${SHARED_LIB_STAGING_DIR}/${CMAKE_CFG_INTDIR}/vivoxsdk.dll ${SHARED_LIB_STAGING_DIR}/${CMAKE_CFG_INTDIR}/ortp.dll ${SHARED_LIB_STAGING_DIR}/${CMAKE_CFG_INTDIR}/libsndfile-1.dll - ${SHARED_LIB_STAGING_DIR}/${CMAKE_CFG_INTDIR}/zlib1.dll - ${SHARED_LIB_STAGING_DIR}/${CMAKE_CFG_INTDIR}/vivoxplatform.dll ${SHARED_LIB_STAGING_DIR}/${CMAKE_CFG_INTDIR}/vivoxoal.dll ${SHARED_LIB_STAGING_DIR}/${CMAKE_CFG_INTDIR}/ca-bundle.crt ${GOOGLE_PERF_TOOLS_SOURCE} diff --git a/indra/newview/llvoicevivox.cpp b/indra/newview/llvoicevivox.cpp index fc96b9e21d..da8f51bc03 100755 --- a/indra/newview/llvoicevivox.cpp +++ b/indra/newview/llvoicevivox.cpp @@ -3067,7 +3067,8 @@ void LLVivoxVoiceClient::sessionRemovedEvent( } else { - LL_WARNS("Voice") << "unknown session " << sessionHandle << " removed" << LL_ENDL; + // Already reaped this session. + LL_DEBUGS("Voice") << "unknown session " << sessionHandle << " removed" << LL_ENDL; } } @@ -3310,7 +3311,8 @@ void LLVivoxVoiceClient::mediaStreamUpdatedEvent( } else { - LL_WARNS("Voice") << "session " << sessionHandle << "not found"<< LL_ENDL; + // session disconnectintg and disconnected events arriving after we have already left the session. + LL_DEBUGS("Voice") << "session " << sessionHandle << " not found"<< LL_ENDL; } } @@ -3384,6 +3386,7 @@ void LLVivoxVoiceClient::participantRemovedEvent( } else { + // a late arriving event on a session we have already left. LL_DEBUGS("Voice") << "unknown session " << sessionHandle << LL_ENDL; } } @@ -3468,7 +3471,7 @@ void LLVivoxVoiceClient::participantUpdatedEvent( } else { - LL_INFOS("Voice") << "unknown session " << sessionHandle << LL_ENDL; + LL_DEBUGS("Voice") << "unknown session " << sessionHandle << LL_ENDL; } } diff --git a/indra/newview/viewer_manifest.py b/indra/newview/viewer_manifest.py index 32cf9d3df6..32c4350b40 100755 --- a/indra/newview/viewer_manifest.py +++ b/indra/newview/viewer_manifest.py @@ -396,8 +396,6 @@ class Windows_i686_Manifest(ViewerManifest): self.path("vivoxsdk.dll") self.path("ortp.dll") self.path("libsndfile-1.dll") - self.path("zlib1.dll") - self.path("vivoxplatform.dll") self.path("vivoxoal.dll") self.path("ca-bundle.crt") -- cgit v1.2.3 From c437a9c4ec865c38366c8057010d24311888ecb1 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 20 May 2015 17:37:27 -0700 Subject: Webprofile converted to coroutine. Added JSON->LLSD converter Added corohandler for JSON data --- indra/llcommon/CMakeLists.txt | 5 + indra/llcommon/llsdjson.cpp | 78 ++++++++ indra/llcommon/llsdjson.h | 59 ++++++ indra/llcorehttp/httpheaders.cpp | 18 ++ indra/llcorehttp/httpheaders.h | 6 +- indra/llmessage/CMakeLists.txt | 4 + indra/llmessage/llcorehttputil.cpp | 82 ++++++++ indra/llmessage/llcorehttputil.h | 12 ++ indra/newview/llwebprofile.cpp | 372 ++++++++++++++++++------------------- indra/newview/llwebprofile.h | 12 +- 10 files changed, 449 insertions(+), 199 deletions(-) create mode 100644 indra/llcommon/llsdjson.cpp create mode 100644 indra/llcommon/llsdjson.h (limited to 'indra') diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt index 1459b9ada2..9086691375 100755 --- a/indra/llcommon/CMakeLists.txt +++ b/indra/llcommon/CMakeLists.txt @@ -8,6 +8,7 @@ include(LLCommon) include(Linking) include(Boost) include(LLSharedLibs) +include(JsonCpp) include(GoogleBreakpad) include(GooglePerfTools) include(Copy3rdPartyLibs) @@ -17,6 +18,7 @@ include(URIPARSER) include_directories( ${EXPAT_INCLUDE_DIRS} ${LLCOMMON_INCLUDE_DIRS} + ${JSONCPP_INCLUDE_DIR} ${ZLIB_INCLUDE_DIRS} ${BREAKPAD_INCLUDE_DIRECTORIES} ${URIPARSER_INCLUDE_DIRS} @@ -85,6 +87,7 @@ set(llcommon_SOURCE_FILES llrefcount.cpp llrun.cpp llsd.cpp + llsdjson.cpp llsdparam.cpp llsdserialize.cpp llsdserialize_xml.cpp @@ -193,6 +196,7 @@ set(llcommon_HEADER_FILES llrefcount.h llsafehandle.h llsd.h + llsdjson.h llsdparam.h llsdserialize.h llsdserialize_xml.h @@ -260,6 +264,7 @@ target_link_libraries( ${APRUTIL_LIBRARIES} ${APR_LIBRARIES} ${EXPAT_LIBRARIES} + ${JSONCPP_LIBRARIES} ${ZLIB_LIBRARIES} ${WINDOWS_LIBRARIES} ${BOOST_PROGRAM_OPTIONS_LIBRARY} diff --git a/indra/llcommon/llsdjson.cpp b/indra/llcommon/llsdjson.cpp new file mode 100644 index 0000000000..2afdba388a --- /dev/null +++ b/indra/llcommon/llsdjson.cpp @@ -0,0 +1,78 @@ +/** + * @file llsdjson.cpp + * @brief LLSD flexible data system + * + * $LicenseInfo:firstyear=2015&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2015, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +// Must turn on conditional declarations in header file so definitions end up +// with proper linkage. +#define LLSD_DEBUG_INFO +#include "linden_common.h" + +#include "llsdjson.h" + +#include "llerror.h" +#include "../llmath/llmath.h" + +//========================================================================= +LLSD LlsdFromJson(const Json::Value &val) +{ + LLSD result; + + switch (val.type()) + { + default: + case Json::nullValue: + break; + case Json::intValue: + result = LLSD(static_cast(val.asInt())); + break; + case Json::uintValue: + result = LLSD(static_cast(val.asUInt())); + break; + case Json::realValue: + result = LLSD(static_cast(val.asDouble())); + break; + case Json::stringValue: + result = LLSD(static_cast(val.asString())); + break; + case Json::booleanValue: + result = LLSD(static_cast(val.asBool())); + break; + case Json::arrayValue: + result = LLSD::emptyArray(); + for (Json::ValueConstIterator it = val.begin(); it != val.end(); ++it) + { + result.append(LlsdFromJson((*it))); + } + break; + case Json::objectValue: + result = LLSD::emptyMap(); + for (Json::ValueConstIterator it = val.begin(); it != val.end(); ++it) + { + result[it.memberName()] = LlsdFromJson((*it)); + } + break; + } + return result; +} diff --git a/indra/llcommon/llsdjson.h b/indra/llcommon/llsdjson.h new file mode 100644 index 0000000000..cdf9fed500 --- /dev/null +++ b/indra/llcommon/llsdjson.h @@ -0,0 +1,59 @@ +/** + * @file llsdjson.cpp + * @brief LLSD flexible data system + * + * $LicenseInfo:firstyear=2015&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2015, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLSDJSON_H +#define LL_LLSDJSON_H + +#include +#include +#include + +#include "stdtypes.h" + +#include "llsd.h" +#include "value.h" + +/// Convert a parsed JSON structure into LLSD maintaining member names and +/// array indexes. +/// JSON/JavaScript types are converted as follows: +/// +/// JSON Type | LLSD Type +/// --------------+-------------- +/// null | undefined +/// integer | LLSD::Integer +/// unsigned | LLSD::Integer +/// real/numeric | LLSD::Real +/// string | LLSD::String +/// boolean | LLSD::Boolean +/// array | LLSD::Array +/// object | LLSD::Map +/// +/// For maps and arrays child entries will be converted and added to the structure. +/// Order is preserved for an array but not for objects. +LLSD LlsdFromJson(const Json::Value &val); + + +#endif // LL_LLSDJSON_H diff --git a/indra/llcorehttp/httpheaders.cpp b/indra/llcorehttp/httpheaders.cpp index 73c92c8f10..e03b1b080d 100755 --- a/indra/llcorehttp/httpheaders.cpp +++ b/indra/llcorehttp/httpheaders.cpp @@ -118,6 +118,24 @@ const std::string * HttpHeaders::find(const std::string &name) const return NULL; } +void HttpHeaders::remove(const char *name) +{ + remove(std::string(name)); +} + +void HttpHeaders::remove(const std::string &name) +{ + iterator iend(end()); + for (iterator iter(begin()); iend != iter; ++iter) + { + if ((*iter).first == name) + { + mHeaders.erase(iter); + return; + } + } +} + // Standard Iterators HttpHeaders::iterator HttpHeaders::begin() diff --git a/indra/llcorehttp/httpheaders.h b/indra/llcorehttp/httpheaders.h index 940f92183c..51bd76a01d 100755 --- a/indra/llcorehttp/httpheaders.h +++ b/indra/llcorehttp/httpheaders.h @@ -146,13 +146,17 @@ public: // a pointer to a std::string in the container. // Pointer is valid only for the lifetime of // the container or until container is modifed. - const std::string * find(const std::string &name) const; const std::string * find(const char * name) const { return find(std::string(name)); } + // Remove the header from the list if found. + // + void remove(const std::string &name); + void remove(const char *name); + // Count of headers currently in the list. size_type size() const { diff --git a/indra/llmessage/CMakeLists.txt b/indra/llmessage/CMakeLists.txt index f6ca6a3634..51b8ed6c62 100755 --- a/indra/llmessage/CMakeLists.txt +++ b/indra/llmessage/CMakeLists.txt @@ -14,6 +14,7 @@ include(LLAddBuildTest) include(Python) include(Tut) include(Python) +include(JsonCpp) include_directories (${CMAKE_CURRENT_SOURCE_DIR}) @@ -23,6 +24,7 @@ include_directories( ${LLMATH_INCLUDE_DIRS} ${LLMESSAGE_INCLUDE_DIRS} ${LLVFS_INCLUDE_DIRS} + ${JSONCPP_INCLUDE_DIR} ) set(llmessage_SOURCE_FILES @@ -229,6 +231,7 @@ target_link_libraries( ${LLVFS_LIBRARIES} ${LLMATH_LIBRARIES} ${CARES_LIBRARIES} + ${JSONCPP_LIBRARIES} ${OPENSSL_LIBRARIES} ${CRYPTO_LIBRARIES} ${XMLRPCEPI_LIBRARIES} @@ -254,6 +257,7 @@ if (LL_TESTS) ${LLCOMMON_LIBRARIES} ${LLMESSAGE_LIBRARIES} ${LLCOREHTTP_LIBRARIES} + ${JSONCPP_LIBRARIES} ${BOOST_CONTEXT_LIBRARY} ${BOOST_COROUTINE_LIBRARY} ${GOOGLEMOCK_LIBRARIES} diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index cf34029dfe..05d2e84f88 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -32,7 +32,10 @@ #include #include "llcorehttputil.h" #include "llhttpconstants.h" +#include "llsd.h" +#include "llsdjson.h" #include "llsdserialize.h" +#include "reader.h" using namespace LLCore; @@ -252,6 +255,23 @@ void HttpCoroHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRespons } buildStatusEntry(response, status, result); + +#if 0 + // commenting out, but keeping since this can be useful for debugging + if (!status) + { + LLSD &httpStatus = result[HttpCoroutineAdapter::HTTP_RESULTS]; + + LLCore::BufferArray *body = response->getBody(); + LLCore::BufferArrayStream bas(body); + LLSD::Binary bodyData; + bodyData.reserve(response->getBodySize()); + bas >> std::noskipws; + bodyData.assign(std::istream_iterator(bas), std::istream_iterator()); + httpStatus["error_body"] = bodyData; + } +#endif + mReplyPump.post(result); } @@ -437,6 +457,58 @@ LLSD HttpCoroRawHandler::handleSuccess(LLCore::HttpResponse * response, LLCore:: return result; } +//======================================================================== +/// The HttpCoroJSONHandler is a specialization of the LLCore::HttpHandler for +/// interacting with coroutines. +/// +/// In addition to the normal "http_results" the returned LLSD will contain +/// JSON entries will be converted into an LLSD map. All results are considered +/// strings +/// +class HttpCoroJSONHandler : public HttpCoroHandler +{ +public: + HttpCoroJSONHandler(LLEventStream &reply); + + virtual LLSD handleSuccess(LLCore::HttpResponse * response, LLCore::HttpStatus &status); +}; + +//------------------------------------------------------------------------- +HttpCoroJSONHandler::HttpCoroJSONHandler(LLEventStream &reply) : + HttpCoroHandler(reply) +{ +} + +LLSD HttpCoroJSONHandler::handleSuccess(LLCore::HttpResponse * response, LLCore::HttpStatus &status) +{ + LLSD result = LLSD::emptyMap(); + + BufferArray * body(response->getBody()); + if (!body || !body->size()) + { + return result; + } + + LLCore::BufferArrayStream bas(body); + Json::Value jsonRoot; + + try + { + bas >> jsonRoot; + } + catch (std::runtime_error e) + { // deserialization failed. Record the reason and pass back an empty map for markup. + status = LLCore::HttpStatus(499, std::string(e.what())); + return result; + } + + // Convert the JSON structure to LLSD + result = LlsdFromJson(jsonRoot); + + return result; +} + + //======================================================================== HttpRequestPumper::HttpRequestPumper(const LLCore::HttpRequest::ptr_t &request) : mHttpRequest(request) @@ -614,6 +686,16 @@ LLSD HttpCoroutineAdapter::getRawAndYield(LLCoros::self & self, LLCore::HttpRequ return getAndYield_(self, request, url, options, headers, httpHandler); } +LLSD HttpCoroutineAdapter::getJsonAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, + const std::string & url, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) +{ + LLEventStream replyPump(mAdapterName + "Reply", true); + HttpCoroHandler::ptr_t httpHandler = HttpCoroHandler::ptr_t(new HttpCoroJSONHandler(replyPump)); + + return getAndYield_(self, request, url, options, headers, httpHandler); +} + + LLSD HttpCoroutineAdapter::getAndYield_(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, const std::string & url, LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, diff --git a/indra/llmessage/llcorehttputil.h b/indra/llmessage/llcorehttputil.h index 35e5b0aa2d..d6219318f9 100644 --- a/indra/llmessage/llcorehttputil.h +++ b/indra/llmessage/llcorehttputil.h @@ -373,6 +373,18 @@ public: headers); } + LLSD getJsonAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, + const std::string & url, + LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false), + LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false)); + LLSD getJsonndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, + const std::string & url, LLCore::HttpHeaders::ptr_t &headers) + { + return getJsonAndYield(self, request, url, + LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false), + headers); + } + /// Execute a DELETE transaction on the supplied URL and yield execution of /// the coroutine until a result is available. diff --git a/indra/newview/llwebprofile.cpp b/indra/newview/llwebprofile.cpp index ddb7f7bfce..3d371e629f 100755 --- a/indra/newview/llwebprofile.cpp +++ b/indra/newview/llwebprofile.cpp @@ -34,10 +34,14 @@ #include "llimagepng.h" #include "llplugincookiestore.h" +#include "llsdserialize.h" + // newview #include "llpanelprofile.h" // for getProfileURL(). FIXME: move the method to LLAvatarActions #include "llviewermedia.h" // FIXME: don't use LLViewerMedia internals +#include "llcorehttputil.h" + // third-party #include "reader.h" // JSON @@ -54,139 +58,6 @@ * -> GET via PostImageRedirectResponder */ -/////////////////////////////////////////////////////////////////////////////// -// LLWebProfileResponders::ConfigResponder - -class LLWebProfileResponders::ConfigResponder : public LLHTTPClient::Responder -{ - LOG_CLASS(LLWebProfileResponders::ConfigResponder); - -public: - ConfigResponder(LLPointer imagep) - : mImagep(imagep) - { - } - - // *TODO: Check for 'application/json' content type, and parse json at the base class. - /*virtual*/ void completedRaw( - const LLChannelDescriptors& channels, - const LLIOPipe::buffer_ptr_t& buffer) - { - LLBufferStream istr(channels, buffer.get()); - std::stringstream strstrm; - strstrm << istr.rdbuf(); - const std::string body = strstrm.str(); - - if (getStatus() != HTTP_OK) - { - LL_WARNS() << "Failed to get upload config " << dumpResponse() << LL_ENDL; - LLWebProfile::reportImageUploadStatus(false); - return; - } - - Json::Value root; - Json::Reader reader; - if (!reader.parse(body, root)) - { - LL_WARNS() << "Failed to parse upload config: " << reader.getFormatedErrorMessages() << LL_ENDL; - LLWebProfile::reportImageUploadStatus(false); - return; - } - - // *TODO: 404 = not supported by the grid - // *TODO: increase timeout or handle 499 Expired - - // Convert config to LLSD. - const Json::Value data = root["data"]; - const std::string upload_url = root["url"].asString(); - LLSD config; - config["acl"] = data["acl"].asString(); - config["AWSAccessKeyId"] = data["AWSAccessKeyId"].asString(); - config["Content-Type"] = data["Content-Type"].asString(); - config["key"] = data["key"].asString(); - config["policy"] = data["policy"].asString(); - config["success_action_redirect"] = data["success_action_redirect"].asString(); - config["signature"] = data["signature"].asString(); - config["add_loc"] = data.get("add_loc", "0").asString(); - config["caption"] = data.get("caption", "").asString(); - - // Do the actual image upload using the configuration. - LL_DEBUGS("Snapshots") << "Got upload config, POSTing image to " << upload_url << ", config=[" << config << "]" << LL_ENDL; - LLWebProfile::post(mImagep, config, upload_url); - } - -private: - LLPointer mImagep; -}; - -/////////////////////////////////////////////////////////////////////////////// -// LLWebProfilePostImageRedirectResponder -class LLWebProfileResponders::PostImageRedirectResponder : public LLHTTPClient::Responder -{ - LOG_CLASS(LLWebProfileResponders::PostImageRedirectResponder); - -public: - /*virtual*/ void completedRaw( - const LLChannelDescriptors& channels, - const LLIOPipe::buffer_ptr_t& buffer) - { - if (getStatus() != HTTP_OK) - { - LL_WARNS() << "Failed to upload image " << dumpResponse() << LL_ENDL; - LLWebProfile::reportImageUploadStatus(false); - return; - } - - LLBufferStream istr(channels, buffer.get()); - std::stringstream strstrm; - strstrm << istr.rdbuf(); - const std::string body = strstrm.str(); - LL_INFOS() << "Image uploaded." << LL_ENDL; - LL_DEBUGS("Snapshots") << "Uploading image succeeded. Response: [" << body << "]" << LL_ENDL; - LLWebProfile::reportImageUploadStatus(true); - } -}; - - -/////////////////////////////////////////////////////////////////////////////// -// LLWebProfileResponders::PostImageResponder -class LLWebProfileResponders::PostImageResponder : public LLHTTPClient::Responder -{ - LOG_CLASS(LLWebProfileResponders::PostImageResponder); - -public: - /*virtual*/ void completedRaw(const LLChannelDescriptors& channels, - const LLIOPipe::buffer_ptr_t& buffer) - { - // Viewer seems to fail to follow a 303 redirect on POST request - // (URLRequest Error: 65, Send failed since rewinding of the data stream failed). - // Handle it manually. - if (getStatus() == HTTP_SEE_OTHER) - { - LLSD headers = LLViewerMedia::getHeaders(); - headers[HTTP_OUT_HEADER_COOKIE] = LLWebProfile::getAuthCookie(); - const std::string& redir_url = getResponseHeader(HTTP_IN_HEADER_LOCATION); - if (redir_url.empty()) - { - LL_WARNS() << "Received empty redirection URL " << dumpResponse() << LL_ENDL; - LL_DEBUGS("Snapshots") << "[headers:" << getResponseHeaders() << "]" << LL_ENDL; - LLWebProfile::reportImageUploadStatus(false); - } - else - { - LL_DEBUGS("Snapshots") << "Got redirection URL: " << redir_url << LL_ENDL; - LLHTTPClient::get(redir_url, new LLWebProfileResponders::PostImageRedirectResponder, headers); - } - } - else - { - LL_WARNS() << "Unexpected POST response " << dumpResponse() << LL_ENDL; - LL_DEBUGS("Snapshots") << "[headers:" << getResponseHeaders() << "]" << LL_ENDL; - LLWebProfile::reportImageUploadStatus(false); - } - } -}; - /////////////////////////////////////////////////////////////////////////////// // LLWebProfile @@ -196,15 +67,9 @@ LLWebProfile::status_callback_t LLWebProfile::mStatusCallback; // static void LLWebProfile::uploadImage(LLPointer image, const std::string& caption, bool add_location) { - // Get upload configuration data. - std::string config_url(getProfileURL(LLStringUtil::null) + "snapshots/s3_upload_config"); - config_url += "?caption=" + LLURI::escape(caption); - config_url += "&add_loc=" + std::string(add_location ? "1" : "0"); - - LL_DEBUGS("Snapshots") << "Requesting " << config_url << LL_ENDL; - LLSD headers = LLViewerMedia::getHeaders(); - headers[HTTP_OUT_HEADER_COOKIE] = getAuthCookie(); - LLHTTPClient::get(config_url, new LLWebProfileResponders::ConfigResponder(image), headers); + LLCoros::instance().launch("LLWebProfile::uploadImageCoro", + boost::bind(&LLWebProfile::uploadImageCoro, _1, image, caption, add_location)); + } // static @@ -214,74 +79,193 @@ void LLWebProfile::setAuthCookie(const std::string& cookie) sAuthCookie = cookie; } -// static -void LLWebProfile::post(LLPointer image, const LLSD& config, const std::string& url) + +/*static*/ +LLCore::HttpHeaders::ptr_t LLWebProfile::buildDefaultHeaders() { - if (dynamic_cast(image.get()) == 0) - { - LL_WARNS() << "Image to upload is not a PNG" << LL_ENDL; - llassert(dynamic_cast(image.get()) != 0); - return; - } + LLCore::HttpHeaders::ptr_t httpHeaders(new LLCore::HttpHeaders); + LLSD headers = LLViewerMedia::getHeaders(); - const std::string boundary = "----------------------------0123abcdefab"; + for (LLSD::map_iterator it = headers.beginMap(); it != headers.endMap(); ++it) + { + httpHeaders->append((*it).first, (*it).second.asStringRef()); + } - LLSD headers = LLViewerMedia::getHeaders(); - headers[HTTP_OUT_HEADER_COOKIE] = getAuthCookie(); - headers[HTTP_OUT_HEADER_CONTENT_TYPE] = "multipart/form-data; boundary=" + boundary; + return httpHeaders; +} - std::ostringstream body; - // *NOTE: The order seems to matter. - body << "--" << boundary << "\r\n" - << "Content-Disposition: form-data; name=\"key\"\r\n\r\n" - << config["key"].asString() << "\r\n"; +/*static*/ +void LLWebProfile::uploadImageCoro(LLCoros::self& self, LLPointer image, std::string caption, bool addLocation) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("genericPostCoro", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); + LLCore::HttpHeaders::ptr_t httpHeaders; + + if (dynamic_cast(image.get()) == 0) + { + LL_WARNS() << "Image to upload is not a PNG" << LL_ENDL; + llassert(dynamic_cast(image.get()) != 0); + return; + } + + httpOpts->setWantHeaders(true); + + // Get upload configuration data. + std::string configUrl(getProfileURL(std::string()) + "snapshots/s3_upload_config"); + configUrl += "?caption=" + LLURI::escape(caption); + configUrl += "&add_loc=" + std::string(addLocation ? "1" : "0"); + + LL_DEBUGS("Snapshots") << "Requesting " << configUrl << LL_ENDL; + + httpHeaders = buildDefaultHeaders(); + httpHeaders->append(HTTP_OUT_HEADER_COOKIE, getAuthCookie()); + + LLSD result = httpAdapter->getJsonAndYield(self, httpRequest, configUrl, httpOpts, httpHeaders); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + + if (!status) + { + std::ostringstream ostm; + LLSDSerialize::toPrettyXML(httpResults, ostm); + LL_WARNS("Snapshots") << "Failed to get image upload config" << LL_ENDL; + LL_WARNS("Snapshots") << ostm.str() << LL_ENDL; + LLWebProfile::reportImageUploadStatus(false); + return; + } + + // Ready to build our image post body. + + const LLSD &data = result["data"]; + const std::string &uploadUrl = result["url"].asStringRef(); + const std::string boundary = "----------------------------0123abcdefab"; + + // a new set of headers. + httpHeaders = buildDefaultHeaders(); + httpHeaders->append(HTTP_OUT_HEADER_COOKIE, getAuthCookie()); + httpHeaders->remove(HTTP_OUT_HEADER_CONTENT_TYPE); + httpHeaders->append(HTTP_OUT_HEADER_CONTENT_TYPE, "multipart/form-data; boundary=" + boundary); + + LLCore::BufferArray::ptr_t body = LLWebProfile::buildPostData(data, image, boundary); + + result = httpAdapter->postAndYield(self, httpRequest, uploadUrl, body, httpOpts, httpHeaders); + + { + std::ostringstream ostm; + LLSDSerialize::toPrettyXML(result, ostm); + LL_WARNS("Snapshots") << ostm.str() << LL_ENDL; + } + body.reset(); + httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + + if (!status && (status != LLCore::HttpStatus(HTTP_SEE_OTHER))) + { + LL_WARNS("Snapshots") << "Failed to upload image data." << LL_ENDL; + LLWebProfile::reportImageUploadStatus(false); + return; + } + + LLSD resultHeaders = httpResults[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS_HEADERS]; + + httpHeaders = buildDefaultHeaders(); + httpHeaders->append(HTTP_OUT_HEADER_COOKIE, getAuthCookie()); + + const std::string& redirUrl = resultHeaders[HTTP_IN_HEADER_LOCATION].asStringRef(); + + if (redirUrl.empty()) + { + LL_WARNS("Snapshots") << "Received empty redirection URL in post image." << LL_ENDL; + LLWebProfile::reportImageUploadStatus(false); + } + + LL_DEBUGS("Snapshots") << "Got redirection URL: " << redirUrl << LL_ENDL; + + result = httpAdapter->getRawAndYield(self, httpRequest, redirUrl, httpOpts, httpHeaders); + + httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + + if (status != LLCore::HttpStatus(HTTP_OK)) + { + LL_WARNS("Snapshots") << "Failed to upload image." << LL_ENDL; + LLWebProfile::reportImageUploadStatus(false); + return; + } + + LLSD raw = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS_RAW]; +// const LLSD::Binary &rawBin = raw.asBinary(); +// std::istringstream rawresult(rawBin.begin(), rawBin.end()); + +// LLBufferStream istr(channels, buffer.get()); +// std::stringstream strstrm; +// strstrm << istr.rdbuf(); +// const std::string body = strstrm.str(); + LL_INFOS("Snapshots") << "Image uploaded." << LL_ENDL; + LL_DEBUGS("Snapshots") << "Uploading image succeeded. Response: [" << raw.asString() << "]" << LL_ENDL; + LLWebProfile::reportImageUploadStatus(true); - body << "--" << boundary << "\r\n" - << "Content-Disposition: form-data; name=\"AWSAccessKeyId\"\r\n\r\n" - << config["AWSAccessKeyId"].asString() << "\r\n"; - body << "--" << boundary << "\r\n" - << "Content-Disposition: form-data; name=\"acl\"\r\n\r\n" - << config["acl"].asString() << "\r\n"; +} - body << "--" << boundary << "\r\n" - << "Content-Disposition: form-data; name=\"Content-Type\"\r\n\r\n" - << config["Content-Type"].asString() << "\r\n"; +/*static*/ +LLCore::BufferArray::ptr_t LLWebProfile::buildPostData(const LLSD &data, LLPointer &image, const std::string &boundary) +{ + LLCore::BufferArray::ptr_t body(new LLCore::BufferArray); + LLCore::BufferArrayStream bas(body.get()); - body << "--" << boundary << "\r\n" - << "Content-Disposition: form-data; name=\"policy\"\r\n\r\n" - << config["policy"].asString() << "\r\n"; + // std::ostringstream body; - body << "--" << boundary << "\r\n" - << "Content-Disposition: form-data; name=\"signature\"\r\n\r\n" - << config["signature"].asString() << "\r\n"; + // *NOTE: The order seems to matter. + bas << "--" << boundary << "\r\n" + << "Content-Disposition: form-data; name=\"key\"\r\n\r\n" + << data["key"].asString() << "\r\n"; - body << "--" << boundary << "\r\n" - << "Content-Disposition: form-data; name=\"success_action_redirect\"\r\n\r\n" - << config["success_action_redirect"].asString() << "\r\n"; + bas << "--" << boundary << "\r\n" + << "Content-Disposition: form-data; name=\"AWSAccessKeyId\"\r\n\r\n" + << data["AWSAccessKeyId"].asString() << "\r\n"; - body << "--" << boundary << "\r\n" - << "Content-Disposition: form-data; name=\"file\"; filename=\"snapshot.png\"\r\n" - << "Content-Type: image/png\r\n\r\n"; + bas << "--" << boundary << "\r\n" + << "Content-Disposition: form-data; name=\"acl\"\r\n\r\n" + << data["acl"].asString() << "\r\n"; - // Insert the image data. - // *FIX: Treating this as a string will probably screw it up ... - U8* image_data = image->getData(); - for (S32 i = 0; i < image->getDataSize(); ++i) - { - body << image_data[i]; - } + bas << "--" << boundary << "\r\n" + << "Content-Disposition: form-data; name=\"Content-Type\"\r\n\r\n" + << data["Content-Type"].asString() << "\r\n"; + + bas << "--" << boundary << "\r\n" + << "Content-Disposition: form-data; name=\"policy\"\r\n\r\n" + << data["policy"].asString() << "\r\n"; + + bas << "--" << boundary << "\r\n" + << "Content-Disposition: form-data; name=\"signature\"\r\n\r\n" + << data["signature"].asString() << "\r\n"; + + bas << "--" << boundary << "\r\n" + << "Content-Disposition: form-data; name=\"success_action_redirect\"\r\n\r\n" + << data["success_action_redirect"].asString() << "\r\n"; + + bas << "--" << boundary << "\r\n" + << "Content-Disposition: form-data; name=\"file\"; filename=\"snapshot.png\"\r\n" + << "Content-Type: image/png\r\n\r\n"; - body << "\r\n--" << boundary << "--\r\n"; + // Insert the image data. + //char *datap = (char *)(image->getData()); + //bas.write(datap, image->getDataSize()); + U8* image_data = image->getData(); + for (S32 i = 0; i < image->getDataSize(); ++i) + { + bas << image_data[i]; + } - // postRaw() takes ownership of the buffer and releases it later. - size_t size = body.str().size(); - U8 *data = new U8[size]; - memcpy(data, body.str().data(), size); + bas << "\r\n--" << boundary << "--\r\n"; - // Send request, successful upload will trigger posting metadata. - LLHTTPClient::postRaw(url, data, size, new LLWebProfileResponders::PostImageResponder(), headers); + return body; } // static diff --git a/indra/newview/llwebprofile.h b/indra/newview/llwebprofile.h index 10279bffac..604ef7aff7 100755 --- a/indra/newview/llwebprofile.h +++ b/indra/newview/llwebprofile.h @@ -28,6 +28,10 @@ #define LL_LLWEBPROFILE_H #include "llimage.h" +#include "lleventcoro.h" +#include "llcoros.h" +#include "httpheaders.h" +#include "bufferarray.h" namespace LLWebProfileResponders { @@ -54,11 +58,11 @@ public: static void setImageUploadResultCallback(status_callback_t cb) { mStatusCallback = cb; } private: - friend class LLWebProfileResponders::ConfigResponder; - friend class LLWebProfileResponders::PostImageResponder; - friend class LLWebProfileResponders::PostImageRedirectResponder; + static LLCore::HttpHeaders::ptr_t buildDefaultHeaders(); + + static void uploadImageCoro(LLCoros::self& self, LLPointer image, std::string caption, bool add_location); + static LLCore::BufferArray::ptr_t buildPostData(const LLSD &data, LLPointer &image, const std::string &boundary); - static void post(LLPointer image, const LLSD& config, const std::string& url); static void reportImageUploadStatus(bool ok); static std::string getAuthCookie(); -- cgit v1.2.3 From ff121254b29ea628472faf1eda06058f06c050d1 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 22 May 2015 09:27:33 -0700 Subject: Removed dead HTTP client adapter code Partial conversion of group manager clean up some debug code in web profiles. --- indra/llmessage/CMakeLists.txt | 3 - indra/llmessage/llhttpclientadapter.cpp | 73 ------- indra/llmessage/llhttpclientadapter.h | 53 ----- indra/llmessage/tests/llhttpclientadapter_test.cpp | 222 --------------------- indra/llmessage/tests/lltesthttpclientadapter.cpp | 61 ------ indra/llmessage/tests/lltesthttpclientadapter.h | 57 ------ indra/newview/llgroupmgr.cpp | 183 ++++++++++++----- indra/newview/llgroupmgr.h | 18 +- indra/newview/llwebprofile.cpp | 24 +-- 9 files changed, 153 insertions(+), 541 deletions(-) delete mode 100755 indra/llmessage/llhttpclientadapter.cpp delete mode 100755 indra/llmessage/llhttpclientadapter.h delete mode 100755 indra/llmessage/tests/llhttpclientadapter_test.cpp delete mode 100755 indra/llmessage/tests/lltesthttpclientadapter.cpp delete mode 100755 indra/llmessage/tests/lltesthttpclientadapter.h (limited to 'indra') diff --git a/indra/llmessage/CMakeLists.txt b/indra/llmessage/CMakeLists.txt index 51b8ed6c62..abdb418224 100755 --- a/indra/llmessage/CMakeLists.txt +++ b/indra/llmessage/CMakeLists.txt @@ -48,7 +48,6 @@ set(llmessage_SOURCE_FILES llhost.cpp llhttpassetstorage.cpp llhttpclient.cpp - llhttpclientadapter.cpp llhttpconstants.cpp llhttpnode.cpp llhttpsdhandler.cpp @@ -143,7 +142,6 @@ set(llmessage_HEADER_FILES llhttpassetstorage.h llhttpclient.h llhttpclientinterface.h - llhttpclientadapter.h llhttpconstants.h llhttpnode.h llhttpnodeadapter.h @@ -281,7 +279,6 @@ if (LL_TESTS) LL_ADD_INTEGRATION_TEST(llavatarnamecache "" "${test_libs}") LL_ADD_INTEGRATION_TEST(llhost "" "${test_libs}") - LL_ADD_INTEGRATION_TEST(llhttpclientadapter "" "${test_libs}") LL_ADD_INTEGRATION_TEST(llpartdata "" "${test_libs}") LL_ADD_INTEGRATION_TEST(llxfer_file "" "${test_libs}") endif (LL_TESTS) diff --git a/indra/llmessage/llhttpclientadapter.cpp b/indra/llmessage/llhttpclientadapter.cpp deleted file mode 100755 index 8c2a0ad9cf..0000000000 --- a/indra/llmessage/llhttpclientadapter.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/** - * @file llhttpclientadapter.cpp - * @brief - * - * $LicenseInfo:firstyear=2009&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#include "llhttpclientadapter.h" -#include "llhttpclient.h" -// -// LLHTTPClientAdapter::~LLHTTPClientAdapter() -// { -// } -// -// void LLHTTPClientAdapter::get(const std::string& url, LLCurl::ResponderPtr responder) -// { -// LLSD empty_pragma_header; -// // Pragma is required to stop curl adding "no-cache" -// // Space is required to stop llurlrequest from turning off proxying -// empty_pragma_header[HTTP_OUT_HEADER_PRAGMA] = " "; -// LLHTTPClient::get(url, responder, empty_pragma_header); -// } -// -// void LLHTTPClientAdapter::get(const std::string& url, LLCurl::ResponderPtr responder, const LLSD& headers) -// { -// LLSD empty_pragma_header = headers; -// if (!empty_pragma_header.has(HTTP_OUT_HEADER_PRAGMA)) -// { -// // as above -// empty_pragma_header[HTTP_OUT_HEADER_PRAGMA] = " "; -// } -// LLHTTPClient::get(url, responder, empty_pragma_header); -// } -// -// void LLHTTPClientAdapter::put(const std::string& url, const LLSD& body, LLCurl::ResponderPtr responder) -// { -// LLHTTPClient::put(url, body, responder); -// } -// -// void LLHTTPClientAdapter::put( -// const std::string& url, -// const LLSD& body, -// LLCurl::ResponderPtr responder, -// const LLSD& headers) -// { -// LLHTTPClient::put(url, body, responder, headers); -// } -// -// void LLHTTPClientAdapter::del( -// const std::string& url, -// LLCurl::ResponderPtr responder) -// { -// LLHTTPClient::del(url, responder); -// } diff --git a/indra/llmessage/llhttpclientadapter.h b/indra/llmessage/llhttpclientadapter.h deleted file mode 100755 index 0067703895..0000000000 --- a/indra/llmessage/llhttpclientadapter.h +++ /dev/null @@ -1,53 +0,0 @@ -/** - * @file llhttpclientadepter.h - * @brief - * - * $LicenseInfo:firstyear=2008&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifndef LL_HTTPCLIENTADAPTER_H -#define LL_HTTPCLIENTADAPTER_H - -#include "llhttpclientinterface.h" -#include "llsingleton.h" // LLSingleton<> - -/* -class LLHTTPClientAdapter : public LLHTTPClientInterface, public LLSingleton -{ -public: - virtual ~LLHTTPClientAdapter(); - virtual void get(const std::string& url, LLCurl::ResponderPtr responder); - virtual void get(const std::string& url, LLCurl::ResponderPtr responder, const LLSD& headers); - virtual void put(const std::string& url, const LLSD& body, LLCurl::ResponderPtr responder); - virtual void put( - const std::string& url, - const LLSD& body, - LLCurl::ResponderPtr responder, - const LLSD& headers); - virtual void del( - const std::string& url, - LLCurl::ResponderPtr responder); -}; -*/ - -#endif - diff --git a/indra/llmessage/tests/llhttpclientadapter_test.cpp b/indra/llmessage/tests/llhttpclientadapter_test.cpp deleted file mode 100755 index e0a82e237b..0000000000 --- a/indra/llmessage/tests/llhttpclientadapter_test.cpp +++ /dev/null @@ -1,222 +0,0 @@ -/** - * @file llhttpclientadapter_test.cpp - * @brief Tests for LLHTTPClientAdapter - * - * $LicenseInfo:firstyear=2008&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ -#if 0 -#include "llhttpclientadapter.h" - -#include "../test/lltut.h" -#include "llhttpclient.h" -#include "llcurl_stub.cpp" - -float const HTTP_REQUEST_EXPIRY_SECS = 1.0F; - -std::vector get_urls; -std::vector< LLCurl::ResponderPtr > get_responders; -void LLHTTPClient::get(const std::string& url, LLCurl::ResponderPtr responder, const LLSD& headers, const F32 timeout, bool follow_redirects) -{ - get_urls.push_back(url); - get_responders.push_back(responder); -} - -std::vector put_urls; -std::vector put_body; -std::vector put_headers; -std::vector put_responders; - -void LLHTTPClient::put(const std::string& url, const LLSD& body, LLCurl::ResponderPtr responder, const LLSD& headers, const F32 timeout) -{ - put_urls.push_back(url); - put_responders.push_back(responder); - put_body.push_back(body); - put_headers.push_back(headers); - -} - -std::vector delete_urls; -std::vector delete_responders; - -void LLHTTPClient::del( - const std::string& url, - LLCurl::ResponderPtr responder, - const LLSD& headers, - const F32 timeout) -{ - delete_urls.push_back(url); - delete_responders.push_back(responder); -} - -namespace tut -{ - struct LLHTTPClientAdapterData - { - LLHTTPClientAdapterData() - { - get_urls.clear(); - get_responders.clear(); - put_urls.clear(); - put_responders.clear(); - put_body.clear(); - put_headers.clear(); - delete_urls.clear(); - delete_responders.clear(); - } - }; - - typedef test_group factory; - typedef factory::object object; -} - -namespace -{ - tut::factory tf("LLHTTPClientAdapterData"); -} - -namespace tut -{ - // Ensure we can create the object - template<> template<> - void object::test<1>() - { - LLHTTPClientAdapter adapter; - } - - // Does the get pass the appropriate arguments to the LLHTTPClient - template<> template<> - void object::test<2>() - { - LLHTTPClientAdapter adapter; - - LLCurl::ResponderPtr responder = new LLCurl::Responder(); - - adapter.get("Made up URL", responder); - ensure_equals(get_urls.size(), 1); - ensure_equals(get_urls[0], "Made up URL"); - } - - // Ensure the responder matches the one passed to get - template<> template<> - void object::test<3>() - { - LLHTTPClientAdapter adapter; - LLCurl::ResponderPtr responder = new LLCurl::Responder(); - - adapter.get("Made up URL", responder); - - ensure_equals(get_responders.size(), 1); - ensure_equals(get_responders[0].get(), responder.get()); - } - - // Ensure the correct url is used in the put - template<> template<> - void object::test<4>() - { - LLHTTPClientAdapter adapter; - - LLCurl::ResponderPtr responder = new LLCurl::Responder(); - - LLSD body; - body["TestBody"] = "Foobar"; - - adapter.put("Made up URL", body, responder); - ensure_equals(put_urls.size(), 1); - ensure_equals(put_urls[0], "Made up URL"); - } - - // Ensure the correct responder is used by put - template<> template<> - void object::test<5>() - { - LLHTTPClientAdapter adapter; - - LLCurl::ResponderPtr responder = new LLCurl::Responder(); - - LLSD body; - body["TestBody"] = "Foobar"; - - adapter.put("Made up URL", body, responder); - - ensure_equals(put_responders.size(), 1); - ensure_equals(put_responders[0].get(), responder.get()); - } - - // Ensure the message body is passed through the put properly - template<> template<> - void object::test<6>() - { - LLHTTPClientAdapter adapter; - - LLCurl::ResponderPtr responder = new LLCurl::Responder(); - - LLSD body; - body["TestBody"] = "Foobar"; - - adapter.put("Made up URL", body, responder); - - ensure_equals(put_body.size(), 1); - ensure_equals(put_body[0]["TestBody"].asString(), "Foobar"); - } - - // Ensure that headers are passed through put properly - template<> template<> - void object::test<7>() - { - LLHTTPClientAdapter adapter; - - LLCurl::ResponderPtr responder = new LLCurl::Responder(); - - LLSD body = LLSD::emptyMap(); - body["TestBody"] = "Foobar"; - - LLSD headers = LLSD::emptyMap(); - headers["booger"] = "omg"; - - adapter.put("Made up URL", body, responder, headers); - - ensure_equals("Header count", put_headers.size(), 1); - ensure_equals( - "First header", - put_headers[0]["booger"].asString(), - "omg"); - } - - // Ensure that del() passes appropriate arguments to the LLHTTPClient - template<> template<> - void object::test<8>() - { - LLHTTPClientAdapter adapter; - - LLCurl::ResponderPtr responder = new LLCurl::Responder(); - - adapter.del("Made up URL", responder); - - ensure_equals("URL count", delete_urls.size(), 1); - ensure_equals("Received URL", delete_urls[0], "Made up URL"); - - ensure_equals("Responder count", delete_responders.size(), 1); - //ensure_equals("Responder", delete_responders[0], responder); - } -} - -#endif \ No newline at end of file diff --git a/indra/llmessage/tests/lltesthttpclientadapter.cpp b/indra/llmessage/tests/lltesthttpclientadapter.cpp deleted file mode 100755 index 4539e4a540..0000000000 --- a/indra/llmessage/tests/lltesthttpclientadapter.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/** - * @file - * @brief - * - * $LicenseInfo:firstyear=2008&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ -#include "lltesthttpclientadapter.h" - -LLTestHTTPClientAdapter::LLTestHTTPClientAdapter() -{ -} - -LLTestHTTPClientAdapter::~LLTestHTTPClientAdapter() -{ -} - -void LLTestHTTPClientAdapter::get(const std::string& url, LLCurl::ResponderPtr responder) -{ - mGetUrl.push_back(url); - mGetResponder.push_back(responder); -} - -void LLTestHTTPClientAdapter::put(const std::string& url, const LLSD& body, LLCurl::ResponderPtr responder) -{ - mPutUrl.push_back(url); - mPutBody.push_back(body); - mPutResponder.push_back(responder); -} - -U32 LLTestHTTPClientAdapter::putCalls() const -{ - return mPutUrl.size(); -} - -void LLTestHTTPClientAdapter::get(const std::string& url, LLCurl::ResponderPtr responder, const LLSD& headers) -{ - mGetUrl.push_back(url); - mGetHeaders.push_back(headers); - mGetResponder.push_back(responder); -} - - diff --git a/indra/llmessage/tests/lltesthttpclientadapter.h b/indra/llmessage/tests/lltesthttpclientadapter.h deleted file mode 100755 index c29cbb3a2a..0000000000 --- a/indra/llmessage/tests/lltesthttpclientadapter.h +++ /dev/null @@ -1,57 +0,0 @@ -/** - * @file - * @brief - * - * $LicenseInfo:firstyear=2008&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -/* Macro Definitions */ -#ifndef LL_LLTESTHTTPCLIENTADAPTER_H -#define LL_LLTESTHTTPCLIENTADAPTER_H - - -#include "linden_common.h" -#include "llhttpclientinterface.h" - -class LLTestHTTPClientAdapter : public LLHTTPClientInterface -{ -public: - LLTestHTTPClientAdapter(); - virtual ~LLTestHTTPClientAdapter(); - virtual void get(const std::string& url, LLCurl::ResponderPtr responder); - virtual void get(const std::string& url, LLCurl::ResponderPtr responder, const LLSD& headers); - - virtual void put(const std::string& url, const LLSD& body, LLCurl::ResponderPtr responder); - U32 putCalls() const; - - std::vector mPutBody; - std::vector mGetHeaders; - std::vector mPutUrl; - std::vector mGetUrl; - std::vector mPutResponder; - std::vector mGetResponder; -}; - - - -#endif //LL_LLSIMULATORPRESENCESENDER_H - diff --git a/indra/newview/llgroupmgr.cpp b/indra/newview/llgroupmgr.cpp index 56e671d902..21220507e7 100755 --- a/indra/newview/llgroupmgr.cpp +++ b/indra/newview/llgroupmgr.cpp @@ -53,6 +53,7 @@ #include "lltrans.h" #include "llviewerregion.h" #include +#include "llcorehttputil.h" #if LL_MSVC #pragma warning(push) @@ -768,9 +769,9 @@ void LLGroupMgrGroupData::removeBanEntry(const LLUUID& ban_id) // LLGroupMgr // -LLGroupMgr::LLGroupMgr() +LLGroupMgr::LLGroupMgr(): + mMemberRequestInFlight(false) { - mLastGroupMembersRequestFrame = 0; } LLGroupMgr::~LLGroupMgr() @@ -1861,7 +1862,7 @@ void LLGroupMgr::sendGroupMemberEjects(const LLUUID& group_id, group_datap->mMemberVersion.generate(); } - +#if 1 // Responder class for capability group management class GroupBanDataResponder : public LLHTTPClient::Responder { @@ -1900,6 +1901,77 @@ void GroupBanDataResponder::httpSuccess() } } +#else +//void LLGroupMgr::groupBanRequestCoro(LLCoros::self& self, std::string url, LLUUID groupId, +// LLGroupMgr::EBanRequestAction action, uuid_vec_t banList) +void LLGroupMgr::groupBanRequestCoro(LLCoros::self& self, std::string url, LLUUID groupId, + LLGroupMgr::EBanRequestAction action, LLSD body) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("groupMembersRequest", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + + std::string finalUrl = url + "?group_id=" + groupId.asString(); + + EBanRequestAction currAction = action; + + do + { + LLSD result; + + if (currAction & (BAN_CREATE | BAN_DELETE)) // these two actions result in POSTS + { // build the post data. +// LLSD postData = LLSD::emptyMap(); +// +// postData["ban_action"] = (LLSD::Integer)(currAction & ~BAN_UPDATE); +// // Add our list of potential banned residents to the list +// postData["ban_ids"] = LLSD::emptyArray(); +// +// LLSD banEntry; +// for (uuid_vec_t::const_iterator it = banList.begin(); it != banList.end(); ++it) +// { +// banEntry = (*it); +// postData["ban_ids"].append(banEntry); +// } +// +// result = httpAdapter->postAndYield(self, httpRequest, finalUrl, postData); + + result = httpAdapter->postAndYield(self, httpRequest, finalUrl, body); + } + else + { + result = httpAdapter->getAndYield(self, httpRequest, finalUrl); + } + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + + if (!status) + { + LL_WARNS("GrpMgr") << "Error receiving group member data " << LL_ENDL; + return; + } + + if (result.has("ban_list")) + { + result.erase(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS); + // group ban data received + processGroupBanRequest(result); + } + + if (currAction & BAN_UPDATE) + { + currAction = BAN_NO_ACTION; + continue; + } + break; + } while (true); +} + +#endif + + void LLGroupMgr::sendGroupBanRequest( EBanRequestType request_type, const LLUUID& group_id, U32 ban_action, /* = BAN_NO_ACTION */ @@ -1925,7 +1997,32 @@ void LLGroupMgr::sendGroupBanRequest( EBanRequestType request_type, { return; } - cap_url += "?group_id=" + group_id.asString(); + +#if 0 + + LLSD body = LLSD::emptyMap(); + body["ban_action"] = (LLSD::Integer)(ban_action & ~BAN_UPDATE); + // Add our list of potential banned residents to the list + body["ban_ids"] = LLSD::emptyArray(); + LLSD ban_entry; + + uuid_vec_t::const_iterator iter = ban_list.begin(); + for (; iter != ban_list.end(); ++iter) + { + ban_entry = (*iter); + body["ban_ids"].append(ban_entry); + } + + LLCoros::instance().launch("LLGroupMgr::groupBanRequestCoro", + boost::bind(&LLGroupMgr::groupBanRequestCoro, this, _1, cap_url, group_id, + static_cast(ban_action), body)); + +// LLCoros::instance().launch("LLGroupMgr::groupBanRequestCoro", +// boost::bind(&LLGroupMgr::groupBanRequestCoro, this, _1, cap_url, group_id, +// static_cast(ban_action), ban_list)); + +#else + cap_url += "?group_id=" + group_id.asString(); LLSD body = LLSD::emptyMap(); body["ban_action"] = (LLSD::Integer)(ban_action & ~BAN_UPDATE); @@ -1953,9 +2050,9 @@ void LLGroupMgr::sendGroupBanRequest( EBanRequestType request_type, case REQUEST_DEL: break; } +#endif } - void LLGroupMgr::processGroupBanRequest(const LLSD& content) { // Did we get anything in content? @@ -1992,45 +2089,42 @@ void LLGroupMgr::processGroupBanRequest(const LLSD& content) LLGroupMgr::getInstance()->notifyObservers(GC_BANLIST); } +void LLGroupMgr::groupMembersRequestCoro(LLCoros::self& self, std::string url, LLUUID groupId) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("groupMembersRequest", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + LLCore::HttpOptions::ptr_t httpOpts = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions); + mMemberRequestInFlight = true; -// Responder class for capability group management -class GroupMemberDataResponder : public LLHTTPClient::Responder -{ - LOG_CLASS(GroupMemberDataResponder); -public: - GroupMemberDataResponder() {} - virtual ~GroupMemberDataResponder() {} + LLSD postData = LLSD::emptyMap(); + postData["group_id"] = groupId; -private: - /* virtual */ void httpSuccess(); - /* virtual */ void httpFailure(); - LLSD mMemberData; -}; + LLSD result = httpAdapter->postAndYield(self, httpRequest, url, postData, httpOpts); -void GroupMemberDataResponder::httpFailure() -{ - LL_WARNS("GrpMgr") << "Error receiving group member data " - << dumpResponse() << LL_ENDL; -} + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); -void GroupMemberDataResponder::httpSuccess() -{ - const LLSD& content = getContent(); - if (!content.isMap()) - { - failureResult(HTTP_INTERNAL_ERROR, "Malformed response contents", content); - return; - } - LLGroupMgr::processCapGroupMembersRequest(content); -} + if (!status) + { + LL_WARNS("GrpMgr") << "Error receiving group member data " << LL_ENDL; + mMemberRequestInFlight = false; + return; + } + result.erase(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS); + LLGroupMgr::processCapGroupMembersRequest(result); + mMemberRequestInFlight = false; +} -// static void LLGroupMgr::sendCapGroupMembersRequest(const LLUUID& group_id) { + static U32 lastGroupMemberRequestFrame = 0; + // Have we requested the information already this frame? - if(mLastGroupMembersRequestFrame == gFrameCount) + if ((lastGroupMemberRequestFrame == gFrameCount) || (mMemberRequestInFlight)) return; LLViewerRegion* currentRegion = gAgent.getRegion(); @@ -2059,20 +2153,13 @@ void LLGroupMgr::sendCapGroupMembersRequest(const LLUUID& group_id) return; } - // Post to our service. Add a body containing the group_id. - LLSD body = LLSD::emptyMap(); - body["group_id"] = group_id; - - LLHTTPClient::ResponderPtr grp_data_responder = new GroupMemberDataResponder(); - - // This could take a while to finish, timeout after 5 minutes. - LLHTTPClient::post(cap_url, body, grp_data_responder, LLSD(), 300); + lastGroupMemberRequestFrame = gFrameCount; - mLastGroupMembersRequestFrame = gFrameCount; + LLCoros::instance().launch("LLGroupMgr::groupMembersRequestCoro", + boost::bind(&LLGroupMgr::groupMembersRequestCoro, this, _1, cap_url, group_id)); } -// static void LLGroupMgr::processCapGroupMembersRequest(const LLSD& content) { // Did we get anything in content? @@ -2089,7 +2176,7 @@ void LLGroupMgr::processCapGroupMembersRequest(const LLSD& content) LLUUID group_id = content["group_id"].asUUID(); - LLGroupMgrGroupData* group_datap = LLGroupMgr::getInstance()->getGroupData(group_id); + LLGroupMgrGroupData* group_datap = getGroupData(group_id); if(!group_datap) { LL_WARNS("GrpMgr") << "Received incorrect, possibly stale, group or request id" << LL_ENDL; @@ -2183,7 +2270,7 @@ void LLGroupMgr::processCapGroupMembersRequest(const LLSD& content) // TODO: // Refactor to reduce multiple calls for data we already have. if(group_datap->mTitles.size() < 1) - LLGroupMgr::getInstance()->sendGroupTitlesRequest(group_id); + sendGroupTitlesRequest(group_id); group_datap->mMemberDataComplete = true; @@ -2192,11 +2279,11 @@ void LLGroupMgr::processCapGroupMembersRequest(const LLSD& content) if (group_datap->mPendingRoleMemberRequest || !group_datap->mRoleMemberDataComplete) { group_datap->mPendingRoleMemberRequest = false; - LLGroupMgr::getInstance()->sendGroupRoleMembersRequest(group_id); + sendGroupRoleMembersRequest(group_id); } group_datap->mChanged = TRUE; - LLGroupMgr::getInstance()->notifyObservers(GC_MEMBER_DATA); + notifyObservers(GC_MEMBER_DATA); } diff --git a/indra/newview/llgroupmgr.h b/indra/newview/llgroupmgr.h index 2e94e8d9a0..f41a637917 100755 --- a/indra/newview/llgroupmgr.h +++ b/indra/newview/llgroupmgr.h @@ -32,6 +32,8 @@ #include #include #include +#include "lleventcoro.h" +#include "llcoros.h" // Forward Declarations class LLMessageSystem; @@ -362,6 +364,7 @@ public: BAN_UPDATE = 4 }; + public: LLGroupMgr(); ~LLGroupMgr(); @@ -396,15 +399,13 @@ public: static void sendGroupMemberEjects(const LLUUID& group_id, uuid_vec_t& member_ids); - static void sendGroupBanRequest(EBanRequestType request_type, + void sendGroupBanRequest(EBanRequestType request_type, const LLUUID& group_id, U32 ban_action = BAN_NO_ACTION, const uuid_vec_t ban_list = uuid_vec_t()); - static void processGroupBanRequest(const LLSD& content); void sendCapGroupMembersRequest(const LLUUID& group_id); - static void processCapGroupMembersRequest(const LLSD& content); void cancelGroupRoleChanges(const LLUUID& group_id); @@ -427,6 +428,15 @@ public: void clearGroupData(const LLUUID& group_id); private: + friend class GroupBanDataResponder; + + void groupMembersRequestCoro(LLCoros::self& self, std::string url, LLUUID groupId); + void processCapGroupMembersRequest(const LLSD& content); + + //void groupBanRequestCoro(LLCoros::self& self, std::string url, LLUUID groupId, EBanRequestAction action, uuid_vec_t banList); + void groupBanRequestCoro(LLCoros::self& self, std::string url, LLUUID groupId, EBanRequestAction action, LLSD postBody); + static void processGroupBanRequest(const LLSD& content); + void notifyObservers(LLGroupChange gc); void notifyObserver(const LLUUID& group_id, LLGroupChange gc); void addGroup(LLGroupMgrGroupData* group_datap); @@ -442,7 +452,7 @@ private: typedef std::map observer_map_t; observer_map_t mParticularObservers; - S32 mLastGroupMembersRequestFrame; + bool mMemberRequestInFlight; }; diff --git a/indra/newview/llwebprofile.cpp b/indra/newview/llwebprofile.cpp index 3d371e629f..df5f4e3588 100755 --- a/indra/newview/llwebprofile.cpp +++ b/indra/newview/llwebprofile.cpp @@ -131,10 +131,7 @@ void LLWebProfile::uploadImageCoro(LLCoros::self& self, LLPointerappend(HTTP_OUT_HEADER_COOKIE, getAuthCookie()); httpHeaders->remove(HTTP_OUT_HEADER_CONTENT_TYPE); httpHeaders->append(HTTP_OUT_HEADER_CONTENT_TYPE, "multipart/form-data; boundary=" + boundary); @@ -155,11 +152,6 @@ void LLWebProfile::uploadImageCoro(LLCoros::self& self, LLPointerpostAndYield(self, httpRequest, uploadUrl, body, httpOpts, httpHeaders); - { - std::ostringstream ostm; - LLSDSerialize::toPrettyXML(result, ostm); - LL_WARNS("Snapshots") << ostm.str() << LL_ENDL; - } body.reset(); httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -173,7 +165,7 @@ void LLWebProfile::uploadImageCoro(LLCoros::self& self, LLPointerappend(HTTP_OUT_HEADER_COOKIE, getAuthCookie()); const std::string& redirUrl = resultHeaders[HTTP_IN_HEADER_LOCATION].asStringRef(); @@ -198,16 +190,10 @@ void LLWebProfile::uploadImageCoro(LLCoros::self& self, LLPointer Date: Fri, 22 May 2015 10:59:43 -0700 Subject: Floater IM Session to trivial coroutine. Changed debugging output from core utitl to string. --- indra/llmessage/llcorehttputil.cpp | 6 ++++-- indra/newview/llfloaterimsession.cpp | 26 ++++---------------------- 2 files changed, 8 insertions(+), 24 deletions(-) (limited to 'indra') diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index 05d2e84f88..001df9e385 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -264,11 +264,13 @@ void HttpCoroHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRespons LLCore::BufferArray *body = response->getBody(); LLCore::BufferArrayStream bas(body); - LLSD::Binary bodyData; + LLSD::String bodyData; bodyData.reserve(response->getBodySize()); bas >> std::noskipws; bodyData.assign(std::istream_iterator(bas), std::istream_iterator()); - httpStatus["error_body"] = bodyData; + httpStatus["error_body"] = LLSD(bodyData); + + LL_WARNS() << "Returned body=" << std::endl << httpStatus["error_body"].asString() << LL_ENDL; } #endif diff --git a/indra/newview/llfloaterimsession.cpp b/indra/newview/llfloaterimsession.cpp index fc7fcf3ab9..6623ce0f80 100755 --- a/indra/newview/llfloaterimsession.cpp +++ b/indra/newview/llfloaterimsession.cpp @@ -41,7 +41,6 @@ #include "llchicletbar.h" #include "lldonotdisturbnotificationstorage.h" #include "llfloaterreg.h" -#include "llhttpclient.h" #include "llfloateravatarpicker.h" #include "llfloaterimcontainer.h" // to replace separate IM Floaters with multifloater container #include "llinventoryfunctions.h" @@ -62,6 +61,7 @@ #include "llviewerchat.h" #include "llnotificationmanager.h" #include "llautoreplace.h" +#include "llcorehttputil.h" const F32 ME_TYPING_TIMEOUT = 4.0f; const F32 OTHER_TYPING_TIMEOUT = 9.0f; @@ -1178,26 +1178,6 @@ BOOL LLFloaterIMSession::isInviteAllowed() const || mIsP2PChat); } -class LLSessionInviteResponder : public LLHTTPClient::Responder -{ - LOG_CLASS(LLSessionInviteResponder); -public: - LLSessionInviteResponder(const LLUUID& session_id) - { - mSessionID = session_id; - } - -protected: - void httpFailure() - { - LL_WARNS() << "Error inviting all agents to session " << dumpResponse() << LL_ENDL; - //throw something back to the viewer here? - } - -private: - LLUUID mSessionID; -}; - BOOL LLFloaterIMSession::inviteToSession(const uuid_vec_t& ids) { LLViewerRegion* region = gAgent.getRegion(); @@ -1221,7 +1201,9 @@ BOOL LLFloaterIMSession::inviteToSession(const uuid_vec_t& ids) } data["method"] = "invite"; data["session-id"] = mSessionID; - LLHTTPClient::post(url, data,new LLSessionInviteResponder(mSessionID)); + + LLCoreHttpUtil::HttpCoroutineAdapter::messageHttpPost(url, data, + "Session invite sent", "Session invite failed"); } else { -- cgit v1.2.3 From e9257f034a51473cf09fa1c9f35f424f87e5f715 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 22 May 2015 15:33:40 -0700 Subject: Object default perm floater --- indra/newview/llfloaterperms.cpp | 106 ++++++++++++++++++++------------------- indra/newview/llfloaterperms.h | 4 ++ 2 files changed, 58 insertions(+), 52 deletions(-) (limited to 'indra') diff --git a/indra/newview/llfloaterperms.cpp b/indra/newview/llfloaterperms.cpp index 042cf47070..06af2725c3 100755 --- a/indra/newview/llfloaterperms.cpp +++ b/indra/newview/llfloaterperms.cpp @@ -37,6 +37,7 @@ #include "llnotificationsutil.h" #include "llsdserialize.h" #include "llvoavatar.h" +#include "llcorehttputil.h" LLFloaterPerms::LLFloaterPerms(const LLSD& seed) : LLFloater(seed) @@ -166,41 +167,6 @@ void LLFloaterPermsDefault::onCommitCopy(const LLSD& user_data) xfer->setEnabled(copyable); } -class LLFloaterPermsResponder : public LLHTTPClient::Responder -{ -public: - LLFloaterPermsResponder(): LLHTTPClient::Responder() {} -private: - static std::string sPreviousReason; - - void httpFailure() - { - const std::string& reason = getReason(); - // Do not display the same error more than once in a row - if (reason != sPreviousReason) - { - sPreviousReason = reason; - LLSD args; - args["REASON"] = reason; - LLNotificationsUtil::add("DefaultObjectPermissions", args); - } - } - - void httpSuccess() - { - //const LLSD& content = getContent(); - //dump_sequential_xml("perms_responder_result.xml", content); - - // Since we have had a successful POST call be sure to display the next error message - // even if it is the same as a previous one. - sPreviousReason = ""; - LLFloaterPermsDefault::setCapSent(true); - LL_INFOS("ObjectPermissionsFloater") << "Default permissions successfully sent to simulator" << LL_ENDL; - } -}; - - std::string LLFloaterPermsResponder::sPreviousReason; - void LLFloaterPermsDefault::sendInitialPerms() { if(!mCapSent) @@ -215,23 +181,8 @@ void LLFloaterPermsDefault::updateCap() if(!object_url.empty()) { - LLSD report = LLSD::emptyMap(); - report["default_object_perm_masks"]["Group"] = - (LLSD::Integer)LLFloaterPerms::getGroupPerms(sCategoryNames[CAT_OBJECTS]); - report["default_object_perm_masks"]["Everyone"] = - (LLSD::Integer)LLFloaterPerms::getEveryonePerms(sCategoryNames[CAT_OBJECTS]); - report["default_object_perm_masks"]["NextOwner"] = - (LLSD::Integer)LLFloaterPerms::getNextOwnerPerms(sCategoryNames[CAT_OBJECTS]); - - { - LL_DEBUGS("ObjectPermissionsFloater") << "Sending default permissions to '" - << object_url << "'\n"; - std::ostringstream sent_perms_log; - LLSDSerialize::toPrettyXML(report, sent_perms_log); - LL_CONT << sent_perms_log.str() << LL_ENDL; - } - - LLHTTPClient::post(object_url, report, new LLFloaterPermsResponder()); + LLCoros::instance().launch("LLFloaterPermsDefault::updateCapCoro", + boost::bind(&LLFloaterPermsDefault::updateCapCoro, _1, object_url)); } else { @@ -239,6 +190,57 @@ void LLFloaterPermsDefault::updateCap() } } +/*static*/ +void LLFloaterPermsDefault::updateCapCoro(LLCoros::self& self, std::string url) +{ + static std::string previousReason; + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("genericPostCoro", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + + LLSD postData = LLSD::emptyMap(); + postData["default_object_perm_masks"]["Group"] = + (LLSD::Integer)LLFloaterPerms::getGroupPerms(sCategoryNames[CAT_OBJECTS]); + postData["default_object_perm_masks"]["Everyone"] = + (LLSD::Integer)LLFloaterPerms::getEveryonePerms(sCategoryNames[CAT_OBJECTS]); + postData["default_object_perm_masks"]["NextOwner"] = + (LLSD::Integer)LLFloaterPerms::getNextOwnerPerms(sCategoryNames[CAT_OBJECTS]); + + { + LL_DEBUGS("ObjectPermissionsFloater") << "Sending default permissions to '" + << url << "'\n"; + std::ostringstream sent_perms_log; + LLSDSerialize::toPrettyXML(postData, sent_perms_log); + LL_CONT << sent_perms_log.str() << LL_ENDL; + } + + LLSD result = httpAdapter->postAndYield(self, httpRequest, url, postData); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + + if (!status) + { + const std::string& reason = status.toString(); + // Do not display the same error more than once in a row + if (reason != previousReason) + { + previousReason = reason; + LLSD args; + args["REASON"] = reason; + LLNotificationsUtil::add("DefaultObjectPermissions", args); + } + return; + } + + // Since we have had a successful POST call be sure to display the next error message + // even if it is the same as a previous one. + previousReason.clear(); + LLFloaterPermsDefault::setCapSent(true); + LL_INFOS("ObjectPermissionsFloater") << "Default permissions successfully sent to simulator" << LL_ENDL; +} + void LLFloaterPermsDefault::setCapSent(bool cap_sent) { mCapSent = cap_sent; diff --git a/indra/newview/llfloaterperms.h b/indra/newview/llfloaterperms.h index 2bb0a19dc1..15fdefa3a1 100755 --- a/indra/newview/llfloaterperms.h +++ b/indra/newview/llfloaterperms.h @@ -29,6 +29,8 @@ #define LL_LLFLOATERPERMPREFS_H #include "llfloater.h" +#include "lleventcoro.h" +#include "llcoros.h" class LLFloaterPerms : public LLFloater { @@ -80,6 +82,8 @@ private: void refresh(); static const std::string sCategoryNames[CAT_LAST]; + static void LLFloaterPermsDefault::updateCapCoro(LLCoros::self& self, std::string url); + // cached values only for implementing cancel. bool mShareWithGroup[CAT_LAST]; -- cgit v1.2.3 From 00b2b60a0c495656e1b8e0a20272c449eea49b3c Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 22 May 2015 16:14:00 -0700 Subject: Region debug console to coroutines. --- indra/newview/llfloaterregiondebugconsole.cpp | 50 +++++++++++++++++++++++++++ indra/newview/llfloaterregiondebugconsole.h | 6 +++- 2 files changed, 55 insertions(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/llfloaterregiondebugconsole.cpp b/indra/newview/llfloaterregiondebugconsole.cpp index 40757a4d04..00955ff941 100755 --- a/indra/newview/llfloaterregiondebugconsole.cpp +++ b/indra/newview/llfloaterregiondebugconsole.cpp @@ -35,6 +35,7 @@ #include "lllineeditor.h" #include "lltexteditor.h" #include "llviewerregion.h" +#include "llcorehttputil.h" // Two versions of the sim console API are supported. // @@ -68,6 +69,7 @@ namespace const std::string CONSOLE_NOT_SUPPORTED( "This region does not support the simulator console."); +#if 0 // This responder handles the initial response. Unless error() is called // we assume that the simulator has received our request. Error will be // called if this request times out. @@ -119,6 +121,7 @@ namespace public: LLTextEditor * mOutput; }; +#endif // This handles responses for console commands sent via the asynchronous // API. @@ -202,26 +205,73 @@ void LLFloaterRegionDebugConsole::onInput(LLUICtrl* ctrl, const LLSD& param) } else { +#if 1 + LLSD postData = LLSD(input->getText()); + LLCoreHttpUtil::HttpCoroutineAdapter::callbackHttpPost(url, postData, + boost::bind(&LLFloaterRegionDebugConsole::onConsoleSuccess, this, _1), + boost::bind(&LLFloaterRegionDebugConsole::onConsoleError, this, _1)); +#else // Using SimConsole (deprecated) LLHTTPClient::post( url, LLSD(input->getText()), new ConsoleResponder(mOutput)); +#endif } } else { +#if 1 + LLSD postData = LLSD(input->getText()); + LLCoreHttpUtil::HttpCoroutineAdapter::callbackHttpPost(url, postData, + NULL, + boost::bind(&LLFloaterRegionDebugConsole::onAsyncConsoleError, this, _1)); + +#else // Using SimConsoleAsync LLHTTPClient::post( url, LLSD(input->getText()), new AsyncConsoleResponder); +#endif } mOutput->appendText(text, false); input->clear(); } +void LLFloaterRegionDebugConsole::onAsyncConsoleError(LLSD result) +{ + LL_WARNS("Console") << UNABLE_TO_SEND_COMMAND << LL_ENDL; + sConsoleReplySignal(UNABLE_TO_SEND_COMMAND); +} + +void LLFloaterRegionDebugConsole::onConsoleError(LLSD result) +{ + LL_WARNS("Console") << UNABLE_TO_SEND_COMMAND << LL_ENDL; + if (mOutput) + { + mOutput->appendText( + UNABLE_TO_SEND_COMMAND + PROMPT, + false); + } + +} + +void LLFloaterRegionDebugConsole::onConsoleSuccess(LLSD result) +{ + if (mOutput) + { + LLSD response = result; + if (response.isMap() && response.has(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS_CONTENT)) + { + response = response[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS_CONTENT]; + } + mOutput->appendText( + response.asString() + PROMPT, false); + } +} + void LLFloaterRegionDebugConsole::onReplyReceived(const std::string& output) { mOutput->appendText(output + PROMPT, false); diff --git a/indra/newview/llfloaterregiondebugconsole.h b/indra/newview/llfloaterregiondebugconsole.h index fd3af4152e..ee4bd79b17 100755 --- a/indra/newview/llfloaterregiondebugconsole.h +++ b/indra/newview/llfloaterregiondebugconsole.h @@ -38,7 +38,7 @@ class LLTextEditor; typedef boost::signals2::signal< void (const std::string& output)> console_reply_signal_t; -class LLFloaterRegionDebugConsole : public LLFloater, public LLHTTPClient::Responder +class LLFloaterRegionDebugConsole : public LLFloater { public: LLFloaterRegionDebugConsole(LLSD const & key); @@ -56,6 +56,10 @@ public: private: void onReplyReceived(const std::string& output); + void onAsyncConsoleError(LLSD result); + void onConsoleError(LLSD result); + void onConsoleSuccess(LLSD result); + boost::signals2::connection mReplySignalConnection; }; -- cgit v1.2.3 From d784b20e2926ffcdf3d79de157b0ec0e1676bc82 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 22 May 2015 16:27:25 -0700 Subject: Clean out the dead code --- indra/newview/llfloaterregiondebugconsole.cpp | 71 --------------------------- 1 file changed, 71 deletions(-) (limited to 'indra') diff --git a/indra/newview/llfloaterregiondebugconsole.cpp b/indra/newview/llfloaterregiondebugconsole.cpp index 00955ff941..271fb2f9a3 100755 --- a/indra/newview/llfloaterregiondebugconsole.cpp +++ b/indra/newview/llfloaterregiondebugconsole.cpp @@ -30,7 +30,6 @@ #include "llfloaterregiondebugconsole.h" #include "llagent.h" -#include "llhttpclient.h" #include "llhttpnode.h" #include "lllineeditor.h" #include "lltexteditor.h" @@ -69,60 +68,6 @@ namespace const std::string CONSOLE_NOT_SUPPORTED( "This region does not support the simulator console."); -#if 0 - // This responder handles the initial response. Unless error() is called - // we assume that the simulator has received our request. Error will be - // called if this request times out. - class AsyncConsoleResponder : public LLHTTPClient::Responder - { - LOG_CLASS(AsyncConsoleResponder); - protected: - /* virtual */ - void httpFailure() - { - LL_WARNS("Console") << dumpResponse() << LL_ENDL; - sConsoleReplySignal(UNABLE_TO_SEND_COMMAND); - } - }; - - class ConsoleResponder : public LLHTTPClient::Responder - { - LOG_CLASS(ConsoleResponder); - public: - ConsoleResponder(LLTextEditor *output) : mOutput(output) - { - } - - protected: - /*virtual*/ - void httpFailure() - { - LL_WARNS("Console") << dumpResponse() << LL_ENDL; - if (mOutput) - { - mOutput->appendText( - UNABLE_TO_SEND_COMMAND + PROMPT, - false); - } - } - - /*virtual*/ - void httpSuccess() - { - const LLSD& content = getContent(); - LL_DEBUGS("Console") << content << LL_ENDL; - if (mOutput) - { - mOutput->appendText( - content.asString() + PROMPT, false); - } - } - - public: - LLTextEditor * mOutput; - }; -#endif - // This handles responses for console commands sent via the asynchronous // API. class ConsoleResponseNode : public LLHTTPNode @@ -205,35 +150,19 @@ void LLFloaterRegionDebugConsole::onInput(LLUICtrl* ctrl, const LLSD& param) } else { -#if 1 LLSD postData = LLSD(input->getText()); LLCoreHttpUtil::HttpCoroutineAdapter::callbackHttpPost(url, postData, boost::bind(&LLFloaterRegionDebugConsole::onConsoleSuccess, this, _1), boost::bind(&LLFloaterRegionDebugConsole::onConsoleError, this, _1)); -#else - // Using SimConsole (deprecated) - LLHTTPClient::post( - url, - LLSD(input->getText()), - new ConsoleResponder(mOutput)); -#endif } } else { -#if 1 LLSD postData = LLSD(input->getText()); LLCoreHttpUtil::HttpCoroutineAdapter::callbackHttpPost(url, postData, NULL, boost::bind(&LLFloaterRegionDebugConsole::onAsyncConsoleError, this, _1)); -#else - // Using SimConsoleAsync - LLHTTPClient::post( - url, - LLSD(input->getText()), - new AsyncConsoleResponder); -#endif } mOutput->appendText(text, false); -- cgit v1.2.3 From 55ea4bb04d4a25c88beeeb1b393efebdd83f35fd Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 26 May 2015 09:48:47 -0700 Subject: Extra specification that MS didn't catch. --- indra/newview/llfloaterperms.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/llfloaterperms.h b/indra/newview/llfloaterperms.h index 15fdefa3a1..ba7d39fe89 100755 --- a/indra/newview/llfloaterperms.h +++ b/indra/newview/llfloaterperms.h @@ -82,7 +82,7 @@ private: void refresh(); static const std::string sCategoryNames[CAT_LAST]; - static void LLFloaterPermsDefault::updateCapCoro(LLCoros::self& self, std::string url); + static void updateCapCoro(LLCoros::self& self, std::string url); // cached values only for implementing cancel. -- cgit v1.2.3 From 9134a3a097607e427b18af010774eb842be893f2 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 26 May 2015 16:59:44 -0700 Subject: Coros for Object cost and physics flags. --- indra/newview/llviewerobjectlist.cpp | 467 ++++++++++++++++------------------- indra/newview/llviewerobjectlist.h | 10 + 2 files changed, 223 insertions(+), 254 deletions(-) (limited to 'indra') diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp index 7c36b30dd1..1c3e2aec01 100755 --- a/indra/newview/llviewerobjectlist.cpp +++ b/indra/newview/llviewerobjectlist.cpp @@ -78,6 +78,7 @@ #include "llappviewer.h" #include "llfloaterperms.h" #include "llvocache.h" +#include "llcorehttputil.h" extern F32 gMinObjectDistance; extern BOOL gAnimateTextures; @@ -795,190 +796,6 @@ void LLViewerObjectList::updateApparentAngles(LLAgent &agent) LLVOAvatar::cullAvatarsByPixelArea(); } -class LLObjectCostResponder : public LLCurl::Responder -{ - LOG_CLASS(LLObjectCostResponder); -public: - LLObjectCostResponder(const LLSD& object_ids) - : mObjectIDs(object_ids) - { - } - - // Clear's the global object list's pending - // request list for all objects requested - void clear_object_list_pending_requests() - { - // TODO*: No more hard coding - for ( - LLSD::array_iterator iter = mObjectIDs.beginArray(); - iter != mObjectIDs.endArray(); - ++iter) - { - gObjectList.onObjectCostFetchFailure(iter->asUUID()); - } - } - -private: - /* virtual */ void httpFailure() - { - LL_WARNS() << dumpResponse() << LL_ENDL; - - // TODO*: Error message to user - // For now just clear the request from the pending list - clear_object_list_pending_requests(); - } - - /* virtual */ void httpSuccess() - { - const LLSD& content = getContent(); - if ( !content.isMap() || content.has("error") ) - { - // Improper response or the request had an error, - // show an error to the user? - LL_WARNS() - << "Application level error when fetching object " - << "cost. Message: " << content["error"]["message"].asString() - << ", identifier: " << content["error"]["identifier"].asString() - << LL_ENDL; - - // TODO*: Adaptively adjust request size if the - // service says we've requested too many and retry - - // TODO*: Error message if not retrying - clear_object_list_pending_requests(); - return; - } - - // Success, grab the resource cost and linked set costs - // for an object if one was returned - for ( - LLSD::array_iterator iter = mObjectIDs.beginArray(); - iter != mObjectIDs.endArray(); - ++iter) - { - LLUUID object_id = iter->asUUID(); - - // Check to see if the request contains data for the object - if ( content.has(iter->asString()) ) - { - F32 link_cost = - content[iter->asString()]["linked_set_resource_cost"].asReal(); - F32 object_cost = - content[iter->asString()]["resource_cost"].asReal(); - - F32 physics_cost = content[iter->asString()]["physics_cost"].asReal(); - F32 link_physics_cost = content[iter->asString()]["linked_set_physics_cost"].asReal(); - - gObjectList.updateObjectCost(object_id, object_cost, link_cost, physics_cost, link_physics_cost); - } - else - { - // TODO*: Give user feedback about the missing data? - gObjectList.onObjectCostFetchFailure(object_id); - } - } - } - -private: - LLSD mObjectIDs; -}; - - -class LLPhysicsFlagsResponder : public LLCurl::Responder -{ - LOG_CLASS(LLPhysicsFlagsResponder); -public: - LLPhysicsFlagsResponder(const LLSD& object_ids) - : mObjectIDs(object_ids) - { - } - - // Clear's the global object list's pending - // request list for all objects requested - void clear_object_list_pending_requests() - { - // TODO*: No more hard coding - for ( - LLSD::array_iterator iter = mObjectIDs.beginArray(); - iter != mObjectIDs.endArray(); - ++iter) - { - gObjectList.onPhysicsFlagsFetchFailure(iter->asUUID()); - } - } - -private: - /* virtual */ void httpFailure() - { - LL_WARNS() << dumpResponse() << LL_ENDL; - - // TODO*: Error message to user - // For now just clear the request from the pending list - clear_object_list_pending_requests(); - } - - /* virtual void */ void httpSuccess() - { - const LLSD& content = getContent(); - if ( !content.isMap() || content.has("error") ) - { - // Improper response or the request had an error, - // show an error to the user? - LL_WARNS() - << "Application level error when fetching object " - << "physics flags. Message: " << content["error"]["message"].asString() - << ", identifier: " << content["error"]["identifier"].asString() - << LL_ENDL; - - // TODO*: Adaptively adjust request size if the - // service says we've requested too many and retry - - // TODO*: Error message if not retrying - clear_object_list_pending_requests(); - return; - } - - // Success, grab the resource cost and linked set costs - // for an object if one was returned - for ( - LLSD::array_iterator iter = mObjectIDs.beginArray(); - iter != mObjectIDs.endArray(); - ++iter) - { - LLUUID object_id = iter->asUUID(); - - // Check to see if the request contains data for the object - if ( content.has(iter->asString()) ) - { - const LLSD& data = content[iter->asString()]; - - S32 shape_type = data["PhysicsShapeType"].asInteger(); - - gObjectList.updatePhysicsShapeType(object_id, shape_type); - - if (data.has("Density")) - { - F32 density = data["Density"].asReal(); - F32 friction = data["Friction"].asReal(); - F32 restitution = data["Restitution"].asReal(); - F32 gravity_multiplier = data["GravityMultiplier"].asReal(); - - gObjectList.updatePhysicsProperties(object_id, - density, friction, restitution, gravity_multiplier); - } - } - else - { - // TODO*: Give user feedback about the missing data? - gObjectList.onPhysicsFlagsFetchFailure(object_id); - } - } - } - -private: - LLSD mObjectIDs; -}; - static LLTrace::BlockTimerStatHandle FTM_IDLE_COPY("Idle Copy"); void LLViewerObjectList::update(LLAgent &agent) @@ -1174,41 +991,8 @@ void LLViewerObjectList::fetchObjectCosts() if (!url.empty()) { - LLSD id_list; - U32 object_index = 0; - - for ( - std::set::iterator iter = mStaleObjectCost.begin(); - iter != mStaleObjectCost.end(); - ) - { - // Check to see if a request for this object - // has already been made. - if ( mPendingObjectCost.find(*iter) == - mPendingObjectCost.end() ) - { - mPendingObjectCost.insert(*iter); - id_list[object_index++] = *iter; - } - - mStaleObjectCost.erase(iter++); - - if (object_index >= MAX_CONCURRENT_PHYSICS_REQUESTS) - { - break; - } - } - - if ( id_list.size() > 0 ) - { - LLSD post_data = LLSD::emptyMap(); - - post_data["object_ids"] = id_list; - LLHTTPClient::post( - url, - post_data, - new LLObjectCostResponder(id_list)); - } + LLCoros::instance().launch("LLViewerObjectList::fetchObjectCostsCoro", + boost::bind(&LLViewerObjectList::fetchObjectCostsCoro, this, _1, url)); } else { @@ -1219,6 +1003,111 @@ void LLViewerObjectList::fetchObjectCosts() } } +/*static*/ +void LLViewerObjectList::reportObjectCostFailure(LLSD &objectList) +{ + // TODO*: No more hard coding + for (LLSD::array_iterator it = objectList.beginArray(); it != objectList.endArray(); ++it) + { + gObjectList.onObjectCostFetchFailure(it->asUUID()); + } +} + + +void LLViewerObjectList::fetchObjectCostsCoro(LLCoros::self& self, std::string url) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("genericPostCoro", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + + LLSD idList; + U32 objectIndex = 0; + + for (std::set::iterator it = mStaleObjectCost.begin(); it != mStaleObjectCost.end(); ) + { + // Check to see if a request for this object + // has already been made. + if (mPendingObjectCost.find(*it) == mPendingObjectCost.end()) + { + mPendingObjectCost.insert(*it); + idList[objectIndex++] = *it; + } + + mStaleObjectCost.erase(it++); + + if (objectIndex >= MAX_CONCURRENT_PHYSICS_REQUESTS) + { + break; + } + } + + if (idList.size() < 1) + { + LL_INFOS() << "No outstanding object IDs to request." << LL_ENDL; + return; + } + + LLSD postData = LLSD::emptyMap(); + + postData["object_ids"] = idList; + + LLSD result = httpAdapter->postAndYield(self, httpRequest, url, postData); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + + if (!status || result.has("error")) + { + if (result.has("error")) + { + LL_WARNS() << "Application level error when fetching object " + << "cost. Message: " << result["error"]["message"].asString() + << ", identifier: " << result["error"]["identifier"].asString() + << LL_ENDL; + + // TODO*: Adaptively adjust request size if the + // service says we've requested too many and retry + } + reportObjectCostFailure(idList); + + return; + } + + // Success, grab the resource cost and linked set costs + // for an object if one was returned + for (LLSD::array_iterator it = idList.beginArray(); it != idList.endArray(); ++it) + { + LLUUID objectId = it->asUUID(); + + // Check to see if the request contains data for the object + if (result.has(it->asString())) + { + const LLSD& data = result[it->asString()]; + + S32 shapeType = data["PhysicsShapeType"].asInteger(); + + gObjectList.updatePhysicsShapeType(objectId, shapeType); + + if (data.has("Density")) + { + F32 density = data["Density"].asReal(); + F32 friction = data["Friction"].asReal(); + F32 restitution = data["Restitution"].asReal(); + F32 gravityMult = data["GravityMultiplier"].asReal(); + + gObjectList.updatePhysicsProperties(objectId, density, friction, restitution, gravityMult); + } + } + else + { + // TODO*: Give user feedback about the missing data? + gObjectList.onPhysicsFlagsFetchFailure(objectId); + } + } + +} + void LLViewerObjectList::fetchPhysicsFlags() { // issue http request for stale object physics flags @@ -1232,41 +1121,8 @@ void LLViewerObjectList::fetchPhysicsFlags() if (!url.empty()) { - LLSD id_list; - U32 object_index = 0; - - for ( - std::set::iterator iter = mStalePhysicsFlags.begin(); - iter != mStalePhysicsFlags.end(); - ) - { - // Check to see if a request for this object - // has already been made. - if ( mPendingPhysicsFlags.find(*iter) == - mPendingPhysicsFlags.end() ) - { - mPendingPhysicsFlags.insert(*iter); - id_list[object_index++] = *iter; - } - - mStalePhysicsFlags.erase(iter++); - - if (object_index >= MAX_CONCURRENT_PHYSICS_REQUESTS) - { - break; - } - } - - if ( id_list.size() > 0 ) - { - LLSD post_data = LLSD::emptyMap(); - - post_data["object_ids"] = id_list; - LLHTTPClient::post( - url, - post_data, - new LLPhysicsFlagsResponder(id_list)); - } + LLCoros::instance().launch("LLViewerObjectList::fetchPhisicsFlagsCoro", + boost::bind(&LLViewerObjectList::fetchPhisicsFlagsCoro, this, _1, url)); } else { @@ -1277,6 +1133,109 @@ void LLViewerObjectList::fetchPhysicsFlags() } } +/*static*/ +void LLViewerObjectList::reportPhysicsFlagFailure(LLSD &objectList) +{ + // TODO*: No more hard coding + for (LLSD::array_iterator it = objectList.beginArray(); it != objectList.endArray(); ++it) + { + gObjectList.onPhysicsFlagsFetchFailure(it->asUUID()); + } +} + +void LLViewerObjectList::fetchPhisicsFlagsCoro(LLCoros::self& self, std::string url) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("genericPostCoro", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + + LLSD idList; + U32 objectIndex = 0; + + for (std::set::iterator it = mStalePhysicsFlags.begin(); it != mStalePhysicsFlags.end(); ) + { + // Check to see if a request for this object + // has already been made. + if (mPendingPhysicsFlags.find(*it) == mPendingPhysicsFlags.end()) + { + mPendingPhysicsFlags.insert(*it); + idList[objectIndex++] = *it; + } + + mStalePhysicsFlags.erase(it++); + + if (objectIndex >= MAX_CONCURRENT_PHYSICS_REQUESTS) + { + break; + } + } + + if (idList.size() < 1) + { + LL_INFOS() << "No outstanding object physics flags to request." << LL_ENDL; + return; + } + + LLSD postData = LLSD::emptyMap(); + + postData["object_ids"] = idList; + + LLSD result = httpAdapter->postAndYield(self, httpRequest, url, postData); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + + if (!status || result.has("error")) + { + if (result.has("error")) + { + LL_WARNS() << "Application level error when fetching object " + << "physics flags. Message: " << result["error"]["message"].asString() + << ", identifier: " << result["error"]["identifier"].asString() + << LL_ENDL; + + // TODO*: Adaptively adjust request size if the + // service says we've requested too many and retry + } + reportPhysicsFlagFailure(idList); + + return; + } + + // Success, grab the resource cost and linked set costs + // for an object if one was returned + for (LLSD::array_iterator it = idList.beginArray(); it != idList.endArray(); ++it) + { + LLUUID objectId = it->asUUID(); + + // Check to see if the request contains data for the object + if (result.has(it->asString())) + { + const LLSD& data = result[it->asString()]; + + S32 shapeType = data["PhysicsShapeType"].asInteger(); + + gObjectList.updatePhysicsShapeType(objectId, shapeType); + + if (data.has("Density")) + { + F32 density = data["Density"].asReal(); + F32 friction = data["Friction"].asReal(); + F32 restitution = data["Restitution"].asReal(); + F32 gravityMult = data["GravityMultiplier"].asReal(); + + gObjectList.updatePhysicsProperties(objectId, density, + friction, restitution, gravityMult); + } + } + else + { + // TODO*: Give user feedback about the missing data? + gObjectList.onPhysicsFlagsFetchFailure(objectId); + } + } +} void LLViewerObjectList::clearDebugText() { diff --git a/indra/newview/llviewerobjectlist.h b/indra/newview/llviewerobjectlist.h index 594317cd9f..f849813f0a 100755 --- a/indra/newview/llviewerobjectlist.h +++ b/indra/newview/llviewerobjectlist.h @@ -36,6 +36,8 @@ // project includes #include "llviewerobject.h" +#include "lleventcoro.h" +#include "llcoros.h" class LLCamera; class LLNetMap; @@ -227,6 +229,14 @@ protected: std::set mSelectPickList; friend class LLViewerObject; + +private: + static void reportObjectCostFailure(LLSD &objectList); + void fetchObjectCostsCoro(LLCoros::self& self, std::string url); + + static void reportPhysicsFlagFailure(LLSD &obejectList); + void fetchPhisicsFlagsCoro(LLCoros::self& self, std::string url); + }; -- cgit v1.2.3 From 83543e556cba8753077c9f004bb0dc71b4509007 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 27 May 2015 17:15:01 -0700 Subject: Memory leak (extra ref) in webprofile Viewer media routines to coroutine. Post with raw respons in llcorehttputil LLCore::Http added headers only option (applies only on get) --- indra/llcorehttp/_httpoprequest.cpp | 8 +- indra/llcorehttp/httpoptions.cpp | 29 ++- indra/llcorehttp/httpoptions.h | 10 + indra/llmessage/llcorehttputil.cpp | 12 +- indra/llmessage/llcorehttputil.h | 13 + indra/newview/llviewermedia.cpp | 483 ++++++++++++++++-------------------- indra/newview/llviewermedia.h | 14 +- indra/newview/llwebprofile.cpp | 2 +- 8 files changed, 282 insertions(+), 289 deletions(-) (limited to 'indra') diff --git a/indra/llcorehttp/_httpoprequest.cpp b/indra/llcorehttp/_httpoprequest.cpp index b1b05dc285..3b6647882e 100755 --- a/indra/llcorehttp/_httpoprequest.cpp +++ b/indra/llcorehttp/_httpoprequest.cpp @@ -532,6 +532,7 @@ HttpStatus HttpOpRequest::prepareRequest(HttpService * service) long sslPeerV(0L); long sslHostV(0L); long dnsCacheTimeout(-1L); + long nobody(0L); if (mReqOptions) { @@ -539,6 +540,7 @@ HttpStatus HttpOpRequest::prepareRequest(HttpService * service) sslPeerV = mReqOptions->getSSLVerifyPeer() ? 1L : 0L; sslHostV = mReqOptions->getSSLVerifyHost() ? 2L : 0L; dnsCacheTimeout = mReqOptions->getDNSCacheTimeout(); + nobody = mReqOptions->getHeadersOnly() ? 1L : 0L; } code = curl_easy_setopt(mCurlHandle, CURLOPT_FOLLOWLOCATION, follow_redirect); check_curl_easy_code(code, CURLOPT_FOLLOWLOCATION); @@ -548,6 +550,9 @@ HttpStatus HttpOpRequest::prepareRequest(HttpService * service) code = curl_easy_setopt(mCurlHandle, CURLOPT_SSL_VERIFYHOST, sslHostV); check_curl_easy_code(code, CURLOPT_SSL_VERIFYHOST); + code = curl_easy_setopt(mCurlHandle, CURLOPT_NOBODY, nobody); + check_curl_easy_code(code, CURLOPT_NOBODY); + // The Linksys WRT54G V5 router has an issue with frequent // DNS lookups from LAN machines. If they happen too often, // like for every HTTP request, the router gets annoyed after @@ -587,7 +592,8 @@ HttpStatus HttpOpRequest::prepareRequest(HttpService * service) switch (mReqMethod) { case HOR_GET: - code = curl_easy_setopt(mCurlHandle, CURLOPT_HTTPGET, 1); + if (nobody == 0) + code = curl_easy_setopt(mCurlHandle, CURLOPT_HTTPGET, 1); check_curl_easy_code(code, CURLOPT_HTTPGET); break; diff --git a/indra/llcorehttp/httpoptions.cpp b/indra/llcorehttp/httpoptions.cpp index a4d08a80df..2b42bcaf6d 100755 --- a/indra/llcorehttp/httpoptions.cpp +++ b/indra/llcorehttp/httpoptions.cpp @@ -34,16 +34,17 @@ namespace LLCore HttpOptions::HttpOptions() : RefCounted(true), - mWantHeaders(false), - mTracing(HTTP_TRACE_OFF), - mTimeout(HTTP_REQUEST_TIMEOUT_DEFAULT), - mTransferTimeout(HTTP_REQUEST_XFER_TIMEOUT_DEFAULT), - mRetries(HTTP_RETRY_COUNT_DEFAULT), - mUseRetryAfter(HTTP_USE_RETRY_AFTER_DEFAULT), - mFollowRedirects(false), - mVerifyPeer(false), - mVerifyHost(false), - mDNSCacheTimeout(-1L) + mWantHeaders(false), + mTracing(HTTP_TRACE_OFF), + mTimeout(HTTP_REQUEST_TIMEOUT_DEFAULT), + mTransferTimeout(HTTP_REQUEST_XFER_TIMEOUT_DEFAULT), + mRetries(HTTP_RETRY_COUNT_DEFAULT), + mUseRetryAfter(HTTP_USE_RETRY_AFTER_DEFAULT), + mFollowRedirects(false), + mVerifyPeer(false), + mVerifyHost(false), + mDNSCacheTimeout(-1L), + mNoBody(false) {} @@ -104,4 +105,12 @@ void HttpOptions::setDNSCacheTimeout(int timeout) { mDNSCacheTimeout = timeout; } + +void HttpOptions::setHeadersOnly(bool nobody) +{ + mNoBody = nobody; + if (mNoBody) + setWantHeaders(true); +} + } // end namespace LLCore diff --git a/indra/llcorehttp/httpoptions.h b/indra/llcorehttp/httpoptions.h index 765d2431bb..21ecff85af 100755 --- a/indra/llcorehttp/httpoptions.h +++ b/indra/llcorehttp/httpoptions.h @@ -149,6 +149,15 @@ public: { return mDNSCacheTimeout; } + + /// Retrieve only the headers and status from the request. Setting this + /// to true implies setWantHeaders(true) as well. + /// Default: false + void setHeadersOnly(bool nobody); + bool getHeadersOnly() const + { + return mNoBody; + } protected: bool mWantHeaders; @@ -161,6 +170,7 @@ protected: bool mVerifyPeer; bool mVerifyHost; int mDNSCacheTimeout; + bool mNoBody; }; // end class HttpOptions diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index 001df9e385..c4a7e9040a 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -256,7 +256,7 @@ void HttpCoroHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRespons buildStatusEntry(response, status, result); -#if 0 +#if 1 // commenting out, but keeping since this can be useful for debugging if (!status) { @@ -608,6 +608,16 @@ LLSD HttpCoroutineAdapter::postAndYield(LLCoros::self & self, LLCore::HttpReques return postAndYield_(self, request, url, rawbody, options, headers, httpHandler); } +LLSD HttpCoroutineAdapter::postRawAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, + const std::string & url, LLCore::BufferArray::ptr_t rawbody, + LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) +{ + LLEventStream replyPump(mAdapterName, true); + HttpCoroHandler::ptr_t httpHandler = HttpCoroHandler::ptr_t(new HttpCoroRawHandler(replyPump)); + + return postAndYield_(self, request, url, rawbody, options, headers, httpHandler); +} + LLSD HttpCoroutineAdapter::postAndYield_(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, const std::string & url, LLCore::BufferArray::ptr_t &rawbody, LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, diff --git a/indra/llmessage/llcorehttputil.h b/indra/llmessage/llcorehttputil.h index d6219318f9..213610e58e 100644 --- a/indra/llmessage/llcorehttputil.h +++ b/indra/llmessage/llcorehttputil.h @@ -334,6 +334,19 @@ public: LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false), headers); } + LLSD postRawAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, + const std::string & url, LLCore::BufferArray::ptr_t rawbody, + LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false), + LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false)); + + LLSD postRawAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, + const std::string & url, LLCore::BufferArray::ptr_t &rawbody, + LLCore::HttpHeaders::ptr_t &headers) + { + return postRawAndYield(self, request, url, rawbody, + LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false), headers); + } + /// Execute a Put transaction on the supplied URL and yield execution of /// the coroutine until a result is available. /// diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp index 509227c683..02167b099e 100755 --- a/indra/newview/llviewermedia.cpp +++ b/indra/newview/llviewermedia.cpp @@ -69,6 +69,7 @@ #include "llwebprofile.h" #include "llwindow.h" #include "llvieweraudio.h" +#include "llcorehttputil.h" #include "llfloaterwebcontent.h" // for handling window close requests and geometry change requests in media browser windows. @@ -152,190 +153,6 @@ LLViewerMediaObserver::~LLViewerMediaObserver() } -// Move this to its own file. -// helper class that tries to download a URL from a web site and calls a method -// on the Panel Land Media and to discover the MIME type -class LLMimeDiscoveryResponder : public LLHTTPClient::Responder -{ - LOG_CLASS(LLMimeDiscoveryResponder); -public: - LLMimeDiscoveryResponder( viewer_media_t media_impl) - : mMediaImpl(media_impl), - mInitialized(false) - { - if(mMediaImpl->mMimeTypeProbe != NULL) - { - LL_ERRS() << "impl already has an outstanding responder" << LL_ENDL; - } - - mMediaImpl->mMimeTypeProbe = this; - } - - ~LLMimeDiscoveryResponder() - { - disconnectOwner(); - } - -private: - /* virtual */ void httpCompleted() - { - if (!isGoodStatus()) - { - LL_WARNS() << dumpResponse() - << " [headers:" << getResponseHeaders() << "]" << LL_ENDL; - } - const std::string& media_type = getResponseHeader(HTTP_IN_HEADER_CONTENT_TYPE); - std::string::size_type idx1 = media_type.find_first_of(";"); - std::string mime_type = media_type.substr(0, idx1); - - LL_DEBUGS() << "status is " << getStatus() << ", media type \"" << media_type << "\"" << LL_ENDL; - - // 2xx status codes indicate success. - // Most 4xx status codes are successful enough for our purposes. - // 499 is the error code for host not found, timeout, etc. - // 500 means "Internal Server error" but we decided it's okay to - // accept this and go past it in the MIME type probe - // 302 means the resource can be found temporarily in a different place - added this for join.secondlife.com - // 499 is a code specifc to join.secondlife.com (?) apparently safe to ignore -// if( ((status >= 200) && (status < 300)) || -// ((status >= 400) && (status < 499)) || -// (status == 500) || -// (status == 302) || -// (status == 499) -// ) - // We now no longer check the error code returned from the probe. - // If we have a mime type, use it. If not, default to the web plugin and let it handle error reporting. - //if(1) - { - // The probe was successful. - if(mime_type.empty()) - { - // Some sites don't return any content-type header at all. - // Treat an empty mime type as text/html. - mime_type = HTTP_CONTENT_TEXT_HTML; - } - } - //else - //{ - // LL_WARNS() << "responder failed with status " << dumpResponse() << LL_ENDL; - // - // if(mMediaImpl) - // { - // mMediaImpl->mMediaSourceFailed = true; - // } - // return; - //} - - // the call to initializeMedia may disconnect the responder, which will clear mMediaImpl. - // Make a local copy so we can call loadURI() afterwards. - LLViewerMediaImpl *impl = mMediaImpl; - - if(impl && !mInitialized && ! mime_type.empty()) - { - if(impl->initializeMedia(mime_type)) - { - mInitialized = true; - impl->loadURI(); - disconnectOwner(); - } - } - } - -public: - void cancelRequest() - { - disconnectOwner(); - } - -private: - void disconnectOwner() - { - if(mMediaImpl) - { - if(mMediaImpl->mMimeTypeProbe != this) - { - LL_ERRS() << "internal error: mMediaImpl->mMimeTypeProbe != this" << LL_ENDL; - } - - mMediaImpl->mMimeTypeProbe = NULL; - } - mMediaImpl = NULL; - } - - -public: - LLViewerMediaImpl *mMediaImpl; - bool mInitialized; -}; - -class LLViewerMediaOpenIDResponder : public LLHTTPClient::Responder -{ - LOG_CLASS(LLViewerMediaOpenIDResponder); -public: - LLViewerMediaOpenIDResponder( ) - { - } - - ~LLViewerMediaOpenIDResponder() - { - } - - /* virtual */ void completedRaw( - const LLChannelDescriptors& channels, - const LLIOPipe::buffer_ptr_t& buffer) - { - // We don't care about the content of the response, only the Set-Cookie header. - LL_DEBUGS("MediaAuth") << dumpResponse() - << " [headers:" << getResponseHeaders() << "]" << LL_ENDL; - const std::string& cookie = getResponseHeader(HTTP_IN_HEADER_SET_COOKIE); - - // *TODO: What about bad status codes? Does this destroy previous cookies? - LLViewerMedia::openIDCookieResponse(cookie); - } - -}; - -class LLViewerMediaWebProfileResponder : public LLHTTPClient::Responder -{ -LOG_CLASS(LLViewerMediaWebProfileResponder); -public: - LLViewerMediaWebProfileResponder(std::string host) - { - mHost = host; - } - - ~LLViewerMediaWebProfileResponder() - { - } - - void completedRaw( - const LLChannelDescriptors& channels, - const LLIOPipe::buffer_ptr_t& buffer) - { - // We don't care about the content of the response, only the set-cookie header. - LL_WARNS("MediaAuth") << dumpResponse() - << " [headers:" << getResponseHeaders() << "]" << LL_ENDL; - - LLSD stripped_content = getResponseHeaders(); - // *TODO: Check that this works. - stripped_content.erase(HTTP_IN_HEADER_SET_COOKIE); - LL_WARNS("MediaAuth") << stripped_content << LL_ENDL; - - const std::string& cookie = getResponseHeader(HTTP_IN_HEADER_SET_COOKIE); - LL_DEBUGS("MediaAuth") << "cookie = " << cookie << LL_ENDL; - - // *TODO: What about bad status codes? Does this destroy previous cookies? - LLViewerMedia::getCookieStore()->setCookiesFromHost(cookie, mHost); - - // Set cookie for snapshot publishing. - std::string auth_cookie = cookie.substr(0, cookie.find(";")); // strip path - LLWebProfile::setAuthCookie(auth_cookie); - } - - std::string mHost; -}; - - LLPluginCookieStore *LLViewerMedia::sCookieStore = NULL; LLURL LLViewerMedia::sOpenIDURL; std::string LLViewerMedia::sOpenIDCookie; @@ -1394,81 +1211,154 @@ void LLViewerMedia::setOpenIDCookie() { if(!sOpenIDCookie.empty()) { - // The LLURL can give me the 'authority', which is of the form: [username[:password]@]hostname[:port] - // We want just the hostname for the cookie code, but LLURL doesn't seem to have a way to extract that. - // We therefore do it here. - std::string authority = sOpenIDURL.mAuthority; - std::string::size_type host_start = authority.find('@'); - if(host_start == std::string::npos) - { - // no username/password - host_start = 0; - } - else - { - // Hostname starts after the @. - // (If the hostname part is empty, this may put host_start at the end of the string. In that case, it will end up passing through an empty hostname, which is correct.) - ++host_start; - } - std::string::size_type host_end = authority.rfind(':'); - if((host_end == std::string::npos) || (host_end < host_start)) - { - // no port - host_end = authority.size(); - } - - getCookieStore()->setCookiesFromHost(sOpenIDCookie, authority.substr(host_start, host_end - host_start)); + std::string profileUrl = getProfileURL(""); + + LLCoros::instance().launch("LLViewerMedia::getOpenIDCookieCoro", + boost::bind(&LLViewerMedia::getOpenIDCookieCoro, _1, profileUrl)); + } +} - // Do a web profile get so we can store the cookie - LLSD headers = LLSD::emptyMap(); - headers[HTTP_OUT_HEADER_ACCEPT] = "*/*"; - headers[HTTP_OUT_HEADER_COOKIE] = sOpenIDCookie; - headers[HTTP_OUT_HEADER_USER_AGENT] = getCurrentUserAgent(); +/*static*/ +void LLViewerMedia::getOpenIDCookieCoro(LLCoros::self& self, std::string url) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("getOpenIDCookieCoro", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); + LLCore::HttpHeaders::ptr_t httpHeaders(new LLCore::HttpHeaders); + + httpOpts->setFollowRedirects(true); + httpOpts->setWantHeaders(true); + + LLURL hostUrl(url.c_str()); + std::string hostAuth = hostUrl.getAuthority(); + + // *TODO: Expand LLURL to split and extract this information better. + // The structure of a URL is well defined and needing to retrieve parts of it are common. + // original comment: + // The LLURL can give me the 'authority', which is of the form: [username[:password]@]hostname[:port] + // We want just the hostname for the cookie code, but LLURL doesn't seem to have a way to extract that. + // We therefore do it here. + std::string authority = sOpenIDURL.mAuthority; + std::string::size_type hostStart = authority.find('@'); + if (hostStart == std::string::npos) + { // no username/password + hostStart = 0; + } + else + { // Hostname starts after the @. + // (If the hostname part is empty, this may put host_start at the end of the string. In that case, it will end up passing through an empty hostname, which is correct.) + ++hostStart; + } + std::string::size_type hostEnd = authority.rfind(':'); + if ((hostEnd == std::string::npos) || (hostEnd < hostStart)) + { // no port + hostEnd = authority.size(); + } - std::string profile_url = getProfileURL(""); - LLURL raw_profile_url( profile_url.c_str() ); + getCookieStore()->setCookiesFromHost(sOpenIDCookie, authority.substr(hostStart, hostEnd - hostStart)); + + // Do a web profile get so we can store the cookie + httpHeaders->append(HTTP_OUT_HEADER_ACCEPT, "*/*"); + httpHeaders->append(HTTP_OUT_HEADER_COOKIE, sOpenIDCookie); + httpHeaders->append(HTTP_OUT_HEADER_USER_AGENT, getCurrentUserAgent()); + + + LL_DEBUGS("MediaAuth") << "Requesting " << url << LL_ENDL; + LL_DEBUGS("MediaAuth") << "sOpenIDCookie = [" << sOpenIDCookie << "]" << LL_ENDL; + + LLSD result = httpAdapter->getRawAndYield(self, httpRequest, url, httpOpts, httpHeaders); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + + if (!status) + { + LL_WARNS("MediaAuth") << "Error getting web profile." << LL_ENDL; + return; + } + + LLSD resultHeaders = httpResults[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS_HEADERS]; + if (!resultHeaders.has(HTTP_IN_HEADER_SET_COOKIE)) + { + LL_WARNS("MediaAuth") << "No cookie in response." << LL_ENDL; + return; + } + + const std::string& cookie = resultHeaders[HTTP_IN_HEADER_SET_COOKIE].asStringRef(); + LL_DEBUGS("MediaAuth") << "cookie = " << cookie << LL_ENDL; + + // *TODO: What about bad status codes? Does this destroy previous cookies? + LLViewerMedia::getCookieStore()->setCookiesFromHost(cookie, hostAuth); + + // Set cookie for snapshot publishing. + std::string authCookie = cookie.substr(0, cookie.find(";")); // strip path + LLWebProfile::setAuthCookie(authCookie); - LL_DEBUGS("MediaAuth") << "Requesting " << profile_url << LL_ENDL; - LL_DEBUGS("MediaAuth") << "sOpenIDCookie = [" << sOpenIDCookie << "]" << LL_ENDL; - LLHTTPClient::get(profile_url, - new LLViewerMediaWebProfileResponder(raw_profile_url.getAuthority()), - headers); - } } ///////////////////////////////////////////////////////////////////////////////////////// // static -void LLViewerMedia::openIDSetup(const std::string &openid_url, const std::string &openid_token) +void LLViewerMedia::openIDSetup(const std::string &openidUrl, const std::string &openidToken) { - LL_DEBUGS("MediaAuth") << "url = \"" << openid_url << "\", token = \"" << openid_token << "\"" << LL_ENDL; + LL_DEBUGS("MediaAuth") << "url = \"" << openidUrl << "\", token = \"" << openidToken << "\"" << LL_ENDL; - // post the token to the url - // the responder will need to extract the cookie(s). + LLCoros::instance().launch("LLViewerMedia::openIDSetupCoro", + boost::bind(&LLViewerMedia::openIDSetupCoro, _1, openidUrl, openidToken)); +} - // Save the OpenID URL for later -- we may need the host when adding the cookie. - sOpenIDURL.init(openid_url.c_str()); - - // We shouldn't ever do this twice, but just in case this code gets repurposed later, clear existing cookies. - sOpenIDCookie.clear(); +/*static*/ +void LLViewerMedia::openIDSetupCoro(LLCoros::self& self, std::string openidUrl, std::string openidToken) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("openIDSetupCoro", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); + LLCore::HttpHeaders::ptr_t httpHeaders(new LLCore::HttpHeaders); - LLSD headers = LLSD::emptyMap(); - // Keep LLHTTPClient from adding an "Accept: application/llsd+xml" header - headers[HTTP_OUT_HEADER_ACCEPT] = "*/*"; - // and use the expected content-type for a post, instead of the LLHTTPClient::postRaw() default of "application/octet-stream" - headers[HTTP_OUT_HEADER_CONTENT_TYPE] = "application/x-www-form-urlencoded"; - - // postRaw() takes ownership of the buffer and releases it later, so we need to allocate a new buffer here. - size_t size = openid_token.size(); - U8 *data = new U8[size]; - memcpy(data, openid_token.data(), size); - - LLHTTPClient::postRaw( - openid_url, - data, - size, - new LLViewerMediaOpenIDResponder(), - headers); - + httpOpts->setWantHeaders(true); + + // post the token to the url + // the responder will need to extract the cookie(s). + // Save the OpenID URL for later -- we may need the host when adding the cookie. + sOpenIDURL.init(openidUrl.c_str()); + // We shouldn't ever do this twice, but just in case this code gets repurposed later, clear existing cookies. + sOpenIDCookie.clear(); + + httpHeaders->append(HTTP_OUT_HEADER_ACCEPT, "*/*"); + httpHeaders->append(HTTP_OUT_HEADER_CONTENT_TYPE, "application/x-www-form-urlencoded"); + + LLCore::BufferArray::ptr_t rawbody(new LLCore::BufferArray, false); + LLCore::BufferArrayStream bas(rawbody.get()); + + bas << std::noskipws << openidToken; + + LLSD result = httpAdapter->postRawAndYield(self, httpRequest, openidUrl, rawbody, httpOpts, httpHeaders); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + + if (!status) + { + LL_WARNS("MediaAuth") << "Error getting Open ID cookie" << LL_ENDL; + return; + } + + LLSD resultHeaders = httpResults[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS_HEADERS]; + if (!resultHeaders.has(HTTP_IN_HEADER_SET_COOKIE)) + { + LL_WARNS("MediaAuth") << "No cookie in response." << LL_ENDL; + return; + } + + // We don't care about the content of the response, only the Set-Cookie header. + const std::string &cookie = resultHeaders[HTTP_IN_HEADER_SET_COOKIE]; + + // *TODO: What about bad status codes? Does this destroy previous cookies? + LLViewerMedia::openIDCookieResponse(cookie); + LL_DEBUGS("MediaAuth") << "OpenID cookie set." << LL_ENDL; } ///////////////////////////////////////////////////////////////////////////////////////// @@ -1661,7 +1551,6 @@ LLViewerMediaImpl::LLViewerMediaImpl( const LLUUID& texture_id, mIsParcelMedia(false), mProximity(-1), mProximityDistance(0.0f), - mMimeTypeProbe(NULL), mMediaAutoPlay(false), mInNearbyMediaList(false), mClearCache(false), @@ -1671,8 +1560,10 @@ LLViewerMediaImpl::LLViewerMediaImpl( const LLUUID& texture_id, mIsUpdated(false), mTrustedBrowser(false), mZoomFactor(1.0), - mCleanBrowser(false) -{ + mCleanBrowser(false), + mMimeProbe(), + mCanceling(false) +{ // Set up the mute list observer if it hasn't been set up already. if(!sViewerMediaMuteListObserverInitialized) @@ -2610,7 +2501,8 @@ void LLViewerMediaImpl::navigateInternal() return; } - if(mMimeTypeProbe != NULL) + + if (!mMimeProbe.expired()) { LL_WARNS() << "MIME type probe already in progress -- bailing out." << LL_ENDL; return; @@ -2648,14 +2540,8 @@ void LLViewerMediaImpl::navigateInternal() if(scheme.empty() || "http" == scheme || "https" == scheme) { - // If we don't set an Accept header, LLHTTPClient will add one like this: - // Accept: application/llsd+xml - // which is really not what we want. - LLSD headers = LLSD::emptyMap(); - headers[HTTP_OUT_HEADER_ACCEPT] = "*/*"; - // Allow cookies in the response, to prevent a redirect loop when accessing join.secondlife.com - headers[HTTP_OUT_HEADER_COOKIE] = ""; - LLHTTPClient::getHeaderOnly( mMediaURL, new LLMimeDiscoveryResponder(this), headers, 10.0f); + LLCoros::instance().launch("LLViewerMediaImpl::mimeDiscoveryCoro", + boost::bind(&LLViewerMediaImpl::mimeDiscoveryCoro, this, _1, mMediaURL)); } else if("data" == scheme || "file" == scheme || "about" == scheme) { @@ -2685,6 +2571,65 @@ void LLViewerMediaImpl::navigateInternal() } } +void LLViewerMediaImpl::mimeDiscoveryCoro(LLCoros::self& self, std::string url) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("mimeDiscoveryCoro", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); + LLCore::HttpHeaders::ptr_t httpHeaders(new LLCore::HttpHeaders); + + mMimeProbe = httpAdapter; + + httpOpts->setHeadersOnly(true); + + httpHeaders->append(HTTP_OUT_HEADER_ACCEPT, "*/*"); + httpHeaders->append(HTTP_OUT_HEADER_COOKIE, ""); + + LLSD result = httpAdapter->getRawAndYield(self, httpRequest, url, httpOpts, httpHeaders); + + mMimeProbe.reset(); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + + if (!status) + { + LL_WARNS() << "Error retrieving media headers." << LL_ENDL; + } + + LLSD resultHeaders = httpResults[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS_HEADERS]; + + const std::string& mediaType = resultHeaders[HTTP_IN_HEADER_CONTENT_TYPE].asStringRef(); + + std::string::size_type idx1 = mediaType.find_first_of(";"); + std::string mimeType = mediaType.substr(0, idx1); + + // We now no longer need to check the error code returned from the probe. + // If we have a mime type, use it. If not, default to the web plugin and let it handle error reporting. + // The probe was successful. + if (mimeType.empty()) + { + // Some sites don't return any content-type header at all. + // Treat an empty mime type as text/html. + mimeType = HTTP_CONTENT_TEXT_HTML; + } + + LL_DEBUGS() << "Media type \"" << mediaType << "\", mime type is \"" << mimeType << "\"" << LL_ENDL; + + // the call to initializeMedia may disconnect the responder, which will clear mMediaImpl. + // Make a local copy so we can call loadURI() afterwards. + + if (!mimeType.empty()) + { + if (initializeMedia(mimeType)) + { + loadURI(); + } + } +} + ////////////////////////////////////////////////////////////////////////////////////////// void LLViewerMediaImpl::navigateStop() { @@ -2783,7 +2728,7 @@ void LLViewerMediaImpl::update() { // Don't load new instances that are at PRIORITY_SLIDESHOW or below. They're just kept around to preserve state. } - else if(mMimeTypeProbe != NULL) + else if (!mMimeProbe.expired()) { // this media source is doing a MIME type probe -- don't try loading it again. } @@ -3673,18 +3618,10 @@ void LLViewerMediaImpl::setNavigateSuspended(bool suspend) void LLViewerMediaImpl::cancelMimeTypeProbe() { - if(mMimeTypeProbe != NULL) - { - // There doesn't seem to be a way to actually cancel an outstanding request. - // Simulate it by telling the LLMimeDiscoveryResponder not to write back any results. - mMimeTypeProbe->cancelRequest(); - - // The above should already have set mMimeTypeProbe to NULL. - if(mMimeTypeProbe != NULL) - { - LL_ERRS() << "internal error: mMimeTypeProbe is not NULL after cancelling request." << LL_ENDL; - } - } + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t probeAdapter = mMimeProbe.lock(); + + if (probeAdapter) + probeAdapter->cancelYieldingOperation(); } void LLViewerMediaImpl::addObject(LLVOVolume* obj) diff --git a/indra/newview/llviewermedia.h b/indra/newview/llviewermedia.h index 6803adfaa2..5658651c6e 100755 --- a/indra/newview/llviewermedia.h +++ b/indra/newview/llviewermedia.h @@ -40,6 +40,9 @@ #include "llnotificationptr.h" #include "llurl.h" +#include "lleventcoro.h" +#include "llcoros.h" +#include "llcorehttputil.h" class LLViewerMediaImpl; class LLUUID; @@ -165,7 +168,10 @@ public: private: static void setOpenIDCookie(); static void onTeleportFinished(); - + + static void openIDSetupCoro(LLCoros::self& self, std::string openidUrl, std::string openidToken); + static void getOpenIDCookieCoro(LLCoros::self& self, std::string url); + static LLPluginCookieStore *sCookieStore; static LLURL sOpenIDURL; static std::string sOpenIDCookie; @@ -180,7 +186,6 @@ class LLViewerMediaImpl public: friend class LLViewerMedia; - friend class LLMimeDiscoveryResponder; LLViewerMediaImpl( const LLUUID& texture_id, @@ -453,7 +458,6 @@ private: S32 mProximity; F64 mProximityDistance; F64 mProximityCamera; - LLMimeDiscoveryResponder *mMimeTypeProbe; bool mMediaAutoPlay; std::string mMediaEntryURL; bool mInNearbyMediaList; // used by LLPanelNearbyMedia::refreshList() for performance reasons @@ -470,6 +474,10 @@ private: BOOL mIsUpdated ; std::list< LLVOVolume* > mObjectList ; + void mimeDiscoveryCoro(LLCoros::self& self, std::string url); + LLCoreHttpUtil::HttpCoroutineAdapter::wptr_t mMimeProbe; + bool mCanceling; + private: LLViewerMediaTexture *updatePlaceholderImage(); }; diff --git a/indra/newview/llwebprofile.cpp b/indra/newview/llwebprofile.cpp index df5f4e3588..a72deafe33 100755 --- a/indra/newview/llwebprofile.cpp +++ b/indra/newview/llwebprofile.cpp @@ -202,7 +202,7 @@ void LLWebProfile::uploadImageCoro(LLCoros::self& self, LLPointer &image, const std::string &boundary) { - LLCore::BufferArray::ptr_t body(new LLCore::BufferArray); + LLCore::BufferArray::ptr_t body(new LLCore::BufferArray, false); LLCore::BufferArrayStream bas(body.get()); // *NOTE: The order seems to matter. -- cgit v1.2.3 From 7fb7e93a13356655e0827c083072e67fe1823fd4 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 28 May 2015 12:48:08 -0700 Subject: Remove the display name floater --- indra/newview/CMakeLists.txt | 4 - indra/newview/llfloaterdisplayname.cpp | 217 --------------------------------- indra/newview/llfloaterdisplayname.h | 38 ------ indra/newview/llpanelme.cpp | 1 - indra/newview/llviewerdisplayname.cpp | 211 -------------------------------- indra/newview/llviewerdisplayname.h | 53 -------- indra/newview/llviewerfloaterreg.cpp | 2 - 7 files changed, 526 deletions(-) delete mode 100755 indra/newview/llfloaterdisplayname.cpp delete mode 100755 indra/newview/llfloaterdisplayname.h delete mode 100755 indra/newview/llviewerdisplayname.cpp delete mode 100755 indra/newview/llviewerdisplayname.h (limited to 'indra') diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index ada27c0282..3553e3a612 100755 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -231,7 +231,6 @@ set(viewer_SOURCE_FILES llfloaterconversationpreview.cpp llfloaterdeleteenvpreset.cpp llfloaterdestinations.cpp - llfloaterdisplayname.cpp llfloatereditdaycycle.cpp llfloatereditsky.cpp llfloatereditwater.cpp @@ -612,7 +611,6 @@ set(viewer_SOURCE_FILES llviewercontrol.cpp llviewercontrollistener.cpp llviewerdisplay.cpp - llviewerdisplayname.cpp llviewerfloaterreg.cpp llviewerfoldertype.cpp llviewergenericmessage.cpp @@ -835,7 +833,6 @@ set(viewer_HEADER_FILES llfloaterconversationpreview.h llfloaterdeleteenvpreset.h llfloaterdestinations.h - llfloaterdisplayname.h llfloatereditdaycycle.h llfloatereditsky.h llfloatereditwater.h @@ -1209,7 +1206,6 @@ set(viewer_HEADER_FILES llviewercontrol.h llviewercontrollistener.h llviewerdisplay.h - llviewerdisplayname.h llviewerfloaterreg.h llviewerfoldertype.h llviewergenericmessage.h diff --git a/indra/newview/llfloaterdisplayname.cpp b/indra/newview/llfloaterdisplayname.cpp deleted file mode 100755 index 596e8c0dbe..0000000000 --- a/indra/newview/llfloaterdisplayname.cpp +++ /dev/null @@ -1,217 +0,0 @@ -/** - * @file llfloaterdisplayname.cpp - * @author Leyla Farazha - * @brief Implementation of the LLFloaterDisplayName class. - * - * $LicenseInfo:firstyear=2002&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - - -#include "llviewerprecompiledheaders.h" -#include "llfloaterreg.h" -#include "llfloater.h" - -#include "llnotificationsutil.h" -#include "llviewerdisplayname.h" - -#include "llnotifications.h" -#include "llfloaterdisplayname.h" -#include "llavatarnamecache.h" - -#include "llagent.h" - - -class LLFloaterDisplayName : public LLFloater -{ -public: - LLFloaterDisplayName(const LLSD& key); - virtual ~LLFloaterDisplayName() { } - /*virtual*/ BOOL postBuild(); - void onSave(); - void onReset(); - void onCancel(); - /*virtual*/ void onOpen(const LLSD& key); - -private: - - void onCacheSetName(bool success, - const std::string& reason, - const LLSD& content); -}; - -LLFloaterDisplayName::LLFloaterDisplayName(const LLSD& key) : - LLFloater(key) -{ -} - -void LLFloaterDisplayName::onOpen(const LLSD& key) -{ - getChild("display_name_editor")->clear(); - getChild("display_name_confirm")->clear(); - - LLAvatarName av_name; - LLAvatarNameCache::get(gAgent.getID(), &av_name); - - F64 now_secs = LLDate::now().secondsSinceEpoch(); - - if (now_secs < av_name.mNextUpdate) - { - // ...can't update until some time in the future - F64 next_update_local_secs = - av_name.mNextUpdate - LLStringOps::getLocalTimeOffset(); - LLDate next_update_local(next_update_local_secs); - // display as "July 18 12:17 PM" - std::string next_update_string = - next_update_local.toHTTPDateString("%B %d %I:%M %p"); - getChild("lockout_text")->setTextArg("[TIME]", next_update_string); - getChild("lockout_text")->setVisible(true); - getChild("save_btn")->setEnabled(false); - getChild("display_name_editor")->setEnabled(false); - getChild("display_name_confirm")->setEnabled(false); - getChild("cancel_btn")->setFocus(TRUE); - - } - else - { - getChild("lockout_text")->setVisible(false); - getChild("save_btn")->setEnabled(true); - getChild("display_name_editor")->setEnabled(true); - getChild("display_name_confirm")->setEnabled(true); - - } -} - -BOOL LLFloaterDisplayName::postBuild() -{ - getChild("reset_btn")->setCommitCallback(boost::bind(&LLFloaterDisplayName::onReset, this)); - getChild("cancel_btn")->setCommitCallback(boost::bind(&LLFloaterDisplayName::onCancel, this)); - getChild("save_btn")->setCommitCallback(boost::bind(&LLFloaterDisplayName::onSave, this)); - - center(); - - return TRUE; -} - -void LLFloaterDisplayName::onCacheSetName(bool success, - const std::string& reason, - const LLSD& content) -{ - if (success) - { - // Inform the user that the change took place, but will take a while - // to percolate. - LLSD args; - args["DISPLAY_NAME"] = content["display_name"]; - LLNotificationsUtil::add("SetDisplayNameSuccess", args); - return; - } - - // Request failed, notify the user - std::string error_tag = content["error_tag"].asString(); - LL_INFOS() << "set name failure error_tag " << error_tag << LL_ENDL; - - // We might have a localized string for this message - // error_args will usually be empty from the server. - if (!error_tag.empty() - && LLNotifications::getInstance()->templateExists(error_tag)) - { - LLNotificationsUtil::add(error_tag); - return; - } - - // The server error might have a localized message for us - std::string lang_code = LLUI::getLanguage(); - LLSD error_desc = content["error_description"]; - if (error_desc.has( lang_code )) - { - LLSD args; - args["MESSAGE"] = error_desc[lang_code].asString(); - LLNotificationsUtil::add("GenericAlert", args); - return; - } - - // No specific error, throw a generic one - LLNotificationsUtil::add("SetDisplayNameFailedGeneric"); -} - -void LLFloaterDisplayName::onCancel() -{ - setVisible(false); -} - -void LLFloaterDisplayName::onReset() -{ - if (LLAvatarNameCache::hasNameLookupURL()) - { - LLViewerDisplayName::set("",boost::bind(&LLFloaterDisplayName::onCacheSetName, this, _1, _2, _3)); - } - else - { - LLNotificationsUtil::add("SetDisplayNameFailedGeneric"); - } - - setVisible(false); -} - - -void LLFloaterDisplayName::onSave() -{ - std::string display_name_utf8 = getChild("display_name_editor")->getValue().asString(); - std::string display_name_confirm = getChild("display_name_confirm")->getValue().asString(); - - if (display_name_utf8.compare(display_name_confirm)) - { - LLNotificationsUtil::add("SetDisplayNameMismatch"); - return; - } - - const U32 DISPLAY_NAME_MAX_LENGTH = 31; // characters, not bytes - LLWString display_name_wstr = utf8string_to_wstring(display_name_utf8); - if (display_name_wstr.size() > DISPLAY_NAME_MAX_LENGTH) - { - LLSD args; - args["LENGTH"] = llformat("%d", DISPLAY_NAME_MAX_LENGTH); - LLNotificationsUtil::add("SetDisplayNameFailedLength", args); - return; - } - - if (LLAvatarNameCache::hasNameLookupURL()) - { - LLViewerDisplayName::set(display_name_utf8,boost::bind(&LLFloaterDisplayName::onCacheSetName, this, _1, _2, _3)); - } - else - { - LLNotificationsUtil::add("SetDisplayNameFailedGeneric"); - } - - setVisible(false); -} - - -////////////////////////////////////////////////////////////////////////////// -// LLInspectObjectUtil -////////////////////////////////////////////////////////////////////////////// -void LLFloaterDisplayNameUtil::registerFloater() -{ - LLFloaterReg::add("display_name", "floater_display_name.xml", - &LLFloaterReg::build); -} diff --git a/indra/newview/llfloaterdisplayname.h b/indra/newview/llfloaterdisplayname.h deleted file mode 100755 index a00bf56712..0000000000 --- a/indra/newview/llfloaterdisplayname.h +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @file llfloaterdisplayname.h - * - * $LicenseInfo:firstyear=2009&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifndef LLFLOATERDISPLAYNAME_H -#define LLFLOATERDISPLAYNAME_H - - -namespace LLFloaterDisplayNameUtil -{ - // Register with LLFloaterReg - void registerFloater(); -} - - - -#endif diff --git a/indra/newview/llpanelme.cpp b/indra/newview/llpanelme.cpp index cedd3025fc..55e4ffff5e 100755 --- a/indra/newview/llpanelme.cpp +++ b/indra/newview/llpanelme.cpp @@ -37,7 +37,6 @@ #include "llfloaterreg.h" #include "llhints.h" #include "llviewercontrol.h" -#include "llviewerdisplayname.h" // Linden libraries #include "llavatarnamecache.h" // IDEVO diff --git a/indra/newview/llviewerdisplayname.cpp b/indra/newview/llviewerdisplayname.cpp deleted file mode 100755 index e390e8776d..0000000000 --- a/indra/newview/llviewerdisplayname.cpp +++ /dev/null @@ -1,211 +0,0 @@ -/** - * @file llviewerdisplayname.cpp - * @brief Wrapper for display name functionality - * - * $LicenseInfo:firstyear=2010&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#include "llviewerprecompiledheaders.h" - -#include "llviewerdisplayname.h" - -// viewer includes -#include "llagent.h" -#include "llviewerregion.h" -#include "llvoavatar.h" - -// library includes -#include "llavatarnamecache.h" -#include "llhttpclient.h" -#include "llhttpnode.h" -#include "llnotificationsutil.h" -#include "llui.h" // getLanguage() - -namespace LLViewerDisplayName -{ - // Fired when viewer receives server response to display name change - set_name_signal_t sSetDisplayNameSignal; - - // Fired when there is a change in the agent's name - name_changed_signal_t sNameChangedSignal; - - void addNameChangedCallback(const name_changed_signal_t::slot_type& cb) - { - sNameChangedSignal.connect(cb); - } - - void doNothing() { } -} - -class LLSetDisplayNameResponder : public LLHTTPClient::Responder -{ - LOG_CLASS(LLSetDisplayNameResponder); -private: - // only care about errors - /*virtual*/ void httpFailure() - { - LL_WARNS() << dumpResponse() << LL_ENDL; - LLViewerDisplayName::sSetDisplayNameSignal(false, "", LLSD()); - LLViewerDisplayName::sSetDisplayNameSignal.disconnect_all_slots(); - } -}; - -void LLViewerDisplayName::set(const std::string& display_name, const set_name_slot_t& slot) -{ - // TODO: simple validation here - - LLViewerRegion* region = gAgent.getRegion(); - llassert(region); - std::string cap_url = region->getCapability("SetDisplayName"); - if (cap_url.empty()) - { - // this server does not support display names, report error - slot(false, "unsupported", LLSD()); - return; - } - - // People API can return localized error messages. Indicate our - // language preference via header. - LLSD headers; - headers[HTTP_OUT_HEADER_ACCEPT_LANGUAGE] = LLUI::getLanguage(); - - // People API requires both the old and new value to change a variable. - // Our display name will be in cache before the viewer's UI is available - // to request a change, so we can use direct lookup without callback. - LLAvatarName av_name; - if (!LLAvatarNameCache::get( gAgent.getID(), &av_name)) - { - slot(false, "name unavailable", LLSD()); - return; - } - - // People API expects array of [ "old value", "new value" ] - LLSD change_array = LLSD::emptyArray(); - change_array.append(av_name.getDisplayName()); - change_array.append(display_name); - - LL_INFOS() << "Set name POST to " << cap_url << LL_ENDL; - - // Record our caller for when the server sends back a reply - sSetDisplayNameSignal.connect(slot); - - // POST the requested change. The sim will not send a response back to - // this request directly, rather it will send a separate message after it - // communicates with the back-end. - LLSD body; - body["display_name"] = change_array; - LLHTTPClient::post(cap_url, body, new LLSetDisplayNameResponder, headers); -} - -class LLSetDisplayNameReply : public LLHTTPNode -{ - LOG_CLASS(LLSetDisplayNameReply); -public: - /*virtual*/ void post( - LLHTTPNode::ResponsePtr response, - const LLSD& context, - const LLSD& input) const - { - LLSD body = input["body"]; - - S32 status = body["status"].asInteger(); - bool success = (status == HTTP_OK); - std::string reason = body["reason"].asString(); - LLSD content = body["content"]; - - LL_INFOS() << "status " << status << " reason " << reason << LL_ENDL; - - // If viewer's concept of display name is out-of-date, the set request - // will fail with 409 Conflict. If that happens, fetch up-to-date - // name information. - if (status == HTTP_CONFLICT) - { - LLUUID agent_id = gAgent.getID(); - // Flush stale data - LLAvatarNameCache::erase( agent_id ); - // Queue request for new data: nothing to do on callback though... - // Note: no need to disconnect the callback as it never gets out of scope - LLAvatarNameCache::get(agent_id, boost::bind(&LLViewerDisplayName::doNothing)); - // Kill name tag, as it is wrong - LLVOAvatar::invalidateNameTag( agent_id ); - } - - // inform caller of result - LLViewerDisplayName::sSetDisplayNameSignal(success, reason, content); - LLViewerDisplayName::sSetDisplayNameSignal.disconnect_all_slots(); - } -}; - - -class LLDisplayNameUpdate : public LLHTTPNode -{ - /*virtual*/ void post( - LLHTTPNode::ResponsePtr response, - const LLSD& context, - const LLSD& input) const - { - LLSD body = input["body"]; - LLUUID agent_id = body["agent_id"]; - std::string old_display_name = body["old_display_name"]; - // By convention this record is called "agent" in the People API - LLSD name_data = body["agent"]; - - // Inject the new name data into cache - LLAvatarName av_name; - av_name.fromLLSD( name_data ); - - LL_INFOS() << "name-update now " << LLDate::now() - << " next_update " << LLDate(av_name.mNextUpdate) - << LL_ENDL; - - // Name expiration time may be provided in headers, or we may use a - // default value - // *TODO: get actual headers out of ResponsePtr - //LLSD headers = response->mHeaders; - LLSD headers; - av_name.mExpires = - LLAvatarNameCache::nameExpirationFromHeaders(headers); - - LLAvatarNameCache::insert(agent_id, av_name); - - // force name tag to update - LLVOAvatar::invalidateNameTag(agent_id); - - LLSD args; - args["OLD_NAME"] = old_display_name; - args["SLID"] = av_name.getUserName(); - args["NEW_NAME"] = av_name.getDisplayName(); - LLNotificationsUtil::add("DisplayNameUpdate", args); - if (agent_id == gAgent.getID()) - { - LLViewerDisplayName::sNameChangedSignal(); - } - } -}; - -LLHTTPRegistration - gHTTPRegistrationMessageSetDisplayNameReply( - "/message/SetDisplayNameReply"); - -LLHTTPRegistration - gHTTPRegistrationMessageDisplayNameUpdate( - "/message/DisplayNameUpdate"); diff --git a/indra/newview/llviewerdisplayname.h b/indra/newview/llviewerdisplayname.h deleted file mode 100755 index 16d59ae43b..0000000000 --- a/indra/newview/llviewerdisplayname.h +++ /dev/null @@ -1,53 +0,0 @@ -/** - * @file llviewerdisplayname.h - * @brief Wrapper for display name functionality - * - * $LicenseInfo:firstyear=2010&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifndef LLVIEWERDISPLAYNAME_H -#define LLVIEWERDISPLAYNAME_H - -#include - -class LLSD; -class LLUUID; - -namespace LLViewerDisplayName -{ - typedef boost::signals2::signal< - void (bool success, const std::string& reason, const LLSD& content)> - set_name_signal_t; - typedef set_name_signal_t::slot_type set_name_slot_t; - - typedef boost::signals2::signal name_changed_signal_t; - typedef name_changed_signal_t::slot_type name_changed_slot_t; - - // Sends an update to the server to change a display name - // and call back when done. May not succeed due to service - // unavailable or name not available. - void set(const std::string& display_name, const set_name_slot_t& slot); - - void addNameChangedCallback(const name_changed_signal_t::slot_type& cb); -} - -#endif // LLVIEWERDISPLAYNAME_H diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp index fc18b20758..55d69528a8 100755 --- a/indra/newview/llviewerfloaterreg.cpp +++ b/indra/newview/llviewerfloaterreg.cpp @@ -56,7 +56,6 @@ #include "llfloaterconversationpreview.h" #include "llfloaterdeleteenvpreset.h" #include "llfloaterdestinations.h" -#include "llfloaterdisplayname.h" #include "llfloatereditdaycycle.h" #include "llfloatereditsky.h" #include "llfloatereditwater.h" @@ -238,7 +237,6 @@ void LLViewerFloaterReg::registerFloaters() LLInspectRemoteObjectUtil::registerFloater(); LLFloaterVoiceVolumeUtil::registerFloater(); LLNotificationsUI::registerFloater(); - LLFloaterDisplayNameUtil::registerFloater(); LLFloaterReg::add("lagmeter", "floater_lagmeter.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("land_holdings", "floater_land_holdings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); -- cgit v1.2.3 From aa47516e895fcc6c2ee8f43ee94e4be73a92a9da Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 28 May 2015 14:02:36 -0700 Subject: Convert LSL syntax download to coroutine. --- indra/newview/llsyntaxid.cpp | 139 +++++++++++++++++++++---------------------- indra/newview/llsyntaxid.h | 10 +++- 2 files changed, 74 insertions(+), 75 deletions(-) (limited to 'indra') diff --git a/indra/newview/llsyntaxid.cpp b/indra/newview/llsyntaxid.cpp index 802dff1ead..fbb800f881 100644 --- a/indra/newview/llsyntaxid.cpp +++ b/indra/newview/llsyntaxid.cpp @@ -34,66 +34,8 @@ #include "llhttpclient.h" #include "llsdserialize.h" #include "llviewerregion.h" +#include "llcorehttputil.h" -//----------------------------------------------------------------------------- -// fetchKeywordsFileResponder -//----------------------------------------------------------------------------- -class fetchKeywordsFileResponder : public LLHTTPClient::Responder -{ -public: - fetchKeywordsFileResponder(const std::string& filespec) - : mFileSpec(filespec) - { - LL_DEBUGS("SyntaxLSL") << "Instantiating with file saving to: '" << filespec << "'" << LL_ENDL; - } - - /* virtual */ void httpFailure() - { - LL_WARNS("SyntaxLSL") << "failed to fetch syntax file [status:" << getStatus() << "]: " << getContent() << LL_ENDL; - } - - /* virtual */ void httpSuccess() - { - // Continue only if a valid LLSD object was returned. - const LLSD& content = getContent(); - if (content.isMap()) - { - if (LLSyntaxIdLSL::getInstance()->isSupportedVersion(content)) - { - LLSyntaxIdLSL::getInstance()->setKeywordsXml(content); - - cacheFile(content); - LLSyntaxIdLSL::getInstance()->handleFileFetched(mFileSpec); - } - else - { - LL_WARNS("SyntaxLSL") << "Unknown or unsupported version of syntax file." << LL_ENDL; - } - } - else - { - LL_WARNS("SyntaxLSL") << "Syntax file '" << mFileSpec << "' contains invalid LLSD." << LL_ENDL; - } - } - - void cacheFile(const LLSD& content_ref) - { - std::stringstream str; - LLSDSerialize::toXML(content_ref, str); - const std::string xml = str.str(); - - // save the str to disk, usually to the cache. - llofstream file(mFileSpec.c_str(), std::ios_base::out); - file.write(xml.c_str(), str.str().size()); - file.close(); - - LL_DEBUGS("SyntaxLSL") << "Syntax file received, saving as: '" << mFileSpec << "'" << LL_ENDL; - } - -private: - std::string mFileSpec; -}; - //----------------------------------------------------------------------------- // LLSyntaxIdLSL //----------------------------------------------------------------------------- @@ -166,13 +108,72 @@ bool LLSyntaxIdLSL::syntaxIdChanged() //----------------------------------------------------------------------------- void LLSyntaxIdLSL::fetchKeywordsFile(const std::string& filespec) { - mInflightFetches.push_back(filespec); - LLHTTPClient::get(mCapabilityURL, - new fetchKeywordsFileResponder(filespec), - LLSD(), 30.f); + LLCoros::instance().launch("LLSyntaxIdLSL::fetchKeywordsFileCoro", + boost::bind(&LLSyntaxIdLSL::fetchKeywordsFileCoro, this, _1, mCapabilityURL, filespec)); LL_DEBUGS("SyntaxLSL") << "LSLSyntaxId capability URL is: " << mCapabilityURL << ". Filename to use is: '" << filespec << "'." << LL_ENDL; } +//----------------------------------------------------------------------------- +// fetchKeywordsFileCoro +//----------------------------------------------------------------------------- +void LLSyntaxIdLSL::fetchKeywordsFileCoro(LLCoros::self& self, std::string url, std::string fileSpec) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("genericPostCoro", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + + std::pair::iterator, bool> insrt = mInflightFetches.insert(fileSpec); + if (!insrt.second) + { + LL_WARNS("SyntaxLSL") << "Already downloading keyword file called \"" << fileSpec << "\"." << LL_ENDL; + return; + } + + LLSD result = httpAdapter->getAndYield(self, httpRequest, url); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + + mInflightFetches.erase(fileSpec); + + if (!status) + { + LL_WARNS("SyntaxLSL") << "Failed to fetch syntax file \"" << fileSpec << "\"" << LL_ENDL; + return; + } + + result.erase(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS); + + if (isSupportedVersion(result)) + { + setKeywordsXml(result); + cacheFile(fileSpec, result); + loadKeywordsIntoLLSD(); + } + else + { + LL_WARNS("SyntaxLSL") << "Unknown or unsupported version of syntax file." << LL_ENDL; + } + +} + +//----------------------------------------------------------------------------- +// cacheFile +//----------------------------------------------------------------------------- +void LLSyntaxIdLSL::cacheFile(const std::string &fileSpec, const LLSD& content_ref) +{ + std::stringstream str; + LLSDSerialize::toXML(content_ref, str); + const std::string xml = str.str(); + + // save the str to disk, usually to the cache. + llofstream file(fileSpec.c_str(), std::ios_base::out); + file.write(xml.c_str(), str.str().size()); + file.close(); + + LL_DEBUGS("SyntaxLSL") << "Syntax file received, saving as: '" << fileSpec << "'" << LL_ENDL; +} //----------------------------------------------------------------------------- // initialize @@ -260,8 +261,8 @@ void LLSyntaxIdLSL::loadDefaultKeywordsIntoLLSD() // loadKeywordsFileIntoLLSD //----------------------------------------------------------------------------- /** - * @brief Load xml serialised LLSD - * @desc Opens the specified filespec and attempts to deserialise the + * @brief Load xml serialized LLSD + * @desc Opens the specified filespec and attempts to deserializes the * contained data to the specified LLSD object. indicate success/failure with * sLoaded/sLoadFailed members. */ @@ -276,7 +277,7 @@ void LLSyntaxIdLSL::loadKeywordsIntoLLSD() { if (isSupportedVersion(content)) { - LL_DEBUGS("SyntaxLSL") << "Deserialised: " << mFullFileSpec << LL_ENDL; + LL_DEBUGS("SyntaxLSL") << "Deserialized: " << mFullFileSpec << LL_ENDL; } else { @@ -317,12 +318,6 @@ void LLSyntaxIdLSL::handleCapsReceived(const LLUUID& region_uuid) } } -void LLSyntaxIdLSL::handleFileFetched(const std::string& filepath) -{ - mInflightFetches.remove(filepath); - loadKeywordsIntoLLSD(); -} - boost::signals2::connection LLSyntaxIdLSL::addSyntaxIDCallback(const syntax_id_changed_signal_t::slot_type& cb) { return mSyntaxIDChangedSignal.connect(cb); diff --git a/indra/newview/llsyntaxid.h b/indra/newview/llsyntaxid.h index 504fb0997e..47de94cea2 100644 --- a/indra/newview/llsyntaxid.h +++ b/indra/newview/llsyntaxid.h @@ -31,6 +31,8 @@ #include "llviewerprecompiledheaders.h" #include "llsingleton.h" +#include "lleventcoro.h" +#include "llcoros.h" class fetchKeywordsFileResponder; @@ -40,7 +42,7 @@ class LLSyntaxIdLSL : public LLSingleton friend class fetchKeywordsFileResponder; private: - std::list mInflightFetches; + std::set mInflightFetches; typedef boost::signals2::signal syntax_id_changed_signal_t; syntax_id_changed_signal_t mSyntaxIDChangedSignal; boost::signals2::connection mRegionChangedCallback; @@ -49,13 +51,15 @@ private: bool isSupportedVersion(const LLSD& content); void handleRegionChanged(); void handleCapsReceived(const LLUUID& region_uuid); - void handleFileFetched(const std::string& filepath); void setKeywordsXml(const LLSD& content) { mKeywordsXml = content; }; void buildFullFileSpec(); void fetchKeywordsFile(const std::string& filespec); void loadDefaultKeywordsIntoLLSD(); void loadKeywordsIntoLLSD(); - + + void fetchKeywordsFileCoro(LLCoros::self& self, std::string url, std::string fileSpec); + void cacheFile(const std::string &fileSpec, const LLSD& content_ref); + std::string mCapabilityURL; std::string mFullFileSpec; ELLPath mFilePath; -- cgit v1.2.3 From 4fb588187106b18724d730e6235fc57454744341 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 29 May 2015 10:22:46 -0700 Subject: Set media viewer mime probe to follow redirection. Coroutines for group moderation. --- indra/newview/llspeakers.cpp | 98 ++++++++++++++++++++--------------------- indra/newview/llspeakers.h | 4 ++ indra/newview/llviewermedia.cpp | 1 + 3 files changed, 54 insertions(+), 49 deletions(-) (limited to 'indra') diff --git a/indra/newview/llspeakers.cpp b/indra/newview/llspeakers.cpp index 7867e1573c..125b7e5355 100755 --- a/indra/newview/llspeakers.cpp +++ b/indra/newview/llspeakers.cpp @@ -39,6 +39,7 @@ #include "llviewerregion.h" #include "llvoavatar.h" #include "llworld.h" +#include "llcorehttputil.h" extern LLControlGroup gSavedSettings; @@ -264,49 +265,6 @@ bool LLSpeakersDelayActionsStorage::isTimerStarted(const LLUUID& speaker_id) return (mActionTimersMap.size() > 0) && (mActionTimersMap.find(speaker_id) != mActionTimersMap.end()); } -// -// ModerationResponder -// - -class ModerationResponder : public LLHTTPClient::Responder -{ - LOG_CLASS(ModerationResponder); -public: - ModerationResponder(const LLUUID& session_id) - { - mSessionID = session_id; - } - -protected: - virtual void httpFailure() - { - LL_WARNS() << dumpResponse() << LL_ENDL; - - if ( gIMMgr ) - { - //403 == you're not a mod - //should be disabled if you're not a moderator - if ( HTTP_FORBIDDEN == getStatus() ) - { - gIMMgr->showSessionEventError( - "mute", - "not_a_mod_error", - mSessionID); - } - else - { - gIMMgr->showSessionEventError( - "mute", - "generic_request_error", - mSessionID); - } - } - } - -private: - LLUUID mSessionID; -}; - // // LLSpeakerMgr // @@ -883,7 +841,8 @@ void LLIMSpeakerMgr::toggleAllowTextChat(const LLUUID& speaker_id) //current value represents ability to type, so invert data["params"]["mute_info"]["text"] = !speakerp->mModeratorMutedText; - LLHTTPClient::post(url, data, new ModerationResponder(getSessionID())); + LLCoros::instance().launch("LLIMSpeakerMgr::moderationActionCoro", + boost::bind(&LLIMSpeakerMgr::moderationActionCoro, this, _1, url, data)); } void LLIMSpeakerMgr::moderateVoiceParticipant(const LLUUID& avatar_id, bool unmute) @@ -907,10 +866,50 @@ void LLIMSpeakerMgr::moderateVoiceParticipant(const LLUUID& avatar_id, bool unmu data["params"]["mute_info"] = LLSD::emptyMap(); data["params"]["mute_info"]["voice"] = !unmute; - LLHTTPClient::post( - url, - data, - new ModerationResponder(getSessionID())); + LLCoros::instance().launch("LLIMSpeakerMgr::moderationActionCoro", + boost::bind(&LLIMSpeakerMgr::moderationActionCoro, this, _1, url, data)); +} + +void LLIMSpeakerMgr::moderationActionCoro(LLCoros::self& self, std::string url, LLSD action) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("moderationActionCoro", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + LLCore::HttpOptions::ptr_t httpOpts = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions); + + httpOpts->setWantHeaders(true); + + LLUUID sessionId = action["session-id"]; + + LLSD result = httpAdapter->postAndYield(self, httpRequest, url, action, httpOpts); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + + if (!status) + { + if (gIMMgr) + { + //403 == you're not a mod + //should be disabled if you're not a moderator + if (status == LLCore::HttpStatus(HTTP_FORBIDDEN)) + { + gIMMgr->showSessionEventError( + "mute", + "not_a_mod_error", + sessionId); + } + else + { + gIMMgr->showSessionEventError( + "mute", + "generic_request_error", + sessionId); + } + } + return; + } } void LLIMSpeakerMgr::moderateVoiceAllParticipants( bool unmute_everyone ) @@ -949,7 +948,8 @@ void LLIMSpeakerMgr::moderateVoiceSession(const LLUUID& session_id, bool disallo data["params"]["update_info"]["moderated_mode"] = LLSD::emptyMap(); data["params"]["update_info"]["moderated_mode"]["voice"] = disallow_voice; - LLHTTPClient::post(url, data, new ModerationResponder(session_id)); + LLCoros::instance().launch("LLIMSpeakerMgr::moderationActionCoro", + boost::bind(&LLIMSpeakerMgr::moderationActionCoro, this, _1, url, data)); } void LLIMSpeakerMgr::forceVoiceModeratedMode(bool should_be_muted) diff --git a/indra/newview/llspeakers.h b/indra/newview/llspeakers.h index 0e69184125..1f3b2f584c 100755 --- a/indra/newview/llspeakers.h +++ b/indra/newview/llspeakers.h @@ -30,6 +30,8 @@ #include "llevent.h" #include "lleventtimer.h" #include "llvoicechannel.h" +#include "lleventcoro.h" +#include "llcoros.h" class LLSpeakerMgr; @@ -333,6 +335,8 @@ protected: */ void forceVoiceModeratedMode(bool should_be_muted); + void moderationActionCoro(LLCoros::self& self, std::string url, LLSD action); + }; class LLActiveSpeakerMgr : public LLSpeakerMgr, public LLSingleton diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp index 02167b099e..33421cba90 100755 --- a/indra/newview/llviewermedia.cpp +++ b/indra/newview/llviewermedia.cpp @@ -2582,6 +2582,7 @@ void LLViewerMediaImpl::mimeDiscoveryCoro(LLCoros::self& self, std::string url) mMimeProbe = httpAdapter; + httpOpts->setFollowRedirects(true); httpOpts->setHeadersOnly(true); httpHeaders->append(HTTP_OUT_HEADER_ACCEPT, "*/*"); -- cgit v1.2.3 From d41ad508bf10643c3bfeb70dd8f39e187d618a02 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 29 May 2015 13:17:03 -0700 Subject: Land SKU descriptions by coro --- indra/newview/llproductinforequest.cpp | 63 ++++++++++++++++++---------------- indra/newview/llproductinforequest.h | 21 +++++++----- 2 files changed, 45 insertions(+), 39 deletions(-) (limited to 'indra') diff --git a/indra/newview/llproductinforequest.cpp b/indra/newview/llproductinforequest.cpp index e92bf4590d..fd948765b3 100755 --- a/indra/newview/llproductinforequest.cpp +++ b/indra/newview/llproductinforequest.cpp @@ -32,31 +32,10 @@ #include "llagent.h" // for gAgent #include "lltrans.h" #include "llviewerregion.h" +#include "llcorehttputil.h" -class LLProductInfoRequestResponder : public LLHTTPClient::Responder -{ - LOG_CLASS(LLProductInfoRequestResponder); -private: - //If we get back a normal response, handle it here - /* virtual */ void httpSuccess() - { - const LLSD& content = getContent(); - if (!content.isArray()) - { - failureResult(HTTP_INTERNAL_ERROR, "Malformed response contents", content); - return; - } - LLProductInfoRequestManager::instance().setSkuDescriptions(getContent()); - } - - //If we get back an error (not found, etc...), handle it here - /* virtual */ void httpFailure() - { - LL_WARNS() << dumpResponse() << LL_ENDL; - } -}; - -LLProductInfoRequestManager::LLProductInfoRequestManager() : mSkuDescriptions() +LLProductInfoRequestManager::LLProductInfoRequestManager(): + mSkuDescriptions() { } @@ -65,15 +44,11 @@ void LLProductInfoRequestManager::initSingleton() std::string url = gAgent.getRegion()->getCapability("ProductInfoRequest"); if (!url.empty()) { - LLHTTPClient::get(url, new LLProductInfoRequestResponder()); + LLCoros::instance().launch("LLProductInfoRequestManager::getLandDescriptionsCoro", + boost::bind(&LLProductInfoRequestManager::getLandDescriptionsCoro, this, _1, url)); } } -void LLProductInfoRequestManager::setSkuDescriptions(const LLSD& content) -{ - mSkuDescriptions = content; -} - std::string LLProductInfoRequestManager::getDescriptionForSku(const std::string& sku) { // The description LLSD is an array of maps; each array entry @@ -90,3 +65,31 @@ std::string LLProductInfoRequestManager::getDescriptionForSku(const std::string& } return LLTrans::getString("land_type_unknown"); } + +void LLProductInfoRequestManager::getLandDescriptionsCoro(LLCoros::self& self, std::string url) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("genericPostCoro", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + + LLSD result = httpAdapter->getAndYield(self, httpRequest, url); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + + if (!status) + { + return; + } + + if (result.has(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS_CONTENT) && + result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS_CONTENT].isArray()) + { + mSkuDescriptions = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS_CONTENT]; + } + else + { + LL_WARNS() << "Land SKU description response is malformed" << LL_ENDL; + } +} diff --git a/indra/newview/llproductinforequest.h b/indra/newview/llproductinforequest.h index fe8f7093b0..44aaa9d6e4 100755 --- a/indra/newview/llproductinforequest.h +++ b/indra/newview/llproductinforequest.h @@ -30,25 +30,28 @@ #include "llhttpclient.h" #include "llmemory.h" +#include "lleventcoro.h" +#include "llcoros.h" -/* - This is a singleton to manage a cache of information about land types. - The land system provides a capability to get information about the - set of possible land sku, name, and description information. - We use description in the UI, but the sku is provided in the various - messages; this tool provides translation between the systems. +/** + * This is a singleton to manage a cache of information about land types. + * The land system provides a capability to get information about the + * set of possible land sku, name, and description information. + * We use description in the UI, but the sku is provided in the various + * messages; this tool provides translation between the systems. */ - class LLProductInfoRequestManager : public LLSingleton { public: LLProductInfoRequestManager(); - void setSkuDescriptions(const LLSD& content); std::string getDescriptionForSku(const std::string& sku); + private: friend class LLSingleton; /* virtual */ void initSingleton(); - LLSD mSkuDescriptions; + + void getLandDescriptionsCoro(LLCoros::self& self, std::string url); + LLSD mSkuDescriptions; }; #endif // LL_LLPRODUCTINFOREQUEST_H -- cgit v1.2.3 From 68da6fa846fee1e3c5fb478945ef54f83a86aacd Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 1 Jun 2015 16:54:53 -0700 Subject: Set follow redirects so that the default is the same when no options are are specified and when follow redirects is not specified on the options object. --- indra/llcorehttp/httpoptions.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/llcorehttp/httpoptions.cpp b/indra/llcorehttp/httpoptions.cpp index 2b42bcaf6d..3459a37aff 100755 --- a/indra/llcorehttp/httpoptions.cpp +++ b/indra/llcorehttp/httpoptions.cpp @@ -40,7 +40,7 @@ HttpOptions::HttpOptions() : RefCounted(true), mTransferTimeout(HTTP_REQUEST_XFER_TIMEOUT_DEFAULT), mRetries(HTTP_RETRY_COUNT_DEFAULT), mUseRetryAfter(HTTP_USE_RETRY_AFTER_DEFAULT), - mFollowRedirects(false), + mFollowRedirects(true), mVerifyPeer(false), mVerifyHost(false), mDNSCacheTimeout(-1L), -- cgit v1.2.3 From 2abfc14946dc7c544e74931cfe1df887e508a936 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 1 Jun 2015 16:56:42 -0700 Subject: Marketplace vendor outbox. Incomplete conversion. Still issues with redirection. --- indra/newview/llmarketplacefunctions.cpp | 172 +++++++++++++++++++++++++++++-- indra/newview/llviewermedia.cpp | 12 +++ indra/newview/llviewermedia.h | 1 + 3 files changed, 174 insertions(+), 11 deletions(-) (limited to 'indra') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index 4a7a4e268d..d095623b2e 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -36,7 +36,9 @@ #include "llviewercontrol.h" #include "llviewermedia.h" #include "llviewernetwork.h" - +#include "lleventcoro.h" +#include "llcoros.h" +#include "llcorehttputil.h" // // Helpers @@ -117,11 +119,76 @@ namespace LLMarketplaceImport static S32 sImportResultStatus = 0; static LLSD sImportResults = LLSD::emptyMap(); +#if 0 static LLTimer slmGetTimer; static LLTimer slmPostTimer; - +#endif // Responders - + +#if 1 + void marketplacePostCoro(LLCoros::self& self, std::string url) + { + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("marketplacePostCoro", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + LLCore::HttpHeaders::ptr_t httpHeaders(new LLCore::HttpHeaders); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); + + httpOpts->setWantHeaders(true); + httpOpts->setFollowRedirects(false); + + httpHeaders->append(HTTP_OUT_HEADER_ACCEPT, "*/*"); + httpHeaders->append(HTTP_OUT_HEADER_CONNECTION, "Keep-Alive"); + httpHeaders->append(HTTP_OUT_HEADER_COOKIE, sMarketplaceCookie); + httpHeaders->append(HTTP_OUT_HEADER_CONTENT_TYPE, HTTP_CONTENT_XML); + httpHeaders->append(HTTP_OUT_HEADER_USER_AGENT, LLViewerMedia::getCurrentUserAgent()); + + LLSD result = httpAdapter->postAndYield(self, httpRequest, url, LLSD(), httpOpts, httpHeaders); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + + S32 httpCode = status.getType(); + if ((httpCode == MarketplaceErrorCodes::IMPORT_REDIRECT) || + (httpCode == MarketplaceErrorCodes::IMPORT_AUTHENTICATION_ERROR) || + // MAINT-2301 : we determined we can safely ignore that error in that context + (httpCode == MarketplaceErrorCodes::IMPORT_JOB_TIMEOUT)) + { + if (gSavedSettings.getBOOL("InventoryOutboxLogging")) + { + LL_INFOS() << " SLM POST : Ignoring time out status and treating it as success" << LL_ENDL; + } + httpCode = MarketplaceErrorCodes::IMPORT_DONE; + } + + if (httpCode >= MarketplaceErrorCodes::IMPORT_BAD_REQUEST) + { + if (gSavedSettings.getBOOL("InventoryOutboxLogging")) + { + LL_INFOS() << " SLM POST clearing marketplace cookie due to client or server error" << LL_ENDL; + } + sMarketplaceCookie.clear(); + } + + sImportInProgress = (httpCode == MarketplaceErrorCodes::IMPORT_DONE); + sImportPostPending = false; + sImportResultStatus = httpCode; + + { + std::stringstream str; + LLSDSerialize::toPrettyXML(result, str); + + LL_INFOS() << "Full results:\n" << str.str() << "\n" << LL_ENDL; + } + + result.erase(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS); + sImportId = result; + + } + + +#else class LLImportPostResponder : public LLHTTPClient::Responder { LOG_CLASS(LLImportPostResponder); @@ -167,7 +234,75 @@ namespace LLMarketplaceImport sImportId = getContent(); } }; - +#endif + +#if 1 + void marketplaceGetCoro(LLCoros::self& self, std::string url, bool buildHeaders) + { + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("marketplacePostCoro", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + LLCore::HttpHeaders::ptr_t httpHeaders; + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); + + httpOpts->setWantHeaders(true); + httpOpts->setFollowRedirects(false); + + if (buildHeaders) + { + httpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders); + + httpHeaders->append(HTTP_OUT_HEADER_ACCEPT, "*/*"); + httpHeaders->append(HTTP_OUT_HEADER_COOKIE, sMarketplaceCookie); + httpHeaders->append(HTTP_OUT_HEADER_CONTENT_TYPE, HTTP_CONTENT_LLSD_XML); + httpHeaders->append(HTTP_OUT_HEADER_USER_AGENT, LLViewerMedia::getCurrentUserAgent()); + } + else + { + httpHeaders = LLViewerMedia::getHttpHeaders(); + } + + LLSD result = httpAdapter->getAndYield(self, httpRequest, url, httpOpts, httpHeaders); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + LLSD resultHeaders = httpResults[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS_HEADERS]; + + if (sMarketplaceCookie.empty() && resultHeaders.has(HTTP_IN_HEADER_SET_COOKIE)) + { + sMarketplaceCookie = resultHeaders[HTTP_IN_HEADER_SET_COOKIE].asString(); + } + + // MAINT-2452 : Do not clear the cookie on IMPORT_DONE_WITH_ERRORS : Happens when trying to import objects with wrong permissions + // ACME-1221 : Do not clear the cookie on IMPORT_NOT_FOUND : Happens for newly created Merchant accounts that are initially empty + S32 httpCode = status.getType(); + if ((httpCode >= MarketplaceErrorCodes::IMPORT_BAD_REQUEST) && + (httpCode != MarketplaceErrorCodes::IMPORT_DONE_WITH_ERRORS) && + (httpCode != MarketplaceErrorCodes::IMPORT_NOT_FOUND)) + { + if (gSavedSettings.getBOOL("InventoryOutboxLogging")) + { + LL_INFOS() << " SLM GET clearing marketplace cookie due to client or server error" << LL_ENDL; + } + sMarketplaceCookie.clear(); + } + else if (gSavedSettings.getBOOL("InventoryOutboxLogging") && (httpCode >= MarketplaceErrorCodes::IMPORT_BAD_REQUEST)) + { + LL_INFOS() << " SLM GET : Got error status = " << httpCode << ", but marketplace cookie not cleared." << LL_ENDL; + } + + sImportInProgress = (httpCode == MarketplaceErrorCodes::IMPORT_PROCESSING); + sImportGetPending = false; + sImportResultStatus = httpCode; + + result.erase(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS); + sImportResults = result; + + + } + +#else class LLImportGetResponder : public LLHTTPClient::Responder { LOG_CLASS(LLImportGetResponder); @@ -193,7 +328,7 @@ namespace LLMarketplaceImport } // MAINT-2452 : Do not clear the cookie on IMPORT_DONE_WITH_ERRORS : Happens when trying to import objects with wrong permissions - // ACME-1221 : Do not clear the cookie on IMPORT_NOT_FOUND : Happens for newly created Merchant accounts that are initally empty + // ACME-1221 : Do not clear the cookie on IMPORT_NOT_FOUND : Happens for newly created Merchant accounts that are initially empty S32 status = getStatus(); if ((status >= MarketplaceErrorCodes::IMPORT_BAD_REQUEST) && (status != MarketplaceErrorCodes::IMPORT_DONE_WITH_ERRORS) && @@ -216,6 +351,7 @@ namespace LLMarketplaceImport sImportResults = getContent(); } }; +#endif // Basic API @@ -266,8 +402,13 @@ namespace LLMarketplaceImport sImportGetPending = true; std::string url = getInventoryImportURL(); - - if (gSavedSettings.getBOOL("InventoryOutboxLogging")) + +#if 1 + LLCoros::instance().launch("marketplaceGetCoro", + boost::bind(&marketplaceGetCoro, _1, url, false)); + +#else + if (gSavedSettings.getBOOL("InventoryOutboxLogging")) { LL_INFOS() << " SLM GET: establishMarketplaceSessionCookie, LLHTTPClient::get, url = " << url << LL_ENDL; LLSD headers = LLViewerMedia::getHeaders(); @@ -279,7 +420,7 @@ namespace LLMarketplaceImport slmGetTimer.start(); LLHTTPClient::get(url, new LLImportGetResponder(), LLViewerMedia::getHeaders()); - +#endif return true; } @@ -296,6 +437,11 @@ namespace LLMarketplaceImport url += sImportId.asString(); +#if 1 + LLCoros::instance().launch("marketplaceGetCoro", + boost::bind(&marketplaceGetCoro, _1, url, true)); + +#else // Make the headers for the post LLSD headers = LLSD::emptyMap(); headers[HTTP_OUT_HEADER_ACCEPT] = "*/*"; @@ -315,7 +461,7 @@ namespace LLMarketplaceImport slmGetTimer.start(); LLHTTPClient::get(url, new LLImportGetResponder(), headers); - +#endif return true; } @@ -334,6 +480,11 @@ namespace LLMarketplaceImport std::string url = getInventoryImportURL(); +#if 1 + LLCoros::instance().launch("marketplacePostCoro", + boost::bind(&marketplacePostCoro, _1, url)); + +#else // Make the headers for the post LLSD headers = LLSD::emptyMap(); headers[HTTP_OUT_HEADER_ACCEPT] = "*/*"; @@ -353,7 +504,7 @@ namespace LLMarketplaceImport slmPostTimer.start(); LLHTTPClient::post(url, LLSD(), new LLImportPostResponder(), headers); - +#endif return true; } } @@ -362,7 +513,6 @@ namespace LLMarketplaceImport // // Interface class // - static const F32 MARKET_IMPORTER_UPDATE_FREQUENCY = 1.0f; //static diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp index 33421cba90..6784c97192 100755 --- a/indra/newview/llviewermedia.cpp +++ b/indra/newview/llviewermedia.cpp @@ -1205,6 +1205,18 @@ LLSD LLViewerMedia::getHeaders() return headers; } +LLCore::HttpHeaders::ptr_t LLViewerMedia::getHttpHeaders() +{ + LLCore::HttpHeaders::ptr_t headers(new LLCore::HttpHeaders); + + headers->append(HTTP_OUT_HEADER_ACCEPT, "*/*"); + headers->append(HTTP_OUT_HEADER_CONTENT_TYPE, HTTP_CONTENT_XML); + headers->append(HTTP_OUT_HEADER_COOKIE, sOpenIDCookie); + headers->append(HTTP_OUT_HEADER_USER_AGENT, getCurrentUserAgent()); + + return headers; +} + ///////////////////////////////////////////////////////////////////////////////////////// // static void LLViewerMedia::setOpenIDCookie() diff --git a/indra/newview/llviewermedia.h b/indra/newview/llviewermedia.h index 5658651c6e..ff9840627c 100755 --- a/indra/newview/llviewermedia.h +++ b/indra/newview/llviewermedia.h @@ -164,6 +164,7 @@ public: static void setOnlyAudibleMediaTextureID(const LLUUID& texture_id); static LLSD getHeaders(); + static LLCore::HttpHeaders::ptr_t getHttpHeaders(); private: static void setOpenIDCookie(); -- cgit v1.2.3 From bd3dc9cfe24ffc433783201e854f00bbd07aed54 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 3 Jun 2015 11:21:19 -0700 Subject: Coroutines for Script info floater and land auction prep. --- indra/newview/llfloaterauction.cpp | 11 +- indra/newview/llfloaterscriptlimits.cpp | 572 +++++++++++--------------------- indra/newview/llfloaterscriptlimits.h | 58 +--- 3 files changed, 215 insertions(+), 426 deletions(-) (limited to 'indra') diff --git a/indra/newview/llfloaterauction.cpp b/indra/newview/llfloaterauction.cpp index 51b59a7a74..fbffb81fcc 100755 --- a/indra/newview/llfloaterauction.cpp +++ b/indra/newview/llfloaterauction.cpp @@ -57,6 +57,7 @@ #include "llsdutil.h" #include "llsdutil_math.h" #include "lltrans.h" +#include "llcorehttputil.h" ///---------------------------------------------------------------------------- /// Local function declarations, constants, enums, and typedefs @@ -361,7 +362,10 @@ void LLFloaterAuction::doResetParcel() LL_INFOS() << "Sending parcel update to reset for auction via capability to: " << mParcelUpdateCapUrl << LL_ENDL; - LLHTTPClient::post(mParcelUpdateCapUrl, body, new LLHTTPClient::Responder()); + + LLCoreHttpUtil::HttpCoroutineAdapter::messageHttpPost(mParcelUpdateCapUrl, body, + "Parcel reset for auction", + "Parcel not set for auction."); // Send a message to clear the object return time LLMessageSystem *msg = gMessageSystem; @@ -511,7 +515,10 @@ void LLFloaterAuction::doSellToAnyone() LL_INFOS() << "Sending parcel update to sell to anyone for L$1 via capability to: " << mParcelUpdateCapUrl << LL_ENDL; - LLHTTPClient::post(mParcelUpdateCapUrl, body, new LLHTTPClient::Responder()); + + LLCoreHttpUtil::HttpCoroutineAdapter::messageHttpPost(mParcelUpdateCapUrl, body, + "Parcel set as sell to everyone.", + "Parcel sell to everyone failed."); // clean up floater, and get out cleanupAndClose(); diff --git a/indra/newview/llfloaterscriptlimits.cpp b/indra/newview/llfloaterscriptlimits.cpp index 166ef5ed7a..be18565670 100755 --- a/indra/newview/llfloaterscriptlimits.cpp +++ b/indra/newview/llfloaterscriptlimits.cpp @@ -50,6 +50,7 @@ #include "llviewerparcelmgr.h" #include "llviewerregion.h" #include "llviewerwindow.h" +#include "llcorehttputil.h" ///---------------------------------------------------------------------------- /// LLFloaterScriptLimits @@ -179,372 +180,6 @@ void LLPanelScriptLimitsInfo::updateChild(LLUICtrl* child_ctr) { } -///---------------------------------------------------------------------------- -// Responders -///---------------------------------------------------------------------------- - -void fetchScriptLimitsRegionInfoResponder::httpSuccess() -{ - const LLSD& content = getContent(); - if (!content.isMap()) - { - failureResult(HTTP_INTERNAL_ERROR, "Malformed response contents", content); - return; - } - //we don't need to test with a fake respose here (shouldn't anyway) - -#ifdef DUMP_REPLIES_TO_LLINFOS - - LLSDNotationStreamer notation_streamer(content); - std::ostringstream nice_llsd; - nice_llsd << notation_streamer; - - OSMessageBox(nice_llsd.str(), "main cap response:", 0); - - LL_INFOS() << "main cap response:" << content << LL_ENDL; - -#endif - - // at this point we have an llsd which should contain ether one or two urls to the services we want. - // first we look for the details service: - if(content.has("ScriptResourceDetails")) - { - LLHTTPClient::get(content["ScriptResourceDetails"], new fetchScriptLimitsRegionDetailsResponder(mInfo)); - } - else - { - LLFloaterScriptLimits* instance = LLFloaterReg::getTypedInstance("script_limits"); - if(!instance) - { - LL_WARNS() << "Failed to get llfloaterscriptlimits instance" << LL_ENDL; - } - } - - // then the summary service: - if(content.has("ScriptResourceSummary")) - { - LLHTTPClient::get(content["ScriptResourceSummary"], new fetchScriptLimitsRegionSummaryResponder(mInfo)); - } -} - -void fetchScriptLimitsRegionInfoResponder::httpFailure() -{ - LL_WARNS() << dumpResponse() << LL_ENDL; -} - -void fetchScriptLimitsRegionSummaryResponder::httpSuccess() -{ - const LLSD& content_ref = getContent(); -#ifdef USE_FAKE_RESPONSES - - LLSD fake_content; - LLSD summary = LLSD::emptyMap(); - LLSD available = LLSD::emptyArray(); - LLSD available_urls = LLSD::emptyMap(); - LLSD available_memory = LLSD::emptyMap(); - LLSD used = LLSD::emptyArray(); - LLSD used_urls = LLSD::emptyMap(); - LLSD used_memory = LLSD::emptyMap(); - - used_urls["type"] = "urls"; - used_urls["amount"] = FAKE_NUMBER_OF_URLS; - available_urls["type"] = "urls"; - available_urls["amount"] = FAKE_AVAILABLE_URLS; - used_memory["type"] = "memory"; - used_memory["amount"] = FAKE_AMOUNT_OF_MEMORY; - available_memory["type"] = "memory"; - available_memory["amount"] = FAKE_AVAILABLE_MEMORY; - -//summary response:{'summary':{'available':[{'amount':i731,'type':'urls'},{'amount':i895577,'type':'memory'},{'amount':i731,'type':'urls'},{'amount':i895577,'type':'memory'}],'used':[{'amount':i329,'type':'urls'},{'amount':i66741,'type':'memory'}]}} - - used.append(used_urls); - used.append(used_memory); - available.append(available_urls); - available.append(available_memory); - - summary["available"] = available; - summary["used"] = used; - - fake_content["summary"] = summary; - - const LLSD& content = fake_content; - -#else - - const LLSD& content = content_ref; - -#endif - - if (!content.isMap()) - { - failureResult(HTTP_INTERNAL_ERROR, "Malformed response contents", content); - return; - } - - -#ifdef DUMP_REPLIES_TO_LLINFOS - - LLSDNotationStreamer notation_streamer(content); - std::ostringstream nice_llsd; - nice_llsd << notation_streamer; - - OSMessageBox(nice_llsd.str(), "summary response:", 0); - - LL_WARNS() << "summary response:" << *content << LL_ENDL; - -#endif - - LLFloaterScriptLimits* instance = LLFloaterReg::getTypedInstance("script_limits"); - if(!instance) - { - LL_WARNS() << "Failed to get llfloaterscriptlimits instance" << LL_ENDL; - } - else - { - LLTabContainer* tab = instance->getChild("scriptlimits_panels"); - if(tab) - { - LLPanelScriptLimitsRegionMemory* panel_memory = (LLPanelScriptLimitsRegionMemory*)tab->getChild("script_limits_region_memory_panel"); - if(panel_memory) - { - panel_memory->getChild("loading_text")->setValue(LLSD(std::string(""))); - - LLButton* btn = panel_memory->getChild("refresh_list_btn"); - if(btn) - { - btn->setEnabled(true); - } - - panel_memory->setRegionSummary(content); - } - } - } -} - -void fetchScriptLimitsRegionSummaryResponder::httpFailure() -{ - LL_WARNS() << dumpResponse() << LL_ENDL; -} - -void fetchScriptLimitsRegionDetailsResponder::httpSuccess() -{ - const LLSD& content_ref = getContent(); -#ifdef USE_FAKE_RESPONSES -/* -Updated detail service, ** denotes field added: - -result (map) -+-parcels (array of maps) - +-id (uuid) - +-local_id (S32)** - +-name (string) - +-owner_id (uuid) (in ERS as owner, but owner_id in code) - +-objects (array of maps) - +-id (uuid) - +-name (string) - +-owner_id (uuid) (in ERS as owner, in code as owner_id) - +-owner_name (sting)** - +-location (map)** - +-x (float) - +-y (float) - +-z (float) - +-resources (map) (this is wrong in the ERS but right in code) - +-type (string) - +-amount (int) -*/ - LLSD fake_content; - LLSD resource = LLSD::emptyMap(); - LLSD location = LLSD::emptyMap(); - LLSD object = LLSD::emptyMap(); - LLSD objects = LLSD::emptyArray(); - LLSD parcel = LLSD::emptyMap(); - LLSD parcels = LLSD::emptyArray(); - - resource["urls"] = FAKE_NUMBER_OF_URLS; - resource["memory"] = FAKE_AMOUNT_OF_MEMORY; - - location["x"] = 128.0f; - location["y"] = 128.0f; - location["z"] = 0.0f; - - object["id"] = LLUUID("d574a375-0c6c-fe3d-5733-da669465afc7"); - object["name"] = "Gabs fake Object!"; - object["owner_id"] = LLUUID("8dbf2d41-69a0-4e5e-9787-0c9d297bc570"); - object["owner_name"] = "Gabs Linden"; - object["location"] = location; - object["resources"] = resource; - - objects.append(object); - - parcel["id"] = LLUUID("da05fb28-0d20-e593-2728-bddb42dd0160"); - parcel["local_id"] = 42; - parcel["name"] = "Gabriel Linden\'s Sub Plot"; - parcel["objects"] = objects; - parcels.append(parcel); - - fake_content["parcels"] = parcels; - const LLSD& content = fake_content; - -#else - - const LLSD& content = content_ref; - -#endif - - if (!content.isMap()) - { - failureResult(HTTP_INTERNAL_ERROR, "Malformed response contents", content); - return; - } - -#ifdef DUMP_REPLIES_TO_LLINFOS - - LLSDNotationStreamer notation_streamer(content); - std::ostringstream nice_llsd; - nice_llsd << notation_streamer; - - OSMessageBox(nice_llsd.str(), "details response:", 0); - - LL_INFOS() << "details response:" << content << LL_ENDL; - -#endif - - LLFloaterScriptLimits* instance = LLFloaterReg::getTypedInstance("script_limits"); - - if(!instance) - { - LL_WARNS() << "Failed to get llfloaterscriptlimits instance" << LL_ENDL; - } - else - { - LLTabContainer* tab = instance->getChild("scriptlimits_panels"); - if(tab) - { - LLPanelScriptLimitsRegionMemory* panel_memory = (LLPanelScriptLimitsRegionMemory*)tab->getChild("script_limits_region_memory_panel"); - if(panel_memory) - { - panel_memory->setRegionDetails(content); - } - else - { - LL_WARNS() << "Failed to get scriptlimits memory panel" << LL_ENDL; - } - } - else - { - LL_WARNS() << "Failed to get scriptlimits_panels" << LL_ENDL; - } - } -} - -void fetchScriptLimitsRegionDetailsResponder::httpFailure() -{ - LL_WARNS() << dumpResponse() << LL_ENDL; -} - -void fetchScriptLimitsAttachmentInfoResponder::httpSuccess() -{ - const LLSD& content_ref = getContent(); - -#ifdef USE_FAKE_RESPONSES - - // just add the summary, as that's all I'm testing currently! - LLSD fake_content = LLSD::emptyMap(); - LLSD summary = LLSD::emptyMap(); - LLSD available = LLSD::emptyArray(); - LLSD available_urls = LLSD::emptyMap(); - LLSD available_memory = LLSD::emptyMap(); - LLSD used = LLSD::emptyArray(); - LLSD used_urls = LLSD::emptyMap(); - LLSD used_memory = LLSD::emptyMap(); - - used_urls["type"] = "urls"; - used_urls["amount"] = FAKE_NUMBER_OF_URLS; - available_urls["type"] = "urls"; - available_urls["amount"] = FAKE_AVAILABLE_URLS; - used_memory["type"] = "memory"; - used_memory["amount"] = FAKE_AMOUNT_OF_MEMORY; - available_memory["type"] = "memory"; - available_memory["amount"] = FAKE_AVAILABLE_MEMORY; - - used.append(used_urls); - used.append(used_memory); - available.append(available_urls); - available.append(available_memory); - - summary["available"] = available; - summary["used"] = used; - - fake_content["summary"] = summary; - fake_content["attachments"] = content_ref["attachments"]; - - const LLSD& content = fake_content; - -#else - - const LLSD& content = content_ref; - -#endif - - if (!content.isMap()) - { - failureResult(HTTP_INTERNAL_ERROR, "Malformed response contents", content); - return; - } - -#ifdef DUMP_REPLIES_TO_LLINFOS - - LLSDNotationStreamer notation_streamer(content); - std::ostringstream nice_llsd; - nice_llsd << notation_streamer; - - OSMessageBox(nice_llsd.str(), "attachment response:", 0); - - LL_INFOS() << "attachment response:" << content << LL_ENDL; - -#endif - - LLFloaterScriptLimits* instance = LLFloaterReg::getTypedInstance("script_limits"); - - if(!instance) - { - LL_WARNS() << "Failed to get llfloaterscriptlimits instance" << LL_ENDL; - } - else - { - LLTabContainer* tab = instance->getChild("scriptlimits_panels"); - if(tab) - { - LLPanelScriptLimitsAttachment* panel = (LLPanelScriptLimitsAttachment*)tab->getChild("script_limits_my_avatar_panel"); - if(panel) - { - panel->getChild("loading_text")->setValue(LLSD(std::string(""))); - - LLButton* btn = panel->getChild("refresh_list_btn"); - if(btn) - { - btn->setEnabled(true); - } - - panel->setAttachmentDetails(content); - } - else - { - LL_WARNS() << "Failed to get script_limits_my_avatar_panel" << LL_ENDL; - } - } - else - { - LL_WARNS() << "Failed to get scriptlimits_panels" << LL_ENDL; - } - } -} - -void fetchScriptLimitsAttachmentInfoResponder::httpFailure() -{ - LL_WARNS() << dumpResponse() << LL_ENDL; -} - ///---------------------------------------------------------------------------- // Memory Panel ///---------------------------------------------------------------------------- @@ -564,12 +199,8 @@ BOOL LLPanelScriptLimitsRegionMemory::getLandScriptResources() std::string url = gAgent.getRegion()->getCapability("LandResources"); if (!url.empty()) { - body["parcel_id"] = mParcelId; - - LLSD info; - info["parcel_id"] = mParcelId; - LLHTTPClient::post(url, body, new fetchScriptLimitsRegionInfoResponder(info)); - + LLCoros::instance().launch("LLPanelScriptLimitsRegionMemory::getLandScriptResourcesCoro", + boost::bind(&LLPanelScriptLimitsRegionMemory::getLandScriptResourcesCoro, this, _1, url)); return TRUE; } else @@ -578,6 +209,147 @@ BOOL LLPanelScriptLimitsRegionMemory::getLandScriptResources() } } +void LLPanelScriptLimitsRegionMemory::getLandScriptResourcesCoro(LLCoros::self& self, std::string url) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("getLandScriptResourcesCoro", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + + LLSD postData; + + postData["parcel_id"] = mParcelId; + + LLSD result = httpAdapter->postAndYield(self, httpRequest, url, postData); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + + if (!status) + { + LL_WARNS() << "Failed to get script resource info" << LL_ENDL; + return; + } + + // We could retrieve these sequentially inline from this coroutine. But + // since the original code retrieved them in parallel I'll spawn two + // coroutines to do the retrieval. + + // The summary service: + if (result.has("ScriptResourceSummary")) + { + std::string urlResourceSummary = result["ScriptResourceSummary"].asString(); + LLCoros::instance().launch("LLPanelScriptLimitsRegionMemory::getLandScriptSummaryCoro", + boost::bind(&LLPanelScriptLimitsRegionMemory::getLandScriptSummaryCoro, this, _1, urlResourceSummary)); + } + + if (result.has("ScriptResourceDetails")) + { + std::string urlResourceDetails = result["ScriptResourceDetails"].asString(); + LLCoros::instance().launch("LLPanelScriptLimitsRegionMemory::getLandScriptDetailsCoro", + boost::bind(&LLPanelScriptLimitsRegionMemory::getLandScriptDetailsCoro, this, _1, urlResourceDetails)); + } + + +} + +void LLPanelScriptLimitsRegionMemory::getLandScriptSummaryCoro(LLCoros::self& self, std::string url) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("getLandScriptSummaryCoro", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + + LLSD result = httpAdapter->getAndYield(self, httpRequest, url); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + + if (!status) + { + LL_WARNS() << "Unable to retrieve script summary." << LL_ENDL; + return; + } + + LLFloaterScriptLimits* instance = LLFloaterReg::getTypedInstance("script_limits"); + if (!instance) + { + LL_WARNS() << "Failed to get llfloaterscriptlimits instance" << LL_ENDL; + return; + } + + LLTabContainer* tab = instance->getChild("scriptlimits_panels"); + if (!tab) + { + LL_WARNS() << "Unable to access script limits tab" << LL_ENDL; + return; + } + + LLPanelScriptLimitsRegionMemory* panelMemory = (LLPanelScriptLimitsRegionMemory*)tab->getChild("script_limits_region_memory_panel"); + if (!panelMemory) + { + LL_WARNS() << "Unable to get memory panel." << LL_ENDL; + return; + } + + panelMemory->getChild("loading_text")->setValue(LLSD(std::string(""))); + + LLButton* btn = panelMemory->getChild("refresh_list_btn"); + if (btn) + { + btn->setEnabled(true); + } + + result.erase(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS); + panelMemory->setRegionSummary(result); + +} + +void LLPanelScriptLimitsRegionMemory::getLandScriptDetailsCoro(LLCoros::self& self, std::string url) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("getLandScriptDetailsCoro", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + + LLSD result = httpAdapter->getAndYield(self, httpRequest, url); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + + if (!status) + { + LL_WARNS() << "Unable to retrieve script details." << LL_ENDL; + return; + } + + LLFloaterScriptLimits* instance = LLFloaterReg::getTypedInstance("script_limits"); + + if (!instance) + { + LL_WARNS() << "Failed to get llfloaterscriptlimits instance" << LL_ENDL; + return; + } + + LLTabContainer* tab = instance->getChild("scriptlimits_panels"); + if (!tab) + { + LL_WARNS() << "Unable to access script limits tab" << LL_ENDL; + return; + } + + LLPanelScriptLimitsRegionMemory* panelMemory = (LLPanelScriptLimitsRegionMemory*)tab->getChild("script_limits_region_memory_panel"); + + if (!panelMemory) + { + LL_WARNS() << "Unable to get memory panel." << LL_ENDL; + return; + } + + result.erase(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS); + panelMemory->setRegionDetails(result); +} + void LLPanelScriptLimitsRegionMemory::processParcelInfo(const LLParcelData& parcel_data) { if(!getLandScriptResources()) @@ -1174,7 +946,8 @@ BOOL LLPanelScriptLimitsAttachment::requestAttachmentDetails() std::string url = gAgent.getRegion()->getCapability("AttachmentResources"); if (!url.empty()) { - LLHTTPClient::get(url, body, new fetchScriptLimitsAttachmentInfoResponder()); + LLCoros::instance().launch("LLPanelScriptLimitsAttachment::getAttachmentLimitsCoro", + boost::bind(&LLPanelScriptLimitsAttachment::getAttachmentLimitsCoro, this, _1, url)); return TRUE; } else @@ -1183,6 +956,59 @@ BOOL LLPanelScriptLimitsAttachment::requestAttachmentDetails() } } +void LLPanelScriptLimitsAttachment::getAttachmentLimitsCoro(LLCoros::self& self, std::string url) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("getAttachmentLimitsCoro", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + + LLSD result = httpAdapter->getAndYield(self, httpRequest, url); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + + if (!status) + { + LL_WARNS() << "Unable to retrieve attachment limits." << LL_ENDL; + return; + } + + LLFloaterScriptLimits* instance = LLFloaterReg::getTypedInstance("script_limits"); + + if (!instance) + { + LL_WARNS() << "Failed to get llfloaterscriptlimits instance" << LL_ENDL; + return; + } + + LLTabContainer* tab = instance->getChild("scriptlimits_panels"); + if (!tab) + { + LL_WARNS() << "Failed to get scriptlimits_panels" << LL_ENDL; + return; + } + + LLPanelScriptLimitsAttachment* panel = (LLPanelScriptLimitsAttachment*)tab->getChild("script_limits_my_avatar_panel"); + if (!panel) + { + LL_WARNS() << "Failed to get script_limits_my_avatar_panel" << LL_ENDL; + return; + } + + panel->getChild("loading_text")->setValue(LLSD(std::string(""))); + + LLButton* btn = panel->getChild("refresh_list_btn"); + if (btn) + { + btn->setEnabled(true); + } + + result.erase(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS); + panel->setAttachmentDetails(result); +} + + void LLPanelScriptLimitsAttachment::setAttachmentDetails(LLSD content) { LLScrollListCtrl *list = getChild("scripts_list"); diff --git a/indra/newview/llfloaterscriptlimits.h b/indra/newview/llfloaterscriptlimits.h index 5ba0185d32..030020087b 100755 --- a/indra/newview/llfloaterscriptlimits.h +++ b/indra/newview/llfloaterscriptlimits.h @@ -33,6 +33,8 @@ #include "llhost.h" #include "llpanel.h" #include "llremoteparcelrequest.h" +#include "lleventcoro.h" +#include "llcoros.h" class LLPanelScriptLimitsInfo; class LLTabContainer; @@ -79,57 +81,6 @@ protected: LLHost mHost; }; -///////////////////////////////////////////////////////////////////////////// -// Responders -///////////////////////////////////////////////////////////////////////////// - -class fetchScriptLimitsRegionInfoResponder: public LLHTTPClient::Responder -{ - LOG_CLASS(fetchScriptLimitsRegionInfoResponder); -public: - fetchScriptLimitsRegionInfoResponder(const LLSD& info) : mInfo(info) {}; - -private: - /* virtual */ void httpSuccess(); - /* virtual */ void httpFailure(); - LLSD mInfo; -}; - -class fetchScriptLimitsRegionSummaryResponder: public LLHTTPClient::Responder -{ - LOG_CLASS(fetchScriptLimitsRegionSummaryResponder); -public: - fetchScriptLimitsRegionSummaryResponder(const LLSD& info) : mInfo(info) {}; - -private: - /* virtual */ void httpSuccess(); - /* virtual */ void httpFailure(); - LLSD mInfo; -}; - -class fetchScriptLimitsRegionDetailsResponder: public LLHTTPClient::Responder -{ - LOG_CLASS(fetchScriptLimitsRegionDetailsResponder); -public: - fetchScriptLimitsRegionDetailsResponder(const LLSD& info) : mInfo(info) {}; - -private: - /* virtual */ void httpSuccess(); - /* virtual */ void httpFailure(); - LLSD mInfo; -}; - -class fetchScriptLimitsAttachmentInfoResponder: public LLHTTPClient::Responder -{ - LOG_CLASS(fetchScriptLimitsAttachmentInfoResponder); -public: - fetchScriptLimitsAttachmentInfoResponder() {}; - -private: - /* virtual */ void httpSuccess(); - /* virtual */ void httpFailure(); -}; - ///////////////////////////////////////////////////////////////////////////// // Memory panel ///////////////////////////////////////////////////////////////////////////// @@ -181,6 +132,10 @@ private: std::vector mObjectListItems; + void getLandScriptResourcesCoro(LLCoros::self& self, std::string url); + void getLandScriptSummaryCoro(LLCoros::self& self, std::string url); + void getLandScriptDetailsCoro(LLCoros::self& self, std::string url); + protected: // LLRemoteParcelInfoObserver interface: @@ -225,6 +180,7 @@ public: void clearList(); private: + void getAttachmentLimitsCoro(LLCoros::self& self, std::string url); bool mGotAttachmentMemoryUsed; S32 mAttachmentMemoryMax; -- cgit v1.2.3 From dcd364022435ed7dc7458b83a4d3b42a0b777b11 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 3 Jun 2015 11:57:58 -0700 Subject: TOS retrieval to coroutine --- indra/newview/llfloatertos.cpp | 84 ++++++++++++++---------------------------- indra/newview/llfloatertos.h | 5 +++ 2 files changed, 32 insertions(+), 57 deletions(-) (limited to 'indra') diff --git a/indra/newview/llfloatertos.cpp b/indra/newview/llfloatertos.cpp index c1c21c593e..f8195de155 100755 --- a/indra/newview/llfloatertos.cpp +++ b/indra/newview/llfloatertos.cpp @@ -45,7 +45,7 @@ #include "llvfile.h" #include "message.h" #include "llstartup.h" // login_alert_done - +#include "llcorehttputil.h" LLFloaterTOS::LLFloaterTOS(const LLSD& data) : LLModalDialog( data["message"].asString() ), @@ -57,57 +57,6 @@ LLFloaterTOS::LLFloaterTOS(const LLSD& data) { } -// helper class that trys to download a URL from a web site and calls a method -// on parent class indicating if the web server is working or not -class LLIamHere : public LLHTTPClient::Responder -{ - LOG_CLASS(LLIamHere); -private: - LLIamHere( LLFloaterTOS* parent ) : - mParent( parent ) - {} - - LLFloaterTOS* mParent; - -public: - static LLIamHere* build( LLFloaterTOS* parent ) - { - return new LLIamHere( parent ); - } - - virtual void setParent( LLFloaterTOS* parentIn ) - { - mParent = parentIn; - } - -protected: - virtual void httpSuccess() - { - if ( mParent ) - { - mParent->setSiteIsAlive( true ); - } - } - - virtual void httpFailure() - { - LL_DEBUGS("LLIamHere") << dumpResponse() << LL_ENDL; - if ( mParent ) - { - // *HACK: For purposes of this alive check, 302 Found - // (aka Moved Temporarily) is considered alive. The web site - // redirects this link to a "cache busting" temporary URL. JC - bool alive = (getStatus() == HTTP_FOUND); - mParent->setSiteIsAlive( alive ); - } - } -}; - -// this is global and not a class member to keep crud out of the header file -namespace { - LLPointer< LLIamHere > gResponsePtr = 0; -}; - BOOL LLFloaterTOS::postBuild() { childSetAction("Continue", onContinue, this); @@ -180,9 +129,6 @@ void LLFloaterTOS::setSiteIsAlive( bool alive ) LLFloaterTOS::~LLFloaterTOS() { - // tell the responder we're not here anymore - if ( gResponsePtr ) - gResponsePtr->setParent( 0 ); } // virtual @@ -243,9 +189,10 @@ void LLFloaterTOS::handleMediaEvent(LLPluginClassMedia* /*self*/, EMediaEvent ev if(!mLoadingScreenLoaded) { mLoadingScreenLoaded = true; + std::string url(getString("real_url")); - gResponsePtr = LLIamHere::build( this ); - LLHTTPClient::get( getString( "real_url" ), gResponsePtr ); + LLCoros::instance().launch("LLFloaterTOS::testSiteIsAliveCoro", + boost::bind(&LLFloaterTOS::testSiteIsAliveCoro, this, _1, url)); } else if(mRealNavigateBegun) { @@ -257,3 +204,26 @@ void LLFloaterTOS::handleMediaEvent(LLPluginClassMedia* /*self*/, EMediaEvent ev } } +void LLFloaterTOS::testSiteIsAliveCoro(LLCoros::self& self, std::string url) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("genericPostCoro", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + LLCore::HttpOptions::ptr_t httpOpts = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions); + + httpOpts->setWantHeaders(true); + + LL_INFOS("HttpCoroutineAdapter", "genericPostCoro") << "Generic POST for " << url << LL_ENDL; + + LLSD result = httpAdapter->getAndYield(self, httpRequest, url); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + + // double not. + // First ! returns a boolean error status, second ! is true if success result. + setSiteIsAlive(!!status); +} + + diff --git a/indra/newview/llfloatertos.h b/indra/newview/llfloatertos.h index 47126d06a6..90bea2fe83 100755 --- a/indra/newview/llfloatertos.h +++ b/indra/newview/llfloatertos.h @@ -31,6 +31,8 @@ #include "llassetstorage.h" #include "llmediactrl.h" #include +#include "lleventcoro.h" +#include "llcoros.h" class LLButton; class LLRadioGroup; @@ -60,12 +62,15 @@ public: /*virtual*/ void handleMediaEvent(LLPluginClassMedia* self, EMediaEvent event); private: + void testSiteIsAliveCoro(LLCoros::self& self, std::string url); std::string mMessage; bool mLoadingScreenLoaded; bool mSiteAlive; bool mRealNavigateBegun; std::string mReplyPumpName; + + }; #endif // LL_LLFLOATERTOS_H -- cgit v1.2.3 From 2f0e3de43eafc4aeab75b648ecdc0c275ac368f5 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 3 Jun 2015 13:51:45 -0700 Subject: Land Media URL entry to coroutine. --- indra/newview/llfloaterurlentry.cpp | 88 +++++++++++++++++++++++-------------- indra/newview/llfloaterurlentry.h | 7 ++- 2 files changed, 61 insertions(+), 34 deletions(-) (limited to 'indra') diff --git a/indra/newview/llfloaterurlentry.cpp b/indra/newview/llfloaterurlentry.cpp index e02e8eeb5a..1e58f6c6ec 100755 --- a/indra/newview/llfloaterurlentry.cpp +++ b/indra/newview/llfloaterurlentry.cpp @@ -40,40 +40,10 @@ #include "lluictrlfactory.h" #include "llwindow.h" #include "llviewerwindow.h" +#include "llcorehttputil.h" static LLFloaterURLEntry* sInstance = NULL; -// Move this to its own file. -// helper class that tries to download a URL from a web site and calls a method -// on the Panel Land Media and to discover the MIME type -class LLMediaTypeResponder : public LLHTTPClient::Responder -{ - LOG_CLASS(LLMediaTypeResponder); -public: - LLMediaTypeResponder( const LLHandle parent ) : - mParent( parent ) - {} - - LLHandle mParent; - -private: - /* virtual */ void httpCompleted() - { - const std::string& media_type = getResponseHeader(HTTP_IN_HEADER_CONTENT_TYPE); - std::string::size_type idx1 = media_type.find_first_of(";"); - std::string mime_type = media_type.substr(0, idx1); - - // Set empty type to none/none. Empty string is reserved for legacy parcels - // which have no mime type set. - std::string resolved_mime_type = ! mime_type.empty() ? mime_type : LLMIMETypes::getDefaultMimeType(); - LLFloaterURLEntry* floater_url_entry = (LLFloaterURLEntry*)mParent.get(); - if ( floater_url_entry ) - { - floater_url_entry->headerFetchComplete( getStatus(), resolved_mime_type ); - } - } -}; - //----------------------------------------------------------------------------- // LLFloaterURLEntry() //----------------------------------------------------------------------------- @@ -225,8 +195,8 @@ void LLFloaterURLEntry::onBtnOK( void* userdata ) if(!media_url.empty() && (scheme == "http" || scheme == "https")) { - LLHTTPClient::getHeaderOnly( media_url, - new LLMediaTypeResponder(self->getHandle())); + LLCoros::instance().launch("LLFloaterURLEntry::getMediaTypeCoro", + boost::bind(&LLFloaterURLEntry::getMediaTypeCoro, _1, media_url, self->getHandle())); } else { @@ -239,6 +209,58 @@ void LLFloaterURLEntry::onBtnOK( void* userdata ) self->getChildView("media_entry")->setEnabled(false); } +// static +void LLFloaterURLEntry::getMediaTypeCoro(LLCoros::self& self, std::string url, LLHandle parentHandle) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("getMediaTypeCoro", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + LLCore::HttpOptions::ptr_t httpOpts = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions); + + httpOpts->setHeadersOnly(true); + + LL_INFOS("HttpCoroutineAdapter", "genericPostCoro") << "Generic POST for " << url << LL_ENDL; + + LLSD result = httpAdapter->getAndYield(self, httpRequest, url, httpOpts); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + + LLFloaterURLEntry* floaterUrlEntry = (LLFloaterURLEntry*)parentHandle.get(); + if (!floaterUrlEntry) + { + LL_WARNS() << "Could not get URL entry floater." << LL_ENDL; + return; + } + + // Set empty type to none/none. Empty string is reserved for legacy parcels + // which have no mime type set. + std::string resolvedMimeType = LLMIMETypes::getDefaultMimeType(); + + if (!status) + { + floaterUrlEntry->headerFetchComplete(status.getType(), resolvedMimeType); + return; + } + + LLSD resultHeaders = httpResults[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS_HEADERS]; + + if (resultHeaders.has(HTTP_IN_HEADER_CONTENT_TYPE)) + { + const std::string& mediaType = resultHeaders[HTTP_IN_HEADER_CONTENT_TYPE]; + std::string::size_type idx1 = mediaType.find_first_of(";"); + std::string mimeType = mediaType.substr(0, idx1); + if (!mimeType.empty()) + { + resolvedMimeType = mimeType; + } + } + + floaterUrlEntry->headerFetchComplete(status.getType(), resolvedMimeType); + +} + // static //----------------------------------------------------------------------------- // onBtnCancel() diff --git a/indra/newview/llfloaterurlentry.h b/indra/newview/llfloaterurlentry.h index bdd1ebe592..2f5afa653d 100755 --- a/indra/newview/llfloaterurlentry.h +++ b/indra/newview/llfloaterurlentry.h @@ -29,6 +29,8 @@ #include "llfloater.h" #include "llpanellandmedia.h" +#include "lleventcoro.h" +#include "llcoros.h" class LLLineEditor; class LLComboBox; @@ -56,7 +58,10 @@ private: static void onBtnOK(void*); static void onBtnCancel(void*); static void onBtnClear(void*); - bool callback_clear_url_list(const LLSD& notification, const LLSD& response); + bool callback_clear_url_list(const LLSD& notification, const LLSD& response); + + static void getMediaTypeCoro(LLCoros::self& self, std::string url, LLHandle parentHandle); + }; #endif // LL_LLFLOATERURLENTRY_H -- cgit v1.2.3 From 0d3fb07bfa205b65f242ef2b761e827ff30e42fe Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 3 Jun 2015 16:04:40 -0700 Subject: Remove vestigial httpclient.h include from files that no longer need it. --- indra/llmessage/llavatarnamecache.cpp | 1 - indra/llmessage/llcorehttputil.h | 1 + indra/newview/llagentlanguage.cpp | 1 - indra/newview/llavatarrenderinfoaccountant.cpp | 1 - indra/newview/llestateinfomodel.cpp | 1 - indra/newview/lleventpoll.cpp | 2 -- indra/newview/llfacebookconnect.cpp | 1 - indra/newview/llfeaturemanager.cpp | 1 - indra/newview/llflickrconnect.cpp | 1 - indra/newview/llfloaterabout.cpp | 2 +- indra/newview/llfloaterautoreplacesettings.cpp | 1 - indra/newview/llfloateravatarpicker.cpp | 1 - indra/newview/llfloaterhoverheight.cpp | 1 - indra/newview/llfloaterregiondebugconsole.h | 1 - indra/newview/llfloatertos.cpp | 2 -- indra/newview/llfloaterurlentry.cpp | 2 -- indra/newview/llmediadataclient.h | 1 - indra/newview/llpanelclassified.cpp | 1 - indra/newview/llpanellogin.cpp | 1 - indra/newview/llpathfindingmanager.cpp | 1 - indra/newview/llproductinforequest.h | 1 - indra/newview/llremoteparcelrequest.cpp | 1 - indra/newview/llremoteparcelrequest.h | 1 - indra/newview/llspeakers.cpp | 1 - indra/newview/llsyntaxid.cpp | 1 - indra/newview/lltexturefetch.cpp | 1 - indra/newview/lltwitterconnect.cpp | 1 - indra/newview/llviewerregion.h | 1 - indra/newview/llvoicechannel.cpp | 1 - indra/newview/llwebprofile.cpp | 1 - indra/newview/llwlhandlers.h | 1 - indra/viewer_components/updater/llupdatechecker.cpp | 1 - indra/viewer_components/updater/llupdatechecker.h | 1 - 33 files changed, 2 insertions(+), 35 deletions(-) (limited to 'indra') diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index 88b88d0454..5d9daca37a 100755 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -30,7 +30,6 @@ #include "llcachename.h" // we wrap this system #include "llframetimer.h" -#include "llhttpclient.h" #include "llsd.h" #include "llsdserialize.h" #include "httpresponse.h" diff --git a/indra/llmessage/llcorehttputil.h b/indra/llmessage/llcorehttputil.h index 213610e58e..53c8112395 100644 --- a/indra/llmessage/llcorehttputil.h +++ b/indra/llmessage/llcorehttputil.h @@ -36,6 +36,7 @@ #include "httpheaders.h" #include "httpoptions.h" #include "httphandler.h" +#include "llhttpconstants.h" // *TODO: move to llcorehttp #include "bufferarray.h" #include "bufferstream.h" #include "llsd.h" diff --git a/indra/newview/llagentlanguage.cpp b/indra/newview/llagentlanguage.cpp index f2ac323578..66aec42417 100755 --- a/indra/newview/llagentlanguage.cpp +++ b/indra/newview/llagentlanguage.cpp @@ -70,7 +70,6 @@ bool LLAgentLanguage::update() body["language"] = language; body["language_is_public"] = gSavedSettings.getBOOL("LanguageIsPublic"); - //LLHTTPClient::post(url, body, new LLHTTPClient::Responder); LLCore::HttpHandle handle = gAgent.requestPostCapability("UpdateAgentLanguage", url, body); if (handle == LLCORE_HTTP_HANDLE_INVALID) { diff --git a/indra/newview/llavatarrenderinfoaccountant.cpp b/indra/newview/llavatarrenderinfoaccountant.cpp index 45be4dfbc9..73b2ecfd36 100644 --- a/indra/newview/llavatarrenderinfoaccountant.cpp +++ b/indra/newview/llavatarrenderinfoaccountant.cpp @@ -35,7 +35,6 @@ // external library headers // other Linden headers #include "llcharacter.h" -#include "llhttpclient.h" #include "lltimer.h" #include "llviewercontrol.h" #include "llviewermenu.h" diff --git a/indra/newview/llestateinfomodel.cpp b/indra/newview/llestateinfomodel.cpp index 6597d3ad46..04d0dda7ac 100755 --- a/indra/newview/llestateinfomodel.cpp +++ b/indra/newview/llestateinfomodel.cpp @@ -29,7 +29,6 @@ #include "llestateinfomodel.h" // libs -#include "llhttpclient.h" #include "llregionflags.h" #include "message.h" diff --git a/indra/newview/lleventpoll.cpp b/indra/newview/lleventpoll.cpp index 9ba3e7ef5b..03a380f2f6 100755 --- a/indra/newview/lleventpoll.cpp +++ b/indra/newview/lleventpoll.cpp @@ -30,8 +30,6 @@ #include "llappviewer.h" #include "llagent.h" -#include "llhttpclient.h" -#include "llhttpconstants.h" #include "llsdserialize.h" #include "lleventtimer.h" #include "llviewerregion.h" diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index 2a1614a422..d1ed4e8ba4 100755 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -34,7 +34,6 @@ #include "llagent.h" #include "llcallingcard.h" // for LLAvatarTracker #include "llcommandhandler.h" -#include "llhttpclient.h" #include "llnotificationsutil.h" #include "llurlaction.h" #include "llimagepng.h" diff --git a/indra/newview/llfeaturemanager.cpp b/indra/newview/llfeaturemanager.cpp index c61e11b912..9a714ac962 100755 --- a/indra/newview/llfeaturemanager.cpp +++ b/indra/newview/llfeaturemanager.cpp @@ -40,7 +40,6 @@ #include "llappviewer.h" #include "llbufferstream.h" -#include "llhttpclient.h" #include "llnotificationsutil.h" #include "llviewercontrol.h" #include "llworld.h" diff --git a/indra/newview/llflickrconnect.cpp b/indra/newview/llflickrconnect.cpp index 933e4691a2..b3c89b9798 100644 --- a/indra/newview/llflickrconnect.cpp +++ b/indra/newview/llflickrconnect.cpp @@ -32,7 +32,6 @@ #include "llagent.h" #include "llcallingcard.h" // for LLAvatarTracker #include "llcommandhandler.h" -#include "llhttpclient.h" #include "llnotificationsutil.h" #include "llurlaction.h" #include "llimagepng.h" diff --git a/indra/newview/llfloaterabout.cpp b/indra/newview/llfloaterabout.cpp index 952bc204b8..f58a5881a8 100755 --- a/indra/newview/llfloaterabout.cpp +++ b/indra/newview/llfloaterabout.cpp @@ -205,7 +205,7 @@ void LLFloaterAbout::startFetchServerReleaseNotes() // So we query the URL ourselves, expecting to find // an URL suitable for external browsers in the "Location:" HTTP header. std::string cap_url = region->getCapability("ServerReleaseNotes"); - //LLHTTPClient::get(cap_url, new LLServerReleaseNotesURLFetcher); + LLCoreHttpUtil::HttpCoroutineAdapter::callbackHttpGet(cap_url, &LLFloaterAbout::handleServerReleaseNotes, &LLFloaterAbout::handleServerReleaseNotes); diff --git a/indra/newview/llfloaterautoreplacesettings.cpp b/indra/newview/llfloaterautoreplacesettings.cpp index 6e56e929df..5830f2f711 100755 --- a/indra/newview/llfloaterautoreplacesettings.cpp +++ b/indra/newview/llfloaterautoreplacesettings.cpp @@ -36,7 +36,6 @@ #include "llcolorswatch.h" #include "llcombobox.h" #include "llview.h" -#include "llhttpclient.h" #include "llbufferstream.h" #include "llcheckboxctrl.h" #include "llviewercontrol.h" diff --git a/indra/newview/llfloateravatarpicker.cpp b/indra/newview/llfloateravatarpicker.cpp index 84e3584331..e5e9a794a4 100755 --- a/indra/newview/llfloateravatarpicker.cpp +++ b/indra/newview/llfloateravatarpicker.cpp @@ -42,7 +42,6 @@ #include "llavatarnamecache.h" // IDEVO #include "llbutton.h" #include "llcachename.h" -#include "llhttpclient.h" // IDEVO #include "lllineeditor.h" #include "llscrolllistctrl.h" #include "llscrolllistitem.h" diff --git a/indra/newview/llfloaterhoverheight.cpp b/indra/newview/llfloaterhoverheight.cpp index 8908626de6..003a22fa04 100755 --- a/indra/newview/llfloaterhoverheight.cpp +++ b/indra/newview/llfloaterhoverheight.cpp @@ -31,7 +31,6 @@ #include "llsliderctrl.h" #include "llviewercontrol.h" #include "llsdserialize.h" -#include "llhttpclient.h" #include "llagent.h" #include "llviewerregion.h" #include "llvoavatarself.h" diff --git a/indra/newview/llfloaterregiondebugconsole.h b/indra/newview/llfloaterregiondebugconsole.h index ee4bd79b17..f55d964924 100755 --- a/indra/newview/llfloaterregiondebugconsole.h +++ b/indra/newview/llfloaterregiondebugconsole.h @@ -31,7 +31,6 @@ #include #include "llfloater.h" -#include "llhttpclient.h" class LLTextEditor; diff --git a/indra/newview/llfloatertos.cpp b/indra/newview/llfloatertos.cpp index f8195de155..27938bfbc4 100755 --- a/indra/newview/llfloatertos.cpp +++ b/indra/newview/llfloatertos.cpp @@ -35,8 +35,6 @@ // linden library includes #include "llbutton.h" #include "llevents.h" -#include "llhttpclient.h" -#include "llhttpconstants.h" #include "llnotificationsutil.h" #include "llradiogroup.h" #include "lltextbox.h" diff --git a/indra/newview/llfloaterurlentry.cpp b/indra/newview/llfloaterurlentry.cpp index 1e58f6c6ec..110d760dc9 100755 --- a/indra/newview/llfloaterurlentry.cpp +++ b/indra/newview/llfloaterurlentry.cpp @@ -26,8 +26,6 @@ #include "llviewerprecompiledheaders.h" -#include "llhttpclient.h" - #include "llfloaterurlentry.h" #include "llpanellandmedia.h" diff --git a/indra/newview/llmediadataclient.h b/indra/newview/llmediadataclient.h index 0b81a6ab22..9907897613 100755 --- a/indra/newview/llmediadataclient.h +++ b/indra/newview/llmediadataclient.h @@ -27,7 +27,6 @@ #ifndef LL_LLMEDIADATACLIENT_H #define LL_LLMEDIADATACLIENT_H -#include "llhttpclient.h" #include #include "llrefcount.h" #include "llpointer.h" diff --git a/indra/newview/llpanelclassified.cpp b/indra/newview/llpanelclassified.cpp index 2689420c00..5d1ae4ff10 100755 --- a/indra/newview/llpanelclassified.cpp +++ b/indra/newview/llpanelclassified.cpp @@ -34,7 +34,6 @@ #include "lldispatcher.h" #include "llfloaterreg.h" -#include "llhttpclient.h" #include "llnotifications.h" #include "llnotificationsutil.h" #include "llparcel.h" diff --git a/indra/newview/llpanellogin.cpp b/indra/newview/llpanellogin.cpp index cc8c3edd51..99c9fad82d 100755 --- a/indra/newview/llpanellogin.cpp +++ b/indra/newview/llpanellogin.cpp @@ -59,7 +59,6 @@ #include "llviewernetwork.h" #include "llviewerwindow.h" // to link into child list #include "lluictrlfactory.h" -#include "llhttpclient.h" #include "llweb.h" #include "llmediactrl.h" #include "llrootview.h" diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index e5c7627334..5dc90c987d 100755 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -39,7 +39,6 @@ #include #include "llagent.h" -#include "llhttpclient.h" #include "llhttpnode.h" #include "llnotificationsutil.h" #include "llpathfindingcharacterlist.h" diff --git a/indra/newview/llproductinforequest.h b/indra/newview/llproductinforequest.h index 44aaa9d6e4..3ddae95a93 100755 --- a/indra/newview/llproductinforequest.h +++ b/indra/newview/llproductinforequest.h @@ -28,7 +28,6 @@ #ifndef LL_LLPRODUCTINFOREQUEST_H #define LL_LLPRODUCTINFOREQUEST_H -#include "llhttpclient.h" #include "llmemory.h" #include "lleventcoro.h" #include "llcoros.h" diff --git a/indra/newview/llremoteparcelrequest.cpp b/indra/newview/llremoteparcelrequest.cpp index 9d750c1ee4..7e8e9ac18e 100755 --- a/indra/newview/llremoteparcelrequest.cpp +++ b/indra/newview/llremoteparcelrequest.cpp @@ -31,7 +31,6 @@ #include "message.h" #include "llpanel.h" -#include "llhttpclient.h" #include "llsdserialize.h" #include "llurlentry.h" #include "llviewerregion.h" diff --git a/indra/newview/llremoteparcelrequest.h b/indra/newview/llremoteparcelrequest.h index 75819174c4..982a1590e5 100755 --- a/indra/newview/llremoteparcelrequest.h +++ b/indra/newview/llremoteparcelrequest.h @@ -29,7 +29,6 @@ #ifndef LL_LLREMOTEPARCELREQUEST_H #define LL_LLREMOTEPARCELREQUEST_H -#include "llhttpclient.h" #include "llhandle.h" #include "llsingleton.h" #include "llcoros.h" diff --git a/indra/newview/llspeakers.cpp b/indra/newview/llspeakers.cpp index 125b7e5355..9a9739c9cb 100755 --- a/indra/newview/llspeakers.cpp +++ b/indra/newview/llspeakers.cpp @@ -34,7 +34,6 @@ #include "llgroupmgr.h" #include "llsdutil.h" #include "lluicolortable.h" -#include "llhttpclient.h" #include "llviewerobjectlist.h" #include "llviewerregion.h" #include "llvoavatar.h" diff --git a/indra/newview/llsyntaxid.cpp b/indra/newview/llsyntaxid.cpp index fbb800f881..d2197dcb4f 100644 --- a/indra/newview/llsyntaxid.cpp +++ b/indra/newview/llsyntaxid.cpp @@ -31,7 +31,6 @@ #include "llsyntaxid.h" #include "llagent.h" #include "llappviewer.h" -#include "llhttpclient.h" #include "llsdserialize.h" #include "llviewerregion.h" #include "llcorehttputil.h" diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp index fab4203ec3..f4b1ff7313 100755 --- a/indra/newview/lltexturefetch.cpp +++ b/indra/newview/lltexturefetch.cpp @@ -35,7 +35,6 @@ #include "lltexturefetch.h" #include "lldir.h" -#include "llhttpclient.h" #include "llhttpconstants.h" #include "llimage.h" #include "llimagej2c.h" diff --git a/indra/newview/lltwitterconnect.cpp b/indra/newview/lltwitterconnect.cpp index 66500b5455..24555b007a 100644 --- a/indra/newview/lltwitterconnect.cpp +++ b/indra/newview/lltwitterconnect.cpp @@ -32,7 +32,6 @@ #include "llagent.h" #include "llcallingcard.h" // for LLAvatarTracker #include "llcommandhandler.h" -#include "llhttpclient.h" #include "llnotificationsutil.h" #include "llurlaction.h" #include "llimagepng.h" diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h index d15f2eab20..c6df155cb5 100755 --- a/indra/newview/llviewerregion.h +++ b/indra/newview/llviewerregion.h @@ -40,7 +40,6 @@ #include "llweb.h" #include "llcapabilityprovider.h" #include "m4math.h" // LLMatrix4 -#include "llhttpclient.h" #include "llframetimer.h" // Surface id's diff --git a/indra/newview/llvoicechannel.cpp b/indra/newview/llvoicechannel.cpp index fd1892e94b..338201aab1 100755 --- a/indra/newview/llvoicechannel.cpp +++ b/indra/newview/llvoicechannel.cpp @@ -28,7 +28,6 @@ #include "llagent.h" #include "llfloaterreg.h" -#include "llhttpclient.h" #include "llimview.h" #include "llnotifications.h" #include "llnotificationsutil.h" diff --git a/indra/newview/llwebprofile.cpp b/indra/newview/llwebprofile.cpp index a72deafe33..a9a4573eea 100755 --- a/indra/newview/llwebprofile.cpp +++ b/indra/newview/llwebprofile.cpp @@ -30,7 +30,6 @@ // libs #include "llbufferstream.h" -#include "llhttpclient.h" #include "llimagepng.h" #include "llplugincookiestore.h" diff --git a/indra/newview/llwlhandlers.h b/indra/newview/llwlhandlers.h index e8908410d9..0b778901ad 100755 --- a/indra/newview/llwlhandlers.h +++ b/indra/newview/llwlhandlers.h @@ -28,7 +28,6 @@ #define LL_LLWLHANDLERS_H #include "llviewerprecompiledheaders.h" -#include "llhttpclient.h" #include "llcoros.h" class LLEnvironmentRequest diff --git a/indra/viewer_components/updater/llupdatechecker.cpp b/indra/viewer_components/updater/llupdatechecker.cpp index e5d7d345cb..29cb238892 100755 --- a/indra/viewer_components/updater/llupdatechecker.cpp +++ b/indra/viewer_components/updater/llupdatechecker.cpp @@ -26,7 +26,6 @@ #include "linden_common.h" #include #include -#include "llhttpclient.h" #include "llsd.h" #include "llupdatechecker.h" #include "lluri.h" diff --git a/indra/viewer_components/updater/llupdatechecker.h b/indra/viewer_components/updater/llupdatechecker.h index 09ed306ca7..e5050bb952 100755 --- a/indra/viewer_components/updater/llupdatechecker.h +++ b/indra/viewer_components/updater/llupdatechecker.h @@ -30,7 +30,6 @@ #include #include "llmd5.h" -#include "llhttpclient.h" #include "lleventcoro.h" #include "llcoros.h" -- cgit v1.2.3 From fac351f8f22028bb83a4ebce926979d90ce9301c Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 3 Jun 2015 16:13:19 -0700 Subject: Was a little too agressive in header removal in two places. --- indra/newview/llpanelplaceinfo.cpp | 1 + indra/newview/llvoicevivox.h | 1 + 2 files changed, 2 insertions(+) (limited to 'indra') diff --git a/indra/newview/llpanelplaceinfo.cpp b/indra/newview/llpanelplaceinfo.cpp index 9725e7f5fe..cec56a7ae7 100755 --- a/indra/newview/llpanelplaceinfo.cpp +++ b/indra/newview/llpanelplaceinfo.cpp @@ -45,6 +45,7 @@ #include "llpanelpick.h" #include "lltexturectrl.h" #include "llviewerregion.h" +#include "llhttpconstants.h" LLPanelPlaceInfo::LLPanelPlaceInfo() : LLPanel(), diff --git a/indra/newview/llvoicevivox.h b/indra/newview/llvoicevivox.h index f00108050b..a3cdb342e2 100755 --- a/indra/newview/llvoicevivox.h +++ b/indra/newview/llvoicevivox.h @@ -39,6 +39,7 @@ class LLVivoxProtocolParser; #include "llcallingcard.h" // for LLFriendObserver #include "lleventcoro.h" #include "llcoros.h" +#include #ifdef LL_USESYSTEMLIBS # include "expat.h" -- cgit v1.2.3 From 154429371253f08d7c13247055e76b5c229f903a Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 4 Jun 2015 08:57:47 -0700 Subject: Fix broken web profile posting. --- indra/newview/llwebprofile.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'indra') diff --git a/indra/newview/llwebprofile.cpp b/indra/newview/llwebprofile.cpp index a9a4573eea..727c9ffb18 100755 --- a/indra/newview/llwebprofile.cpp +++ b/indra/newview/llwebprofile.cpp @@ -112,6 +112,7 @@ void LLWebProfile::uploadImageCoro(LLCoros::self& self, LLPointersetWantHeaders(true); + httpOpts->setFollowRedirects(false); // Get upload configuration data. std::string configUrl(getProfileURL(std::string()) + "snapshots/s3_upload_config"); -- cgit v1.2.3 From d034c4f2445eb3095bd17aef421c367bb913af39 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 4 Jun 2015 09:58:27 -0700 Subject: IM session decline using coroutines. --- indra/newview/llimview.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'indra') diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp index 814015c0ed..0e5c16752e 100755 --- a/indra/newview/llimview.cpp +++ b/indra/newview/llimview.cpp @@ -37,7 +37,6 @@ #include "llrect.h" #include "llerror.h" #include "llbutton.h" -#include "llhttpclient.h" #include "llsdutil_math.h" #include "llstring.h" #include "lltextutil.h" @@ -2505,10 +2504,10 @@ void LLIncomingCallDialog::processCallResponse(S32 response, const LLSD &payload LLSD data; data["method"] = "decline invitation"; data["session-id"] = session_id; - LLHTTPClient::post( - url, - data, - NULL); + + LLCoreHttpUtil::HttpCoroutineAdapter::messageHttpPost(url, data, + "Invitation declined", + "Invitation decline failed."); } } @@ -2587,10 +2586,9 @@ bool inviteUserResponse(const LLSD& notification, const LLSD& response) LLSD data; data["method"] = "decline invitation"; data["session-id"] = session_id; - LLHTTPClient::post( - url, - data, - NULL); + LLCoreHttpUtil::HttpCoroutineAdapter::messageHttpPost(url, data, + "Invitation declined.", + "Invitation decline failed."); } } -- cgit v1.2.3 From d0d58c41b48f8a2a0e18610b577059ee8419be5c Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 4 Jun 2015 17:36:24 -0700 Subject: Default headers added. Group manager finished conversion. Outfit folders coverted. --- indra/llmessage/llcorehttputil.cpp | 38 +++++-- indra/llmessage/llcorehttputil.h | 9 ++ indra/newview/llgroupmgr.cpp | 223 ++++++++++++++----------------------- indra/newview/llgroupmgr.h | 9 +- indra/newview/llinventorymodel.cpp | 115 +++++++++---------- indra/newview/llinventorymodel.h | 22 ++-- 6 files changed, 193 insertions(+), 223 deletions(-) (limited to 'indra') diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index c4a7e9040a..1fd7e7be2e 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -37,6 +37,8 @@ #include "llsdserialize.h" #include "reader.h" +#include "message.h" // for getting the port + using namespace LLCore; @@ -243,11 +245,10 @@ void HttpCoroHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRespons result = LLSD::emptyMap(); LL_WARNS() << "\n--------------------------------------------------------------------------\n" - << " Error[" << status.toULong() << "] cannot access url '" << response->getRequestURL() + << " Error[" << status.getType() << "] cannot access url '" << response->getRequestURL() << "' because " << status.toString() << "\n--------------------------------------------------------------------------" << LL_ENDL; - } else { @@ -578,8 +579,10 @@ LLSD HttpCoroutineAdapter::postAndYield_(LLCoros::self & self, LLCore::HttpReque LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler) { - //LL_INFOS() << "Requesting transaction " << transactionId << LL_ENDL; HttpRequestPumper pumper(request); + + checkDefaultHeaders(headers); + // The HTTPCoroHandler does not self delete, so retrieval of a the contained // pointer from the smart pointer is safe in this case. LLCore::HttpHandle hhandle = requestPostWithLLSD(request, @@ -623,8 +626,10 @@ LLSD HttpCoroutineAdapter::postAndYield_(LLCoros::self & self, LLCore::HttpReque LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler) { - //LL_INFOS() << "Requesting transaction " << transactionId << LL_ENDL; HttpRequestPumper pumper(request); + + checkDefaultHeaders(headers); + // The HTTPCoroHandler does not self delete, so retrieval of a the contained // pointer from the smart pointer is safe in this case. LLCore::HttpHandle hhandle = request->requestPost(mPolicyId, mPriority, url, rawbody.get(), @@ -658,8 +663,10 @@ LLSD HttpCoroutineAdapter::putAndYield_(LLCoros::self & self, LLCore::HttpReques LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler) { - //LL_INFOS() << "Requesting transaction " << transactionId << LL_ENDL; HttpRequestPumper pumper(request); + + checkDefaultHeaders(headers); + // The HTTPCoroHandler does not self delete, so retrieval of a the contained // pointer from the smart pointer is safe in this case. LLCore::HttpHandle hhandle = requestPutWithLLSD(request, @@ -713,8 +720,9 @@ LLSD HttpCoroutineAdapter::getAndYield_(LLCoros::self & self, LLCore::HttpReques LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler) { - //LL_INFOS() << "Requesting transaction " << transactionId << LL_ENDL; HttpRequestPumper pumper(request); + checkDefaultHeaders(headers); + // The HTTPCoroHandler does not self delete, so retrieval of a the contained // pointer from the smart pointer is safe in this case. LLCore::HttpHandle hhandle = request->requestGet(mPolicyId, mPriority, @@ -747,8 +755,9 @@ LLSD HttpCoroutineAdapter::deleteAndYield_(LLCoros::self & self, LLCore::HttpReq const std::string & url, LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler) { - //LL_INFOS() << "Requesting transaction " << transactionId << LL_ENDL; HttpRequestPumper pumper(request); + + checkDefaultHeaders(headers); // The HTTPCoroHandler does not self delete, so retrieval of a the contained // pointer from the smart pointer is safe in this case. LLCore::HttpHandle hhandle = request->requestDelete(mPolicyId, mPriority, @@ -766,6 +775,21 @@ LLSD HttpCoroutineAdapter::deleteAndYield_(LLCoros::self & self, LLCore::HttpReq return results; } +void HttpCoroutineAdapter::checkDefaultHeaders(LLCore::HttpHeaders::ptr_t &headers) +{ + if (!headers) + headers.reset(new LLCore::HttpHeaders); + if (!headers->find(HTTP_OUT_HEADER_ACCEPT)) + { + headers->append(HTTP_OUT_HEADER_ACCEPT, HTTP_CONTENT_LLSD_XML); + } + + if (!headers->find("X-SecondLife-UDP-Listen-Port") && gMessageSystem) + { + headers->append("X-SecondLife-UDP-Listen-Port", llformat("%d", gMessageSystem->mPort)); + } +} + void HttpCoroutineAdapter::cancelYieldingOperation() { diff --git a/indra/llmessage/llcorehttputil.h b/indra/llmessage/llcorehttputil.h index 53c8112395..e6c9d2463c 100644 --- a/indra/llmessage/llcorehttputil.h +++ b/indra/llmessage/llcorehttputil.h @@ -286,6 +286,13 @@ private: /// will be automatically pumped and the method will return with an LLSD describing /// the result of the operation. See HttpCoroHandler for a description of the /// decoration done to the returned LLSD. +/// +/// Posting through the adapter will automatically add the following headers to +/// the request if they have not been previously specified in a supplied +/// HttpHeaders object: +/// "Accept=application/llsd+xml" +/// "X-SecondLife-UDP-Listen-Port=###" +/// class HttpCoroutineAdapter { public: @@ -467,6 +474,8 @@ private: static void trivialGetCoro(LLCoros::self& self, std::string url, completionCallback_t success, completionCallback_t failure); static void trivialPostCoro(LLCoros::self& self, std::string url, LLSD postData, completionCallback_t success, completionCallback_t failure); + void checkDefaultHeaders(LLCore::HttpHeaders::ptr_t &headers); + std::string mAdapterName; LLCore::HttpRequest::priority_t mPriority; LLCore::HttpRequest::policy_t mPolicyId; diff --git a/indra/newview/llgroupmgr.cpp b/indra/newview/llgroupmgr.cpp index 21220507e7..0852104ba7 100755 --- a/indra/newview/llgroupmgr.cpp +++ b/indra/newview/llgroupmgr.cpp @@ -1862,120 +1862,94 @@ void LLGroupMgr::sendGroupMemberEjects(const LLUUID& group_id, group_datap->mMemberVersion.generate(); } -#if 1 -// Responder class for capability group management -class GroupBanDataResponder : public LLHTTPClient::Responder +void LLGroupMgr::getGroupBanRequestCoro(LLCoros::self& self, std::string url, LLUUID groupId) { -public: - GroupBanDataResponder(const LLUUID& gropup_id, BOOL force_refresh=false); - virtual ~GroupBanDataResponder() {} - virtual void httpSuccess(); - virtual void httpFailure(); -private: - LLUUID mGroupID; - BOOL mForceRefresh; -}; + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("groupMembersRequest", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); -GroupBanDataResponder::GroupBanDataResponder(const LLUUID& gropup_id, BOOL force_refresh) : - mGroupID(gropup_id), - mForceRefresh(force_refresh) -{} + std::string finalUrl = url + "?group_id=" + groupId.asString(); -void GroupBanDataResponder::httpFailure() -{ - LL_WARNS("GrpMgr") << "Error receiving group member data [status:" - << mStatus << "]: " << mContent << LL_ENDL; -} + LLSD result = httpAdapter->getAndYield(self, httpRequest, finalUrl); -void GroupBanDataResponder::httpSuccess() -{ - if (mContent.has("ban_list")) - { - // group ban data received - LLGroupMgr::processGroupBanRequest(mContent); - } - else if (mForceRefresh) - { - // no ban data received, refreshing data after successful operation - LLGroupMgr::getInstance()->sendGroupBanRequest(LLGroupMgr::REQUEST_GET, mGroupID); - } + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + + if (!status) + { + LL_WARNS("GrpMgr") << "Error receiving group member data " << LL_ENDL; + return; + } + + if (result.has("ban_list")) + { + result.erase(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS); + // group ban data received + processGroupBanRequest(result); + } } -#else -//void LLGroupMgr::groupBanRequestCoro(LLCoros::self& self, std::string url, LLUUID groupId, -// LLGroupMgr::EBanRequestAction action, uuid_vec_t banList) -void LLGroupMgr::groupBanRequestCoro(LLCoros::self& self, std::string url, LLUUID groupId, - LLGroupMgr::EBanRequestAction action, LLSD body) +void LLGroupMgr::postGroupBanRequestCoro(LLCoros::self& self, std::string url, LLUUID groupId, + U32 action, uuid_vec_t banList, bool update) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("groupMembersRequest", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + LLCore::HttpHeaders::ptr_t httpHeaders(new LLCore::HttpHeaders, false); + LLCore::HttpOptions::ptr_t httpOptions(new LLCore::HttpOptions, false); + + httpOptions->setFollowRedirects(false); + + httpHeaders->append(HTTP_OUT_HEADER_CONTENT_TYPE, HTTP_CONTENT_LLSD_XML); + std::string finalUrl = url + "?group_id=" + groupId.asString(); - EBanRequestAction currAction = action; + LLSD postData = LLSD::emptyMap(); + postData["ban_action"] = (LLSD::Integer)action; + // Add our list of potential banned residents to the list + postData["ban_ids"] = LLSD::emptyArray(); + LLSD banEntry; - do + uuid_vec_t::const_iterator it = banList.begin(); + for (; it != banList.end(); ++it) { - LLSD result; - - if (currAction & (BAN_CREATE | BAN_DELETE)) // these two actions result in POSTS - { // build the post data. -// LLSD postData = LLSD::emptyMap(); -// -// postData["ban_action"] = (LLSD::Integer)(currAction & ~BAN_UPDATE); -// // Add our list of potential banned residents to the list -// postData["ban_ids"] = LLSD::emptyArray(); -// -// LLSD banEntry; -// for (uuid_vec_t::const_iterator it = banList.begin(); it != banList.end(); ++it) -// { -// banEntry = (*it); -// postData["ban_ids"].append(banEntry); -// } -// -// result = httpAdapter->postAndYield(self, httpRequest, finalUrl, postData); - - result = httpAdapter->postAndYield(self, httpRequest, finalUrl, body); - } - else - { - result = httpAdapter->getAndYield(self, httpRequest, finalUrl); - } - - LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; - LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); - - if (!status) - { - LL_WARNS("GrpMgr") << "Error receiving group member data " << LL_ENDL; - return; - } - - if (result.has("ban_list")) - { - result.erase(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS); - // group ban data received - processGroupBanRequest(result); - } - - if (currAction & BAN_UPDATE) - { - currAction = BAN_NO_ACTION; - continue; - } - break; - } while (true); -} + banEntry = (*it); + postData["ban_ids"].append(banEntry); + } -#endif + LL_WARNS() << "post: " << ll_pretty_print_sd(postData) << LL_ENDL; + LLSD result = httpAdapter->postAndYield(self, httpRequest, finalUrl, postData, httpOptions, httpHeaders); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + + if (!status) + { + LL_WARNS("GrpMgr") << "Error posting group member data " << LL_ENDL; + return; + } + + if (result.has("ban_list")) + { + result.erase(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS); + // group ban data received + processGroupBanRequest(result); + } + + if (update) + { + getGroupBanRequestCoro(self, url, groupId); + } +} void LLGroupMgr::sendGroupBanRequest( EBanRequestType request_type, const LLUUID& group_id, U32 ban_action, /* = BAN_NO_ACTION */ - const std::vector ban_list) /* = std::vector() */ + const std::vector &ban_list) /* = std::vector() */ { LLViewerRegion* currentRegion = gAgent.getRegion(); if(!currentRegion) @@ -1998,59 +1972,24 @@ void LLGroupMgr::sendGroupBanRequest( EBanRequestType request_type, return; } -#if 0 + U32 action = ban_action & ~BAN_UPDATE; + bool update = ((ban_action & BAN_UPDATE) == BAN_UPDATE); - LLSD body = LLSD::emptyMap(); - body["ban_action"] = (LLSD::Integer)(ban_action & ~BAN_UPDATE); - // Add our list of potential banned residents to the list - body["ban_ids"] = LLSD::emptyArray(); - LLSD ban_entry; - - uuid_vec_t::const_iterator iter = ban_list.begin(); - for (; iter != ban_list.end(); ++iter) + switch (request_type) { - ban_entry = (*iter); - body["ban_ids"].append(ban_entry); + case REQUEST_GET: + LLCoros::instance().launch("LLGroupMgr::getGroupBanRequestCoro", + boost::bind(&LLGroupMgr::getGroupBanRequestCoro, this, _1, cap_url, group_id)); + break; + case REQUEST_POST: + LLCoros::instance().launch("LLGroupMgr::postGroupBanRequestCoro", + boost::bind(&LLGroupMgr::postGroupBanRequestCoro, this, _1, cap_url, group_id, + action, ban_list, update)); + break; + case REQUEST_PUT: + case REQUEST_DEL: + break; } - - LLCoros::instance().launch("LLGroupMgr::groupBanRequestCoro", - boost::bind(&LLGroupMgr::groupBanRequestCoro, this, _1, cap_url, group_id, - static_cast(ban_action), body)); - -// LLCoros::instance().launch("LLGroupMgr::groupBanRequestCoro", -// boost::bind(&LLGroupMgr::groupBanRequestCoro, this, _1, cap_url, group_id, -// static_cast(ban_action), ban_list)); - -#else - cap_url += "?group_id=" + group_id.asString(); - - LLSD body = LLSD::emptyMap(); - body["ban_action"] = (LLSD::Integer)(ban_action & ~BAN_UPDATE); - // Add our list of potential banned residents to the list - body["ban_ids"] = LLSD::emptyArray(); - LLSD ban_entry; - - uuid_vec_t::const_iterator iter = ban_list.begin(); - for(;iter != ban_list.end(); ++iter) - { - ban_entry = (*iter); - body["ban_ids"].append(ban_entry); - } - - LLHTTPClient::ResponderPtr grp_ban_responder = new GroupBanDataResponder(group_id, ban_action & BAN_UPDATE); - switch(request_type) - { - case REQUEST_GET: - LLHTTPClient::get(cap_url, grp_ban_responder); - break; - case REQUEST_POST: - LLHTTPClient::post(cap_url, body, grp_ban_responder); - break; - case REQUEST_PUT: - case REQUEST_DEL: - break; - } -#endif } void LLGroupMgr::processGroupBanRequest(const LLSD& content) diff --git a/indra/newview/llgroupmgr.h b/indra/newview/llgroupmgr.h index f41a637917..1163923eff 100755 --- a/indra/newview/llgroupmgr.h +++ b/indra/newview/llgroupmgr.h @@ -402,7 +402,7 @@ public: void sendGroupBanRequest(EBanRequestType request_type, const LLUUID& group_id, U32 ban_action = BAN_NO_ACTION, - const uuid_vec_t ban_list = uuid_vec_t()); + const uuid_vec_t &ban_list = uuid_vec_t()); void sendCapGroupMembersRequest(const LLUUID& group_id); @@ -428,13 +428,12 @@ public: void clearGroupData(const LLUUID& group_id); private: - friend class GroupBanDataResponder; - void groupMembersRequestCoro(LLCoros::self& self, std::string url, LLUUID groupId); void processCapGroupMembersRequest(const LLSD& content); - //void groupBanRequestCoro(LLCoros::self& self, std::string url, LLUUID groupId, EBanRequestAction action, uuid_vec_t banList); - void groupBanRequestCoro(LLCoros::self& self, std::string url, LLUUID groupId, EBanRequestAction action, LLSD postBody); + void getGroupBanRequestCoro(LLCoros::self& self, std::string url, LLUUID groupId); + void postGroupBanRequestCoro(LLCoros::self& self, std::string url, LLUUID groupId, U32 action, uuid_vec_t banList, bool update); + static void processGroupBanRequest(const LLSD& content); void notifyObservers(LLGroupChange gc); diff --git a/indra/newview/llinventorymodel.cpp b/indra/newview/llinventorymodel.cpp index f92332dea5..6d21dd4ba7 100755 --- a/indra/newview/llinventorymodel.cpp +++ b/indra/newview/llinventorymodel.cpp @@ -524,59 +524,6 @@ const LLUUID LLInventoryModel::findLibraryCategoryUUIDForType(LLFolderType::ETyp return findCategoryUUIDForTypeInRoot(preferred_type, create_folder, gInventory.getLibraryRootFolderID()); } -class LLCreateInventoryCategoryResponder : public LLHTTPClient::Responder -{ - LOG_CLASS(LLCreateInventoryCategoryResponder); -public: - LLCreateInventoryCategoryResponder(LLInventoryModel* model, - boost::optional callback): - mModel(model), - mCallback(callback) - { - } - -protected: - virtual void httpFailure() - { - LL_WARNS(LOG_INV) << dumpResponse() << LL_ENDL; - } - - virtual void httpSuccess() - { - //Server has created folder. - const LLSD& content = getContent(); - if (!content.isMap() || !content.has("folder_id")) - { - failureResult(HTTP_INTERNAL_ERROR, "Malformed response contents", content); - return; - } - LLUUID category_id = content["folder_id"].asUUID(); - - LL_DEBUGS(LOG_INV) << ll_pretty_print_sd(content) << LL_ENDL; - // Add the category to the internal representation - LLPointer cat = - new LLViewerInventoryCategory( category_id, - content["parent_id"].asUUID(), - (LLFolderType::EType)content["type"].asInteger(), - content["name"].asString(), - gAgent.getID() ); - cat->setVersion(LLViewerInventoryCategory::VERSION_INITIAL); - cat->setDescendentCount(0); - LLInventoryModel::LLCategoryUpdate update(cat->getParentUUID(), 1); - mModel->accountForUpdate(update); - mModel->updateCategory(cat); - - if (mCallback) - { - mCallback.get()(category_id); - } - } - -private: - boost::optional mCallback; - LLInventoryModel* mModel; -}; - // Convenience function to create a new category. You could call // updateCategory() with a newly generated UUID category, but this // version will take care of details like what the name should be @@ -584,7 +531,7 @@ private: LLUUID LLInventoryModel::createNewCategory(const LLUUID& parent_id, LLFolderType::EType preferred_type, const std::string& pname, - boost::optional callback) + inventory_func_type callback) { LLUUID id; @@ -616,7 +563,7 @@ LLUUID LLInventoryModel::createNewCategory(const LLUUID& parent_id, if ( viewer_region ) url = viewer_region->getCapability("CreateInventoryCategory"); - if (!url.empty() && callback.get_ptr()) + if (!url.empty() && callback) { //Let's use the new capability. @@ -630,11 +577,8 @@ LLUUID LLInventoryModel::createNewCategory(const LLUUID& parent_id, request["payload"] = body; LL_DEBUGS(LOG_INV) << "create category request: " << ll_pretty_print_sd(request) << LL_ENDL; - // viewer_region->getCapAPI().post(request); - LLHTTPClient::post( - url, - body, - new LLCreateInventoryCategoryResponder(this, callback) ); + LLCoros::instance().launch("LLInventoryModel::createNewCategoryCoro", + boost::bind(&LLInventoryModel::createNewCategoryCoro, this, _1, url, body, callback)); return LLUUID::null; } @@ -663,6 +607,57 @@ LLUUID LLInventoryModel::createNewCategory(const LLUUID& parent_id, return id; } +void LLInventoryModel::createNewCategoryCoro(LLCoros::self& self, std::string url, LLSD postData, inventory_func_type callback) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("createNewCategoryCoro", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + LLCore::HttpOptions::ptr_t httpOpts = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions); + + + httpOpts->setWantHeaders(true); + + LL_INFOS("HttpCoroutineAdapter", "genericPostCoro") << "Generic POST for " << url << LL_ENDL; + + LLSD result = httpAdapter->postAndYield(self, httpRequest, url, postData, httpOpts); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + + if (!status) + { + LL_WARNS() << "HTTP failure attempting to create category." << LL_ENDL; + return; + } + + if (!result.has("folder_id")) + { + LL_WARNS() << "Malformed response contents" << ll_pretty_print_sd(result) << LL_ENDL; + return; + } + + LLUUID categoryId = result["folder_id"].asUUID(); + + // Add the category to the internal representation + LLPointer cat = new LLViewerInventoryCategory(categoryId, + result["parent_id"].asUUID(), (LLFolderType::EType)result["type"].asInteger(), + result["name"].asString(), gAgent.getID()); + + cat->setVersion(LLViewerInventoryCategory::VERSION_INITIAL); + cat->setDescendentCount(0); + LLInventoryModel::LLCategoryUpdate update(cat->getParentUUID(), 1); + + accountForUpdate(update); + updateCategory(cat); + + if (callback) + { + callback(categoryId); + } + +} + // This is optimized for the case that we just want to know whether a // category has any immediate children meeting a condition, without // needing to recurse or build up any lists. diff --git a/indra/newview/llinventorymodel.h b/indra/newview/llinventorymodel.h index ac336e347c..26ee06535a 100755 --- a/indra/newview/llinventorymodel.h +++ b/indra/newview/llinventorymodel.h @@ -46,6 +46,8 @@ #include "httpoptions.h" #include "httpheaders.h" #include "httphandler.h" +#include "lleventcoro.h" +#include "llcoros.h" class LLInventoryObserver; class LLInventoryObject; @@ -207,14 +209,14 @@ private: **/ //-------------------------------------------------------------------- - // Descendents + // Descendants //-------------------------------------------------------------------- public: - // Make sure we have the descendents in the structure. Returns true + // Make sure we have the descendants in the structure. Returns true // if a fetch was performed. bool fetchDescendentsOf(const LLUUID& folder_id) const; - // Return the direct descendents of the id provided.Set passed + // Return the direct descendants of the id provided.Set passed // in values to NULL if the call fails. // NOTE: The array provided points straight into the guts of // this object, and should only be used for read operations, since @@ -223,10 +225,10 @@ public: cat_array_t*& categories, item_array_t*& items) const; - // Compute a hash of direct descendent names (for detecting child name changes) + // Compute a hash of direct descendant names (for detecting child name changes) LLMD5 hashDirectDescendentNames(const LLUUID& cat_id) const; - // Starting with the object specified, add its descendents to the + // Starting with the object specified, add its descendants to the // array provided, but do not add the inventory object specified // by id. There is no guaranteed order. // NOTE: Neither array will be erased before adding objects to it. @@ -340,7 +342,7 @@ public: U32 updateItem(const LLViewerInventoryItem* item, U32 mask = 0); // Change an existing item with the matching id or add - // the category. No notifcation will be sent to observers. This + // the category. No notification will be sent to observers. This // method will only generate network traffic if the item had to be // reparented. // NOTE: In usage, you will want to perform cache accounting @@ -378,7 +380,7 @@ public: bool update_parent_version = true, bool do_notify_observers = true); - // Update model after all descendents removed from server. + // Update model after all descendants removed from server. void onDescendentsPurgedFromServer(const LLUUID& object_id, bool fix_broken_links = true); // Update model after an existing item gets updated on server. @@ -409,7 +411,7 @@ public: // Changes items order by insertion of the item identified by src_item_id // before (or after) the item identified by dest_item_id. Both items must exist in items array. // Sorting is stored after method is finished. Only src_item_id is moved before (or after) dest_item_id. - // The parameter "insert_before" controls on which side of dest_item_id src_item_id gets rensinserted. + // The parameter "insert_before" controls on which side of dest_item_id src_item_id gets reinserted. static void updateItemsOrder(LLInventoryModel::item_array_t& items, const LLUUID& src_item_id, const LLUUID& dest_item_id, @@ -433,7 +435,7 @@ public: LLUUID createNewCategory(const LLUUID& parent_id, LLFolderType::EType preferred_type, const std::string& name, - boost::optional callback = boost::optional()); + inventory_func_type callback = NULL); protected: // Internal methods that add inventory and make sure that all of // the internal data structures are consistent. These methods @@ -441,6 +443,8 @@ protected: // instance will take over the memory management from there. void addCategory(LLViewerInventoryCategory* category); void addItem(LLViewerInventoryItem* item); + + void createNewCategoryCoro(LLCoros::self& self, std::string url, LLSD postData, inventory_func_type callback); /** Mutators ** ** -- cgit v1.2.3 From daf4d167b66c6124b96dee585b43060e2ea06b42 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 5 Jun 2015 15:19:24 -0700 Subject: Added a seek method to LLCore::Http for data rewind. A couple of minor changes to merchant out box in hopes that the would fix the issues. --- indra/llcorehttp/_httpoprequest.cpp | 35 ++++++++++++++++++++++++++++++++ indra/llcorehttp/_httpoprequest.h | 1 + indra/newview/llmarketplacefunctions.cpp | 6 +++--- 3 files changed, 39 insertions(+), 3 deletions(-) (limited to 'indra') diff --git a/indra/llcorehttp/_httpoprequest.cpp b/indra/llcorehttp/_httpoprequest.cpp index 3b6647882e..3a51f898ab 100755 --- a/indra/llcorehttp/_httpoprequest.cpp +++ b/indra/llcorehttp/_httpoprequest.cpp @@ -515,6 +515,10 @@ HttpStatus HttpOpRequest::prepareRequest(HttpService * service) check_curl_easy_code(code, CURLOPT_READFUNCTION); code = curl_easy_setopt(mCurlHandle, CURLOPT_READDATA, this); check_curl_easy_code(code, CURLOPT_READDATA); + code = curl_easy_setopt(mCurlHandle, CURLOPT_SEEKFUNCTION, seekCallback); + check_curl_easy_code(code, CURLOPT_SEEKFUNCTION); + code = curl_easy_setopt(mCurlHandle, CURLOPT_SEEKDATA, this); + check_curl_easy_code(code, CURLOPT_SEEKDATA); code = curl_easy_setopt(mCurlHandle, CURLOPT_COOKIEFILE, ""); check_curl_easy_code(code, CURLOPT_COOKIEFILE); @@ -819,6 +823,37 @@ size_t HttpOpRequest::readCallback(void * data, size_t size, size_t nmemb, void return read_size; } + +int HttpOpRequest::seekCallback(void *userdata, curl_off_t offset, int origin) +{ + HttpOpRequest * op(static_cast(userdata)); + + if (!op->mReqBody) + { + return 0; + } + + size_t newPos = 0; + if (origin == SEEK_SET) + newPos = offset; + else if (origin == SEEK_END) + newPos = static_cast(op->mReqBody->size()) + offset; + else if (origin == SEEK_CUR) + newPos = static_cast(op->mCurlBodyPos) + offset; + else + return 2; + + if ((newPos < 0) || (newPos >= op->mReqBody->size())) + { + LL_WARNS(LOG_CORE) << "Attempt to seek to position outside post body." << LL_ENDL; + return 2; + } + + op->mCurlBodyPos = (size_t)newPos; + + return 0; +} + size_t HttpOpRequest::headerCallback(void * data, size_t size, size_t nmemb, void * userdata) { diff --git a/indra/llcorehttp/_httpoprequest.h b/indra/llcorehttp/_httpoprequest.h index ca40898a81..b1bb101bea 100755 --- a/indra/llcorehttp/_httpoprequest.h +++ b/indra/llcorehttp/_httpoprequest.h @@ -175,6 +175,7 @@ protected: // static size_t writeCallback(void * data, size_t size, size_t nmemb, void * userdata); static size_t readCallback(void * data, size_t size, size_t nmemb, void * userdata); + static int seekCallback(void *data, curl_off_t offset, int origin); static size_t headerCallback(void * data, size_t size, size_t nmemb, void * userdata); static CURLcode curlSslCtxCallback(CURL *curl, void *ssl_ctx, void *userptr); static int sslCertVerifyCallback(X509_STORE_CTX *ctx, void *param); diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index d095623b2e..bd77912a6c 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -136,7 +136,7 @@ namespace LLMarketplaceImport LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); httpOpts->setWantHeaders(true); - httpOpts->setFollowRedirects(false); + httpOpts->setFollowRedirects(true); httpHeaders->append(HTTP_OUT_HEADER_ACCEPT, "*/*"); httpHeaders->append(HTTP_OUT_HEADER_CONNECTION, "Keep-Alive"); @@ -241,13 +241,13 @@ namespace LLMarketplaceImport { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t - httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("marketplacePostCoro", httpPolicy)); + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("marketplaceGetCoro", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); LLCore::HttpHeaders::ptr_t httpHeaders; LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); httpOpts->setWantHeaders(true); - httpOpts->setFollowRedirects(false); + httpOpts->setFollowRedirects(!sMarketplaceCookie.empty()); if (buildHeaders) { -- cgit v1.2.3 From dde75d76210c9e4df0516b89f8f199fe081a5e87 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 5 Jun 2015 16:11:27 -0700 Subject: Mac builds are very picking about testing an unsigned for < 0 --- indra/llcorehttp/_httpoprequest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/llcorehttp/_httpoprequest.cpp b/indra/llcorehttp/_httpoprequest.cpp index 3a51f898ab..503c04dfa7 100755 --- a/indra/llcorehttp/_httpoprequest.cpp +++ b/indra/llcorehttp/_httpoprequest.cpp @@ -843,7 +843,7 @@ int HttpOpRequest::seekCallback(void *userdata, curl_off_t offset, int origin) else return 2; - if ((newPos < 0) || (newPos >= op->mReqBody->size())) + if (newPos >= op->mReqBody->size()) { LL_WARNS(LOG_CORE) << "Attempt to seek to position outside post body." << LL_ENDL; return 2; -- cgit v1.2.3 From cf4fec954ca46a139465144ccc3888b8fc7d41da Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 8 Jun 2015 17:29:01 -0700 Subject: Added a way to pass a policy Id to the coroadapter. Changed language, appearance, and maturity to conform to use the adapter rather than the SDHandler --- indra/llmessage/llcorehttputil.cpp | 22 ++- indra/llmessage/llcorehttputil.h | 18 ++- indra/newview/llagent.cpp | 193 ++++++++-------------- indra/newview/llagent.h | 18 ++- indra/newview/llagentlanguage.cpp | 27 ++-- indra/newview/llappearancemgr.cpp | 316 +++++++++++++------------------------ indra/newview/llappearancemgr.h | 3 + 7 files changed, 222 insertions(+), 375 deletions(-) (limited to 'indra') diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index 1fd7e7be2e..9ccebabab4 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -848,10 +848,10 @@ LLCore::HttpStatus HttpCoroutineAdapter::getStatusFromLLSD(const LLSD &httpResul } /*static*/ -void HttpCoroutineAdapter::callbackHttpGet(const std::string &url, completionCallback_t success, completionCallback_t failure) +void HttpCoroutineAdapter::callbackHttpGet(const std::string &url, LLCore::HttpRequest::policy_t policyId, completionCallback_t success, completionCallback_t failure) { LLCoros::instance().launch("HttpCoroutineAdapter::genericGetCoro", - boost::bind(&HttpCoroutineAdapter::trivialGetCoro, _1, url, success, failure)); + boost::bind(&HttpCoroutineAdapter::trivialGetCoro, _1, url, policyId, success, failure)); } /*static*/ @@ -865,13 +865,12 @@ void HttpCoroutineAdapter::messageHttpGet(const std::string &url, const std::str } /*static*/ -void HttpCoroutineAdapter::trivialGetCoro(LLCoros::self& self, std::string url, completionCallback_t success, completionCallback_t failure) +void HttpCoroutineAdapter::trivialGetCoro(LLCoros::self& self, std::string url, LLCore::HttpRequest::policy_t policyId, completionCallback_t success, completionCallback_t failure) { - LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t - httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("genericGetCoro", httpPolicy)); + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("genericGetCoro", policyId)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLCore::HttpOptions::ptr_t httpOpts = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions, false); httpOpts->setWantHeaders(true); @@ -899,10 +898,10 @@ void HttpCoroutineAdapter::trivialGetCoro(LLCoros::self& self, std::string url, } /*static*/ -void HttpCoroutineAdapter::callbackHttpPost(const std::string &url, const LLSD &postData, completionCallback_t success, completionCallback_t failure) +void HttpCoroutineAdapter::callbackHttpPost(const std::string &url, LLCore::HttpRequest::policy_t policyId, const LLSD &postData, completionCallback_t success, completionCallback_t failure) { LLCoros::instance().launch("HttpCoroutineAdapter::genericPostCoro", - boost::bind(&HttpCoroutineAdapter::trivialPostCoro, _1, url, postData, success, failure)); + boost::bind(&HttpCoroutineAdapter::trivialPostCoro, _1, url, policyId, postData, success, failure)); } /*static*/ @@ -917,13 +916,12 @@ void HttpCoroutineAdapter::messageHttpPost(const std::string &url, const LLSD &p } /*static*/ -void HttpCoroutineAdapter::trivialPostCoro(LLCoros::self& self, std::string url, LLSD postData, completionCallback_t success, completionCallback_t failure) +void HttpCoroutineAdapter::trivialPostCoro(LLCoros::self& self, std::string url, LLCore::HttpRequest::policy_t policyId, LLSD postData, completionCallback_t success, completionCallback_t failure) { - LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t - httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("genericPostCoro", httpPolicy)); + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("genericPostCoro", policyId)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLCore::HttpOptions::ptr_t httpOpts = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions, false); httpOpts->setWantHeaders(true); diff --git a/indra/llmessage/llcorehttputil.h b/indra/llmessage/llcorehttputil.h index e6c9d2463c..e98399c985 100644 --- a/indra/llmessage/llcorehttputil.h +++ b/indra/llmessage/llcorehttputil.h @@ -427,10 +427,18 @@ public: /// should match this form. /// @sa callbackHttpGet /// @sa callbackHttpPost - typedef boost::function completionCallback_t; + typedef boost::function completionCallback_t; - static void callbackHttpGet(const std::string &url, completionCallback_t success = NULL, completionCallback_t failure = NULL); - static void callbackHttpPost(const std::string &url, const LLSD &postData, completionCallback_t success = NULL, completionCallback_t failure = NULL); + static void callbackHttpGet(const std::string &url, LLCore::HttpRequest::policy_t policyId, completionCallback_t success = NULL, completionCallback_t failure = NULL); + static void callbackHttpGet(const std::string &url, completionCallback_t success = NULL, completionCallback_t failure = NULL) + { + callbackHttpGet(url, LLCore::HttpRequest::DEFAULT_POLICY_ID, success, failure); + } + static void callbackHttpPost(const std::string &url, LLCore::HttpRequest::policy_t policyId, const LLSD &postData, completionCallback_t success = NULL, completionCallback_t failure = NULL); + static void callbackHttpPost(const std::string &url, const LLSD &postData, completionCallback_t success = NULL, completionCallback_t failure = NULL) + { + callbackHttpPost(url, LLCore::HttpRequest::DEFAULT_POLICY_ID, postData, success, failure); + } /// Generic Get and post routines for HTTP via coroutines. /// These static methods do all required setup for the GET or POST operation. @@ -471,8 +479,8 @@ private: const std::string & url, LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler); - static void trivialGetCoro(LLCoros::self& self, std::string url, completionCallback_t success, completionCallback_t failure); - static void trivialPostCoro(LLCoros::self& self, std::string url, LLSD postData, completionCallback_t success, completionCallback_t failure); + static void trivialGetCoro(LLCoros::self& self, std::string url, LLCore::HttpRequest::policy_t policyId, completionCallback_t success, completionCallback_t failure); + static void trivialPostCoro(LLCoros::self& self, std::string url, LLCore::HttpRequest::policy_t policyId, LLSD postData, completionCallback_t success, completionCallback_t failure); void checkDefaultHeaders(LLCore::HttpHeaders::ptr_t &headers); diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index b983a636b6..df304d66c3 100755 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -2550,83 +2550,6 @@ int LLAgent::convertTextToMaturity(char text) return LLAgentAccess::convertTextToMaturity(text); } -//========================================================================= -class LLMaturityHttpHandler : public LLHttpSDHandler -{ -public: - LLMaturityHttpHandler(LLAgent *agent, U8 preferred, U8 previous): - LLHttpSDHandler(), - mAgent(agent), - mPreferredMaturity(preferred), - mPreviousMaturity(previous) - { } - - virtual ~LLMaturityHttpHandler() - { } - -protected: - virtual void onSuccess(LLCore::HttpResponse * response, const LLSD &content); - virtual void onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status); - -private: - U8 parseMaturityFromServerResponse(const LLSD &pContent) const; - - LLAgent * mAgent; - U8 mPreferredMaturity; - U8 mPreviousMaturity; - -}; - -//------------------------------------------------------------------------- -void LLMaturityHttpHandler::onSuccess(LLCore::HttpResponse * response, const LLSD &content) -{ - U8 actualMaturity = parseMaturityFromServerResponse(content); - - if (actualMaturity != mPreferredMaturity) - { - LL_WARNS() << "while attempting to change maturity preference from '" - << LLViewerRegion::accessToString(mPreviousMaturity) - << "' to '" << LLViewerRegion::accessToString(mPreferredMaturity) - << "', the server responded with '" - << LLViewerRegion::accessToString(actualMaturity) - << "' [value:" << static_cast(actualMaturity) - << "], " << LL_ENDL; - } - mAgent->handlePreferredMaturityResult(actualMaturity); -} - -void LLMaturityHttpHandler::onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status) -{ - LL_WARNS() << "while attempting to change maturity preference from '" - << LLViewerRegion::accessToString(mPreviousMaturity) - << "' to '" << LLViewerRegion::accessToString(mPreferredMaturity) - << "', " << LL_ENDL; - mAgent->handlePreferredMaturityError(); -} - -U8 LLMaturityHttpHandler::parseMaturityFromServerResponse(const LLSD &pContent) const -{ - U8 maturity = SIM_ACCESS_MIN; - - llassert(pContent.isDefined()); - llassert(pContent.isMap()); - llassert(pContent.has("access_prefs")); - llassert(pContent.get("access_prefs").isMap()); - llassert(pContent.get("access_prefs").has("max")); - llassert(pContent.get("access_prefs").get("max").isString()); - if (pContent.isDefined() && pContent.isMap() && pContent.has("access_prefs") - && pContent.get("access_prefs").isMap() && pContent.get("access_prefs").has("max") - && pContent.get("access_prefs").get("max").isString()) - { - LLSD::String actualPreference = pContent.get("access_prefs").get("max").asString(); - LLStringUtil::trim(actualPreference); - maturity = LLViewerRegion::shortStringToAccess(actualPreference); - } - - return maturity; -} -//========================================================================= - void LLAgent::handlePreferredMaturityResult(U8 pServerMaturity) { // Update the number of responses received @@ -2761,76 +2684,88 @@ void LLAgent::sendMaturityPreferenceToServer(U8 pPreferredMaturity) LL_WARNS("Agent") << "Region is not defined, can not change Maturity setting." << LL_ENDL; return; } - std::string url = getRegion()->getCapability("UpdateAgentInformation"); - - // If the capability is not defined, report it as an error - if (url.empty()) - { - LL_WARNS("Agent") << "'UpdateAgentInformation' is not defined for region" << LL_ENDL; - return; - } - - LLMaturityHttpHandler * handler = new LLMaturityHttpHandler(this, pPreferredMaturity, mLastKnownResponseMaturity); LLSD access_prefs = LLSD::emptyMap(); access_prefs["max"] = LLViewerRegion::accessToShortString(pPreferredMaturity); LLSD postData = LLSD::emptyMap(); postData["access_prefs"] = access_prefs; - LL_INFOS() << "Sending viewer preferred maturity to '" << LLViewerRegion::accessToString(pPreferredMaturity) - << "' via capability to: " << url << LL_ENDL; - - LLCore::HttpHandle handle = requestPostCapability("UpdateAgentInformation", url, postData, handler); + LL_INFOS() << "Sending viewer preferred maturity to '" << LLViewerRegion::accessToString(pPreferredMaturity) << LL_ENDL; - if (handle == LLCORE_HTTP_HANDLE_INVALID) - { - delete handler; - LL_WARNS("Agent") << "Maturity request post failed." << LL_ENDL; - } + if (!requestPostCapability("UpdateAgentInformation", postData, + static_cast(boost::bind(&LLAgent::processMaturityPreferenceFromServer, this, _1, pPreferredMaturity)), + static_cast(boost::bind(&LLAgent::handlePreferredMaturityError, this)) + )) + { + LL_WARNS("Agent") << "Maturity request post failed." << LL_ENDL; + } } } -// *TODO:RIDER Convert this system to using the coroutine scheme for HTTP communications -// -LLCore::HttpHandle LLAgent::requestPostCapability(const std::string &cap, const std::string &url, LLSD &postData, LLHttpSDHandler *usrhndlr) + +void LLAgent::processMaturityPreferenceFromServer(const LLSD &result, U8 perferredMaturity) { - LLHttpSDHandler * handler = (usrhndlr) ? usrhndlr : new LLHttpSDGenericHandler(cap); - LLCore::HttpHandle handle = LLCoreHttpUtil::requestPostWithLLSD(mHttpRequest, - mHttpPolicy, mHttpPriority, url, - postData, mHttpOptions, mHttpHeaders, handler); + U8 maturity = SIM_ACCESS_MIN; - 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 POST failed. Reason " - << status.toTerseString() << " \"" << status.toString() << "\"" << LL_ENDL; - } - return handle; + llassert(result.isDefined()); + llassert(result.isMap()); + llassert(result.has("access_prefs")); + llassert(result.get("access_prefs").isMap()); + llassert(result.get("access_prefs").has("max")); + llassert(result.get("access_prefs").get("max").isString()); + if (result.isDefined() && result.isMap() && result.has("access_prefs") + && result.get("access_prefs").isMap() && result.get("access_prefs").has("max") + && result.get("access_prefs").get("max").isString()) + { + LLSD::String actualPreference = result.get("access_prefs").get("max").asString(); + LLStringUtil::trim(actualPreference); + maturity = LLViewerRegion::shortStringToAccess(actualPreference); + } + + if (maturity != perferredMaturity) + { + LL_WARNS() << "while attempting to change maturity preference from '" + << LLViewerRegion::accessToString(mLastKnownResponseMaturity) + << "' to '" << LLViewerRegion::accessToString(perferredMaturity) + << "', the server responded with '" + << LLViewerRegion::accessToString(maturity) + << "' [value:" << static_cast(maturity) + << "], " << LL_ENDL; + } + handlePreferredMaturityResult(maturity); } -LLCore::HttpHandle LLAgent::requestGetCapability(const std::string &cap, const std::string &url, LLHttpSDHandler *usrhndlr) + +bool LLAgent::requestPostCapability(const std::string &capName, LLSD &postData, httpCallback_t cbSuccess, httpCallback_t cbFailure) { - LLHttpSDHandler * handler = (usrhndlr) ? usrhndlr : new LLHttpSDGenericHandler(cap); - LLCore::HttpHandle handle = mHttpRequest->requestGet(mHttpPolicy, mHttpPriority, - url, mHttpOptions.get(), mHttpHeaders.get(), handler); + std::string url; + + url = getRegion()->getCapability(capName); - if (handle == LLCORE_HTTP_HANDLE_INVALID) + if (url.empty()) { - // 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; + LL_WARNS("Agent") << "Could not retrieve region capability \"" << capName << "\"" << LL_ENDL; + return false; } - return handle; + + LLCoreHttpUtil::HttpCoroutineAdapter::callbackHttpPost(url, mHttpPolicy, postData, cbSuccess, cbFailure); + return true; +} + +bool LLAgent::requestGetCapability(const std::string &capName, httpCallback_t cbSuccess, httpCallback_t cbFailure) +{ + std::string url; + + url = getRegion()->getCapability(capName); + + if (url.empty()) + { + LL_WARNS("Agent") << "Could not retrieve region capability \"" << capName << "\"" << LL_ENDL; + return false; + } + + LLCoreHttpUtil::HttpCoroutineAdapter::callbackHttpGet(url, mHttpPolicy, cbSuccess, cbFailure); + return true; } BOOL LLAgent::getAdminOverride() const diff --git a/indra/newview/llagent.h b/indra/newview/llagent.h index 1bad35751f..745c0b063a 100755 --- a/indra/newview/llagent.h +++ b/indra/newview/llagent.h @@ -36,9 +36,7 @@ #include "llpermissionsflags.h" #include "llevents.h" #include "v3dmath.h" -#include "httprequest.h" -#include "httpheaders.h" -#include "httpoptions.h" +#include "llcorehttputil.h" #include #include @@ -66,6 +64,8 @@ class LLUIColor; class LLTeleportRequest; class LLHttpSDHandler; + + typedef boost::shared_ptr LLTeleportRequestPtr; //-------------------------------------------------------------------- @@ -638,6 +638,8 @@ public: void setMaturityRatingChangeDuringTeleport(U8 pMaturityRatingChange); private: + + friend class LLTeleportRequest; friend class LLTeleportRequestViaLandmark; friend class LLTeleportRequestViaLure; @@ -774,8 +776,8 @@ private: bool isMaturityPreferenceSyncedWithServer() const; void sendMaturityPreferenceToServer(U8 pPreferredMaturity); + void processMaturityPreferenceFromServer(const LLSD &result, U8 perferredMaturity); - friend class LLMaturityHttpHandler; void handlePreferredMaturityResult(U8 pServerMaturity); void handlePreferredMaturityError(); void reportPreferredMaturitySuccess(); @@ -929,10 +931,14 @@ public: ** UTILITY **/ public: + typedef LLCoreHttpUtil::HttpCoroutineAdapter::completionCallback_t httpCallback_t; + /// Utilities for allowing the the agent sub managers to post and get via /// 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 requestGetCapability(const std::string &cap, const std::string &url, LLHttpSDHandler *usrhndlr = NULL); + bool requestPostCapability(const std::string &capName, LLSD &postData, httpCallback_t cbSuccess = NULL, httpCallback_t cbFailure = NULL); + bool requestGetCapability(const std::string &capName, httpCallback_t cbSuccess = NULL, httpCallback_t cbFailure = NULL); +// LLCore::HttpHandle requestPostCapability(const std::string &cap, const std::string &url, LLSD &postData, LLHttpSDHandler *usrhndlr = NULL); +// LLCore::HttpHandle requestGetCapability(const std::string &cap, const std::string &url, LLHttpSDHandler *usrhndlr = NULL); /** Utility ** ** diff --git a/indra/newview/llagentlanguage.cpp b/indra/newview/llagentlanguage.cpp index 66aec42417..cdb0e3302d 100755 --- a/indra/newview/llagentlanguage.cpp +++ b/indra/newview/llagentlanguage.cpp @@ -55,26 +55,17 @@ void LLAgentLanguage::onChange() // static bool LLAgentLanguage::update() { - LLSD body; - std::string url; + LLSD body; - if (gAgent.getRegion()) - { - url = gAgent.getRegion()->getCapability("UpdateAgentLanguage"); - } - - if (!url.empty()) - { - std::string language = LLUI::getLanguage(); + std::string language = LLUI::getLanguage(); - body["language"] = language; - body["language_is_public"] = gSavedSettings.getBOOL("LanguageIsPublic"); + body["language"] = language; + body["language_is_public"] = gSavedSettings.getBOOL("LanguageIsPublic"); - LLCore::HttpHandle handle = gAgent.requestPostCapability("UpdateAgentLanguage", url, body); - if (handle == LLCORE_HTTP_HANDLE_INVALID) - { - LL_WARNS() << "Unable to change language." << LL_ENDL; - } - } + if (!gAgent.requestPostCapability("UpdateAgentLanguage", body)) + { + LL_WARNS("Language") << "Language capability unavailable." << LL_ENDL; + } + return true; } diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp index 59d2079b5d..5ad71369c3 100755 --- a/indra/newview/llappearancemgr.cpp +++ b/indra/newview/llappearancemgr.cpp @@ -1245,196 +1245,6 @@ static void removeDuplicateItems(LLInventoryModel::item_array_t& items) items = new_items; } -//========================================================================= -#if 0 -// *TODO: -class LLAppearanceMgrHttpHandler -{ -public: - - static void apperanceMgrRequestCoro(LLCoros::self& self, std::string url); - -private: - LLAppearanceMgrHttpHandler(); - - static void debugCOF(const LLSD& content); - - -}; - -void LLAppearanceMgrHttpHandler::apperanceMgrRequestCoro(LLCoros::self& self, std::string url) -{ - LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); - LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t - httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("EnvironmentRequest", httpPolicy)); - LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - - - -} - -#else - -// *TODO: Convert this and llavatar over to using the coroutine scheme rather -// than the responder for communications. (see block above for start...) - -class LLAppearanceMgrHttpHandler : public LLHttpSDHandler -{ -public: - LLAppearanceMgrHttpHandler(LLAppearanceMgr *mgr) : - LLHttpSDHandler(), - mManager(mgr) - { } - - virtual ~LLAppearanceMgrHttpHandler() - { } - - virtual void onCompleted(LLCore::HttpHandle handle, LLCore::HttpResponse * response); - -protected: - virtual void onSuccess(LLCore::HttpResponse * response, const LLSD &content); - virtual void onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status); - -private: - static void debugCOF(const LLSD& content); - - LLAppearanceMgr *mManager; - -}; - -//------------------------------------------------------------------------- -void LLAppearanceMgrHttpHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpResponse * response) -{ - mManager->decrementInFlightCounter(); - - LLHttpSDHandler::onCompleted(handle, response); -} - -void LLAppearanceMgrHttpHandler::onSuccess(LLCore::HttpResponse * response, const LLSD &content) -{ - if (!content.isMap()) - { - LLCore::HttpStatus status = LLCore::HttpStatus(HTTP_INTERNAL_ERROR, "Malformed response contents"); - response->setStatus(status); - onFailure(response, status); - if (gSavedSettings.getBOOL("DebugAvatarAppearanceMessage")) - { - debugCOF(content); - } - return; - } - if (content["success"].asBoolean()) - { - LL_DEBUGS("Avatar") << "succeeded" << LL_ENDL; - if (gSavedSettings.getBOOL("DebugAvatarAppearanceMessage")) - { - dump_sequential_xml(gAgentAvatarp->getFullname() + "_appearance_request_ok", content); - } - } - else - { - LLCore::HttpStatus status = LLCore::HttpStatus(HTTP_INTERNAL_ERROR, "Non-success response"); - response->setStatus(status); - onFailure(response, status); - if (gSavedSettings.getBOOL("DebugAvatarAppearanceMessage")) - { - debugCOF(content); - } - return; - } -} - -void LLAppearanceMgrHttpHandler::onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status) -{ - LL_WARNS("Avatar") << "Appearance Mgr request failed to " << response->getRequestURL() - << ". Reason code: (" << status.toTerseString() << ") " - << status.toString() << LL_ENDL; -} - -#endif - -void LLAppearanceMgrHttpHandler::debugCOF(const LLSD& content) -{ - dump_sequential_xml(gAgentAvatarp->getFullname() + "_appearance_request_error", content); - - LL_INFOS("Avatar") << "AIS COF, version received: " << content["expected"].asInteger() - << " ================================= " << LL_ENDL; - std::set ais_items, local_items; - const LLSD& cof_raw = content["cof_raw"]; - for (LLSD::array_const_iterator it = cof_raw.beginArray(); - it != cof_raw.endArray(); ++it) - { - const LLSD& item = *it; - if (item["parent_id"].asUUID() == LLAppearanceMgr::instance().getCOF()) - { - ais_items.insert(item["item_id"].asUUID()); - if (item["type"].asInteger() == 24) // link - { - LL_INFOS("Avatar") << "AIS Link: item_id: " << item["item_id"].asUUID() - << " linked_item_id: " << item["asset_id"].asUUID() - << " name: " << item["name"].asString() - << LL_ENDL; - } - else if (item["type"].asInteger() == 25) // folder link - { - LL_INFOS("Avatar") << "AIS Folder link: item_id: " << item["item_id"].asUUID() - << " linked_item_id: " << item["asset_id"].asUUID() - << " name: " << item["name"].asString() - << LL_ENDL; - } - else - { - LL_INFOS("Avatar") << "AIS Other: item_id: " << item["item_id"].asUUID() - << " linked_item_id: " << item["asset_id"].asUUID() - << " name: " << item["name"].asString() - << " type: " << item["type"].asInteger() - << LL_ENDL; - } - } - } - LL_INFOS("Avatar") << LL_ENDL; - LL_INFOS("Avatar") << "Local COF, version requested: " << content["observed"].asInteger() - << " ================================= " << LL_ENDL; - LLInventoryModel::cat_array_t cat_array; - LLInventoryModel::item_array_t item_array; - gInventory.collectDescendents(LLAppearanceMgr::instance().getCOF(), - cat_array, item_array, LLInventoryModel::EXCLUDE_TRASH); - for (S32 i = 0; i < item_array.size(); i++) - { - const LLViewerInventoryItem* inv_item = item_array.at(i).get(); - local_items.insert(inv_item->getUUID()); - LL_INFOS("Avatar") << "LOCAL: item_id: " << inv_item->getUUID() - << " linked_item_id: " << inv_item->getLinkedUUID() - << " name: " << inv_item->getName() - << " parent: " << inv_item->getParentUUID() - << LL_ENDL; - } - LL_INFOS("Avatar") << " ================================= " << LL_ENDL; - S32 local_only = 0, ais_only = 0; - for (std::set::iterator it = local_items.begin(); it != local_items.end(); ++it) - { - if (ais_items.find(*it) == ais_items.end()) - { - LL_INFOS("Avatar") << "LOCAL ONLY: " << *it << LL_ENDL; - local_only++; - } - } - for (std::set::iterator it = ais_items.begin(); it != ais_items.end(); ++it) - { - if (local_items.find(*it) == local_items.end()) - { - LL_INFOS("Avatar") << "AIS ONLY: " << *it << LL_ENDL; - ais_only++; - } - } - if (local_only == 0 && ais_only == 0) - { - LL_INFOS("Avatar") << "COF contents identical, only version numbers differ (req " - << content["observed"].asInteger() - << " rcv " << content["expected"].asInteger() - << ")" << LL_ENDL; - } -} //========================================================================= const LLUUID LLAppearanceMgr::getCOF() const @@ -3509,7 +3319,7 @@ void LLAppearanceMgr::requestServerAppearanceUpdate() if (gAgentAvatarp->isEditingAppearance()) { - LL_WARNS("Avatar") << "Avatar editing appeance, not sending request." << LL_ENDL; + LL_WARNS("Avatar") << "Avatar editing appearance, not sending request." << LL_ENDL; // don't send out appearance updates if in appearance editing mode return; } @@ -3523,12 +3333,6 @@ void LLAppearanceMgr::requestServerAppearanceUpdate() { LL_WARNS("Avatar") << "Region does not support baking" << LL_ENDL; } - std::string url = gAgent.getRegion()->getCapability("UpdateAvatarAppearance"); - if (url.empty()) - { - LL_WARNS("Avatar") << "No cap for UpdateAvatarAppearance." << LL_ENDL; - return; - } LLSD postData; S32 cof_version = LLAppearanceMgr::instance().getCOFVersion(); @@ -3544,9 +3348,6 @@ void LLAppearanceMgr::requestServerAppearanceUpdate() postData["cof_version"] = cof_version + 999; } } - LL_DEBUGS("Avatar") << "request url " << url << " my_cof_version " << cof_version << LL_ENDL; - - LLAppearanceMgrHttpHandler * handler = new LLAppearanceMgrHttpHandler(this); mInFlightCounter++; mInFlightTimer.setTimerExpirySec(60.0); @@ -3554,15 +3355,120 @@ void LLAppearanceMgr::requestServerAppearanceUpdate() llassert(cof_version >= gAgentAvatarp->mLastUpdateRequestCOFVersion); gAgentAvatarp->mLastUpdateRequestCOFVersion = cof_version; + if (!gAgent.requestPostCapability("UpdateAvatarAppearance", postData, + static_cast(boost::bind(&LLAppearanceMgr::serverAppearanceUpdateSuccess, this, _1)), + static_cast(boost::bind(&LLAppearanceMgr::decrementInFlightCounter, this)))) + { + LL_WARNS("Avatar") << "Unable to access UpdateAvatarAppearance in this region." << LL_ENDL; + } +} + +void LLAppearanceMgr::serverAppearanceUpdateSuccess(const LLSD &result) +{ + decrementInFlightCounter(); + if (result["success"].asBoolean()) + { + LL_DEBUGS("Avatar") << "succeeded" << LL_ENDL; + if (gSavedSettings.getBOOL("DebugAvatarAppearanceMessage")) + { + dump_sequential_xml(gAgentAvatarp->getFullname() + "_appearance_request_ok", result); + } + } + else + { + LL_WARNS("Avatar") << "Non success response for change appearance" << LL_ENDL; + if (gSavedSettings.getBOOL("DebugAvatarAppearanceMessage")) + { + debugAppearanceUpdateCOF(result); + } + } +} - LLCore::HttpHandle handle = gAgent.requestPostCapability("UpdateAvatarAppearance", url, postData, handler); +/*static*/ +void LLAppearanceMgr::debugAppearanceUpdateCOF(const LLSD& content) +{ + dump_sequential_xml(gAgentAvatarp->getFullname() + "_appearance_request_error", content); - if (handle == LLCORE_HTTP_HANDLE_INVALID) - { - delete handler; - } + LL_INFOS("Avatar") << "AIS COF, version received: " << content["expected"].asInteger() + << " ================================= " << LL_ENDL; + std::set ais_items, local_items; + const LLSD& cof_raw = content["cof_raw"]; + for (LLSD::array_const_iterator it = cof_raw.beginArray(); + it != cof_raw.endArray(); ++it) + { + const LLSD& item = *it; + if (item["parent_id"].asUUID() == LLAppearanceMgr::instance().getCOF()) + { + ais_items.insert(item["item_id"].asUUID()); + if (item["type"].asInteger() == 24) // link + { + LL_INFOS("Avatar") << "AIS Link: item_id: " << item["item_id"].asUUID() + << " linked_item_id: " << item["asset_id"].asUUID() + << " name: " << item["name"].asString() + << LL_ENDL; + } + else if (item["type"].asInteger() == 25) // folder link + { + LL_INFOS("Avatar") << "AIS Folder link: item_id: " << item["item_id"].asUUID() + << " linked_item_id: " << item["asset_id"].asUUID() + << " name: " << item["name"].asString() + << LL_ENDL; + } + else + { + LL_INFOS("Avatar") << "AIS Other: item_id: " << item["item_id"].asUUID() + << " linked_item_id: " << item["asset_id"].asUUID() + << " name: " << item["name"].asString() + << " type: " << item["type"].asInteger() + << LL_ENDL; + } + } + } + LL_INFOS("Avatar") << LL_ENDL; + LL_INFOS("Avatar") << "Local COF, version requested: " << content["observed"].asInteger() + << " ================================= " << LL_ENDL; + LLInventoryModel::cat_array_t cat_array; + LLInventoryModel::item_array_t item_array; + gInventory.collectDescendents(LLAppearanceMgr::instance().getCOF(), + cat_array, item_array, LLInventoryModel::EXCLUDE_TRASH); + for (S32 i = 0; i < item_array.size(); i++) + { + const LLViewerInventoryItem* inv_item = item_array.at(i).get(); + local_items.insert(inv_item->getUUID()); + LL_INFOS("Avatar") << "LOCAL: item_id: " << inv_item->getUUID() + << " linked_item_id: " << inv_item->getLinkedUUID() + << " name: " << inv_item->getName() + << " parent: " << inv_item->getParentUUID() + << LL_ENDL; + } + LL_INFOS("Avatar") << " ================================= " << LL_ENDL; + S32 local_only = 0, ais_only = 0; + for (std::set::iterator it = local_items.begin(); it != local_items.end(); ++it) + { + if (ais_items.find(*it) == ais_items.end()) + { + LL_INFOS("Avatar") << "LOCAL ONLY: " << *it << LL_ENDL; + local_only++; + } + } + for (std::set::iterator it = ais_items.begin(); it != ais_items.end(); ++it) + { + if (local_items.find(*it) == local_items.end()) + { + LL_INFOS("Avatar") << "AIS ONLY: " << *it << LL_ENDL; + ais_only++; + } + } + if (local_only == 0 && ais_only == 0) + { + LL_INFOS("Avatar") << "COF contents identical, only version numbers differ (req " + << content["observed"].asInteger() + << " rcv " << content["expected"].asInteger() + << ")" << LL_ENDL; + } } + bool LLAppearanceMgr::testCOFRequestVersion() const { // If we have already received an update for this or higher cof version, ignore. diff --git a/indra/newview/llappearancemgr.h b/indra/newview/llappearancemgr.h index 669d7242aa..3d9a1f1518 100755 --- a/indra/newview/llappearancemgr.h +++ b/indra/newview/llappearancemgr.h @@ -233,6 +233,9 @@ public: private: + void serverAppearanceUpdateSuccess(const LLSD &result); + static void debugAppearanceUpdateCOF(const LLSD& content); + std::string mAppearanceServiceURL; protected: -- cgit v1.2.3 From aba8d5e488d771f3d30ee75f0fbca30747adb7d1 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 9 Jun 2015 13:06:09 -0700 Subject: Removed homelocation responder (rolled into llagent) Removed sdhandler from llagent. Removed unused values from llacountingccostmgr Fixed smart pontier creation in llfacebook --- indra/llmessage/llavatarnamecache.cpp | 1 - indra/newview/CMakeLists.txt | 2 - indra/newview/llaccountingcostmanager.cpp | 4 -- indra/newview/llaccountingcostmanager.h | 2 - indra/newview/llagent.cpp | 100 +++++++++++++-------------- indra/newview/llagent.h | 12 +--- indra/newview/llfacebookconnect.cpp | 10 +-- indra/newview/llhomelocationresponder.cpp | 108 ------------------------------ indra/newview/llhomelocationresponder.h | 44 ------------ 9 files changed, 58 insertions(+), 225 deletions(-) delete mode 100755 indra/newview/llhomelocationresponder.cpp delete mode 100755 indra/newview/llhomelocationresponder.h (limited to 'indra') diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index 5d9daca37a..e4b8642c4d 100755 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -135,7 +135,6 @@ namespace LLAvatarNameCache // Erase expired names from cache void eraseUnrefreshed(); - //bool expirationFromCacheControl(LLCore::HttpHeaders *headers, F64 *expires); bool expirationFromCacheControl(const LLSD& headers, F64 *expires); // This is a coroutine. The only parameter that can be specified as a reference is the self diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 3553e3a612..bebc82e847 100755 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -326,7 +326,6 @@ set(viewer_SOURCE_FILES llgroupmgr.cpp llhasheduniqueid.cpp llhints.cpp - llhomelocationresponder.cpp llhttpretrypolicy.cpp llhudeffect.cpp llhudeffectbeam.cpp @@ -931,7 +930,6 @@ set(viewer_HEADER_FILES llhasheduniqueid.h llhints.h llhttpretrypolicy.h - llhomelocationresponder.h llhudeffect.h llhudeffectbeam.h llhudeffectlookat.h diff --git a/indra/newview/llaccountingcostmanager.cpp b/indra/newview/llaccountingcostmanager.cpp index 6337fbe444..f928c84ecb 100755 --- a/indra/newview/llaccountingcostmanager.cpp +++ b/indra/newview/llaccountingcostmanager.cpp @@ -35,13 +35,9 @@ //=============================================================================== LLAccountingCostManager::LLAccountingCostManager(): mHttpRequest(), - mHttpHeaders(), - mHttpOptions(), mHttpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID) { mHttpRequest = LLCore::HttpRequest::ptr_t(new LLCore::HttpRequest()); - mHttpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false); - mHttpOptions = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false); //mHttpPolicy = LLCore::HttpRequest::DEFAULT_POLICY_ID; } diff --git a/indra/newview/llaccountingcostmanager.h b/indra/newview/llaccountingcostmanager.h index f4d45d43cb..34748894e3 100755 --- a/indra/newview/llaccountingcostmanager.h +++ b/indra/newview/llaccountingcostmanager.h @@ -80,8 +80,6 @@ private: void accountingCostCoro(LLCoros::self& self, std::string url, eSelectionType selectionType, const LLHandle observerHandle); LLCore::HttpRequest::ptr_t mHttpRequest; - LLCore::HttpHeaders::ptr_t mHttpHeaders; - LLCore::HttpOptions::ptr_t mHttpOptions; LLCore::HttpRequest::policy_t mHttpPolicy; }; //=============================================================================== diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index df304d66c3..230447b256 100755 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -52,7 +52,6 @@ #include "llfloatertools.h" #include "llgroupactions.h" #include "llgroupmgr.h" -#include "llhomelocationresponder.h" #include "llhudmanager.h" #include "lljoystickbutton.h" #include "llmorphview.h" @@ -95,7 +94,6 @@ #include "lscript_byteformat.h" #include "stringize.h" #include "boost/foreach.hpp" -#include "llhttpsdhandler.h" #include "llcorehttputil.h" using namespace LLAvatarAppearanceDefines; @@ -363,11 +361,7 @@ LLAgent::LLAgent() : mMaturityPreferenceNumRetries(0U), mLastKnownRequestMaturity(SIM_ACCESS_MIN), mLastKnownResponseMaturity(SIM_ACCESS_MIN), - mHttpRequest(), - mHttpHeaders(), - mHttpOptions(), mHttpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID), - mHttpPriority(0), mTeleportState(TELEPORT_NONE), mRegionp(NULL), @@ -470,15 +464,8 @@ void LLAgent::init() LLAppCoreHttp & app_core_http(LLAppViewer::instance()->getAppCoreHttp()); - mHttpRequest = LLCore::HttpRequest::ptr_t(new LLCore::HttpRequest()); - mHttpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false); - mHttpOptions = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false); mHttpPolicy = app_core_http.getPolicy(LLAppCoreHttp::AP_AGENT); - // 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; } @@ -496,10 +483,6 @@ void LLAgent::cleanup() { mTeleportFailedSlot.disconnect(); } - if (mBoundListener.connected()) - { - mBoundListener.disconnect(); - } } //----------------------------------------------------------------------------- @@ -522,17 +505,6 @@ LLAgent::~LLAgent() mTeleportSourceSLURL = NULL; } -//----------------------------------------------------------------------------- -// pollHttp -// Polling done once per frame on the "mainloop" to support HTTP processing. -//----------------------------------------------------------------------------- -bool LLAgent::pollHttp(const LLSD&) -{ - mHttpRequest->update(0L); - return false; -} - - // Handle any actions that need to be performed when the main app gains focus // (such as through alt-tab). //----------------------------------------------------------------------------- @@ -2359,27 +2331,9 @@ void LLAgent::setStartPosition( U32 location_id ) body["HomeLocation"] = homeLocation; - // This awkward idiom warrants explanation. - // For starters, LLSDMessage::ResponderAdapter is ONLY for testing the new - // LLSDMessage functionality with a pre-existing LLHTTPClient::Responder. - // In new code, define your reply/error methods on the same class as the - // sending method, bind them to local LLEventPump objects and pass those - // LLEventPump names in the request LLSD object. - // When testing old code, the new LLHomeLocationResponder object - // is referenced by an LLHTTPClient::ResponderPtr, so when the - // ResponderAdapter is deleted, the LLHomeLocationResponder will be too. - // We must trust that the underlying LLHTTPClient code will eventually - // fire either the reply callback or the error callback; either will cause - // the ResponderAdapter to delete itself. - LLSDMessage::ResponderAdapter* - adapter(new LLSDMessage::ResponderAdapter(new LLHomeLocationResponder())); - - request["message"] = "HomeLocation"; - request["payload"] = body; - request["reply"] = adapter->getReplyName(); - request["error"] = adapter->getErrorName(); - - gAgent.getRegion()->getCapAPI().post(request); + if (!requestPostCapability("HomeLocation", body, + boost::bind(&LLAgent::setStartPositionSuccess, this, _1))) + LL_WARNS() << "Unable to post to HomeLocation capability." << LL_ENDL; const U32 HOME_INDEX = 1; if( HOME_INDEX == location_id ) @@ -2388,6 +2342,53 @@ void LLAgent::setStartPosition( U32 location_id ) } } +void LLAgent::setStartPositionSuccess(const LLSD &result) +{ + LLVector3 agent_pos; + bool error = true; + + do { + // was the call to /agent//home-location successful? + // If not, we keep error set to true + if (!result.has("success")) + break; + + if (0 != strncmp("true", result["success"].asString().c_str(), 4)) + break; + + // did the simulator return a "justified" home location? + // If no, we keep error set to true + if (!result.has("HomeLocation")) + break; + + if ((!result["HomeLocation"].has("LocationPos")) || + (!result["HomeLocation"]["LocationPos"].has("X")) || + (!result["HomeLocation"]["LocationPos"].has("Y")) || + (!result["HomeLocation"]["LocationPos"].has("Z"))) + break; + + agent_pos.mV[VX] = result["HomeLocation"]["LocationPos"]["X"].asInteger(); + agent_pos.mV[VY] = result["HomeLocation"]["LocationPos"]["Y"].asInteger(); + agent_pos.mV[VZ] = result["HomeLocation"]["LocationPos"]["Z"].asInteger(); + + error = false; + + } while (0); + + if (error) + { + LL_WARNS() << "Error in response to home position set." << LL_ENDL; + } + else + { + LL_INFOS() << "setting home position" << LL_ENDL; + + LLViewerRegion *viewer_region = gAgent.getRegion(); + setHomePosRegion(viewer_region->getHandle(), agent_pos); + } +} + +#if 1 struct HomeLocationMapper: public LLCapabilityListener::CapabilityMapper { // No reply message expected @@ -2414,6 +2415,7 @@ struct HomeLocationMapper: public LLCapabilityListener::CapabilityMapper }; // Need an instance of this class so it will self-register static HomeLocationMapper homeLocationMapper; +#endif void LLAgent::requestStopMotion( LLMotion* motion ) { diff --git a/indra/newview/llagent.h b/indra/newview/llagent.h index 745c0b063a..0ba3dea427 100755 --- a/indra/newview/llagent.h +++ b/indra/newview/llagent.h @@ -62,7 +62,6 @@ class LLSLURL; class LLPauseRequestHandle; class LLUIColor; class LLTeleportRequest; -class LLHttpSDHandler; @@ -234,6 +233,8 @@ public: void setHomePosRegion(const U64& region_handle, const LLVector3& pos_region); BOOL getHomePosGlobal(LLVector3d* pos_global); private: + void setStartPositionSuccess(const LLSD &result); + BOOL mHaveHomePosition; U64 mHomeRegionHandle; LLVector3 mHomePosRegion; @@ -767,12 +768,7 @@ private: unsigned int mMaturityPreferenceNumRetries; U8 mLastKnownRequestMaturity; U8 mLastKnownResponseMaturity; - LLCore::HttpRequest::ptr_t mHttpRequest; - LLCore::HttpHeaders::ptr_t mHttpHeaders; - LLCore::HttpOptions::ptr_t mHttpOptions; LLCore::HttpRequest::policy_t mHttpPolicy; - LLCore::HttpRequest::priority_t mHttpPriority; - LLTempBoundListener mBoundListener; bool isMaturityPreferenceSyncedWithServer() const; void sendMaturityPreferenceToServer(U8 pPreferredMaturity); @@ -787,8 +783,6 @@ private: void handleMaturity(const LLSD &pNewValue); bool validateMaturity(const LLSD& newvalue); - bool pollHttp(const LLSD &); - /** Access ** ** @@ -937,8 +931,6 @@ public: /// HTTP using the agent's policy settings and headers. bool requestPostCapability(const std::string &capName, LLSD &postData, httpCallback_t cbSuccess = NULL, httpCallback_t cbFailure = NULL); bool requestGetCapability(const std::string &capName, httpCallback_t cbSuccess = NULL, httpCallback_t cbFailure = NULL); -// LLCore::HttpHandle requestPostCapability(const std::string &cap, const std::string &url, LLSD &postData, LLHttpSDHandler *usrhndlr = NULL); -// LLCore::HttpHandle requestGetCapability(const std::string &cap, const std::string &url, LLHttpSDHandler *usrhndlr = NULL); /** Utility ** ** diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index d1ed4e8ba4..a295910379 100755 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -131,7 +131,7 @@ void LLFacebookConnect::facebookConnectCoro(LLCoros::self& self, std::string aut LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FacebookConnect", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions, false); LLSD putData; if (!authCode.empty()) @@ -217,7 +217,7 @@ void LLFacebookConnect::facebookShareCoro(LLCoros::self& self, std::string route LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FacebookConnect", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions, false); httpOpts->setWantHeaders(true); @@ -239,8 +239,8 @@ void LLFacebookConnect::facebookShareImageCoro(LLCoros::self& self, std::string LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FacebookConnect", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLCore::HttpHeaders::ptr_t httpHeaders(new LLCore::HttpHeaders); - LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); + LLCore::HttpHeaders::ptr_t httpHeaders(new LLCore::HttpHeaders, false); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions, false); httpOpts->setWantHeaders(true); @@ -386,7 +386,7 @@ void LLFacebookConnect::facebookConnectInfoCoro(LLCoros::self& self) LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FacebookConnect", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions, false); httpOpts->setWantHeaders(true); diff --git a/indra/newview/llhomelocationresponder.cpp b/indra/newview/llhomelocationresponder.cpp deleted file mode 100755 index d0492bcdb4..0000000000 --- a/indra/newview/llhomelocationresponder.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/** - * @file llhomelocationresponder.cpp - * @author Meadhbh Hamrick - * @brief Processes responses to the HomeLocation CapReq - * - * $LicenseInfo:firstyear=2008&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -/* File Inclusions */ -#include "llviewerprecompiledheaders.h" - -#include "llhomelocationresponder.h" -#include "llsdutil.h" -#include "llagent.h" -#include "llviewerregion.h" - -void LLHomeLocationResponder::httpSuccess() -{ - const LLSD& content = getContent(); - LLVector3 agent_pos; - bool error = true; - - do { - - // was the call to /agent//home-location successful? - // If not, we keep error set to true - if( ! content.has("success") ) - { - break; - } - - if( 0 != strncmp("true", content["success"].asString().c_str(), 4 ) ) - { - break; - } - - // did the simulator return a "justified" home location? - // If no, we keep error set to true - if( ! content.has( "HomeLocation" ) ) - { - break; - } - - if( ! content["HomeLocation"].has("LocationPos") ) - { - break; - } - - if( ! content["HomeLocation"]["LocationPos"].has("X") ) - { - break; - } - - agent_pos.mV[VX] = content["HomeLocation"]["LocationPos"]["X"].asInteger(); - - if( ! content["HomeLocation"]["LocationPos"].has("Y") ) - { - break; - } - - agent_pos.mV[VY] = content["HomeLocation"]["LocationPos"]["Y"].asInteger(); - - if( ! content["HomeLocation"]["LocationPos"].has("Z") ) - { - break; - } - - agent_pos.mV[VZ] = content["HomeLocation"]["LocationPos"]["Z"].asInteger(); - - error = false; - } while( 0 ); - - if( error ) - { - failureResult(HTTP_INTERNAL_ERROR, "Invalid server response content", content); - } - else - { - LL_INFOS() << "setting home position" << LL_ENDL; - - LLViewerRegion *viewer_region = gAgent.getRegion(); - gAgent.setHomePosRegion( viewer_region->getHandle(), agent_pos ); - } -} - -void LLHomeLocationResponder::httpFailure() -{ - LL_WARNS() << dumpResponse() << LL_ENDL; -} diff --git a/indra/newview/llhomelocationresponder.h b/indra/newview/llhomelocationresponder.h deleted file mode 100755 index adc6c8cb58..0000000000 --- a/indra/newview/llhomelocationresponder.h +++ /dev/null @@ -1,44 +0,0 @@ -/** - * @file llhomelocationresponder.h - * @author Meadhbh Hamrick - * @brief Processes responses to the HomeLocation CapReq - * - * $LicenseInfo:firstyear=2008&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - - /* Macro Definitions */ -#ifndef LL_LLHOMELOCATIONRESPONDER_H -#define LL_LLHOMELOCATIONRESPONDER_H - -/* File Inclusions */ -#include "llhttpclient.h" - -/* Typedef, Enum, Class, Struct, etc. */ -class LLHomeLocationResponder : public LLHTTPClient::Responder -{ - LOG_CLASS(LLHomeLocationResponder); -private: - /* virtual */ void httpSuccess(); - /* virtual */ void httpFailure(); -}; - -#endif -- cgit v1.2.3 From be1fa962dffd9601d65b480ddd2bb09c70ad5f89 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 9 Jun 2015 15:36:10 -0700 Subject: Removed dead code, llsdmessage, llcapabilitylistener and the associated tests. --- indra/llmessage/CMakeLists.txt | 18 -- indra/llmessage/llsdmessage.cpp | 168 -------------- indra/llmessage/llsdmessage.h | 168 -------------- indra/llmessage/tests/llsdmessage_test.cpp | 130 ----------- indra/newview/CMakeLists.txt | 10 - indra/newview/llagent.cpp | 31 --- indra/newview/llcapabilitylistener.cpp | 202 ---------------- indra/newview/llcapabilitylistener.h | 131 ----------- indra/newview/llviewerinventory.cpp | 23 +- indra/newview/llviewerregion.cpp | 46 +--- indra/newview/llviewerregion.h | 5 - indra/newview/tests/llcapabilitylistener_test.cpp | 271 ---------------------- 12 files changed, 20 insertions(+), 1183 deletions(-) delete mode 100755 indra/llmessage/llsdmessage.cpp delete mode 100755 indra/llmessage/llsdmessage.h delete mode 100755 indra/llmessage/tests/llsdmessage_test.cpp delete mode 100755 indra/newview/llcapabilitylistener.cpp delete mode 100755 indra/newview/llcapabilitylistener.h delete mode 100755 indra/newview/tests/llcapabilitylistener_test.cpp (limited to 'indra') diff --git a/indra/llmessage/CMakeLists.txt b/indra/llmessage/CMakeLists.txt index abdb418224..57710049a5 100755 --- a/indra/llmessage/CMakeLists.txt +++ b/indra/llmessage/CMakeLists.txt @@ -75,7 +75,6 @@ set(llmessage_SOURCE_FILES llpumpio.cpp llsdappservices.cpp llsdhttpserver.cpp - llsdmessage.cpp llsdmessagebuilder.cpp llsdmessagereader.cpp llsdrpcclient.cpp @@ -176,7 +175,6 @@ set(llmessage_HEADER_FILES llregionhandle.h llsdappservices.h llsdhttpserver.h - llsdmessage.h llsdmessagebuilder.h llsdmessagereader.h llsdrpcclient.h @@ -261,22 +259,6 @@ if (LL_TESTS) ${GOOGLEMOCK_LIBRARIES} ) - LL_ADD_INTEGRATION_TEST( - llsdmessage - "llsdmessage.cpp" - "${test_libs}" - ${PYTHON_EXECUTABLE} - "${CMAKE_CURRENT_SOURCE_DIR}/tests/test_llsdmessage_peer.py" - ) - - LL_ADD_INTEGRATION_TEST( - llhttpclient - "llhttpclient.cpp" - "${test_libs}" - ${PYTHON_EXECUTABLE} - "${CMAKE_CURRENT_SOURCE_DIR}/tests/test_llsdmessage_peer.py" - ) - LL_ADD_INTEGRATION_TEST(llavatarnamecache "" "${test_libs}") LL_ADD_INTEGRATION_TEST(llhost "" "${test_libs}") LL_ADD_INTEGRATION_TEST(llpartdata "" "${test_libs}") diff --git a/indra/llmessage/llsdmessage.cpp b/indra/llmessage/llsdmessage.cpp deleted file mode 100755 index 61fcc5dd2f..0000000000 --- a/indra/llmessage/llsdmessage.cpp +++ /dev/null @@ -1,168 +0,0 @@ -/** - * @file llsdmessage.cpp - * @author Nat Goodspeed - * @date 2008-10-31 - * @brief Implementation for llsdmessage. - * - * $LicenseInfo:firstyear=2008&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#if LL_WINDOWS -#pragma warning (disable : 4675) // "resolved by ADL" -- just as I want! -#endif - -// Precompiled header -#include "linden_common.h" -// associated header -#include "llsdmessage.h" -// STL headers -// std headers -// external library headers -// other Linden headers -#include "llevents.h" -#include "llsdserialize.h" -#include "llhttpclient.h" -#include "llmessageconfig.h" -#include "llhost.h" -#include "message.h" -#include "llsdutil.h" - -// Declare a static LLSDMessage instance to ensure that we have a listener as -// soon as someone tries to post on our canonical LLEventPump name. -static LLSDMessage httpListener; - -LLSDMessage::LLSDMessage(): - // Instantiating our own local LLEventPump with a string name the - // constructor is NOT allowed to tweak is a way of ensuring Singleton - // semantics: attempting to instantiate a second LLSDMessage object would - // throw LLEventPump::DupPumpName. - mEventPump("LLHTTPClient") -{ - mEventPump.listen("self", boost::bind(&LLSDMessage::httpListener, this, _1)); -} - -bool LLSDMessage::httpListener(const LLSD& request) -{ - // Extract what we want from the request object. We do it all up front - // partly to document what we expect. - LLSD::String url(request["url"]); - LLSD payload(request["payload"]); - LLSD::String reply(request["reply"]); - LLSD::String error(request["error"]); - LLSD::Real timeout(request["timeout"]); - // If the LLSD doesn't even have a "url" key, we doubt it was intended for - // this listener. - if (url.empty()) - { - std::ostringstream out; - out << "request event without 'url' key to '" << mEventPump.getName() << "'"; - throw ArgError(out.str()); - } - // Establish default timeout. This test relies on LLSD::asReal() returning - // exactly 0.0 for an undef value. - if (! timeout) - { - timeout = HTTP_REQUEST_EXPIRY_SECS; - } - LLHTTPClient::post(url, payload, - new LLSDMessage::EventResponder(LLEventPumps::instance(), - request, - url, "POST", reply, error), - LLSD(), // headers - (F32)timeout); - return false; -} - -void LLSDMessage::EventResponder::httpSuccess() -{ - // If our caller passed an empty replyPump name, they're not - // listening: this is a fire-and-forget message. Don't bother posting - // to the pump whose name is "". - if (! mReplyPump.empty()) - { - LLSD response(getContent()); - mReqID.stamp(response); - mPumps.obtain(mReplyPump).post(response); - } - else // default success handling - { - LL_INFOS("LLSDMessage::EventResponder") - << "'" << mMessage << "' to '" << mTarget << "' succeeded" - << LL_ENDL; - } -} - -void LLSDMessage::EventResponder::httpFailure() -{ - // If our caller passed an empty errorPump name, they're not - // listening: "default error handling is acceptable." Only post to an - // explicit pump name. - if (! mErrorPump.empty()) - { - LLSD info(mReqID.makeResponse()); - info["target"] = mTarget; - info["message"] = mMessage; - info["status"] = getStatus(); - info["reason"] = getReason(); - info["content"] = getContent(); - mPumps.obtain(mErrorPump).post(info); - } - else // default error handling - { - // convention seems to be to use LL_INFOS(), but that seems a bit casual? - LL_WARNS("LLSDMessage::EventResponder") - << "'" << mMessage << "' to '" << mTarget - << "' failed " << dumpResponse() << LL_ENDL; - } -} - -LLSDMessage::ResponderAdapter::ResponderAdapter(LLHTTPClient::ResponderPtr responder, - const std::string& name): - mResponder(responder), - mReplyPump(name + ".reply", true), // tweak name for uniqueness - mErrorPump(name + ".error", true) -{ - mReplyPump.listen("self", boost::bind(&ResponderAdapter::listener, this, _1, true)); - mErrorPump.listen("self", boost::bind(&ResponderAdapter::listener, this, _1, false)); -} - -bool LLSDMessage::ResponderAdapter::listener(const LLSD& payload, bool success) -{ - if (success) - { - mResponder->successResult(payload); - } - else - { - mResponder->failureResult(payload["status"].asInteger(), payload["reason"], payload["content"]); - } - - /*---------------- MUST BE LAST STATEMENT BEFORE RETURN ----------------*/ - delete this; - // Destruction of mResponder will usually implicitly free its referent as well - /*------------------------- NOTHING AFTER THIS -------------------------*/ - return false; -} - -void LLSDMessage::link() -{ -} diff --git a/indra/llmessage/llsdmessage.h b/indra/llmessage/llsdmessage.h deleted file mode 100755 index e5d532d6a4..0000000000 --- a/indra/llmessage/llsdmessage.h +++ /dev/null @@ -1,168 +0,0 @@ -/** - * @file llsdmessage.h - * @author Nat Goodspeed - * @date 2008-10-30 - * @brief API intended to unify sending capability, UDP and TCP messages: - * https://wiki.lindenlab.com/wiki/Viewer:Messaging/Messaging_Notes - * - * $LicenseInfo:firstyear=2008&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#if ! defined(LL_LLSDMESSAGE_H) -#define LL_LLSDMESSAGE_H - -#include "llerror.h" // LOG_CLASS() -#include "llevents.h" // LLEventPumps -#include "llhttpclient.h" -#include -#include - -class LLSD; - -/** - * Class managing the messaging API described in - * https://wiki.lindenlab.com/wiki/Viewer:Messaging/Messaging_Notes - */ -class LLSDMessage -{ - LOG_CLASS(LLSDMessage); - -public: - LLSDMessage(); - - /// Exception if you specify arguments badly - struct ArgError: public std::runtime_error - { - ArgError(const std::string& what): - std::runtime_error(std::string("ArgError: ") + what) {} - }; - - /** - * The response idiom used by LLSDMessage -- LLEventPump names on which to - * post reply or error -- is designed for the case in which your - * reply/error handlers are methods on the same class as the method - * sending the message. Any state available to the sending method that - * must be visible to the reply/error methods can conveniently be stored - * on that class itself, if it's not already. - * - * The LLHTTPClient::Responder idiom requires a separate instance of a - * separate class so that it can dispatch to the code of interest by - * calling canonical virtual methods. Interesting state must be copied - * into that new object. - * - * With some trepidation, because existing response code is packaged in - * LLHTTPClient::Responder subclasses, we provide this adapter class - * for transitional purposes only. Instantiate a new heap - * ResponderAdapter with your new LLHTTPClient::ResponderPtr. Pass - * ResponderAdapter::getReplyName() and/or getErrorName() in your - * LLSDMessage (or LLViewerRegion::getCapAPI()) request event. The - * ResponderAdapter will call the appropriate Responder method, then - * @c delete itself. - */ - class ResponderAdapter - { - public: - /** - * Bind the new LLHTTPClient::Responder subclass instance. - * - * Passing the constructor a name other than the default is only - * interesting if you suspect some usage will lead to an exception or - * log message. - */ - ResponderAdapter(LLHTTPClient::ResponderPtr responder, - const std::string& name="ResponderAdapter"); - - /// EventPump name on which LLSDMessage should post reply event - std::string getReplyName() const { return mReplyPump.getName(); } - /// EventPump name on which LLSDMessage should post error event - std::string getErrorName() const { return mErrorPump.getName(); } - - private: - // We have two different LLEventStreams, though we route them both to - // the same listener, so that we can bind an extra flag identifying - // which case (reply or error) reached that listener. - bool listener(const LLSD&, bool success); - - LLHTTPClient::ResponderPtr mResponder; - LLEventStream mReplyPump, mErrorPump; - }; - - /** - * Force our implementation file to be linked with caller. The .cpp file - * contains a static instance of this class, which must be linked into the - * executable to support the canonical listener. But since the primary - * interface to that static instance is via a named LLEventPump rather - * than by direct reference, the linker doesn't necessarily perceive the - * necessity to bring in the translation unit. Referencing this dummy - * method forces the issue. - */ - static void link(); - -private: - friend class LLCapabilityListener; - /// Responder used for internal purposes by LLSDMessage and - /// LLCapabilityListener. Others should use higher-level APIs. - class EventResponder: public LLHTTPClient::Responder - { - LOG_CLASS(EventResponder); - public: - /** - * LLHTTPClient::Responder that dispatches via named LLEventPump instances. - * We bind LLEventPumps, even though it's an LLSingleton, for testability. - * We bind the string names of the desired LLEventPump instances rather - * than actually obtain()ing them so we only obtain() the one we're going - * to use. If the caller doesn't bother to listen() on it, the other pump - * may never materialize at all. - * @a target and @a message are only to clarify error processing. - * For a capability message, @a target should be the region description, - * @a message should be the capability name. - * For a service with a visible URL, pass the URL as @a target and the HTTP verb - * (e.g. "POST") as @a message. - */ - EventResponder(LLEventPumps& pumps, - const LLSD& request, - const std::string& target, const std::string& message, - const std::string& replyPump, const std::string& errorPump): - mPumps(pumps), - mReqID(request), - mTarget(target), - mMessage(message), - mReplyPump(replyPump), - mErrorPump(errorPump) - {} - - protected: - virtual void httpSuccess(); - virtual void httpFailure(); - - private: - LLEventPumps& mPumps; - LLReqID mReqID; - const std::string mTarget, mMessage, mReplyPump, mErrorPump; - }; - -private: - bool httpListener(const LLSD&); - LLEventStream mEventPump; -}; - -#endif /* ! defined(LL_LLSDMESSAGE_H) */ diff --git a/indra/llmessage/tests/llsdmessage_test.cpp b/indra/llmessage/tests/llsdmessage_test.cpp deleted file mode 100755 index 44b024a83f..0000000000 --- a/indra/llmessage/tests/llsdmessage_test.cpp +++ /dev/null @@ -1,130 +0,0 @@ -/** - * @file llsdmessage_test.cpp - * @author Nat Goodspeed - * @date 2008-12-22 - * @brief Test of llsdmessage.h - * - * $LicenseInfo:firstyear=2008&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#if LL_WINDOWS -#pragma warning (disable : 4675) // "resolved by ADL" -- just as I want! -#endif - -// Precompiled header -#include "linden_common.h" -// associated header -#include "llsdmessage.h" -// STL headers -#include -// std headers -#include -#include -// external library headers -// other Linden headers -#include "../test/lltut.h" -#include "../test/catch_and_store_what_in.h" -#include "llsdserialize.h" -#include "llevents.h" -#include "stringize.h" -#include "llhost.h" -#include "tests/networkio.h" -#include "tests/commtest.h" - -/***************************************************************************** -* TUT -*****************************************************************************/ -namespace tut -{ - struct llsdmessage_data: public commtest_data - { - LLEventPump& httpPump; - - llsdmessage_data(): - httpPump(pumps.obtain("LLHTTPClient")) - { - LLCurl::initClass(); - LLSDMessage::link(); - } - }; - typedef test_group llsdmessage_group; - typedef llsdmessage_group::object llsdmessage_object; - llsdmessage_group llsdmgr("llsdmessage"); - - template<> template<> - void llsdmessage_object::test<1>() - { - std::string threw; - // This should fail... - try - { - LLSDMessage localListener; - } - CATCH_AND_STORE_WHAT_IN(threw, LLEventPump::DupPumpName) - ensure("second LLSDMessage should throw", ! threw.empty()); - } - - template<> template<> - void llsdmessage_object::test<2>() - { - LLSD request, body; - body["data"] = "yes"; - request["payload"] = body; - request["reply"] = replyPump.getName(); - request["error"] = errorPump.getName(); - bool threw = false; - try - { - httpPump.post(request); - } - catch (const LLSDMessage::ArgError&) - { - threw = true; - } - ensure("missing URL", threw); - } - - template<> template<> - void llsdmessage_object::test<3>() - { - LLSD request, body; - body["data"] = "yes"; - request["url"] = server + "got-message"; - request["payload"] = body; - request["reply"] = replyPump.getName(); - request["error"] = errorPump.getName(); - httpPump.post(request); - ensure("got response", netio.pump()); - ensure("success response", success); - ensure_equals(result["reply"].asString(), "success"); - - body["status"] = 499; - body["reason"] = "custom error message"; - request["url"] = server + "fail"; - request["payload"] = body; - httpPump.post(request); - ensure("got response", netio.pump()); - ensure("failure response", ! success); - ensure_equals(result["status"].asInteger(), body["status"].asInteger()); - ensure_equals(result["reason"].asString(), body["reason"].asString()); - } -} // namespace tut diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index bebc82e847..9949656fcc 100755 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -142,7 +142,6 @@ set(viewer_SOURCE_FILES llbuycurrencyhtml.cpp llcallbacklist.cpp llcallingcard.cpp - llcapabilitylistener.cpp llcaphttpsender.cpp llchannelmanager.cpp llchatbar.cpp @@ -742,7 +741,6 @@ set(viewer_HEADER_FILES llbuycurrencyhtml.h llcallbacklist.h llcallingcard.h - llcapabilitylistener.h llcapabilityprovider.h llcaphttpsender.h llchannelmanager.h @@ -2298,7 +2296,6 @@ if (LL_TESTS) LL_ADD_PROJECT_UNIT_TESTS(${VIEWER_BINARY_NAME} "${viewer_TEST_SOURCE_FILES}") #set(TEST_DEBUG on) - set(test_sources llcapabilitylistener.cpp) ################################################## # DISABLING PRECOMPILED HEADERS USAGE FOR TESTS ################################################## @@ -2314,13 +2311,6 @@ if (LL_TESTS) ${GOOGLEMOCK_LIBRARIES} ) - LL_ADD_INTEGRATION_TEST(llcapabilitylistener - "${test_sources}" - "${test_libs}" - ${PYTHON_EXECUTABLE} - "${CMAKE_SOURCE_DIR}/llmessage/tests/test_llsdmessage_peer.py" - ) - if (LINUX) # llcommon uses `clock_gettime' which is provided by librt on linux. set(LIBRT_LIBRARY diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index 230447b256..2060065c75 100755 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -38,7 +38,6 @@ #include "llappearancemgr.h" #include "llanimationstates.h" #include "llcallingcard.h" -#include "llcapabilitylistener.h" #include "llchannelmanager.h" #include "llchicletbar.h" #include "llconsole.h" @@ -62,7 +61,6 @@ #include "llpaneltopinfobar.h" #include "llparcel.h" #include "llrendersphere.h" -#include "llsdmessage.h" #include "llsdutil.h" #include "llsky.h" #include "llslurl.h" @@ -2388,35 +2386,6 @@ void LLAgent::setStartPositionSuccess(const LLSD &result) } } -#if 1 -struct HomeLocationMapper: public LLCapabilityListener::CapabilityMapper -{ - // No reply message expected - HomeLocationMapper(): LLCapabilityListener::CapabilityMapper("HomeLocation") {} - virtual void buildMessage(LLMessageSystem* msg, - const LLUUID& agentID, - const LLUUID& sessionID, - const std::string& capabilityName, - const LLSD& payload) const - { - msg->newMessageFast(_PREHASH_SetStartLocationRequest); - msg->nextBlockFast( _PREHASH_AgentData); - msg->addUUIDFast(_PREHASH_AgentID, agentID); - msg->addUUIDFast(_PREHASH_SessionID, sessionID); - msg->nextBlockFast( _PREHASH_StartLocationData); - // corrected by sim - msg->addStringFast(_PREHASH_SimName, ""); - msg->addU32Fast(_PREHASH_LocationID, payload["HomeLocation"]["LocationId"].asInteger()); - msg->addVector3Fast(_PREHASH_LocationPos, - ll_vector3_from_sdmap(payload["HomeLocation"]["LocationPos"])); - msg->addVector3Fast(_PREHASH_LocationLookAt, - ll_vector3_from_sdmap(payload["HomeLocation"]["LocationLookAt"])); - } -}; -// Need an instance of this class so it will self-register -static HomeLocationMapper homeLocationMapper; -#endif - void LLAgent::requestStopMotion( LLMotion* motion ) { // Notify all avatars that a motion has stopped. diff --git a/indra/newview/llcapabilitylistener.cpp b/indra/newview/llcapabilitylistener.cpp deleted file mode 100755 index ef9b910ae5..0000000000 --- a/indra/newview/llcapabilitylistener.cpp +++ /dev/null @@ -1,202 +0,0 @@ -/** - * @file llcapabilitylistener.cpp - * @author Nat Goodspeed - * @date 2009-01-07 - * @brief Implementation for llcapabilitylistener. - * - * $LicenseInfo:firstyear=2009&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -// Precompiled header -#include "llviewerprecompiledheaders.h" -// associated header -#include "llcapabilitylistener.h" -// STL headers -#include -// std headers -// external library headers -#include -// other Linden headers -#include "stringize.h" -#include "llcapabilityprovider.h" -#include "message.h" - -class LLCapabilityListener::CapabilityMappers: public LLSingleton -{ -public: - void registerMapper(const LLCapabilityListener::CapabilityMapper*); - void unregisterMapper(const LLCapabilityListener::CapabilityMapper*); - const LLCapabilityListener::CapabilityMapper* find(const std::string& cap) const; - - struct DupCapMapper: public std::runtime_error - { - DupCapMapper(const std::string& what): - std::runtime_error(std::string("DupCapMapper: ") + what) - {} - }; - -private: - friend class LLSingleton; - CapabilityMappers(); - - typedef std::map CapabilityMap; - CapabilityMap mMap; -}; - -LLCapabilityListener::LLCapabilityListener(const std::string& name, - LLMessageSystem* messageSystem, - const LLCapabilityProvider& provider, - const LLUUID& agentID, - const LLUUID& sessionID): - mEventPump(name), - mMessageSystem(messageSystem), - mProvider(provider), - mAgentID(agentID), - mSessionID(sessionID) -{ - mEventPump.listen("self", boost::bind(&LLCapabilityListener::capListener, this, _1)); -} - -bool LLCapabilityListener::capListener(const LLSD& request) -{ - // Extract what we want from the request object. We do it all up front - // partly to document what we expect. - LLSD::String cap(request["message"]); - LLSD payload(request["payload"]); - LLSD::String reply(request["reply"]); - LLSD::String error(request["error"]); - LLSD::Real timeout(request["timeout"]); - // If the LLSD doesn't even have a "message" key, we doubt it was intended - // for this listener. - if (cap.empty()) - { - LL_ERRS("capListener") << "capability request event without 'message' key to '" - << getCapAPI().getName() - << "' on region\n" << mProvider.getDescription() - << LL_ENDL; - return false; // in case fatal-error function isn't - } - // Establish default timeout. This test relies on LLSD::asReal() returning - // exactly 0.0 for an undef value. - if (! timeout) - { - timeout = HTTP_REQUEST_EXPIRY_SECS; - } - // Look up the url for the requested capability name. - std::string url = mProvider.getCapability(cap); - if (! url.empty()) - { - // This capability is supported by the region to which we're talking. - LLHTTPClient::post(url, payload, - new LLSDMessage::EventResponder(LLEventPumps::instance(), - request, - mProvider.getDescription(), - cap, reply, error), - LLSD(), // headers - timeout); - } - else - { - // Capability not supported -- do we have a registered mapper? - const CapabilityMapper* mapper = CapabilityMappers::instance().find(cap); - if (! mapper) // capability neither supported nor mapped - { - LL_ERRS("capListener") << "unsupported capability '" << cap << "' request to '" - << getCapAPI().getName() << "' on region\n" - << mProvider.getDescription() - << LL_ENDL; - } - else if (! mapper->getReplyName().empty()) // mapper expects reply support - { - LL_ERRS("capListener") << "Mapper for capability '" << cap - << "' requires unimplemented support for reply message '" - << mapper->getReplyName() - << "' on '" << getCapAPI().getName() << "' on region\n" - << mProvider.getDescription() - << LL_ENDL; - } - else - { - LL_INFOS("capListener") << "fallback invoked for capability '" << cap - << "' request to '" << getCapAPI().getName() - << "' on region\n" << mProvider.getDescription() - << LL_ENDL; - mapper->buildMessage(mMessageSystem, mAgentID, mSessionID, cap, payload); - mMessageSystem->sendReliable(mProvider.getHost()); - } - } - return false; -} - -LLCapabilityListener::CapabilityMapper::CapabilityMapper(const std::string& cap, const std::string& reply): - mCapName(cap), - mReplyName(reply) -{ - LLCapabilityListener::CapabilityMappers::instance().registerMapper(this); -} - -LLCapabilityListener::CapabilityMapper::~CapabilityMapper() -{ - LLCapabilityListener::CapabilityMappers::instance().unregisterMapper(this); -} - -LLSD LLCapabilityListener::CapabilityMapper::readResponse(LLMessageSystem* messageSystem) const -{ - return LLSD(); -} - -LLCapabilityListener::CapabilityMappers::CapabilityMappers() {} - -void LLCapabilityListener::CapabilityMappers::registerMapper(const LLCapabilityListener::CapabilityMapper* mapper) -{ - // Try to insert a new map entry by which we can look up the passed mapper - // instance. - std::pair inserted = - mMap.insert(CapabilityMap::value_type(mapper->getCapName(), mapper)); - // If we already have a mapper for that name, insert() merely located the - // existing iterator and returned false. It is a coding error to try to - // register more than one mapper for the same capability name. - if (! inserted.second) - { - throw DupCapMapper(std::string("Duplicate capability name ") + mapper->getCapName()); - } -} - -void LLCapabilityListener::CapabilityMappers::unregisterMapper(const LLCapabilityListener::CapabilityMapper* mapper) -{ - CapabilityMap::iterator found = mMap.find(mapper->getCapName()); - if (found != mMap.end()) - { - mMap.erase(found); - } -} - -const LLCapabilityListener::CapabilityMapper* -LLCapabilityListener::CapabilityMappers::find(const std::string& cap) const -{ - CapabilityMap::const_iterator found = mMap.find(cap); - if (found != mMap.end()) - { - return found->second; - } - return NULL; -} diff --git a/indra/newview/llcapabilitylistener.h b/indra/newview/llcapabilitylistener.h deleted file mode 100755 index e7535013e7..0000000000 --- a/indra/newview/llcapabilitylistener.h +++ /dev/null @@ -1,131 +0,0 @@ -/** - * @file llcapabilitylistener.h - * @author Nat Goodspeed - * @date 2009-01-07 - * @brief Provide an event-based API for capability requests - * - * $LicenseInfo:firstyear=2009&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#if ! defined(LL_LLCAPABILITYLISTENER_H) -#define LL_LLCAPABILITYLISTENER_H - -#include "llevents.h" // LLEventPump -#include "llsdmessage.h" // LLSDMessage::ArgError -#include "llerror.h" // LOG_CLASS() - -class LLCapabilityProvider; -class LLMessageSystem; -class LLSD; - -class LLCapabilityListener -{ - LOG_CLASS(LLCapabilityListener); -public: - LLCapabilityListener(const std::string& name, LLMessageSystem* messageSystem, - const LLCapabilityProvider& provider, - const LLUUID& agentID, const LLUUID& sessionID); - - /// Capability-request exception - typedef LLSDMessage::ArgError ArgError; - /// Get LLEventPump on which we listen for capability requests - /// (https://wiki.lindenlab.com/wiki/Viewer:Messaging/Messaging_Notes#Capabilities) - LLEventPump& getCapAPI() { return mEventPump; } - - /** - * Base class for mapping an as-yet-undeployed capability name to a (pair - * of) LLMessageSystem message(s). To map a capability name to such - * messages, derive a subclass of CapabilityMapper and declare a static - * instance in a translation unit known to be loaded. The mapping is not - * region-specific. If an LLViewerRegion's capListener() receives a - * request for a supported capability, it will use the capability's URL. - * If not, it will look for an applicable CapabilityMapper subclass - * instance. - */ - class CapabilityMapper - { - public: - /** - * Base-class constructor. Typically your subclass constructor will - * pass these parameters as literals. - * @param cap the capability name handled by this (subclass) instance - * @param reply the name of the response LLMessageSystem message. Omit - * if the LLMessageSystem message you intend to send doesn't prompt a - * reply message, or if you already handle that message in some other - * way. - */ - CapabilityMapper(const std::string& cap, const std::string& reply = ""); - virtual ~CapabilityMapper(); - /// query the capability name - std::string getCapName() const { return mCapName; } - /// query the reply message name - std::string getReplyName() const { return mReplyName; } - /** - * Override this method to build the LLMessageSystem message we should - * send instead of the requested capability message. DO NOT send that - * message: that will be handled by the caller. - */ - virtual void buildMessage(LLMessageSystem* messageSystem, - const LLUUID& agentID, - const LLUUID& sessionID, - const std::string& capabilityName, - const LLSD& payload) const = 0; - /** - * Override this method if you pass a non-empty @a reply - * LLMessageSystem message name to the constructor: that is, if you - * expect to receive an LLMessageSystem message in response to the - * message you constructed in buildMessage(). If you don't pass a @a - * reply message name, you need not override this method as it won't - * be called. - * - * Using LLMessageSystem message-reading operations, your - * readResponse() override should construct and return an LLSD object - * of the form you expect to receive from the real implementation of - * the capability you intend to invoke, when it finally goes live. - */ - virtual LLSD readResponse(LLMessageSystem* messageSystem) const; - - private: - const std::string mCapName; - const std::string mReplyName; - }; - -private: - /// Bind the LLCapabilityProvider passed to our ctor - const LLCapabilityProvider& mProvider; - - /// Post an event to this LLEventPump to invoke a capability message on - /// the bound LLCapabilityProvider's server - /// (https://wiki.lindenlab.com/wiki/Viewer:Messaging/Messaging_Notes#Capabilities) - LLEventStream mEventPump; - - LLMessageSystem* mMessageSystem; - LLUUID mAgentID, mSessionID; - - /// listener to process capability requests - bool capListener(const LLSD&); - - /// helper class for capListener() - class CapabilityMappers; -}; - -#endif /* ! defined(LL_LLCAPABILITYLISTENER_H) */ diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp index d112118082..9a20dea2aa 100755 --- a/indra/newview/llviewerinventory.cpp +++ b/indra/newview/llviewerinventory.cpp @@ -1750,27 +1750,20 @@ void copy_inventory_from_notecard(const LLUUID& destination_id, return; } - // check capability to prevent a crash while LL_ERRS in LLCapabilityListener::capListener. See EXT-8459. - std::string url = viewer_region->getCapability("CopyInventoryFromNotecard"); - if (url.empty()) - { - LL_WARNS(LOG_NOTECARD) << "There is no 'CopyInventoryFromNotecard' capability" - << " for region: " << viewer_region->getName() - << LL_ENDL; - return; - } - - LLSD request, body; + LLSD body; body["notecard-id"] = notecard_inv_id; body["object-id"] = object_id; body["item-id"] = src->getUUID(); body["folder-id"] = destination_id; body["callback-id"] = (LLSD::Integer)callback_id; - request["message"] = "CopyInventoryFromNotecard"; - request["payload"] = body; - - viewer_region->getCapAPI().post(request); + /// *TODO: RIDER: This posts the request under the agents policy. + /// When I convert the inventory over this call should be moved under that + /// policy as well. + if (!gAgent.requestPostCapability("CopyInventoryFromNotecard", body)) + { + LL_WARNS() << "SIM does not have the capability to copy from notecard." << LL_ENDL; + } } void create_new_item(const std::string& name, diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index ddf64aa08b..5c25e03e09 100755 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -48,7 +48,6 @@ #include "llavatarrenderinfoaccountant.h" #include "llcallingcard.h" #include "llcaphttpsender.h" -#include "llcapabilitylistener.h" #include "llcommandhandler.h" #include "lldir.h" #include "lleventpoll.h" @@ -151,29 +150,18 @@ LLRegionHandler gRegionHandler; class LLViewerRegionImpl { public: - LLViewerRegionImpl(LLViewerRegion * region, LLHost const & host) - : mHost(host), - mCompositionp(NULL), - mEventPoll(NULL), - mSeedCapMaxAttempts(MAX_CAP_REQUEST_ATTEMPTS), - mSeedCapMaxAttemptsBeforeLogin(MAX_SEED_CAP_ATTEMPTS_BEFORE_LOGIN), - mSeedCapAttempts(0), - mHttpResponderID(0), - mLastCameraUpdate(0), - mLastCameraOrigin(), - mVOCachePartition(NULL), - mLandp(NULL), - // I'd prefer to set the LLCapabilityListener name to match the region - // name -- it's disappointing that's not available at construction time. - // We could instead store an LLCapabilityListener*, making - // setRegionNameAndZone() replace the instance. Would that pose - // consistency problems? Can we even request a capability before calling - // setRegionNameAndZone()? - // For testability -- the new Michael Feathers paradigm -- - // LLCapabilityListener binds all the globals it expects to need at - // construction time. - mCapabilityListener(host.getString(), gMessageSystem, *region, - gAgent.getID(), gAgent.getSessionID()) + LLViewerRegionImpl(LLViewerRegion * region, LLHost const & host): + mHost(host), + mCompositionp(NULL), + mEventPoll(NULL), + mSeedCapMaxAttempts(MAX_CAP_REQUEST_ATTEMPTS), + mSeedCapMaxAttemptsBeforeLogin(MAX_SEED_CAP_ATTEMPTS_BEFORE_LOGIN), + mSeedCapAttempts(0), + mHttpResponderID(0), + mLastCameraUpdate(0), + mLastCameraOrigin(), + mVOCachePartition(NULL), + mLandp(NULL) {} void buildCapabilityNames(LLSD& capabilityNames); @@ -225,11 +213,6 @@ public: S32 mHttpResponderID; - /// Post an event to this LLCapabilityListener to invoke a capability message on - /// this LLViewerRegion's server - /// (https://wiki.lindenlab.com/wiki/Viewer:Messaging/Messaging_Notes#Capabilities) - LLCapabilityListener mCapabilityListener; - //spatial partitions for objects in this region std::vector mObjectPartition; @@ -638,11 +621,6 @@ LLViewerRegion::~LLViewerRegion() mImpl = NULL; } -LLEventPump& LLViewerRegion::getCapAPI() const -{ - return mImpl->mCapabilityListener.getCapAPI(); -} - /*virtual*/ const LLHost& LLViewerRegion::getHost() const { diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h index c6df155cb5..8c4966369c 100755 --- a/indra/newview/llviewerregion.h +++ b/indra/newview/llviewerregion.h @@ -61,7 +61,6 @@ class LLVOCache; class LLVOCacheEntry; class LLSpatialPartition; class LLEventPump; -class LLCapabilityListener; class LLDataPacker; class LLDataPackerBinaryBuffer; class LLHost; @@ -269,10 +268,6 @@ public: static bool isSpecialCapabilityName(const std::string &name); void logActiveCapabilities() const; - /// Get LLEventPump on which we listen for capability requests - /// (https://wiki.lindenlab.com/wiki/Viewer:Messaging/Messaging_Notes#Capabilities) - LLEventPump& getCapAPI() const; - /// implements LLCapabilityProvider /*virtual*/ const LLHost& getHost() const; const U64 &getHandle() const { return mHandle; } diff --git a/indra/newview/tests/llcapabilitylistener_test.cpp b/indra/newview/tests/llcapabilitylistener_test.cpp deleted file mode 100755 index bde991a01e..0000000000 --- a/indra/newview/tests/llcapabilitylistener_test.cpp +++ /dev/null @@ -1,271 +0,0 @@ -/** - * @file llcapabilitylistener_test.cpp - * @author Nat Goodspeed - * @date 2008-12-31 - * @brief Test for llcapabilitylistener.cpp. - * - * $LicenseInfo:firstyear=2008&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -// Precompiled header -#include "../llviewerprecompiledheaders.h" -// Own header -#include "../llcapabilitylistener.h" -// STL headers -#include -#include -#include -// std headers -// external library headers -#include "boost/bind.hpp" -// other Linden headers -#include "../test/lltut.h" -#include "../llcapabilityprovider.h" -#include "lluuid.h" -#include "tests/networkio.h" -#include "tests/commtest.h" -#include "tests/wrapllerrs.h" -#include "message.h" -#include "stringize.h" - -#if defined(LL_WINDOWS) -#pragma warning(disable: 4355) // using 'this' in base-class ctor initializer expr -#endif - -/***************************************************************************** -* TestCapabilityProvider -*****************************************************************************/ -struct TestCapabilityProvider: public LLCapabilityProvider -{ - TestCapabilityProvider(const LLHost& host): - mHost(host) - {} - - std::string getCapability(const std::string& cap) const - { - CapMap::const_iterator found = mCaps.find(cap); - if (found != mCaps.end()) - return found->second; - // normal LLViewerRegion lookup failure mode - return ""; - } - void setCapability(const std::string& cap, const std::string& url) - { - mCaps[cap] = url; - } - const LLHost& getHost() const { return mHost; } - std::string getDescription() const { return "TestCapabilityProvider"; } - - LLHost mHost; - typedef std::map CapMap; - CapMap mCaps; -}; - -/***************************************************************************** -* Dummy LLMessageSystem methods -*****************************************************************************/ -/*==========================================================================*| -// This doesn't work because we're already linking in llmessage.a, and we get -// duplicate-symbol errors from the linker. Perhaps if I wanted to go through -// the exercise of providing dummy versions of every single symbol defined in -// message.o -- maybe some day. -typedef std::vector< std::pair > StringPairVector; -StringPairVector call_history; - -S32 LLMessageSystem::sendReliable(const LLHost& host) -{ - call_history.push_back(StringPairVector::value_type("sendReliable", stringize(host))); - return 0; -} -|*==========================================================================*/ - -/***************************************************************************** -* TUT -*****************************************************************************/ -namespace tut -{ - struct llcapears_data: public commtest_data - { - TestCapabilityProvider provider; - LLCapabilityListener regionListener; - LLEventPump& regionPump; - - llcapears_data(): - provider(host), - regionListener("testCapabilityListener", NULL, provider, LLUUID(), LLUUID()), - regionPump(regionListener.getCapAPI()) - { - LLCurl::initClass(); - provider.setCapability("good", server + "capability-test"); - provider.setCapability("fail", server + "fail"); - } - }; - typedef test_group llcapears_group; - typedef llcapears_group::object llcapears_object; - llcapears_group llsdmgr("llcapabilitylistener"); - - template<> template<> - void llcapears_object::test<1>() - { - LLSD request, body; - body["data"] = "yes"; - request["payload"] = body; - request["reply"] = replyPump.getName(); - request["error"] = errorPump.getName(); - std::string threw; - try - { - WrapLLErrs capture; - regionPump.post(request); - } - catch (const WrapLLErrs::FatalException& e) - { - threw = e.what(); - } - ensure_contains("missing capability name", threw, "without 'message' key"); - } - - template<> template<> - void llcapears_object::test<2>() - { - LLSD request, body; - body["data"] = "yes"; - request["message"] = "good"; - request["payload"] = body; - request["reply"] = replyPump.getName(); - request["error"] = errorPump.getName(); - regionPump.post(request); - ensure("got response", netio.pump()); - ensure("success response", success); - ensure_equals(result["reply"].asString(), "success"); - - body["status"] = 499; - body["reason"] = "custom error message"; - request["message"] = "fail"; - request["payload"] = body; - regionPump.post(request); - ensure("got response", netio.pump()); - ensure("failure response", ! success); - ensure_equals(result["status"].asInteger(), body["status"].asInteger()); - ensure_equals(result["reason"].asString(), body["reason"].asString()); - } - - template<> template<> - void llcapears_object::test<3>() - { - LLSD request, body; - body["data"] = "yes"; - request["message"] = "unknown"; - request["payload"] = body; - request["reply"] = replyPump.getName(); - request["error"] = errorPump.getName(); - std::string threw; - try - { - WrapLLErrs capture; - regionPump.post(request); - } - catch (const WrapLLErrs::FatalException& e) - { - threw = e.what(); - } - ensure_contains("bad capability name", threw, "unsupported capability"); - } - - struct TestMapper: public LLCapabilityListener::CapabilityMapper - { - // Instantiator gets to specify whether mapper expects a reply. - // I'd really like to be able to test CapabilityMapper::buildMessage() - // functionality, too, but -- even though LLCapabilityListener accepts - // the LLMessageSystem* that it passes to CapabilityMapper -- - // LLMessageSystem::sendReliable(const LLHost&) isn't virtual, so it's - // not helpful to pass a subclass instance. I suspect that making any - // LLMessageSystem methods virtual would provoke howls of outrage, - // given how heavily it's used. Nor can I just provide a local - // definition of LLMessageSystem::sendReliable(const LLHost&) because - // we're already linking in the rest of message.o via llmessage.a, and - // that produces duplicate-symbol link errors. - TestMapper(const std::string& replyMessage = std::string()): - LLCapabilityListener::CapabilityMapper("test", replyMessage) - {} - virtual void buildMessage(LLMessageSystem* msg, - const LLUUID& agentID, - const LLUUID& sessionID, - const std::string& capabilityName, - const LLSD& payload) const - { - msg->newMessageFast(_PREHASH_SetStartLocationRequest); - msg->nextBlockFast( _PREHASH_AgentData); - msg->addUUIDFast(_PREHASH_AgentID, agentID); - msg->addUUIDFast(_PREHASH_SessionID, sessionID); - msg->nextBlockFast( _PREHASH_StartLocationData); - // corrected by sim - msg->addStringFast(_PREHASH_SimName, ""); - msg->addU32Fast(_PREHASH_LocationID, payload["HomeLocation"]["LocationId"].asInteger()); -/*==========================================================================*| - msg->addVector3Fast(_PREHASH_LocationPos, - ll_vector3_from_sdmap(payload["HomeLocation"]["LocationPos"])); - msg->addVector3Fast(_PREHASH_LocationLookAt, - ll_vector3_from_sdmap(payload["HomeLocation"]["LocationLookAt"])); -|*==========================================================================*/ - } - }; - - template<> template<> - void llcapears_object::test<4>() - { - TestMapper testMapper("WantReply"); - LLSD request, body; - body["data"] = "yes"; - request["message"] = "test"; - request["payload"] = body; - request["reply"] = replyPump.getName(); - request["error"] = errorPump.getName(); - std::string threw; - try - { - WrapLLErrs capture; - regionPump.post(request); - } - catch (const WrapLLErrs::FatalException& e) - { - threw = e.what(); - } - ensure_contains("capability mapper wants reply", threw, "unimplemented support for reply message"); - } - - template<> template<> - void llcapears_object::test<5>() - { - TestMapper testMapper; - std::string threw; - try - { - TestMapper testMapper2; - } - catch (const std::runtime_error& e) - { - threw = e.what(); - } - ensure_contains("no dup cap mapper", threw, "DupCapMapper"); - } -} -- cgit v1.2.3 From 4a4470af3210153e0909eb75d51de461d14a3128 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 17 Jun 2015 13:53:28 -0700 Subject: Coding policy fixes --- indra/linux_crash_logger/CMakeLists.txt | 10 +++++----- indra/llcommon/CMakeLists.txt | 4 ++-- indra/llcrashlogger/CMakeLists.txt | 2 +- indra/llmessage/CMakeLists.txt | 4 ++-- indra/llmessage/llhttpsdhandler.h | 2 +- indra/mac_crash_logger/CMakeLists.txt | 8 ++++---- indra/newview/CMakeLists.txt | 8 ++++---- indra/newview/llfloatermodeluploadbase.cpp | 2 +- indra/viewer_components/updater/CMakeLists.txt | 4 ++-- indra/win_crash_logger/CMakeLists.txt | 4 ++-- 10 files changed, 24 insertions(+), 24 deletions(-) (limited to 'indra') diff --git a/indra/linux_crash_logger/CMakeLists.txt b/indra/linux_crash_logger/CMakeLists.txt index 44dddd0034..81d14c695b 100755 --- a/indra/linux_crash_logger/CMakeLists.txt +++ b/indra/linux_crash_logger/CMakeLists.txt @@ -17,7 +17,7 @@ include(FreeType) include(Boost) include_directories( - ${LLCOREHTTP_INCLUDE_DIRS} + ${LLCOREHTTP_INCLUDE_DIRS} ${LLCOMMON_INCLUDE_DIRS} ${LLCRASHLOGGER_INCLUDE_DIRS} ${LLMATH_INCLUDE_DIRS} @@ -67,14 +67,14 @@ target_link_libraries(linux-crash-logger ${LLMESSAGE_LIBRARIES} ${LLVFS_LIBRARIES} ${LLMATH_LIBRARIES} - ${LLCOREHTTP_LIBRARIES} + ${LLCOREHTTP_LIBRARIES} ${LLCOMMON_LIBRARIES} - ${BOOST_CONTEXT_LIBRARY} - ${BOOST_COROUTINE_LIBRARY} + ${BOOST_CONTEXT_LIBRARY} + ${BOOST_COROUTINE_LIBRARY} ${UI_LIBRARIES} ${DB_LIBRARIES} ${FREETYPE_LIBRARIES} - ${LIBRT_LIBRARY} + ${LIBRT_LIBRARY} ) add_custom_target(linux-crash-logger-target ALL diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt index 9086691375..9757679ce1 100755 --- a/indra/llcommon/CMakeLists.txt +++ b/indra/llcommon/CMakeLists.txt @@ -87,7 +87,7 @@ set(llcommon_SOURCE_FILES llrefcount.cpp llrun.cpp llsd.cpp - llsdjson.cpp + llsdjson.cpp llsdparam.cpp llsdserialize.cpp llsdserialize_xml.cpp @@ -196,7 +196,7 @@ set(llcommon_HEADER_FILES llrefcount.h llsafehandle.h llsd.h - llsdjson.h + llsdjson.h llsdparam.h llsdserialize.h llsdserialize_xml.h diff --git a/indra/llcrashlogger/CMakeLists.txt b/indra/llcrashlogger/CMakeLists.txt index c41e61c497..da23b46b7b 100755 --- a/indra/llcrashlogger/CMakeLists.txt +++ b/indra/llcrashlogger/CMakeLists.txt @@ -11,7 +11,7 @@ include(LLVFS) include(LLXML) include_directories( - ${LLCOREHTTP_INCLUDE_DIRS} + ${LLCOREHTTP_INCLUDE_DIRS} ${LLCOMMON_INCLUDE_DIRS} ${LLMATH_INCLUDE_DIRS} ${LLMESSAGE_INCLUDE_DIRS} diff --git a/indra/llmessage/CMakeLists.txt b/indra/llmessage/CMakeLists.txt index 57710049a5..faab1aec92 100755 --- a/indra/llmessage/CMakeLists.txt +++ b/indra/llmessage/CMakeLists.txt @@ -50,7 +50,7 @@ set(llmessage_SOURCE_FILES llhttpclient.cpp llhttpconstants.cpp llhttpnode.cpp - llhttpsdhandler.cpp + llhttpsdhandler.cpp llhttpsender.cpp llinstantmessage.cpp lliobuffer.cpp @@ -144,7 +144,7 @@ set(llmessage_HEADER_FILES llhttpconstants.h llhttpnode.h llhttpnodeadapter.h - llhttpsdhandler.h + llhttpsdhandler.h llhttpsender.h llinstantmessage.h llinvite.h diff --git a/indra/llmessage/llhttpsdhandler.h b/indra/llmessage/llhttpsdhandler.h index 814d1c22b5..3b81dc66b9 100644 --- a/indra/llmessage/llhttpsdhandler.h +++ b/indra/llmessage/llhttpsdhandler.h @@ -69,4 +69,4 @@ protected: private: std::string mName; }; -#endif \ No newline at end of file +#endif diff --git a/indra/mac_crash_logger/CMakeLists.txt b/indra/mac_crash_logger/CMakeLists.txt index ce20284b59..ab20388261 100755 --- a/indra/mac_crash_logger/CMakeLists.txt +++ b/indra/mac_crash_logger/CMakeLists.txt @@ -15,7 +15,7 @@ include(LLSharedLibs) include(Boost) include_directories( - ${LLCOREHTTP_INCLUDE_DIRS} + ${LLCOREHTTP_INCLUDE_DIRS} ${LLCOMMON_INCLUDE_DIRS} ${LLCRASHLOGGER_INCLUDE_DIRS} ${LLMATH_INCLUDE_DIRS} @@ -74,10 +74,10 @@ target_link_libraries(mac-crash-logger ${LLMESSAGE_LIBRARIES} ${LLVFS_LIBRARIES} ${LLMATH_LIBRARIES} - ${LLCOREHTTP_LIBRARIES} + ${LLCOREHTTP_LIBRARIES} ${LLCOMMON_LIBRARIES} - ${BOOST_CONTEXT_LIBRARY} - ${BOOST_COROUTINE_LIBRARY} + ${BOOST_CONTEXT_LIBRARY} + ${BOOST_COROUTINE_LIBRARY} ) add_custom_command( diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 9949656fcc..51787b6258 100755 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -2311,11 +2311,11 @@ if (LL_TESTS) ${GOOGLEMOCK_LIBRARIES} ) - if (LINUX) + if (LINUX) # llcommon uses `clock_gettime' which is provided by librt on linux. set(LIBRT_LIBRARY - rt - ) + rt + ) endif (LINUX) set(test_libs @@ -2328,7 +2328,7 @@ if (LL_TESTS) ${GOOGLEMOCK_LIBRARIES} ${OPENSSL_LIBRARIES} ${CRYPTO_LIBRARIES} - ${LIBRT_LIBRARY} + ${LIBRT_LIBRARY} ${BOOST_CONTEXT_LIBRARY} ${BOOST_COROUTINE_LIBRARY} ) diff --git a/indra/newview/llfloatermodeluploadbase.cpp b/indra/newview/llfloatermodeluploadbase.cpp index 644d45c16e..aa91a2ce03 100755 --- a/indra/newview/llfloatermodeluploadbase.cpp +++ b/indra/newview/llfloatermodeluploadbase.cpp @@ -90,4 +90,4 @@ void LLFloaterModelUploadBase::requestAgentUploadPermissionsCoro(LLCoros::self& result.erase(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS); observer->onPermissionsReceived(result); -} \ No newline at end of file +} diff --git a/indra/viewer_components/updater/CMakeLists.txt b/indra/viewer_components/updater/CMakeLists.txt index 2e284bf993..53e309290f 100755 --- a/indra/viewer_components/updater/CMakeLists.txt +++ b/indra/viewer_components/updater/CMakeLists.txt @@ -16,7 +16,7 @@ include(LLVFS) include_directories( ${LLCOMMON_INCLUDE_DIRS} - ${LLCOREHTTP_INCLUDE_DIRS} + ${LLCOREHTTP_INCLUDE_DIRS} ${LLMESSAGE_INCLUDE_DIRS} ${LLPLUGIN_INCLUDE_DIRS} ${LLVFS_INCLUDE_DIRS} @@ -61,7 +61,7 @@ add_library(llupdaterservice target_link_libraries(llupdaterservice ${LLCOMMON_LIBRARIES} - ${LLCOREHTTP_LIBRARIES} + ${LLCOREHTTP_LIBRARIES} ${LLMESSAGE_LIBRARIES} ${LLPLUGIN_LIBRARIES} ${LLVFS_LIBRARIES} diff --git a/indra/win_crash_logger/CMakeLists.txt b/indra/win_crash_logger/CMakeLists.txt index a52c8cc42b..144d037a31 100755 --- a/indra/win_crash_logger/CMakeLists.txt +++ b/indra/win_crash_logger/CMakeLists.txt @@ -17,7 +17,7 @@ include(GoogleBreakpad) include(Boost) include_directories( - ${LLCOREHTTP_INCLUDE_DIRS} + ${LLCOREHTTP_INCLUDE_DIRS} ${LLCOMMON_INCLUDE_DIRS} ${LLCRASHLOGGER_INCLUDE_DIRS} ${LLMATH_INCLUDE_DIRS} @@ -80,7 +80,7 @@ target_link_libraries(windows-crash-logger ${LLXML_LIBRARIES} ${LLMESSAGE_LIBRARIES} ${LLMATH_LIBRARIES} - ${LLCOREHTTP_LIBRARIES} + ${LLCOREHTTP_LIBRARIES} ${LLCOMMON_LIBRARIES} ${BOOST_CONTEXT_LIBRARY} ${BOOST_COROUTINE_LIBRARY} -- cgit v1.2.3 From 82e34f1683f67b8394306b1569260508a213b99e Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 17 Jun 2015 14:41:28 -0700 Subject: https://jira.secondlife.com/browse/MAINT-5283 The default behavior in the HTTP layer changed to follow redirects automatically. This was causing a problem with connecting to the SL share service which was attempting to riderect to the login page at the CURL level. Connections to SL Share will no longer redirect, corrected for Facebook, Flickr and Twitter. --- indra/newview/llfacebookconnect.cpp | 18 +++++++++++++++--- indra/newview/llflickrconnect.cpp | 23 ++++++++++++++++------- indra/newview/lltwitterconnect.cpp | 23 ++++++++++++++++------- 3 files changed, 47 insertions(+), 17 deletions(-) (limited to 'indra') diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index a295910379..29c5d0c673 100755 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -144,6 +144,7 @@ void LLFacebookConnect::facebookConnectCoro(LLCoros::self& self, std::string aut } httpOpts->setWantHeaders(true); + httpOpts->setFollowRedirects(false); setConnectionState(LLFacebookConnect::FB_CONNECTION_IN_PROGRESS); @@ -220,6 +221,7 @@ void LLFacebookConnect::facebookShareCoro(LLCoros::self& self, std::string route LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions, false); httpOpts->setWantHeaders(true); + httpOpts->setFollowRedirects(false); setConnectionState(LLFacebookConnect::FB_POSTING); @@ -243,6 +245,7 @@ void LLFacebookConnect::facebookShareImageCoro(LLCoros::self& self, std::string LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions, false); httpOpts->setWantHeaders(true); + httpOpts->setFollowRedirects(false); std::string imageFormat; if (dynamic_cast(image.get())) @@ -307,10 +310,12 @@ void LLFacebookConnect::facebookDisconnectCoro(LLCoros::self& self) LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FacebookConnect", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions, false); setConnectionState(LLFacebookConnect::FB_DISCONNECTING); + httpOpts->setFollowRedirects(false); - LLSD result = httpAdapter->deleteAndYield(self, httpRequest, getFacebookConnectURL("/connection")); + LLSD result = httpAdapter->deleteAndYield(self, httpRequest, getFacebookConnectURL("/connection"), httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -340,10 +345,13 @@ void LLFacebookConnect::facebookConnectedCheckCoro(LLCoros::self& self, bool aut LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FacebookConnect", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions, false); setConnectionState(LLFacebookConnect::FB_CONNECTION_IN_PROGRESS); - LLSD result = httpAdapter->getAndYield(self, httpRequest, getFacebookConnectURL("/connection", true)); + httpOpts->setFollowRedirects(false); + + LLSD result = httpAdapter->getAndYield(self, httpRequest, getFacebookConnectURL("/connection", true), httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -389,6 +397,7 @@ void LLFacebookConnect::facebookConnectInfoCoro(LLCoros::self& self) LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions, false); httpOpts->setWantHeaders(true); + httpOpts->setFollowRedirects(false); LLSD result = httpAdapter->getAndYield(self, httpRequest, getFacebookConnectURL("/info", true), httpOpts); @@ -429,8 +438,11 @@ void LLFacebookConnect::facebookConnectFriendsCoro(LLCoros::self& self) LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FacebookConnect", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions, false); + + httpOpts->setFollowRedirects(false); - LLSD result = httpAdapter->getAndYield(self, httpRequest, getFacebookConnectURL("/friends", true)); + LLSD result = httpAdapter->getAndYield(self, httpRequest, getFacebookConnectURL("/friends", true), httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); diff --git a/indra/newview/llflickrconnect.cpp b/indra/newview/llflickrconnect.cpp index b3c89b9798..4ec3344b48 100644 --- a/indra/newview/llflickrconnect.cpp +++ b/indra/newview/llflickrconnect.cpp @@ -73,9 +73,10 @@ void LLFlickrConnect::flickrConnectCoro(LLCoros::self& self, std::string request LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FlickrConnect", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions, false); httpOpts->setWantHeaders(true); + httpOpts->setFollowRedirects(false); LLSD body; if (!requestToken.empty()) @@ -162,9 +163,10 @@ void LLFlickrConnect::flickrShareCoro(LLCoros::self& self, LLSD share) LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FlickrConnect", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions, false); httpOpts->setWantHeaders(true); + httpOpts->setFollowRedirects(false); setConnectionState(LLFlickrConnect::FLICKR_POSTING); @@ -185,10 +187,11 @@ void LLFlickrConnect::flickrShareImageCoro(LLCoros::self& self, LLPointersetWantHeaders(true); + httpOpts->setFollowRedirects(false); std::string imageFormat; if (dynamic_cast(image.get())) @@ -263,10 +266,12 @@ void LLFlickrConnect::flickrDisconnectCoro(LLCoros::self& self) LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FlickrConnect", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions, false); setConnectionState(LLFlickrConnect::FLICKR_DISCONNECTING); + httpOpts->setFollowRedirects(false); - LLSD result = httpAdapter->deleteAndYield(self, httpRequest, getFlickrConnectURL("/connection")); + LLSD result = httpAdapter->deleteAndYield(self, httpRequest, getFlickrConnectURL("/connection"), httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -295,10 +300,13 @@ void LLFlickrConnect::flickrConnectedCoro(LLCoros::self& self, bool autoConnect) LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FlickrConnect", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions, false); setConnectionState(LLFlickrConnect::FLICKR_CONNECTION_IN_PROGRESS); - LLSD result = httpAdapter->getAndYield(self, httpRequest, getFlickrConnectURL("/connection", true)); + httpOpts->setFollowRedirects(false); + + LLSD result = httpAdapter->getAndYield(self, httpRequest, getFlickrConnectURL("/connection", true), false); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -342,9 +350,10 @@ void LLFlickrConnect::flickrInfoCoro(LLCoros::self& self) LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FlickrConnect", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions, false); httpOpts->setWantHeaders(true); + httpOpts->setFollowRedirects(false); LLSD result = httpAdapter->getAndYield(self, httpRequest, getFlickrConnectURL("/info", true), httpOpts); diff --git a/indra/newview/lltwitterconnect.cpp b/indra/newview/lltwitterconnect.cpp index 24555b007a..3ad7a58bdc 100644 --- a/indra/newview/lltwitterconnect.cpp +++ b/indra/newview/lltwitterconnect.cpp @@ -73,9 +73,10 @@ void LLTwitterConnect::twitterConnectCoro(LLCoros::self& self, std::string reque LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("TwitterConnect", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions, false); httpOpts->setWantHeaders(true); + httpOpts->setFollowRedirects(false); LLSD body; if (!requestToken.empty()) @@ -162,9 +163,10 @@ void LLTwitterConnect::twitterShareCoro(LLCoros::self& self, std::string route, LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("TwitterConnect", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions, false); httpOpts->setWantHeaders(true); + httpOpts->setFollowRedirects(false); setConnectionState(LLTwitterConnect::TWITTER_POSTING); @@ -184,10 +186,11 @@ void LLTwitterConnect::twitterShareImageCoro(LLCoros::self& self, LLPointersetWantHeaders(true); + httpOpts->setFollowRedirects(false); std::string imageFormat; if (dynamic_cast(image.get())) @@ -250,10 +253,13 @@ void LLTwitterConnect::twitterDisconnectCoro(LLCoros::self& self) LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("TwitterConnect", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions, false); + + httpOpts->setFollowRedirects(false); setConnectionState(LLTwitterConnect::TWITTER_DISCONNECTING); - LLSD result = httpAdapter->deleteAndYield(self, httpRequest, getTwitterConnectURL("/connection")); + LLSD result = httpAdapter->deleteAndYield(self, httpRequest, getTwitterConnectURL("/connection"), httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -282,10 +288,12 @@ void LLTwitterConnect::twitterConnectedCoro(LLCoros::self& self, bool autoConnec LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("TwitterConnect", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions, false); + httpOpts->setFollowRedirects(false); setConnectionState(LLTwitterConnect::TWITTER_CONNECTION_IN_PROGRESS); - LLSD result = httpAdapter->getAndYield(self, httpRequest, getTwitterConnectURL("/connection", true)); + LLSD result = httpAdapter->getAndYield(self, httpRequest, getTwitterConnectURL("/connection", true), httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -329,9 +337,10 @@ void LLTwitterConnect::twitterInfoCoro(LLCoros::self& self) LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("TwitterConnect", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions, false); httpOpts->setWantHeaders(true); + httpOpts->setFollowRedirects(false); LLSD result = httpAdapter->getAndYield(self, httpRequest, getTwitterConnectURL("/info", true), httpOpts); -- cgit v1.2.3 From 1060094eec34dfd355e2995409cf37f3a84240d0 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 17 Jun 2015 15:46:22 -0700 Subject: Distressing. A variable got autocorrected to 'false' but the compiler didn't catch it. --- indra/newview/llflickrconnect.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/llflickrconnect.cpp b/indra/newview/llflickrconnect.cpp index 4ec3344b48..570b93c33c 100644 --- a/indra/newview/llflickrconnect.cpp +++ b/indra/newview/llflickrconnect.cpp @@ -306,7 +306,7 @@ void LLFlickrConnect::flickrConnectedCoro(LLCoros::self& self, bool autoConnect) httpOpts->setFollowRedirects(false); - LLSD result = httpAdapter->getAndYield(self, httpRequest, getFlickrConnectURL("/connection", true), false); + LLSD result = httpAdapter->getAndYield(self, httpRequest, getFlickrConnectURL("/connection", true), httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); -- cgit v1.2.3 From da81830f4a2de5434d2d1f6e34f904b6e4b99710 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 18 Jun 2015 17:55:37 -0400 Subject: MAINT-5200: Add debug headers to Facebook slshare-service calls. --- indra/newview/llfacebookconnect.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'indra') diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index 29c5d0c673..ccfd7f6442 100755 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -67,6 +67,13 @@ void toast_user_for_facebook_success() LLNotificationsUtil::add("FacebookConnect", args); } +LLCore::HttpHeaders::ptr_t get_headers() +{ + LLCore::HttpHeaders::ptr_t httpHeaders(new LLCore::HttpHeaders); + httpHeaders->append("X-debug-tag", "dbgvwr"); + return httpHeaders; +} + /////////////////////////////////////////////////////////////////////////////// // class LLFacebookConnectHandler : public LLCommandHandler @@ -148,7 +155,7 @@ void LLFacebookConnect::facebookConnectCoro(LLCoros::self& self, std::string aut setConnectionState(LLFacebookConnect::FB_CONNECTION_IN_PROGRESS); - LLSD result = httpAdapter->putAndYield(self, httpRequest, getFacebookConnectURL("/connection"), putData, httpOpts); + LLSD result = httpAdapter->putAndYield(self, httpRequest, getFacebookConnectURL("/connection"), putData, httpOpts, get_headers()); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -225,7 +232,7 @@ void LLFacebookConnect::facebookShareCoro(LLCoros::self& self, std::string route setConnectionState(LLFacebookConnect::FB_POSTING); - LLSD result = httpAdapter->postAndYield(self, httpRequest, getFacebookConnectURL(route, true), share, httpOpts); + LLSD result = httpAdapter->postAndYield(self, httpRequest, getFacebookConnectURL(route, true), share, httpOpts, get_headers()); if (testShareStatus(result)) { @@ -241,7 +248,7 @@ void LLFacebookConnect::facebookShareImageCoro(LLCoros::self& self, std::string LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FacebookConnect", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLCore::HttpHeaders::ptr_t httpHeaders(new LLCore::HttpHeaders, false); + LLCore::HttpHeaders::ptr_t httpHeaders(get_headers()); LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions, false); httpOpts->setWantHeaders(true); @@ -315,7 +322,7 @@ void LLFacebookConnect::facebookDisconnectCoro(LLCoros::self& self) setConnectionState(LLFacebookConnect::FB_DISCONNECTING); httpOpts->setFollowRedirects(false); - LLSD result = httpAdapter->deleteAndYield(self, httpRequest, getFacebookConnectURL("/connection"), httpOpts); + LLSD result = httpAdapter->deleteAndYield(self, httpRequest, getFacebookConnectURL("/connection"), httpOpts, get_headers()); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -351,7 +358,7 @@ void LLFacebookConnect::facebookConnectedCheckCoro(LLCoros::self& self, bool aut httpOpts->setFollowRedirects(false); - LLSD result = httpAdapter->getAndYield(self, httpRequest, getFacebookConnectURL("/connection", true), httpOpts); + LLSD result = httpAdapter->getAndYield(self, httpRequest, getFacebookConnectURL("/connection", true), httpOpts, get_headers()); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -399,7 +406,7 @@ void LLFacebookConnect::facebookConnectInfoCoro(LLCoros::self& self) httpOpts->setWantHeaders(true); httpOpts->setFollowRedirects(false); - LLSD result = httpAdapter->getAndYield(self, httpRequest, getFacebookConnectURL("/info", true), httpOpts); + LLSD result = httpAdapter->getAndYield(self, httpRequest, getFacebookConnectURL("/info", true), httpOpts, get_headers()); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -442,7 +449,7 @@ void LLFacebookConnect::facebookConnectFriendsCoro(LLCoros::self& self) httpOpts->setFollowRedirects(false); - LLSD result = httpAdapter->getAndYield(self, httpRequest, getFacebookConnectURL("/friends", true), httpOpts); + LLSD result = httpAdapter->getAndYield(self, httpRequest, getFacebookConnectURL("/friends", true), httpOpts, get_headers()); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); -- cgit v1.2.3 From ed4099628c362cdc880962198a2a4984ab67dd8f Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 23 Jun 2015 11:58:15 -0700 Subject: Start work on coprocedure manager. --- indra/newview/CMakeLists.txt | 2 + indra/newview/llassetuploadresponders.cpp | 3 +- indra/newview/llassetuploadresponders.h | 2 + indra/newview/llcoproceduremanager.cpp | 177 ++++++++++++++++++++++++++++++ indra/newview/llcoproceduremanager.h | 118 ++++++++++++++++++++ 5 files changed, 301 insertions(+), 1 deletion(-) create mode 100644 indra/newview/llcoproceduremanager.cpp create mode 100644 indra/newview/llcoproceduremanager.h (limited to 'indra') diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 51787b6258..9b3324700a 100755 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -164,6 +164,7 @@ set(viewer_SOURCE_FILES llconversationloglistitem.cpp llconversationmodel.cpp llconversationview.cpp + llcoproceduremanager.cpp llcurrencyuimanager.cpp llcylinder.cpp lldateutil.cpp @@ -764,6 +765,7 @@ set(viewer_HEADER_FILES llconversationloglistitem.h llconversationmodel.h llconversationview.h + llcoproceduremanager.h llcurrencyuimanager.h llcylinder.h lldateutil.h diff --git a/indra/newview/llassetuploadresponders.cpp b/indra/newview/llassetuploadresponders.cpp index d2b1dcbf35..e492b8cf5d 100755 --- a/indra/newview/llassetuploadresponders.cpp +++ b/indra/newview/llassetuploadresponders.cpp @@ -674,6 +674,7 @@ void LLUpdateTaskInventoryResponder::uploadComplete(const LLSD& content) } +#if 0 ///////////////////////////////////////////////////// // LLNewAgentInventoryVariablePriceResponder::Impl // ///////////////////////////////////////////////////// @@ -1144,5 +1145,5 @@ void LLNewAgentInventoryVariablePriceResponder::showConfirmationDialog( LLPointer(this))); } } - +#endif diff --git a/indra/newview/llassetuploadresponders.h b/indra/newview/llassetuploadresponders.h index 7fbebc7481..18968bb1af 100755 --- a/indra/newview/llassetuploadresponders.h +++ b/indra/newview/llassetuploadresponders.h @@ -79,6 +79,7 @@ protected: virtual void httpFailure(); }; +#if 0 // A base class which goes through and performs some default // actions for variable price uploads. If more specific actions // are needed (such as different confirmation messages, etc.) @@ -115,6 +116,7 @@ private: class Impl; Impl* mImpl; }; +#endif class LLUpdateAgentInventoryResponder : public LLAssetUploadResponder { diff --git a/indra/newview/llcoproceduremanager.cpp b/indra/newview/llcoproceduremanager.cpp new file mode 100644 index 0000000000..3f5fe7a582 --- /dev/null +++ b/indra/newview/llcoproceduremanager.cpp @@ -0,0 +1,177 @@ +/** +* @file llupdloadmanager.cpp +* @author Rider Linden +* @brief Singleton class for managing asset uploads to the sim. +* +* $LicenseInfo:firstyear=2015&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2015, Linden Research, Inc. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; +* version 2.1 of the License only. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA +* $/LicenseInfo$ +*/ + +#include "llviewerprecompiledheaders.h" +#include "linden_common.h" + +#include "llviewercontrol.h" + +#include "llcoproceduremanager.h" + +//========================================================================= +#define COROCOUNT 1 + +//========================================================================= +LLCoprocedureManager::LLCoprocedureManager(): + LLSingleton(), + mPendingCoprocs(), + mShutdown(false), + mWakeupTrigger("CoprocedureManager", true), + mCoroMapping(), + mHTTPPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID) +{ + initializeManager(); +} + +LLCoprocedureManager::~LLCoprocedureManager() +{ + shutdown(); +} + +//========================================================================= +void LLCoprocedureManager::initializeManager() +{ + mShutdown = false; + + // *TODO: Retrieve the actual number of concurrent coroutines fro gSavedSettings and + // clamp to a "reasonable" number. + for (int count = 0; count < COROCOUNT; ++count) + { + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter = + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t( + new LLCoreHttpUtil::HttpCoroutineAdapter("uploadPostAdapter", mHTTPPolicy)); + + std::string uploadCoro = LLCoros::instance().launch("LLCoprocedureManager::coprocedureInvokerCoro", + boost::bind(&LLCoprocedureManager::coprocedureInvokerCoro, this, _1, httpAdapter)); + + mCoroMapping.insert(CoroAdapterMap_t::value_type(uploadCoro, httpAdapter)); + } + + mWakeupTrigger.post(LLSD()); +} + +void LLCoprocedureManager::shutdown(bool hardShutdown) +{ + CoroAdapterMap_t::iterator it; + + for (it = mCoroMapping.begin(); it != mCoroMapping.end(); ++it) + { + if (!(*it).first.empty()) + { + if (hardShutdown) + { + LLCoros::instance().kill((*it).first); + } + } + if ((*it).second) + { + (*it).second->cancelYieldingOperation(); + } + } + + mShutdown = true; + mCoroMapping.clear(); + mPendingCoprocs.clear(); +} + +//========================================================================= +LLUUID LLCoprocedureManager::enqueueCoprocedure(const std::string &name, LLCoprocedureManager::CoProcedure_t proc) +{ + LLUUID id(LLUUID::generateNewID()); + + mPendingCoprocs.push_back(QueuedCoproc::ptr_t(new QueuedCoproc(name, id, proc))); + LL_INFOS() << "Coprocedure(" << name << ") enqueued with id=" << id.asString() << LL_ENDL; + + mWakeupTrigger.post(LLSD()); + + return id; +} + +void LLCoprocedureManager::cancelCoprocedure(const LLUUID &id) +{ + // first check the active coroutines. If there, remove it and return. + ActiveCoproc_t::iterator itActive = mActiveCoprocs.find(id); + if (itActive != mActiveCoprocs.end()) + { + LL_INFOS() << "Found and canceling active coprocedure with id=" << id.asString() << LL_ENDL; + (*itActive).second->cancelYieldingOperation(); + mActiveCoprocs.erase(itActive); + return; + } + + for (AssetQueue_t::iterator it = mPendingCoprocs.begin(); it != mPendingCoprocs.end(); ++it) + { + if ((*it)->mId == id) + { + LL_INFOS() << "Found and removing queued coroutine(" << (*it)->mName << ") with Id=" << id.asString() << LL_ENDL; + mPendingCoprocs.erase(it); + return; + } + } + + LL_INFOS() << "Coprocedure with Id=" << id.asString() << " was not found." << LL_ENDL; +} + +//========================================================================= +void LLCoprocedureManager::coprocedureInvokerCoro(LLCoros::self& self, LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter) +{ + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + + while (!mShutdown) + { + waitForEventOn(self, mWakeupTrigger); + if (mShutdown) + break; + + while (!mPendingCoprocs.empty()) + { + QueuedCoproc::ptr_t coproc = mPendingCoprocs.front(); + mPendingCoprocs.pop_front(); + mActiveCoprocs.insert(ActiveCoproc_t::value_type(coproc->mId, httpAdapter)); + + LL_INFOS() << "Dequeued and invoking coprocedure(" << coproc->mName << ") with id=" << coproc->mId.asString() << LL_ENDL; + + try + { + coproc->mProc(self, httpAdapter, coproc->mId); + } + catch (std::exception &e) + { + LL_WARNS() << "Coprocedure(" << coproc->mName << ") id=" << coproc->mId.asString() << + " threw an exception! Message=\"" << e.what() << "\"" << LL_ENDL; + } + + LL_INFOS() << "Finished coprocedure(" << coproc->mName << ")" << LL_ENDL; + + ActiveCoproc_t::iterator itActive = mActiveCoprocs.find(coproc->mId); + if (itActive != mActiveCoprocs.end()) + { + mActiveCoprocs.erase(itActive); + } + } + } +} diff --git a/indra/newview/llcoproceduremanager.h b/indra/newview/llcoproceduremanager.h new file mode 100644 index 0000000000..8902b217c2 --- /dev/null +++ b/indra/newview/llcoproceduremanager.h @@ -0,0 +1,118 @@ +/** +* @file llupdloadmanager.h +* @author Rider Linden +* @brief Singleton class for managing asset uploads to the sim. +* +* $LicenseInfo:firstyear=2015&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2015, Linden Research, Inc. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; +* version 2.1 of the License only. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA +* $/LicenseInfo$ +*/ + +#ifndef LL_UPLOAD_MANAGER_H +#define LL_UPLOAD_MANAGER_H + +#include "lleventcoro.h" +#include "llcoros.h" +#include "llcorehttputil.h" +#include "lluuid.h" + +class LLCoprocedureManager : public LLSingleton < LLCoprocedureManager > +{ +public: + typedef boost::function CoProcedure_t; + + virtual ~LLCoprocedureManager(); + + /// Places the coprocedure on the queue for processing. + /// + /// @param name Is used for debugging and should identify this coroutine. + /// @param proc Is a bound function to be executed + /// + /// @return This method returns a UUID that can be used later to cancel execution. + LLUUID enqueueCoprocedure(const std::string &name, CoProcedure_t proc); + + /// Cancel a coprocedure. If the coprocedure is already being actively executed + /// this method calls cancelYieldingOperation() on the associated HttpAdapter + /// If it has not yet been dequeued it is simply removed from the queue. + void cancelCoprocedure(const LLUUID &id); + + /// Requests a shutdown of the upload manager. Passing 'true' will perform + /// an immediate kill on the upload coroutine. + void shutdown(bool hardShutdown = false); + + /// Returns the number of coprocedures in the queue awaiting processing. + /// + inline size_t countPending() const + { + return mPendingCoprocs.size(); + } + + /// Returns the number of coprocedures actively being processed. + /// + inline size_t countActive() const + { + return mActiveCoprocs.size(); + } + + /// Returns the total number of coprocedures either queued or in active processing. + /// + inline size_t count() const + { + return countPending() + countActive(); + } + +protected: + LLCoprocedureManager(); + +private: + struct QueuedCoproc + { + typedef boost::shared_ptr ptr_t; + + QueuedCoproc(const std::string &name, const LLUUID &id, CoProcedure_t proc): + mName(name), + mId(id), + mProc(proc) + {} + + std::string mName; + LLUUID mId; + CoProcedure_t mProc; + }; + + typedef std::deque AssetQueue_t; + typedef std::map ActiveCoproc_t; + + AssetQueue_t mPendingCoprocs; + ActiveCoproc_t mActiveCoprocs; + bool mShutdown; + LLEventStream mWakeupTrigger; + + + typedef std::map CoroAdapterMap_t; + LLCore::HttpRequest::policy_t mHTTPPolicy; + + CoroAdapterMap_t mCoroMapping; + + void initializeManager(); + void coprocedureInvokerCoro(LLCoros::self& self, LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter); +}; + +#endif -- cgit v1.2.3 From ec1368becf02466cf6b44d50938c09d76b7ae712 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 23 Jun 2015 14:43:12 -0700 Subject: Code review results with Nat --- indra/newview/llcoproceduremanager.cpp | 27 +++++++++++++-------------- indra/newview/llcoproceduremanager.h | 9 +++++---- 2 files changed, 18 insertions(+), 18 deletions(-) (limited to 'indra') diff --git a/indra/newview/llcoproceduremanager.cpp b/indra/newview/llcoproceduremanager.cpp index 3f5fe7a582..3ecb323cab 100644 --- a/indra/newview/llcoproceduremanager.cpp +++ b/indra/newview/llcoproceduremanager.cpp @@ -1,5 +1,5 @@ /** -* @file llupdloadmanager.cpp +* @file llcoproceduremanager.cpp * @author Rider Linden * @brief Singleton class for managing asset uploads to the sim. * @@ -44,18 +44,6 @@ LLCoprocedureManager::LLCoprocedureManager(): mCoroMapping(), mHTTPPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID) { - initializeManager(); -} - -LLCoprocedureManager::~LLCoprocedureManager() -{ - shutdown(); -} - -//========================================================================= -void LLCoprocedureManager::initializeManager() -{ - mShutdown = false; // *TODO: Retrieve the actual number of concurrent coroutines fro gSavedSettings and // clamp to a "reasonable" number. @@ -74,6 +62,13 @@ void LLCoprocedureManager::initializeManager() mWakeupTrigger.post(LLSD()); } +LLCoprocedureManager::~LLCoprocedureManager() +{ + shutdown(); +} + +//========================================================================= + void LLCoprocedureManager::shutdown(bool hardShutdown) { CoroAdapterMap_t::iterator it; @@ -123,7 +118,7 @@ void LLCoprocedureManager::cancelCoprocedure(const LLUUID &id) return; } - for (AssetQueue_t::iterator it = mPendingCoprocs.begin(); it != mPendingCoprocs.end(); ++it) + for (CoprocQueue_t::iterator it = mPendingCoprocs.begin(); it != mPendingCoprocs.end(); ++it) { if ((*it)->mId == id) { @@ -164,6 +159,10 @@ void LLCoprocedureManager::coprocedureInvokerCoro(LLCoros::self& self, LLCoreHtt LL_WARNS() << "Coprocedure(" << coproc->mName << ") id=" << coproc->mId.asString() << " threw an exception! Message=\"" << e.what() << "\"" << LL_ENDL; } + catch (...) + { + LL_WARNS() << "A non std::exception was thrown from " << coproc->mName << " with id=" << coproc->mId << "." << LL_ENDL; + } LL_INFOS() << "Finished coprocedure(" << coproc->mName << ")" << LL_ENDL; diff --git a/indra/newview/llcoproceduremanager.h b/indra/newview/llcoproceduremanager.h index 8902b217c2..e84eba2db9 100644 --- a/indra/newview/llcoproceduremanager.h +++ b/indra/newview/llcoproceduremanager.h @@ -1,5 +1,5 @@ /** -* @file llupdloadmanager.h +* @file llcoproceduremanager.h * @author Rider Linden * @brief Singleton class for managing asset uploads to the sim. * @@ -97,10 +97,12 @@ private: CoProcedure_t mProc; }; - typedef std::deque AssetQueue_t; + // we use a deque here rather than std::queue since we want to be able to + // iterate through the queue and potentially erase an entry from the middle. + typedef std::deque CoprocQueue_t; typedef std::map ActiveCoproc_t; - AssetQueue_t mPendingCoprocs; + CoprocQueue_t mPendingCoprocs; ActiveCoproc_t mActiveCoprocs; bool mShutdown; LLEventStream mWakeupTrigger; @@ -111,7 +113,6 @@ private: CoroAdapterMap_t mCoroMapping; - void initializeManager(); void coprocedureInvokerCoro(LLCoros::self& self, LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter); }; -- cgit v1.2.3 From 97033975510d0514821f943287d91708eefa9c92 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 24 Jun 2015 10:10:22 -0700 Subject: MAINT-5295 Remove POSTFIELDS from PUT operation. --- indra/llcorehttp/_httpoprequest.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'indra') diff --git a/indra/llcorehttp/_httpoprequest.cpp b/indra/llcorehttp/_httpoprequest.cpp index 503c04dfa7..799587ff22 100755 --- a/indra/llcorehttp/_httpoprequest.cpp +++ b/indra/llcorehttp/_httpoprequest.cpp @@ -635,8 +635,6 @@ HttpStatus HttpOpRequest::prepareRequest(HttpService * service) } code = curl_easy_setopt(mCurlHandle, CURLOPT_INFILESIZE, data_size); check_curl_easy_code(code, CURLOPT_INFILESIZE); - code = curl_easy_setopt(mCurlHandle, CURLOPT_POSTFIELDS, (void *) NULL); - check_curl_easy_code(code, CURLOPT_POSTFIELDS); mCurlHeaders = curl_slist_append(mCurlHeaders, "Expect:"); } break; -- cgit v1.2.3 From 08ef748cba55d5d950b224710c8592e94fcce5c7 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 25 Jun 2015 15:47:56 -0700 Subject: Added file upload interface to core HTTP utils. --- indra/llmessage/llcorehttputil.cpp | 56 ++++++++++++++++++++++++++++++++++++++ indra/llmessage/llcorehttputil.h | 30 ++++++++++++++++++++ 2 files changed, 86 insertions(+) (limited to 'indra') diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index 9ccebabab4..68c55eaf54 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -36,6 +36,7 @@ #include "llsdjson.h" #include "llsdserialize.h" #include "reader.h" +#include "llvfile.h" #include "message.h" // for getting the port @@ -621,6 +622,61 @@ LLSD HttpCoroutineAdapter::postRawAndYield(LLCoros::self & self, LLCore::HttpReq return postAndYield_(self, request, url, rawbody, options, headers, httpHandler); } +// *TODO: This functionality could be moved into the LLCore::Http library itself +// by having the CURL layer read the file directly. +LLSD HttpCoroutineAdapter::postFileAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, + const std::string & url, std::string fileName, + LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) +{ + LLCore::BufferArray::ptr_t fileData(new LLCore::BufferArray, false); + + // scoping for our streams so that they go away when we no longer need them. + { + LLCore::BufferArrayStream outs(fileData.get()); + llifstream ins(fileName.c_str(), std::iostream::binary | std::iostream::out); + + if (ins.is_open()) + { + + ins.seekg(0, std::ios::beg); + ins >> std::noskipws; + + std::copy(std::istream_iterator(ins), std::istream_iterator(), + std::ostream_iterator(outs)); + + ins.close(); + } + } + + return postAndYield(self, request, url, fileData, options, headers); +} + +// *TODO: This functionality could be moved into the LLCore::Http library itself +// by having the CURL layer read the file directly. +LLSD HttpCoroutineAdapter::postFileAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, + const std::string & url, LLUUID assetId, LLAssetType::EType assetType, + LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) +{ + LLCore::BufferArray::ptr_t fileData(new LLCore::BufferArray, false); + + // scoping for our streams so that they go away when we no longer need them. + { + LLCore::BufferArrayStream outs(fileData.get()); + LLVFile vfile(gVFS, assetId, assetType, LLVFile::READ); + + S32 fileSize = vfile.getSize(); + U8* fileBuffer; + fileBuffer = new U8[fileSize]; + vfile.read(fileBuffer, fileSize); + + outs.write((char*)fileBuffer, fileSize); + delete[] fileBuffer; + } + + return postAndYield(self, request, url, fileData, options, headers); +} + + LLSD HttpCoroutineAdapter::postAndYield_(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, const std::string & url, LLCore::BufferArray::ptr_t &rawbody, LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, diff --git a/indra/llmessage/llcorehttputil.h b/indra/llmessage/llcorehttputil.h index e98399c985..71f95dd6e4 100644 --- a/indra/llmessage/llcorehttputil.h +++ b/indra/llmessage/llcorehttputil.h @@ -43,6 +43,8 @@ #include "llevents.h" #include "llcoros.h" #include "lleventcoro.h" +#include "llassettype.h" +#include "lluuid.h" /// /// The base llcorehttp library implements many HTTP idioms @@ -355,6 +357,34 @@ public: LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false), headers); } + LLSD postFileAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, + const std::string & url, std::string fileName, + LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false), + LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false)); + + LLSD postFileAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, + const std::string & url, std::string fileName, + LLCore::HttpHeaders::ptr_t &headers) + { + return postFileAndYield(self, request, url, fileName, + LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false), headers); + } + + + LLSD HttpCoroutineAdapter::postFileAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, + const std::string & url, LLUUID assetId, LLAssetType::EType assetType, + LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false), + LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false)); + + LLSD HttpCoroutineAdapter::postFileAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, + const std::string & url, LLUUID assetId, LLAssetType::EType assetType, + LLCore::HttpHeaders::ptr_t &headers) + { + return postFileAndYield(self, request, url, assetId, assetType, + LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false), headers); + } + + /// Execute a Put transaction on the supplied URL and yield execution of /// the coroutine until a result is available. /// -- cgit v1.2.3 From da7b675025ef1a9b884b54340d207e7bc77d36af Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Mon, 29 Jun 2015 09:07:19 -0400 Subject: Remove extraneous class qualification from method declaration. clang doesn't like finding HttpCoroutineAdapter::postFileAndYield(...) inside the class definition for HttpCoroutineAdapter. It's much happier with plain postFileAndYield(...). --- indra/llmessage/llcorehttputil.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra') diff --git a/indra/llmessage/llcorehttputil.h b/indra/llmessage/llcorehttputil.h index 71f95dd6e4..17168bd1f8 100644 --- a/indra/llmessage/llcorehttputil.h +++ b/indra/llmessage/llcorehttputil.h @@ -371,12 +371,12 @@ public: } - LLSD HttpCoroutineAdapter::postFileAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, + LLSD postFileAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, const std::string & url, LLUUID assetId, LLAssetType::EType assetType, LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false), LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false)); - LLSD HttpCoroutineAdapter::postFileAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, + LLSD postFileAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, const std::string & url, LLUUID assetId, LLAssetType::EType assetType, LLCore::HttpHeaders::ptr_t &headers) { -- cgit v1.2.3 From f779c164a2da0eec3454d1d26ccd333751afcf4f Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Mon, 29 Jun 2015 13:07:37 -0400 Subject: MAINT-5200: Add DebugSlshareLogTag temp setting for developers. This allows engaging slshare-service debug logging for a particular viewer session without having to twiddle the slshare-service hosts. Also fix leaky LLCore::HttpHeaders::ptr_t construction. --- indra/newview/app_settings/settings.xml | 11 +++++++++++ indra/newview/llfacebookconnect.cpp | 16 ++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) (limited to 'indra') diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 845cb5ae96..fca3fd8cf3 100755 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -2370,6 +2370,17 @@ Value 0 + DebugSlshareLogTag + + Comment + Request slshare-service debug logging + Persist + 0 + Type + String + Value + + DebugStatModeFPS Comment diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index ccfd7f6442..0aaee4f961 100755 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -41,6 +41,7 @@ #include "lltrans.h" #include "llevents.h" #include "llviewerregion.h" +#include "llviewercontrol.h" #include "llfloaterwebcontent.h" #include "llfloaterreg.h" @@ -69,8 +70,19 @@ void toast_user_for_facebook_success() LLCore::HttpHeaders::ptr_t get_headers() { - LLCore::HttpHeaders::ptr_t httpHeaders(new LLCore::HttpHeaders); - httpHeaders->append("X-debug-tag", "dbgvwr"); + LLCore::HttpHeaders::ptr_t httpHeaders(new LLCore::HttpHeaders, false); + // The DebugSlshareLogTag mechanism is intended to trigger slshare-service + // debug logging. slshare-service is coded to respond to an X-debug-tag + // header by engaging debug logging for that request only. This way a + // developer need not muck with the slshare-service image to engage debug + // logging. Moreover, the value of X-debug-tag is embedded in each such + // log line so the developer can quickly find the log lines pertinent to + // THIS session. + std::string logtag(gSavedSettings.getString("DebugSlshareLogTag")); + if (! logtag.empty()) + { + httpHeaders->append("X-debug-tag", logtag); + } return httpHeaders; } -- cgit v1.2.3 From 8bd39583fe19eb8f372f59f9aaee6d7c16a6f4e1 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Mon, 29 Jun 2015 15:32:47 -0400 Subject: MAINT-4952: Fix misplaced comments on intrusive_ptr_etc() overloads. --- indra/llcommon/llrefcount.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'indra') diff --git a/indra/llcommon/llrefcount.h b/indra/llcommon/llrefcount.h index 3836a9b5fb..1107973569 100755 --- a/indra/llcommon/llrefcount.h +++ b/indra/llcommon/llrefcount.h @@ -143,15 +143,10 @@ private: LLAtomic32< S32 > mRef; }; -/** - * intrusive pointer support - * this allows you to use boost::intrusive_ptr with any LLRefCount-derived type - */ /** * intrusive pointer support for LLThreadSafeRefCount * this allows you to use boost::intrusive_ptr with any LLThreadSafeRefCount-derived type */ - inline void intrusive_ptr_add_ref(LLThreadSafeRefCount* p) { p->ref(); @@ -162,6 +157,10 @@ inline void intrusive_ptr_release(LLThreadSafeRefCount* p) p->unref(); } +/** + * intrusive pointer support + * this allows you to use boost::intrusive_ptr with any LLRefCount-derived type + */ inline void intrusive_ptr_add_ref(LLRefCount* p) { p->ref(); -- cgit v1.2.3 From 76cb1fcf0b5b9d8415e2517c482bab0c6c6602fb Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Mon, 29 Jun 2015 15:37:32 -0400 Subject: MAINT-4952: Add IntrusivePtr wrapper for boost::intrusive_ptr. For a RefCounted subclass T, boost::intrusive_ptr must be instantiated as boost::intrusive_ptr(raw ptr, false) to avoid immortal instances. Forgetting that final bool parameter is both easy and extremely hard to spot with desk checking or code review. IntrusivePtr provides constructors that Do The Right Thing, so we can typedef a subclass T's ptr_t to IntrusivePtr rather than directly to boost::intrusive_ptr. --- indra/llcorehttp/_refcounted.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'indra') diff --git a/indra/llcorehttp/_refcounted.h b/indra/llcorehttp/_refcounted.h index cd16e2e2b4..7f713f2298 100755 --- a/indra/llcorehttp/_refcounted.h +++ b/indra/llcorehttp/_refcounted.h @@ -32,6 +32,7 @@ #include "fix_macros.h" #include +#include #include "llapr.h" @@ -120,6 +121,24 @@ inline void RefCounted::destroySelf() delete this; } +/** + * boost::intrusive_ptr may be used to manage RefCounted classes. + * Unfortunately RefCounted and boost::intrusive_ptr use different conventions + * for the initial refcount value. To avoid leaky (immortal) objects, you + * should really construct boost::intrusive_ptr(rawptr, false). + * IntrusivePtr encapsulates that for you. + */ +template +struct IntrusivePtr: public boost::intrusive_ptr +{ + IntrusivePtr(): + boost::intrusive_ptr() + {} + IntrusivePtr(T* p): + boost::intrusive_ptr(p, false) + {} +}; + inline void intrusive_ptr_add_ref(RefCounted* p) { p->addRef(); -- cgit v1.2.3 From 80d17b2dd9cdd7a9445480fdb0e12774396751eb Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Mon, 29 Jun 2015 17:19:51 -0400 Subject: MAINT-4952: Use IntrusivePtr for BufferArray,HttpHeaders,HttpOptions. Specifically, change the ptr_t typedefs for these LLCore classes to use IntrusivePtr rather than directly using boost::intrusive_ptr. This allows us to use a simple ptr_t(raw ptr) constructor rather than having to remember to code ptr_t(raw ptr, false) everywhere. In fact, the latter form is now invalid: remove the now-extraneous 'false' constructor parameters. --- indra/llcorehttp/bufferarray.h | 2 +- indra/llcorehttp/httpheaders.h | 2 +- indra/llcorehttp/httpoptions.h | 2 +- indra/llcrashlogger/llcrashlogger.cpp | 2 +- indra/llmessage/llavatarnamecache.cpp | 4 +-- indra/llmessage/llcorehttputil.cpp | 8 ++--- indra/llmessage/llcorehttputil.h | 56 +++++++++++++++++------------------ indra/newview/llfacebookconnect.cpp | 18 +++++------ indra/newview/llflickrconnect.cpp | 16 +++++----- indra/newview/llgroupmgr.cpp | 4 +-- indra/newview/llmaterialmgr.cpp | 4 +-- indra/newview/llmediadataclient.cpp | 4 +-- indra/newview/lltwitterconnect.cpp | 16 +++++----- indra/newview/llviewermedia.cpp | 2 +- indra/newview/llwebprofile.cpp | 2 +- indra/newview/llxmlrpctransaction.cpp | 6 ++-- 16 files changed, 74 insertions(+), 74 deletions(-) (limited to 'indra') diff --git a/indra/llcorehttp/bufferarray.h b/indra/llcorehttp/bufferarray.h index 076f341736..320adf2b8b 100755 --- a/indra/llcorehttp/bufferarray.h +++ b/indra/llcorehttp/bufferarray.h @@ -74,7 +74,7 @@ public: BufferArray(); - typedef boost::intrusive_ptr ptr_t; + typedef LLCoreInt::IntrusivePtr ptr_t; protected: virtual ~BufferArray(); // Use release() diff --git a/indra/llcorehttp/httpheaders.h b/indra/llcorehttp/httpheaders.h index 51bd76a01d..8f14568fa3 100755 --- a/indra/llcorehttp/httpheaders.h +++ b/indra/llcorehttp/httpheaders.h @@ -92,7 +92,7 @@ public: /// the instance. HttpHeaders(); - typedef boost::intrusive_ptr ptr_t; + typedef LLCoreInt::IntrusivePtr ptr_t; protected: virtual ~HttpHeaders(); // Use release() diff --git a/indra/llcorehttp/httpoptions.h b/indra/llcorehttp/httpoptions.h index 21ecff85af..2fe05a65ff 100755 --- a/indra/llcorehttp/httpoptions.h +++ b/indra/llcorehttp/httpoptions.h @@ -60,7 +60,7 @@ class HttpOptions : public LLCoreInt::RefCounted public: HttpOptions(); - typedef boost::intrusive_ptr ptr_t; + typedef LLCoreInt::IntrusivePtr ptr_t; protected: virtual ~HttpOptions(); // Use release() diff --git a/indra/llcrashlogger/llcrashlogger.cpp b/indra/llcrashlogger/llcrashlogger.cpp index 90f70c0d1c..cb05c4ff03 100755 --- a/indra/llcrashlogger/llcrashlogger.cpp +++ b/indra/llcrashlogger/llcrashlogger.cpp @@ -397,7 +397,7 @@ bool LLCrashLogger::saveCrashBehaviorSetting(S32 crash_behavior) bool LLCrashLogger::runCrashLogPost(std::string host, LLSD data, std::string msg, int retries, int timeout) { LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions, false); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); gBreak = false; httpOpts->setTimeout(timeout); diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index e4b8642c4d..7014048021 100755 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -468,8 +468,8 @@ void LLAvatarNameCache::initClass(bool running, bool usePeopleAPI) sUsePeopleAPI = usePeopleAPI; sHttpRequest = LLCore::HttpRequest::ptr_t(new LLCore::HttpRequest()); - sHttpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false); - sHttpOptions = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false); + sHttpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders()); + sHttpOptions = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()); sHttpPolicy = LLCore::HttpRequest::DEFAULT_POLICY_ID; sHttpPriority = 0; } diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index 68c55eaf54..4ec01aa405 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -628,7 +628,7 @@ LLSD HttpCoroutineAdapter::postFileAndYield(LLCoros::self & self, LLCore::HttpRe const std::string & url, std::string fileName, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { - LLCore::BufferArray::ptr_t fileData(new LLCore::BufferArray, false); + LLCore::BufferArray::ptr_t fileData(new LLCore::BufferArray); // scoping for our streams so that they go away when we no longer need them. { @@ -657,7 +657,7 @@ LLSD HttpCoroutineAdapter::postFileAndYield(LLCoros::self & self, LLCore::HttpRe const std::string & url, LLUUID assetId, LLAssetType::EType assetType, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { - LLCore::BufferArray::ptr_t fileData(new LLCore::BufferArray, false); + LLCore::BufferArray::ptr_t fileData(new LLCore::BufferArray); // scoping for our streams so that they go away when we no longer need them. { @@ -926,7 +926,7 @@ void HttpCoroutineAdapter::trivialGetCoro(LLCoros::self& self, std::string url, LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("genericGetCoro", policyId)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions, false); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); httpOpts->setWantHeaders(true); @@ -977,7 +977,7 @@ void HttpCoroutineAdapter::trivialPostCoro(LLCoros::self& self, std::string url, LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("genericPostCoro", policyId)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions, false); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); httpOpts->setWantHeaders(true); diff --git a/indra/llmessage/llcorehttputil.h b/indra/llmessage/llcorehttputil.h index 17168bd1f8..7dd161d1cd 100644 --- a/indra/llmessage/llcorehttputil.h +++ b/indra/llmessage/llcorehttputil.h @@ -322,18 +322,18 @@ public: /// not be deallocated during the yield. LLSD postAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, const std::string & url, const LLSD & body, - LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false), - LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false)); + LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), + LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders())); LLSD postAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, const std::string & url, LLCore::BufferArray::ptr_t rawbody, - LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false), - LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false)); + LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), + LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders())); LLSD postAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, const std::string & url, const LLSD & body, LLCore::HttpHeaders::ptr_t &headers) { return postAndYield(self, request, url, body, - LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false), headers); + LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), headers); } LLSD postAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, @@ -341,47 +341,47 @@ public: LLCore::HttpHeaders::ptr_t &headers) { return postAndYield(self, request, url, rawbody, - LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false), headers); + LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), headers); } LLSD postRawAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, const std::string & url, LLCore::BufferArray::ptr_t rawbody, - LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false), - LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false)); + LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), + LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders())); LLSD postRawAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, const std::string & url, LLCore::BufferArray::ptr_t &rawbody, LLCore::HttpHeaders::ptr_t &headers) { return postRawAndYield(self, request, url, rawbody, - LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false), headers); + LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), headers); } LLSD postFileAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, const std::string & url, std::string fileName, - LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false), - LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false)); + LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), + LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders())); LLSD postFileAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, const std::string & url, std::string fileName, LLCore::HttpHeaders::ptr_t &headers) { return postFileAndYield(self, request, url, fileName, - LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false), headers); + LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), headers); } LLSD postFileAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, const std::string & url, LLUUID assetId, LLAssetType::EType assetType, - LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false), - LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false)); + LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), + LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders())); LLSD postFileAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, const std::string & url, LLUUID assetId, LLAssetType::EType assetType, LLCore::HttpHeaders::ptr_t &headers) { return postFileAndYield(self, request, url, assetId, assetType, - LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false), headers); + LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), headers); } @@ -392,8 +392,8 @@ public: /// not be deallocated during the yield. LLSD putAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, const std::string & url, const LLSD & body, - LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false), - LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false)); + LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), + LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders())); /// Execute a Get transaction on the supplied URL and yield execution of /// the coroutine until a result is available. @@ -402,37 +402,37 @@ public: /// not be deallocated during the yield. LLSD getAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, const std::string & url, - LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false), - LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false)); + LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), + LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders())); LLSD getAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, const std::string & url, LLCore::HttpHeaders::ptr_t &headers) { return getAndYield(self, request, url, - LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false), + LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), headers); } LLSD getRawAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, const std::string & url, - LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false), - LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false)); + LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), + LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders())); LLSD getRawAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, const std::string & url, LLCore::HttpHeaders::ptr_t &headers) { return getRawAndYield(self, request, url, - LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false), + LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), headers); } LLSD getJsonAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, const std::string & url, - LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false), - LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false)); + LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), + LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders())); LLSD getJsonndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, const std::string & url, LLCore::HttpHeaders::ptr_t &headers) { return getJsonAndYield(self, request, url, - LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false), + LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), headers); } @@ -444,8 +444,8 @@ public: /// not be deallocated during the yield. LLSD deleteAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, const std::string & url, - LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false), - LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false)); + LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), + LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders())); /// void cancelYieldingOperation(); diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index 29c5d0c673..a1700a4357 100755 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -131,7 +131,7 @@ void LLFacebookConnect::facebookConnectCoro(LLCoros::self& self, std::string aut LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FacebookConnect", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions, false); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); LLSD putData; if (!authCode.empty()) @@ -218,7 +218,7 @@ void LLFacebookConnect::facebookShareCoro(LLCoros::self& self, std::string route LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FacebookConnect", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions, false); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); httpOpts->setWantHeaders(true); httpOpts->setFollowRedirects(false); @@ -241,8 +241,8 @@ void LLFacebookConnect::facebookShareImageCoro(LLCoros::self& self, std::string LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FacebookConnect", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLCore::HttpHeaders::ptr_t httpHeaders(new LLCore::HttpHeaders, false); - LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions, false); + LLCore::HttpHeaders::ptr_t httpHeaders(new LLCore::HttpHeaders); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); httpOpts->setWantHeaders(true); httpOpts->setFollowRedirects(false); @@ -268,7 +268,7 @@ void LLFacebookConnect::facebookShareImageCoro(LLCoros::self& self, std::string std::string contentType = "multipart/form-data; boundary=" + boundary; httpHeaders->append("Content-Type", contentType.c_str()); - LLCore::BufferArray::ptr_t raw = LLCore::BufferArray::ptr_t(new LLCore::BufferArray(), false); // + LLCore::BufferArray::ptr_t raw = LLCore::BufferArray::ptr_t(new LLCore::BufferArray()); // LLCore::BufferArrayStream body(raw.get()); // *NOTE: The order seems to matter. @@ -310,7 +310,7 @@ void LLFacebookConnect::facebookDisconnectCoro(LLCoros::self& self) LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FacebookConnect", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions, false); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); setConnectionState(LLFacebookConnect::FB_DISCONNECTING); httpOpts->setFollowRedirects(false); @@ -345,7 +345,7 @@ void LLFacebookConnect::facebookConnectedCheckCoro(LLCoros::self& self, bool aut LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FacebookConnect", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions, false); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); setConnectionState(LLFacebookConnect::FB_CONNECTION_IN_PROGRESS); @@ -394,7 +394,7 @@ void LLFacebookConnect::facebookConnectInfoCoro(LLCoros::self& self) LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FacebookConnect", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions, false); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); httpOpts->setWantHeaders(true); httpOpts->setFollowRedirects(false); @@ -438,7 +438,7 @@ void LLFacebookConnect::facebookConnectFriendsCoro(LLCoros::self& self) LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FacebookConnect", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions, false); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); httpOpts->setFollowRedirects(false); diff --git a/indra/newview/llflickrconnect.cpp b/indra/newview/llflickrconnect.cpp index 570b93c33c..873b1a7138 100644 --- a/indra/newview/llflickrconnect.cpp +++ b/indra/newview/llflickrconnect.cpp @@ -73,7 +73,7 @@ void LLFlickrConnect::flickrConnectCoro(LLCoros::self& self, std::string request LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FlickrConnect", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions, false); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); httpOpts->setWantHeaders(true); httpOpts->setFollowRedirects(false); @@ -163,7 +163,7 @@ void LLFlickrConnect::flickrShareCoro(LLCoros::self& self, LLSD share) LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FlickrConnect", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions, false); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); httpOpts->setWantHeaders(true); httpOpts->setFollowRedirects(false); @@ -187,8 +187,8 @@ void LLFlickrConnect::flickrShareImageCoro(LLCoros::self& self, LLPointersetWantHeaders(true); httpOpts->setFollowRedirects(false); @@ -214,7 +214,7 @@ void LLFlickrConnect::flickrShareImageCoro(LLCoros::self& self, LLPointerappend("Content-Type", contentType.c_str()); - LLCore::BufferArray::ptr_t raw = LLCore::BufferArray::ptr_t(new LLCore::BufferArray(), false); // + LLCore::BufferArray::ptr_t raw = LLCore::BufferArray::ptr_t(new LLCore::BufferArray()); // LLCore::BufferArrayStream body(raw.get()); // *NOTE: The order seems to matter. @@ -266,7 +266,7 @@ void LLFlickrConnect::flickrDisconnectCoro(LLCoros::self& self) LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FlickrConnect", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions, false); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); setConnectionState(LLFlickrConnect::FLICKR_DISCONNECTING); httpOpts->setFollowRedirects(false); @@ -300,7 +300,7 @@ void LLFlickrConnect::flickrConnectedCoro(LLCoros::self& self, bool autoConnect) LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FlickrConnect", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions, false); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); setConnectionState(LLFlickrConnect::FLICKR_CONNECTION_IN_PROGRESS); @@ -350,7 +350,7 @@ void LLFlickrConnect::flickrInfoCoro(LLCoros::self& self) LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FlickrConnect", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions, false); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); httpOpts->setWantHeaders(true); httpOpts->setFollowRedirects(false); diff --git a/indra/newview/llgroupmgr.cpp b/indra/newview/llgroupmgr.cpp index 0852104ba7..0fb39ab02e 100755 --- a/indra/newview/llgroupmgr.cpp +++ b/indra/newview/llgroupmgr.cpp @@ -1897,8 +1897,8 @@ void LLGroupMgr::postGroupBanRequestCoro(LLCoros::self& self, std::string url, L LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("groupMembersRequest", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLCore::HttpHeaders::ptr_t httpHeaders(new LLCore::HttpHeaders, false); - LLCore::HttpOptions::ptr_t httpOptions(new LLCore::HttpOptions, false); + LLCore::HttpHeaders::ptr_t httpHeaders(new LLCore::HttpHeaders); + LLCore::HttpOptions::ptr_t httpOptions(new LLCore::HttpOptions); httpOptions->setFollowRedirects(false); diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index 8a726ec7c9..aef5bcf0dd 100755 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -139,8 +139,8 @@ LLMaterialMgr::LLMaterialMgr(): LLAppCoreHttp & app_core_http(LLAppViewer::instance()->getAppCoreHttp()); mHttpRequest = LLCore::HttpRequest::ptr_t(new LLCore::HttpRequest()); - mHttpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false); - mHttpOptions = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false); + mHttpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders()); + mHttpOptions = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()); mHttpPolicy = app_core_http.getPolicy(LLAppCoreHttp::AP_MATERIALS); mMaterials.insert(std::pair(LLMaterialID::null, LLMaterialPtr(NULL))); diff --git a/indra/newview/llmediadataclient.cpp b/indra/newview/llmediadataclient.cpp index f996e7b26e..b8ff76aa6d 100755 --- a/indra/newview/llmediadataclient.cpp +++ b/indra/newview/llmediadataclient.cpp @@ -178,8 +178,8 @@ LLMediaDataClient::LLMediaDataClient(F32 queue_timer_delay, F32 retry_timer_dela mMaxRoundRobinQueueSize(max_round_robin_queue_size), mQueueTimerIsRunning(false), mHttpRequest(new LLCore::HttpRequest()), - mHttpHeaders(new LLCore::HttpHeaders(), false), - mHttpOpts(new LLCore::HttpOptions(), false), + mHttpHeaders(new LLCore::HttpHeaders()), + mHttpOpts(new LLCore::HttpOptions()), mHttpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID) { // *TODO: Look up real Policy ID diff --git a/indra/newview/lltwitterconnect.cpp b/indra/newview/lltwitterconnect.cpp index 3ad7a58bdc..09435850c3 100644 --- a/indra/newview/lltwitterconnect.cpp +++ b/indra/newview/lltwitterconnect.cpp @@ -73,7 +73,7 @@ void LLTwitterConnect::twitterConnectCoro(LLCoros::self& self, std::string reque LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("TwitterConnect", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions, false); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); httpOpts->setWantHeaders(true); httpOpts->setFollowRedirects(false); @@ -163,7 +163,7 @@ void LLTwitterConnect::twitterShareCoro(LLCoros::self& self, std::string route, LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("TwitterConnect", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions, false); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); httpOpts->setWantHeaders(true); httpOpts->setFollowRedirects(false); @@ -186,8 +186,8 @@ void LLTwitterConnect::twitterShareImageCoro(LLCoros::self& self, LLPointersetWantHeaders(true); httpOpts->setFollowRedirects(false); @@ -213,7 +213,7 @@ void LLTwitterConnect::twitterShareImageCoro(LLCoros::self& self, LLPointerappend("Content-Type", contentType.c_str()); - LLCore::BufferArray::ptr_t raw = LLCore::BufferArray::ptr_t(new LLCore::BufferArray(), false); // + LLCore::BufferArray::ptr_t raw = LLCore::BufferArray::ptr_t(new LLCore::BufferArray()); // LLCore::BufferArrayStream body(raw.get()); // *NOTE: The order seems to matter. @@ -253,7 +253,7 @@ void LLTwitterConnect::twitterDisconnectCoro(LLCoros::self& self) LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("TwitterConnect", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions, false); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); httpOpts->setFollowRedirects(false); @@ -288,7 +288,7 @@ void LLTwitterConnect::twitterConnectedCoro(LLCoros::self& self, bool autoConnec LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("TwitterConnect", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions, false); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); httpOpts->setFollowRedirects(false); setConnectionState(LLTwitterConnect::TWITTER_CONNECTION_IN_PROGRESS); @@ -337,7 +337,7 @@ void LLTwitterConnect::twitterInfoCoro(LLCoros::self& self) LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("TwitterConnect", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions, false); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); httpOpts->setWantHeaders(true); httpOpts->setFollowRedirects(false); diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp index 6784c97192..6d0fce46aa 100755 --- a/indra/newview/llviewermedia.cpp +++ b/indra/newview/llviewermedia.cpp @@ -1342,7 +1342,7 @@ void LLViewerMedia::openIDSetupCoro(LLCoros::self& self, std::string openidUrl, httpHeaders->append(HTTP_OUT_HEADER_ACCEPT, "*/*"); httpHeaders->append(HTTP_OUT_HEADER_CONTENT_TYPE, "application/x-www-form-urlencoded"); - LLCore::BufferArray::ptr_t rawbody(new LLCore::BufferArray, false); + LLCore::BufferArray::ptr_t rawbody(new LLCore::BufferArray); LLCore::BufferArrayStream bas(rawbody.get()); bas << std::noskipws << openidToken; diff --git a/indra/newview/llwebprofile.cpp b/indra/newview/llwebprofile.cpp index 727c9ffb18..62ba40ca32 100755 --- a/indra/newview/llwebprofile.cpp +++ b/indra/newview/llwebprofile.cpp @@ -202,7 +202,7 @@ void LLWebProfile::uploadImageCoro(LLCoros::self& self, LLPointer &image, const std::string &boundary) { - LLCore::BufferArray::ptr_t body(new LLCore::BufferArray, false); + LLCore::BufferArray::ptr_t body(new LLCore::BufferArray); LLCore::BufferArrayStream bas(body.get()); // *NOTE: The order seems to matter. diff --git a/indra/newview/llxmlrpctransaction.cpp b/indra/newview/llxmlrpctransaction.cpp index 702d0c3a29..066970614a 100755 --- a/indra/newview/llxmlrpctransaction.cpp +++ b/indra/newview/llxmlrpctransaction.cpp @@ -357,7 +357,7 @@ void LLXMLRPCTransaction::Impl::init(XMLRPC_REQUEST request, bool useGzip) } // LLRefCounted starts with a 1 ref, so don't add a ref in the smart pointer - httpOpts = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false); + httpOpts = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()); httpOpts->setTimeout(40L); @@ -368,7 +368,7 @@ void LLXMLRPCTransaction::Impl::init(XMLRPC_REQUEST request, bool useGzip) httpOpts->setSSLVerifyHost( vefifySSLCert ? 2 : 0); // LLRefCounted starts with a 1 ref, so don't add a ref in the smart pointer - httpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false); + httpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders()); httpHeaders->append(HTTP_OUT_HEADER_CONTENT_TYPE, HTTP_CONTENT_TEXT_XML); @@ -376,7 +376,7 @@ void LLXMLRPCTransaction::Impl::init(XMLRPC_REQUEST request, bool useGzip) //This might help with bug #503 */ //httpOpts->setDNSCacheTimeout(-1); - LLCore::BufferArray::ptr_t body = LLCore::BufferArray::ptr_t(new LLCore::BufferArray(), false); + LLCore::BufferArray::ptr_t body = LLCore::BufferArray::ptr_t(new LLCore::BufferArray()); // TODO: See if there is a way to serialize to a preallocated buffer I'm // not fond of the copy here. -- cgit v1.2.3 From 45ddc6e91da8e48a21fac1d317e66524db304a17 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Mon, 29 Jun 2015 23:14:45 -0400 Subject: MAINT-5200: Correct new LLCore::HttpHeaders::ptr_t usage. The convention about how to construct an HttpHeaders::ptr_t has changed. Change new code to adapt to merged changes. --- indra/newview/llfacebookconnect.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index 59827c581c..87d7aacda1 100755 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -70,7 +70,7 @@ void toast_user_for_facebook_success() LLCore::HttpHeaders::ptr_t get_headers() { - LLCore::HttpHeaders::ptr_t httpHeaders(new LLCore::HttpHeaders, false); + LLCore::HttpHeaders::ptr_t httpHeaders(new LLCore::HttpHeaders); // The DebugSlshareLogTag mechanism is intended to trigger slshare-service // debug logging. slshare-service is coded to respond to an X-debug-tag // header by engaging debug logging for that request only. This way a -- cgit v1.2.3 From ddb63e7fb70eefea200fbb385efe86e50e5c1e12 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 30 Jun 2015 17:11:10 -0700 Subject: Initial checkin for uploading via coroutine. --- indra/llcommon/llstring.h | 2 + indra/newview/CMakeLists.txt | 2 + indra/newview/llcoproceduremanager.h | 8 +- indra/newview/llfloaterbvhpreview.cpp | 18 +- indra/newview/llsnapshotlivepreview.cpp | 18 +- indra/newview/llviewerassetupload.cpp | 138 ++++++++++++ indra/newview/llviewerassetupload.h | 50 +++++ indra/newview/llviewermenufile.cpp | 386 ++++++++++++++------------------ indra/newview/llviewermenufile.h | 136 +++++++++-- 9 files changed, 514 insertions(+), 244 deletions(-) create mode 100644 indra/newview/llviewerassetupload.cpp create mode 100644 indra/newview/llviewerassetupload.h (limited to 'indra') diff --git a/indra/llcommon/llstring.h b/indra/llcommon/llstring.h index 0177f48bf5..393f6d7a8c 100755 --- a/indra/llcommon/llstring.h +++ b/indra/llcommon/llstring.h @@ -1394,6 +1394,7 @@ BOOL LLStringUtilBase::containsNonprintable(const string_type& string) return rv; } +// *TODO: reimplement in terms of algorithm //static template void LLStringUtilBase::stripNonprintable(string_type& string) @@ -1427,6 +1428,7 @@ void LLStringUtilBase::stripNonprintable(string_type& string) delete []c_string; } +// *TODO: reimplement in terms of algorithm template std::basic_string LLStringUtilBase::quote(const string_type& str, const string_type& triggers, diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 9b3324700a..e2ee32d1e7 100755 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -603,6 +603,7 @@ set(viewer_SOURCE_FILES llviewerassetstats.cpp llviewerassetstorage.cpp llviewerassettype.cpp + llviewerassetupload.cpp llviewerattachmenu.cpp llvieweraudio.cpp llviewercamera.cpp @@ -1197,6 +1198,7 @@ set(viewer_HEADER_FILES llviewerassetstats.h llviewerassetstorage.h llviewerassettype.h + llviewerassetupload.h llviewerattachmenu.h llvieweraudio.h llviewercamera.h diff --git a/indra/newview/llcoproceduremanager.h b/indra/newview/llcoproceduremanager.h index e84eba2db9..4e971d42e3 100644 --- a/indra/newview/llcoproceduremanager.h +++ b/indra/newview/llcoproceduremanager.h @@ -25,8 +25,8 @@ * $/LicenseInfo$ */ -#ifndef LL_UPLOAD_MANAGER_H -#define LL_UPLOAD_MANAGER_H +#ifndef LL_COPROCEDURE_MANAGER_H +#define LL_COPROCEDURE_MANAGER_H #include "lleventcoro.h" #include "llcoros.h" @@ -38,6 +38,7 @@ class LLCoprocedureManager : public LLSingleton < LLCoprocedureManager > public: typedef boost::function CoProcedure_t; + LLCoprocedureManager(); virtual ~LLCoprocedureManager(); /// Places the coprocedure on the queue for processing. @@ -78,9 +79,6 @@ public: return countPending() + countActive(); } -protected: - LLCoprocedureManager(); - private: struct QueuedCoproc { diff --git a/indra/newview/llfloaterbvhpreview.cpp b/indra/newview/llfloaterbvhpreview.cpp index 669ffa7c59..edc1421588 100755 --- a/indra/newview/llfloaterbvhpreview.cpp +++ b/indra/newview/llfloaterbvhpreview.cpp @@ -992,10 +992,20 @@ void LLFloaterBvhPreview::onBtnOK(void* userdata) { std::string name = floaterp->getChild("name_form")->getValue().asString(); std::string desc = floaterp->getChild("description_form")->getValue().asString(); - LLAssetStorage::LLStoreAssetCallback callback = NULL; S32 expected_upload_cost = LLGlobalEconomy::Singleton::getInstance()->getPriceUpload(); - void *userdata = NULL; - upload_new_resource(floaterp->mTransactionID, // tid +#if 1 + NewResourceUploadInfo::ptr_t assetUpdloadInfo(new NewResourceUploadInfo(name, desc, 0, + LLFolderType::FT_NONE, LLInventoryType::IT_ANIMATION, + LLFloaterPerms::getNextOwnerPerms("Uploads"), LLFloaterPerms::getGroupPerms("Uploads"), LLFloaterPerms::getEveryonePerms("Uploads"), + name, expected_upload_cost)); + + upload_new_resource(floaterp->mTransactionID, LLAssetType::AT_ANIMATION, + assetUpdloadInfo); +#else + LLAssetStorage::LLStoreAssetCallback callback = NULL; + void *userdata = NULL; + + upload_new_resource(floaterp->mTransactionID, // tid LLAssetType::AT_ANIMATION, name, desc, @@ -1005,7 +1015,7 @@ void LLFloaterBvhPreview::onBtnOK(void* userdata) LLFloaterPerms::getNextOwnerPerms("Uploads"), LLFloaterPerms::getGroupPerms("Uploads"), LLFloaterPerms::getEveryonePerms("Uploads"), name, callback, expected_upload_cost, userdata); - +#endif } else { diff --git a/indra/newview/llsnapshotlivepreview.cpp b/indra/newview/llsnapshotlivepreview.cpp index 0ae8a338e0..bbf560f3fa 100644 --- a/indra/newview/llsnapshotlivepreview.cpp +++ b/indra/newview/llsnapshotlivepreview.cpp @@ -1004,9 +1004,22 @@ void LLSnapshotLivePreview::saveTexture() LLAgentUI::buildLocationString(pos_string, LLAgentUI::LOCATION_FORMAT_FULL); std::string who_took_it; LLAgentUI::buildFullname(who_took_it); - LLAssetStorage::LLStoreAssetCallback callback = NULL; S32 expected_upload_cost = LLGlobalEconomy::Singleton::getInstance()->getPriceUpload(); - void *userdata = NULL; +#if 1 + std::string name = "Snapshot: " + pos_string; + std::string desc = "Taken by " + who_took_it + " at " + pos_string; + + NewResourceUploadInfo::ptr_t assetUploadInfo(new NewResourceUploadInfo(name, desc, 0, + LLFolderType::FT_SNAPSHOT_CATEGORY, LLInventoryType::IT_SNAPSHOT, + PERM_ALL, LLFloaterPerms::getGroupPerms("Uploads"), LLFloaterPerms::getEveryonePerms("Uploads"), + name, expected_upload_cost)); + + upload_new_resource(tid, LLAssetType::AT_TEXTURE, assetUploadInfo); + +#else + LLAssetStorage::LLStoreAssetCallback callback = NULL; + void *userdata = NULL; + upload_new_resource(tid, // tid LLAssetType::AT_TEXTURE, "Snapshot : " + pos_string, @@ -1019,6 +1032,7 @@ void LLSnapshotLivePreview::saveTexture() LLFloaterPerms::getEveryonePerms("Uploads"), "Snapshot : " + pos_string, callback, expected_upload_cost, userdata); +#endif gViewerWindow->playSnapshotAnimAndSound(); } else diff --git a/indra/newview/llviewerassetupload.cpp b/indra/newview/llviewerassetupload.cpp new file mode 100644 index 0000000000..3f21cf2b7e --- /dev/null +++ b/indra/newview/llviewerassetupload.cpp @@ -0,0 +1,138 @@ +/** +* @file llviewerassetupload.cpp +* @author optional +* @brief brief description of the file +* +* $LicenseInfo:firstyear=2011&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2011, Linden Research, Inc. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; +* version 2.1 of the License only. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA +* $/LicenseInfo$ +*/ + +#include "llviewerprecompiledheaders.h" + +#include "linden_common.h" +#include "llviewerassetupload.h" +#include "llviewertexturelist.h" +#include "llimage.h" +#include "lltrans.h" +#include "lluuid.h" +#include "llvorbisencode.h" +#include "lluploaddialog.h" +#include "lleconomy.h" + +//========================================================================= +/*static*/ +void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoros::self &self, LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &httpAdapter, const LLUUID &id, + std::string url, NewResourceUploadInfo::ptr_t uploadInfo) +{ + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + + uploadInfo->prepareUpload(); + uploadInfo->logPreparedUpload(); + + std::string uploadMessage = "Uploading...\n\n"; + uploadMessage.append(uploadInfo->getDisplayName()); + LLUploadDialog::modalUploadDialog(uploadMessage); + + LLSD body = uploadInfo->generatePostBody(); + + LLSD result = httpAdapter->postAndYield(self, httpRequest, url, body); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + + if (!status) + { + + } + + std::string uploader = result["uploader"].asString(); + + result = httpAdapter->postFileAndYield(self, httpRequest, uploader, uploadInfo->getAssetId(), uploadInfo->getAssetType()); + + if (!status) + { + + } + + S32 expected_upload_cost = 0; + + // Update L$ and ownership credit information + // since it probably changed on the server + if (uploadInfo->getAssetType() == LLAssetType::AT_TEXTURE || + uploadInfo->getAssetType() == LLAssetType::AT_SOUND || + uploadInfo->getAssetType() == LLAssetType::AT_ANIMATION || + uploadInfo->getAssetType() == LLAssetType::AT_MESH) + { + expected_upload_cost = + LLGlobalEconomy::Singleton::getInstance()->getPriceUpload(); + } + + on_new_single_inventory_upload_complete( + uploadInfo->getAssetType(), + uploadInfo->getInventoryType(), + uploadInfo->getAssetTypeString(), // note the paramert calls for inv_type string... + uploadInfo->getFolderId(), + uploadInfo->getName(), + uploadInfo->getDescription(), + result, + expected_upload_cost); + +#if 0 + + LLSD initalBody = generate_new_resource_upload_capability_body(); + + + + LLSD result = httpAdapter->postAndYield(self, httpRequest, url, initalBody); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + + if (!status) + { + + } + + std::string state = result["state"].asString(); + + if (state == "upload") + { +// Upload the file... + result = httpAdapter->postFileAndYield(self, httpRequest, url, initalBody); + + httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + + state = result["state"].asString(); + } + + if (state == "complete") + { + // done with the upload. + } + else + { + // an error occurred + } +#endif +} + +//========================================================================= diff --git a/indra/newview/llviewerassetupload.h b/indra/newview/llviewerassetupload.h new file mode 100644 index 0000000000..c80a7617e1 --- /dev/null +++ b/indra/newview/llviewerassetupload.h @@ -0,0 +1,50 @@ +/** +* @file llviewerassetupload.h +* @author optional +* @brief brief description of the file +* +* $LicenseInfo:firstyear=2011&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2011, Linden Research, Inc. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; +* version 2.1 of the License only. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA +* $/LicenseInfo$ +*/ + +#ifndef LL_VIEWER_ASSET_UPLOAD_H +#define LL_VIEWER_ASSET_UPLOAD_H + +#include "llfoldertype.h" +#include "llassettype.h" +#include "llinventorytype.h" +#include "lleventcoro.h" +#include "llcoros.h" +#include "llcorehttputil.h" + +#include "llviewermenufile.h" + +class LLViewerAssetUpload +{ +public: + + static void AssetInventoryUploadCoproc(LLCoros::self &self, LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &httpAdapter, const LLUUID &id, + std::string url, NewResourceUploadInfo::ptr_t uploadInfo); + + +}; + +#endif // !VIEWER_ASSET_UPLOAD_H diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index f8e50ba463..7bcf241d5e 100755 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -62,6 +62,8 @@ #include "lluploaddialog.h" #include "lltrans.h" #include "llfloaterbuycurrency.h" +#include "llcoproceduremanager.h" +#include "llviewerassetupload.h" // linden libraries #include "llassetuploadresponders.h" @@ -621,6 +623,7 @@ void handle_compress_image(void*) } } + LLUUID upload_new_resource( const std::string& src_filename, std::string name, @@ -704,123 +707,6 @@ LLUUID upload_new_resource( return LLUUID(); } } - else if(exten == "tmp") - { - // This is a generic .lin resource file - asset_type = LLAssetType::AT_OBJECT; - LLFILE* in = LLFile::fopen(src_filename, "rb"); /* Flawfinder: ignore */ - if (in) - { - // read in the file header - char buf[16384]; /* Flawfinder: ignore */ - size_t readbytes; - S32 version; - if (fscanf(in, "LindenResource\nversion %d\n", &version)) - { - if (2 == version) - { - // *NOTE: This buffer size is hard coded into scanf() below. - char label[MAX_STRING]; /* Flawfinder: ignore */ - char value[MAX_STRING]; /* Flawfinder: ignore */ - S32 tokens_read; - while (fgets(buf, 1024, in)) - { - label[0] = '\0'; - value[0] = '\0'; - tokens_read = sscanf( /* Flawfinder: ignore */ - buf, - "%254s %254s\n", - label, value); - - LL_INFOS() << "got: " << label << " = " << value - << LL_ENDL; - - if (EOF == tokens_read) - { - fclose(in); - error_message = llformat("corrupt resource file: %s", src_filename.c_str()); - args["FILE"] = src_filename; - upload_error(error_message, "CorruptResourceFile", filename, args); - return LLUUID(); - } - - if (2 == tokens_read) - { - if (! strcmp("type", label)) - { - asset_type = (LLAssetType::EType)(atoi(value)); - } - } - else - { - if (! strcmp("_DATA_", label)) - { - // below is the data section - break; - } - } - // other values are currently discarded - } - - } - else - { - fclose(in); - error_message = llformat("unknown linden resource file version in file: %s", src_filename.c_str()); - args["FILE"] = src_filename; - upload_error(error_message, "UnknownResourceFileVersion", filename, args); - return LLUUID(); - } - } - else - { - // this is an original binary formatted .lin file - // start over at the beginning of the file - fseek(in, 0, SEEK_SET); - - const S32 MAX_ASSET_DESCRIPTION_LENGTH = 256; - const S32 MAX_ASSET_NAME_LENGTH = 64; - S32 header_size = 34 + MAX_ASSET_DESCRIPTION_LENGTH + MAX_ASSET_NAME_LENGTH; - S16 type_num; - - // read in and throw out most of the header except for the type - if (fread(buf, header_size, 1, in) != 1) - { - LL_WARNS() << "Short read" << LL_ENDL; - } - memcpy(&type_num, buf + 16, sizeof(S16)); /* Flawfinder: ignore */ - asset_type = (LLAssetType::EType)type_num; - } - - // copy the file's data segment into another file for uploading - LLFILE* out = LLFile::fopen(filename, "wb"); /* Flawfinder: ignore */ - if (out) - { - while((readbytes = fread(buf, 1, 16384, in))) /* Flawfinder: ignore */ - { - if (fwrite(buf, 1, readbytes, out) != readbytes) - { - LL_WARNS() << "Short write" << LL_ENDL; - } - } - fclose(out); - } - else - { - fclose(in); - error_message = llformat( "Unable to create output file: %s", filename.c_str()); - args["FILE"] = filename; - upload_error(error_message, "UnableToCreateOutputFile", filename, args); - return LLUUID(); - } - - fclose(in); - } - else - { - LL_INFOS() << "Couldn't open .lin file " << src_filename << LL_ENDL; - } - } else if (exten == "bvh") { error_message = llformat("We do not currently support bulk upload of animation files\n"); @@ -876,6 +762,17 @@ LLUUID upload_new_resource( { t_disp_name = src_filename; } + +#if 1 + NewResourceUploadInfo::ptr_t uploadInfo(new NewResourceUploadInfo( + name, desc, compression_info, + destination_folder_type, inv_type, + next_owner_perms, group_perms, everyone_perms, + display_name, expected_upload_cost)); + + upload_new_resource(tid, asset_type, uploadInfo, + callback, userdata); +#else upload_new_resource( tid, asset_type, @@ -891,6 +788,7 @@ LLUUID upload_new_resource( callback, expected_upload_cost, userdata); +#endif } else { @@ -1035,6 +933,7 @@ void upload_done_callback( } } +#if 0 static LLAssetID upload_new_resource_prep( const LLTransactionID& tid, LLAssetType::EType asset_type, @@ -1056,7 +955,9 @@ static LLAssetID upload_new_resource_prep( return uuid; } +#endif +#if 0 LLSD generate_new_resource_upload_capability_body( LLAssetType::EType asset_type, const std::string& name, @@ -1084,140 +985,81 @@ LLSD generate_new_resource_upload_capability_body( return body; } +#endif void upload_new_resource( - const LLTransactionID &tid, - LLAssetType::EType asset_type, - std::string name, - std::string desc, - S32 compression_info, - LLFolderType::EType destination_folder_type, - LLInventoryType::EType inv_type, - U32 next_owner_perms, - U32 group_perms, - U32 everyone_perms, - const std::string& display_name, - LLAssetStorage::LLStoreAssetCallback callback, - S32 expected_upload_cost, - void *userdata) + const LLTransactionID &tid, + LLAssetType::EType assetType, + NewResourceUploadInfo::ptr_t &uploadInfo, + LLAssetStorage::LLStoreAssetCallback callback, + void *userdata) { if(gDisconnected) { return ; } - - LLAssetID uuid = - upload_new_resource_prep( - tid, - asset_type, - inv_type, - name, - display_name, - desc); - - if( LLAssetType::AT_SOUND == asset_type ) - { - add(LLStatViewer::UPLOAD_SOUND, 1); - } - else - if( LLAssetType::AT_TEXTURE == asset_type ) - { - add(LLStatViewer::UPLOAD_TEXTURE, 1); - } - else - if( LLAssetType::AT_ANIMATION == asset_type) - { - add(LLStatViewer::ANIMATION_UPLOADS, 1); - } - if(LLInventoryType::IT_NONE == inv_type) - { - inv_type = LLInventoryType::defaultForAssetType(asset_type); - } - LLStringUtil::stripNonprintable(name); - LLStringUtil::stripNonprintable(desc); - if(name.empty()) - { - name = "(No Name)"; - } - if(desc.empty()) - { - desc = "(No Description)"; - } - - // At this point, we're ready for the upload. - std::string upload_message = "Uploading...\n\n"; - upload_message.append(display_name); - LLUploadDialog::modalUploadDialog(upload_message); + uploadInfo->setAssetType(assetType); + uploadInfo->setTransactionId(tid); - LL_INFOS() << "*** Uploading: " << LL_ENDL; - LL_INFOS() << "Type: " << LLAssetType::lookup(asset_type) << LL_ENDL; - LL_INFOS() << "UUID: " << uuid << LL_ENDL; - LL_INFOS() << "Name: " << name << LL_ENDL; - LL_INFOS() << "Desc: " << desc << LL_ENDL; - LL_INFOS() << "Expected Upload Cost: " << expected_upload_cost << LL_ENDL; - LL_DEBUGS() << "Folder: " << gInventory.findCategoryUUIDForType((destination_folder_type == LLFolderType::FT_NONE) ? LLFolderType::assetTypeToFolderType(asset_type) : destination_folder_type) << LL_ENDL; - LL_DEBUGS() << "Asset Type: " << LLAssetType::lookup(asset_type) << LL_ENDL; - std::string url = gAgent.getRegion()->getCapability( - "NewFileAgentInventory"); + std::string url = gAgent.getRegion()->getCapability("NewFileAgentInventory"); if ( !url.empty() ) { - LL_INFOS() << "New Agent Inventory via capability" << LL_ENDL; - - LLSD body; - body = generate_new_resource_upload_capability_body( - asset_type, - name, - desc, - destination_folder_type, - inv_type, - next_owner_perms, - group_perms, - everyone_perms); - - LLHTTPClient::post( - url, - body, - new LLNewAgentInventoryResponder( - body, - uuid, - asset_type)); + LLCoprocedureManager::CoProcedure_t proc = boost::bind(&LLViewerAssetUpload::AssetInventoryUploadCoproc, _1, _2, _3, url, uploadInfo); + + LLCoprocedureManager::getInstance()->enqueueCoprocedure("LLViewerAssetUpload::AssetInventoryUploadCoproc", proc); +// LL_INFOS() << "New Agent Inventory via capability" << LL_ENDL; +// uploadInfo->prepareUpload(); +// uploadInfo->logPreparedUpload(); +// +// LLSD body = uploadInfo->generatePostBody(); +// +// LLHTTPClient::post( +// url, +// body, +// new LLNewAgentInventoryResponder( +// body, +// uploadInfo->getAssetId(), +// assetType)); } else { + uploadInfo->prepareUpload(); + uploadInfo->logPreparedUpload(); + LL_INFOS() << "NewAgentInventory capability not found, new agent inventory via asset system." << LL_ENDL; // check for adequate funds // TODO: do this check on the sim - if (LLAssetType::AT_SOUND == asset_type || - LLAssetType::AT_TEXTURE == asset_type || - LLAssetType::AT_ANIMATION == asset_type) + if (LLAssetType::AT_SOUND == assetType || + LLAssetType::AT_TEXTURE == assetType || + LLAssetType::AT_ANIMATION == assetType) { S32 balance = gStatusBar->getBalance(); - if (balance < expected_upload_cost) + if (balance < uploadInfo->getExpectedUploadCost()) { // insufficient funds, bail on this upload LLStringUtil::format_map_t args; - args["NAME"] = name; - args["AMOUNT"] = llformat("%d", expected_upload_cost); - LLBuyCurrencyHTML::openCurrencyFloater( LLTrans::getString("UploadingCosts", args), expected_upload_cost ); + args["NAME"] = uploadInfo->getName(); + args["AMOUNT"] = llformat("%d", uploadInfo->getExpectedUploadCost()); + LLBuyCurrencyHTML::openCurrencyFloater(LLTrans::getString("UploadingCosts", args), uploadInfo->getExpectedUploadCost()); return; } } LLResourceData* data = new LLResourceData; data->mAssetInfo.mTransactionID = tid; - data->mAssetInfo.mUuid = uuid; - data->mAssetInfo.mType = asset_type; + data->mAssetInfo.mUuid = uploadInfo->getAssetId(); + data->mAssetInfo.mType = assetType; data->mAssetInfo.mCreatorID = gAgentID; - data->mInventoryType = inv_type; - data->mNextOwnerPerm = next_owner_perms; - data->mExpectedUploadCost = expected_upload_cost; + data->mInventoryType = uploadInfo->getInventoryType(); + data->mNextOwnerPerm = uploadInfo->getNextOwnerPerms(); + data->mExpectedUploadCost = uploadInfo->getExpectedUploadCost(); data->mUserData = userdata; - data->mAssetInfo.setName(name); - data->mAssetInfo.setDescription(desc); - data->mPreferredLocation = destination_folder_type; + data->mAssetInfo.setName(uploadInfo->getName()); + data->mAssetInfo.setDescription(uploadInfo->getDescription()); + data->mPreferredLocation = uploadInfo->getDestinationFolderType(); LLAssetStorage::LLStoreAssetCallback asset_callback = &upload_done_callback; if (callback) @@ -1233,6 +1075,7 @@ void upload_new_resource( } } +#if 0 LLAssetID generate_asset_id_for_new_upload(const LLTransactionID& tid) { if ( gDisconnected ) @@ -1292,6 +1135,7 @@ void assign_defaults_and_show_upload_message( upload_message.append(display_name); LLUploadDialog::modalUploadDialog(upload_message); } +#endif void init_menu_file() @@ -1315,3 +1159,107 @@ void init_menu_file() // "File.SaveTexture" moved to llpanelmaininventory so that it can be properly handled. } + +LLAssetID NewResourceUploadInfo::prepareUpload() +{ + LLAssetID uuid = generateNewAssetId(); + + incrementUploadStats(); + assignDefaults(); + + return uuid; +} + +std::string NewResourceUploadInfo::getAssetTypeString() const +{ + return LLAssetType::lookup(mAssetType); +} + +std::string NewResourceUploadInfo::getInventoryTypeString() const +{ + return LLInventoryType::lookup(mInventoryType); +} + +LLSD NewResourceUploadInfo::generatePostBody() +{ + LLSD body; + + body["folder_id"] = mFolderId; + body["asset_type"] = getAssetTypeString(); + body["inventory_type"] = getInventoryTypeString(); + body["name"] = mName; + body["description"] = mDescription; + body["next_owner_mask"] = LLSD::Integer(mNextOwnerPerms); + body["group_mask"] = LLSD::Integer(mGroupPerms); + body["everyone_mask"] = LLSD::Integer(mEveryonePerms); + + return body; + +} + +void NewResourceUploadInfo::logPreparedUpload() +{ + LL_INFOS() << "*** Uploading: " << std::endl << + "Type: " << LLAssetType::lookup(mAssetType) << std::endl << + "UUID: " << mAssetId.asString() << std::endl << + "Name: " << mName << std::endl << + "Desc: " << mDescription << std::endl << + "Expected Upload Cost: " << mExpectedUploadCost << std::endl << + "Folder: " << mFolderId << std::endl << + "Asset Type: " << LLAssetType::lookup(mAssetType) << LL_ENDL; +} + +LLAssetID NewResourceUploadInfo::generateNewAssetId() +{ + if (gDisconnected) + { + LLAssetID rv; + + rv.setNull(); + return rv; + } + mAssetId = mTransactionId.makeAssetID(gAgent.getSecureSessionID()); + + return mAssetId; +} + +void NewResourceUploadInfo::incrementUploadStats() const +{ + if (LLAssetType::AT_SOUND == mAssetType) + { + add(LLStatViewer::UPLOAD_SOUND, 1); + } + else if (LLAssetType::AT_TEXTURE == mAssetType) + { + add(LLStatViewer::UPLOAD_TEXTURE, 1); + } + else if (LLAssetType::AT_ANIMATION == mAssetType) + { + add(LLStatViewer::ANIMATION_UPLOADS, 1); + } +} + +void NewResourceUploadInfo::assignDefaults() +{ + if (LLInventoryType::IT_NONE == mInventoryType) + { + mInventoryType = LLInventoryType::defaultForAssetType(mAssetType); + } + LLStringUtil::stripNonprintable(mName); + LLStringUtil::stripNonprintable(mDescription); + + if (mName.empty()) + { + mName = "(No Name)"; + } + if (mDescription.empty()) + { + mDescription = "(No Description)"; + } + + mFolderId = gInventory.findCategoryUUIDForType( + (mDestinationFolderType == LLFolderType::FT_NONE) ? + (LLFolderType::EType)mAssetType : mDestinationFolderType); + +} + diff --git a/indra/newview/llviewermenufile.h b/indra/newview/llviewermenufile.h index 3034d00b22..76704e8edd 100755 --- a/indra/newview/llviewermenufile.h +++ b/indra/newview/llviewermenufile.h @@ -39,20 +39,126 @@ class LLTransactionID; void init_menu_file(); +#if 1 +class NewResourceUploadInfo +{ +public: + typedef boost::shared_ptr ptr_t; + + NewResourceUploadInfo(std::string name, + std::string description, + S32 compressionInfo, + LLFolderType::EType destinationType, + LLInventoryType::EType inventoryType, + U32 nextOWnerPerms, + U32 groupPerms, + U32 everyonePerms, + std::string displayName, + S32 expectedCost) : + mName(name), + mDescription(description), + mDisplayName(displayName), + mCompressionInfo(compressionInfo), + mNextOwnerPerms(nextOWnerPerms), + mGroupPerms(mGroupPerms), + mEveryonePerms(mEveryonePerms), + mExpectedUploadCost(expectedCost), + mInventoryType(inventoryType), + mDestinationFolderType(destinationType) + { } + + virtual ~NewResourceUploadInfo() + { } + + virtual LLAssetID prepareUpload(); + virtual LLSD generatePostBody(); + virtual void logPreparedUpload(); + + void setAssetType(LLAssetType::EType assetType) { mAssetType = assetType; } + LLAssetType::EType getAssetType() const { return mAssetType; } + std::string getAssetTypeString() const; + void setTransactionId(LLTransactionID transactionId) { mTransactionId = transactionId; } + LLTransactionID getTransactionId() const { return mTransactionId; } + LLUUID getFolderId() const { return mFolderId; } + + LLAssetID getAssetId() const { return mAssetId; } + + std::string getName() const { return mName; }; + std::string getDescription() const { return mDescription; }; + std::string getDisplayName() const { return mDisplayName; }; + S32 getCompressionInfo() const { return mCompressionInfo; }; + U32 getNextOwnerPerms() const { return mNextOwnerPerms; }; + U32 getGroupPerms() const { return mGroupPerms; }; + U32 getEveryonePerms() const { return mEveryonePerms; }; + S32 getExpectedUploadCost() const { return mExpectedUploadCost; }; + LLInventoryType::EType getInventoryType() const { return mInventoryType; }; + std::string getInventoryTypeString() const; + + LLFolderType::EType getDestinationFolderType() const { return mDestinationFolderType; }; + +protected: + LLAssetID generateNewAssetId(); + void incrementUploadStats() const; + virtual void assignDefaults(); + +private: + LLAssetType::EType mAssetType; + std::string mName; + std::string mDescription; + std::string mDisplayName; + S32 mCompressionInfo; + U32 mNextOwnerPerms; + U32 mGroupPerms; + U32 mEveryonePerms; + S32 mExpectedUploadCost; + LLUUID mFolderId; + + LLInventoryType::EType mInventoryType; + LLFolderType::EType mDestinationFolderType; + + LLAssetID mAssetId; + LLTransactionID mTransactionId; +}; + + LLUUID upload_new_resource( - const std::string& src_filename, - std::string name, - std::string desc, - S32 compression_info, - LLFolderType::EType destination_folder_type, - LLInventoryType::EType inv_type, - U32 next_owner_perms, - U32 group_perms, - U32 everyone_perms, - const std::string& display_name, - LLAssetStorage::LLStoreAssetCallback callback, - S32 expected_upload_cost, - void *userdata); + const std::string& src_filename, + std::string name, + std::string desc, + S32 compression_info, + LLFolderType::EType destination_folder_type, + LLInventoryType::EType inv_type, + U32 next_owner_perms, + U32 group_perms, + U32 everyone_perms, + const std::string& display_name, + LLAssetStorage::LLStoreAssetCallback callback, + S32 expected_upload_cost, + void *userdata); + +void upload_new_resource( + const LLTransactionID &tid, + LLAssetType::EType type, + NewResourceUploadInfo::ptr_t &uploadInfo, + LLAssetStorage::LLStoreAssetCallback callback = NULL, + void *userdata = NULL); + + +#else +LLUUID upload_new_resource( + const std::string& src_filename, + std::string name, + std::string desc, + S32 compression_info, + LLFolderType::EType destination_folder_type, + LLInventoryType::EType inv_type, + U32 next_owner_perms, + U32 group_perms, + U32 everyone_perms, + const std::string& display_name, + LLAssetStorage::LLStoreAssetCallback callback, + S32 expected_upload_cost, + void *userdata); void upload_new_resource( const LLTransactionID &tid, @@ -70,9 +176,9 @@ void upload_new_resource( S32 expected_upload_cost, void *userdata); - LLAssetID generate_asset_id_for_new_upload(const LLTransactionID& tid); void increase_new_upload_stats(LLAssetType::EType asset_type); +#endif void assign_defaults_and_show_upload_message( LLAssetType::EType asset_type, LLInventoryType::EType& inventory_type, @@ -80,6 +186,7 @@ void assign_defaults_and_show_upload_message( const std::string& display_name, std::string& description); +#if 0 LLSD generate_new_resource_upload_capability_body( LLAssetType::EType asset_type, const std::string& name, @@ -89,6 +196,7 @@ LLSD generate_new_resource_upload_capability_body( U32 next_owner_perms, U32 group_perms, U32 everyone_perms); +#endif void on_new_single_inventory_upload_complete( LLAssetType::EType asset_type, -- cgit v1.2.3 From f25179f148415763e310b0dd7f91a37dcf4c58c0 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Wed, 1 Jul 2015 11:02:56 -0400 Subject: MAINT-4952: fix NewResourceUploadInfo member initialization list. --- indra/newview/llviewermenufile.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra') diff --git a/indra/newview/llviewermenufile.h b/indra/newview/llviewermenufile.h index 76704e8edd..297895cbf0 100755 --- a/indra/newview/llviewermenufile.h +++ b/indra/newview/llviewermenufile.h @@ -60,8 +60,8 @@ public: mDisplayName(displayName), mCompressionInfo(compressionInfo), mNextOwnerPerms(nextOWnerPerms), - mGroupPerms(mGroupPerms), - mEveryonePerms(mEveryonePerms), + mGroupPerms(groupPerms), + mEveryonePerms(everyonePerms), mExpectedUploadCost(expectedCost), mInventoryType(inventoryType), mDestinationFolderType(destinationType) -- cgit v1.2.3 From 1b80e02b0b99b9bde50efba8bc95788e9057e7b0 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 1 Jul 2015 09:21:12 -0700 Subject: Added header for httpclient to llpanelexperiencepicker. (Will be removed when converted to coroutines) --- indra/newview/llpanelexperiencepicker.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'indra') diff --git a/indra/newview/llpanelexperiencepicker.cpp b/indra/newview/llpanelexperiencepicker.cpp index 70d826a407..c7a353a6af 100644 --- a/indra/newview/llpanelexperiencepicker.cpp +++ b/indra/newview/llpanelexperiencepicker.cpp @@ -42,6 +42,7 @@ #include "llviewercontrol.h" #include "llfloater.h" #include "lltrans.h" +#include "llhttpclient.h" // *TODO: Rider, remove when converting #define BTN_FIND "find" #define BTN_OK "ok_btn" -- cgit v1.2.3 From 41dff76327feffed798c8b24673885bc9ad61005 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Wed, 1 Jul 2015 14:04:23 -0400 Subject: MAINT-5351: Remove Boost Preprocessor headers from llcoros.h. These were used in a former iteration (when we explicitly forwarded parameters), but are no longer needed. --- indra/llcommon/llcoros.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'indra') diff --git a/indra/llcommon/llcoros.h b/indra/llcommon/llcoros.h index 01ee11da1a..f07539ac54 100755 --- a/indra/llcommon/llcoros.h +++ b/indra/llcommon/llcoros.h @@ -33,9 +33,6 @@ #include "llsingleton.h" #include #include -#include -#include -#include #include /** -- cgit v1.2.3 From b262ded7e0cf21314524bf702b0e4fe28a3c3060 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Wed, 1 Jul 2015 18:33:29 -0400 Subject: MAINT-5351: Remove 'self' parameter from coroutine functions. lleventcoro_test.cpp runs clean (as modified for new API), and all the rest builds clean, but the resulting viewer is as yet untested. --- indra/llcommon/llcoros.cpp | 86 +++++++++- indra/llcommon/llcoros.h | 64 ++++---- indra/llcommon/lleventcoro.cpp | 113 +++++++++++-- indra/llcommon/lleventcoro.h | 176 ++++----------------- indra/llcommon/tests/lleventcoro_test.cpp | 174 ++++++++------------ indra/llmessage/llavatarnamecache.cpp | 12 +- indra/llmessage/llcorehttputil.cpp | 72 ++++----- indra/llmessage/llcorehttputil.h | 66 ++++---- indra/newview/llaccountingcostmanager.cpp | 8 +- indra/newview/llaccountingcostmanager.h | 2 +- indra/newview/llavatarrenderinfoaccountant.cpp | 12 +- indra/newview/llavatarrenderinfoaccountant.h | 4 +- indra/newview/llcoproceduremanager.cpp | 8 +- indra/newview/llcoproceduremanager.h | 4 +- indra/newview/llestateinfomodel.cpp | 6 +- indra/newview/llestateinfomodel.h | 2 +- indra/newview/lleventpoll.cpp | 10 +- indra/newview/llfacebookconnect.cpp | 46 +++--- indra/newview/llfacebookconnect.h | 14 +- indra/newview/llfeaturemanager.cpp | 6 +- indra/newview/llfeaturemanager.h | 2 +- indra/newview/llflickrconnect.cpp | 36 ++--- indra/newview/llflickrconnect.h | 12 +- indra/newview/llfloateravatarpicker.cpp | 6 +- indra/newview/llfloateravatarpicker.h | 2 +- indra/newview/llfloatermodeluploadbase.cpp | 6 +- indra/newview/llfloatermodeluploadbase.h | 2 +- indra/newview/llfloaterperms.cpp | 6 +- indra/newview/llfloaterperms.h | 2 +- indra/newview/llfloaterscriptlimits.cpp | 24 +-- indra/newview/llfloaterscriptlimits.h | 8 +- indra/newview/llfloatertos.cpp | 6 +- indra/newview/llfloatertos.h | 2 +- indra/newview/llfloaterurlentry.cpp | 6 +- indra/newview/llfloaterurlentry.h | 2 +- indra/newview/llgroupmgr.cpp | 20 +-- indra/newview/llgroupmgr.h | 6 +- indra/newview/llimview.cpp | 20 +-- indra/newview/llinventorymodel.cpp | 6 +- indra/newview/llinventorymodel.h | 2 +- indra/newview/llmarketplacefunctions.cpp | 14 +- indra/newview/llpathfindingmanager.cpp | 46 +++--- indra/newview/llpathfindingmanager.h | 12 +- indra/newview/llproductinforequest.cpp | 6 +- indra/newview/llproductinforequest.h | 2 +- indra/newview/llremoteparcelrequest.cpp | 6 +- indra/newview/llremoteparcelrequest.h | 2 +- indra/newview/llspeakers.cpp | 10 +- indra/newview/llspeakers.h | 2 +- indra/newview/llsyntaxid.cpp | 6 +- indra/newview/llsyntaxid.h | 2 +- indra/newview/lltwitterconnect.cpp | 38 ++--- indra/newview/lltwitterconnect.h | 12 +- indra/newview/llviewerassetupload.cpp | 10 +- indra/newview/llviewerassetupload.h | 2 +- indra/newview/llviewermedia.cpp | 18 +-- indra/newview/llviewermedia.h | 6 +- indra/newview/llviewermenufile.cpp | 2 +- indra/newview/llviewerobjectlist.cpp | 12 +- indra/newview/llviewerobjectlist.h | 4 +- indra/newview/llviewerregion.cpp | 24 +-- indra/newview/llvoavatarself.cpp | 6 +- indra/newview/llvoavatarself.h | 2 +- indra/newview/llvoicechannel.cpp | 6 +- indra/newview/llvoicechannel.h | 2 +- indra/newview/llvoicevivox.cpp | 12 +- indra/newview/llvoicevivox.h | 4 +- indra/newview/llwebprofile.cpp | 10 +- indra/newview/llwebprofile.h | 2 +- indra/newview/llwlhandlers.cpp | 12 +- indra/newview/llwlhandlers.h | 4 +- indra/viewer_components/login/lllogin.cpp | 17 +- .../viewer_components/updater/llupdatechecker.cpp | 6 +- indra/viewer_components/updater/llupdatechecker.h | 2 +- 74 files changed, 692 insertions(+), 690 deletions(-) (limited to 'indra') diff --git a/indra/llcommon/llcoros.cpp b/indra/llcommon/llcoros.cpp index baaddcaed1..2d0c419ae0 100755 --- a/indra/llcommon/llcoros.cpp +++ b/indra/llcommon/llcoros.cpp @@ -34,11 +34,65 @@ // std headers // external library headers #include +#include // other Linden headers #include "llevents.h" #include "llerror.h" #include "stringize.h" +namespace { + +// do nothing, when we need nothing done +void no_cleanup(LLCoros::coro::self*) {} + +// When the dcoroutine library calls a top-level callable, it implicitly +// passes coro::self& as the first parameter. All our consumer code used to +// explicitly pass coro::self& down through all levels of call stack, because +// at the leaf level we need it for context-switching. But since coroutines +// are based on cooperative switching, we can cause the top-level entry point +// to stash a static pointer to the currently-running coroutine, and manage it +// appropriately as we switch out and back in. That eliminates the need to +// pass it as an explicit parameter down through every level, which is +// unfortunately viral in nature. Finding it implicitly rather than explicitly +// allows minor maintenance in which a leaf-level function adds a new async +// I/O call that suspends the calling coroutine, WITHOUT having to propagate +// coro::self& through every function signature down to that point -- and of +// course through every other caller of every such function. +// We use a boost::thread_specific_ptr because each thread potentially has its +// own distinct pool of coroutines. +// This thread_specific_ptr does NOT own the 'self' object! It merely +// identifies it. For this reason we instantiate it with a no-op cleanup +// function. +static boost::thread_specific_ptr +sCurrentSelf(no_cleanup); + +} // anonymous + +//static +LLCoros::coro::self& LLCoros::get_self() +{ + coro::self* current_self = sCurrentSelf.get(); + if (! current_self) + { + LL_ERRS("LLCoros") << "Calling get_self() from non-coroutine context!" << LL_ENDL; + } + return *current_self; +} + +LLCoros::Suspending::Suspending(): + mSuspended(sCurrentSelf.get()) +{ + // For the duration of our time away from this coroutine, sCurrentSelf + // must NOT refer to this coroutine. + sCurrentSelf.reset(); +} + +LLCoros::Suspending::~Suspending() +{ + // Okay, we're back, reinstate previous value of sCurrentSelf. + sCurrentSelf.reset(mSuspended); +} + LLCoros::LLCoros(): // MAINT-2724: default coroutine stack size too small on Windows. // Previously we used @@ -60,7 +114,7 @@ bool LLCoros::cleanup(const LLSD&) // since last tick? if (mi->second->exited()) { - LL_INFOS("LLCoros") << "LLCoros: cleaning up coroutine " << mi->first << LL_ENDL; + LL_INFOS("LLCoros") << "LLCoros: cleaning up coroutine " << mi->first << LL_ENDL; // The erase() call will invalidate its passed iterator value -- // so increment mi FIRST -- but pass its original value to // erase(). This is what postincrement is all about. @@ -94,7 +148,7 @@ std::string LLCoros::generateDistinctName(const std::string& prefix) const { if (mCoros.find(name) == mCoros.end()) { - LL_INFOS("LLCoros") << "LLCoros: launching coroutine " << name << LL_ENDL; + LL_INFOS("LLCoros") << "LLCoros: launching coroutine " << name << LL_ENDL; return name; } } @@ -114,10 +168,10 @@ bool LLCoros::kill(const std::string& name) return true; } -std::string LLCoros::getNameByID(const void* self_id) const +std::string LLCoros::getName() const { - // Walk the existing coroutines, looking for one from which the 'self_id' - // passed to us comes. + // Walk the existing coroutines, looking for the current one. + void* self_id = get_self().get_id(); for (CoroMap::const_iterator mi(mCoros.begin()), mend(mCoros.end()); mi != mend; ++mi) { namespace coro_private = boost::dcoroutines::detail; @@ -136,10 +190,24 @@ void LLCoros::setStackSize(S32 stacksize) mStackSize = stacksize; } +namespace { + +// Top-level wrapper around caller's coroutine callable. This function accepts +// the coroutine library's implicit coro::self& parameter and sets sCurrentSelf +// but does not pass it down to the caller's callable. +void toplevel(LLCoros::coro::self& self, const LLCoros::callable_t& callable) +{ + sCurrentSelf.reset(&self); + callable(); + sCurrentSelf.reset(); +} + +} // anonymous + /***************************************************************************** * MUST BE LAST *****************************************************************************/ -// Turn off MSVC optimizations for just LLCoros::launchImpl() -- see +// Turn off MSVC optimizations for just LLCoros::launch() -- see // DEV-32777. But MSVC doesn't support push/pop for optimization flags as it // does for warning suppression, and we really don't want to force // optimization ON for other code even in Debug or RelWithDebInfo builds. @@ -150,9 +218,13 @@ void LLCoros::setStackSize(S32 stacksize) #pragma optimize("", off) #endif // LL_MSVC -std::string LLCoros::launchImpl(const std::string& prefix, coro* newCoro) +std::string LLCoros::launch(const std::string& prefix, const callable_t& callable) { std::string name(generateDistinctName(prefix)); + // Wrap the caller's callable in our toplevel() function so we can manage + // sCurrentSelf appropriately at startup and shutdown of each coroutine. + coro* newCoro = new coro(boost::bind(toplevel, _1, callable), mStackSize); + // Store it in our pointer map mCoros.insert(name, newCoro); /* Run the coroutine until its first wait, then return here */ (*newCoro)(std::nothrow); diff --git a/indra/llcommon/llcoros.h b/indra/llcommon/llcoros.h index f07539ac54..3f58a17aa9 100755 --- a/indra/llcommon/llcoros.h +++ b/indra/llcommon/llcoros.h @@ -32,6 +32,7 @@ #include #include "llsingleton.h" #include +#include #include #include @@ -77,8 +78,8 @@ class LL_COMMON_API LLCoros: public LLSingleton public: /// Canonical boost::dcoroutines::coroutine signature we use typedef boost::dcoroutines::coroutine coro; - /// Canonical 'self' type - typedef coro::self self; + /// Canonical callable type + typedef boost::function callable_t; /** * Create and start running a new coroutine with specified name. The name @@ -91,39 +92,33 @@ public: * { * public: * ... - * // Do NOT NOT NOT accept reference params other than 'self'! + * // Do NOT NOT NOT accept reference params! * // Pass by value only! - * void myCoroutineMethod(LLCoros::self& self, std::string, LLSD); + * void myCoroutineMethod(std::string, LLSD); * ... * }; * ... * std::string name = LLCoros::instance().launch( - * "mycoro", boost::bind(&MyClass::myCoroutineMethod, this, _1, + * "mycoro", boost::bind(&MyClass::myCoroutineMethod, this, * "somestring", LLSD(17)); * @endcode * - * Your function/method must accept LLCoros::self& as its first parameter. - * It can accept any other parameters you want -- but ONLY BY VALUE! - * Other reference parameters are a BAD IDEA! You Have Been Warned. See + * Your function/method can accept any parameters you want -- but ONLY BY + * VALUE! Reference parameters are a BAD IDEA! You Have Been Warned. See * DEV-32777 comments for an explanation. * - * Pass a callable that accepts the single LLCoros::self& parameter. It - * may work to pass a free function whose only parameter is 'self'; for - * all other cases use boost::bind(). Of course, for a non-static class - * method, the first parameter must be the class instance. Use the - * placeholder _1 for the 'self' parameter. Any other parameters should be - * passed via the bind() expression. + * Pass a nullary callable. It works to directly pass a nullary free + * function (or static method); for all other cases use boost::bind(). Of + * course, for a non-static class method, the first parameter must be the + * class instance. Any other parameters should be passed via the bind() + * expression. * * launch() tweaks the suggested name so it won't collide with any * existing coroutine instance, creates the coroutine instance, registers * it with the tweaked name and runs it until its first wait. At that * point it returns the tweaked name. */ - template - std::string launch(const std::string& prefix, const CALLABLE& callable) - { - return launchImpl(prefix, new coro(callable, mStackSize)); - } + std::string launch(const std::string& prefix, const callable_t& callable); /** * Abort a running coroutine by name. Normally, when a coroutine either @@ -135,27 +130,34 @@ public: bool kill(const std::string& name); /** - * From within a coroutine, pass its @c self object to look up the - * (tweaked) name string by which this coroutine is registered. Returns - * the empty string if not found (e.g. if the coroutine was launched by - * hand rather than using LLCoros::launch()). + * From within a coroutine, look up the (tweaked) name string by which + * this coroutine is registered. Returns the empty string if not found + * (e.g. if the coroutine was launched by hand rather than using + * LLCoros::launch()). */ - template - std::string getName(const COROUTINE_SELF& self) const + std::string getName() const; + + /// get the current coro::self& for those who really really care + static coro::self& get_self(); + + /// Instantiate one of these in a block surrounding any leaf point when + /// control literally switches away from this coroutine. + class Suspending { - return getNameByID(self.get_id()); - } + public: + Suspending(); + ~Suspending(); - /// getName() by self.get_id() - std::string getNameByID(const void* self_id) const; + private: + coro::self* mSuspended; + }; /// for delayed initialization void setStackSize(S32 stacksize); private: - friend class LLSingleton; LLCoros(); - std::string launchImpl(const std::string& prefix, coro* newCoro); + friend class LLSingleton; std::string generateDistinctName(const std::string& prefix) const; bool cleanup(const LLSD&); diff --git a/indra/llcommon/lleventcoro.cpp b/indra/llcommon/lleventcoro.cpp index 81cc33fbba..be93e9c83b 100755 --- a/indra/llcommon/lleventcoro.cpp +++ b/indra/llcommon/lleventcoro.cpp @@ -34,33 +34,24 @@ #include // std headers // external library headers +#include +#include // other Linden headers #include "llsdserialize.h" #include "llerror.h" #include "llcoros.h" -std::string LLEventDetail::listenerNameForCoroImpl(const void* self_id) +std::string LLEventDetail::listenerNameForCoro() { - // First, if this coroutine was launched by LLCoros::launch(), find that name. - std::string name(LLCoros::instance().getNameByID(self_id)); + // If this coroutine was launched by LLCoros::launch(), find that name. + std::string name(LLCoros::instance().getName()); if (! name.empty()) { return name; } - // Apparently this coroutine wasn't launched by LLCoros::launch(). Check - // whether we have a memo for this self_id. - typedef std::map MapType; - static MapType memo; - MapType::const_iterator found = memo.find(self_id); - if (found != memo.end()) - { - // this coroutine instance has called us before, reuse same name - return found->second; - } // this is the first time we've been called for this coroutine instance name = LLEventPump::inventName("coro"); - memo[self_id] = name; - LL_INFOS("LLEventCoro") << "listenerNameForCoroImpl(" << self_id << "): inventing coro name '" + LL_INFOS("LLEventCoro") << "listenerNameForCoro(): inventing coro name '" << name << "'" << LL_ENDL; return name; } @@ -118,6 +109,98 @@ void LLEventDetail::storeToLLSDPath(LLSD& dest, const LLSD& rawPath, const LLSD& *pdest = value; } +LLSD postAndWait(const LLSD& event, const LLEventPumpOrPumpName& requestPump, + const LLEventPumpOrPumpName& replyPump, const LLSD& replyPumpNamePath) +{ + // declare the future + boost::dcoroutines::future future(LLCoros::get_self()); + // make a callback that will assign a value to the future, and listen on + // the specified LLEventPump with that callback + std::string listenerName(LLEventDetail::listenerNameForCoro()); + LLTempBoundListener connection( + replyPump.getPump().listen(listenerName, + voidlistener(boost::dcoroutines::make_callback(future)))); + // skip the "post" part if requestPump is default-constructed + if (requestPump) + { + // If replyPumpNamePath is non-empty, store the replyPump name in the + // request event. + LLSD modevent(event); + LLEventDetail::storeToLLSDPath(modevent, replyPumpNamePath, replyPump.getPump().getName()); + LL_DEBUGS("lleventcoro") << "postAndWait(): coroutine " << listenerName + << " posting to " << requestPump.getPump().getName() + << LL_ENDL; + + // *NOTE:Mani - Removed because modevent could contain user's hashed passwd. + // << ": " << modevent << LL_ENDL; + requestPump.getPump().post(modevent); + } + LL_DEBUGS("lleventcoro") << "postAndWait(): coroutine " << listenerName + << " about to wait on LLEventPump " << replyPump.getPump().getName() + << LL_ENDL; + // trying to dereference ("resolve") the future makes us wait for it + LLSD value; + { + // instantiate Suspending to manage the "current" coroutine + LLCoros::Suspending suspended; + value = *future; + } // destroy Suspending as soon as we're back + LL_DEBUGS("lleventcoro") << "postAndWait(): coroutine " << listenerName + << " resuming with " << value << LL_ENDL; + // returning should disconnect the connection + return value; +} + +LLEventWithID postAndWait2(const LLSD& event, + const LLEventPumpOrPumpName& requestPump, + const LLEventPumpOrPumpName& replyPump0, + const LLEventPumpOrPumpName& replyPump1, + const LLSD& replyPump0NamePath, + const LLSD& replyPump1NamePath) +{ + // declare the future + boost::dcoroutines::future future(LLCoros::get_self()); + // either callback will assign a value to this future; listen on + // each specified LLEventPump with a callback + std::string name(LLEventDetail::listenerNameForCoro()); + LLTempBoundListener connection0( + replyPump0.getPump().listen(name + "a", + LLEventDetail::wfeoh(boost::dcoroutines::make_callback(future), 0))); + LLTempBoundListener connection1( + replyPump1.getPump().listen(name + "b", + LLEventDetail::wfeoh(boost::dcoroutines::make_callback(future), 1))); + // skip the "post" part if requestPump is default-constructed + if (requestPump) + { + // If either replyPumpNamePath is non-empty, store the corresponding + // replyPump name in the request event. + LLSD modevent(event); + LLEventDetail::storeToLLSDPath(modevent, replyPump0NamePath, + replyPump0.getPump().getName()); + LLEventDetail::storeToLLSDPath(modevent, replyPump1NamePath, + replyPump1.getPump().getName()); + LL_DEBUGS("lleventcoro") << "postAndWait2(): coroutine " << name + << " posting to " << requestPump.getPump().getName() + << ": " << modevent << LL_ENDL; + requestPump.getPump().post(modevent); + } + LL_DEBUGS("lleventcoro") << "postAndWait2(): coroutine " << name + << " about to wait on LLEventPumps " << replyPump0.getPump().getName() + << ", " << replyPump1.getPump().getName() << LL_ENDL; + // trying to dereference ("resolve") the future makes us wait for it + LLEventWithID value; + { + // instantiate Suspending to manage "current" coroutine + LLCoros::Suspending suspended; + value = *future; + } // destroy Suspending as soon as we're back + LL_DEBUGS("lleventcoro") << "postAndWait(): coroutine " << name + << " resuming with (" << value.first << ", " << value.second << ")" + << LL_ENDL; + // returning should disconnect both connections + return value; +} + LLSD errorException(const LLEventWithID& result, const std::string& desc) { // If the result arrived on the error pump (pump 1), instead of diff --git a/indra/llcommon/lleventcoro.h b/indra/llcommon/lleventcoro.h index abbeeaa373..daf9360a2e 100755 --- a/indra/llcommon/lleventcoro.h +++ b/indra/llcommon/lleventcoro.h @@ -29,8 +29,6 @@ #if ! defined(LL_LLEVENTCORO_H) #define LL_LLEVENTCORO_H -#include -#include #include #include #include @@ -102,9 +100,6 @@ LLVoidListener voidlistener(const LISTENER& listener) namespace LLEventDetail { - /// Implementation for listenerNameForCoro(), see below - LL_COMMON_API std::string listenerNameForCoroImpl(const void* self_id); - /** * waitForEventOn() permits a coroutine to temporarily listen on an * LLEventPump any number of times. We don't really want to have to ask @@ -116,21 +111,9 @@ namespace LLEventDetail * call waitForEventOn() any number of times, we don't really want to * consume an arbitrary number of generated inventName()s: that namespace, * though large, is nonetheless finite. So we memoize an invented name for - * each distinct coroutine instance (each different 'self' object). We - * can't know the type of 'self', because it depends on the coroutine - * body's signature. So we cast its address to void*, looking for distinct - * pointer values. Yes, that means that an early coroutine could cache a - * value here, then be destroyed, only to be supplanted by a later - * coroutine (of the same or different type), and we'll end up - * "recognizing" the second one and reusing the listener name -- but - * that's okay, since it won't collide with any listener name used by the - * earlier coroutine since that earlier coroutine no longer exists. + * each distinct coroutine instance. */ - template - std::string listenerNameForCoro(COROUTINE_SELF& self) - { - return listenerNameForCoroImpl(self.get_id()); - } + std::string listenerNameForCoro(); /** * Implement behavior described for postAndWait()'s @a replyPumpNamePath @@ -159,7 +142,7 @@ namespace LLEventDetail * convenience: the difference between this function and the sequence * @code * requestPump.post(myEvent); - * LLSD reply = waitForEventOn(self, replyPump); + * LLSD reply = waitForEventOn(replyPump); * @endcode * is that the sequence above fails if the reply is posted immediately on * @a replyPump, that is, before requestPump.post() returns. In the @@ -201,51 +184,16 @@ namespace LLEventDetail * @a replyPumpNamePath specifies the entry in the lowest-level structure in * @a event into which to store replyPump.getName(). */ -template -LLSD postAndWait(SELF& self, const LLSD& event, const LLEventPumpOrPumpName& requestPump, - const LLEventPumpOrPumpName& replyPump, const LLSD& replyPumpNamePath=LLSD()) -{ - // declare the future - boost::dcoroutines::future future(self); - // make a callback that will assign a value to the future, and listen on - // the specified LLEventPump with that callback - std::string listenerName(LLEventDetail::listenerNameForCoro(self)); - LLTempBoundListener connection( - replyPump.getPump().listen(listenerName, - voidlistener(boost::dcoroutines::make_callback(future)))); - // skip the "post" part if requestPump is default-constructed - if (requestPump) - { - // If replyPumpNamePath is non-empty, store the replyPump name in the - // request event. - LLSD modevent(event); - LLEventDetail::storeToLLSDPath(modevent, replyPumpNamePath, replyPump.getPump().getName()); - LL_DEBUGS("lleventcoro") << "postAndWait(): coroutine " << listenerName - << " posting to " << requestPump.getPump().getName() - << LL_ENDL; - - // *NOTE:Mani - Removed because modevent could contain user's hashed passwd. - // << ": " << modevent << LL_ENDL; - requestPump.getPump().post(modevent); - } - LL_DEBUGS("lleventcoro") << "postAndWait(): coroutine " << listenerName - << " about to wait on LLEventPump " << replyPump.getPump().getName() - << LL_ENDL; - // trying to dereference ("resolve") the future makes us wait for it - LLSD value(*future); - LL_DEBUGS("lleventcoro") << "postAndWait(): coroutine " << listenerName - << " resuming with " << value << LL_ENDL; - // returning should disconnect the connection - return value; -} +LLSD postAndWait(const LLSD& event, const LLEventPumpOrPumpName& requestPump, + const LLEventPumpOrPumpName& replyPump, const LLSD& replyPumpNamePath=LLSD()); /// Wait for the next event on the specified LLEventPump. Pass either the /// LLEventPump& or its string name. -template -LLSD waitForEventOn(SELF& self, const LLEventPumpOrPumpName& pump) +inline +LLSD waitForEventOn(const LLEventPumpOrPumpName& pump) { // This is now a convenience wrapper for postAndWait(). - return postAndWait(self, LLSD(), LLEventPumpOrPumpName(), pump); + return postAndWait(LLSD(), LLEventPumpOrPumpName(), pump); } /// return type for two-pump variant of waitForEventOn() @@ -313,7 +261,7 @@ namespace LLEventDetail * I'd have preferred to overload the name postAndWait() for both signatures. * But consider the following ambiguous call: * @code - * postAndWait(self, LLSD(), requestPump, replyPump, "someString"); + * postAndWait(LLSD(), requestPump, replyPump, "someString"); * @endcode * "someString" could be converted to either LLSD (@a replyPumpNamePath for * the single-pump function) or LLEventOrPumpName (@a replyPump1 for two-pump @@ -322,69 +270,29 @@ namespace LLEventDetail * It seems less burdensome to write postAndWait2() than to write either * LLSD("someString") or LLEventOrPumpName("someString"). */ -template -LLEventWithID postAndWait2(SELF& self, const LLSD& event, +LLEventWithID postAndWait2(const LLSD& event, const LLEventPumpOrPumpName& requestPump, const LLEventPumpOrPumpName& replyPump0, const LLEventPumpOrPumpName& replyPump1, const LLSD& replyPump0NamePath=LLSD(), - const LLSD& replyPump1NamePath=LLSD()) -{ - // declare the future - boost::dcoroutines::future future(self); - // either callback will assign a value to this future; listen on - // each specified LLEventPump with a callback - std::string name(LLEventDetail::listenerNameForCoro(self)); - LLTempBoundListener connection0( - replyPump0.getPump().listen(name + "a", - LLEventDetail::wfeoh(boost::dcoroutines::make_callback(future), 0))); - LLTempBoundListener connection1( - replyPump1.getPump().listen(name + "b", - LLEventDetail::wfeoh(boost::dcoroutines::make_callback(future), 1))); - // skip the "post" part if requestPump is default-constructed - if (requestPump) - { - // If either replyPumpNamePath is non-empty, store the corresponding - // replyPump name in the request event. - LLSD modevent(event); - LLEventDetail::storeToLLSDPath(modevent, replyPump0NamePath, - replyPump0.getPump().getName()); - LLEventDetail::storeToLLSDPath(modevent, replyPump1NamePath, - replyPump1.getPump().getName()); - LL_DEBUGS("lleventcoro") << "postAndWait2(): coroutine " << name - << " posting to " << requestPump.getPump().getName() - << ": " << modevent << LL_ENDL; - requestPump.getPump().post(modevent); - } - LL_DEBUGS("lleventcoro") << "postAndWait2(): coroutine " << name - << " about to wait on LLEventPumps " << replyPump0.getPump().getName() - << ", " << replyPump1.getPump().getName() << LL_ENDL; - // trying to dereference ("resolve") the future makes us wait for it - LLEventWithID value(*future); - LL_DEBUGS("lleventcoro") << "postAndWait(): coroutine " << name - << " resuming with (" << value.first << ", " << value.second << ")" - << LL_ENDL; - // returning should disconnect both connections - return value; -} + const LLSD& replyPump1NamePath=LLSD()); /** * Wait for the next event on either of two specified LLEventPumps. */ -template +inline LLEventWithID -waitForEventOn(SELF& self, - const LLEventPumpOrPumpName& pump0, const LLEventPumpOrPumpName& pump1) +waitForEventOn(const LLEventPumpOrPumpName& pump0, const LLEventPumpOrPumpName& pump1) { // This is now a convenience wrapper for postAndWait2(). - return postAndWait2(self, LLSD(), LLEventPumpOrPumpName(), pump0, pump1); + return postAndWait2(LLSD(), LLEventPumpOrPumpName(), pump0, pump1); } /** * Helper for the two-pump variant of waitForEventOn(), e.g.: * * @code - * LLSD reply = errorException(waitForEventOn(self, replyPump, errorPump), + * LLSD reply = errorException(waitForEventOn(replyPump, errorPump), * "error response from login.cgi"); * @endcode * @@ -454,26 +362,16 @@ public: /** * Wait for an event on this LLEventPump. - * - * @note - * The other major usage pattern we considered was to bind @c self at - * LLCoroEventPump construction time, which would avoid passing the - * parameter to each wait() call. But if we were going to bind @c self as - * a class member, we'd need to specify a class template parameter - * indicating its type. The big advantage of passing it to the wait() call - * is that the type can be implicit. */ - template - LLSD wait(SELF& self) + LLSD wait() { - return waitForEventOn(self, mPump); + return ::waitForEventOn(mPump); } - template - LLSD postAndWait(SELF& self, const LLSD& event, const LLEventPumpOrPumpName& requestPump, + LLSD postAndWait(const LLSD& event, const LLEventPumpOrPumpName& requestPump, const LLSD& replyPumpNamePath=LLSD()) { - return ::postAndWait(self, event, requestPump, mPump, replyPumpNamePath); + return ::postAndWait(event, requestPump, mPump, replyPumpNamePath); } private: @@ -509,55 +407,49 @@ public: /// request pump 1 LLEventPump& getPump1() { return mPump1; } - /// waitForEventOn(self, either of our two LLEventPumps) - template - LLEventWithID wait(SELF& self) + /// waitForEventOn(either of our two LLEventPumps) + LLEventWithID wait() { - return waitForEventOn(self, mPump0, mPump1); + return waitForEventOn(mPump0, mPump1); } - /// errorException(wait(self)) - template - LLSD waitWithException(SELF& self) + /// errorException(wait()) + LLSD waitWithException() { - return errorException(wait(self), std::string("Error event on ") + getName1()); + return errorException(wait(), std::string("Error event on ") + getName1()); } - /// errorLog(wait(self)) - template - LLSD waitWithLog(SELF& self) + /// errorLog(wait()) + LLSD waitWithLog() { - return errorLog(wait(self), std::string("Error event on ") + getName1()); + return errorLog(wait(), std::string("Error event on ") + getName1()); } - template - LLEventWithID postAndWait(SELF& self, const LLSD& event, + LLEventWithID postAndWait(const LLSD& event, const LLEventPumpOrPumpName& requestPump, const LLSD& replyPump0NamePath=LLSD(), const LLSD& replyPump1NamePath=LLSD()) { - return postAndWait2(self, event, requestPump, mPump0, mPump1, + return postAndWait2(event, requestPump, mPump0, mPump1, replyPump0NamePath, replyPump1NamePath); } - template - LLSD postAndWaitWithException(SELF& self, const LLSD& event, + LLSD postAndWaitWithException(const LLSD& event, const LLEventPumpOrPumpName& requestPump, const LLSD& replyPump0NamePath=LLSD(), const LLSD& replyPump1NamePath=LLSD()) { - return errorException(postAndWait(self, event, requestPump, + return errorException(postAndWait(event, requestPump, replyPump0NamePath, replyPump1NamePath), std::string("Error event on ") + getName1()); } - template - LLSD postAndWaitWithLog(SELF& self, const LLSD& event, + LLSD postAndWaitWithLog(const LLSD& event, const LLEventPumpOrPumpName& requestPump, const LLSD& replyPump0NamePath=LLSD(), const LLSD& replyPump1NamePath=LLSD()) { - return errorLog(postAndWait(self, event, requestPump, + return errorLog(postAndWait(event, requestPump, replyPump0NamePath, replyPump1NamePath), std::string("Error event on ") + getName1()); } diff --git a/indra/llcommon/tests/lleventcoro_test.cpp b/indra/llcommon/tests/lleventcoro_test.cpp index 2096807e53..31e9856477 100755 --- a/indra/llcommon/tests/lleventcoro_test.cpp +++ b/indra/llcommon/tests/lleventcoro_test.cpp @@ -82,6 +82,7 @@ #include "llevents.h" #include "tests/wrapllerrs.h" #include "stringize.h" +#include "llcoros.h" #include "lleventcoro.h" #include "../test/debug.h" @@ -121,9 +122,6 @@ typedef coroutine match_coroutine_type; /***************************************************************************** * Test helpers *****************************************************************************/ -// I suspect this will be typical of coroutines used in Linden software -typedef boost::dcoroutines::coroutine coroutine_type; - /// Simulate an event API whose response is immediate: sent on receipt of the /// initial request, rather than after some delay. This is the case that /// distinguishes postAndWait() from calling post(), then calling @@ -166,7 +164,7 @@ namespace tut { // Define coroutine bodies as methods here so they can use ensure*() - void explicit_wait(coroutine_type::self& self) + void explicit_wait(boost::dcoroutines::coroutine::self& self) { BEGIN { @@ -187,20 +185,20 @@ namespace tut END } - void waitForEventOn1(coroutine_type::self& self) + void waitForEventOn1() { BEGIN { - result = waitForEventOn(self, "source"); + result = waitForEventOn("source"); } END } - void waitForEventOn2(coroutine_type::self& self) + void waitForEventOn2() { BEGIN { - LLEventWithID pair = waitForEventOn(self, "reply", "error"); + LLEventWithID pair = waitForEventOn("reply", "error"); result = pair.first; which = pair.second; debug(STRINGIZE("result = " << result << ", which = " << which)); @@ -208,12 +206,11 @@ namespace tut END } - void postAndWait1(coroutine_type::self& self) + void postAndWait1() { BEGIN { - result = postAndWait(self, - LLSDMap("value", 17), // request event + result = postAndWait(LLSDMap("value", 17), // request event immediateAPI.getPump(), // requestPump "reply1", // replyPump "reply"); // request["reply"] = name @@ -221,12 +218,11 @@ namespace tut END } - void postAndWait2(coroutine_type::self& self) + void postAndWait2() { BEGIN { - LLEventWithID pair = ::postAndWait2(self, - LLSDMap("value", 18), + LLEventWithID pair = ::postAndWait2(LLSDMap("value", 18), immediateAPI.getPump(), "reply2", "error2", @@ -239,12 +235,11 @@ namespace tut END } - void postAndWait2_1(coroutine_type::self& self) + void postAndWait2_1() { BEGIN { - LLEventWithID pair = ::postAndWait2(self, - LLSDMap("value", 18)("fail", LLSD()), + LLEventWithID pair = ::postAndWait2(LLSDMap("value", 18)("fail", LLSD()), immediateAPI.getPump(), "reply2", "error2", @@ -257,55 +252,55 @@ namespace tut END } - void coroPump(coroutine_type::self& self) + void coroPump() { BEGIN { LLCoroEventPump waiter; replyName = waiter.getName(); - result = waiter.wait(self); + result = waiter.wait(); } END } - void coroPumpPost(coroutine_type::self& self) + void coroPumpPost() { BEGIN { LLCoroEventPump waiter; - result = waiter.postAndWait(self, LLSDMap("value", 17), + result = waiter.postAndWait(LLSDMap("value", 17), immediateAPI.getPump(), "reply"); } END } - void coroPumps(coroutine_type::self& self) + void coroPumps() { BEGIN { LLCoroEventPumps waiter; replyName = waiter.getName0(); errorName = waiter.getName1(); - LLEventWithID pair(waiter.wait(self)); + LLEventWithID pair(waiter.wait()); result = pair.first; which = pair.second; } END } - void coroPumpsNoEx(coroutine_type::self& self) + void coroPumpsNoEx() { BEGIN { LLCoroEventPumps waiter; replyName = waiter.getName0(); errorName = waiter.getName1(); - result = waiter.waitWithException(self); + result = waiter.waitWithException(); } END } - void coroPumpsEx(coroutine_type::self& self) + void coroPumpsEx() { BEGIN { @@ -314,7 +309,7 @@ namespace tut errorName = waiter.getName1(); try { - result = waiter.waitWithException(self); + result = waiter.waitWithException(); debug("no exception"); } catch (const LLErrorEvent& e) @@ -326,19 +321,19 @@ namespace tut END } - void coroPumpsNoLog(coroutine_type::self& self) + void coroPumpsNoLog() { BEGIN { LLCoroEventPumps waiter; replyName = waiter.getName0(); errorName = waiter.getName1(); - result = waiter.waitWithLog(self); + result = waiter.waitWithLog(); } END } - void coroPumpsLog(coroutine_type::self& self) + void coroPumpsLog() { BEGIN { @@ -348,7 +343,7 @@ namespace tut WrapLLErrs capture; try { - result = waiter.waitWithLog(self); + result = waiter.waitWithLog(); debug("no exception"); } catch (const WrapLLErrs::FatalException& e) @@ -360,12 +355,12 @@ namespace tut END } - void coroPumpsPost(coroutine_type::self& self) + void coroPumpsPost() { BEGIN { LLCoroEventPumps waiter; - LLEventWithID pair(waiter.postAndWait(self, LLSDMap("value", 23), + LLEventWithID pair(waiter.postAndWait(LLSDMap("value", 23), immediateAPI.getPump(), "reply", "error")); result = pair.first; which = pair.second; @@ -373,13 +368,13 @@ namespace tut END } - void coroPumpsPost_1(coroutine_type::self& self) + void coroPumpsPost_1() { BEGIN { LLCoroEventPumps waiter; LLEventWithID pair( - waiter.postAndWait(self, LLSDMap("value", 23)("fail", LLSD()), + waiter.postAndWait(LLSDMap("value", 23)("fail", LLSD()), immediateAPI.getPump(), "reply", "error")); result = pair.first; which = pair.second; @@ -387,25 +382,25 @@ namespace tut END } - void coroPumpsPostNoEx(coroutine_type::self& self) + void coroPumpsPostNoEx() { BEGIN { LLCoroEventPumps waiter; - result = waiter.postAndWaitWithException(self, LLSDMap("value", 8), + result = waiter.postAndWaitWithException(LLSDMap("value", 8), immediateAPI.getPump(), "reply", "error"); } END } - void coroPumpsPostEx(coroutine_type::self& self) + void coroPumpsPostEx() { BEGIN { LLCoroEventPumps waiter; try { - result = waiter.postAndWaitWithException(self, + result = waiter.postAndWaitWithException( LLSDMap("value", 9)("fail", LLSD()), immediateAPI.getPump(), "reply", "error"); debug("no exception"); @@ -419,18 +414,18 @@ namespace tut END } - void coroPumpsPostNoLog(coroutine_type::self& self) + void coroPumpsPostNoLog() { BEGIN { LLCoroEventPumps waiter; - result = waiter.postAndWaitWithLog(self, LLSDMap("value", 30), + result = waiter.postAndWaitWithLog(LLSDMap("value", 30), immediateAPI.getPump(), "reply", "error"); } END } - void coroPumpsPostLog(coroutine_type::self& self) + void coroPumpsPostLog() { BEGIN { @@ -438,7 +433,7 @@ namespace tut WrapLLErrs capture; try { - result = waiter.postAndWaitWithLog(self, + result = waiter.postAndWaitWithLog( LLSDMap("value", 31)("fail", LLSD()), immediateAPI.getPump(), "reply", "error"); debug("no exception"); @@ -452,11 +447,6 @@ namespace tut END } - void ensure_done(coroutine_type& coro) - { - ensure("coroutine complete", ! coro); - } - ImmediateAPI immediateAPI; std::string replyName, errorName, threw; LLSD result, errordata; @@ -520,7 +510,8 @@ namespace tut // Construct the coroutine instance that will run explicit_wait. // Pass the ctor a callable that accepts the coroutine_type::self // param passed by the library. - coroutine_type coro(boost::bind(&coroutine_data::explicit_wait, this, _1)); + boost::dcoroutines::coroutine + coro(boost::bind(&coroutine_data::explicit_wait, this, _1)); // Start the coroutine coro(std::nothrow); // When the coroutine waits for the event pump, it returns here. @@ -528,7 +519,7 @@ namespace tut // Satisfy the wait. LLEventPumps::instance().obtain("source").post("received"); // Now wait for the coroutine to complete. - ensure_done(coro); + ensure("coroutine complete", ! coro); // ensure the coroutine ran and woke up again with the intended result ensure_equals(result.asString(), "received"); } @@ -538,12 +529,11 @@ namespace tut { set_test_name("waitForEventOn1"); DEBUG; - coroutine_type coro(boost::bind(&coroutine_data::waitForEventOn1, this, _1)); - coro(std::nothrow); + LLCoros::instance().launch("test<3>", + boost::bind(&coroutine_data::waitForEventOn1, this)); debug("about to send"); LLEventPumps::instance().obtain("source").post("received"); debug("back from send"); - ensure_done(coro); ensure_equals(result.asString(), "received"); } @@ -553,12 +543,10 @@ namespace tut set_test_name("waitForEventOn2 reply"); { DEBUG; - coroutine_type coro(boost::bind(&coroutine_data::waitForEventOn2, this, _1)); - coro(std::nothrow); + LLCoros::instance().launch("test<4>", boost::bind(&coroutine_data::waitForEventOn2, this)); debug("about to send"); LLEventPumps::instance().obtain("reply").post("received"); debug("back from send"); - ensure_done(coro); } ensure_equals(result.asString(), "received"); ensure_equals("which pump", which, 0); @@ -569,12 +557,10 @@ namespace tut { set_test_name("waitForEventOn2 error"); DEBUG; - coroutine_type coro(boost::bind(&coroutine_data::waitForEventOn2, this, _1)); - coro(std::nothrow); + LLCoros::instance().launch("test<5>", boost::bind(&coroutine_data::waitForEventOn2, this)); debug("about to send"); LLEventPumps::instance().obtain("error").post("badness"); debug("back from send"); - ensure_done(coro); ensure_equals(result.asString(), "badness"); ensure_equals("which pump", which, 1); } @@ -584,12 +570,10 @@ namespace tut { set_test_name("coroPump"); DEBUG; - coroutine_type coro(boost::bind(&coroutine_data::coroPump, this, _1)); - coro(std::nothrow); + LLCoros::instance().launch("test<6>", boost::bind(&coroutine_data::coroPump, this)); debug("about to send"); LLEventPumps::instance().obtain(replyName).post("received"); debug("back from send"); - ensure_done(coro); ensure_equals(result.asString(), "received"); } @@ -598,12 +582,10 @@ namespace tut { set_test_name("coroPumps reply"); DEBUG; - coroutine_type coro(boost::bind(&coroutine_data::coroPumps, this, _1)); - coro(std::nothrow); + LLCoros::instance().launch("test<7>", boost::bind(&coroutine_data::coroPumps, this)); debug("about to send"); LLEventPumps::instance().obtain(replyName).post("received"); debug("back from send"); - ensure_done(coro); ensure_equals(result.asString(), "received"); ensure_equals("which pump", which, 0); } @@ -613,12 +595,10 @@ namespace tut { set_test_name("coroPumps error"); DEBUG; - coroutine_type coro(boost::bind(&coroutine_data::coroPumps, this, _1)); - coro(std::nothrow); + LLCoros::instance().launch("test<8>", boost::bind(&coroutine_data::coroPumps, this)); debug("about to send"); LLEventPumps::instance().obtain(errorName).post("badness"); debug("back from send"); - ensure_done(coro); ensure_equals(result.asString(), "badness"); ensure_equals("which pump", which, 1); } @@ -628,12 +608,10 @@ namespace tut { set_test_name("coroPumpsNoEx"); DEBUG; - coroutine_type coro(boost::bind(&coroutine_data::coroPumpsNoEx, this, _1)); - coro(std::nothrow); + LLCoros::instance().launch("test<9>", boost::bind(&coroutine_data::coroPumpsNoEx, this)); debug("about to send"); LLEventPumps::instance().obtain(replyName).post("received"); debug("back from send"); - ensure_done(coro); ensure_equals(result.asString(), "received"); } @@ -642,12 +620,10 @@ namespace tut { set_test_name("coroPumpsEx"); DEBUG; - coroutine_type coro(boost::bind(&coroutine_data::coroPumpsEx, this, _1)); - coro(std::nothrow); + LLCoros::instance().launch("test<10>", boost::bind(&coroutine_data::coroPumpsEx, this)); debug("about to send"); LLEventPumps::instance().obtain(errorName).post("badness"); debug("back from send"); - ensure_done(coro); ensure("no result", result.isUndefined()); ensure_equals("got error", errordata.asString(), "badness"); } @@ -657,12 +633,10 @@ namespace tut { set_test_name("coroPumpsNoLog"); DEBUG; - coroutine_type coro(boost::bind(&coroutine_data::coroPumpsNoLog, this, _1)); - coro(std::nothrow); + LLCoros::instance().launch("test<11>", boost::bind(&coroutine_data::coroPumpsNoLog, this)); debug("about to send"); LLEventPumps::instance().obtain(replyName).post("received"); debug("back from send"); - ensure_done(coro); ensure_equals(result.asString(), "received"); } @@ -671,12 +645,10 @@ namespace tut { set_test_name("coroPumpsLog"); DEBUG; - coroutine_type coro(boost::bind(&coroutine_data::coroPumpsLog, this, _1)); - coro(std::nothrow); + LLCoros::instance().launch("test<12>", boost::bind(&coroutine_data::coroPumpsLog, this)); debug("about to send"); LLEventPumps::instance().obtain(errorName).post("badness"); debug("back from send"); - ensure_done(coro); ensure("no result", result.isUndefined()); ensure_contains("got error", threw, "badness"); } @@ -686,9 +658,7 @@ namespace tut { set_test_name("postAndWait1"); DEBUG; - coroutine_type coro(boost::bind(&coroutine_data::postAndWait1, this, _1)); - coro(std::nothrow); - ensure_done(coro); + LLCoros::instance().launch("test<13>", boost::bind(&coroutine_data::postAndWait1, this)); ensure_equals(result.asInteger(), 18); } @@ -697,9 +667,7 @@ namespace tut { set_test_name("postAndWait2"); DEBUG; - coroutine_type coro(boost::bind(&coroutine_data::postAndWait2, this, _1)); - coro(std::nothrow); - ensure_done(coro); + LLCoros::instance().launch("test<14>", boost::bind(&coroutine_data::postAndWait2, this)); ensure_equals(result.asInteger(), 19); ensure_equals(which, 0); } @@ -709,9 +677,7 @@ namespace tut { set_test_name("postAndWait2_1"); DEBUG; - coroutine_type coro(boost::bind(&coroutine_data::postAndWait2_1, this, _1)); - coro(std::nothrow); - ensure_done(coro); + LLCoros::instance().launch("test<15>", boost::bind(&coroutine_data::postAndWait2_1, this)); ensure_equals(result.asInteger(), 19); ensure_equals(which, 1); } @@ -721,9 +687,7 @@ namespace tut { set_test_name("coroPumpPost"); DEBUG; - coroutine_type coro(boost::bind(&coroutine_data::coroPumpPost, this, _1)); - coro(std::nothrow); - ensure_done(coro); + LLCoros::instance().launch("test<16>", boost::bind(&coroutine_data::coroPumpPost, this)); ensure_equals(result.asInteger(), 18); } @@ -732,9 +696,7 @@ namespace tut { set_test_name("coroPumpsPost reply"); DEBUG; - coroutine_type coro(boost::bind(&coroutine_data::coroPumpsPost, this, _1)); - coro(std::nothrow); - ensure_done(coro); + LLCoros::instance().launch("test<17>", boost::bind(&coroutine_data::coroPumpsPost, this)); ensure_equals(result.asInteger(), 24); ensure_equals("which pump", which, 0); } @@ -744,9 +706,7 @@ namespace tut { set_test_name("coroPumpsPost error"); DEBUG; - coroutine_type coro(boost::bind(&coroutine_data::coroPumpsPost_1, this, _1)); - coro(std::nothrow); - ensure_done(coro); + LLCoros::instance().launch("test<18>", boost::bind(&coroutine_data::coroPumpsPost_1, this)); ensure_equals(result.asInteger(), 24); ensure_equals("which pump", which, 1); } @@ -756,9 +716,8 @@ namespace tut { set_test_name("coroPumpsPostNoEx"); DEBUG; - coroutine_type coro(boost::bind(&coroutine_data::coroPumpsPostNoEx, this, _1)); - coro(std::nothrow); - ensure_done(coro); + LLCoros::instance().launch("test<19>", + boost::bind(&coroutine_data::coroPumpsPostNoEx, this)); ensure_equals(result.asInteger(), 9); } @@ -767,9 +726,7 @@ namespace tut { set_test_name("coroPumpsPostEx"); DEBUG; - coroutine_type coro(boost::bind(&coroutine_data::coroPumpsPostEx, this, _1)); - coro(std::nothrow); - ensure_done(coro); + LLCoros::instance().launch("test<20>", boost::bind(&coroutine_data::coroPumpsPostEx, this)); ensure("no result", result.isUndefined()); ensure_equals("got error", errordata.asInteger(), 10); } @@ -779,9 +736,8 @@ namespace tut { set_test_name("coroPumpsPostNoLog"); DEBUG; - coroutine_type coro(boost::bind(&coroutine_data::coroPumpsPostNoLog, this, _1)); - coro(std::nothrow); - ensure_done(coro); + LLCoros::instance().launch("test<21>", + boost::bind(&coroutine_data::coroPumpsPostNoLog, this)); ensure_equals(result.asInteger(), 31); } @@ -790,9 +746,7 @@ namespace tut { set_test_name("coroPumpsPostLog"); DEBUG; - coroutine_type coro(boost::bind(&coroutine_data::coroPumpsPostLog, this, _1)); - coro(std::nothrow); - ensure_done(coro); + LLCoros::instance().launch("test<22>", boost::bind(&coroutine_data::coroPumpsPostLog, this)); ensure("no result", result.isUndefined()); ensure_contains("got error", threw, "32"); } diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index 7014048021..d262862c80 100755 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -137,8 +137,8 @@ namespace LLAvatarNameCache bool expirationFromCacheControl(const LLSD& headers, F64 *expires); - // This is a coroutine. The only parameter that can be specified as a reference is the self - void requestAvatarNameCache_(LLCoros::self& self, std::string url, std::vector agentIds); + // This is a coroutine. + void requestAvatarNameCache_(std::string url, std::vector agentIds); void handleAvNameCacheSuccess(const LLSD &data, const LLSD &httpResult); } @@ -185,9 +185,9 @@ namespace LLAvatarNameCache // Coroutine for sending and processing avatar name cache requests. // Do not call directly. See documentation in lleventcoro.h and llcoro.h for // further explanation. -void LLAvatarNameCache::requestAvatarNameCache_(LLCoros::self& self, std::string url, std::vector agentIds) +void LLAvatarNameCache::requestAvatarNameCache_(std::string url, std::vector agentIds) { - LL_DEBUGS("AvNameCache") << "Entering coroutine " << LLCoros::instance().getName(self) + LL_DEBUGS("AvNameCache") << "Entering coroutine " << LLCoros::instance().getName() << " with url '" << url << "', requesting " << agentIds.size() << " Agent Ids" << LL_ENDL; try @@ -195,7 +195,7 @@ void LLAvatarNameCache::requestAvatarNameCache_(LLCoros::self& self, std::string bool success = true; LLCoreHttpUtil::HttpCoroutineAdapter httpAdapter("NameCache", LLAvatarNameCache::sHttpPolicy); - LLSD results = httpAdapter.getAndYield(self, sHttpRequest, url); + LLSD results = httpAdapter.getAndYield(sHttpRequest, url); LLSD httpResults; LL_DEBUGS() << results << LL_ENDL; @@ -401,7 +401,7 @@ void LLAvatarNameCache::requestNamesViaCapability() std::string coroname = LLCoros::instance().launch("LLAvatarNameCache::requestAvatarNameCache_", - boost::bind(&LLAvatarNameCache::requestAvatarNameCache_, _1, url, agent_ids)); + boost::bind(&LLAvatarNameCache::requestAvatarNameCache_, url, agent_ids)); LL_DEBUGS("AvNameCache") << coroname << " with url '" << url << "', agent_ids.size()=" << agent_ids.size() << LL_ENDL; } diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index 4ec01aa405..ac1c2f8e58 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -565,17 +565,17 @@ HttpCoroutineAdapter::~HttpCoroutineAdapter() cancelYieldingOperation(); } -LLSD HttpCoroutineAdapter::postAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::postAndYield(LLCore::HttpRequest::ptr_t request, const std::string & url, const LLSD & body, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { LLEventStream replyPump(mAdapterName, true); HttpCoroHandler::ptr_t httpHandler = HttpCoroHandler::ptr_t(new HttpCoroLLSDHandler(replyPump)); - return postAndYield_(self, request, url, body, options, headers, httpHandler); + return postAndYield_(request, url, body, options, headers, httpHandler); } -LLSD HttpCoroutineAdapter::postAndYield_(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, +LLSD HttpCoroutineAdapter::postAndYield_(LLCore::HttpRequest::ptr_t &request, const std::string & url, const LLSD & body, LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler) @@ -596,35 +596,35 @@ LLSD HttpCoroutineAdapter::postAndYield_(LLCoros::self & self, LLCore::HttpReque } saveState(hhandle, request, handler); - LLSD results = waitForEventOn(self, handler->getReplyPump()); + LLSD results = waitForEventOn(handler->getReplyPump()); cleanState(); return results; } -LLSD HttpCoroutineAdapter::postAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::postAndYield(LLCore::HttpRequest::ptr_t request, const std::string & url, LLCore::BufferArray::ptr_t rawbody, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { LLEventStream replyPump(mAdapterName, true); HttpCoroHandler::ptr_t httpHandler = HttpCoroHandler::ptr_t(new HttpCoroLLSDHandler(replyPump)); - return postAndYield_(self, request, url, rawbody, options, headers, httpHandler); + return postAndYield_(request, url, rawbody, options, headers, httpHandler); } -LLSD HttpCoroutineAdapter::postRawAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::postRawAndYield(LLCore::HttpRequest::ptr_t request, const std::string & url, LLCore::BufferArray::ptr_t rawbody, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { LLEventStream replyPump(mAdapterName, true); HttpCoroHandler::ptr_t httpHandler = HttpCoroHandler::ptr_t(new HttpCoroRawHandler(replyPump)); - return postAndYield_(self, request, url, rawbody, options, headers, httpHandler); + return postAndYield_(request, url, rawbody, options, headers, httpHandler); } // *TODO: This functionality could be moved into the LLCore::Http library itself // by having the CURL layer read the file directly. -LLSD HttpCoroutineAdapter::postFileAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::postFileAndYield(LLCore::HttpRequest::ptr_t request, const std::string & url, std::string fileName, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { @@ -648,12 +648,12 @@ LLSD HttpCoroutineAdapter::postFileAndYield(LLCoros::self & self, LLCore::HttpRe } } - return postAndYield(self, request, url, fileData, options, headers); + return postAndYield(request, url, fileData, options, headers); } // *TODO: This functionality could be moved into the LLCore::Http library itself // by having the CURL layer read the file directly. -LLSD HttpCoroutineAdapter::postFileAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::postFileAndYield(LLCore::HttpRequest::ptr_t request, const std::string & url, LLUUID assetId, LLAssetType::EType assetType, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { @@ -673,11 +673,11 @@ LLSD HttpCoroutineAdapter::postFileAndYield(LLCoros::self & self, LLCore::HttpRe delete[] fileBuffer; } - return postAndYield(self, request, url, fileData, options, headers); + return postAndYield(request, url, fileData, options, headers); } -LLSD HttpCoroutineAdapter::postAndYield_(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, +LLSD HttpCoroutineAdapter::postAndYield_(LLCore::HttpRequest::ptr_t &request, const std::string & url, LLCore::BufferArray::ptr_t &rawbody, LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler) @@ -697,24 +697,24 @@ LLSD HttpCoroutineAdapter::postAndYield_(LLCoros::self & self, LLCore::HttpReque } saveState(hhandle, request, handler); - LLSD results = waitForEventOn(self, handler->getReplyPump()); + LLSD results = waitForEventOn(handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; } -LLSD HttpCoroutineAdapter::putAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::putAndYield(LLCore::HttpRequest::ptr_t request, const std::string & url, const LLSD & body, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { LLEventStream replyPump(mAdapterName + "Reply", true); HttpCoroHandler::ptr_t httpHandler = HttpCoroHandler::ptr_t(new HttpCoroLLSDHandler(replyPump)); - return putAndYield_(self, request, url, body, options, headers, httpHandler); + return putAndYield_(request, url, body, options, headers, httpHandler); } -LLSD HttpCoroutineAdapter::putAndYield_(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, +LLSD HttpCoroutineAdapter::putAndYield_(LLCore::HttpRequest::ptr_t &request, const std::string & url, const LLSD & body, LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler) @@ -735,43 +735,43 @@ LLSD HttpCoroutineAdapter::putAndYield_(LLCoros::self & self, LLCore::HttpReques } saveState(hhandle, request, handler); - LLSD results = waitForEventOn(self, handler->getReplyPump()); + LLSD results = waitForEventOn(handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; } -LLSD HttpCoroutineAdapter::getAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::getAndYield(LLCore::HttpRequest::ptr_t request, const std::string & url, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { LLEventStream replyPump(mAdapterName + "Reply", true); HttpCoroHandler::ptr_t httpHandler = HttpCoroHandler::ptr_t(new HttpCoroLLSDHandler(replyPump)); - return getAndYield_(self, request, url, options, headers, httpHandler); + return getAndYield_(request, url, options, headers, httpHandler); } -LLSD HttpCoroutineAdapter::getRawAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::getRawAndYield(LLCore::HttpRequest::ptr_t request, const std::string & url, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { LLEventStream replyPump(mAdapterName + "Reply", true); HttpCoroHandler::ptr_t httpHandler = HttpCoroHandler::ptr_t(new HttpCoroRawHandler(replyPump)); - return getAndYield_(self, request, url, options, headers, httpHandler); + return getAndYield_(request, url, options, headers, httpHandler); } -LLSD HttpCoroutineAdapter::getJsonAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::getJsonAndYield(LLCore::HttpRequest::ptr_t request, const std::string & url, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { LLEventStream replyPump(mAdapterName + "Reply", true); HttpCoroHandler::ptr_t httpHandler = HttpCoroHandler::ptr_t(new HttpCoroJSONHandler(replyPump)); - return getAndYield_(self, request, url, options, headers, httpHandler); + return getAndYield_(request, url, options, headers, httpHandler); } -LLSD HttpCoroutineAdapter::getAndYield_(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, +LLSD HttpCoroutineAdapter::getAndYield_(LLCore::HttpRequest::ptr_t &request, const std::string & url, LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler) @@ -790,24 +790,24 @@ LLSD HttpCoroutineAdapter::getAndYield_(LLCoros::self & self, LLCore::HttpReques } saveState(hhandle, request, handler); - LLSD results = waitForEventOn(self, handler->getReplyPump()); + LLSD results = waitForEventOn(handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; } -LLSD HttpCoroutineAdapter::deleteAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::deleteAndYield(LLCore::HttpRequest::ptr_t request, const std::string & url, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { LLEventStream replyPump(mAdapterName + "Reply", true); HttpCoroHandler::ptr_t httpHandler = HttpCoroHandler::ptr_t(new HttpCoroLLSDHandler(replyPump)); - return deleteAndYield_(self, request, url, options, headers, httpHandler); + return deleteAndYield_(request, url, options, headers, httpHandler); } -LLSD HttpCoroutineAdapter::deleteAndYield_(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, +LLSD HttpCoroutineAdapter::deleteAndYield_(LLCore::HttpRequest::ptr_t &request, const std::string & url, LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler) { @@ -825,7 +825,7 @@ LLSD HttpCoroutineAdapter::deleteAndYield_(LLCoros::self & self, LLCore::HttpReq } saveState(hhandle, request, handler); - LLSD results = waitForEventOn(self, handler->getReplyPump()); + LLSD results = waitForEventOn(handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; @@ -907,7 +907,7 @@ LLCore::HttpStatus HttpCoroutineAdapter::getStatusFromLLSD(const LLSD &httpResul void HttpCoroutineAdapter::callbackHttpGet(const std::string &url, LLCore::HttpRequest::policy_t policyId, completionCallback_t success, completionCallback_t failure) { LLCoros::instance().launch("HttpCoroutineAdapter::genericGetCoro", - boost::bind(&HttpCoroutineAdapter::trivialGetCoro, _1, url, policyId, success, failure)); + boost::bind(&HttpCoroutineAdapter::trivialGetCoro, url, policyId, success, failure)); } /*static*/ @@ -921,7 +921,7 @@ void HttpCoroutineAdapter::messageHttpGet(const std::string &url, const std::str } /*static*/ -void HttpCoroutineAdapter::trivialGetCoro(LLCoros::self& self, std::string url, LLCore::HttpRequest::policy_t policyId, completionCallback_t success, completionCallback_t failure) +void HttpCoroutineAdapter::trivialGetCoro(std::string url, LLCore::HttpRequest::policy_t policyId, completionCallback_t success, completionCallback_t failure) { LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("genericGetCoro", policyId)); @@ -932,7 +932,7 @@ void HttpCoroutineAdapter::trivialGetCoro(LLCoros::self& self, std::string url, LL_INFOS("HttpCoroutineAdapter", "genericGetCoro") << "Generic GET for " << url << LL_ENDL; - LLSD result = httpAdapter->getAndYield(self, httpRequest, url, httpOpts); + LLSD result = httpAdapter->getAndYield(httpRequest, url, httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -957,7 +957,7 @@ void HttpCoroutineAdapter::trivialGetCoro(LLCoros::self& self, std::string url, void HttpCoroutineAdapter::callbackHttpPost(const std::string &url, LLCore::HttpRequest::policy_t policyId, const LLSD &postData, completionCallback_t success, completionCallback_t failure) { LLCoros::instance().launch("HttpCoroutineAdapter::genericPostCoro", - boost::bind(&HttpCoroutineAdapter::trivialPostCoro, _1, url, policyId, postData, success, failure)); + boost::bind(&HttpCoroutineAdapter::trivialPostCoro, url, policyId, postData, success, failure)); } /*static*/ @@ -972,7 +972,7 @@ void HttpCoroutineAdapter::messageHttpPost(const std::string &url, const LLSD &p } /*static*/ -void HttpCoroutineAdapter::trivialPostCoro(LLCoros::self& self, std::string url, LLCore::HttpRequest::policy_t policyId, LLSD postData, completionCallback_t success, completionCallback_t failure) +void HttpCoroutineAdapter::trivialPostCoro(std::string url, LLCore::HttpRequest::policy_t policyId, LLSD postData, completionCallback_t success, completionCallback_t failure) { LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("genericPostCoro", policyId)); @@ -983,7 +983,7 @@ void HttpCoroutineAdapter::trivialPostCoro(LLCoros::self& self, std::string url, LL_INFOS("HttpCoroutineAdapter", "genericPostCoro") << "Generic POST for " << url << LL_ENDL; - LLSD result = httpAdapter->postAndYield(self, httpRequest, url, postData, httpOpts); + LLSD result = httpAdapter->postAndYield(httpRequest, url, postData, httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); diff --git a/indra/llmessage/llcorehttputil.h b/indra/llmessage/llcorehttputil.h index 7dd161d1cd..cf35177e48 100644 --- a/indra/llmessage/llcorehttputil.h +++ b/indra/llmessage/llcorehttputil.h @@ -320,67 +320,67 @@ public: /// /// @Note: the request's smart pointer is passed by value so that it will /// not be deallocated during the yield. - LLSD postAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, + LLSD postAndYield(LLCore::HttpRequest::ptr_t request, const std::string & url, const LLSD & body, LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders())); - LLSD postAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, + LLSD postAndYield(LLCore::HttpRequest::ptr_t request, const std::string & url, LLCore::BufferArray::ptr_t rawbody, LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders())); - LLSD postAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, + LLSD postAndYield(LLCore::HttpRequest::ptr_t &request, const std::string & url, const LLSD & body, LLCore::HttpHeaders::ptr_t &headers) { - return postAndYield(self, request, url, body, + return postAndYield(request, url, body, LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), headers); } - LLSD postAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, + LLSD postAndYield(LLCore::HttpRequest::ptr_t &request, const std::string & url, LLCore::BufferArray::ptr_t &rawbody, LLCore::HttpHeaders::ptr_t &headers) { - return postAndYield(self, request, url, rawbody, + return postAndYield(request, url, rawbody, LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), headers); } - LLSD postRawAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, + LLSD postRawAndYield(LLCore::HttpRequest::ptr_t request, const std::string & url, LLCore::BufferArray::ptr_t rawbody, LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders())); - LLSD postRawAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, + LLSD postRawAndYield(LLCore::HttpRequest::ptr_t &request, const std::string & url, LLCore::BufferArray::ptr_t &rawbody, LLCore::HttpHeaders::ptr_t &headers) { - return postRawAndYield(self, request, url, rawbody, + return postRawAndYield(request, url, rawbody, LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), headers); } - LLSD postFileAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, + LLSD postFileAndYield(LLCore::HttpRequest::ptr_t request, const std::string & url, std::string fileName, LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders())); - LLSD postFileAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, + LLSD postFileAndYield(LLCore::HttpRequest::ptr_t &request, const std::string & url, std::string fileName, LLCore::HttpHeaders::ptr_t &headers) { - return postFileAndYield(self, request, url, fileName, + return postFileAndYield(request, url, fileName, LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), headers); } - LLSD postFileAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, + LLSD postFileAndYield(LLCore::HttpRequest::ptr_t request, const std::string & url, LLUUID assetId, LLAssetType::EType assetType, LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders())); - LLSD postFileAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, + LLSD postFileAndYield(LLCore::HttpRequest::ptr_t request, const std::string & url, LLUUID assetId, LLAssetType::EType assetType, LLCore::HttpHeaders::ptr_t &headers) { - return postFileAndYield(self, request, url, assetId, assetType, + return postFileAndYield(request, url, assetId, assetType, LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), headers); } @@ -390,7 +390,7 @@ public: /// /// @Note: the request's smart pointer is passed by value so that it will /// not be deallocated during the yield. - LLSD putAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, + LLSD putAndYield(LLCore::HttpRequest::ptr_t request, const std::string & url, const LLSD & body, LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders())); @@ -400,38 +400,38 @@ public: /// /// @Note: the request's smart pointer is passed by value so that it will /// not be deallocated during the yield. - LLSD getAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, + LLSD getAndYield(LLCore::HttpRequest::ptr_t request, const std::string & url, LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders())); - LLSD getAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, + LLSD getAndYield(LLCore::HttpRequest::ptr_t &request, const std::string & url, LLCore::HttpHeaders::ptr_t &headers) { - return getAndYield(self, request, url, + return getAndYield(request, url, LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), headers); } - LLSD getRawAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, + LLSD getRawAndYield(LLCore::HttpRequest::ptr_t request, const std::string & url, LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders())); - LLSD getRawAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, + LLSD getRawAndYield(LLCore::HttpRequest::ptr_t &request, const std::string & url, LLCore::HttpHeaders::ptr_t &headers) { - return getRawAndYield(self, request, url, + return getRawAndYield(request, url, LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), headers); } - LLSD getJsonAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, + LLSD getJsonAndYield(LLCore::HttpRequest::ptr_t request, const std::string & url, LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders())); - LLSD getJsonndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, + LLSD getJsonndYield(LLCore::HttpRequest::ptr_t &request, const std::string & url, LLCore::HttpHeaders::ptr_t &headers) { - return getJsonAndYield(self, request, url, + return getJsonAndYield(request, url, LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), headers); } @@ -442,7 +442,7 @@ public: /// /// @Note: the request's smart pointer is passed by value so that it will /// not be deallocated during the yield. - LLSD deleteAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, + LLSD deleteAndYield(LLCore::HttpRequest::ptr_t request, const std::string & url, LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders())); @@ -486,31 +486,31 @@ private: HttpCoroHandler::ptr_t &handler); void cleanState(); - LLSD postAndYield_(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, + LLSD postAndYield_(LLCore::HttpRequest::ptr_t &request, const std::string & url, const LLSD & body, LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler); - LLSD postAndYield_(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, + LLSD postAndYield_(LLCore::HttpRequest::ptr_t &request, const std::string & url, LLCore::BufferArray::ptr_t &rawbody, LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler); - LLSD putAndYield_(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, + LLSD putAndYield_(LLCore::HttpRequest::ptr_t &request, const std::string & url, const LLSD & body, LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler); - LLSD getAndYield_(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, + LLSD getAndYield_(LLCore::HttpRequest::ptr_t &request, const std::string & url, LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler); - LLSD deleteAndYield_(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, + LLSD deleteAndYield_(LLCore::HttpRequest::ptr_t &request, const std::string & url, LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler); - static void trivialGetCoro(LLCoros::self& self, std::string url, LLCore::HttpRequest::policy_t policyId, completionCallback_t success, completionCallback_t failure); - static void trivialPostCoro(LLCoros::self& self, std::string url, LLCore::HttpRequest::policy_t policyId, LLSD postData, completionCallback_t success, completionCallback_t failure); + static void trivialGetCoro(std::string url, LLCore::HttpRequest::policy_t policyId, completionCallback_t success, completionCallback_t failure); + static void trivialPostCoro(std::string url, LLCore::HttpRequest::policy_t policyId, LLSD postData, completionCallback_t success, completionCallback_t failure); void checkDefaultHeaders(LLCore::HttpHeaders::ptr_t &headers); diff --git a/indra/newview/llaccountingcostmanager.cpp b/indra/newview/llaccountingcostmanager.cpp index f928c84ecb..cd9146ea16 100755 --- a/indra/newview/llaccountingcostmanager.cpp +++ b/indra/newview/llaccountingcostmanager.cpp @@ -45,10 +45,10 @@ LLAccountingCostManager::LLAccountingCostManager(): // Coroutine for sending and processing avatar name cache requests. // Do not call directly. See documentation in lleventcoro.h and llcoro.h for // further explanation. -void LLAccountingCostManager::accountingCostCoro(LLCoros::self& self, std::string url, +void LLAccountingCostManager::accountingCostCoro(std::string url, eSelectionType selectionType, const LLHandle observerHandle) { - LL_DEBUGS("LLAccountingCostManager") << "Entering coroutine " << LLCoros::instance().getName(self) + LL_DEBUGS("LLAccountingCostManager") << "Entering coroutine " << LLCoros::instance().getName() << " with url '" << url << LL_ENDL; try @@ -101,7 +101,7 @@ void LLAccountingCostManager::accountingCostCoro(LLCoros::self& self, std::strin LLCoreHttpUtil::HttpCoroutineAdapter httpAdapter("AccountingCost", mHttpPolicy); - LLSD results = httpAdapter.postAndYield(self, mHttpRequest, url, dataToPost); + LLSD results = httpAdapter.postAndYield(mHttpRequest, url, dataToPost); LLSD httpResults; httpResults = results["http_result"]; @@ -181,7 +181,7 @@ void LLAccountingCostManager::fetchCosts( eSelectionType selectionType, { std::string coroname = LLCoros::instance().launch("LLAccountingCostManager::accountingCostCoro", - boost::bind(&LLAccountingCostManager::accountingCostCoro, this, _1, url, selectionType, observer_handle)); + boost::bind(&LLAccountingCostManager::accountingCostCoro, this, url, selectionType, observer_handle)); LL_DEBUGS() << coroname << " with url '" << url << LL_ENDL; } diff --git a/indra/newview/llaccountingcostmanager.h b/indra/newview/llaccountingcostmanager.h index 34748894e3..d5a94f6fda 100755 --- a/indra/newview/llaccountingcostmanager.h +++ b/indra/newview/llaccountingcostmanager.h @@ -77,7 +77,7 @@ private: std::set mPendingObjectQuota; typedef std::set::iterator IDIt; - void accountingCostCoro(LLCoros::self& self, std::string url, eSelectionType selectionType, const LLHandle observerHandle); + void accountingCostCoro(std::string url, eSelectionType selectionType, const LLHandle observerHandle); LLCore::HttpRequest::ptr_t mHttpRequest; LLCore::HttpRequest::policy_t mHttpPolicy; diff --git a/indra/newview/llavatarrenderinfoaccountant.cpp b/indra/newview/llavatarrenderinfoaccountant.cpp index 73b2ecfd36..e260142254 100644 --- a/indra/newview/llavatarrenderinfoaccountant.cpp +++ b/indra/newview/llavatarrenderinfoaccountant.cpp @@ -60,14 +60,14 @@ LLFrameTimer LLAvatarRenderInfoAccountant::sRenderInfoReportTimer; //LLCore::HttpRequest::ptr_t LLAvatarRenderInfoAccountant::sHttpRequest; //========================================================================= -void LLAvatarRenderInfoAccountant::avatarRenderInfoGetCoro(LLCoros::self& self, std::string url, U64 regionHandle) +void LLAvatarRenderInfoAccountant::avatarRenderInfoGetCoro(std::string url, U64 regionHandle) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("AvatarRenderInfoAccountant", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLSD result = httpAdapter->getAndYield(self, httpRequest, url); + LLSD result = httpAdapter->getAndYield(httpRequest, url); LLViewerRegion * regionp = LLWorld::getInstance()->getRegionFromHandle(regionHandle); if (!regionp) @@ -130,7 +130,7 @@ void LLAvatarRenderInfoAccountant::avatarRenderInfoGetCoro(LLCoros::self& self, } //------------------------------------------------------------------------- -void LLAvatarRenderInfoAccountant::avatarRenderInfoReportCoro(LLCoros::self& self, std::string url, U64 regionHandle) +void LLAvatarRenderInfoAccountant::avatarRenderInfoReportCoro(std::string url, U64 regionHandle) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -190,7 +190,7 @@ void LLAvatarRenderInfoAccountant::avatarRenderInfoReportCoro(LLCoros::self& sel report[KEY_AGENTS] = agents; regionp = NULL; - LLSD result = httpAdapter->postAndYield(self, httpRequest, url, report); + LLSD result = httpAdapter->postAndYield(httpRequest, url, report); regionp = LLWorld::getInstance()->getRegionFromHandle(regionHandle); if (!regionp) @@ -239,7 +239,7 @@ void LLAvatarRenderInfoAccountant::sendRenderInfoToRegion(LLViewerRegion * regio { std::string coroname = LLCoros::instance().launch("LLAvatarRenderInfoAccountant::avatarRenderInfoReportCoro", - boost::bind(&LLAvatarRenderInfoAccountant::avatarRenderInfoReportCoro, _1, url, regionp->getHandle())); + boost::bind(&LLAvatarRenderInfoAccountant::avatarRenderInfoReportCoro, url, regionp->getHandle())); } } @@ -264,7 +264,7 @@ void LLAvatarRenderInfoAccountant::getRenderInfoFromRegion(LLViewerRegion * regi // First send a request to get the latest data std::string coroname = LLCoros::instance().launch("LLAvatarRenderInfoAccountant::avatarRenderInfoGetCoro", - boost::bind(&LLAvatarRenderInfoAccountant::avatarRenderInfoGetCoro, _1, url, regionp->getHandle())); + boost::bind(&LLAvatarRenderInfoAccountant::avatarRenderInfoGetCoro, url, regionp->getHandle())); } } diff --git a/indra/newview/llavatarrenderinfoaccountant.h b/indra/newview/llavatarrenderinfoaccountant.h index 1736f03772..f7a04cca2c 100644 --- a/indra/newview/llavatarrenderinfoaccountant.h +++ b/indra/newview/llavatarrenderinfoaccountant.h @@ -56,8 +56,8 @@ private: // Send data updates about once per minute, only need per-frame resolution static LLFrameTimer sRenderInfoReportTimer; - static void avatarRenderInfoGetCoro(LLCoros::self& self, std::string url, U64 regionHandle); - static void avatarRenderInfoReportCoro(LLCoros::self& self, std::string url, U64 regionHandle); + static void avatarRenderInfoGetCoro(std::string url, U64 regionHandle); + static void avatarRenderInfoReportCoro(std::string url, U64 regionHandle); }; diff --git a/indra/newview/llcoproceduremanager.cpp b/indra/newview/llcoproceduremanager.cpp index 3ecb323cab..1a4a906f35 100644 --- a/indra/newview/llcoproceduremanager.cpp +++ b/indra/newview/llcoproceduremanager.cpp @@ -54,7 +54,7 @@ LLCoprocedureManager::LLCoprocedureManager(): new LLCoreHttpUtil::HttpCoroutineAdapter("uploadPostAdapter", mHTTPPolicy)); std::string uploadCoro = LLCoros::instance().launch("LLCoprocedureManager::coprocedureInvokerCoro", - boost::bind(&LLCoprocedureManager::coprocedureInvokerCoro, this, _1, httpAdapter)); + boost::bind(&LLCoprocedureManager::coprocedureInvokerCoro, this, httpAdapter)); mCoroMapping.insert(CoroAdapterMap_t::value_type(uploadCoro, httpAdapter)); } @@ -132,13 +132,13 @@ void LLCoprocedureManager::cancelCoprocedure(const LLUUID &id) } //========================================================================= -void LLCoprocedureManager::coprocedureInvokerCoro(LLCoros::self& self, LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter) +void LLCoprocedureManager::coprocedureInvokerCoro(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter) { LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); while (!mShutdown) { - waitForEventOn(self, mWakeupTrigger); + waitForEventOn(mWakeupTrigger); if (mShutdown) break; @@ -152,7 +152,7 @@ void LLCoprocedureManager::coprocedureInvokerCoro(LLCoros::self& self, LLCoreHtt try { - coproc->mProc(self, httpAdapter, coproc->mId); + coproc->mProc(httpAdapter, coproc->mId); } catch (std::exception &e) { diff --git a/indra/newview/llcoproceduremanager.h b/indra/newview/llcoproceduremanager.h index 4e971d42e3..6ba3891e87 100644 --- a/indra/newview/llcoproceduremanager.h +++ b/indra/newview/llcoproceduremanager.h @@ -36,7 +36,7 @@ class LLCoprocedureManager : public LLSingleton < LLCoprocedureManager > { public: - typedef boost::function CoProcedure_t; + typedef boost::function CoProcedure_t; LLCoprocedureManager(); virtual ~LLCoprocedureManager(); @@ -111,7 +111,7 @@ private: CoroAdapterMap_t mCoroMapping; - void coprocedureInvokerCoro(LLCoros::self& self, LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter); + void coprocedureInvokerCoro(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter); }; #endif diff --git a/indra/newview/llestateinfomodel.cpp b/indra/newview/llestateinfomodel.cpp index 04d0dda7ac..884d1579e6 100755 --- a/indra/newview/llestateinfomodel.cpp +++ b/indra/newview/llestateinfomodel.cpp @@ -123,12 +123,12 @@ bool LLEstateInfoModel::commitEstateInfoCaps() } LLCoros::instance().launch("LLEstateInfoModel::commitEstateInfoCapsCoro", - boost::bind(&LLEstateInfoModel::commitEstateInfoCapsCoro, this, _1, url)); + boost::bind(&LLEstateInfoModel::commitEstateInfoCapsCoro, this, url)); return true; } -void LLEstateInfoModel::commitEstateInfoCapsCoro(LLCoros::self& self, std::string url) +void LLEstateInfoModel::commitEstateInfoCapsCoro(std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -153,7 +153,7 @@ void LLEstateInfoModel::commitEstateInfoCapsCoro(LLCoros::self& self, std::strin << ", sun_hour = " << getSunHour() << LL_ENDL; LL_DEBUGS() << body << LL_ENDL; - LLSD result = httpAdapter->postAndYield(self, httpRequest, url, body); + LLSD result = httpAdapter->postAndYield(httpRequest, url, body); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); diff --git a/indra/newview/llestateinfomodel.h b/indra/newview/llestateinfomodel.h index 2deae7e322..fcfbd1ce7d 100755 --- a/indra/newview/llestateinfomodel.h +++ b/indra/newview/llestateinfomodel.h @@ -101,7 +101,7 @@ private: update_signal_t mUpdateSignal; /// emitted when we receive update from sim update_signal_t mCommitSignal; /// emitted when our update gets applied to sim - void commitEstateInfoCapsCoro(LLCoros::self& self, std::string url); + void commitEstateInfoCapsCoro(std::string url); }; inline bool LLEstateInfoModel::getFlag(U64 flag) const diff --git a/indra/newview/lleventpoll.cpp b/indra/newview/lleventpoll.cpp index 03a380f2f6..54da226209 100755 --- a/indra/newview/lleventpoll.cpp +++ b/indra/newview/lleventpoll.cpp @@ -61,7 +61,7 @@ namespace Details static const F32 EVENT_POLL_ERROR_RETRY_SECONDS_INC; static const S32 MAX_EVENT_POLL_HTTP_ERRORS; - void eventPollCoro(LLCoros::self& self, std::string url); + void eventPollCoro(std::string url); void handleMessage(const LLSD &content); @@ -113,7 +113,7 @@ namespace Details { std::string coroname = LLCoros::instance().launch("LLEventPollImpl::eventPollCoro", - boost::bind(&LLEventPollImpl::eventPollCoro, this, _1, url)); + boost::bind(&LLEventPollImpl::eventPollCoro, this, url)); LL_INFOS("LLEventPollImpl") << coroname << " with url '" << url << LL_ENDL; } } @@ -131,7 +131,7 @@ namespace Details } } - void LLEventPollImpl::eventPollCoro(LLCoros::self& self, std::string url) + void LLEventPollImpl::eventPollCoro(std::string url) { LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("EventPoller", mHttpPolicy)); LLSD acknowledge; @@ -154,7 +154,7 @@ namespace Details // << LLSDXMLStreamer(request) << LL_ENDL; LL_DEBUGS("LLEventPollImpl") << " <" << counter << "> posting and yielding." << LL_ENDL; - LLSD result = httpAdapter->postAndYield(self, mHttpRequest, url, request); + LLSD result = httpAdapter->postAndYield(mHttpRequest, url, request); // LL_DEBUGS("LLEventPollImpl::eventPollCoro") << "<" << counter << "> result = " // << LLSDXMLStreamer(result) << LL_ENDL; @@ -197,7 +197,7 @@ namespace Details " seconds, error count is now " << errorCount << LL_ENDL; timeout.eventAfter(waitToRetry, LLSD()); - waitForEventOn(self, timeout); + waitForEventOn(timeout); if (mDone) break; diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index 87d7aacda1..136e02953c 100755 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -144,7 +144,7 @@ LLFacebookConnectHandler gFacebookConnectHandler; /////////////////////////////////////////////////////////////////////////////// // -void LLFacebookConnect::facebookConnectCoro(LLCoros::self& self, std::string authCode, std::string authState) +void LLFacebookConnect::facebookConnectCoro(std::string authCode, std::string authState) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -167,7 +167,7 @@ void LLFacebookConnect::facebookConnectCoro(LLCoros::self& self, std::string aut setConnectionState(LLFacebookConnect::FB_CONNECTION_IN_PROGRESS); - LLSD result = httpAdapter->putAndYield(self, httpRequest, getFacebookConnectURL("/connection"), putData, httpOpts, get_headers()); + LLSD result = httpAdapter->putAndYield(httpRequest, getFacebookConnectURL("/connection"), putData, httpOpts, get_headers()); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -231,7 +231,7 @@ bool LLFacebookConnect::testShareStatus(LLSD &result) return false; } -void LLFacebookConnect::facebookShareCoro(LLCoros::self& self, std::string route, LLSD share) +void LLFacebookConnect::facebookShareCoro(std::string route, LLSD share) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -244,7 +244,7 @@ void LLFacebookConnect::facebookShareCoro(LLCoros::self& self, std::string route setConnectionState(LLFacebookConnect::FB_POSTING); - LLSD result = httpAdapter->postAndYield(self, httpRequest, getFacebookConnectURL(route, true), share, httpOpts, get_headers()); + LLSD result = httpAdapter->postAndYield(httpRequest, getFacebookConnectURL(route, true), share, httpOpts, get_headers()); if (testShareStatus(result)) { @@ -254,7 +254,7 @@ void LLFacebookConnect::facebookShareCoro(LLCoros::self& self, std::string route } } -void LLFacebookConnect::facebookShareImageCoro(LLCoros::self& self, std::string route, LLPointer image, std::string caption) +void LLFacebookConnect::facebookShareImageCoro(std::string route, LLPointer image, std::string caption) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -311,7 +311,7 @@ void LLFacebookConnect::facebookShareImageCoro(LLCoros::self& self, std::string setConnectionState(LLFacebookConnect::FB_POSTING); - LLSD result = httpAdapter->postAndYield(self, httpRequest, getFacebookConnectURL(route, true), raw, httpOpts, httpHeaders); + LLSD result = httpAdapter->postAndYield(httpRequest, getFacebookConnectURL(route, true), raw, httpOpts, httpHeaders); if (testShareStatus(result)) { @@ -323,7 +323,7 @@ void LLFacebookConnect::facebookShareImageCoro(LLCoros::self& self, std::string /////////////////////////////////////////////////////////////////////////////// // -void LLFacebookConnect::facebookDisconnectCoro(LLCoros::self& self) +void LLFacebookConnect::facebookDisconnectCoro() { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -334,7 +334,7 @@ void LLFacebookConnect::facebookDisconnectCoro(LLCoros::self& self) setConnectionState(LLFacebookConnect::FB_DISCONNECTING); httpOpts->setFollowRedirects(false); - LLSD result = httpAdapter->deleteAndYield(self, httpRequest, getFacebookConnectURL("/connection"), httpOpts, get_headers()); + LLSD result = httpAdapter->deleteAndYield(httpRequest, getFacebookConnectURL("/connection"), httpOpts, get_headers()); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -358,7 +358,7 @@ void LLFacebookConnect::facebookDisconnectCoro(LLCoros::self& self) /////////////////////////////////////////////////////////////////////////////// // -void LLFacebookConnect::facebookConnectedCheckCoro(LLCoros::self& self, bool autoConnect) +void LLFacebookConnect::facebookConnectedCheckCoro(bool autoConnect) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -370,7 +370,7 @@ void LLFacebookConnect::facebookConnectedCheckCoro(LLCoros::self& self, bool aut httpOpts->setFollowRedirects(false); - LLSD result = httpAdapter->getAndYield(self, httpRequest, getFacebookConnectURL("/connection", true), httpOpts, get_headers()); + LLSD result = httpAdapter->getAndYield(httpRequest, getFacebookConnectURL("/connection", true), httpOpts, get_headers()); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -407,7 +407,7 @@ void LLFacebookConnect::facebookConnectedCheckCoro(LLCoros::self& self, bool aut /////////////////////////////////////////////////////////////////////////////// // -void LLFacebookConnect::facebookConnectInfoCoro(LLCoros::self& self) +void LLFacebookConnect::facebookConnectInfoCoro() { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -418,7 +418,7 @@ void LLFacebookConnect::facebookConnectInfoCoro(LLCoros::self& self) httpOpts->setWantHeaders(true); httpOpts->setFollowRedirects(false); - LLSD result = httpAdapter->getAndYield(self, httpRequest, getFacebookConnectURL("/info", true), httpOpts, get_headers()); + LLSD result = httpAdapter->getAndYield(httpRequest, getFacebookConnectURL("/info", true), httpOpts, get_headers()); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -451,7 +451,7 @@ void LLFacebookConnect::facebookConnectInfoCoro(LLCoros::self& self) /////////////////////////////////////////////////////////////////////////////// // -void LLFacebookConnect::facebookConnectFriendsCoro(LLCoros::self& self) +void LLFacebookConnect::facebookConnectFriendsCoro() { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -461,7 +461,7 @@ void LLFacebookConnect::facebookConnectFriendsCoro(LLCoros::self& self) httpOpts->setFollowRedirects(false); - LLSD result = httpAdapter->getAndYield(self, httpRequest, getFacebookConnectURL("/friends", true), httpOpts, get_headers()); + LLSD result = httpAdapter->getAndYield(httpRequest, getFacebookConnectURL("/friends", true), httpOpts, get_headers()); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -547,19 +547,19 @@ std::string LLFacebookConnect::getFacebookConnectURL(const std::string& route, b void LLFacebookConnect::connectToFacebook(const std::string& auth_code, const std::string& auth_state) { LLCoros::instance().launch("LLFacebookConnect::facebookConnectCoro", - boost::bind(&LLFacebookConnect::facebookConnectCoro, this, _1, auth_code, auth_state)); + boost::bind(&LLFacebookConnect::facebookConnectCoro, this, auth_code, auth_state)); } void LLFacebookConnect::disconnectFromFacebook() { LLCoros::instance().launch("LLFacebookConnect::facebookDisconnectCoro", - boost::bind(&LLFacebookConnect::facebookDisconnectCoro, this, _1)); + boost::bind(&LLFacebookConnect::facebookDisconnectCoro, this)); } void LLFacebookConnect::checkConnectionToFacebook(bool auto_connect) { LLCoros::instance().launch("LLFacebookConnect::facebookConnectedCheckCoro", - boost::bind(&LLFacebookConnect::facebookConnectedCheckCoro, this, _1, auto_connect)); + boost::bind(&LLFacebookConnect::facebookConnectedCheckCoro, this, auto_connect)); } void LLFacebookConnect::loadFacebookInfo() @@ -567,7 +567,7 @@ void LLFacebookConnect::loadFacebookInfo() if(mRefreshInfo) { LLCoros::instance().launch("LLFacebookConnect::facebookConnectInfoCoro", - boost::bind(&LLFacebookConnect::facebookConnectInfoCoro, this, _1)); + boost::bind(&LLFacebookConnect::facebookConnectInfoCoro, this)); } } @@ -576,7 +576,7 @@ void LLFacebookConnect::loadFacebookFriends() if(mRefreshContent) { LLCoros::instance().launch("LLFacebookConnect::facebookConnectFriendsCoro", - boost::bind(&LLFacebookConnect::facebookConnectFriendsCoro, this, _1)); + boost::bind(&LLFacebookConnect::facebookConnectFriendsCoro, this)); } } @@ -606,7 +606,7 @@ void LLFacebookConnect::postCheckin(const std::string& location, const std::stri } LLCoros::instance().launch("LLFacebookConnect::facebookShareCoro", - boost::bind(&LLFacebookConnect::facebookShareCoro, this, _1, "/share/checkin", body)); + boost::bind(&LLFacebookConnect::facebookShareCoro, this, "/share/checkin", body)); } void LLFacebookConnect::sharePhoto(const std::string& image_url, const std::string& caption) @@ -617,13 +617,13 @@ void LLFacebookConnect::sharePhoto(const std::string& image_url, const std::stri body["caption"] = caption; LLCoros::instance().launch("LLFacebookConnect::facebookShareCoro", - boost::bind(&LLFacebookConnect::facebookShareCoro, this, _1, "/share/photo", body)); + boost::bind(&LLFacebookConnect::facebookShareCoro, this, "/share/photo", body)); } void LLFacebookConnect::sharePhoto(LLPointer image, const std::string& caption) { LLCoros::instance().launch("LLFacebookConnect::facebookShareImageCoro", - boost::bind(&LLFacebookConnect::facebookShareImageCoro, this, _1, "/share/photo", image, caption)); + boost::bind(&LLFacebookConnect::facebookShareImageCoro, this, "/share/photo", image, caption)); } void LLFacebookConnect::updateStatus(const std::string& message) @@ -632,7 +632,7 @@ void LLFacebookConnect::updateStatus(const std::string& message) body["message"] = message; LLCoros::instance().launch("LLFacebookConnect::facebookShareCoro", - boost::bind(&LLFacebookConnect::facebookShareCoro, this, _1, "/share/wall", body)); + boost::bind(&LLFacebookConnect::facebookShareCoro, this, "/share/wall", body)); } void LLFacebookConnect::storeInfo(const LLSD& info) diff --git a/indra/newview/llfacebookconnect.h b/indra/newview/llfacebookconnect.h index f569c2f486..2a2cdb5499 100644 --- a/indra/newview/llfacebookconnect.h +++ b/indra/newview/llfacebookconnect.h @@ -105,13 +105,13 @@ private: static boost::scoped_ptr sContentWatcher; bool testShareStatus(LLSD &results); - void facebookConnectCoro(LLCoros::self& self, std::string authCode, std::string authState); - void facebookConnectedCheckCoro(LLCoros::self& self, bool autoConnect); - void facebookDisconnectCoro(LLCoros::self& self); - void facebookShareCoro(LLCoros::self& self, std::string route, LLSD share); - void facebookShareImageCoro(LLCoros::self& self, std::string route, LLPointer image, std::string caption); - void facebookConnectInfoCoro(LLCoros::self& self); - void facebookConnectFriendsCoro(LLCoros::self& self); + void facebookConnectCoro(std::string authCode, std::string authState); + void facebookConnectedCheckCoro(bool autoConnect); + void facebookDisconnectCoro(); + void facebookShareCoro(std::string route, LLSD share); + void facebookShareImageCoro(std::string route, LLPointer image, std::string caption); + void facebookConnectInfoCoro(); + void facebookConnectFriendsCoro(); }; #endif // LL_LLFACEBOOKCONNECT_H diff --git a/indra/newview/llfeaturemanager.cpp b/indra/newview/llfeaturemanager.cpp index 9a714ac962..0b76ca16a9 100755 --- a/indra/newview/llfeaturemanager.cpp +++ b/indra/newview/llfeaturemanager.cpp @@ -492,7 +492,7 @@ bool LLFeatureManager::loadGPUClass() return true; // indicates that a gpu value was established } -void LLFeatureManager::fetchFeatureTableCoro(LLCoros::self& self, std::string tableName) +void LLFeatureManager::fetchFeatureTableCoro(std::string tableName) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -526,7 +526,7 @@ void LLFeatureManager::fetchFeatureTableCoro(LLCoros::self& self, std::string ta LL_INFOS() << "LLFeatureManager fetching " << url << " into " << path << LL_ENDL; - LLSD result = httpAdapter->getRawAndYield(self, httpRequest, url); + LLSD result = httpAdapter->getRawAndYield(httpRequest, url); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -553,7 +553,7 @@ void LLFeatureManager::fetchFeatureTableCoro(LLCoros::self& self, std::string ta void LLFeatureManager::fetchHTTPTables() { LLCoros::instance().launch("LLFeatureManager::fetchFeatureTableCoro", - boost::bind(&LLFeatureManager::fetchFeatureTableCoro, this, _1, FEATURE_TABLE_VER_FILENAME)); + boost::bind(&LLFeatureManager::fetchFeatureTableCoro, this, FEATURE_TABLE_VER_FILENAME)); } void LLFeatureManager::cleanupFeatureTables() diff --git a/indra/newview/llfeaturemanager.h b/indra/newview/llfeaturemanager.h index 1490c2122c..12ea691b49 100755 --- a/indra/newview/llfeaturemanager.h +++ b/indra/newview/llfeaturemanager.h @@ -166,7 +166,7 @@ protected: void initBaseMask(); - void fetchFeatureTableCoro(LLCoros::self& self, std::string name); + void fetchFeatureTableCoro(std::string name); std::map mMaskList; std::set mSkippedFeatures; diff --git a/indra/newview/llflickrconnect.cpp b/indra/newview/llflickrconnect.cpp index 873b1a7138..83e4f19191 100644 --- a/indra/newview/llflickrconnect.cpp +++ b/indra/newview/llflickrconnect.cpp @@ -67,7 +67,7 @@ void toast_user_for_flickr_success() /////////////////////////////////////////////////////////////////////////////// // -void LLFlickrConnect::flickrConnectCoro(LLCoros::self& self, std::string requestToken, std::string oauthVerifier) +void LLFlickrConnect::flickrConnectCoro(std::string requestToken, std::string oauthVerifier) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -86,7 +86,7 @@ void LLFlickrConnect::flickrConnectCoro(LLCoros::self& self, std::string request setConnectionState(LLFlickrConnect::FLICKR_CONNECTION_IN_PROGRESS); - LLSD result = httpAdapter->putAndYield(self, httpRequest, getFlickrConnectURL("/connection"), body, httpOpts); + LLSD result = httpAdapter->putAndYield(httpRequest, getFlickrConnectURL("/connection"), body, httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -157,7 +157,7 @@ bool LLFlickrConnect::testShareStatus(LLSD &result) return false; } -void LLFlickrConnect::flickrShareCoro(LLCoros::self& self, LLSD share) +void LLFlickrConnect::flickrShareCoro(LLSD share) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -170,7 +170,7 @@ void LLFlickrConnect::flickrShareCoro(LLCoros::self& self, LLSD share) setConnectionState(LLFlickrConnect::FLICKR_POSTING); - LLSD result = httpAdapter->postAndYield(self, httpRequest, getFlickrConnectURL("/share/photo", true), share, httpOpts); + LLSD result = httpAdapter->postAndYield(httpRequest, getFlickrConnectURL("/share/photo", true), share, httpOpts); if (testShareStatus(result)) { @@ -181,7 +181,7 @@ void LLFlickrConnect::flickrShareCoro(LLCoros::self& self, LLSD share) } -void LLFlickrConnect::flickrShareImageCoro(LLCoros::self& self, LLPointer image, std::string title, std::string description, std::string tags, int safetyLevel) +void LLFlickrConnect::flickrShareImageCoro(LLPointer image, std::string title, std::string description, std::string tags, int safetyLevel) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -248,7 +248,7 @@ void LLFlickrConnect::flickrShareImageCoro(LLCoros::self& self, LLPointerpostAndYield(self, httpRequest, getFlickrConnectURL("/share/photo", true), raw, httpOpts, httpHeaders); + LLSD result = httpAdapter->postAndYield(httpRequest, getFlickrConnectURL("/share/photo", true), raw, httpOpts, httpHeaders); if (testShareStatus(result)) { @@ -260,7 +260,7 @@ void LLFlickrConnect::flickrShareImageCoro(LLCoros::self& self, LLPointersetFollowRedirects(false); - LLSD result = httpAdapter->deleteAndYield(self, httpRequest, getFlickrConnectURL("/connection"), httpOpts); + LLSD result = httpAdapter->deleteAndYield(httpRequest, getFlickrConnectURL("/connection"), httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -294,7 +294,7 @@ void LLFlickrConnect::flickrDisconnectCoro(LLCoros::self& self) /////////////////////////////////////////////////////////////////////////////// // -void LLFlickrConnect::flickrConnectedCoro(LLCoros::self& self, bool autoConnect) +void LLFlickrConnect::flickrConnectedCoro(bool autoConnect) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -306,7 +306,7 @@ void LLFlickrConnect::flickrConnectedCoro(LLCoros::self& self, bool autoConnect) httpOpts->setFollowRedirects(false); - LLSD result = httpAdapter->getAndYield(self, httpRequest, getFlickrConnectURL("/connection", true), httpOpts); + LLSD result = httpAdapter->getAndYield(httpRequest, getFlickrConnectURL("/connection", true), httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -344,7 +344,7 @@ void LLFlickrConnect::flickrConnectedCoro(LLCoros::self& self, bool autoConnect) /////////////////////////////////////////////////////////////////////////////// // -void LLFlickrConnect::flickrInfoCoro(LLCoros::self& self) +void LLFlickrConnect::flickrInfoCoro() { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -355,7 +355,7 @@ void LLFlickrConnect::flickrInfoCoro(LLCoros::self& self) httpOpts->setWantHeaders(true); httpOpts->setFollowRedirects(false); - LLSD result = httpAdapter->getAndYield(self, httpRequest, getFlickrConnectURL("/info", true), httpOpts); + LLSD result = httpAdapter->getAndYield(httpRequest, getFlickrConnectURL("/info", true), httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -438,19 +438,19 @@ std::string LLFlickrConnect::getFlickrConnectURL(const std::string& route, bool void LLFlickrConnect::connectToFlickr(const std::string& request_token, const std::string& oauth_verifier) { LLCoros::instance().launch("LLFlickrConnect::flickrConnectCoro", - boost::bind(&LLFlickrConnect::flickrConnectCoro, this, _1, request_token, oauth_verifier)); + boost::bind(&LLFlickrConnect::flickrConnectCoro, this, request_token, oauth_verifier)); } void LLFlickrConnect::disconnectFromFlickr() { LLCoros::instance().launch("LLFlickrConnect::flickrDisconnectCoro", - boost::bind(&LLFlickrConnect::flickrDisconnectCoro, this, _1)); + boost::bind(&LLFlickrConnect::flickrDisconnectCoro, this)); } void LLFlickrConnect::checkConnectionToFlickr(bool auto_connect) { LLCoros::instance().launch("LLFlickrConnect::flickrConnectedCoro", - boost::bind(&LLFlickrConnect::flickrConnectedCoro, this, _1, auto_connect)); + boost::bind(&LLFlickrConnect::flickrConnectedCoro, this, auto_connect)); } void LLFlickrConnect::loadFlickrInfo() @@ -458,7 +458,7 @@ void LLFlickrConnect::loadFlickrInfo() if(mRefreshInfo) { LLCoros::instance().launch("LLFlickrConnect::flickrInfoCoro", - boost::bind(&LLFlickrConnect::flickrInfoCoro, this, _1)); + boost::bind(&LLFlickrConnect::flickrInfoCoro, this)); } } @@ -472,14 +472,14 @@ void LLFlickrConnect::uploadPhoto(const std::string& image_url, const std::strin body["safety_level"] = safety_level; LLCoros::instance().launch("LLFlickrConnect::flickrShareCoro", - boost::bind(&LLFlickrConnect::flickrShareCoro, this, _1, body)); + boost::bind(&LLFlickrConnect::flickrShareCoro, this, body)); } void LLFlickrConnect::uploadPhoto(LLPointer image, const std::string& title, const std::string& description, const std::string& tags, int safety_level) { LLCoros::instance().launch("LLFlickrConnect::flickrShareImageCoro", - boost::bind(&LLFlickrConnect::flickrShareImageCoro, this, _1, image, + boost::bind(&LLFlickrConnect::flickrShareImageCoro, this, image, title, description, tags, safety_level)); } diff --git a/indra/newview/llflickrconnect.h b/indra/newview/llflickrconnect.h index 26c63f8b08..0155804da0 100644 --- a/indra/newview/llflickrconnect.h +++ b/indra/newview/llflickrconnect.h @@ -97,12 +97,12 @@ private: static boost::scoped_ptr sContentWatcher; bool testShareStatus(LLSD &result); - void flickrConnectCoro(LLCoros::self& self, std::string requestToken, std::string oauthVerifier); - void flickrShareCoro(LLCoros::self& self, LLSD share); - void flickrShareImageCoro(LLCoros::self& self, LLPointer image, std::string title, std::string description, std::string tags, int safetyLevel); - void flickrDisconnectCoro(LLCoros::self& self); - void flickrConnectedCoro(LLCoros::self& self, bool autoConnect); - void flickrInfoCoro(LLCoros::self& self); + void flickrConnectCoro(std::string requestToken, std::string oauthVerifier); + void flickrShareCoro(LLSD share); + void flickrShareImageCoro(LLPointer image, std::string title, std::string description, std::string tags, int safetyLevel); + void flickrDisconnectCoro(); + void flickrConnectedCoro(bool autoConnect); + void flickrInfoCoro(); }; diff --git a/indra/newview/llfloateravatarpicker.cpp b/indra/newview/llfloateravatarpicker.cpp index e5e9a794a4..2824038f77 100755 --- a/indra/newview/llfloateravatarpicker.cpp +++ b/indra/newview/llfloateravatarpicker.cpp @@ -457,7 +457,7 @@ BOOL LLFloaterAvatarPicker::visibleItemsSelected() const } /*static*/ -void LLFloaterAvatarPicker::findCoro(LLCoros::self& self, std::string url, LLUUID queryID, std::string name) +void LLFloaterAvatarPicker::findCoro(std::string url, LLUUID queryID, std::string name) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -466,7 +466,7 @@ void LLFloaterAvatarPicker::findCoro(LLCoros::self& self, std::string url, LLUUI LL_INFOS("HttpCoroutineAdapter", "genericPostCoro") << "Generic POST for " << url << LL_ENDL; - LLSD result = httpAdapter->getAndYield(self, httpRequest, url); + LLSD result = httpAdapter->getAndYield(httpRequest, url); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -513,7 +513,7 @@ void LLFloaterAvatarPicker::find() LL_INFOS() << "avatar picker " << url << LL_ENDL; LLCoros::instance().launch("LLFloaterAvatarPicker::findCoro", - boost::bind(&LLFloaterAvatarPicker::findCoro, _1, url, mQueryID, getKey().asString())); + boost::bind(&LLFloaterAvatarPicker::findCoro, url, mQueryID, getKey().asString())); } else { diff --git a/indra/newview/llfloateravatarpicker.h b/indra/newview/llfloateravatarpicker.h index 200f74278e..fbee61b054 100755 --- a/indra/newview/llfloateravatarpicker.h +++ b/indra/newview/llfloateravatarpicker.h @@ -86,7 +86,7 @@ private: void populateFriend(); BOOL visibleItemsSelected() const; // Returns true if any items in the current tab are selected. - static void findCoro(LLCoros::self& self, std::string url, LLUUID mQueryID, std::string mName); + static void findCoro(std::string url, LLUUID mQueryID, std::string mName); void find(); void setAllowMultiple(BOOL allow_multiple); LLScrollListCtrl* getActiveList(); diff --git a/indra/newview/llfloatermodeluploadbase.cpp b/indra/newview/llfloatermodeluploadbase.cpp index aa91a2ce03..e2f84fd990 100755 --- a/indra/newview/llfloatermodeluploadbase.cpp +++ b/indra/newview/llfloatermodeluploadbase.cpp @@ -49,7 +49,7 @@ void LLFloaterModelUploadBase::requestAgentUploadPermissions() << "::requestAgentUploadPermissions() requesting for upload model permissions from: " << url << LL_ENDL; LLCoros::instance().launch("LLFloaterModelUploadBase::requestAgentUploadPermissionsCoro", - boost::bind(&LLFloaterModelUploadBase::requestAgentUploadPermissionsCoro, this, _1, url, getPermObserverHandle())); + boost::bind(&LLFloaterModelUploadBase::requestAgentUploadPermissionsCoro, this, url, getPermObserverHandle())); } else { @@ -61,7 +61,7 @@ void LLFloaterModelUploadBase::requestAgentUploadPermissions() } } -void LLFloaterModelUploadBase::requestAgentUploadPermissionsCoro(LLCoros::self& self, std::string url, +void LLFloaterModelUploadBase::requestAgentUploadPermissionsCoro(std::string url, LLHandle observerHandle) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); @@ -70,7 +70,7 @@ void LLFloaterModelUploadBase::requestAgentUploadPermissionsCoro(LLCoros::self& LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLSD result = httpAdapter->getAndYield(self, httpRequest, url); + LLSD result = httpAdapter->getAndYield(httpRequest, url); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); diff --git a/indra/newview/llfloatermodeluploadbase.h b/indra/newview/llfloatermodeluploadbase.h index 9bb9959af0..0d4c834122 100755 --- a/indra/newview/llfloatermodeluploadbase.h +++ b/indra/newview/llfloatermodeluploadbase.h @@ -56,7 +56,7 @@ protected: // requests agent's permissions to upload model void requestAgentUploadPermissions(); - void requestAgentUploadPermissionsCoro(LLCoros::self& self, std::string url, LLHandle observerHandle); + void requestAgentUploadPermissionsCoro(std::string url, LLHandle observerHandle); std::string mUploadModelUrl; bool mHasUploadPerm; diff --git a/indra/newview/llfloaterperms.cpp b/indra/newview/llfloaterperms.cpp index 06af2725c3..16bb449fdb 100755 --- a/indra/newview/llfloaterperms.cpp +++ b/indra/newview/llfloaterperms.cpp @@ -182,7 +182,7 @@ void LLFloaterPermsDefault::updateCap() if(!object_url.empty()) { LLCoros::instance().launch("LLFloaterPermsDefault::updateCapCoro", - boost::bind(&LLFloaterPermsDefault::updateCapCoro, _1, object_url)); + boost::bind(&LLFloaterPermsDefault::updateCapCoro, object_url)); } else { @@ -191,7 +191,7 @@ void LLFloaterPermsDefault::updateCap() } /*static*/ -void LLFloaterPermsDefault::updateCapCoro(LLCoros::self& self, std::string url) +void LLFloaterPermsDefault::updateCapCoro(std::string url) { static std::string previousReason; LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); @@ -215,7 +215,7 @@ void LLFloaterPermsDefault::updateCapCoro(LLCoros::self& self, std::string url) LL_CONT << sent_perms_log.str() << LL_ENDL; } - LLSD result = httpAdapter->postAndYield(self, httpRequest, url, postData); + LLSD result = httpAdapter->postAndYield(httpRequest, url, postData); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); diff --git a/indra/newview/llfloaterperms.h b/indra/newview/llfloaterperms.h index ba7d39fe89..e866b6de7d 100755 --- a/indra/newview/llfloaterperms.h +++ b/indra/newview/llfloaterperms.h @@ -82,7 +82,7 @@ private: void refresh(); static const std::string sCategoryNames[CAT_LAST]; - static void updateCapCoro(LLCoros::self& self, std::string url); + static void updateCapCoro(std::string url); // cached values only for implementing cancel. diff --git a/indra/newview/llfloaterscriptlimits.cpp b/indra/newview/llfloaterscriptlimits.cpp index be18565670..14719a77f9 100755 --- a/indra/newview/llfloaterscriptlimits.cpp +++ b/indra/newview/llfloaterscriptlimits.cpp @@ -200,7 +200,7 @@ BOOL LLPanelScriptLimitsRegionMemory::getLandScriptResources() if (!url.empty()) { LLCoros::instance().launch("LLPanelScriptLimitsRegionMemory::getLandScriptResourcesCoro", - boost::bind(&LLPanelScriptLimitsRegionMemory::getLandScriptResourcesCoro, this, _1, url)); + boost::bind(&LLPanelScriptLimitsRegionMemory::getLandScriptResourcesCoro, this, url)); return TRUE; } else @@ -209,7 +209,7 @@ BOOL LLPanelScriptLimitsRegionMemory::getLandScriptResources() } } -void LLPanelScriptLimitsRegionMemory::getLandScriptResourcesCoro(LLCoros::self& self, std::string url) +void LLPanelScriptLimitsRegionMemory::getLandScriptResourcesCoro(std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -220,7 +220,7 @@ void LLPanelScriptLimitsRegionMemory::getLandScriptResourcesCoro(LLCoros::self& postData["parcel_id"] = mParcelId; - LLSD result = httpAdapter->postAndYield(self, httpRequest, url, postData); + LLSD result = httpAdapter->postAndYield(httpRequest, url, postData); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -240,27 +240,27 @@ void LLPanelScriptLimitsRegionMemory::getLandScriptResourcesCoro(LLCoros::self& { std::string urlResourceSummary = result["ScriptResourceSummary"].asString(); LLCoros::instance().launch("LLPanelScriptLimitsRegionMemory::getLandScriptSummaryCoro", - boost::bind(&LLPanelScriptLimitsRegionMemory::getLandScriptSummaryCoro, this, _1, urlResourceSummary)); + boost::bind(&LLPanelScriptLimitsRegionMemory::getLandScriptSummaryCoro, this, urlResourceSummary)); } if (result.has("ScriptResourceDetails")) { std::string urlResourceDetails = result["ScriptResourceDetails"].asString(); LLCoros::instance().launch("LLPanelScriptLimitsRegionMemory::getLandScriptDetailsCoro", - boost::bind(&LLPanelScriptLimitsRegionMemory::getLandScriptDetailsCoro, this, _1, urlResourceDetails)); + boost::bind(&LLPanelScriptLimitsRegionMemory::getLandScriptDetailsCoro, this, urlResourceDetails)); } } -void LLPanelScriptLimitsRegionMemory::getLandScriptSummaryCoro(LLCoros::self& self, std::string url) +void LLPanelScriptLimitsRegionMemory::getLandScriptSummaryCoro(std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("getLandScriptSummaryCoro", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLSD result = httpAdapter->getAndYield(self, httpRequest, url); + LLSD result = httpAdapter->getAndYield(httpRequest, url); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -305,14 +305,14 @@ void LLPanelScriptLimitsRegionMemory::getLandScriptSummaryCoro(LLCoros::self& se } -void LLPanelScriptLimitsRegionMemory::getLandScriptDetailsCoro(LLCoros::self& self, std::string url) +void LLPanelScriptLimitsRegionMemory::getLandScriptDetailsCoro(std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("getLandScriptDetailsCoro", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLSD result = httpAdapter->getAndYield(self, httpRequest, url); + LLSD result = httpAdapter->getAndYield(httpRequest, url); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -947,7 +947,7 @@ BOOL LLPanelScriptLimitsAttachment::requestAttachmentDetails() if (!url.empty()) { LLCoros::instance().launch("LLPanelScriptLimitsAttachment::getAttachmentLimitsCoro", - boost::bind(&LLPanelScriptLimitsAttachment::getAttachmentLimitsCoro, this, _1, url)); + boost::bind(&LLPanelScriptLimitsAttachment::getAttachmentLimitsCoro, this, url)); return TRUE; } else @@ -956,14 +956,14 @@ BOOL LLPanelScriptLimitsAttachment::requestAttachmentDetails() } } -void LLPanelScriptLimitsAttachment::getAttachmentLimitsCoro(LLCoros::self& self, std::string url) +void LLPanelScriptLimitsAttachment::getAttachmentLimitsCoro(std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("getAttachmentLimitsCoro", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLSD result = httpAdapter->getAndYield(self, httpRequest, url); + LLSD result = httpAdapter->getAndYield(httpRequest, url); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); diff --git a/indra/newview/llfloaterscriptlimits.h b/indra/newview/llfloaterscriptlimits.h index 030020087b..e3cbbd185f 100755 --- a/indra/newview/llfloaterscriptlimits.h +++ b/indra/newview/llfloaterscriptlimits.h @@ -132,9 +132,9 @@ private: std::vector mObjectListItems; - void getLandScriptResourcesCoro(LLCoros::self& self, std::string url); - void getLandScriptSummaryCoro(LLCoros::self& self, std::string url); - void getLandScriptDetailsCoro(LLCoros::self& self, std::string url); + void getLandScriptResourcesCoro(std::string url); + void getLandScriptSummaryCoro(std::string url); + void getLandScriptDetailsCoro(std::string url); protected: @@ -180,7 +180,7 @@ public: void clearList(); private: - void getAttachmentLimitsCoro(LLCoros::self& self, std::string url); + void getAttachmentLimitsCoro(std::string url); bool mGotAttachmentMemoryUsed; S32 mAttachmentMemoryMax; diff --git a/indra/newview/llfloatertos.cpp b/indra/newview/llfloatertos.cpp index 27938bfbc4..6dc08417d7 100755 --- a/indra/newview/llfloatertos.cpp +++ b/indra/newview/llfloatertos.cpp @@ -190,7 +190,7 @@ void LLFloaterTOS::handleMediaEvent(LLPluginClassMedia* /*self*/, EMediaEvent ev std::string url(getString("real_url")); LLCoros::instance().launch("LLFloaterTOS::testSiteIsAliveCoro", - boost::bind(&LLFloaterTOS::testSiteIsAliveCoro, this, _1, url)); + boost::bind(&LLFloaterTOS::testSiteIsAliveCoro, this, url)); } else if(mRealNavigateBegun) { @@ -202,7 +202,7 @@ void LLFloaterTOS::handleMediaEvent(LLPluginClassMedia* /*self*/, EMediaEvent ev } } -void LLFloaterTOS::testSiteIsAliveCoro(LLCoros::self& self, std::string url) +void LLFloaterTOS::testSiteIsAliveCoro(std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -214,7 +214,7 @@ void LLFloaterTOS::testSiteIsAliveCoro(LLCoros::self& self, std::string url) LL_INFOS("HttpCoroutineAdapter", "genericPostCoro") << "Generic POST for " << url << LL_ENDL; - LLSD result = httpAdapter->getAndYield(self, httpRequest, url); + LLSD result = httpAdapter->getAndYield(httpRequest, url); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); diff --git a/indra/newview/llfloatertos.h b/indra/newview/llfloatertos.h index 90bea2fe83..2748b20513 100755 --- a/indra/newview/llfloatertos.h +++ b/indra/newview/llfloatertos.h @@ -62,7 +62,7 @@ public: /*virtual*/ void handleMediaEvent(LLPluginClassMedia* self, EMediaEvent event); private: - void testSiteIsAliveCoro(LLCoros::self& self, std::string url); + void testSiteIsAliveCoro(std::string url); std::string mMessage; bool mLoadingScreenLoaded; diff --git a/indra/newview/llfloaterurlentry.cpp b/indra/newview/llfloaterurlentry.cpp index 110d760dc9..6683a6e6e6 100755 --- a/indra/newview/llfloaterurlentry.cpp +++ b/indra/newview/llfloaterurlentry.cpp @@ -194,7 +194,7 @@ void LLFloaterURLEntry::onBtnOK( void* userdata ) (scheme == "http" || scheme == "https")) { LLCoros::instance().launch("LLFloaterURLEntry::getMediaTypeCoro", - boost::bind(&LLFloaterURLEntry::getMediaTypeCoro, _1, media_url, self->getHandle())); + boost::bind(&LLFloaterURLEntry::getMediaTypeCoro, media_url, self->getHandle())); } else { @@ -208,7 +208,7 @@ void LLFloaterURLEntry::onBtnOK( void* userdata ) } // static -void LLFloaterURLEntry::getMediaTypeCoro(LLCoros::self& self, std::string url, LLHandle parentHandle) +void LLFloaterURLEntry::getMediaTypeCoro(std::string url, LLHandle parentHandle) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -220,7 +220,7 @@ void LLFloaterURLEntry::getMediaTypeCoro(LLCoros::self& self, std::string url, L LL_INFOS("HttpCoroutineAdapter", "genericPostCoro") << "Generic POST for " << url << LL_ENDL; - LLSD result = httpAdapter->getAndYield(self, httpRequest, url, httpOpts); + LLSD result = httpAdapter->getAndYield(httpRequest, url, httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); diff --git a/indra/newview/llfloaterurlentry.h b/indra/newview/llfloaterurlentry.h index 2f5afa653d..20f4604907 100755 --- a/indra/newview/llfloaterurlentry.h +++ b/indra/newview/llfloaterurlentry.h @@ -60,7 +60,7 @@ private: static void onBtnClear(void*); bool callback_clear_url_list(const LLSD& notification, const LLSD& response); - static void getMediaTypeCoro(LLCoros::self& self, std::string url, LLHandle parentHandle); + static void getMediaTypeCoro(std::string url, LLHandle parentHandle); }; diff --git a/indra/newview/llgroupmgr.cpp b/indra/newview/llgroupmgr.cpp index 0fb39ab02e..edae0bfd19 100755 --- a/indra/newview/llgroupmgr.cpp +++ b/indra/newview/llgroupmgr.cpp @@ -1862,7 +1862,7 @@ void LLGroupMgr::sendGroupMemberEjects(const LLUUID& group_id, group_datap->mMemberVersion.generate(); } -void LLGroupMgr::getGroupBanRequestCoro(LLCoros::self& self, std::string url, LLUUID groupId) +void LLGroupMgr::getGroupBanRequestCoro(std::string url, LLUUID groupId) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -1871,7 +1871,7 @@ void LLGroupMgr::getGroupBanRequestCoro(LLCoros::self& self, std::string url, LL std::string finalUrl = url + "?group_id=" + groupId.asString(); - LLSD result = httpAdapter->getAndYield(self, httpRequest, finalUrl); + LLSD result = httpAdapter->getAndYield(httpRequest, finalUrl); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -1890,7 +1890,7 @@ void LLGroupMgr::getGroupBanRequestCoro(LLCoros::self& self, std::string url, LL } } -void LLGroupMgr::postGroupBanRequestCoro(LLCoros::self& self, std::string url, LLUUID groupId, +void LLGroupMgr::postGroupBanRequestCoro(std::string url, LLUUID groupId, U32 action, uuid_vec_t banList, bool update) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); @@ -1922,7 +1922,7 @@ void LLGroupMgr::postGroupBanRequestCoro(LLCoros::self& self, std::string url, L LL_WARNS() << "post: " << ll_pretty_print_sd(postData) << LL_ENDL; - LLSD result = httpAdapter->postAndYield(self, httpRequest, finalUrl, postData, httpOptions, httpHeaders); + LLSD result = httpAdapter->postAndYield(httpRequest, finalUrl, postData, httpOptions, httpHeaders); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -1942,7 +1942,7 @@ void LLGroupMgr::postGroupBanRequestCoro(LLCoros::self& self, std::string url, L if (update) { - getGroupBanRequestCoro(self, url, groupId); + getGroupBanRequestCoro(url, groupId); } } @@ -1979,11 +1979,11 @@ void LLGroupMgr::sendGroupBanRequest( EBanRequestType request_type, { case REQUEST_GET: LLCoros::instance().launch("LLGroupMgr::getGroupBanRequestCoro", - boost::bind(&LLGroupMgr::getGroupBanRequestCoro, this, _1, cap_url, group_id)); + boost::bind(&LLGroupMgr::getGroupBanRequestCoro, this, cap_url, group_id)); break; case REQUEST_POST: LLCoros::instance().launch("LLGroupMgr::postGroupBanRequestCoro", - boost::bind(&LLGroupMgr::postGroupBanRequestCoro, this, _1, cap_url, group_id, + boost::bind(&LLGroupMgr::postGroupBanRequestCoro, this, cap_url, group_id, action, ban_list, update)); break; case REQUEST_PUT: @@ -2028,7 +2028,7 @@ void LLGroupMgr::processGroupBanRequest(const LLSD& content) LLGroupMgr::getInstance()->notifyObservers(GC_BANLIST); } -void LLGroupMgr::groupMembersRequestCoro(LLCoros::self& self, std::string url, LLUUID groupId) +void LLGroupMgr::groupMembersRequestCoro(std::string url, LLUUID groupId) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -2041,7 +2041,7 @@ void LLGroupMgr::groupMembersRequestCoro(LLCoros::self& self, std::string url, L LLSD postData = LLSD::emptyMap(); postData["group_id"] = groupId; - LLSD result = httpAdapter->postAndYield(self, httpRequest, url, postData, httpOpts); + LLSD result = httpAdapter->postAndYield(httpRequest, url, postData, httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -2095,7 +2095,7 @@ void LLGroupMgr::sendCapGroupMembersRequest(const LLUUID& group_id) lastGroupMemberRequestFrame = gFrameCount; LLCoros::instance().launch("LLGroupMgr::groupMembersRequestCoro", - boost::bind(&LLGroupMgr::groupMembersRequestCoro, this, _1, cap_url, group_id)); + boost::bind(&LLGroupMgr::groupMembersRequestCoro, this, cap_url, group_id)); } diff --git a/indra/newview/llgroupmgr.h b/indra/newview/llgroupmgr.h index 1163923eff..fd0c2de854 100755 --- a/indra/newview/llgroupmgr.h +++ b/indra/newview/llgroupmgr.h @@ -428,11 +428,11 @@ public: void clearGroupData(const LLUUID& group_id); private: - void groupMembersRequestCoro(LLCoros::self& self, std::string url, LLUUID groupId); + void groupMembersRequestCoro(std::string url, LLUUID groupId); void processCapGroupMembersRequest(const LLSD& content); - void getGroupBanRequestCoro(LLCoros::self& self, std::string url, LLUUID groupId); - void postGroupBanRequestCoro(LLCoros::self& self, std::string url, LLUUID groupId, U32 action, uuid_vec_t banList, bool update); + void getGroupBanRequestCoro(std::string url, LLUUID groupId); + void postGroupBanRequestCoro(std::string url, LLUUID groupId, U32 action, uuid_vec_t banList, bool update); static void processGroupBanRequest(const LLSD& content); diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp index 0e5c16752e..8d670d0b0a 100755 --- a/indra/newview/llimview.cpp +++ b/indra/newview/llimview.cpp @@ -79,8 +79,8 @@ const static std::string NEARBY_P2P_BY_AGENT("nearby_P2P_by_agent"); /** Timeout of outgoing session initialization (in seconds) */ const static U32 SESSION_INITIALIZATION_TIMEOUT = 30; -void startConfrenceCoro(LLCoros::self& self, std::string url, LLUUID tempSessionId, LLUUID creatorId, LLUUID otherParticipantId, LLSD agents); -void chatterBoxInvitationCoro(LLCoros::self& self, std::string url, LLUUID sessionId, LLIMMgr::EInvitationType invitationType); +void startConfrenceCoro(std::string url, LLUUID tempSessionId, LLUUID creatorId, LLUUID otherParticipantId, LLSD agents); +void chatterBoxInvitationCoro(std::string url, LLUUID sessionId, LLIMMgr::EInvitationType invitationType); void start_deprecated_conference_chat(const LLUUID& temp_session_id, const LLUUID& creator_id, const LLUUID& other_participant_id, const LLSD& agents_to_invite); std::string LLCallDialogManager::sPreviousSessionlName = ""; @@ -389,7 +389,7 @@ void on_new_message(const LLSD& msg) notify_of_message(msg, false); } -void startConfrenceCoro(LLCoros::self& self, std::string url, +void startConfrenceCoro(std::string url, LLUUID tempSessionId, LLUUID creatorId, LLUUID otherParticipantId, LLSD agents) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); @@ -402,7 +402,7 @@ void startConfrenceCoro(LLCoros::self& self, std::string url, postData["session-id"] = tempSessionId; postData["params"] = agents; - LLSD result = httpAdapter->postAndYield(self, httpRequest, url, postData); + LLSD result = httpAdapter->postAndYield(httpRequest, url, postData); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -430,7 +430,7 @@ void startConfrenceCoro(LLCoros::self& self, std::string url, } } -void chatterBoxInvitationCoro(LLCoros::self& self, std::string url, LLUUID sessionId, LLIMMgr::EInvitationType invitationType) +void chatterBoxInvitationCoro(std::string url, LLUUID sessionId, LLIMMgr::EInvitationType invitationType) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -441,7 +441,7 @@ void chatterBoxInvitationCoro(LLCoros::self& self, std::string url, LLUUID sessi postData["method"] = "accept invitation"; postData["session-id"] = sessionId; - LLSD result = httpAdapter->postAndYield(self, httpRequest, url, postData); + LLSD result = httpAdapter->postAndYield(httpRequest, url, postData); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -1623,7 +1623,7 @@ bool LLIMModel::sendStartSession( "ChatSessionRequest"); LLCoros::instance().launch("startConfrenceCoro", - boost::bind(&startConfrenceCoro, _1, url, + boost::bind(&startConfrenceCoro, url, temp_session_id, gAgent.getID(), other_participant_id, agents)); } else @@ -2468,7 +2468,7 @@ void LLIncomingCallDialog::processCallResponse(S32 response, const LLSD &payload if (voice) { LLCoros::instance().launch("chatterBoxInvitationCoro", - boost::bind(&chatterBoxInvitationCoro, _1, url, + boost::bind(&chatterBoxInvitationCoro, url, session_id, inv_type)); // send notification message to the corresponding chat @@ -2555,7 +2555,7 @@ bool inviteUserResponse(const LLSD& notification, const LLSD& response) "ChatSessionRequest"); LLCoros::instance().launch("chatterBoxInvitationCoro", - boost::bind(&chatterBoxInvitationCoro, _1, url, + boost::bind(&chatterBoxInvitationCoro, url, session_id, inv_type)); } } @@ -3646,7 +3646,7 @@ public: if ( url != "" ) { LLCoros::instance().launch("chatterBoxInvitationCoro", - boost::bind(&chatterBoxInvitationCoro, _1, url, + boost::bind(&chatterBoxInvitationCoro, url, session_id, LLIMMgr::INVITATION_TYPE_INSTANT_MESSAGE)); } } //end if invitation has instant message diff --git a/indra/newview/llinventorymodel.cpp b/indra/newview/llinventorymodel.cpp index 6d21dd4ba7..25450f2317 100755 --- a/indra/newview/llinventorymodel.cpp +++ b/indra/newview/llinventorymodel.cpp @@ -578,7 +578,7 @@ LLUUID LLInventoryModel::createNewCategory(const LLUUID& parent_id, LL_DEBUGS(LOG_INV) << "create category request: " << ll_pretty_print_sd(request) << LL_ENDL; LLCoros::instance().launch("LLInventoryModel::createNewCategoryCoro", - boost::bind(&LLInventoryModel::createNewCategoryCoro, this, _1, url, body, callback)); + boost::bind(&LLInventoryModel::createNewCategoryCoro, this, url, body, callback)); return LLUUID::null; } @@ -607,7 +607,7 @@ LLUUID LLInventoryModel::createNewCategory(const LLUUID& parent_id, return id; } -void LLInventoryModel::createNewCategoryCoro(LLCoros::self& self, std::string url, LLSD postData, inventory_func_type callback) +void LLInventoryModel::createNewCategoryCoro(std::string url, LLSD postData, inventory_func_type callback) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -620,7 +620,7 @@ void LLInventoryModel::createNewCategoryCoro(LLCoros::self& self, std::string ur LL_INFOS("HttpCoroutineAdapter", "genericPostCoro") << "Generic POST for " << url << LL_ENDL; - LLSD result = httpAdapter->postAndYield(self, httpRequest, url, postData, httpOpts); + LLSD result = httpAdapter->postAndYield(httpRequest, url, postData, httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); diff --git a/indra/newview/llinventorymodel.h b/indra/newview/llinventorymodel.h index 26ee06535a..1f1c686ef1 100755 --- a/indra/newview/llinventorymodel.h +++ b/indra/newview/llinventorymodel.h @@ -444,7 +444,7 @@ protected: void addCategory(LLViewerInventoryCategory* category); void addItem(LLViewerInventoryItem* item); - void createNewCategoryCoro(LLCoros::self& self, std::string url, LLSD postData, inventory_func_type callback); + void createNewCategoryCoro(std::string url, LLSD postData, inventory_func_type callback); /** Mutators ** ** diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index bd77912a6c..38c4382654 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -126,7 +126,7 @@ namespace LLMarketplaceImport // Responders #if 1 - void marketplacePostCoro(LLCoros::self& self, std::string url) + void marketplacePostCoro(std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -144,7 +144,7 @@ namespace LLMarketplaceImport httpHeaders->append(HTTP_OUT_HEADER_CONTENT_TYPE, HTTP_CONTENT_XML); httpHeaders->append(HTTP_OUT_HEADER_USER_AGENT, LLViewerMedia::getCurrentUserAgent()); - LLSD result = httpAdapter->postAndYield(self, httpRequest, url, LLSD(), httpOpts, httpHeaders); + LLSD result = httpAdapter->postAndYield(httpRequest, url, LLSD(), httpOpts, httpHeaders); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -237,7 +237,7 @@ namespace LLMarketplaceImport #endif #if 1 - void marketplaceGetCoro(LLCoros::self& self, std::string url, bool buildHeaders) + void marketplaceGetCoro(std::string url, bool buildHeaders) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -263,7 +263,7 @@ namespace LLMarketplaceImport httpHeaders = LLViewerMedia::getHttpHeaders(); } - LLSD result = httpAdapter->getAndYield(self, httpRequest, url, httpOpts, httpHeaders); + LLSD result = httpAdapter->getAndYield(httpRequest, url, httpOpts, httpHeaders); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -405,7 +405,7 @@ namespace LLMarketplaceImport #if 1 LLCoros::instance().launch("marketplaceGetCoro", - boost::bind(&marketplaceGetCoro, _1, url, false)); + boost::bind(&marketplaceGetCoro, url, false)); #else if (gSavedSettings.getBOOL("InventoryOutboxLogging")) @@ -439,7 +439,7 @@ namespace LLMarketplaceImport #if 1 LLCoros::instance().launch("marketplaceGetCoro", - boost::bind(&marketplaceGetCoro, _1, url, true)); + boost::bind(&marketplaceGetCoro, url, true)); #else // Make the headers for the post @@ -482,7 +482,7 @@ namespace LLMarketplaceImport #if 1 LLCoros::instance().launch("marketplacePostCoro", - boost::bind(&marketplacePostCoro, _1, url)); + boost::bind(&marketplacePostCoro, url)); #else // Make the headers for the post diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index 5dc90c987d..2e6937a79f 100755 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -225,7 +225,7 @@ void LLPathfindingManager::requestGetNavMeshForRegion(LLViewerRegion *pRegion, b U64 regionHandle = pRegion->getHandle(); std::string coroname = LLCoros::instance().launch("LLPathfindingManager::navMeshStatusRequestCoro", - boost::bind(&LLPathfindingManager::navMeshStatusRequestCoro, this, _1, navMeshStatusURL, regionHandle, pIsGetStatusOnly)); + boost::bind(&LLPathfindingManager::navMeshStatusRequestCoro, this, navMeshStatusURL, regionHandle, pIsGetStatusOnly)); } } @@ -259,12 +259,12 @@ void LLPathfindingManager::requestGetLinksets(request_id_t pRequestId, object_re LinksetsResponder::ptr_t linksetsResponderPtr(new LinksetsResponder(pRequestId, pLinksetsCallback, true, doRequestTerrain)); std::string coroname = LLCoros::instance().launch("LLPathfindingManager::linksetObjectsCoro", - boost::bind(&LLPathfindingManager::linksetObjectsCoro, this, _1, objectLinksetsURL, linksetsResponderPtr, LLSD())); + boost::bind(&LLPathfindingManager::linksetObjectsCoro, this, objectLinksetsURL, linksetsResponderPtr, LLSD())); if (doRequestTerrain) { std::string coroname = LLCoros::instance().launch("LLPathfindingManager::linksetTerrainCoro", - boost::bind(&LLPathfindingManager::linksetTerrainCoro, this, _1, terrainLinksetsURL, linksetsResponderPtr, LLSD())); + boost::bind(&LLPathfindingManager::linksetTerrainCoro, this, terrainLinksetsURL, linksetsResponderPtr, LLSD())); } } } @@ -308,13 +308,13 @@ void LLPathfindingManager::requestSetLinksets(request_id_t pRequestId, const LLP if (!objectPostData.isUndefined()) { std::string coroname = LLCoros::instance().launch("LLPathfindingManager::linksetObjectsCoro", - boost::bind(&LLPathfindingManager::linksetObjectsCoro, this, _1, objectLinksetsURL, linksetsResponderPtr, objectPostData)); + boost::bind(&LLPathfindingManager::linksetObjectsCoro, this, objectLinksetsURL, linksetsResponderPtr, objectPostData)); } if (!terrainPostData.isUndefined()) { std::string coroname = LLCoros::instance().launch("LLPathfindingManager::linksetTerrainCoro", - boost::bind(&LLPathfindingManager::linksetTerrainCoro, this, _1, terrainLinksetsURL, linksetsResponderPtr, terrainPostData)); + boost::bind(&LLPathfindingManager::linksetTerrainCoro, this, terrainLinksetsURL, linksetsResponderPtr, terrainPostData)); } } } @@ -347,7 +347,7 @@ void LLPathfindingManager::requestGetCharacters(request_id_t pRequestId, object_ pCharactersCallback(pRequestId, kRequestStarted, emptyCharacterListPtr); std::string coroname = LLCoros::instance().launch("LLPathfindingManager::charactersCoro", - boost::bind(&LLPathfindingManager::charactersCoro, this, _1, charactersURL, pRequestId, pCharactersCallback)); + boost::bind(&LLPathfindingManager::charactersCoro, this, charactersURL, pRequestId, pCharactersCallback)); } } } @@ -381,7 +381,7 @@ void LLPathfindingManager::requestGetAgentState() llassert(!agentStateURL.empty()); std::string coroname = LLCoros::instance().launch("LLPathfindingManager::navAgentStateRequestCoro", - boost::bind(&LLPathfindingManager::navAgentStateRequestCoro, this, _1, agentStateURL)); + boost::bind(&LLPathfindingManager::navAgentStateRequestCoro, this, agentStateURL)); } } } @@ -404,7 +404,7 @@ void LLPathfindingManager::requestRebakeNavMesh(rebake_navmesh_callback_t pRebak llassert(!navMeshStatusURL.empty()); std::string coroname = LLCoros::instance().launch("LLPathfindingManager::navMeshRebakeCoro", - boost::bind(&LLPathfindingManager::navMeshRebakeCoro, this, _1, navMeshStatusURL, pRebakeNavMeshCallback)); + boost::bind(&LLPathfindingManager::navMeshRebakeCoro, this, navMeshStatusURL, pRebakeNavMeshCallback)); } } @@ -448,7 +448,7 @@ void LLPathfindingManager::handleDeferredGetCharactersForRegion(const LLUUID &pR } } -void LLPathfindingManager::navMeshStatusRequestCoro(LLCoros::self& self, std::string url, U64 regionHandle, bool isGetStatusOnly) +void LLPathfindingManager::navMeshStatusRequestCoro(std::string url, U64 regionHandle, bool isGetStatusOnly) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -464,7 +464,7 @@ void LLPathfindingManager::navMeshStatusRequestCoro(LLCoros::self& self, std::st LLUUID regionUUID = region->getRegionID(); region = NULL; - LLSD result = httpAdapter->getAndYield(self, httpRequest, url); + LLSD result = httpAdapter->getAndYield(httpRequest, url); region = LLWorld::getInstance()->getRegionFromHandle(regionHandle); @@ -519,7 +519,7 @@ void LLPathfindingManager::navMeshStatusRequestCoro(LLCoros::self& self, std::st navMeshPtr->handleNavMeshStart(navMeshStatus); LLSD postData; - result = httpAdapter->postAndYield(self, httpRequest, navMeshURL, postData); + result = httpAdapter->postAndYield(httpRequest, navMeshURL, postData); U32 navMeshVersion = navMeshStatus.getVersion(); @@ -538,14 +538,14 @@ void LLPathfindingManager::navMeshStatusRequestCoro(LLCoros::self& self, std::st } -void LLPathfindingManager::navAgentStateRequestCoro(LLCoros::self& self, std::string url) +void LLPathfindingManager::navAgentStateRequestCoro(std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("NavAgentStateRequest", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLSD result = httpAdapter->getAndYield(self, httpRequest, url); + LLSD result = httpAdapter->getAndYield(httpRequest, url); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -566,7 +566,7 @@ void LLPathfindingManager::navAgentStateRequestCoro(LLCoros::self& self, std::st handleAgentState(canRebake); } -void LLPathfindingManager::navMeshRebakeCoro(LLCoros::self& self, std::string url, rebake_navmesh_callback_t rebakeNavMeshCallback) +void LLPathfindingManager::navMeshRebakeCoro(std::string url, rebake_navmesh_callback_t rebakeNavMeshCallback) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -577,7 +577,7 @@ void LLPathfindingManager::navMeshRebakeCoro(LLCoros::self& self, std::string ur LLSD postData = LLSD::emptyMap(); postData["command"] = "rebuild"; - LLSD result = httpAdapter->postAndYield(self, httpRequest, url, postData); + LLSD result = httpAdapter->postAndYield(httpRequest, url, postData); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -595,7 +595,7 @@ void LLPathfindingManager::navMeshRebakeCoro(LLCoros::self& self, std::string ur // If called with putData undefined this coroutine will issue a get. If there // is data in putData it will be PUT to the URL. -void LLPathfindingManager::linksetObjectsCoro(LLCoros::self &self, std::string url, LinksetsResponder::ptr_t linksetsResponsderPtr, LLSD putData) const +void LLPathfindingManager::linksetObjectsCoro(std::string url, LinksetsResponder::ptr_t linksetsResponsderPtr, LLSD putData) const { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -606,11 +606,11 @@ void LLPathfindingManager::linksetObjectsCoro(LLCoros::self &self, std::string u if (putData.isUndefined()) { - result = httpAdapter->getAndYield(self, httpRequest, url); + result = httpAdapter->getAndYield(httpRequest, url); } else { - result = httpAdapter->putAndYield(self, httpRequest, url, putData); + result = httpAdapter->putAndYield(httpRequest, url, putData); } LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; @@ -631,7 +631,7 @@ void LLPathfindingManager::linksetObjectsCoro(LLCoros::self &self, std::string u // If called with putData undefined this coroutine will issue a GET. If there // is data in putData it will be PUT to the URL. -void LLPathfindingManager::linksetTerrainCoro(LLCoros::self &self, std::string url, LinksetsResponder::ptr_t linksetsResponsderPtr, LLSD putData) const +void LLPathfindingManager::linksetTerrainCoro(std::string url, LinksetsResponder::ptr_t linksetsResponsderPtr, LLSD putData) const { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -642,11 +642,11 @@ void LLPathfindingManager::linksetTerrainCoro(LLCoros::self &self, std::string u if (putData.isUndefined()) { - result = httpAdapter->getAndYield(self, httpRequest, url); + result = httpAdapter->getAndYield(httpRequest, url); } else { - result = httpAdapter->putAndYield(self, httpRequest, url, putData); + result = httpAdapter->putAndYield(httpRequest, url, putData); } LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; @@ -666,14 +666,14 @@ void LLPathfindingManager::linksetTerrainCoro(LLCoros::self &self, std::string u } -void LLPathfindingManager::charactersCoro(LLCoros::self &self, std::string url, request_id_t requestId, object_request_callback_t callback) const +void LLPathfindingManager::charactersCoro(std::string url, request_id_t requestId, object_request_callback_t callback) const { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("LinksetTerrain", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLSD result = httpAdapter->getAndYield(self, httpRequest, url); + LLSD result = httpAdapter->getAndYield(httpRequest, url); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); diff --git a/indra/newview/llpathfindingmanager.h b/indra/newview/llpathfindingmanager.h index abf611801c..e8fad590ba 100755 --- a/indra/newview/llpathfindingmanager.h +++ b/indra/newview/llpathfindingmanager.h @@ -104,12 +104,12 @@ private: void handleDeferredGetLinksetsForRegion(const LLUUID &pRegionUUID, request_id_t pRequestId, object_request_callback_t pLinksetsCallback) const; void handleDeferredGetCharactersForRegion(const LLUUID &pRegionUUID, request_id_t pRequestId, object_request_callback_t pCharactersCallback) const; - void navMeshStatusRequestCoro(LLCoros::self& self, std::string url, U64 regionHandle, bool isGetStatusOnly); - void navAgentStateRequestCoro(LLCoros::self& self, std::string url); - void navMeshRebakeCoro(LLCoros::self& self, std::string url, rebake_navmesh_callback_t rebakeNavMeshCallback); - void linksetObjectsCoro(LLCoros::self &self, std::string url, boost::shared_ptr linksetsResponsderPtr, LLSD putData) const; - void linksetTerrainCoro(LLCoros::self &self, std::string url, boost::shared_ptr linksetsResponsderPtr, LLSD putData) const; - void charactersCoro(LLCoros::self &self, std::string url, request_id_t requestId, object_request_callback_t callback) const; + void navMeshStatusRequestCoro(std::string url, U64 regionHandle, bool isGetStatusOnly); + void navAgentStateRequestCoro(std::string url); + void navMeshRebakeCoro(std::string url, rebake_navmesh_callback_t rebakeNavMeshCallback); + void linksetObjectsCoro(std::string url, boost::shared_ptr linksetsResponsderPtr, LLSD putData) const; + void linksetTerrainCoro(std::string url, boost::shared_ptr linksetsResponsderPtr, LLSD putData) const; + void charactersCoro(std::string url, request_id_t requestId, object_request_callback_t callback) const; //void handleNavMeshStatusRequest(const LLPathfindingNavMeshStatus &pNavMeshStatus, LLViewerRegion *pRegion, bool pIsGetStatusOnly); void handleNavMeshStatusUpdate(const LLPathfindingNavMeshStatus &pNavMeshStatus); diff --git a/indra/newview/llproductinforequest.cpp b/indra/newview/llproductinforequest.cpp index fd948765b3..467e9df482 100755 --- a/indra/newview/llproductinforequest.cpp +++ b/indra/newview/llproductinforequest.cpp @@ -45,7 +45,7 @@ void LLProductInfoRequestManager::initSingleton() if (!url.empty()) { LLCoros::instance().launch("LLProductInfoRequestManager::getLandDescriptionsCoro", - boost::bind(&LLProductInfoRequestManager::getLandDescriptionsCoro, this, _1, url)); + boost::bind(&LLProductInfoRequestManager::getLandDescriptionsCoro, this, url)); } } @@ -66,14 +66,14 @@ std::string LLProductInfoRequestManager::getDescriptionForSku(const std::string& return LLTrans::getString("land_type_unknown"); } -void LLProductInfoRequestManager::getLandDescriptionsCoro(LLCoros::self& self, std::string url) +void LLProductInfoRequestManager::getLandDescriptionsCoro(std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("genericPostCoro", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLSD result = httpAdapter->getAndYield(self, httpRequest, url); + LLSD result = httpAdapter->getAndYield(httpRequest, url); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); diff --git a/indra/newview/llproductinforequest.h b/indra/newview/llproductinforequest.h index 3ddae95a93..75dbf220d1 100755 --- a/indra/newview/llproductinforequest.h +++ b/indra/newview/llproductinforequest.h @@ -49,7 +49,7 @@ private: friend class LLSingleton; /* virtual */ void initSingleton(); - void getLandDescriptionsCoro(LLCoros::self& self, std::string url); + void getLandDescriptionsCoro(std::string url); LLSD mSkuDescriptions; }; diff --git a/indra/newview/llremoteparcelrequest.cpp b/indra/newview/llremoteparcelrequest.cpp index 7e8e9ac18e..06bf90c7cb 100755 --- a/indra/newview/llremoteparcelrequest.cpp +++ b/indra/newview/llremoteparcelrequest.cpp @@ -170,7 +170,7 @@ bool LLRemoteParcelInfoProcessor::requestRegionParcelInfo(const std::string &url if (!url.empty()) { LLCoros::instance().launch("LLRemoteParcelInfoProcessor::regionParcelInfoCoro", - boost::bind(&LLRemoteParcelInfoProcessor::regionParcelInfoCoro, this, _1, url, + boost::bind(&LLRemoteParcelInfoProcessor::regionParcelInfoCoro, this, url, regionId, regionPos, globalPos, observerHandle)); return true; } @@ -178,7 +178,7 @@ bool LLRemoteParcelInfoProcessor::requestRegionParcelInfo(const std::string &url return false; } -void LLRemoteParcelInfoProcessor::regionParcelInfoCoro(LLCoros::self& self, std::string url, +void LLRemoteParcelInfoProcessor::regionParcelInfoCoro(std::string url, LLUUID regionId, LLVector3 posRegion, LLVector3d posGlobal, LLHandle observerHandle) { @@ -200,7 +200,7 @@ void LLRemoteParcelInfoProcessor::regionParcelInfoCoro(LLCoros::self& self, std: bodyData["region_handle"] = ll_sd_from_U64(regionHandle); } - LLSD result = httpAdapter->postAndYield(self, httpRequest, url, bodyData); + LLSD result = httpAdapter->postAndYield(httpRequest, url, bodyData); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); diff --git a/indra/newview/llremoteparcelrequest.h b/indra/newview/llremoteparcelrequest.h index 982a1590e5..cb5af50c5f 100755 --- a/indra/newview/llremoteparcelrequest.h +++ b/indra/newview/llremoteparcelrequest.h @@ -91,7 +91,7 @@ private: typedef std::multimap > observer_multimap_t; observer_multimap_t mObservers; - void regionParcelInfoCoro(LLCoros::self& self, std::string url, LLUUID regionId, LLVector3 posRegion, LLVector3d posGlobal, LLHandle observerHandle); + void regionParcelInfoCoro(std::string url, LLUUID regionId, LLVector3 posRegion, LLVector3d posGlobal, LLHandle observerHandle); }; #endif // LL_LLREMOTEPARCELREQUEST_H diff --git a/indra/newview/llspeakers.cpp b/indra/newview/llspeakers.cpp index 9a9739c9cb..3b060d8343 100755 --- a/indra/newview/llspeakers.cpp +++ b/indra/newview/llspeakers.cpp @@ -841,7 +841,7 @@ void LLIMSpeakerMgr::toggleAllowTextChat(const LLUUID& speaker_id) data["params"]["mute_info"]["text"] = !speakerp->mModeratorMutedText; LLCoros::instance().launch("LLIMSpeakerMgr::moderationActionCoro", - boost::bind(&LLIMSpeakerMgr::moderationActionCoro, this, _1, url, data)); + boost::bind(&LLIMSpeakerMgr::moderationActionCoro, this, url, data)); } void LLIMSpeakerMgr::moderateVoiceParticipant(const LLUUID& avatar_id, bool unmute) @@ -866,10 +866,10 @@ void LLIMSpeakerMgr::moderateVoiceParticipant(const LLUUID& avatar_id, bool unmu data["params"]["mute_info"]["voice"] = !unmute; LLCoros::instance().launch("LLIMSpeakerMgr::moderationActionCoro", - boost::bind(&LLIMSpeakerMgr::moderationActionCoro, this, _1, url, data)); + boost::bind(&LLIMSpeakerMgr::moderationActionCoro, this, url, data)); } -void LLIMSpeakerMgr::moderationActionCoro(LLCoros::self& self, std::string url, LLSD action) +void LLIMSpeakerMgr::moderationActionCoro(std::string url, LLSD action) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -881,7 +881,7 @@ void LLIMSpeakerMgr::moderationActionCoro(LLCoros::self& self, std::string url, LLUUID sessionId = action["session-id"]; - LLSD result = httpAdapter->postAndYield(self, httpRequest, url, action, httpOpts); + LLSD result = httpAdapter->postAndYield(httpRequest, url, action, httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -948,7 +948,7 @@ void LLIMSpeakerMgr::moderateVoiceSession(const LLUUID& session_id, bool disallo data["params"]["update_info"]["moderated_mode"]["voice"] = disallow_voice; LLCoros::instance().launch("LLIMSpeakerMgr::moderationActionCoro", - boost::bind(&LLIMSpeakerMgr::moderationActionCoro, this, _1, url, data)); + boost::bind(&LLIMSpeakerMgr::moderationActionCoro, this, url, data)); } void LLIMSpeakerMgr::forceVoiceModeratedMode(bool should_be_muted) diff --git a/indra/newview/llspeakers.h b/indra/newview/llspeakers.h index 1f3b2f584c..5cff70f377 100755 --- a/indra/newview/llspeakers.h +++ b/indra/newview/llspeakers.h @@ -335,7 +335,7 @@ protected: */ void forceVoiceModeratedMode(bool should_be_muted); - void moderationActionCoro(LLCoros::self& self, std::string url, LLSD action); + void moderationActionCoro(std::string url, LLSD action); }; diff --git a/indra/newview/llsyntaxid.cpp b/indra/newview/llsyntaxid.cpp index d2197dcb4f..7f286044d6 100644 --- a/indra/newview/llsyntaxid.cpp +++ b/indra/newview/llsyntaxid.cpp @@ -108,14 +108,14 @@ bool LLSyntaxIdLSL::syntaxIdChanged() void LLSyntaxIdLSL::fetchKeywordsFile(const std::string& filespec) { LLCoros::instance().launch("LLSyntaxIdLSL::fetchKeywordsFileCoro", - boost::bind(&LLSyntaxIdLSL::fetchKeywordsFileCoro, this, _1, mCapabilityURL, filespec)); + boost::bind(&LLSyntaxIdLSL::fetchKeywordsFileCoro, this, mCapabilityURL, filespec)); LL_DEBUGS("SyntaxLSL") << "LSLSyntaxId capability URL is: " << mCapabilityURL << ". Filename to use is: '" << filespec << "'." << LL_ENDL; } //----------------------------------------------------------------------------- // fetchKeywordsFileCoro //----------------------------------------------------------------------------- -void LLSyntaxIdLSL::fetchKeywordsFileCoro(LLCoros::self& self, std::string url, std::string fileSpec) +void LLSyntaxIdLSL::fetchKeywordsFileCoro(std::string url, std::string fileSpec) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -129,7 +129,7 @@ void LLSyntaxIdLSL::fetchKeywordsFileCoro(LLCoros::self& self, std::string url, return; } - LLSD result = httpAdapter->getAndYield(self, httpRequest, url); + LLSD result = httpAdapter->getAndYield(httpRequest, url); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); diff --git a/indra/newview/llsyntaxid.h b/indra/newview/llsyntaxid.h index 47de94cea2..0afa6dc04b 100644 --- a/indra/newview/llsyntaxid.h +++ b/indra/newview/llsyntaxid.h @@ -57,7 +57,7 @@ private: void loadDefaultKeywordsIntoLLSD(); void loadKeywordsIntoLLSD(); - void fetchKeywordsFileCoro(LLCoros::self& self, std::string url, std::string fileSpec); + void fetchKeywordsFileCoro(std::string url, std::string fileSpec); void cacheFile(const std::string &fileSpec, const LLSD& content_ref); std::string mCapabilityURL; diff --git a/indra/newview/lltwitterconnect.cpp b/indra/newview/lltwitterconnect.cpp index 09435850c3..c6a0a15759 100644 --- a/indra/newview/lltwitterconnect.cpp +++ b/indra/newview/lltwitterconnect.cpp @@ -67,7 +67,7 @@ void toast_user_for_twitter_success() /////////////////////////////////////////////////////////////////////////////// // -void LLTwitterConnect::twitterConnectCoro(LLCoros::self& self, std::string requestToken, std::string oauthVerifier) +void LLTwitterConnect::twitterConnectCoro(std::string requestToken, std::string oauthVerifier) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -86,7 +86,7 @@ void LLTwitterConnect::twitterConnectCoro(LLCoros::self& self, std::string reque setConnectionState(LLTwitterConnect::TWITTER_CONNECTION_IN_PROGRESS); - LLSD result = httpAdapter->putAndYield(self, httpRequest, getTwitterConnectURL("/connection"), body, httpOpts); + LLSD result = httpAdapter->putAndYield(httpRequest, getTwitterConnectURL("/connection"), body, httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -157,7 +157,7 @@ bool LLTwitterConnect::testShareStatus(LLSD &result) return false; } -void LLTwitterConnect::twitterShareCoro(LLCoros::self& self, std::string route, LLSD share) +void LLTwitterConnect::twitterShareCoro(std::string route, LLSD share) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -170,7 +170,7 @@ void LLTwitterConnect::twitterShareCoro(LLCoros::self& self, std::string route, setConnectionState(LLTwitterConnect::TWITTER_POSTING); - LLSD result = httpAdapter->postAndYield(self, httpRequest, getTwitterConnectURL(route, true), share, httpOpts); + LLSD result = httpAdapter->postAndYield(httpRequest, getTwitterConnectURL(route, true), share, httpOpts); if (testShareStatus(result)) { @@ -180,7 +180,7 @@ void LLTwitterConnect::twitterShareCoro(LLCoros::self& self, std::string route, } } -void LLTwitterConnect::twitterShareImageCoro(LLCoros::self& self, LLPointer image, std::string status) +void LLTwitterConnect::twitterShareImageCoro(LLPointer image, std::string status) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -235,7 +235,7 @@ void LLTwitterConnect::twitterShareImageCoro(LLCoros::self& self, LLPointerpostAndYield(self, httpRequest, getTwitterConnectURL("/share/photo", true), raw, httpOpts, httpHeaders); + LLSD result = httpAdapter->postAndYield(httpRequest, getTwitterConnectURL("/share/photo", true), raw, httpOpts, httpHeaders); if (testShareStatus(result)) { @@ -247,7 +247,7 @@ void LLTwitterConnect::twitterShareImageCoro(LLCoros::self& self, LLPointerdeleteAndYield(self, httpRequest, getTwitterConnectURL("/connection"), httpOpts); + LLSD result = httpAdapter->deleteAndYield(httpRequest, getTwitterConnectURL("/connection"), httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -282,7 +282,7 @@ void LLTwitterConnect::twitterDisconnectCoro(LLCoros::self& self) /////////////////////////////////////////////////////////////////////////////// // -void LLTwitterConnect::twitterConnectedCoro(LLCoros::self& self, bool autoConnect) +void LLTwitterConnect::twitterConnectedCoro(bool autoConnect) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -293,7 +293,7 @@ void LLTwitterConnect::twitterConnectedCoro(LLCoros::self& self, bool autoConnec httpOpts->setFollowRedirects(false); setConnectionState(LLTwitterConnect::TWITTER_CONNECTION_IN_PROGRESS); - LLSD result = httpAdapter->getAndYield(self, httpRequest, getTwitterConnectURL("/connection", true), httpOpts); + LLSD result = httpAdapter->getAndYield(httpRequest, getTwitterConnectURL("/connection", true), httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -331,7 +331,7 @@ void LLTwitterConnect::twitterConnectedCoro(LLCoros::self& self, bool autoConnec /////////////////////////////////////////////////////////////////////////////// // -void LLTwitterConnect::twitterInfoCoro(LLCoros::self& self) +void LLTwitterConnect::twitterInfoCoro() { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -342,7 +342,7 @@ void LLTwitterConnect::twitterInfoCoro(LLCoros::self& self) httpOpts->setWantHeaders(true); httpOpts->setFollowRedirects(false); - LLSD result = httpAdapter->getAndYield(self, httpRequest, getTwitterConnectURL("/info", true), httpOpts); + LLSD result = httpAdapter->getAndYield(httpRequest, getTwitterConnectURL("/info", true), httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -425,19 +425,19 @@ std::string LLTwitterConnect::getTwitterConnectURL(const std::string& route, boo void LLTwitterConnect::connectToTwitter(const std::string& request_token, const std::string& oauth_verifier) { LLCoros::instance().launch("LLTwitterConnect::twitterConnectCoro", - boost::bind(&LLTwitterConnect::twitterConnectCoro, this, _1, request_token, oauth_verifier)); + boost::bind(&LLTwitterConnect::twitterConnectCoro, this, request_token, oauth_verifier)); } void LLTwitterConnect::disconnectFromTwitter() { LLCoros::instance().launch("LLTwitterConnect::twitterDisconnectCoro", - boost::bind(&LLTwitterConnect::twitterDisconnectCoro, this, _1)); + boost::bind(&LLTwitterConnect::twitterDisconnectCoro, this)); } void LLTwitterConnect::checkConnectionToTwitter(bool auto_connect) { LLCoros::instance().launch("LLTwitterConnect::twitterConnectedCoro", - boost::bind(&LLTwitterConnect::twitterConnectedCoro, this, _1, auto_connect)); + boost::bind(&LLTwitterConnect::twitterConnectedCoro, this, auto_connect)); } void LLTwitterConnect::loadTwitterInfo() @@ -445,7 +445,7 @@ void LLTwitterConnect::loadTwitterInfo() if(mRefreshInfo) { LLCoros::instance().launch("LLTwitterConnect::twitterInfoCoro", - boost::bind(&LLTwitterConnect::twitterInfoCoro, this, _1)); + boost::bind(&LLTwitterConnect::twitterInfoCoro, this)); } } @@ -456,13 +456,13 @@ void LLTwitterConnect::uploadPhoto(const std::string& image_url, const std::stri body["status"] = status; LLCoros::instance().launch("LLTwitterConnect::twitterShareCoro", - boost::bind(&LLTwitterConnect::twitterShareCoro, this, _1, "/share/photo", body)); + boost::bind(&LLTwitterConnect::twitterShareCoro, this, "/share/photo", body)); } void LLTwitterConnect::uploadPhoto(LLPointer image, const std::string& status) { LLCoros::instance().launch("LLTwitterConnect::twitterShareImageCoro", - boost::bind(&LLTwitterConnect::twitterShareImageCoro, this, _1, image, status)); + boost::bind(&LLTwitterConnect::twitterShareImageCoro, this, image, status)); } void LLTwitterConnect::updateStatus(const std::string& status) @@ -471,7 +471,7 @@ void LLTwitterConnect::updateStatus(const std::string& status) body["status"] = status; LLCoros::instance().launch("LLTwitterConnect::twitterShareCoro", - boost::bind(&LLTwitterConnect::twitterShareCoro, this, _1, "/share/status", body)); + boost::bind(&LLTwitterConnect::twitterShareCoro, this, "/share/status", body)); } void LLTwitterConnect::storeInfo(const LLSD& info) diff --git a/indra/newview/lltwitterconnect.h b/indra/newview/lltwitterconnect.h index 4d11118143..be481a17c1 100644 --- a/indra/newview/lltwitterconnect.h +++ b/indra/newview/lltwitterconnect.h @@ -98,12 +98,12 @@ private: static boost::scoped_ptr sContentWatcher; bool testShareStatus(LLSD &result); - void twitterConnectCoro(LLCoros::self& self, std::string requestToken, std::string oauthVerifier); - void twitterDisconnectCoro(LLCoros::self& self); - void twitterConnectedCoro(LLCoros::self& self, bool autoConnect); - void twitterInfoCoro(LLCoros::self& self); - void twitterShareCoro(LLCoros::self& self, std::string route, LLSD share); - void twitterShareImageCoro(LLCoros::self& self, LLPointer image, std::string status); + void twitterConnectCoro(std::string requestToken, std::string oauthVerifier); + void twitterDisconnectCoro(); + void twitterConnectedCoro(bool autoConnect); + void twitterInfoCoro(); + void twitterShareCoro(std::string route, LLSD share); + void twitterShareImageCoro(LLPointer image, std::string status); }; #endif // LL_LLTWITTERCONNECT_H diff --git a/indra/newview/llviewerassetupload.cpp b/indra/newview/llviewerassetupload.cpp index 3f21cf2b7e..b6bc17c6c9 100644 --- a/indra/newview/llviewerassetupload.cpp +++ b/indra/newview/llviewerassetupload.cpp @@ -39,7 +39,7 @@ //========================================================================= /*static*/ -void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoros::self &self, LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &httpAdapter, const LLUUID &id, +void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &httpAdapter, const LLUUID &id, std::string url, NewResourceUploadInfo::ptr_t uploadInfo) { LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); @@ -53,7 +53,7 @@ void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoros::self &self, LLCore LLSD body = uploadInfo->generatePostBody(); - LLSD result = httpAdapter->postAndYield(self, httpRequest, url, body); + LLSD result = httpAdapter->postAndYield(httpRequest, url, body); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -65,7 +65,7 @@ void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoros::self &self, LLCore std::string uploader = result["uploader"].asString(); - result = httpAdapter->postFileAndYield(self, httpRequest, uploader, uploadInfo->getAssetId(), uploadInfo->getAssetType()); + result = httpAdapter->postFileAndYield(httpRequest, uploader, uploadInfo->getAssetId(), uploadInfo->getAssetType()); if (!status) { @@ -101,7 +101,7 @@ void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoros::self &self, LLCore - LLSD result = httpAdapter->postAndYield(self, httpRequest, url, initalBody); + LLSD result = httpAdapter->postAndYield(httpRequest, url, initalBody); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -116,7 +116,7 @@ void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoros::self &self, LLCore if (state == "upload") { // Upload the file... - result = httpAdapter->postFileAndYield(self, httpRequest, url, initalBody); + result = httpAdapter->postFileAndYield(httpRequest, url, initalBody); httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); diff --git a/indra/newview/llviewerassetupload.h b/indra/newview/llviewerassetupload.h index c80a7617e1..ab766e1d7d 100644 --- a/indra/newview/llviewerassetupload.h +++ b/indra/newview/llviewerassetupload.h @@ -41,7 +41,7 @@ class LLViewerAssetUpload { public: - static void AssetInventoryUploadCoproc(LLCoros::self &self, LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &httpAdapter, const LLUUID &id, + static void AssetInventoryUploadCoproc(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &httpAdapter, const LLUUID &id, std::string url, NewResourceUploadInfo::ptr_t uploadInfo); diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp index 6d0fce46aa..f332a4e98e 100755 --- a/indra/newview/llviewermedia.cpp +++ b/indra/newview/llviewermedia.cpp @@ -1226,12 +1226,12 @@ void LLViewerMedia::setOpenIDCookie() std::string profileUrl = getProfileURL(""); LLCoros::instance().launch("LLViewerMedia::getOpenIDCookieCoro", - boost::bind(&LLViewerMedia::getOpenIDCookieCoro, _1, profileUrl)); + boost::bind(&LLViewerMedia::getOpenIDCookieCoro, profileUrl)); } } /*static*/ -void LLViewerMedia::getOpenIDCookieCoro(LLCoros::self& self, std::string url) +void LLViewerMedia::getOpenIDCookieCoro(std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -1280,7 +1280,7 @@ void LLViewerMedia::getOpenIDCookieCoro(LLCoros::self& self, std::string url) LL_DEBUGS("MediaAuth") << "Requesting " << url << LL_ENDL; LL_DEBUGS("MediaAuth") << "sOpenIDCookie = [" << sOpenIDCookie << "]" << LL_ENDL; - LLSD result = httpAdapter->getRawAndYield(self, httpRequest, url, httpOpts, httpHeaders); + LLSD result = httpAdapter->getRawAndYield(httpRequest, url, httpOpts, httpHeaders); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -1317,11 +1317,11 @@ void LLViewerMedia::openIDSetup(const std::string &openidUrl, const std::string LL_DEBUGS("MediaAuth") << "url = \"" << openidUrl << "\", token = \"" << openidToken << "\"" << LL_ENDL; LLCoros::instance().launch("LLViewerMedia::openIDSetupCoro", - boost::bind(&LLViewerMedia::openIDSetupCoro, _1, openidUrl, openidToken)); + boost::bind(&LLViewerMedia::openIDSetupCoro, openidUrl, openidToken)); } /*static*/ -void LLViewerMedia::openIDSetupCoro(LLCoros::self& self, std::string openidUrl, std::string openidToken) +void LLViewerMedia::openIDSetupCoro(std::string openidUrl, std::string openidToken) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -1347,7 +1347,7 @@ void LLViewerMedia::openIDSetupCoro(LLCoros::self& self, std::string openidUrl, bas << std::noskipws << openidToken; - LLSD result = httpAdapter->postRawAndYield(self, httpRequest, openidUrl, rawbody, httpOpts, httpHeaders); + LLSD result = httpAdapter->postRawAndYield(httpRequest, openidUrl, rawbody, httpOpts, httpHeaders); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -2553,7 +2553,7 @@ void LLViewerMediaImpl::navigateInternal() if(scheme.empty() || "http" == scheme || "https" == scheme) { LLCoros::instance().launch("LLViewerMediaImpl::mimeDiscoveryCoro", - boost::bind(&LLViewerMediaImpl::mimeDiscoveryCoro, this, _1, mMediaURL)); + boost::bind(&LLViewerMediaImpl::mimeDiscoveryCoro, this, mMediaURL)); } else if("data" == scheme || "file" == scheme || "about" == scheme) { @@ -2583,7 +2583,7 @@ void LLViewerMediaImpl::navigateInternal() } } -void LLViewerMediaImpl::mimeDiscoveryCoro(LLCoros::self& self, std::string url) +void LLViewerMediaImpl::mimeDiscoveryCoro(std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -2600,7 +2600,7 @@ void LLViewerMediaImpl::mimeDiscoveryCoro(LLCoros::self& self, std::string url) httpHeaders->append(HTTP_OUT_HEADER_ACCEPT, "*/*"); httpHeaders->append(HTTP_OUT_HEADER_COOKIE, ""); - LLSD result = httpAdapter->getRawAndYield(self, httpRequest, url, httpOpts, httpHeaders); + LLSD result = httpAdapter->getRawAndYield(httpRequest, url, httpOpts, httpHeaders); mMimeProbe.reset(); diff --git a/indra/newview/llviewermedia.h b/indra/newview/llviewermedia.h index ff9840627c..92d644c900 100755 --- a/indra/newview/llviewermedia.h +++ b/indra/newview/llviewermedia.h @@ -170,8 +170,8 @@ private: static void setOpenIDCookie(); static void onTeleportFinished(); - static void openIDSetupCoro(LLCoros::self& self, std::string openidUrl, std::string openidToken); - static void getOpenIDCookieCoro(LLCoros::self& self, std::string url); + static void openIDSetupCoro(std::string openidUrl, std::string openidToken); + static void getOpenIDCookieCoro(std::string url); static LLPluginCookieStore *sCookieStore; static LLURL sOpenIDURL; @@ -475,7 +475,7 @@ private: BOOL mIsUpdated ; std::list< LLVOVolume* > mObjectList ; - void mimeDiscoveryCoro(LLCoros::self& self, std::string url); + void mimeDiscoveryCoro(std::string url); LLCoreHttpUtil::HttpCoroutineAdapter::wptr_t mMimeProbe; bool mCanceling; diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index 7bcf241d5e..c9c670aaff 100755 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -1007,7 +1007,7 @@ void upload_new_resource( if ( !url.empty() ) { - LLCoprocedureManager::CoProcedure_t proc = boost::bind(&LLViewerAssetUpload::AssetInventoryUploadCoproc, _1, _2, _3, url, uploadInfo); + LLCoprocedureManager::CoProcedure_t proc = boost::bind(&LLViewerAssetUpload::AssetInventoryUploadCoproc, _1, _2, url, uploadInfo); LLCoprocedureManager::getInstance()->enqueueCoprocedure("LLViewerAssetUpload::AssetInventoryUploadCoproc", proc); // LL_INFOS() << "New Agent Inventory via capability" << LL_ENDL; diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp index 1c3e2aec01..2a009499d3 100755 --- a/indra/newview/llviewerobjectlist.cpp +++ b/indra/newview/llviewerobjectlist.cpp @@ -992,7 +992,7 @@ void LLViewerObjectList::fetchObjectCosts() if (!url.empty()) { LLCoros::instance().launch("LLViewerObjectList::fetchObjectCostsCoro", - boost::bind(&LLViewerObjectList::fetchObjectCostsCoro, this, _1, url)); + boost::bind(&LLViewerObjectList::fetchObjectCostsCoro, this, url)); } else { @@ -1014,7 +1014,7 @@ void LLViewerObjectList::reportObjectCostFailure(LLSD &objectList) } -void LLViewerObjectList::fetchObjectCostsCoro(LLCoros::self& self, std::string url) +void LLViewerObjectList::fetchObjectCostsCoro(std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -1052,7 +1052,7 @@ void LLViewerObjectList::fetchObjectCostsCoro(LLCoros::self& self, std::string u postData["object_ids"] = idList; - LLSD result = httpAdapter->postAndYield(self, httpRequest, url, postData); + LLSD result = httpAdapter->postAndYield(httpRequest, url, postData); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -1122,7 +1122,7 @@ void LLViewerObjectList::fetchPhysicsFlags() if (!url.empty()) { LLCoros::instance().launch("LLViewerObjectList::fetchPhisicsFlagsCoro", - boost::bind(&LLViewerObjectList::fetchPhisicsFlagsCoro, this, _1, url)); + boost::bind(&LLViewerObjectList::fetchPhisicsFlagsCoro, this, url)); } else { @@ -1143,7 +1143,7 @@ void LLViewerObjectList::reportPhysicsFlagFailure(LLSD &objectList) } } -void LLViewerObjectList::fetchPhisicsFlagsCoro(LLCoros::self& self, std::string url) +void LLViewerObjectList::fetchPhisicsFlagsCoro(std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -1181,7 +1181,7 @@ void LLViewerObjectList::fetchPhisicsFlagsCoro(LLCoros::self& self, std::string postData["object_ids"] = idList; - LLSD result = httpAdapter->postAndYield(self, httpRequest, url, postData); + LLSD result = httpAdapter->postAndYield(httpRequest, url, postData); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); diff --git a/indra/newview/llviewerobjectlist.h b/indra/newview/llviewerobjectlist.h index f849813f0a..9ec7c4bc22 100755 --- a/indra/newview/llviewerobjectlist.h +++ b/indra/newview/llviewerobjectlist.h @@ -232,10 +232,10 @@ protected: private: static void reportObjectCostFailure(LLSD &objectList); - void fetchObjectCostsCoro(LLCoros::self& self, std::string url); + void fetchObjectCostsCoro(std::string url); static void reportPhysicsFlagFailure(LLSD &obejectList); - void fetchPhisicsFlagsCoro(LLCoros::self& self, std::string url); + void fetchPhisicsFlagsCoro(std::string url); }; diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index f0015ceef1..b256482289 100755 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -219,12 +219,12 @@ public: LLVector3 mLastCameraOrigin; U32 mLastCameraUpdate; - void requestBaseCapabilitiesCoro(LLCoros::self& self, U64 regionHandle); - void requestBaseCapabilitiesCompleteCoro(LLCoros::self& self, U64 regionHandle); - void requestSimulatorFeatureCoro(LLCoros::self& self, std::string url, U64 regionHandle); + void requestBaseCapabilitiesCoro(U64 regionHandle); + void requestBaseCapabilitiesCompleteCoro(U64 regionHandle); + void requestSimulatorFeatureCoro(std::string url, U64 regionHandle); }; -void LLViewerRegionImpl::requestBaseCapabilitiesCoro(LLCoros::self& self, U64 regionHandle) +void LLViewerRegionImpl::requestBaseCapabilitiesCoro(U64 regionHandle) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -275,7 +275,7 @@ void LLViewerRegionImpl::requestBaseCapabilitiesCoro(LLCoros::self& self, U64 re << " (attempt #" << mSeedCapAttempts << ")" << LL_ENDL; regionp = NULL; - result = httpAdapter->postAndYield(self, httpRequest, url, capabilityNames); + result = httpAdapter->postAndYield(httpRequest, url, capabilityNames); regionp = LLWorld::getInstance()->getRegionFromHandle(regionHandle); if (!regionp) //region was removed @@ -332,7 +332,7 @@ void LLViewerRegionImpl::requestBaseCapabilitiesCoro(LLCoros::self& self, U64 re } -void LLViewerRegionImpl::requestBaseCapabilitiesCompleteCoro(LLCoros::self& self, U64 regionHandle) +void LLViewerRegionImpl::requestBaseCapabilitiesCompleteCoro(U64 regionHandle) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -365,7 +365,7 @@ void LLViewerRegionImpl::requestBaseCapabilitiesCompleteCoro(LLCoros::self& self LL_INFOS("AppInit", "Capabilities") << "Requesting second Seed from " << url << LL_ENDL; regionp = NULL; - result = httpAdapter->postAndYield(self, httpRequest, url, capabilityNames); + result = httpAdapter->postAndYield(httpRequest, url, capabilityNames); LLSD httpResults = result["http_result"]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -435,7 +435,7 @@ void LLViewerRegionImpl::requestBaseCapabilitiesCompleteCoro(LLCoros::self& self } -void LLViewerRegionImpl::requestSimulatorFeatureCoro(LLCoros::self& self, std::string url, U64 regionHandle) +void LLViewerRegionImpl::requestSimulatorFeatureCoro(std::string url, U64 regionHandle) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -464,7 +464,7 @@ void LLViewerRegionImpl::requestSimulatorFeatureCoro(LLCoros::self& self, std::s } regionp = NULL; - LLSD result = httpAdapter->getAndYield(self, httpRequest, url); + LLSD result = httpAdapter->getAndYield(httpRequest, url); LLSD httpResults = result["http_result"]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -2908,7 +2908,7 @@ void LLViewerRegion::setSeedCapability(const std::string& url) //to the "original" seed cap received and determine why there is problem! std::string coroname = LLCoros::instance().launch("LLEnvironmentRequest::requestBaseCapabilitiesCompleteCoro", - boost::bind(&LLViewerRegionImpl::requestBaseCapabilitiesCompleteCoro, mImpl, _1, getHandle())); + boost::bind(&LLViewerRegionImpl::requestBaseCapabilitiesCompleteCoro, mImpl, getHandle())); return; } @@ -2920,7 +2920,7 @@ void LLViewerRegion::setSeedCapability(const std::string& url) std::string coroname = LLCoros::instance().launch("LLEnvironmentRequest::environmentRequestCoro", - boost::bind(&LLViewerRegionImpl::requestBaseCapabilitiesCoro, mImpl, _1, getHandle())); + boost::bind(&LLViewerRegionImpl::requestBaseCapabilitiesCoro, mImpl, getHandle())); LL_INFOS("AppInit", "Capabilities") << "Launching " << coroname << " requesting seed capabilities from " << url << LL_ENDL; } @@ -2947,7 +2947,7 @@ void LLViewerRegion::setCapability(const std::string& name, const std::string& u // kick off a request for simulator features std::string coroname = LLCoros::instance().launch("LLViewerRegionImpl::requestSimulatorFeatureCoro", - boost::bind(&LLViewerRegionImpl::requestSimulatorFeatureCoro, mImpl, _1, url, getHandle())); + boost::bind(&LLViewerRegionImpl::requestSimulatorFeatureCoro, mImpl, url, getHandle())); LL_INFOS("AppInit", "SimulatorFeatures") << "Launching " << coroname << " requesting simulator features from " << url << LL_ENDL; } diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp index ba4fd59feb..7c460ce097 100755 --- a/indra/newview/llvoavatarself.cpp +++ b/indra/newview/llvoavatarself.cpp @@ -2190,7 +2190,7 @@ const std::string LLVOAvatarSelf::debugDumpAllLocalTextureDataInfo() const return text; } -void LLVOAvatarSelf::appearanceChangeMetricsCoro(LLCoros::self& self, std::string url) +void LLVOAvatarSelf::appearanceChangeMetricsCoro(std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -2242,7 +2242,7 @@ void LLVOAvatarSelf::appearanceChangeMetricsCoro(LLCoros::self& self, std::strin gPendingMetricsUploads++; - LLSD result = httpAdapter->postAndYield(self, httpRequest, url, msg); + LLSD result = httpAdapter->postAndYield(httpRequest, url, msg); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -2347,7 +2347,7 @@ void LLVOAvatarSelf::sendViewerAppearanceChangeMetrics() { LLCoros::instance().launch("LLVOAvatarSelf::appearanceChangeMetricsCoro", - boost::bind(&LLVOAvatarSelf::appearanceChangeMetricsCoro, this, _1, caps_url)); + boost::bind(&LLVOAvatarSelf::appearanceChangeMetricsCoro, this, caps_url)); mTimeSinceLastRezMessage.reset(); } } diff --git a/indra/newview/llvoavatarself.h b/indra/newview/llvoavatarself.h index b3b5fe6c2f..d32c959fb5 100755 --- a/indra/newview/llvoavatarself.h +++ b/indra/newview/llvoavatarself.h @@ -402,7 +402,7 @@ private: F32 mDebugBakedTextureTimes[LLAvatarAppearanceDefines::BAKED_NUM_INDICES][2]; // time to start upload and finish upload of each baked texture void debugTimingLocalTexLoaded(BOOL success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata); - void appearanceChangeMetricsCoro(LLCoros::self& self, std::string url); + void appearanceChangeMetricsCoro(std::string url); bool mInitialMetric; S32 mMetricSequence; /** Diagnostics diff --git a/indra/newview/llvoicechannel.cpp b/indra/newview/llvoicechannel.cpp index 338201aab1..192d50ae9b 100755 --- a/indra/newview/llvoicechannel.cpp +++ b/indra/newview/llvoicechannel.cpp @@ -481,7 +481,7 @@ void LLVoiceChannelGroup::getChannelInfo() std::string url = region->getCapability("ChatSessionRequest"); LLCoros::instance().launch("LLVoiceChannelGroup::voiceCallCapCoro", - boost::bind(&LLVoiceChannelGroup::voiceCallCapCoro, this, _1, url)); + boost::bind(&LLVoiceChannelGroup::voiceCallCapCoro, this, url)); } } @@ -604,7 +604,7 @@ void LLVoiceChannelGroup::setState(EState state) } } -void LLVoiceChannelGroup::voiceCallCapCoro(LLCoros::self& self, std::string url) +void LLVoiceChannelGroup::voiceCallCapCoro(std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -617,7 +617,7 @@ void LLVoiceChannelGroup::voiceCallCapCoro(LLCoros::self& self, std::string url) LL_INFOS("Voice", "voiceCallCapCoro") << "Generic POST for " << url << LL_ENDL; - LLSD result = httpAdapter->postAndYield(self, httpRequest, url, postData); + LLSD result = httpAdapter->postAndYield(httpRequest, url, postData); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); diff --git a/indra/newview/llvoicechannel.h b/indra/newview/llvoicechannel.h index 0dac0b1f6a..ef15b2c79e 100755 --- a/indra/newview/llvoicechannel.h +++ b/indra/newview/llvoicechannel.h @@ -159,7 +159,7 @@ protected: virtual void setState(EState state); private: - void voiceCallCapCoro(LLCoros::self& self, std::string url); + void voiceCallCapCoro(std::string url); U32 mRetries; BOOL mIsRetrying; diff --git a/indra/newview/llvoicevivox.cpp b/indra/newview/llvoicevivox.cpp index c70ce5801d..f50ffdeae7 100755 --- a/indra/newview/llvoicevivox.cpp +++ b/indra/newview/llvoicevivox.cpp @@ -446,13 +446,13 @@ void LLVivoxVoiceClient::requestVoiceAccountProvision(S32 retries) if ( !url.empty() ) { LLCoros::instance().launch("LLVivoxVoiceClient::voiceAccountProvisionCoro", - boost::bind(&LLVivoxVoiceClient::voiceAccountProvisionCoro, this, _1, url, retries)); + boost::bind(&LLVivoxVoiceClient::voiceAccountProvisionCoro, this, url, retries)); setState(stateConnectorStart); } } } -void LLVivoxVoiceClient::voiceAccountProvisionCoro(LLCoros::self& self, std::string url, S32 retries) +void LLVivoxVoiceClient::voiceAccountProvisionCoro(std::string url, S32 retries) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -462,7 +462,7 @@ void LLVivoxVoiceClient::voiceAccountProvisionCoro(LLCoros::self& self, std::str httpOpts->setRetries(retries); - LLSD result = httpAdapter->postAndYield(self, httpRequest, url, LLSD(), httpOpts); + LLSD result = httpAdapter->postAndYield(httpRequest, url, LLSD(), httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -3928,12 +3928,12 @@ bool LLVivoxVoiceClient::requestParcelVoiceInfo() LL_DEBUGS("Voice") << "sending ParcelVoiceInfoRequest (" << mCurrentRegionName << ", " << mCurrentParcelLocalID << ")" << LL_ENDL; LLCoros::instance().launch("LLVivoxVoiceClient::parcelVoiceInfoRequestCoro", - boost::bind(&LLVivoxVoiceClient::parcelVoiceInfoRequestCoro, this, _1, url)); + boost::bind(&LLVivoxVoiceClient::parcelVoiceInfoRequestCoro, this, url)); return true; } } -void LLVivoxVoiceClient::parcelVoiceInfoRequestCoro(LLCoros::self& self, std::string url) +void LLVivoxVoiceClient::parcelVoiceInfoRequestCoro(std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -3941,7 +3941,7 @@ void LLVivoxVoiceClient::parcelVoiceInfoRequestCoro(LLCoros::self& self, std::st LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); state requestingState = getState(); - LLSD result = httpAdapter->postAndYield(self, httpRequest, url, LLSD()); + LLSD result = httpAdapter->postAndYield(httpRequest, url, LLSD()); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); diff --git a/indra/newview/llvoicevivox.h b/indra/newview/llvoicevivox.h index a3cdb342e2..b12ed80e41 100755 --- a/indra/newview/llvoicevivox.h +++ b/indra/newview/llvoicevivox.h @@ -637,8 +637,8 @@ protected: private: - void voiceAccountProvisionCoro(LLCoros::self& self, std::string url, S32 retries); - void parcelVoiceInfoRequestCoro(LLCoros::self& self, std::string url); + void voiceAccountProvisionCoro(std::string url, S32 retries); + void parcelVoiceInfoRequestCoro(std::string url); LLVoiceVersionInfo mVoiceVersion; diff --git a/indra/newview/llwebprofile.cpp b/indra/newview/llwebprofile.cpp index 62ba40ca32..2033a5f36a 100755 --- a/indra/newview/llwebprofile.cpp +++ b/indra/newview/llwebprofile.cpp @@ -67,7 +67,7 @@ LLWebProfile::status_callback_t LLWebProfile::mStatusCallback; void LLWebProfile::uploadImage(LLPointer image, const std::string& caption, bool add_location) { LLCoros::instance().launch("LLWebProfile::uploadImageCoro", - boost::bind(&LLWebProfile::uploadImageCoro, _1, image, caption, add_location)); + boost::bind(&LLWebProfile::uploadImageCoro, image, caption, add_location)); } @@ -95,7 +95,7 @@ LLCore::HttpHeaders::ptr_t LLWebProfile::buildDefaultHeaders() /*static*/ -void LLWebProfile::uploadImageCoro(LLCoros::self& self, LLPointer image, std::string caption, bool addLocation) +void LLWebProfile::uploadImageCoro(LLPointer image, std::string caption, bool addLocation) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -124,7 +124,7 @@ void LLWebProfile::uploadImageCoro(LLCoros::self& self, LLPointerappend(HTTP_OUT_HEADER_COOKIE, getAuthCookie()); - LLSD result = httpAdapter->getJsonAndYield(self, httpRequest, configUrl, httpOpts, httpHeaders); + LLSD result = httpAdapter->getJsonAndYield(httpRequest, configUrl, httpOpts, httpHeaders); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -150,7 +150,7 @@ void LLWebProfile::uploadImageCoro(LLCoros::self& self, LLPointerpostAndYield(self, httpRequest, uploadUrl, body, httpOpts, httpHeaders); + result = httpAdapter->postAndYield(httpRequest, uploadUrl, body, httpOpts, httpHeaders); body.reset(); httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; @@ -178,7 +178,7 @@ void LLWebProfile::uploadImageCoro(LLCoros::self& self, LLPointergetRawAndYield(self, httpRequest, redirUrl, httpOpts, httpHeaders); + result = httpAdapter->getRawAndYield(httpRequest, redirUrl, httpOpts, httpHeaders); httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); diff --git a/indra/newview/llwebprofile.h b/indra/newview/llwebprofile.h index 604ef7aff7..6227e00afe 100755 --- a/indra/newview/llwebprofile.h +++ b/indra/newview/llwebprofile.h @@ -60,7 +60,7 @@ public: private: static LLCore::HttpHeaders::ptr_t buildDefaultHeaders(); - static void uploadImageCoro(LLCoros::self& self, LLPointer image, std::string caption, bool add_location); + static void uploadImageCoro(LLPointer image, std::string caption, bool add_location); static LLCore::BufferArray::ptr_t buildPostData(const LLSD &data, LLPointer &image, const std::string &boundary); static void reportImageUploadStatus(bool ok); diff --git a/indra/newview/llwlhandlers.cpp b/indra/newview/llwlhandlers.cpp index 3145c3f38d..ff15afa598 100755 --- a/indra/newview/llwlhandlers.cpp +++ b/indra/newview/llwlhandlers.cpp @@ -84,7 +84,7 @@ bool LLEnvironmentRequest::doRequest() std::string coroname = LLCoros::instance().launch("LLEnvironmentRequest::environmentRequestCoro", - boost::bind(&LLEnvironmentRequest::environmentRequestCoro, _1, url)); + boost::bind(&LLEnvironmentRequest::environmentRequestCoro, url)); LL_INFOS("WindlightCaps") << "Requesting region windlight settings via " << url << LL_ENDL; return true; @@ -93,7 +93,7 @@ bool LLEnvironmentRequest::doRequest() S32 LLEnvironmentRequest::sLastRequest = 0; //static -void LLEnvironmentRequest::environmentRequestCoro(LLCoros::self& self, std::string url) +void LLEnvironmentRequest::environmentRequestCoro(std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); S32 requestId = ++LLEnvironmentRequest::sLastRequest; @@ -101,7 +101,7 @@ void LLEnvironmentRequest::environmentRequestCoro(LLCoros::self& self, std::stri httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("EnvironmentRequest", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLSD result = httpAdapter->getAndYield(self, httpRequest, url); + LLSD result = httpAdapter->getAndYield(httpRequest, url); if (requestId != LLEnvironmentRequest::sLastRequest) { @@ -174,18 +174,18 @@ bool LLEnvironmentApply::initiateRequest(const LLSD& content) std::string coroname = LLCoros::instance().launch("LLEnvironmentApply::environmentApplyCoro", - boost::bind(&LLEnvironmentApply::environmentApplyCoro, _1, url, content)); + boost::bind(&LLEnvironmentApply::environmentApplyCoro, url, content)); return true; } -void LLEnvironmentApply::environmentApplyCoro(LLCoros::self& self, std::string url, LLSD content) +void LLEnvironmentApply::environmentApplyCoro(std::string url, LLSD content) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("EnvironmentApply", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLSD result = httpAdapter->postAndYield(self, httpRequest, url, content); + LLSD result = httpAdapter->postAndYield(httpRequest, url, content); LLSD notify; // for error reporting. If there is something to report to user this will be defined. /* diff --git a/indra/newview/llwlhandlers.h b/indra/newview/llwlhandlers.h index 0b778901ad..eb2bbf9553 100755 --- a/indra/newview/llwlhandlers.h +++ b/indra/newview/llwlhandlers.h @@ -41,7 +41,7 @@ private: static void onRegionCapsReceived(const LLUUID& region_id); static bool doRequest(); - static void environmentRequestCoro(LLCoros::self& self, std::string url); + static void environmentRequestCoro(std::string url); static S32 sLastRequest; }; @@ -57,7 +57,7 @@ private: static clock_t sLastUpdate; static clock_t UPDATE_WAIT_SECONDS; - static void environmentApplyCoro(LLCoros::self& self, std::string url, LLSD content); + static void environmentApplyCoro(std::string url, LLSD content); }; #endif // LL_LLWLHANDLERS_H diff --git a/indra/viewer_components/login/lllogin.cpp b/indra/viewer_components/login/lllogin.cpp index b8408a6fb4..0569e9f3e8 100755 --- a/indra/viewer_components/login/lllogin.cpp +++ b/indra/viewer_components/login/lllogin.cpp @@ -107,9 +107,8 @@ private: } // In a coroutine's top-level function args, do NOT NOT NOT accept - // references (const or otherwise) to anything but the self argument! Pass - // by value only! - void login_(LLCoros::self& self, std::string uri, LLSD credentials); + // references (const or otherwise) to anything! Pass by value only! + void login_(std::string uri, LLSD credentials); LLEventStream mPump; LLSD mAuthResponse, mValidAuthResponse; @@ -123,11 +122,11 @@ void LLLogin::Impl::connect(const std::string& uri, const LLSD& login_params) // its first wait; at that point, return here. std::string coroname = LLCoros::instance().launch("LLLogin::Impl::login_", - boost::bind(&Impl::login_, this, _1, uri, login_params)); + boost::bind(&Impl::login_, this, uri, login_params)); LL_DEBUGS("LLLogin") << " connected with uri '" << uri << "', login_params " << login_params << LL_ENDL; } -void LLLogin::Impl::login_(LLCoros::self& self, std::string uri, LLSD login_params) +void LLLogin::Impl::login_(std::string uri, LLSD login_params) { try { @@ -137,7 +136,7 @@ void LLLogin::Impl::login_(LLCoros::self& self, std::string uri, LLSD login_para //{ // printable_params["params"]["passwd"] = "*******"; //} - LL_DEBUGS("LLLogin") << "Entering coroutine " << LLCoros::instance().getName(self) + LL_DEBUGS("LLLogin") << "Entering coroutine " << LLCoros::instance().getName() << " with uri '" << uri << "', parameters " << printable_params << LL_ENDL; // Arriving in SRVRequest state @@ -176,7 +175,7 @@ void LLLogin::Impl::login_(LLCoros::self& self, std::string uri, LLSD login_para request["op"] = "rewriteURI"; request["uri"] = uri; request["reply"] = replyPump.getName(); - rewrittenURIs = postAndWait(self, request, srv_pump_name, filter); + rewrittenURIs = postAndWait(request, srv_pump_name, filter); // EXP-772: If rewrittenURIs fail, try original URI as a fallback. rewrittenURIs.append(uri); } // we no longer need the filter @@ -222,10 +221,10 @@ void LLLogin::Impl::login_(LLCoros::self& self, std::string uri, LLSD login_para // returns. Subsequent responses, of course, must be awaited // without posting again. for (mAuthResponse = validateResponse(loginReplyPump.getName(), - postAndWait(self, request, xmlrpcPump, loginReplyPump, "reply")); + postAndWait(request, xmlrpcPump, loginReplyPump, "reply")); mAuthResponse["status"].asString() == "Downloading"; mAuthResponse = validateResponse(loginReplyPump.getName(), - waitForEventOn(self, loginReplyPump))) + waitForEventOn(loginReplyPump))) { // Still Downloading -- send progress update. sendProgressEvent("offline", "downloading"); diff --git a/indra/viewer_components/updater/llupdatechecker.cpp b/indra/viewer_components/updater/llupdatechecker.cpp index 29cb238892..e889f83aa9 100755 --- a/indra/viewer_components/updater/llupdatechecker.cpp +++ b/indra/viewer_components/updater/llupdatechecker.cpp @@ -117,7 +117,7 @@ void LLUpdateChecker::Implementation::checkVersion(std::string const & urlBase, LL_INFOS("UpdaterService") << "checking for updates at " << checkUrl << LL_ENDL; LLCoros::instance().launch("LLUpdateChecker::Implementation::checkVersionCoro", - boost::bind(&Implementation::checkVersionCoro, this, _1, checkUrl)); + boost::bind(&Implementation::checkVersionCoro, this, checkUrl)); } else @@ -126,7 +126,7 @@ void LLUpdateChecker::Implementation::checkVersion(std::string const & urlBase, } } -void LLUpdateChecker::Implementation::checkVersionCoro(LLCoros::self& self, std::string url) +void LLUpdateChecker::Implementation::checkVersionCoro(std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -135,7 +135,7 @@ void LLUpdateChecker::Implementation::checkVersionCoro(LLCoros::self& self, std: LL_INFOS("checkVersionCoro") << "Getting update information from " << url << LL_ENDL; - LLSD result = httpAdapter->getAndYield(self, httpRequest, url); + LLSD result = httpAdapter->getAndYield(httpRequest, url); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); diff --git a/indra/viewer_components/updater/llupdatechecker.h b/indra/viewer_components/updater/llupdatechecker.h index e5050bb952..d10ea4cf42 100755 --- a/indra/viewer_components/updater/llupdatechecker.h +++ b/indra/viewer_components/updater/llupdatechecker.h @@ -106,7 +106,7 @@ private: unsigned char uniqueid[MD5HEX_STR_SIZE], bool willing_to_test); - void checkVersionCoro(LLCoros::self& self, std::string url); + void checkVersionCoro(std::string url); LOG_CLASS(LLUpdateChecker::Implementation); }; -- cgit v1.2.3 From 7eaee4fde770edae6d64ddf07a917b2ae16a9928 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Wed, 1 Jul 2015 19:14:24 -0400 Subject: MAINT-5351: Reorganize lleventcoro_test.cpp to be more readable. Each test() method invokes a function from earlier in the source. It's much better if each of those functions immediately precedes the test that invokes it. --- indra/llcommon/tests/lleventcoro_test.cpp | 660 ++++++++++++++++-------------- 1 file changed, 344 insertions(+), 316 deletions(-) (limited to 'indra') diff --git a/indra/llcommon/tests/lleventcoro_test.cpp b/indra/llcommon/tests/lleventcoro_test.cpp index 31e9856477..da927038ab 100755 --- a/indra/llcommon/tests/lleventcoro_test.cpp +++ b/indra/llcommon/tests/lleventcoro_test.cpp @@ -160,298 +160,7 @@ private: *****************************************************************************/ namespace tut { - struct coroutine_data - { - // Define coroutine bodies as methods here so they can use ensure*() - - void explicit_wait(boost::dcoroutines::coroutine::self& self) - { - BEGIN - { - // ... do whatever preliminary stuff must happen ... - - // declare the future - boost::dcoroutines::future future(self); - // tell the future what to wait for - LLTempBoundListener connection( - LLEventPumps::instance().obtain("source").listen("coro", voidlistener(boost::dcoroutines::make_callback(future)))); - ensure("Not yet", ! future); - // attempting to dereference ("resolve") the future causes the calling - // coroutine to wait for it - debug("about to wait"); - result = *future; - ensure("Got it", future); - } - END - } - - void waitForEventOn1() - { - BEGIN - { - result = waitForEventOn("source"); - } - END - } - - void waitForEventOn2() - { - BEGIN - { - LLEventWithID pair = waitForEventOn("reply", "error"); - result = pair.first; - which = pair.second; - debug(STRINGIZE("result = " << result << ", which = " << which)); - } - END - } - - void postAndWait1() - { - BEGIN - { - result = postAndWait(LLSDMap("value", 17), // request event - immediateAPI.getPump(), // requestPump - "reply1", // replyPump - "reply"); // request["reply"] = name - } - END - } - - void postAndWait2() - { - BEGIN - { - LLEventWithID pair = ::postAndWait2(LLSDMap("value", 18), - immediateAPI.getPump(), - "reply2", - "error2", - "reply", - "error"); - result = pair.first; - which = pair.second; - debug(STRINGIZE("result = " << result << ", which = " << which)); - } - END - } - - void postAndWait2_1() - { - BEGIN - { - LLEventWithID pair = ::postAndWait2(LLSDMap("value", 18)("fail", LLSD()), - immediateAPI.getPump(), - "reply2", - "error2", - "reply", - "error"); - result = pair.first; - which = pair.second; - debug(STRINGIZE("result = " << result << ", which = " << which)); - } - END - } - - void coroPump() - { - BEGIN - { - LLCoroEventPump waiter; - replyName = waiter.getName(); - result = waiter.wait(); - } - END - } - - void coroPumpPost() - { - BEGIN - { - LLCoroEventPump waiter; - result = waiter.postAndWait(LLSDMap("value", 17), - immediateAPI.getPump(), "reply"); - } - END - } - - void coroPumps() - { - BEGIN - { - LLCoroEventPumps waiter; - replyName = waiter.getName0(); - errorName = waiter.getName1(); - LLEventWithID pair(waiter.wait()); - result = pair.first; - which = pair.second; - } - END - } - - void coroPumpsNoEx() - { - BEGIN - { - LLCoroEventPumps waiter; - replyName = waiter.getName0(); - errorName = waiter.getName1(); - result = waiter.waitWithException(); - } - END - } - - void coroPumpsEx() - { - BEGIN - { - LLCoroEventPumps waiter; - replyName = waiter.getName0(); - errorName = waiter.getName1(); - try - { - result = waiter.waitWithException(); - debug("no exception"); - } - catch (const LLErrorEvent& e) - { - debug(STRINGIZE("exception " << e.what())); - errordata = e.getData(); - } - } - END - } - - void coroPumpsNoLog() - { - BEGIN - { - LLCoroEventPumps waiter; - replyName = waiter.getName0(); - errorName = waiter.getName1(); - result = waiter.waitWithLog(); - } - END - } - - void coroPumpsLog() - { - BEGIN - { - LLCoroEventPumps waiter; - replyName = waiter.getName0(); - errorName = waiter.getName1(); - WrapLLErrs capture; - try - { - result = waiter.waitWithLog(); - debug("no exception"); - } - catch (const WrapLLErrs::FatalException& e) - { - debug(STRINGIZE("exception " << e.what())); - threw = e.what(); - } - } - END - } - - void coroPumpsPost() - { - BEGIN - { - LLCoroEventPumps waiter; - LLEventWithID pair(waiter.postAndWait(LLSDMap("value", 23), - immediateAPI.getPump(), "reply", "error")); - result = pair.first; - which = pair.second; - } - END - } - - void coroPumpsPost_1() - { - BEGIN - { - LLCoroEventPumps waiter; - LLEventWithID pair( - waiter.postAndWait(LLSDMap("value", 23)("fail", LLSD()), - immediateAPI.getPump(), "reply", "error")); - result = pair.first; - which = pair.second; - } - END - } - - void coroPumpsPostNoEx() - { - BEGIN - { - LLCoroEventPumps waiter; - result = waiter.postAndWaitWithException(LLSDMap("value", 8), - immediateAPI.getPump(), "reply", "error"); - } - END - } - - void coroPumpsPostEx() - { - BEGIN - { - LLCoroEventPumps waiter; - try - { - result = waiter.postAndWaitWithException( - LLSDMap("value", 9)("fail", LLSD()), - immediateAPI.getPump(), "reply", "error"); - debug("no exception"); - } - catch (const LLErrorEvent& e) - { - debug(STRINGIZE("exception " << e.what())); - errordata = e.getData(); - } - } - END - } - - void coroPumpsPostNoLog() - { - BEGIN - { - LLCoroEventPumps waiter; - result = waiter.postAndWaitWithLog(LLSDMap("value", 30), - immediateAPI.getPump(), "reply", "error"); - } - END - } - - void coroPumpsPostLog() - { - BEGIN - { - LLCoroEventPumps waiter; - WrapLLErrs capture; - try - { - result = waiter.postAndWaitWithLog( - LLSDMap("value", 31)("fail", LLSD()), - immediateAPI.getPump(), "reply", "error"); - debug("no exception"); - } - catch (const WrapLLErrs::FatalException& e) - { - debug(STRINGIZE("exception " << e.what())); - threw = e.what(); - } - } - END - } - - ImmediateAPI immediateAPI; - std::string replyName, errorName, threw; - LLSD result, errordata; - int which; - }; + struct coroutine_data {}; typedef test_group coroutine_group; typedef coroutine_group::object object; coroutine_group coroutinegrp("coroutine"); @@ -501,9 +210,49 @@ namespace tut ensure("done", ! matcher); } + // use static data so we can intersperse coroutine functions with the + // tests that engage them + ImmediateAPI immediateAPI; + std::string replyName, errorName, threw; + LLSD result, errordata; + int which; + + // reinit vars at the start of each test + void clear() + { + replyName.clear(); + errorName.clear(); + threw.clear(); + result = LLSD(); + errordata = LLSD(); + which = 0; + } + + void explicit_wait(boost::dcoroutines::coroutine::self& self) + { + BEGIN + { + // ... do whatever preliminary stuff must happen ... + + // declare the future + boost::dcoroutines::future future(self); + // tell the future what to wait for + LLTempBoundListener connection( + LLEventPumps::instance().obtain("source").listen("coro", voidlistener(boost::dcoroutines::make_callback(future)))); + ensure("Not yet", ! future); + // attempting to dereference ("resolve") the future causes the calling + // coroutine to wait for it + debug("about to wait"); + result = *future; + ensure("Got it", future); + } + END + } + template<> template<> void object::test<2>() { + clear(); set_test_name("explicit_wait"); DEBUG; @@ -511,7 +260,7 @@ namespace tut // Pass the ctor a callable that accepts the coroutine_type::self // param passed by the library. boost::dcoroutines::coroutine - coro(boost::bind(&coroutine_data::explicit_wait, this, _1)); + coro(explicit_wait); // Start the coroutine coro(std::nothrow); // When the coroutine waits for the event pump, it returns here. @@ -524,26 +273,48 @@ namespace tut ensure_equals(result.asString(), "received"); } + void waitForEventOn1() + { + BEGIN + { + result = waitForEventOn("source"); + } + END + } + template<> template<> void object::test<3>() { + clear(); set_test_name("waitForEventOn1"); DEBUG; - LLCoros::instance().launch("test<3>", - boost::bind(&coroutine_data::waitForEventOn1, this)); + LLCoros::instance().launch("test<3>", waitForEventOn1); debug("about to send"); LLEventPumps::instance().obtain("source").post("received"); debug("back from send"); ensure_equals(result.asString(), "received"); } + void waitForEventOn2() + { + BEGIN + { + LLEventWithID pair = waitForEventOn("reply", "error"); + result = pair.first; + which = pair.second; + debug(STRINGIZE("result = " << result << ", which = " << which)); + } + END + } + template<> template<> void object::test<4>() { + clear(); set_test_name("waitForEventOn2 reply"); { DEBUG; - LLCoros::instance().launch("test<4>", boost::bind(&coroutine_data::waitForEventOn2, this)); + LLCoros::instance().launch("test<4>", waitForEventOn2); debug("about to send"); LLEventPumps::instance().obtain("reply").post("received"); debug("back from send"); @@ -555,9 +326,10 @@ namespace tut template<> template<> void object::test<5>() { + clear(); set_test_name("waitForEventOn2 error"); DEBUG; - LLCoros::instance().launch("test<5>", boost::bind(&coroutine_data::waitForEventOn2, this)); + LLCoros::instance().launch("test<5>", waitForEventOn2); debug("about to send"); LLEventPumps::instance().obtain("error").post("badness"); debug("back from send"); @@ -565,24 +337,51 @@ namespace tut ensure_equals("which pump", which, 1); } + void coroPump() + { + BEGIN + { + LLCoroEventPump waiter; + replyName = waiter.getName(); + result = waiter.wait(); + } + END + } + template<> template<> void object::test<6>() { + clear(); set_test_name("coroPump"); DEBUG; - LLCoros::instance().launch("test<6>", boost::bind(&coroutine_data::coroPump, this)); + LLCoros::instance().launch("test<6>", coroPump); debug("about to send"); LLEventPumps::instance().obtain(replyName).post("received"); debug("back from send"); ensure_equals(result.asString(), "received"); } + void coroPumps() + { + BEGIN + { + LLCoroEventPumps waiter; + replyName = waiter.getName0(); + errorName = waiter.getName1(); + LLEventWithID pair(waiter.wait()); + result = pair.first; + which = pair.second; + } + END + } + template<> template<> void object::test<7>() { + clear(); set_test_name("coroPumps reply"); DEBUG; - LLCoros::instance().launch("test<7>", boost::bind(&coroutine_data::coroPumps, this)); + LLCoros::instance().launch("test<7>", coroPumps); debug("about to send"); LLEventPumps::instance().obtain(replyName).post("received"); debug("back from send"); @@ -593,9 +392,10 @@ namespace tut template<> template<> void object::test<8>() { + clear(); set_test_name("coroPumps error"); DEBUG; - LLCoros::instance().launch("test<8>", boost::bind(&coroutine_data::coroPumps, this)); + LLCoros::instance().launch("test<8>", coroPumps); debug("about to send"); LLEventPumps::instance().obtain(errorName).post("badness"); debug("back from send"); @@ -603,24 +403,59 @@ namespace tut ensure_equals("which pump", which, 1); } + void coroPumpsNoEx() + { + BEGIN + { + LLCoroEventPumps waiter; + replyName = waiter.getName0(); + errorName = waiter.getName1(); + result = waiter.waitWithException(); + } + END + } + template<> template<> void object::test<9>() { + clear(); set_test_name("coroPumpsNoEx"); DEBUG; - LLCoros::instance().launch("test<9>", boost::bind(&coroutine_data::coroPumpsNoEx, this)); + LLCoros::instance().launch("test<9>", coroPumpsNoEx); debug("about to send"); LLEventPumps::instance().obtain(replyName).post("received"); debug("back from send"); ensure_equals(result.asString(), "received"); } + void coroPumpsEx() + { + BEGIN + { + LLCoroEventPumps waiter; + replyName = waiter.getName0(); + errorName = waiter.getName1(); + try + { + result = waiter.waitWithException(); + debug("no exception"); + } + catch (const LLErrorEvent& e) + { + debug(STRINGIZE("exception " << e.what())); + errordata = e.getData(); + } + } + END + } + template<> template<> void object::test<10>() { + clear(); set_test_name("coroPumpsEx"); DEBUG; - LLCoros::instance().launch("test<10>", boost::bind(&coroutine_data::coroPumpsEx, this)); + LLCoros::instance().launch("test<10>", coroPumpsEx); debug("about to send"); LLEventPumps::instance().obtain(errorName).post("badness"); debug("back from send"); @@ -628,24 +463,60 @@ namespace tut ensure_equals("got error", errordata.asString(), "badness"); } + void coroPumpsNoLog() + { + BEGIN + { + LLCoroEventPumps waiter; + replyName = waiter.getName0(); + errorName = waiter.getName1(); + result = waiter.waitWithLog(); + } + END + } + template<> template<> void object::test<11>() { + clear(); set_test_name("coroPumpsNoLog"); DEBUG; - LLCoros::instance().launch("test<11>", boost::bind(&coroutine_data::coroPumpsNoLog, this)); + LLCoros::instance().launch("test<11>", coroPumpsNoLog); debug("about to send"); LLEventPumps::instance().obtain(replyName).post("received"); debug("back from send"); ensure_equals(result.asString(), "received"); } + void coroPumpsLog() + { + BEGIN + { + LLCoroEventPumps waiter; + replyName = waiter.getName0(); + errorName = waiter.getName1(); + WrapLLErrs capture; + try + { + result = waiter.waitWithLog(); + debug("no exception"); + } + catch (const WrapLLErrs::FatalException& e) + { + debug(STRINGIZE("exception " << e.what())); + threw = e.what(); + } + } + END + } + template<> template<> void object::test<12>() { + clear(); set_test_name("coroPumpsLog"); DEBUG; - LLCoros::instance().launch("test<12>", boost::bind(&coroutine_data::coroPumpsLog, this)); + LLCoros::instance().launch("test<12>", coroPumpsLog); debug("about to send"); LLEventPumps::instance().obtain(errorName).post("badness"); debug("back from send"); @@ -653,100 +524,257 @@ namespace tut ensure_contains("got error", threw, "badness"); } + void postAndWait1() + { + BEGIN + { + result = postAndWait(LLSDMap("value", 17), // request event + immediateAPI.getPump(), // requestPump + "reply1", // replyPump + "reply"); // request["reply"] = name + } + END + } + template<> template<> void object::test<13>() { + clear(); set_test_name("postAndWait1"); DEBUG; - LLCoros::instance().launch("test<13>", boost::bind(&coroutine_data::postAndWait1, this)); + LLCoros::instance().launch("test<13>", postAndWait1); ensure_equals(result.asInteger(), 18); } + void postAndWait2() + { + BEGIN + { + LLEventWithID pair = ::postAndWait2(LLSDMap("value", 18), + immediateAPI.getPump(), + "reply2", + "error2", + "reply", + "error"); + result = pair.first; + which = pair.second; + debug(STRINGIZE("result = " << result << ", which = " << which)); + } + END + } + template<> template<> void object::test<14>() { + clear(); set_test_name("postAndWait2"); DEBUG; - LLCoros::instance().launch("test<14>", boost::bind(&coroutine_data::postAndWait2, this)); + LLCoros::instance().launch("test<14>", postAndWait2); ensure_equals(result.asInteger(), 19); ensure_equals(which, 0); } + void postAndWait2_1() + { + BEGIN + { + LLEventWithID pair = ::postAndWait2(LLSDMap("value", 18)("fail", LLSD()), + immediateAPI.getPump(), + "reply2", + "error2", + "reply", + "error"); + result = pair.first; + which = pair.second; + debug(STRINGIZE("result = " << result << ", which = " << which)); + } + END + } + template<> template<> void object::test<15>() { + clear(); set_test_name("postAndWait2_1"); DEBUG; - LLCoros::instance().launch("test<15>", boost::bind(&coroutine_data::postAndWait2_1, this)); + LLCoros::instance().launch("test<15>", postAndWait2_1); ensure_equals(result.asInteger(), 19); ensure_equals(which, 1); } + void coroPumpPost() + { + BEGIN + { + LLCoroEventPump waiter; + result = waiter.postAndWait(LLSDMap("value", 17), + immediateAPI.getPump(), "reply"); + } + END + } + template<> template<> void object::test<16>() { + clear(); set_test_name("coroPumpPost"); DEBUG; - LLCoros::instance().launch("test<16>", boost::bind(&coroutine_data::coroPumpPost, this)); + LLCoros::instance().launch("test<16>", coroPumpPost); ensure_equals(result.asInteger(), 18); } + void coroPumpsPost() + { + BEGIN + { + LLCoroEventPumps waiter; + LLEventWithID pair(waiter.postAndWait(LLSDMap("value", 23), + immediateAPI.getPump(), "reply", "error")); + result = pair.first; + which = pair.second; + } + END + } + template<> template<> void object::test<17>() { + clear(); set_test_name("coroPumpsPost reply"); DEBUG; - LLCoros::instance().launch("test<17>", boost::bind(&coroutine_data::coroPumpsPost, this)); + LLCoros::instance().launch("test<17>", coroPumpsPost); ensure_equals(result.asInteger(), 24); ensure_equals("which pump", which, 0); } + void coroPumpsPost_1() + { + BEGIN + { + LLCoroEventPumps waiter; + LLEventWithID pair( + waiter.postAndWait(LLSDMap("value", 23)("fail", LLSD()), + immediateAPI.getPump(), "reply", "error")); + result = pair.first; + which = pair.second; + } + END + } + template<> template<> void object::test<18>() { + clear(); set_test_name("coroPumpsPost error"); DEBUG; - LLCoros::instance().launch("test<18>", boost::bind(&coroutine_data::coroPumpsPost_1, this)); + LLCoros::instance().launch("test<18>", coroPumpsPost_1); ensure_equals(result.asInteger(), 24); ensure_equals("which pump", which, 1); } + void coroPumpsPostNoEx() + { + BEGIN + { + LLCoroEventPumps waiter; + result = waiter.postAndWaitWithException(LLSDMap("value", 8), + immediateAPI.getPump(), "reply", "error"); + } + END + } + template<> template<> void object::test<19>() { + clear(); set_test_name("coroPumpsPostNoEx"); DEBUG; - LLCoros::instance().launch("test<19>", - boost::bind(&coroutine_data::coroPumpsPostNoEx, this)); + LLCoros::instance().launch("test<19>", coroPumpsPostNoEx); ensure_equals(result.asInteger(), 9); } + void coroPumpsPostEx() + { + BEGIN + { + LLCoroEventPumps waiter; + try + { + result = waiter.postAndWaitWithException( + LLSDMap("value", 9)("fail", LLSD()), + immediateAPI.getPump(), "reply", "error"); + debug("no exception"); + } + catch (const LLErrorEvent& e) + { + debug(STRINGIZE("exception " << e.what())); + errordata = e.getData(); + } + } + END + } + template<> template<> void object::test<20>() { + clear(); set_test_name("coroPumpsPostEx"); DEBUG; - LLCoros::instance().launch("test<20>", boost::bind(&coroutine_data::coroPumpsPostEx, this)); + LLCoros::instance().launch("test<20>", coroPumpsPostEx); ensure("no result", result.isUndefined()); ensure_equals("got error", errordata.asInteger(), 10); } + void coroPumpsPostNoLog() + { + BEGIN + { + LLCoroEventPumps waiter; + result = waiter.postAndWaitWithLog(LLSDMap("value", 30), + immediateAPI.getPump(), "reply", "error"); + } + END + } + template<> template<> void object::test<21>() { + clear(); set_test_name("coroPumpsPostNoLog"); DEBUG; - LLCoros::instance().launch("test<21>", - boost::bind(&coroutine_data::coroPumpsPostNoLog, this)); + LLCoros::instance().launch("test<21>", coroPumpsPostNoLog); ensure_equals(result.asInteger(), 31); } + void coroPumpsPostLog() + { + BEGIN + { + LLCoroEventPumps waiter; + WrapLLErrs capture; + try + { + result = waiter.postAndWaitWithLog( + LLSDMap("value", 31)("fail", LLSD()), + immediateAPI.getPump(), "reply", "error"); + debug("no exception"); + } + catch (const WrapLLErrs::FatalException& e) + { + debug(STRINGIZE("exception " << e.what())); + threw = e.what(); + } + } + END + } + template<> template<> void object::test<22>() { + clear(); set_test_name("coroPumpsPostLog"); DEBUG; - LLCoros::instance().launch("test<22>", boost::bind(&coroutine_data::coroPumpsPostLog, this)); + LLCoros::instance().launch("test<22>", coroPumpsPostLog); ensure("no result", result.isUndefined()); ensure_contains("got error", threw, "32"); } -- cgit v1.2.3 From 2a29dbc48295ad24a8a7137a10b9d891debea978 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Wed, 1 Jul 2015 19:23:08 -0400 Subject: MAINT-5351: Reorder llmessage test libraries to make Linux happy. Both BOOST_CONTEXT_LIBRARY and BOOST_COROUTINE_LIBRARY were mentioned. But as BOOST_COROUTINE_LIBRARY depends on BOOST_CONTEXT_LIBRARY, they must be mentioned in that order for Linux to successfully link the test programs. --- indra/llmessage/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/llmessage/CMakeLists.txt b/indra/llmessage/CMakeLists.txt index 49f825d8f8..ba6e9d3939 100755 --- a/indra/llmessage/CMakeLists.txt +++ b/indra/llmessage/CMakeLists.txt @@ -256,8 +256,8 @@ if (LL_TESTS) ${LLMESSAGE_LIBRARIES} ${LLCOREHTTP_LIBRARIES} ${JSONCPP_LIBRARIES} - ${BOOST_CONTEXT_LIBRARY} ${BOOST_COROUTINE_LIBRARY} + ${BOOST_CONTEXT_LIBRARY} ${GOOGLEMOCK_LIBRARIES} ) -- cgit v1.2.3 From f8a7eda55bdd34eeb2fafed21d23d26cd25f924d Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 2 Jul 2015 09:17:48 -0700 Subject: Adjusting uploadinfo object for expansion. Commit is prelim to allow merge from selfless. --- indra/newview/llfloaterbvhpreview.cpp | 28 +--- indra/newview/llsnapshotlivepreview.cpp | 7 +- indra/newview/llviewerassetupload.cpp | 147 +++++++++++++----- indra/newview/llviewerassetupload.h | 3 +- indra/newview/llviewermenufile.cpp | 267 ++++++++++++-------------------- indra/newview/llviewermenufile.h | 105 ++++--------- 6 files changed, 249 insertions(+), 308 deletions(-) (limited to 'indra') diff --git a/indra/newview/llfloaterbvhpreview.cpp b/indra/newview/llfloaterbvhpreview.cpp index edc1421588..39b5a40efc 100755 --- a/indra/newview/llfloaterbvhpreview.cpp +++ b/indra/newview/llfloaterbvhpreview.cpp @@ -993,29 +993,15 @@ void LLFloaterBvhPreview::onBtnOK(void* userdata) std::string name = floaterp->getChild("name_form")->getValue().asString(); std::string desc = floaterp->getChild("description_form")->getValue().asString(); S32 expected_upload_cost = LLGlobalEconomy::Singleton::getInstance()->getPriceUpload(); -#if 1 - NewResourceUploadInfo::ptr_t assetUpdloadInfo(new NewResourceUploadInfo(name, desc, 0, + + NewResourceUploadInfo::ptr_t assetUpdloadInfo(new NewResourceUploadInfo( + floaterp->mTransactionID, LLAssetType::AT_ANIMATION, + name, desc, 0, LLFolderType::FT_NONE, LLInventoryType::IT_ANIMATION, LLFloaterPerms::getNextOwnerPerms("Uploads"), LLFloaterPerms::getGroupPerms("Uploads"), LLFloaterPerms::getEveryonePerms("Uploads"), - name, expected_upload_cost)); - - upload_new_resource(floaterp->mTransactionID, LLAssetType::AT_ANIMATION, - assetUpdloadInfo); -#else - LLAssetStorage::LLStoreAssetCallback callback = NULL; - void *userdata = NULL; - - upload_new_resource(floaterp->mTransactionID, // tid - LLAssetType::AT_ANIMATION, - name, - desc, - 0, - LLFolderType::FT_NONE, - LLInventoryType::IT_ANIMATION, - LLFloaterPerms::getNextOwnerPerms("Uploads"), LLFloaterPerms::getGroupPerms("Uploads"), LLFloaterPerms::getEveryonePerms("Uploads"), - name, - callback, expected_upload_cost, userdata); -#endif + expected_upload_cost)); + + upload_new_resource(assetUpdloadInfo); } else { diff --git a/indra/newview/llsnapshotlivepreview.cpp b/indra/newview/llsnapshotlivepreview.cpp index bbf560f3fa..bbb5db4a0a 100644 --- a/indra/newview/llsnapshotlivepreview.cpp +++ b/indra/newview/llsnapshotlivepreview.cpp @@ -1009,12 +1009,13 @@ void LLSnapshotLivePreview::saveTexture() std::string name = "Snapshot: " + pos_string; std::string desc = "Taken by " + who_took_it + " at " + pos_string; - NewResourceUploadInfo::ptr_t assetUploadInfo(new NewResourceUploadInfo(name, desc, 0, + NewResourceUploadInfo::ptr_t assetUploadInfo(new NewResourceUploadInfo( + tid, LLAssetType::AT_TEXTURE, name, desc, 0, LLFolderType::FT_SNAPSHOT_CATEGORY, LLInventoryType::IT_SNAPSHOT, PERM_ALL, LLFloaterPerms::getGroupPerms("Uploads"), LLFloaterPerms::getEveryonePerms("Uploads"), - name, expected_upload_cost)); + expected_upload_cost)); - upload_new_resource(tid, LLAssetType::AT_TEXTURE, assetUploadInfo); + upload_new_resource(assetUploadInfo); #else LLAssetStorage::LLStoreAssetCallback callback = NULL; diff --git a/indra/newview/llviewerassetupload.cpp b/indra/newview/llviewerassetupload.cpp index 3f21cf2b7e..e2394e20d5 100644 --- a/indra/newview/llviewerassetupload.cpp +++ b/indra/newview/llviewerassetupload.cpp @@ -35,7 +35,14 @@ #include "lluuid.h" #include "llvorbisencode.h" #include "lluploaddialog.h" +#include "llpreviewscript.h" +#include "llnotificationsutil.h" #include "lleconomy.h" +#include "llagent.h" +#include "llfloaterreg.h" +#include "llstatusbar.h" +#include "llinventorypanel.h" +#include "llsdutil.h" //========================================================================= /*static*/ @@ -44,35 +51,49 @@ void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoros::self &self, LLCore { LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - uploadInfo->prepareUpload(); + LLSD result = uploadInfo->prepareUpload(); uploadInfo->logPreparedUpload(); + if (result.has("error")) + { + HandleUploadError(LLCore::HttpStatus(499), result, uploadInfo); + return; + } + + //self.yield(); + std::string uploadMessage = "Uploading...\n\n"; uploadMessage.append(uploadInfo->getDisplayName()); LLUploadDialog::modalUploadDialog(uploadMessage); LLSD body = uploadInfo->generatePostBody(); - LLSD result = httpAdapter->postAndYield(self, httpRequest, url, body); + result = httpAdapter->postAndYield(self, httpRequest, url, body); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); - if (!status) + if ((!status) || (result.has("error"))) { - + HandleUploadError(status, result, uploadInfo); + LLUploadDialog::modalUploadFinished(); + return; } std::string uploader = result["uploader"].asString(); result = httpAdapter->postFileAndYield(self, httpRequest, uploader, uploadInfo->getAssetId(), uploadInfo->getAssetType()); + httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); if (!status) { - + HandleUploadError(status, result, uploadInfo); + LLUploadDialog::modalUploadFinished(); + return; } - S32 expected_upload_cost = 0; + S32 uploadPrice = 0; // Update L$ and ownership credit information // since it probably changed on the server @@ -81,58 +102,104 @@ void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoros::self &self, LLCore uploadInfo->getAssetType() == LLAssetType::AT_ANIMATION || uploadInfo->getAssetType() == LLAssetType::AT_MESH) { - expected_upload_cost = - LLGlobalEconomy::Singleton::getInstance()->getPriceUpload(); + uploadPrice = LLGlobalEconomy::Singleton::getInstance()->getPriceUpload(); } - on_new_single_inventory_upload_complete( - uploadInfo->getAssetType(), - uploadInfo->getInventoryType(), - uploadInfo->getAssetTypeString(), // note the paramert calls for inv_type string... - uploadInfo->getFolderId(), - uploadInfo->getName(), - uploadInfo->getDescription(), - result, - expected_upload_cost); - -#if 0 - - LLSD initalBody = generate_new_resource_upload_capability_body(); - + bool success = false; + if (uploadPrice > 0) + { + // this upload costed us L$, update our balance + // and display something saying that it cost L$ + LLStatusBar::sendMoneyBalanceRequest(); - LLSD result = httpAdapter->postAndYield(self, httpRequest, url, initalBody); + LLSD args; + args["AMOUNT"] = llformat("%d", uploadPrice); + LLNotificationsUtil::add("UploadPayment", args); + } - LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; - LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + LLUUID serverInventoryItem = uploadInfo->finishUpload(result); - if (!status) + if (serverInventoryItem.notNull()) { - + success = true; + + // Show the preview panel for textures and sounds to let + // user know that the image (or snapshot) arrived intact. + LLInventoryPanel* panel = LLInventoryPanel::getActiveInventoryPanel(); + if (panel) + { + LLFocusableElement* focus = gFocusMgr.getKeyboardFocus(); + panel->setSelection(serverInventoryItem, TAKE_FOCUS_NO); + + // restore keyboard focus + gFocusMgr.setKeyboardFocus(focus); + } + } + else + { + LL_WARNS() << "Can't find a folder to put it in" << LL_ENDL; } - std::string state = result["state"].asString(); + // remove the "Uploading..." message + LLUploadDialog::modalUploadFinished(); - if (state == "upload") + // Let the Snapshot floater know we have finished uploading a snapshot to inventory. + LLFloater* floater_snapshot = LLFloaterReg::findInstance("snapshot"); + if (uploadInfo->getAssetType() == LLAssetType::AT_TEXTURE && floater_snapshot) { -// Upload the file... - result = httpAdapter->postFileAndYield(self, httpRequest, url, initalBody); + floater_snapshot->notify(LLSD().with("set-finished", LLSD().with("ok", success).with("msg", "inventory"))); + } +} - httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; - status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); +//========================================================================= +/*static*/ +void LLViewerAssetUpload::HandleUploadError(LLCore::HttpStatus status, LLSD &result, NewResourceUploadInfo::ptr_t &uploadInfo) +{ + std::string reason; + std::string label("CannotUploadReason"); - state = result["state"].asString(); + LL_WARNS() << ll_pretty_print_sd(result) << LL_ENDL; + + if (result.has("label")) + { + label = result["label"]; } - if (state == "complete") + if (result.has("message")) { - // done with the upload. + reason = result["message"]; } else { - // an error occurred + if (status.getType() == 499) + { + reason = "The server is experiencing unexpected difficulties."; + } + else + { + reason = "Error in upload request. Please visit " + "http://secondlife.com/support for help fixing this problem."; + } } -#endif -} -//========================================================================= + LLSD args; + args["FILE"] = uploadInfo->getDisplayName(); + args["REASON"] = reason; + + LLNotificationsUtil::add(label, args); + + // unfreeze script preview + if (uploadInfo->getAssetType() == LLAssetType::AT_LSL_TEXT) + { + LLPreviewLSL* preview = LLFloaterReg::findTypedInstance("preview_script", + uploadInfo->getItemId()); + if (preview) + { + LLSD errors; + errors.append(LLTrans::getString("UploadFailed") + reason); + preview->callbackLSLCompileFailed(errors); + } + } + +} diff --git a/indra/newview/llviewerassetupload.h b/indra/newview/llviewerassetupload.h index c80a7617e1..ad48be67a6 100644 --- a/indra/newview/llviewerassetupload.h +++ b/indra/newview/llviewerassetupload.h @@ -44,7 +44,8 @@ public: static void AssetInventoryUploadCoproc(LLCoros::self &self, LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &httpAdapter, const LLUUID &id, std::string url, NewResourceUploadInfo::ptr_t uploadInfo); - +private: + static void HandleUploadError(LLCore::HttpStatus status, LLSD &result, NewResourceUploadInfo::ptr_t &uploadInfo); }; #endif // !VIEWER_ASSET_UPLOAD_H diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index 7bcf241d5e..4772dd144b 100755 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -85,8 +85,9 @@ class LLFileEnableUpload : public view_listener_t { bool handleEvent(const LLSD& userdata) { - bool new_value = gStatusBar && LLGlobalEconomy::Singleton::getInstance() && (gStatusBar->getBalance() >= LLGlobalEconomy::Singleton::getInstance()->getPriceUpload()); - return new_value; + return true; +// bool new_value = gStatusBar && LLGlobalEconomy::Singleton::getInstance() && (gStatusBar->getBalance() >= LLGlobalEconomy::Singleton::getInstance()->getPriceUpload()); +// return new_value; } }; @@ -757,38 +758,15 @@ LLUUID upload_new_resource( if (!error) { - std::string t_disp_name = display_name; - if (t_disp_name.empty()) - { - t_disp_name = src_filename; - } - -#if 1 NewResourceUploadInfo::ptr_t uploadInfo(new NewResourceUploadInfo( + tid, asset_type, name, desc, compression_info, destination_folder_type, inv_type, next_owner_perms, group_perms, everyone_perms, - display_name, expected_upload_cost)); + expected_upload_cost)); - upload_new_resource(tid, asset_type, uploadInfo, + upload_new_resource(uploadInfo, callback, userdata); -#else - upload_new_resource( - tid, - asset_type, - name, - desc, - compression_info, // tid - destination_folder_type, - inv_type, - next_owner_perms, - group_perms, - everyone_perms, - display_name, - callback, - expected_upload_cost, - userdata); -#endif } else { @@ -933,63 +911,7 @@ void upload_done_callback( } } -#if 0 -static LLAssetID upload_new_resource_prep( - const LLTransactionID& tid, - LLAssetType::EType asset_type, - LLInventoryType::EType& inventory_type, - std::string& name, - const std::string& display_name, - std::string& description) -{ - LLAssetID uuid = generate_asset_id_for_new_upload(tid); - - increase_new_upload_stats(asset_type); - - assign_defaults_and_show_upload_message( - asset_type, - inventory_type, - name, - display_name, - description); - - return uuid; -} -#endif - -#if 0 -LLSD generate_new_resource_upload_capability_body( - LLAssetType::EType asset_type, - const std::string& name, - const std::string& desc, - LLFolderType::EType destination_folder_type, - LLInventoryType::EType inv_type, - U32 next_owner_perms, - U32 group_perms, - U32 everyone_perms) -{ - LLSD body; - - body["folder_id"] = gInventory.findCategoryUUIDForType( - (destination_folder_type == LLFolderType::FT_NONE) ? - (LLFolderType::EType) asset_type : - destination_folder_type); - - body["asset_type"] = LLAssetType::lookup(asset_type); - body["inventory_type"] = LLInventoryType::lookup(inv_type); - body["name"] = name; - body["description"] = desc; - body["next_owner_mask"] = LLSD::Integer(next_owner_perms); - body["group_mask"] = LLSD::Integer(group_perms); - body["everyone_mask"] = LLSD::Integer(everyone_perms); - - return body; -} -#endif - void upload_new_resource( - const LLTransactionID &tid, - LLAssetType::EType assetType, NewResourceUploadInfo::ptr_t &uploadInfo, LLAssetStorage::LLStoreAssetCallback callback, void *userdata) @@ -999,8 +921,8 @@ void upload_new_resource( return ; } - uploadInfo->setAssetType(assetType); - uploadInfo->setTransactionId(tid); +// uploadInfo->setAssetType(assetType); +// uploadInfo->setTransactionId(tid); std::string url = gAgent.getRegion()->getCapability("NewFileAgentInventory"); @@ -1010,19 +932,6 @@ void upload_new_resource( LLCoprocedureManager::CoProcedure_t proc = boost::bind(&LLViewerAssetUpload::AssetInventoryUploadCoproc, _1, _2, _3, url, uploadInfo); LLCoprocedureManager::getInstance()->enqueueCoprocedure("LLViewerAssetUpload::AssetInventoryUploadCoproc", proc); -// LL_INFOS() << "New Agent Inventory via capability" << LL_ENDL; -// uploadInfo->prepareUpload(); -// uploadInfo->logPreparedUpload(); -// -// LLSD body = uploadInfo->generatePostBody(); -// -// LLHTTPClient::post( -// url, -// body, -// new LLNewAgentInventoryResponder( -// body, -// uploadInfo->getAssetId(), -// assetType)); } else { @@ -1032,9 +941,9 @@ void upload_new_resource( LL_INFOS() << "NewAgentInventory capability not found, new agent inventory via asset system." << LL_ENDL; // check for adequate funds // TODO: do this check on the sim - if (LLAssetType::AT_SOUND == assetType || - LLAssetType::AT_TEXTURE == assetType || - LLAssetType::AT_ANIMATION == assetType) + if (LLAssetType::AT_SOUND == uploadInfo->getAssetType() || + LLAssetType::AT_TEXTURE == uploadInfo->getAssetType() || + LLAssetType::AT_ANIMATION == uploadInfo->getAssetType()) { S32 balance = gStatusBar->getBalance(); if (balance < uploadInfo->getExpectedUploadCost()) @@ -1049,9 +958,9 @@ void upload_new_resource( } LLResourceData* data = new LLResourceData; - data->mAssetInfo.mTransactionID = tid; + data->mAssetInfo.mTransactionID = uploadInfo->getTransactionId(); data->mAssetInfo.mUuid = uploadInfo->getAssetId(); - data->mAssetInfo.mType = assetType; + data->mAssetInfo.mType = uploadInfo->getAssetType(); data->mAssetInfo.mCreatorID = gAgentID; data->mInventoryType = uploadInfo->getInventoryType(); data->mNextOwnerPerm = uploadInfo->getNextOwnerPerms(); @@ -1075,68 +984,6 @@ void upload_new_resource( } } -#if 0 -LLAssetID generate_asset_id_for_new_upload(const LLTransactionID& tid) -{ - if ( gDisconnected ) - { - LLAssetID rv; - - rv.setNull(); - return rv; - } - - LLAssetID uuid = tid.makeAssetID(gAgent.getSecureSessionID()); - - return uuid; -} - -void increase_new_upload_stats(LLAssetType::EType asset_type) -{ - if ( LLAssetType::AT_SOUND == asset_type ) - { - add(LLStatViewer::UPLOAD_SOUND, 1); - } - else if ( LLAssetType::AT_TEXTURE == asset_type ) - { - add(LLStatViewer::UPLOAD_TEXTURE, 1); - } - else if ( LLAssetType::AT_ANIMATION == asset_type ) - { - add(LLStatViewer::ANIMATION_UPLOADS, 1); - } -} - -void assign_defaults_and_show_upload_message( - LLAssetType::EType asset_type, - LLInventoryType::EType& inventory_type, - std::string& name, - const std::string& display_name, - std::string& description) -{ - if ( LLInventoryType::IT_NONE == inventory_type ) - { - inventory_type = LLInventoryType::defaultForAssetType(asset_type); - } - LLStringUtil::stripNonprintable(name); - LLStringUtil::stripNonprintable(description); - - if ( name.empty() ) - { - name = "(No Name)"; - } - if ( description.empty() ) - { - description = "(No Description)"; - } - - // At this point, we're ready for the upload. - std::string upload_message = "Uploading...\n\n"; - upload_message.append(display_name); - LLUploadDialog::modalUploadDialog(upload_message); -} -#endif - void init_menu_file() { @@ -1160,14 +1007,14 @@ void init_menu_file() // "File.SaveTexture" moved to llpanelmaininventory so that it can be properly handled. } -LLAssetID NewResourceUploadInfo::prepareUpload() +LLSD NewResourceUploadInfo::prepareUpload() { - LLAssetID uuid = generateNewAssetId(); + generateNewAssetId(); incrementUploadStats(); assignDefaults(); - return uuid; + return LLSD().with("success", LLSD::Boolean(true)); } std::string NewResourceUploadInfo::getAssetTypeString() const @@ -1209,6 +1056,84 @@ void NewResourceUploadInfo::logPreparedUpload() "Asset Type: " << LLAssetType::lookup(mAssetType) << LL_ENDL; } +LLUUID NewResourceUploadInfo::finishUpload(LLSD &result) +{ + if (getFolderId().isNull()) + { + return LLUUID::null; + } + + U32 permsEveryone = PERM_NONE; + U32 permsGroup = PERM_NONE; + U32 permsNextOwner = PERM_ALL; + + if (result.has("new_next_owner_mask")) + { + // The server provided creation perms so use them. + // Do not assume we got the perms we asked for in + // since the server may not have granted them all. + permsEveryone = result["new_everyone_mask"].asInteger(); + permsGroup = result["new_group_mask"].asInteger(); + permsNextOwner = result["new_next_owner_mask"].asInteger(); + } + else + { + // The server doesn't provide creation perms + // so use old assumption-based perms. + if (getAssetTypeString() != "snapshot") + { + permsNextOwner = PERM_MOVE | PERM_TRANSFER; + } + } + + LLPermissions new_perms; + new_perms.init( + gAgent.getID(), + gAgent.getID(), + LLUUID::null, + LLUUID::null); + + new_perms.initMasks( + PERM_ALL, + PERM_ALL, + permsEveryone, + permsGroup, + permsNextOwner); + + U32 flagsInventoryItem = 0; + if (result.has("inventory_flags")) + { + flagsInventoryItem = static_cast(result["inventory_flags"].asInteger()); + if (flagsInventoryItem != 0) + { + LL_INFOS() << "inventory_item_flags " << flagsInventoryItem << LL_ENDL; + } + } + S32 creationDate = time_corrected(); + + LLUUID serverInventoryItem = result["new_inventory_item"].asUUID(); + LLUUID serverAssetId = result["new_asset"].asUUID(); + + LLPointer item = new LLViewerInventoryItem( + serverInventoryItem, + getFolderId(), + new_perms, + serverAssetId, + getAssetType(), + getInventoryType(), + getName(), + getDescription(), + LLSaleInfo::DEFAULT, + flagsInventoryItem, + creationDate); + + gInventory.updateItem(item); + gInventory.notifyObservers(); + + return serverInventoryItem; +} + + LLAssetID NewResourceUploadInfo::generateNewAssetId() { if (gDisconnected) @@ -1263,3 +1188,7 @@ void NewResourceUploadInfo::assignDefaults() } +std::string NewResourceUploadInfo::getDisplayName() const +{ + return (mName.empty()) ? mAssetId.asString() : mName; +}; diff --git a/indra/newview/llviewermenufile.h b/indra/newview/llviewermenufile.h index 297895cbf0..9bc4d5b041 100755 --- a/indra/newview/llviewermenufile.h +++ b/indra/newview/llviewermenufile.h @@ -39,13 +39,15 @@ class LLTransactionID; void init_menu_file(); -#if 1 class NewResourceUploadInfo { public: typedef boost::shared_ptr ptr_t; - NewResourceUploadInfo(std::string name, + NewResourceUploadInfo( + LLTransactionID transactId, + LLAssetType::EType assetType, + std::string name, std::string description, S32 compressionInfo, LLFolderType::EType destinationType, @@ -53,48 +55,53 @@ public: U32 nextOWnerPerms, U32 groupPerms, U32 everyonePerms, - std::string displayName, S32 expectedCost) : + mTransactionId(transactId), + mAssetType(assetType), mName(name), mDescription(description), - mDisplayName(displayName), mCompressionInfo(compressionInfo), + mDestinationFolderType(destinationType), + mInventoryType(inventoryType), mNextOwnerPerms(nextOWnerPerms), mGroupPerms(groupPerms), mEveryonePerms(everyonePerms), mExpectedUploadCost(expectedCost), - mInventoryType(inventoryType), - mDestinationFolderType(destinationType) + mFolderId(LLUUID::null), + mItemId(LLUUID::null), + mAssetId(LLAssetID::null) { } virtual ~NewResourceUploadInfo() { } - virtual LLAssetID prepareUpload(); + virtual LLSD prepareUpload(); virtual LLSD generatePostBody(); virtual void logPreparedUpload(); + virtual LLUUID finishUpload(LLSD &result); + + //void setAssetType(LLAssetType::EType assetType) { mAssetType = assetType; } + //void setTransactionId(LLTransactionID transactionId) { mTransactionId = transactionId; } - void setAssetType(LLAssetType::EType assetType) { mAssetType = assetType; } + LLTransactionID getTransactionId() const { return mTransactionId; } LLAssetType::EType getAssetType() const { return mAssetType; } std::string getAssetTypeString() const; - void setTransactionId(LLTransactionID transactionId) { mTransactionId = transactionId; } - LLTransactionID getTransactionId() const { return mTransactionId; } - LLUUID getFolderId() const { return mFolderId; } - - LLAssetID getAssetId() const { return mAssetId; } - std::string getName() const { return mName; }; std::string getDescription() const { return mDescription; }; - std::string getDisplayName() const { return mDisplayName; }; S32 getCompressionInfo() const { return mCompressionInfo; }; + LLFolderType::EType getDestinationFolderType() const { return mDestinationFolderType; }; + LLInventoryType::EType getInventoryType() const { return mInventoryType; }; + std::string getInventoryTypeString() const; U32 getNextOwnerPerms() const { return mNextOwnerPerms; }; U32 getGroupPerms() const { return mGroupPerms; }; U32 getEveryonePerms() const { return mEveryonePerms; }; S32 getExpectedUploadCost() const { return mExpectedUploadCost; }; - LLInventoryType::EType getInventoryType() const { return mInventoryType; }; - std::string getInventoryTypeString() const; - - LLFolderType::EType getDestinationFolderType() const { return mDestinationFolderType; }; + + std::string getDisplayName() const; + + LLUUID getFolderId() const { return mFolderId; } + LLUUID getItemId() const { return mItemId; } + LLAssetID getAssetId() const { return mAssetId; } protected: LLAssetID generateNewAssetId(); @@ -102,22 +109,21 @@ protected: virtual void assignDefaults(); private: + LLTransactionID mTransactionId; LLAssetType::EType mAssetType; std::string mName; std::string mDescription; - std::string mDisplayName; S32 mCompressionInfo; + LLFolderType::EType mDestinationFolderType; + LLInventoryType::EType mInventoryType; U32 mNextOwnerPerms; U32 mGroupPerms; U32 mEveryonePerms; S32 mExpectedUploadCost; - LLUUID mFolderId; - - LLInventoryType::EType mInventoryType; - LLFolderType::EType mDestinationFolderType; + LLUUID mFolderId; + LLUUID mItemId; LLAssetID mAssetId; - LLTransactionID mTransactionId; }; @@ -137,48 +143,11 @@ LLUUID upload_new_resource( void *userdata); void upload_new_resource( - const LLTransactionID &tid, - LLAssetType::EType type, NewResourceUploadInfo::ptr_t &uploadInfo, LLAssetStorage::LLStoreAssetCallback callback = NULL, void *userdata = NULL); -#else -LLUUID upload_new_resource( - const std::string& src_filename, - std::string name, - std::string desc, - S32 compression_info, - LLFolderType::EType destination_folder_type, - LLInventoryType::EType inv_type, - U32 next_owner_perms, - U32 group_perms, - U32 everyone_perms, - const std::string& display_name, - LLAssetStorage::LLStoreAssetCallback callback, - S32 expected_upload_cost, - void *userdata); - -void upload_new_resource( - const LLTransactionID &tid, - LLAssetType::EType type, - std::string name, - std::string desc, - S32 compression_info, - LLFolderType::EType destination_folder_type, - LLInventoryType::EType inv_type, - U32 next_owner_perms, - U32 group_perms, - U32 everyone_perms, - const std::string& display_name, - LLAssetStorage::LLStoreAssetCallback callback, - S32 expected_upload_cost, - void *userdata); - -LLAssetID generate_asset_id_for_new_upload(const LLTransactionID& tid); -void increase_new_upload_stats(LLAssetType::EType asset_type); -#endif void assign_defaults_and_show_upload_message( LLAssetType::EType asset_type, LLInventoryType::EType& inventory_type, @@ -186,18 +155,6 @@ void assign_defaults_and_show_upload_message( const std::string& display_name, std::string& description); -#if 0 -LLSD generate_new_resource_upload_capability_body( - LLAssetType::EType asset_type, - const std::string& name, - const std::string& desc, - LLFolderType::EType destination_folder_type, - LLInventoryType::EType inv_type, - U32 next_owner_perms, - U32 group_perms, - U32 everyone_perms); -#endif - void on_new_single_inventory_upload_complete( LLAssetType::EType asset_type, LLInventoryType::EType inventory_type, -- cgit v1.2.3 From 97c67a6634de418e85efcfcd116b2e00efb436e3 Mon Sep 17 00:00:00 2001 From: Bjoseph Wombat Date: Thu, 2 Jul 2015 12:49:55 -0400 Subject: test fix for a race condition in the state machine when switching between region voice and P2P calls. --- indra/newview/llvoicevivox.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'indra') diff --git a/indra/newview/llvoicevivox.cpp b/indra/newview/llvoicevivox.cpp index da8f51bc03..e4b045bdeb 100755 --- a/indra/newview/llvoicevivox.cpp +++ b/indra/newview/llvoicevivox.cpp @@ -1951,7 +1951,10 @@ void LLVivoxVoiceClient::leaveAudioSession() void LLVivoxVoiceClient::sessionTerminateSendMessage(sessionState *session) { std::ostringstream stream; - + + sessionGroupTerminateSendMessage(session); + return; + /* LL_DEBUGS("Voice") << "Sending Session.Terminate with handle " << session->mHandle << LL_ENDL; stream << "" @@ -1959,6 +1962,7 @@ void LLVivoxVoiceClient::sessionTerminateSendMessage(sessionState *session) << "\n\n\n"; writeString(stream.str()); + */ } void LLVivoxVoiceClient::sessionGroupTerminateSendMessage(sessionState *session) @@ -1977,7 +1981,9 @@ void LLVivoxVoiceClient::sessionGroupTerminateSendMessage(sessionState *session) void LLVivoxVoiceClient::sessionMediaDisconnectSendMessage(sessionState *session) { std::ostringstream stream; - + sessionGroupTerminateSendMessage(session); + return; + /* LL_DEBUGS("Voice") << "Sending Session.MediaDisconnect with handle " << session->mHandle << LL_ENDL; stream << "" @@ -1987,6 +1993,7 @@ void LLVivoxVoiceClient::sessionMediaDisconnectSendMessage(sessionState *session << "\n\n\n"; writeString(stream.str()); + */ } -- cgit v1.2.3 From f90023fc0b3b61fd346a2b56e30e5f3c35814192 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 2 Jul 2015 17:00:32 -0400 Subject: MAINT-5357: Introduce and populate llcoro:: namespace. To date, the coroutine helper functions in lleventcoro.h have been in the global namespace. Migrate them into llcoro namespace, and fix references. Specifically, LLVoidListener => llcoro::VoidListener, and voidlistener(), postAndWait(), both waitForEventOn(), postAndWait2(), errorException() and errorLog() have been moved into llcoro. Also migrate new LLCoros::get_self() and Suspending to llcoro:: namespace. While at it, I realized that -- having converted several lleventcoro.h functions from templates (for arbitrary 'self' parameter type) to ordinary functions, having moved them from lleventcoro.h to lleventcoro.cpp, we can now migrate their helpers from lleventcoro.h to lleventcoro.cpp as well. This eliminates the need for the LLEventDetail namespace; the relevant helpers are now in an anonymous namespace in the .cpp file: listenerNameForCoro(), storeToLLSDPath(), WaitForEventOnHelper and wfeoh(). --- indra/llcommon/llcoros.cpp | 10 +-- indra/llcommon/llcoros.h | 35 +++++---- indra/llcommon/lleventcoro.cpp | 119 ++++++++++++++++++++++++----- indra/llcommon/lleventcoro.h | 122 +++++++----------------------- indra/llcommon/tests/lleventcoro_test.cpp | 5 +- indra/llmessage/llcorehttputil.cpp | 10 +-- indra/newview/llcoproceduremanager.cpp | 2 +- indra/newview/lleventpoll.cpp | 2 +- indra/viewer_components/login/lllogin.cpp | 6 +- 9 files changed, 166 insertions(+), 145 deletions(-) (limited to 'indra') diff --git a/indra/llcommon/llcoros.cpp b/indra/llcommon/llcoros.cpp index 2d0c419ae0..957fe034e1 100755 --- a/indra/llcommon/llcoros.cpp +++ b/indra/llcommon/llcoros.cpp @@ -69,9 +69,9 @@ sCurrentSelf(no_cleanup); } // anonymous //static -LLCoros::coro::self& LLCoros::get_self() +LLCoros::coro::self& llcoro::get_self() { - coro::self* current_self = sCurrentSelf.get(); + LLCoros::coro::self* current_self = sCurrentSelf.get(); if (! current_self) { LL_ERRS("LLCoros") << "Calling get_self() from non-coroutine context!" << LL_ENDL; @@ -79,7 +79,7 @@ LLCoros::coro::self& LLCoros::get_self() return *current_self; } -LLCoros::Suspending::Suspending(): +llcoro::Suspending::Suspending(): mSuspended(sCurrentSelf.get()) { // For the duration of our time away from this coroutine, sCurrentSelf @@ -87,7 +87,7 @@ LLCoros::Suspending::Suspending(): sCurrentSelf.reset(); } -LLCoros::Suspending::~Suspending() +llcoro::Suspending::~Suspending() { // Okay, we're back, reinstate previous value of sCurrentSelf. sCurrentSelf.reset(mSuspended); @@ -171,7 +171,7 @@ bool LLCoros::kill(const std::string& name) std::string LLCoros::getName() const { // Walk the existing coroutines, looking for the current one. - void* self_id = get_self().get_id(); + void* self_id = llcoro::get_self().get_id(); for (CoroMap::const_iterator mi(mCoros.begin()), mend(mCoros.end()); mi != mend; ++mi) { namespace coro_private = boost::dcoroutines::detail; diff --git a/indra/llcommon/llcoros.h b/indra/llcommon/llcoros.h index 3f58a17aa9..e478600f00 100755 --- a/indra/llcommon/llcoros.h +++ b/indra/llcommon/llcoros.h @@ -137,21 +137,6 @@ public: */ std::string getName() const; - /// get the current coro::self& for those who really really care - static coro::self& get_self(); - - /// Instantiate one of these in a block surrounding any leaf point when - /// control literally switches away from this coroutine. - class Suspending - { - public: - Suspending(); - ~Suspending(); - - private: - coro::self* mSuspended; - }; - /// for delayed initialization void setStackSize(S32 stacksize); @@ -166,4 +151,24 @@ private: CoroMap mCoros; }; +namespace llcoro +{ + +/// get the current coro::self& for those who really really care +LLCoros::coro::self& get_self(); + +/// Instantiate one of these in a block surrounding any leaf point when +/// control literally switches away from this coroutine. +class Suspending +{ +public: + Suspending(); + ~Suspending(); + +private: + LLCoros::coro::self* mSuspended; +}; + +} // namespace llcoro + #endif /* ! defined(LL_LLCOROS_H) */ diff --git a/indra/llcommon/lleventcoro.cpp b/indra/llcommon/lleventcoro.cpp index be93e9c83b..b7e7edec5a 100755 --- a/indra/llcommon/lleventcoro.cpp +++ b/indra/llcommon/lleventcoro.cpp @@ -41,7 +41,23 @@ #include "llerror.h" #include "llcoros.h" -std::string LLEventDetail::listenerNameForCoro() +namespace +{ + +/** + * waitForEventOn() permits a coroutine to temporarily listen on an + * LLEventPump any number of times. We don't really want to have to ask + * the caller to label each such call with a distinct string; the whole + * point of waitForEventOn() is to present a nice sequential interface to + * the underlying LLEventPump-with-named-listeners machinery. So we'll use + * LLEventPump::inventName() to generate a distinct name for each + * temporary listener. On the other hand, because a given coroutine might + * call waitForEventOn() any number of times, we don't really want to + * consume an arbitrary number of generated inventName()s: that namespace, + * though large, is nonetheless finite. So we memoize an invented name for + * each distinct coroutine instance. + */ +std::string listenerNameForCoro() { // If this coroutine was launched by LLCoros::launch(), find that name. std::string name(LLCoros::instance().getName()); @@ -56,7 +72,25 @@ std::string LLEventDetail::listenerNameForCoro() return name; } -void LLEventDetail::storeToLLSDPath(LLSD& dest, const LLSD& rawPath, const LLSD& value) +/** + * Implement behavior described for postAndWait()'s @a replyPumpNamePath + * parameter: + * + * * If path.isUndefined(), do nothing. + * * If path.isString(), @a dest is an LLSD map: store @a value + * into dest[path.asString()]. + * * If path.isInteger(), @a dest is an LLSD array: store @a + * value into dest[path.asInteger()]. + * * If path.isArray(), iteratively apply the rules above to step + * down through the structure of @a dest. The last array entry in @a + * path specifies the entry in the lowest-level structure in @a dest + * into which to store @a value. + * + * @note + * In the degenerate case in which @a path is an empty array, @a dest will + * @em become @a value rather than @em containing it. + */ +void storeToLLSDPath(LLSD& dest, const LLSD& rawPath, const LLSD& value) { if (rawPath.isUndefined()) { @@ -109,14 +143,16 @@ void LLEventDetail::storeToLLSDPath(LLSD& dest, const LLSD& rawPath, const LLSD& *pdest = value; } -LLSD postAndWait(const LLSD& event, const LLEventPumpOrPumpName& requestPump, - const LLEventPumpOrPumpName& replyPump, const LLSD& replyPumpNamePath) +} // anonymous + +LLSD llcoro::postAndWait(const LLSD& event, const LLEventPumpOrPumpName& requestPump, + const LLEventPumpOrPumpName& replyPump, const LLSD& replyPumpNamePath) { // declare the future - boost::dcoroutines::future future(LLCoros::get_self()); + boost::dcoroutines::future future(llcoro::get_self()); // make a callback that will assign a value to the future, and listen on // the specified LLEventPump with that callback - std::string listenerName(LLEventDetail::listenerNameForCoro()); + std::string listenerName(listenerNameForCoro()); LLTempBoundListener connection( replyPump.getPump().listen(listenerName, voidlistener(boost::dcoroutines::make_callback(future)))); @@ -126,7 +162,7 @@ LLSD postAndWait(const LLSD& event, const LLEventPumpOrPumpName& requestPump, // If replyPumpNamePath is non-empty, store the replyPump name in the // request event. LLSD modevent(event); - LLEventDetail::storeToLLSDPath(modevent, replyPumpNamePath, replyPump.getPump().getName()); + storeToLLSDPath(modevent, replyPumpNamePath, replyPump.getPump().getName()); LL_DEBUGS("lleventcoro") << "postAndWait(): coroutine " << listenerName << " posting to " << requestPump.getPump().getName() << LL_ENDL; @@ -142,7 +178,7 @@ LLSD postAndWait(const LLSD& event, const LLEventPumpOrPumpName& requestPump, LLSD value; { // instantiate Suspending to manage the "current" coroutine - LLCoros::Suspending suspended; + llcoro::Suspending suspended; value = *future; } // destroy Suspending as soon as we're back LL_DEBUGS("lleventcoro") << "postAndWait(): coroutine " << listenerName @@ -151,6 +187,53 @@ LLSD postAndWait(const LLSD& event, const LLEventPumpOrPumpName& requestPump, return value; } +namespace +{ + +/** + * This helper is specifically for the two-pump version of waitForEventOn(). + * We use a single future object, but we want to listen on two pumps with it. + * Since we must still adapt from (the callable constructed by) + * boost::dcoroutines::make_callback() (void return) to provide an event + * listener (bool return), we've adapted VoidListener for the purpose. The + * basic idea is that we construct a distinct instance of WaitForEventOnHelper + * -- binding different instance data -- for each of the pumps. Then, when a + * pump delivers an LLSD value to either WaitForEventOnHelper, it can combine + * that LLSD with its discriminator to feed the future object. + */ +template +class WaitForEventOnHelper +{ +public: + WaitForEventOnHelper(const LISTENER& listener, int discriminator): + mListener(listener), + mDiscrim(discriminator) + {} + // this signature is required for an LLEventPump listener + bool operator()(const LLSD& event) + { + // our future object is defined to accept LLEventWithID + mListener(LLEventWithID(event, mDiscrim)); + // don't swallow the event, let other listeners see it + return false; + } +private: + LISTENER mListener; + const int mDiscrim; +}; + +/// WaitForEventOnHelper type-inference helper +template +WaitForEventOnHelper wfeoh(const LISTENER& listener, int discriminator) +{ + return WaitForEventOnHelper(listener, discriminator); +} + +} // anonymous + +namespace llcoro +{ + LLEventWithID postAndWait2(const LLSD& event, const LLEventPumpOrPumpName& requestPump, const LLEventPumpOrPumpName& replyPump0, @@ -159,26 +242,26 @@ LLEventWithID postAndWait2(const LLSD& event, const LLSD& replyPump1NamePath) { // declare the future - boost::dcoroutines::future future(LLCoros::get_self()); + boost::dcoroutines::future future(llcoro::get_self()); // either callback will assign a value to this future; listen on // each specified LLEventPump with a callback - std::string name(LLEventDetail::listenerNameForCoro()); + std::string name(listenerNameForCoro()); LLTempBoundListener connection0( replyPump0.getPump().listen(name + "a", - LLEventDetail::wfeoh(boost::dcoroutines::make_callback(future), 0))); + wfeoh(boost::dcoroutines::make_callback(future), 0))); LLTempBoundListener connection1( replyPump1.getPump().listen(name + "b", - LLEventDetail::wfeoh(boost::dcoroutines::make_callback(future), 1))); + wfeoh(boost::dcoroutines::make_callback(future), 1))); // skip the "post" part if requestPump is default-constructed if (requestPump) { // If either replyPumpNamePath is non-empty, store the corresponding // replyPump name in the request event. LLSD modevent(event); - LLEventDetail::storeToLLSDPath(modevent, replyPump0NamePath, - replyPump0.getPump().getName()); - LLEventDetail::storeToLLSDPath(modevent, replyPump1NamePath, - replyPump1.getPump().getName()); + storeToLLSDPath(modevent, replyPump0NamePath, + replyPump0.getPump().getName()); + storeToLLSDPath(modevent, replyPump1NamePath, + replyPump1.getPump().getName()); LL_DEBUGS("lleventcoro") << "postAndWait2(): coroutine " << name << " posting to " << requestPump.getPump().getName() << ": " << modevent << LL_ENDL; @@ -191,7 +274,7 @@ LLEventWithID postAndWait2(const LLSD& event, LLEventWithID value; { // instantiate Suspending to manage "current" coroutine - LLCoros::Suspending suspended; + llcoro::Suspending suspended; value = *future; } // destroy Suspending as soon as we're back LL_DEBUGS("lleventcoro") << "postAndWait(): coroutine " << name @@ -227,3 +310,5 @@ LLSD errorLog(const LLEventWithID& result, const std::string& desc) // A simple return must therefore be from the reply pump (pump 0). return result.first; } + +} // namespace llcoro diff --git a/indra/llcommon/lleventcoro.h b/indra/llcommon/lleventcoro.h index daf9360a2e..2a60f2b1e0 100755 --- a/indra/llcommon/lleventcoro.h +++ b/indra/llcommon/lleventcoro.h @@ -72,13 +72,16 @@ private: boost::optional mPump; }; +namespace llcoro +{ + /// This is an adapter for a signature like void LISTENER(const LLSD&), which /// isn't a valid LLEventPump listener: such listeners should return bool. template -class LLVoidListener +class VoidListener { public: - LLVoidListener(const LISTENER& listener): + VoidListener(const LISTENER& listener): mListener(listener) {} bool operator()(const LLSD& event) @@ -91,51 +94,13 @@ private: LISTENER mListener; }; -/// LLVoidListener helper function to infer the type of the LISTENER +/// VoidListener helper function to infer the type of the LISTENER template -LLVoidListener voidlistener(const LISTENER& listener) +VoidListener voidlistener(const LISTENER& listener) { - return LLVoidListener(listener); + return VoidListener(listener); } -namespace LLEventDetail -{ - /** - * waitForEventOn() permits a coroutine to temporarily listen on an - * LLEventPump any number of times. We don't really want to have to ask - * the caller to label each such call with a distinct string; the whole - * point of waitForEventOn() is to present a nice sequential interface to - * the underlying LLEventPump-with-named-listeners machinery. So we'll use - * LLEventPump::inventName() to generate a distinct name for each - * temporary listener. On the other hand, because a given coroutine might - * call waitForEventOn() any number of times, we don't really want to - * consume an arbitrary number of generated inventName()s: that namespace, - * though large, is nonetheless finite. So we memoize an invented name for - * each distinct coroutine instance. - */ - std::string listenerNameForCoro(); - - /** - * Implement behavior described for postAndWait()'s @a replyPumpNamePath - * parameter: - * - * * If path.isUndefined(), do nothing. - * * If path.isString(), @a dest is an LLSD map: store @a value - * into dest[path.asString()]. - * * If path.isInteger(), @a dest is an LLSD array: store @a - * value into dest[path.asInteger()]. - * * If path.isArray(), iteratively apply the rules above to step - * down through the structure of @a dest. The last array entry in @a - * path specifies the entry in the lowest-level structure in @a dest - * into which to store @a value. - * - * @note - * In the degenerate case in which @a path is an empty array, @a dest will - * @em become @a value rather than @em containing it. - */ - LL_COMMON_API void storeToLLSDPath(LLSD& dest, const LLSD& path, const LLSD& value); -} // namespace LLEventDetail - /** * Post specified LLSD event on the specified LLEventPump, then wait for a * response on specified other LLEventPump. This is more than mere @@ -196,50 +161,13 @@ LLSD waitForEventOn(const LLEventPumpOrPumpName& pump) return postAndWait(LLSD(), LLEventPumpOrPumpName(), pump); } +} // namespace llcoro + /// return type for two-pump variant of waitForEventOn() typedef std::pair LLEventWithID; -namespace LLEventDetail +namespace llcoro { - /** - * This helper is specifically for the two-pump version of waitForEventOn(). - * We use a single future object, but we want to listen on two pumps with it. - * Since we must still adapt from (the callable constructed by) - * boost::dcoroutines::make_callback() (void return) to provide an event - * listener (bool return), we've adapted LLVoidListener for the purpose. The - * basic idea is that we construct a distinct instance of WaitForEventOnHelper - * -- binding different instance data -- for each of the pumps. Then, when a - * pump delivers an LLSD value to either WaitForEventOnHelper, it can combine - * that LLSD with its discriminator to feed the future object. - */ - template - class WaitForEventOnHelper - { - public: - WaitForEventOnHelper(const LISTENER& listener, int discriminator): - mListener(listener), - mDiscrim(discriminator) - {} - // this signature is required for an LLEventPump listener - bool operator()(const LLSD& event) - { - // our future object is defined to accept LLEventWithID - mListener(LLEventWithID(event, mDiscrim)); - // don't swallow the event, let other listeners see it - return false; - } - private: - LISTENER mListener; - const int mDiscrim; - }; - - /// WaitForEventOnHelper type-inference helper - template - WaitForEventOnHelper wfeoh(const LISTENER& listener, int discriminator) - { - return WaitForEventOnHelper(listener, discriminator); - } -} // namespace LLEventDetail /** * This function waits for a reply on either of two specified LLEventPumps. @@ -334,6 +262,8 @@ private: */ LL_COMMON_API LLSD errorLog(const LLEventWithID& result, const std::string& desc); +} // namespace llcoro + /** * Certain event APIs require the name of an LLEventPump on which they should * post results. While it works to invent a distinct name and let @@ -365,13 +295,13 @@ public: */ LLSD wait() { - return ::waitForEventOn(mPump); + return llcoro::waitForEventOn(mPump); } LLSD postAndWait(const LLSD& event, const LLEventPumpOrPumpName& requestPump, const LLSD& replyPumpNamePath=LLSD()) { - return ::postAndWait(event, requestPump, mPump, replyPumpNamePath); + return llcoro::postAndWait(event, requestPump, mPump, replyPumpNamePath); } private: @@ -410,19 +340,19 @@ public: /// waitForEventOn(either of our two LLEventPumps) LLEventWithID wait() { - return waitForEventOn(mPump0, mPump1); + return llcoro::waitForEventOn(mPump0, mPump1); } /// errorException(wait()) LLSD waitWithException() { - return errorException(wait(), std::string("Error event on ") + getName1()); + return llcoro::errorException(wait(), std::string("Error event on ") + getName1()); } /// errorLog(wait()) LLSD waitWithLog() { - return errorLog(wait(), std::string("Error event on ") + getName1()); + return llcoro::errorLog(wait(), std::string("Error event on ") + getName1()); } LLEventWithID postAndWait(const LLSD& event, @@ -430,8 +360,8 @@ public: const LLSD& replyPump0NamePath=LLSD(), const LLSD& replyPump1NamePath=LLSD()) { - return postAndWait2(event, requestPump, mPump0, mPump1, - replyPump0NamePath, replyPump1NamePath); + return llcoro::postAndWait2(event, requestPump, mPump0, mPump1, + replyPump0NamePath, replyPump1NamePath); } LLSD postAndWaitWithException(const LLSD& event, @@ -439,9 +369,9 @@ public: const LLSD& replyPump0NamePath=LLSD(), const LLSD& replyPump1NamePath=LLSD()) { - return errorException(postAndWait(event, requestPump, - replyPump0NamePath, replyPump1NamePath), - std::string("Error event on ") + getName1()); + return llcoro::errorException(postAndWait(event, requestPump, + replyPump0NamePath, replyPump1NamePath), + std::string("Error event on ") + getName1()); } LLSD postAndWaitWithLog(const LLSD& event, @@ -449,9 +379,9 @@ public: const LLSD& replyPump0NamePath=LLSD(), const LLSD& replyPump1NamePath=LLSD()) { - return errorLog(postAndWait(event, requestPump, - replyPump0NamePath, replyPump1NamePath), - std::string("Error event on ") + getName1()); + return llcoro::errorLog(postAndWait(event, requestPump, + replyPump0NamePath, replyPump1NamePath), + std::string("Error event on ") + getName1()); } private: diff --git a/indra/llcommon/tests/lleventcoro_test.cpp b/indra/llcommon/tests/lleventcoro_test.cpp index da927038ab..79bcfe58ed 100755 --- a/indra/llcommon/tests/lleventcoro_test.cpp +++ b/indra/llcommon/tests/lleventcoro_test.cpp @@ -86,6 +86,8 @@ #include "lleventcoro.h" #include "../test/debug.h" +using namespace llcoro; + /***************************************************************************** * from the banana.cpp example program borrowed for test<1>() *****************************************************************************/ @@ -259,8 +261,7 @@ namespace tut // Construct the coroutine instance that will run explicit_wait. // Pass the ctor a callable that accepts the coroutine_type::self // param passed by the library. - boost::dcoroutines::coroutine - coro(explicit_wait); + boost::dcoroutines::coroutine coro(explicit_wait); // Start the coroutine coro(std::nothrow); // When the coroutine waits for the event pump, it returns here. diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index ac1c2f8e58..cd3c527241 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -596,7 +596,7 @@ LLSD HttpCoroutineAdapter::postAndYield_(LLCore::HttpRequest::ptr_t &request, } saveState(hhandle, request, handler); - LLSD results = waitForEventOn(handler->getReplyPump()); + LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); cleanState(); return results; @@ -697,7 +697,7 @@ LLSD HttpCoroutineAdapter::postAndYield_(LLCore::HttpRequest::ptr_t &request, } saveState(hhandle, request, handler); - LLSD results = waitForEventOn(handler->getReplyPump()); + LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; @@ -735,7 +735,7 @@ LLSD HttpCoroutineAdapter::putAndYield_(LLCore::HttpRequest::ptr_t &request, } saveState(hhandle, request, handler); - LLSD results = waitForEventOn(handler->getReplyPump()); + LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; @@ -790,7 +790,7 @@ LLSD HttpCoroutineAdapter::getAndYield_(LLCore::HttpRequest::ptr_t &request, } saveState(hhandle, request, handler); - LLSD results = waitForEventOn(handler->getReplyPump()); + LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; @@ -825,7 +825,7 @@ LLSD HttpCoroutineAdapter::deleteAndYield_(LLCore::HttpRequest::ptr_t &request, } saveState(hhandle, request, handler); - LLSD results = waitForEventOn(handler->getReplyPump()); + LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; diff --git a/indra/newview/llcoproceduremanager.cpp b/indra/newview/llcoproceduremanager.cpp index 1a4a906f35..d3168985f8 100644 --- a/indra/newview/llcoproceduremanager.cpp +++ b/indra/newview/llcoproceduremanager.cpp @@ -138,7 +138,7 @@ void LLCoprocedureManager::coprocedureInvokerCoro(LLCoreHttpUtil::HttpCoroutineA while (!mShutdown) { - waitForEventOn(mWakeupTrigger); + llcoro::waitForEventOn(mWakeupTrigger); if (mShutdown) break; diff --git a/indra/newview/lleventpoll.cpp b/indra/newview/lleventpoll.cpp index 54da226209..0aad1d5ba9 100755 --- a/indra/newview/lleventpoll.cpp +++ b/indra/newview/lleventpoll.cpp @@ -197,7 +197,7 @@ namespace Details " seconds, error count is now " << errorCount << LL_ENDL; timeout.eventAfter(waitToRetry, LLSD()); - waitForEventOn(timeout); + llcoro::waitForEventOn(timeout); if (mDone) break; diff --git a/indra/viewer_components/login/lllogin.cpp b/indra/viewer_components/login/lllogin.cpp index 0569e9f3e8..88415ff11a 100755 --- a/indra/viewer_components/login/lllogin.cpp +++ b/indra/viewer_components/login/lllogin.cpp @@ -175,7 +175,7 @@ void LLLogin::Impl::login_(std::string uri, LLSD login_params) request["op"] = "rewriteURI"; request["uri"] = uri; request["reply"] = replyPump.getName(); - rewrittenURIs = postAndWait(request, srv_pump_name, filter); + rewrittenURIs = llcoro::postAndWait(request, srv_pump_name, filter); // EXP-772: If rewrittenURIs fail, try original URI as a fallback. rewrittenURIs.append(uri); } // we no longer need the filter @@ -221,10 +221,10 @@ void LLLogin::Impl::login_(std::string uri, LLSD login_params) // returns. Subsequent responses, of course, must be awaited // without posting again. for (mAuthResponse = validateResponse(loginReplyPump.getName(), - postAndWait(request, xmlrpcPump, loginReplyPump, "reply")); + llcoro::postAndWait(request, xmlrpcPump, loginReplyPump, "reply")); mAuthResponse["status"].asString() == "Downloading"; mAuthResponse = validateResponse(loginReplyPump.getName(), - waitForEventOn(loginReplyPump))) + llcoro::waitForEventOn(loginReplyPump))) { // Still Downloading -- send progress update. sendProgressEvent("offline", "downloading"); -- cgit v1.2.3 From f00cd0ab9fde7377e859942a66fc47649d854a1c Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 2 Jul 2015 14:39:12 -0700 Subject: Crash on second add to coproc queue. --- indra/newview/llfloaternamedesc.cpp | 15 +++ indra/newview/llviewermenufile.cpp | 203 +++++++++++++++++++++++++++++++++++- indra/newview/llviewermenufile.h | 109 ++++++++++++++----- 3 files changed, 300 insertions(+), 27 deletions(-) (limited to 'indra') diff --git a/indra/newview/llfloaternamedesc.cpp b/indra/newview/llfloaternamedesc.cpp index 0cca715fe2..4960ecf5fe 100755 --- a/indra/newview/llfloaternamedesc.cpp +++ b/indra/newview/llfloaternamedesc.cpp @@ -164,6 +164,19 @@ void LLFloaterNameDesc::onBtnOK( ) void *nruserdata = NULL; std::string display_name = LLStringUtil::null; + NewResourceUploadInfo::ptr_t uploadInfo(new NewFileResourceUploadInfo( + mFilenameAndPath, + getChild("name_form")->getValue().asString(), + getChild("description_form")->getValue().asString(), 0, + LLFolderType::FT_NONE, LLInventoryType::IT_NONE, + LLFloaterPerms::getNextOwnerPerms("Uploads"), + LLFloaterPerms::getGroupPerms("Uploads"), + LLFloaterPerms::getEveryonePerms("Uploads"), + expected_upload_cost)); + + upload_new_resource(uploadInfo, callback, nruserdata); + +#if 0 upload_new_resource(mFilenameAndPath, // file getChild("name_form")->getValue().asString(), getChild("description_form")->getValue().asString(), @@ -172,6 +185,8 @@ void LLFloaterNameDesc::onBtnOK( ) LLFloaterPerms::getGroupPerms("Uploads"), LLFloaterPerms::getEveryonePerms("Uploads"), display_name, callback, expected_upload_cost, nruserdata); +#endif + closeFloater(false); } diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index e9eb0e807a..8a95c2a6dd 100755 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -425,6 +425,34 @@ class LLFileUploadBulk : public view_listener_t LLFilePicker& picker = LLFilePicker::instance(); if (picker.getMultipleOpenFiles()) { + std::string filename = picker.getFirstFile(); + S32 expected_upload_cost = LLGlobalEconomy::Singleton::getInstance()->getPriceUpload(); + + while (!filename.empty()) + { + std::string name = gDirUtilp->getBaseFileName(filename, true); + + std::string asset_name = name; + LLStringUtil::replaceNonstandardASCII( asset_name, '?' ); + LLStringUtil::replaceChar(asset_name, '|', '?'); + LLStringUtil::stripNonprintable(asset_name); + LLStringUtil::trim(asset_name); + + NewResourceUploadInfo::ptr_t uploadInfo(new NewFileResourceUploadInfo( + filename, + asset_name, + asset_name, 0, + LLFolderType::FT_NONE, LLInventoryType::IT_NONE, + LLFloaterPerms::getNextOwnerPerms("Uploads"), + LLFloaterPerms::getGroupPerms("Uploads"), + LLFloaterPerms::getEveryonePerms("Uploads"), + expected_upload_cost)); + + upload_new_resource(uploadInfo, NULL, NULL); + + filename = picker.getNextFile(); + } +#if 0 const std::string& filename = picker.getFirstFile(); std::string name = gDirUtilp->getBaseFileName(filename, true); @@ -456,6 +484,7 @@ class LLFileUploadBulk : public view_listener_t // *NOTE: Ew, we don't iterate over the file list here, // we handle the next files in upload_done_callback() +#endif } else { @@ -640,6 +669,18 @@ LLUUID upload_new_resource( S32 expected_upload_cost, void *userdata) { + + NewResourceUploadInfo::ptr_t uploadInfo(new NewFileResourceUploadInfo( + src_filename, + name, desc, compression_info, + destination_folder_type, inv_type, + next_owner_perms, group_perms, everyone_perms, + expected_upload_cost)); + upload_new_resource(uploadInfo, callback, userdata); + + return LLUUID::null; + +#if 0 // Generate the temporary UUID. std::string filename = gDirUtilp->getTempFilename(); LLTransactionID tid; @@ -782,6 +823,7 @@ LLUUID upload_new_resource( } return uuid; +#endif } void upload_done_callback( @@ -1009,7 +1051,8 @@ void init_menu_file() LLSD NewResourceUploadInfo::prepareUpload() { - generateNewAssetId(); + if (mAssetId.isNull()) + generateNewAssetId(); incrementUploadStats(); assignDefaults(); @@ -1192,3 +1235,161 @@ std::string NewResourceUploadInfo::getDisplayName() const { return (mName.empty()) ? mAssetId.asString() : mName; }; + + +NewFileResourceUploadInfo::NewFileResourceUploadInfo( + std::string fileName, + std::string name, + std::string description, + S32 compressionInfo, + LLFolderType::EType destinationType, + LLInventoryType::EType inventoryType, + U32 nextOWnerPerms, + U32 groupPerms, + U32 everyonePerms, + S32 expectedCost): + NewResourceUploadInfo(name, description, compressionInfo, + destinationType, inventoryType, + nextOWnerPerms, groupPerms, everyonePerms, expectedCost), + mFileName(fileName) +{ + LLTransactionID tid; + setTransactionId(tid); +} + + + +LLSD NewFileResourceUploadInfo::prepareUpload() +{ + generateNewAssetId(); + + LLSD result = exportTempFile(); + if (result.has("error")) + return result; + + return NewResourceUploadInfo::prepareUpload(); +} + +LLSD NewFileResourceUploadInfo::exportTempFile() +{ + std::string filename = gDirUtilp->getTempFilename(); + + std::string exten = gDirUtilp->getExtension(getFileName()); + U32 codec = LLImageBase::getCodecFromExtension(exten); + + LLAssetType::EType assetType = LLAssetType::AT_NONE; + std::string errorMessage; + std::string errorLabel; + + bool error = false; + + if (exten.empty()) + { + std::string shortName = gDirUtilp->getBaseFileName(filename); + + // No extension + errorMessage = llformat( + "No file extension for the file: '%s'\nPlease make sure the file has a correct file extension", + shortName.c_str()); + errorLabel = "NoFileExtension"; + error = true; + } + else if (codec != IMG_CODEC_INVALID) + { + // It's an image file, the upload procedure is the same for all + assetType = LLAssetType::AT_TEXTURE; + if (!LLViewerTextureList::createUploadFile(getFileName(), filename, codec)) + { + errorMessage = llformat("Problem with file %s:\n\n%s\n", + getFileName().c_str(), LLImage::getLastError().c_str()); + errorLabel = "ProblemWithFile"; + error = true; + } + } + else if (exten == "wav") + { + assetType = LLAssetType::AT_SOUND; // tag it as audio + S32 encodeResult = 0; + + LL_INFOS() << "Attempting to encode wav as an ogg file" << LL_ENDL; + + encodeResult = encode_vorbis_file(getFileName(), filename); + + if (LLVORBISENC_NOERR != encodeResult) + { + switch (encodeResult) + { + case LLVORBISENC_DEST_OPEN_ERR: + errorMessage = llformat("Couldn't open temporary compressed sound file for writing: %s\n", filename.c_str()); + errorLabel = "CannotOpenTemporarySoundFile"; + break; + + default: + errorMessage = llformat("Unknown vorbis encode failure on: %s\n", getFileName().c_str()); + errorLabel = "UnknownVorbisEncodeFailure"; + break; + } + error = true; + } + } + else if (exten == "bvh") + { + errorMessage = llformat("We do not currently support bulk upload of animation files\n"); + errorLabel = "DoNotSupportBulkAnimationUpload"; + error = true; + } + else if (exten == "anim") + { + assetType = LLAssetType::AT_ANIMATION; + filename = getFileName(); + } + else + { + // Unknown extension + errorMessage = llformat(LLTrans::getString("UnknownFileExtension").c_str(), exten.c_str()); + errorLabel = "ErrorMessage"; + error = TRUE;; + } + + if (error) + { + LLSD errorResult(LLSD::emptyMap()); + + errorResult["error"] = LLSD::Binary(true); + errorResult["message"] = errorMessage; + errorResult["label"] = errorLabel; + return errorResult; + } + + setAssetType(assetType); + + // copy this file into the vfs for upload + S32 file_size; + LLAPRFile infile; + infile.open(filename, LL_APR_RB, NULL, &file_size); + if (infile.getFileHandle()) + { + LLVFile file(gVFS, getAssetId(), assetType, LLVFile::WRITE); + + file.setMaxSize(file_size); + + const S32 buf_size = 65536; + U8 copy_buf[buf_size]; + while ((file_size = infile.read(copy_buf, buf_size))) + { + file.write(copy_buf, file_size); + } + } + else + { + errorMessage = llformat("Unable to access output file: %s", filename.c_str()); + LLSD errorResult(LLSD::emptyMap()); + + errorResult["error"] = LLSD::Binary(true); + errorResult["message"] = errorMessage; + return errorResult; + } + + return LLSD(); + +} diff --git a/indra/newview/llviewermenufile.h b/indra/newview/llviewermenufile.h index 9bc4d5b041..7ee5043777 100755 --- a/indra/newview/llviewermenufile.h +++ b/indra/newview/llviewermenufile.h @@ -45,31 +45,31 @@ public: typedef boost::shared_ptr ptr_t; NewResourceUploadInfo( - LLTransactionID transactId, - LLAssetType::EType assetType, - std::string name, - std::string description, - S32 compressionInfo, - LLFolderType::EType destinationType, - LLInventoryType::EType inventoryType, - U32 nextOWnerPerms, - U32 groupPerms, - U32 everyonePerms, - S32 expectedCost) : - mTransactionId(transactId), - mAssetType(assetType), - mName(name), - mDescription(description), - mCompressionInfo(compressionInfo), - mDestinationFolderType(destinationType), - mInventoryType(inventoryType), - mNextOwnerPerms(nextOWnerPerms), - mGroupPerms(groupPerms), - mEveryonePerms(everyonePerms), - mExpectedUploadCost(expectedCost), - mFolderId(LLUUID::null), - mItemId(LLUUID::null), - mAssetId(LLAssetID::null) + LLTransactionID transactId, + LLAssetType::EType assetType, + std::string name, + std::string description, + S32 compressionInfo, + LLFolderType::EType destinationType, + LLInventoryType::EType inventoryType, + U32 nextOWnerPerms, + U32 groupPerms, + U32 everyonePerms, + S32 expectedCost) : + mTransactionId(transactId), + mAssetType(assetType), + mName(name), + mDescription(description), + mCompressionInfo(compressionInfo), + mDestinationFolderType(destinationType), + mInventoryType(inventoryType), + mNextOwnerPerms(nextOWnerPerms), + mGroupPerms(groupPerms), + mEveryonePerms(everyonePerms), + mExpectedUploadCost(expectedCost), + mFolderId(LLUUID::null), + mItemId(LLUUID::null), + mAssetId(LLAssetID::null) { } virtual ~NewResourceUploadInfo() @@ -97,13 +97,42 @@ public: U32 getEveryonePerms() const { return mEveryonePerms; }; S32 getExpectedUploadCost() const { return mExpectedUploadCost; }; - std::string getDisplayName() const; + virtual std::string getDisplayName() const; LLUUID getFolderId() const { return mFolderId; } LLUUID getItemId() const { return mItemId; } LLAssetID getAssetId() const { return mAssetId; } protected: + NewResourceUploadInfo( + std::string name, + std::string description, + S32 compressionInfo, + LLFolderType::EType destinationType, + LLInventoryType::EType inventoryType, + U32 nextOWnerPerms, + U32 groupPerms, + U32 everyonePerms, + S32 expectedCost) : + mName(name), + mDescription(description), + mCompressionInfo(compressionInfo), + mDestinationFolderType(destinationType), + mInventoryType(inventoryType), + mNextOwnerPerms(nextOWnerPerms), + mGroupPerms(groupPerms), + mEveryonePerms(everyonePerms), + mExpectedUploadCost(expectedCost), + mTransactionId(), + mAssetType(LLAssetType::AT_NONE), + mFolderId(LLUUID::null), + mItemId(LLUUID::null), + mAssetId(LLAssetID::null) + { } + + void setTransactionId(LLTransactionID tid) { mTransactionId = tid; } + void setAssetType(LLAssetType::EType assetType) { mAssetType = assetType; } + LLAssetID generateNewAssetId(); void incrementUploadStats() const; virtual void assignDefaults(); @@ -126,6 +155,34 @@ private: LLAssetID mAssetId; }; +class NewFileResourceUploadInfo : public NewResourceUploadInfo +{ +public: + NewFileResourceUploadInfo( + std::string fileName, + std::string name, + std::string description, + S32 compressionInfo, + LLFolderType::EType destinationType, + LLInventoryType::EType inventoryType, + U32 nextOWnerPerms, + U32 groupPerms, + U32 everyonePerms, + S32 expectedCost); + + virtual LLSD prepareUpload(); + + std::string getFileName() const { return mFileName; }; + +protected: + + virtual LLSD exportTempFile(); + +private: + std::string mFileName; + +}; + LLUUID upload_new_resource( const std::string& src_filename, -- cgit v1.2.3 From d28c7dd7f6a0c2ab2b95169b9d140c5cf4c4c72b Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 2 Jul 2015 15:02:40 -0700 Subject: Forgot to set a Transaction ID --- indra/newview/llviewermenufile.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'indra') diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index 8a95c2a6dd..3160b4b3a6 100755 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -1254,6 +1254,7 @@ NewFileResourceUploadInfo::NewFileResourceUploadInfo( mFileName(fileName) { LLTransactionID tid; + tid.generate(); setTransactionId(tid); } -- cgit v1.2.3 From 6ccd8bb6120be90eccb4e4b482132ed4fc3695af Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 2 Jul 2015 16:54:19 -0700 Subject: Temp disable llavatarnamecache integration test for linux --- indra/llmessage/CMakeLists.txt | 2 +- indra/newview/llviewermenufile.cpp | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'indra') diff --git a/indra/llmessage/CMakeLists.txt b/indra/llmessage/CMakeLists.txt index ba6e9d3939..fc51d147a6 100755 --- a/indra/llmessage/CMakeLists.txt +++ b/indra/llmessage/CMakeLists.txt @@ -261,7 +261,7 @@ if (LL_TESTS) ${GOOGLEMOCK_LIBRARIES} ) - LL_ADD_INTEGRATION_TEST(llavatarnamecache "" "${test_libs}") + #LL_ADD_INTEGRATION_TEST(llavatarnamecache "" "${test_libs}") LL_ADD_INTEGRATION_TEST(llhost "" "${test_libs}") LL_ADD_INTEGRATION_TEST(llpartdata "" "${test_libs}") LL_ADD_INTEGRATION_TEST(llxfer_file "" "${test_libs}") diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index 3160b4b3a6..20fbfaf71a 100755 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -413,7 +413,6 @@ class LLFileUploadBulk : public view_listener_t } // TODO: - // Iterate over all files // Check extensions for uploadability, cost // Check user balance for entire cost // Charge user entire cost -- cgit v1.2.3 From d34476359e59a1902b1498fbed94daca3d20bff1 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Fri, 3 Jul 2015 09:57:02 -0400 Subject: MAINT-5357: Extract LLErrorEvent to global namespace. This exception class got inadvertently swept up into the llcoro namespace. Its LLClassConvention name is intended for use in the global namespace. As there are no current references, this is a trivial change. --- indra/llcommon/lleventcoro.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'indra') diff --git a/indra/llcommon/lleventcoro.h b/indra/llcommon/lleventcoro.h index 2a60f2b1e0..f1c5dc2fde 100755 --- a/indra/llcommon/lleventcoro.h +++ b/indra/llcommon/lleventcoro.h @@ -236,6 +236,8 @@ waitForEventOn(const LLEventPumpOrPumpName& pump0, const LLEventPumpOrPumpName& */ LLSD errorException(const LLEventWithID& result, const std::string& desc); +} // namespace llcoro + /** * Exception thrown by errorException(). We don't call this LLEventError * because it's not an error in event processing: rather, this exception @@ -256,6 +258,9 @@ private: LLSD mData; }; +namespace llcoro +{ + /** * Like errorException(), save that this trips a fatal error using LL_ERRS * rather than throwing an exception. -- cgit v1.2.3 From 99aa00293b1d79eb47cfe2caa85a5740a2959297 Mon Sep 17 00:00:00 2001 From: rider Date: Fri, 3 Jul 2015 09:39:18 -0700 Subject: Remove ambiguous assignment. --- indra/newview/llviewerassetupload.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra') diff --git a/indra/newview/llviewerassetupload.cpp b/indra/newview/llviewerassetupload.cpp index cd4e7c33ef..717b14bb72 100644 --- a/indra/newview/llviewerassetupload.cpp +++ b/indra/newview/llviewerassetupload.cpp @@ -163,12 +163,12 @@ void LLViewerAssetUpload::HandleUploadError(LLCore::HttpStatus status, LLSD &res if (result.has("label")) { - label = result["label"]; + label = result["label"].asString(); } if (result.has("message")) { - reason = result["message"]; + reason = result["message"].asString(); } else { -- cgit v1.2.3 From 1d2514956f15f780aaead9bc123c1353a5b7fd20 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Sat, 4 Jul 2015 19:58:03 -0400 Subject: MAINT-5357: Add llcoro::yield() function to yield for one frame. --- indra/llcommon/lleventcoro.cpp | 8 ++++++++ indra/llcommon/lleventcoro.h | 7 +++++++ 2 files changed, 15 insertions(+) (limited to 'indra') diff --git a/indra/llcommon/lleventcoro.cpp b/indra/llcommon/lleventcoro.cpp index b7e7edec5a..ad02e139b8 100755 --- a/indra/llcommon/lleventcoro.cpp +++ b/indra/llcommon/lleventcoro.cpp @@ -145,6 +145,14 @@ void storeToLLSDPath(LLSD& dest, const LLSD& rawPath, const LLSD& value) } // anonymous +void llcoro::yield() +{ + // By viewer convention, we post an event on the "mainloop" LLEventPump + // each iteration of the main event-handling loop. So waiting for a single + // event on "mainloop" gives us a one-frame yield. + waitForEventOn("mainloop"); +} + LLSD llcoro::postAndWait(const LLSD& event, const LLEventPumpOrPumpName& requestPump, const LLEventPumpOrPumpName& replyPump, const LLSD& replyPumpNamePath) { diff --git a/indra/llcommon/lleventcoro.h b/indra/llcommon/lleventcoro.h index f1c5dc2fde..e2ce4bb193 100755 --- a/indra/llcommon/lleventcoro.h +++ b/indra/llcommon/lleventcoro.h @@ -101,6 +101,13 @@ VoidListener voidlistener(const LISTENER& listener) return VoidListener(listener); } +/** + * Yield control from a coroutine for one "mainloop" tick. If your coroutine + * runs without suspending for nontrivial time, sprinkle in calls to this + * function to avoid stalling the rest of the viewer processing. + */ +void yield(); + /** * Post specified LLSD event on the specified LLEventPump, then wait for a * response on specified other LLEventPump. This is more than mere -- cgit v1.2.3 From 8487a19df1df6e9c279358a8694a729511f6dd85 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 6 Jul 2015 09:51:05 -0700 Subject: Force Boost result_of to use TR1 for tests. --- indra/llcommon/tests/lleventcoro_test.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indra') diff --git a/indra/llcommon/tests/lleventcoro_test.cpp b/indra/llcommon/tests/lleventcoro_test.cpp index 79bcfe58ed..807577a637 100755 --- a/indra/llcommon/tests/lleventcoro_test.cpp +++ b/indra/llcommon/tests/lleventcoro_test.cpp @@ -64,12 +64,14 @@ // Boost.Coroutine #include is the *first* #include of the platform header. // That means that client code must generally #include Boost.Coroutine headers // before anything else. +#define BOOST_RESULT_OF_USE_TR1 1 #include // Normally, lleventcoro.h obviates future.hpp. We only include this because // we implement a "by hand" test of future functionality. #include #include #include +#include #include "linden_common.h" -- cgit v1.2.3 From 0b9a641b17be2a22e2a274ce6ab18a84612454af Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 6 Jul 2015 15:05:27 -0700 Subject: Force Boost use of TR1 for result_of in tests --- indra/llcommon/tests/lleventcoro_test.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'indra') diff --git a/indra/llcommon/tests/lleventcoro_test.cpp b/indra/llcommon/tests/lleventcoro_test.cpp index 79bcfe58ed..9e2bc0acee 100755 --- a/indra/llcommon/tests/lleventcoro_test.cpp +++ b/indra/llcommon/tests/lleventcoro_test.cpp @@ -59,6 +59,7 @@ // http://www.boost.org/LICENSE_1_0.txt) /*****************************************************************************/ +#define BOOST_RESULT_OF_USE_TR1 1 // On some platforms, Boost.Coroutine must #define magic symbols before // #including platform-API headers. Naturally, that's ineffective unless the // Boost.Coroutine #include is the *first* #include of the platform header. -- cgit v1.2.3 From 5a8580f7cb8976b2305a9fd7de7fe3b568e71b94 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 7 Jul 2015 10:09:55 -0700 Subject: Clean up viewrmenufile into viewrassetuplod --- indra/newview/llviewerassetupload.cpp | 351 ++++++++++++++++++++++- indra/newview/llviewerassetupload.h | 142 ++++++++- indra/newview/llviewermenufile.cpp | 524 ---------------------------------- indra/newview/llviewermenufile.h | 146 +--------- 4 files changed, 493 insertions(+), 670 deletions(-) (limited to 'indra') diff --git a/indra/newview/llviewerassetupload.cpp b/indra/newview/llviewerassetupload.cpp index 717b14bb72..1730523d8e 100644 --- a/indra/newview/llviewerassetupload.cpp +++ b/indra/newview/llviewerassetupload.cpp @@ -28,7 +28,6 @@ #include "llviewerprecompiledheaders.h" #include "linden_common.h" -#include "llviewerassetupload.h" #include "llviewertexturelist.h" #include "llimage.h" #include "lltrans.h" @@ -43,6 +42,356 @@ #include "llstatusbar.h" #include "llinventorypanel.h" #include "llsdutil.h" +#include "llviewerassetupload.h" +#include "llappviewer.h" +#include "llviewerstats.h" +#include "llvfile.h" + +LLSD NewResourceUploadInfo::prepareUpload() +{ + if (mAssetId.isNull()) + generateNewAssetId(); + + incrementUploadStats(); + assignDefaults(); + + return LLSD().with("success", LLSD::Boolean(true)); +} + +std::string NewResourceUploadInfo::getAssetTypeString() const +{ + return LLAssetType::lookup(mAssetType); +} + +std::string NewResourceUploadInfo::getInventoryTypeString() const +{ + return LLInventoryType::lookup(mInventoryType); +} + +LLSD NewResourceUploadInfo::generatePostBody() +{ + LLSD body; + + body["folder_id"] = mFolderId; + body["asset_type"] = getAssetTypeString(); + body["inventory_type"] = getInventoryTypeString(); + body["name"] = mName; + body["description"] = mDescription; + body["next_owner_mask"] = LLSD::Integer(mNextOwnerPerms); + body["group_mask"] = LLSD::Integer(mGroupPerms); + body["everyone_mask"] = LLSD::Integer(mEveryonePerms); + + return body; + +} + +void NewResourceUploadInfo::logPreparedUpload() +{ + LL_INFOS() << "*** Uploading: " << std::endl << + "Type: " << LLAssetType::lookup(mAssetType) << std::endl << + "UUID: " << mAssetId.asString() << std::endl << + "Name: " << mName << std::endl << + "Desc: " << mDescription << std::endl << + "Expected Upload Cost: " << mExpectedUploadCost << std::endl << + "Folder: " << mFolderId << std::endl << + "Asset Type: " << LLAssetType::lookup(mAssetType) << LL_ENDL; +} + +LLUUID NewResourceUploadInfo::finishUpload(LLSD &result) +{ + if (getFolderId().isNull()) + { + return LLUUID::null; + } + + U32 permsEveryone = PERM_NONE; + U32 permsGroup = PERM_NONE; + U32 permsNextOwner = PERM_ALL; + + if (result.has("new_next_owner_mask")) + { + // The server provided creation perms so use them. + // Do not assume we got the perms we asked for in + // since the server may not have granted them all. + permsEveryone = result["new_everyone_mask"].asInteger(); + permsGroup = result["new_group_mask"].asInteger(); + permsNextOwner = result["new_next_owner_mask"].asInteger(); + } + else + { + // The server doesn't provide creation perms + // so use old assumption-based perms. + if (getAssetTypeString() != "snapshot") + { + permsNextOwner = PERM_MOVE | PERM_TRANSFER; + } + } + + LLPermissions new_perms; + new_perms.init( + gAgent.getID(), + gAgent.getID(), + LLUUID::null, + LLUUID::null); + + new_perms.initMasks( + PERM_ALL, + PERM_ALL, + permsEveryone, + permsGroup, + permsNextOwner); + + U32 flagsInventoryItem = 0; + if (result.has("inventory_flags")) + { + flagsInventoryItem = static_cast(result["inventory_flags"].asInteger()); + if (flagsInventoryItem != 0) + { + LL_INFOS() << "inventory_item_flags " << flagsInventoryItem << LL_ENDL; + } + } + S32 creationDate = time_corrected(); + + LLUUID serverInventoryItem = result["new_inventory_item"].asUUID(); + LLUUID serverAssetId = result["new_asset"].asUUID(); + + LLPointer item = new LLViewerInventoryItem( + serverInventoryItem, + getFolderId(), + new_perms, + serverAssetId, + getAssetType(), + getInventoryType(), + getName(), + getDescription(), + LLSaleInfo::DEFAULT, + flagsInventoryItem, + creationDate); + + gInventory.updateItem(item); + gInventory.notifyObservers(); + + return serverInventoryItem; +} + + +LLAssetID NewResourceUploadInfo::generateNewAssetId() +{ + if (gDisconnected) + { + LLAssetID rv; + + rv.setNull(); + return rv; + } + mAssetId = mTransactionId.makeAssetID(gAgent.getSecureSessionID()); + + return mAssetId; +} + +void NewResourceUploadInfo::incrementUploadStats() const +{ + if (LLAssetType::AT_SOUND == mAssetType) + { + add(LLStatViewer::UPLOAD_SOUND, 1); + } + else if (LLAssetType::AT_TEXTURE == mAssetType) + { + add(LLStatViewer::UPLOAD_TEXTURE, 1); + } + else if (LLAssetType::AT_ANIMATION == mAssetType) + { + add(LLStatViewer::ANIMATION_UPLOADS, 1); + } +} + +void NewResourceUploadInfo::assignDefaults() +{ + if (LLInventoryType::IT_NONE == mInventoryType) + { + mInventoryType = LLInventoryType::defaultForAssetType(mAssetType); + } + LLStringUtil::stripNonprintable(mName); + LLStringUtil::stripNonprintable(mDescription); + + if (mName.empty()) + { + mName = "(No Name)"; + } + if (mDescription.empty()) + { + mDescription = "(No Description)"; + } + + mFolderId = gInventory.findCategoryUUIDForType( + (mDestinationFolderType == LLFolderType::FT_NONE) ? + (LLFolderType::EType)mAssetType : mDestinationFolderType); + +} + +std::string NewResourceUploadInfo::getDisplayName() const +{ + return (mName.empty()) ? mAssetId.asString() : mName; +}; + +//========================================================================= +NewFileResourceUploadInfo::NewFileResourceUploadInfo( + std::string fileName, + std::string name, + std::string description, + S32 compressionInfo, + LLFolderType::EType destinationType, + LLInventoryType::EType inventoryType, + U32 nextOWnerPerms, + U32 groupPerms, + U32 everyonePerms, + S32 expectedCost) : + NewResourceUploadInfo(name, description, compressionInfo, + destinationType, inventoryType, + nextOWnerPerms, groupPerms, everyonePerms, expectedCost), + mFileName(fileName) +{ + LLTransactionID tid; + tid.generate(); + setTransactionId(tid); +} + + + +LLSD NewFileResourceUploadInfo::prepareUpload() +{ + generateNewAssetId(); + + LLSD result = exportTempFile(); + if (result.has("error")) + return result; + + return NewResourceUploadInfo::prepareUpload(); +} + +LLSD NewFileResourceUploadInfo::exportTempFile() +{ + std::string filename = gDirUtilp->getTempFilename(); + + std::string exten = gDirUtilp->getExtension(getFileName()); + U32 codec = LLImageBase::getCodecFromExtension(exten); + + LLAssetType::EType assetType = LLAssetType::AT_NONE; + std::string errorMessage; + std::string errorLabel; + + bool error = false; + + if (exten.empty()) + { + std::string shortName = gDirUtilp->getBaseFileName(filename); + + // No extension + errorMessage = llformat( + "No file extension for the file: '%s'\nPlease make sure the file has a correct file extension", + shortName.c_str()); + errorLabel = "NoFileExtension"; + error = true; + } + else if (codec != IMG_CODEC_INVALID) + { + // It's an image file, the upload procedure is the same for all + assetType = LLAssetType::AT_TEXTURE; + if (!LLViewerTextureList::createUploadFile(getFileName(), filename, codec)) + { + errorMessage = llformat("Problem with file %s:\n\n%s\n", + getFileName().c_str(), LLImage::getLastError().c_str()); + errorLabel = "ProblemWithFile"; + error = true; + } + } + else if (exten == "wav") + { + assetType = LLAssetType::AT_SOUND; // tag it as audio + S32 encodeResult = 0; + + LL_INFOS() << "Attempting to encode wav as an ogg file" << LL_ENDL; + + encodeResult = encode_vorbis_file(getFileName(), filename); + + if (LLVORBISENC_NOERR != encodeResult) + { + switch (encodeResult) + { + case LLVORBISENC_DEST_OPEN_ERR: + errorMessage = llformat("Couldn't open temporary compressed sound file for writing: %s\n", filename.c_str()); + errorLabel = "CannotOpenTemporarySoundFile"; + break; + + default: + errorMessage = llformat("Unknown vorbis encode failure on: %s\n", getFileName().c_str()); + errorLabel = "UnknownVorbisEncodeFailure"; + break; + } + error = true; + } + } + else if (exten == "bvh") + { + errorMessage = llformat("We do not currently support bulk upload of animation files\n"); + errorLabel = "DoNotSupportBulkAnimationUpload"; + error = true; + } + else if (exten == "anim") + { + assetType = LLAssetType::AT_ANIMATION; + filename = getFileName(); + } + else + { + // Unknown extension + errorMessage = llformat(LLTrans::getString("UnknownFileExtension").c_str(), exten.c_str()); + errorLabel = "ErrorMessage"; + error = TRUE;; + } + + if (error) + { + LLSD errorResult(LLSD::emptyMap()); + + errorResult["error"] = LLSD::Binary(true); + errorResult["message"] = errorMessage; + errorResult["label"] = errorLabel; + return errorResult; + } + + setAssetType(assetType); + + // copy this file into the vfs for upload + S32 file_size; + LLAPRFile infile; + infile.open(filename, LL_APR_RB, NULL, &file_size); + if (infile.getFileHandle()) + { + LLVFile file(gVFS, getAssetId(), assetType, LLVFile::WRITE); + + file.setMaxSize(file_size); + + const S32 buf_size = 65536; + U8 copy_buf[buf_size]; + while ((file_size = infile.read(copy_buf, buf_size))) + { + file.write(copy_buf, file_size); + } + } + else + { + errorMessage = llformat("Unable to access output file: %s", filename.c_str()); + LLSD errorResult(LLSD::emptyMap()); + + errorResult["error"] = LLSD::Binary(true); + errorResult["message"] = errorMessage; + return errorResult; + } + + return LLSD(); + +} //========================================================================= /*static*/ diff --git a/indra/newview/llviewerassetupload.h b/indra/newview/llviewerassetupload.h index 38167fc0c7..82cb8d1b85 100644 --- a/indra/newview/llviewerassetupload.h +++ b/indra/newview/llviewerassetupload.h @@ -35,7 +35,147 @@ #include "llcoros.h" #include "llcorehttputil.h" -#include "llviewermenufile.h" +class NewResourceUploadInfo +{ +public: + typedef boost::shared_ptr ptr_t; + + NewResourceUploadInfo( + LLTransactionID transactId, + LLAssetType::EType assetType, + std::string name, + std::string description, + S32 compressionInfo, + LLFolderType::EType destinationType, + LLInventoryType::EType inventoryType, + U32 nextOWnerPerms, + U32 groupPerms, + U32 everyonePerms, + S32 expectedCost) : + mTransactionId(transactId), + mAssetType(assetType), + mName(name), + mDescription(description), + mCompressionInfo(compressionInfo), + mDestinationFolderType(destinationType), + mInventoryType(inventoryType), + mNextOwnerPerms(nextOWnerPerms), + mGroupPerms(groupPerms), + mEveryonePerms(everyonePerms), + mExpectedUploadCost(expectedCost), + mFolderId(LLUUID::null), + mItemId(LLUUID::null), + mAssetId(LLAssetID::null) + { } + + virtual ~NewResourceUploadInfo() + { } + + virtual LLSD prepareUpload(); + virtual LLSD generatePostBody(); + virtual void logPreparedUpload(); + virtual LLUUID finishUpload(LLSD &result); + + LLTransactionID getTransactionId() const { return mTransactionId; } + LLAssetType::EType getAssetType() const { return mAssetType; } + std::string getAssetTypeString() const; + std::string getName() const { return mName; }; + std::string getDescription() const { return mDescription; }; + S32 getCompressionInfo() const { return mCompressionInfo; }; + LLFolderType::EType getDestinationFolderType() const { return mDestinationFolderType; }; + LLInventoryType::EType getInventoryType() const { return mInventoryType; }; + std::string getInventoryTypeString() const; + U32 getNextOwnerPerms() const { return mNextOwnerPerms; }; + U32 getGroupPerms() const { return mGroupPerms; }; + U32 getEveryonePerms() const { return mEveryonePerms; }; + S32 getExpectedUploadCost() const { return mExpectedUploadCost; }; + + virtual std::string getDisplayName() const; + + LLUUID getFolderId() const { return mFolderId; } + LLUUID getItemId() const { return mItemId; } + LLAssetID getAssetId() const { return mAssetId; } + +protected: + NewResourceUploadInfo( + std::string name, + std::string description, + S32 compressionInfo, + LLFolderType::EType destinationType, + LLInventoryType::EType inventoryType, + U32 nextOWnerPerms, + U32 groupPerms, + U32 everyonePerms, + S32 expectedCost) : + mName(name), + mDescription(description), + mCompressionInfo(compressionInfo), + mDestinationFolderType(destinationType), + mInventoryType(inventoryType), + mNextOwnerPerms(nextOWnerPerms), + mGroupPerms(groupPerms), + mEveryonePerms(everyonePerms), + mExpectedUploadCost(expectedCost), + mTransactionId(), + mAssetType(LLAssetType::AT_NONE), + mFolderId(LLUUID::null), + mItemId(LLUUID::null), + mAssetId(LLAssetID::null) + { } + + void setTransactionId(LLTransactionID tid) { mTransactionId = tid; } + void setAssetType(LLAssetType::EType assetType) { mAssetType = assetType; } + + LLAssetID generateNewAssetId(); + void incrementUploadStats() const; + virtual void assignDefaults(); + +private: + LLTransactionID mTransactionId; + LLAssetType::EType mAssetType; + std::string mName; + std::string mDescription; + S32 mCompressionInfo; + LLFolderType::EType mDestinationFolderType; + LLInventoryType::EType mInventoryType; + U32 mNextOwnerPerms; + U32 mGroupPerms; + U32 mEveryonePerms; + S32 mExpectedUploadCost; + + LLUUID mFolderId; + LLUUID mItemId; + LLAssetID mAssetId; +}; + +class NewFileResourceUploadInfo : public NewResourceUploadInfo +{ +public: + NewFileResourceUploadInfo( + std::string fileName, + std::string name, + std::string description, + S32 compressionInfo, + LLFolderType::EType destinationType, + LLInventoryType::EType inventoryType, + U32 nextOWnerPerms, + U32 groupPerms, + U32 everyonePerms, + S32 expectedCost); + + virtual LLSD prepareUpload(); + + std::string getFileName() const { return mFileName; }; + +protected: + + virtual LLSD exportTempFile(); + +private: + std::string mFileName; + +}; + class LLViewerAssetUpload { diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index 20fbfaf71a..9c4045fa1e 100755 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -451,39 +451,6 @@ class LLFileUploadBulk : public view_listener_t filename = picker.getNextFile(); } -#if 0 - const std::string& filename = picker.getFirstFile(); - std::string name = gDirUtilp->getBaseFileName(filename, true); - - std::string asset_name = name; - LLStringUtil::replaceNonstandardASCII( asset_name, '?' ); - LLStringUtil::replaceChar(asset_name, '|', '?'); - LLStringUtil::stripNonprintable(asset_name); - LLStringUtil::trim(asset_name); - - std::string display_name = LLStringUtil::null; - LLAssetStorage::LLStoreAssetCallback callback = NULL; - S32 expected_upload_cost = LLGlobalEconomy::Singleton::getInstance()->getPriceUpload(); - void *userdata = NULL; - - upload_new_resource( - filename, - asset_name, - asset_name, - 0, - LLFolderType::FT_NONE, - LLInventoryType::IT_NONE, - LLFloaterPerms::getNextOwnerPerms("Uploads"), - LLFloaterPerms::getGroupPerms("Uploads"), - LLFloaterPerms::getEveryonePerms("Uploads"), - display_name, - callback, - expected_upload_cost, - userdata); - - // *NOTE: Ew, we don't iterate over the file list here, - // we handle the next files in upload_done_callback() -#endif } else { @@ -678,151 +645,6 @@ LLUUID upload_new_resource( upload_new_resource(uploadInfo, callback, userdata); return LLUUID::null; - -#if 0 - // Generate the temporary UUID. - std::string filename = gDirUtilp->getTempFilename(); - LLTransactionID tid; - LLAssetID uuid; - - LLSD args; - - std::string exten = gDirUtilp->getExtension(src_filename); - U32 codec = LLImageBase::getCodecFromExtension(exten); - LLAssetType::EType asset_type = LLAssetType::AT_NONE; - std::string error_message; - - BOOL error = FALSE; - - if (exten.empty()) - { - std::string short_name = gDirUtilp->getBaseFileName(filename); - - // No extension - error_message = llformat( - "No file extension for the file: '%s'\nPlease make sure the file has a correct file extension", - short_name.c_str()); - args["FILE"] = short_name; - upload_error(error_message, "NoFileExtension", filename, args); - return LLUUID(); - } - else if (codec != IMG_CODEC_INVALID) - { - // It's an image file, the upload procedure is the same for all - asset_type = LLAssetType::AT_TEXTURE; - if (!LLViewerTextureList::createUploadFile(src_filename, filename, codec )) - { - error_message = llformat( "Problem with file %s:\n\n%s\n", - src_filename.c_str(), LLImage::getLastError().c_str()); - args["FILE"] = src_filename; - args["ERROR"] = LLImage::getLastError(); - upload_error(error_message, "ProblemWithFile", filename, args); - return LLUUID(); - } - } - else if(exten == "wav") - { - asset_type = LLAssetType::AT_SOUND; // tag it as audio - S32 encode_result = 0; - - LL_INFOS() << "Attempting to encode wav as an ogg file" << LL_ENDL; - - encode_result = encode_vorbis_file(src_filename, filename); - - if (LLVORBISENC_NOERR != encode_result) - { - switch(encode_result) - { - case LLVORBISENC_DEST_OPEN_ERR: - error_message = llformat( "Couldn't open temporary compressed sound file for writing: %s\n", filename.c_str()); - args["FILE"] = filename; - upload_error(error_message, "CannotOpenTemporarySoundFile", filename, args); - break; - - default: - error_message = llformat("Unknown vorbis encode failure on: %s\n", src_filename.c_str()); - args["FILE"] = src_filename; - upload_error(error_message, "UnknownVorbisEncodeFailure", filename, args); - break; - } - return LLUUID(); - } - } - else if (exten == "bvh") - { - error_message = llformat("We do not currently support bulk upload of animation files\n"); - upload_error(error_message, "DoNotSupportBulkAnimationUpload", filename, args); - return LLUUID(); - } - else if (exten == "anim") - { - asset_type = LLAssetType::AT_ANIMATION; - filename = src_filename; - } - else - { - // Unknown extension - error_message = llformat(LLTrans::getString("UnknownFileExtension").c_str(), exten.c_str()); - error = TRUE;; - } - - // gen a new transaction ID for this asset - tid.generate(); - - if (!error) - { - uuid = tid.makeAssetID(gAgent.getSecureSessionID()); - // copy this file into the vfs for upload - S32 file_size; - LLAPRFile infile ; - infile.open(filename, LL_APR_RB, NULL, &file_size); - if (infile.getFileHandle()) - { - LLVFile file(gVFS, uuid, asset_type, LLVFile::WRITE); - - file.setMaxSize(file_size); - - const S32 buf_size = 65536; - U8 copy_buf[buf_size]; - while ((file_size = infile.read(copy_buf, buf_size))) - { - file.write(copy_buf, file_size); - } - } - else - { - error_message = llformat( "Unable to access output file: %s", filename.c_str()); - error = TRUE; - } - } - - if (!error) - { - NewResourceUploadInfo::ptr_t uploadInfo(new NewResourceUploadInfo( - tid, asset_type, - name, desc, compression_info, - destination_folder_type, inv_type, - next_owner_perms, group_perms, everyone_perms, - expected_upload_cost)); - - upload_new_resource(uploadInfo, - callback, userdata); - } - else - { - LL_WARNS() << error_message << LL_ENDL; - LLSD args; - args["ERROR_MESSAGE"] = error_message; - LLNotificationsUtil::add("ErrorMessage", args); - if(LLFile::remove(filename) == -1) - { - LL_DEBUGS() << "unable to remove temp file" << LL_ENDL; - } - LLFilePicker::instance().reset(); - } - - return uuid; -#endif } void upload_done_callback( @@ -1047,349 +869,3 @@ void init_menu_file() // "File.SaveTexture" moved to llpanelmaininventory so that it can be properly handled. } - -LLSD NewResourceUploadInfo::prepareUpload() -{ - if (mAssetId.isNull()) - generateNewAssetId(); - - incrementUploadStats(); - assignDefaults(); - - return LLSD().with("success", LLSD::Boolean(true)); -} - -std::string NewResourceUploadInfo::getAssetTypeString() const -{ - return LLAssetType::lookup(mAssetType); -} - -std::string NewResourceUploadInfo::getInventoryTypeString() const -{ - return LLInventoryType::lookup(mInventoryType); -} - -LLSD NewResourceUploadInfo::generatePostBody() -{ - LLSD body; - - body["folder_id"] = mFolderId; - body["asset_type"] = getAssetTypeString(); - body["inventory_type"] = getInventoryTypeString(); - body["name"] = mName; - body["description"] = mDescription; - body["next_owner_mask"] = LLSD::Integer(mNextOwnerPerms); - body["group_mask"] = LLSD::Integer(mGroupPerms); - body["everyone_mask"] = LLSD::Integer(mEveryonePerms); - - return body; - -} - -void NewResourceUploadInfo::logPreparedUpload() -{ - LL_INFOS() << "*** Uploading: " << std::endl << - "Type: " << LLAssetType::lookup(mAssetType) << std::endl << - "UUID: " << mAssetId.asString() << std::endl << - "Name: " << mName << std::endl << - "Desc: " << mDescription << std::endl << - "Expected Upload Cost: " << mExpectedUploadCost << std::endl << - "Folder: " << mFolderId << std::endl << - "Asset Type: " << LLAssetType::lookup(mAssetType) << LL_ENDL; -} - -LLUUID NewResourceUploadInfo::finishUpload(LLSD &result) -{ - if (getFolderId().isNull()) - { - return LLUUID::null; - } - - U32 permsEveryone = PERM_NONE; - U32 permsGroup = PERM_NONE; - U32 permsNextOwner = PERM_ALL; - - if (result.has("new_next_owner_mask")) - { - // The server provided creation perms so use them. - // Do not assume we got the perms we asked for in - // since the server may not have granted them all. - permsEveryone = result["new_everyone_mask"].asInteger(); - permsGroup = result["new_group_mask"].asInteger(); - permsNextOwner = result["new_next_owner_mask"].asInteger(); - } - else - { - // The server doesn't provide creation perms - // so use old assumption-based perms. - if (getAssetTypeString() != "snapshot") - { - permsNextOwner = PERM_MOVE | PERM_TRANSFER; - } - } - - LLPermissions new_perms; - new_perms.init( - gAgent.getID(), - gAgent.getID(), - LLUUID::null, - LLUUID::null); - - new_perms.initMasks( - PERM_ALL, - PERM_ALL, - permsEveryone, - permsGroup, - permsNextOwner); - - U32 flagsInventoryItem = 0; - if (result.has("inventory_flags")) - { - flagsInventoryItem = static_cast(result["inventory_flags"].asInteger()); - if (flagsInventoryItem != 0) - { - LL_INFOS() << "inventory_item_flags " << flagsInventoryItem << LL_ENDL; - } - } - S32 creationDate = time_corrected(); - - LLUUID serverInventoryItem = result["new_inventory_item"].asUUID(); - LLUUID serverAssetId = result["new_asset"].asUUID(); - - LLPointer item = new LLViewerInventoryItem( - serverInventoryItem, - getFolderId(), - new_perms, - serverAssetId, - getAssetType(), - getInventoryType(), - getName(), - getDescription(), - LLSaleInfo::DEFAULT, - flagsInventoryItem, - creationDate); - - gInventory.updateItem(item); - gInventory.notifyObservers(); - - return serverInventoryItem; -} - - -LLAssetID NewResourceUploadInfo::generateNewAssetId() -{ - if (gDisconnected) - { - LLAssetID rv; - - rv.setNull(); - return rv; - } - mAssetId = mTransactionId.makeAssetID(gAgent.getSecureSessionID()); - - return mAssetId; -} - -void NewResourceUploadInfo::incrementUploadStats() const -{ - if (LLAssetType::AT_SOUND == mAssetType) - { - add(LLStatViewer::UPLOAD_SOUND, 1); - } - else if (LLAssetType::AT_TEXTURE == mAssetType) - { - add(LLStatViewer::UPLOAD_TEXTURE, 1); - } - else if (LLAssetType::AT_ANIMATION == mAssetType) - { - add(LLStatViewer::ANIMATION_UPLOADS, 1); - } -} - -void NewResourceUploadInfo::assignDefaults() -{ - if (LLInventoryType::IT_NONE == mInventoryType) - { - mInventoryType = LLInventoryType::defaultForAssetType(mAssetType); - } - LLStringUtil::stripNonprintable(mName); - LLStringUtil::stripNonprintable(mDescription); - - if (mName.empty()) - { - mName = "(No Name)"; - } - if (mDescription.empty()) - { - mDescription = "(No Description)"; - } - - mFolderId = gInventory.findCategoryUUIDForType( - (mDestinationFolderType == LLFolderType::FT_NONE) ? - (LLFolderType::EType)mAssetType : mDestinationFolderType); - -} - -std::string NewResourceUploadInfo::getDisplayName() const -{ - return (mName.empty()) ? mAssetId.asString() : mName; -}; - - -NewFileResourceUploadInfo::NewFileResourceUploadInfo( - std::string fileName, - std::string name, - std::string description, - S32 compressionInfo, - LLFolderType::EType destinationType, - LLInventoryType::EType inventoryType, - U32 nextOWnerPerms, - U32 groupPerms, - U32 everyonePerms, - S32 expectedCost): - NewResourceUploadInfo(name, description, compressionInfo, - destinationType, inventoryType, - nextOWnerPerms, groupPerms, everyonePerms, expectedCost), - mFileName(fileName) -{ - LLTransactionID tid; - tid.generate(); - setTransactionId(tid); -} - - - -LLSD NewFileResourceUploadInfo::prepareUpload() -{ - generateNewAssetId(); - - LLSD result = exportTempFile(); - if (result.has("error")) - return result; - - return NewResourceUploadInfo::prepareUpload(); -} - -LLSD NewFileResourceUploadInfo::exportTempFile() -{ - std::string filename = gDirUtilp->getTempFilename(); - - std::string exten = gDirUtilp->getExtension(getFileName()); - U32 codec = LLImageBase::getCodecFromExtension(exten); - - LLAssetType::EType assetType = LLAssetType::AT_NONE; - std::string errorMessage; - std::string errorLabel; - - bool error = false; - - if (exten.empty()) - { - std::string shortName = gDirUtilp->getBaseFileName(filename); - - // No extension - errorMessage = llformat( - "No file extension for the file: '%s'\nPlease make sure the file has a correct file extension", - shortName.c_str()); - errorLabel = "NoFileExtension"; - error = true; - } - else if (codec != IMG_CODEC_INVALID) - { - // It's an image file, the upload procedure is the same for all - assetType = LLAssetType::AT_TEXTURE; - if (!LLViewerTextureList::createUploadFile(getFileName(), filename, codec)) - { - errorMessage = llformat("Problem with file %s:\n\n%s\n", - getFileName().c_str(), LLImage::getLastError().c_str()); - errorLabel = "ProblemWithFile"; - error = true; - } - } - else if (exten == "wav") - { - assetType = LLAssetType::AT_SOUND; // tag it as audio - S32 encodeResult = 0; - - LL_INFOS() << "Attempting to encode wav as an ogg file" << LL_ENDL; - - encodeResult = encode_vorbis_file(getFileName(), filename); - - if (LLVORBISENC_NOERR != encodeResult) - { - switch (encodeResult) - { - case LLVORBISENC_DEST_OPEN_ERR: - errorMessage = llformat("Couldn't open temporary compressed sound file for writing: %s\n", filename.c_str()); - errorLabel = "CannotOpenTemporarySoundFile"; - break; - - default: - errorMessage = llformat("Unknown vorbis encode failure on: %s\n", getFileName().c_str()); - errorLabel = "UnknownVorbisEncodeFailure"; - break; - } - error = true; - } - } - else if (exten == "bvh") - { - errorMessage = llformat("We do not currently support bulk upload of animation files\n"); - errorLabel = "DoNotSupportBulkAnimationUpload"; - error = true; - } - else if (exten == "anim") - { - assetType = LLAssetType::AT_ANIMATION; - filename = getFileName(); - } - else - { - // Unknown extension - errorMessage = llformat(LLTrans::getString("UnknownFileExtension").c_str(), exten.c_str()); - errorLabel = "ErrorMessage"; - error = TRUE;; - } - - if (error) - { - LLSD errorResult(LLSD::emptyMap()); - - errorResult["error"] = LLSD::Binary(true); - errorResult["message"] = errorMessage; - errorResult["label"] = errorLabel; - return errorResult; - } - - setAssetType(assetType); - - // copy this file into the vfs for upload - S32 file_size; - LLAPRFile infile; - infile.open(filename, LL_APR_RB, NULL, &file_size); - if (infile.getFileHandle()) - { - LLVFile file(gVFS, getAssetId(), assetType, LLVFile::WRITE); - - file.setMaxSize(file_size); - - const S32 buf_size = 65536; - U8 copy_buf[buf_size]; - while ((file_size = infile.read(copy_buf, buf_size))) - { - file.write(copy_buf, file_size); - } - } - else - { - errorMessage = llformat("Unable to access output file: %s", filename.c_str()); - LLSD errorResult(LLSD::emptyMap()); - - errorResult["error"] = LLSD::Binary(true); - errorResult["message"] = errorMessage; - return errorResult; - } - - return LLSD(); - -} diff --git a/indra/newview/llviewermenufile.h b/indra/newview/llviewermenufile.h index 7ee5043777..616eaed373 100755 --- a/indra/newview/llviewermenufile.h +++ b/indra/newview/llviewermenufile.h @@ -34,155 +34,13 @@ #include "llthread.h" #include +#include "llviewerassetupload.h" + class LLTransactionID; void init_menu_file(); -class NewResourceUploadInfo -{ -public: - typedef boost::shared_ptr ptr_t; - - NewResourceUploadInfo( - LLTransactionID transactId, - LLAssetType::EType assetType, - std::string name, - std::string description, - S32 compressionInfo, - LLFolderType::EType destinationType, - LLInventoryType::EType inventoryType, - U32 nextOWnerPerms, - U32 groupPerms, - U32 everyonePerms, - S32 expectedCost) : - mTransactionId(transactId), - mAssetType(assetType), - mName(name), - mDescription(description), - mCompressionInfo(compressionInfo), - mDestinationFolderType(destinationType), - mInventoryType(inventoryType), - mNextOwnerPerms(nextOWnerPerms), - mGroupPerms(groupPerms), - mEveryonePerms(everyonePerms), - mExpectedUploadCost(expectedCost), - mFolderId(LLUUID::null), - mItemId(LLUUID::null), - mAssetId(LLAssetID::null) - { } - - virtual ~NewResourceUploadInfo() - { } - - virtual LLSD prepareUpload(); - virtual LLSD generatePostBody(); - virtual void logPreparedUpload(); - virtual LLUUID finishUpload(LLSD &result); - - //void setAssetType(LLAssetType::EType assetType) { mAssetType = assetType; } - //void setTransactionId(LLTransactionID transactionId) { mTransactionId = transactionId; } - - LLTransactionID getTransactionId() const { return mTransactionId; } - LLAssetType::EType getAssetType() const { return mAssetType; } - std::string getAssetTypeString() const; - std::string getName() const { return mName; }; - std::string getDescription() const { return mDescription; }; - S32 getCompressionInfo() const { return mCompressionInfo; }; - LLFolderType::EType getDestinationFolderType() const { return mDestinationFolderType; }; - LLInventoryType::EType getInventoryType() const { return mInventoryType; }; - std::string getInventoryTypeString() const; - U32 getNextOwnerPerms() const { return mNextOwnerPerms; }; - U32 getGroupPerms() const { return mGroupPerms; }; - U32 getEveryonePerms() const { return mEveryonePerms; }; - S32 getExpectedUploadCost() const { return mExpectedUploadCost; }; - - virtual std::string getDisplayName() const; - - LLUUID getFolderId() const { return mFolderId; } - LLUUID getItemId() const { return mItemId; } - LLAssetID getAssetId() const { return mAssetId; } - -protected: - NewResourceUploadInfo( - std::string name, - std::string description, - S32 compressionInfo, - LLFolderType::EType destinationType, - LLInventoryType::EType inventoryType, - U32 nextOWnerPerms, - U32 groupPerms, - U32 everyonePerms, - S32 expectedCost) : - mName(name), - mDescription(description), - mCompressionInfo(compressionInfo), - mDestinationFolderType(destinationType), - mInventoryType(inventoryType), - mNextOwnerPerms(nextOWnerPerms), - mGroupPerms(groupPerms), - mEveryonePerms(everyonePerms), - mExpectedUploadCost(expectedCost), - mTransactionId(), - mAssetType(LLAssetType::AT_NONE), - mFolderId(LLUUID::null), - mItemId(LLUUID::null), - mAssetId(LLAssetID::null) - { } - - void setTransactionId(LLTransactionID tid) { mTransactionId = tid; } - void setAssetType(LLAssetType::EType assetType) { mAssetType = assetType; } - - LLAssetID generateNewAssetId(); - void incrementUploadStats() const; - virtual void assignDefaults(); - -private: - LLTransactionID mTransactionId; - LLAssetType::EType mAssetType; - std::string mName; - std::string mDescription; - S32 mCompressionInfo; - LLFolderType::EType mDestinationFolderType; - LLInventoryType::EType mInventoryType; - U32 mNextOwnerPerms; - U32 mGroupPerms; - U32 mEveryonePerms; - S32 mExpectedUploadCost; - - LLUUID mFolderId; - LLUUID mItemId; - LLAssetID mAssetId; -}; - -class NewFileResourceUploadInfo : public NewResourceUploadInfo -{ -public: - NewFileResourceUploadInfo( - std::string fileName, - std::string name, - std::string description, - S32 compressionInfo, - LLFolderType::EType destinationType, - LLInventoryType::EType inventoryType, - U32 nextOWnerPerms, - U32 groupPerms, - U32 everyonePerms, - S32 expectedCost); - - virtual LLSD prepareUpload(); - - std::string getFileName() const { return mFileName; }; - -protected: - - virtual LLSD exportTempFile(); - -private: - std::string mFileName; - -}; - LLUUID upload_new_resource( const std::string& src_filename, -- cgit v1.2.3 From 4c1d47d4ae231c1141c6ecf707c033563c99382a Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 7 Jul 2015 19:31:34 +0100 Subject: Backed out selfless merge --- indra/llcommon/llcoros.cpp | 10 +-- indra/llcommon/llcoros.h | 35 ++++---- indra/llcommon/lleventcoro.cpp | 127 ++++------------------------ indra/llcommon/lleventcoro.h | 132 +++++++++++++++++++++--------- indra/llcommon/tests/lleventcoro_test.cpp | 5 +- indra/llmessage/llcorehttputil.cpp | 10 +-- indra/newview/llcoproceduremanager.cpp | 2 +- indra/newview/lleventpoll.cpp | 2 +- indra/viewer_components/login/lllogin.cpp | 6 +- 9 files changed, 144 insertions(+), 185 deletions(-) (limited to 'indra') diff --git a/indra/llcommon/llcoros.cpp b/indra/llcommon/llcoros.cpp index 957fe034e1..2d0c419ae0 100755 --- a/indra/llcommon/llcoros.cpp +++ b/indra/llcommon/llcoros.cpp @@ -69,9 +69,9 @@ sCurrentSelf(no_cleanup); } // anonymous //static -LLCoros::coro::self& llcoro::get_self() +LLCoros::coro::self& LLCoros::get_self() { - LLCoros::coro::self* current_self = sCurrentSelf.get(); + coro::self* current_self = sCurrentSelf.get(); if (! current_self) { LL_ERRS("LLCoros") << "Calling get_self() from non-coroutine context!" << LL_ENDL; @@ -79,7 +79,7 @@ LLCoros::coro::self& llcoro::get_self() return *current_self; } -llcoro::Suspending::Suspending(): +LLCoros::Suspending::Suspending(): mSuspended(sCurrentSelf.get()) { // For the duration of our time away from this coroutine, sCurrentSelf @@ -87,7 +87,7 @@ llcoro::Suspending::Suspending(): sCurrentSelf.reset(); } -llcoro::Suspending::~Suspending() +LLCoros::Suspending::~Suspending() { // Okay, we're back, reinstate previous value of sCurrentSelf. sCurrentSelf.reset(mSuspended); @@ -171,7 +171,7 @@ bool LLCoros::kill(const std::string& name) std::string LLCoros::getName() const { // Walk the existing coroutines, looking for the current one. - void* self_id = llcoro::get_self().get_id(); + void* self_id = get_self().get_id(); for (CoroMap::const_iterator mi(mCoros.begin()), mend(mCoros.end()); mi != mend; ++mi) { namespace coro_private = boost::dcoroutines::detail; diff --git a/indra/llcommon/llcoros.h b/indra/llcommon/llcoros.h index e478600f00..3f58a17aa9 100755 --- a/indra/llcommon/llcoros.h +++ b/indra/llcommon/llcoros.h @@ -137,6 +137,21 @@ public: */ std::string getName() const; + /// get the current coro::self& for those who really really care + static coro::self& get_self(); + + /// Instantiate one of these in a block surrounding any leaf point when + /// control literally switches away from this coroutine. + class Suspending + { + public: + Suspending(); + ~Suspending(); + + private: + coro::self* mSuspended; + }; + /// for delayed initialization void setStackSize(S32 stacksize); @@ -151,24 +166,4 @@ private: CoroMap mCoros; }; -namespace llcoro -{ - -/// get the current coro::self& for those who really really care -LLCoros::coro::self& get_self(); - -/// Instantiate one of these in a block surrounding any leaf point when -/// control literally switches away from this coroutine. -class Suspending -{ -public: - Suspending(); - ~Suspending(); - -private: - LLCoros::coro::self* mSuspended; -}; - -} // namespace llcoro - #endif /* ! defined(LL_LLCOROS_H) */ diff --git a/indra/llcommon/lleventcoro.cpp b/indra/llcommon/lleventcoro.cpp index ad02e139b8..be93e9c83b 100755 --- a/indra/llcommon/lleventcoro.cpp +++ b/indra/llcommon/lleventcoro.cpp @@ -41,23 +41,7 @@ #include "llerror.h" #include "llcoros.h" -namespace -{ - -/** - * waitForEventOn() permits a coroutine to temporarily listen on an - * LLEventPump any number of times. We don't really want to have to ask - * the caller to label each such call with a distinct string; the whole - * point of waitForEventOn() is to present a nice sequential interface to - * the underlying LLEventPump-with-named-listeners machinery. So we'll use - * LLEventPump::inventName() to generate a distinct name for each - * temporary listener. On the other hand, because a given coroutine might - * call waitForEventOn() any number of times, we don't really want to - * consume an arbitrary number of generated inventName()s: that namespace, - * though large, is nonetheless finite. So we memoize an invented name for - * each distinct coroutine instance. - */ -std::string listenerNameForCoro() +std::string LLEventDetail::listenerNameForCoro() { // If this coroutine was launched by LLCoros::launch(), find that name. std::string name(LLCoros::instance().getName()); @@ -72,25 +56,7 @@ std::string listenerNameForCoro() return name; } -/** - * Implement behavior described for postAndWait()'s @a replyPumpNamePath - * parameter: - * - * * If path.isUndefined(), do nothing. - * * If path.isString(), @a dest is an LLSD map: store @a value - * into dest[path.asString()]. - * * If path.isInteger(), @a dest is an LLSD array: store @a - * value into dest[path.asInteger()]. - * * If path.isArray(), iteratively apply the rules above to step - * down through the structure of @a dest. The last array entry in @a - * path specifies the entry in the lowest-level structure in @a dest - * into which to store @a value. - * - * @note - * In the degenerate case in which @a path is an empty array, @a dest will - * @em become @a value rather than @em containing it. - */ -void storeToLLSDPath(LLSD& dest, const LLSD& rawPath, const LLSD& value) +void LLEventDetail::storeToLLSDPath(LLSD& dest, const LLSD& rawPath, const LLSD& value) { if (rawPath.isUndefined()) { @@ -143,24 +109,14 @@ void storeToLLSDPath(LLSD& dest, const LLSD& rawPath, const LLSD& value) *pdest = value; } -} // anonymous - -void llcoro::yield() -{ - // By viewer convention, we post an event on the "mainloop" LLEventPump - // each iteration of the main event-handling loop. So waiting for a single - // event on "mainloop" gives us a one-frame yield. - waitForEventOn("mainloop"); -} - -LLSD llcoro::postAndWait(const LLSD& event, const LLEventPumpOrPumpName& requestPump, - const LLEventPumpOrPumpName& replyPump, const LLSD& replyPumpNamePath) +LLSD postAndWait(const LLSD& event, const LLEventPumpOrPumpName& requestPump, + const LLEventPumpOrPumpName& replyPump, const LLSD& replyPumpNamePath) { // declare the future - boost::dcoroutines::future future(llcoro::get_self()); + boost::dcoroutines::future future(LLCoros::get_self()); // make a callback that will assign a value to the future, and listen on // the specified LLEventPump with that callback - std::string listenerName(listenerNameForCoro()); + std::string listenerName(LLEventDetail::listenerNameForCoro()); LLTempBoundListener connection( replyPump.getPump().listen(listenerName, voidlistener(boost::dcoroutines::make_callback(future)))); @@ -170,7 +126,7 @@ LLSD llcoro::postAndWait(const LLSD& event, const LLEventPumpOrPumpName& request // If replyPumpNamePath is non-empty, store the replyPump name in the // request event. LLSD modevent(event); - storeToLLSDPath(modevent, replyPumpNamePath, replyPump.getPump().getName()); + LLEventDetail::storeToLLSDPath(modevent, replyPumpNamePath, replyPump.getPump().getName()); LL_DEBUGS("lleventcoro") << "postAndWait(): coroutine " << listenerName << " posting to " << requestPump.getPump().getName() << LL_ENDL; @@ -186,7 +142,7 @@ LLSD llcoro::postAndWait(const LLSD& event, const LLEventPumpOrPumpName& request LLSD value; { // instantiate Suspending to manage the "current" coroutine - llcoro::Suspending suspended; + LLCoros::Suspending suspended; value = *future; } // destroy Suspending as soon as we're back LL_DEBUGS("lleventcoro") << "postAndWait(): coroutine " << listenerName @@ -195,53 +151,6 @@ LLSD llcoro::postAndWait(const LLSD& event, const LLEventPumpOrPumpName& request return value; } -namespace -{ - -/** - * This helper is specifically for the two-pump version of waitForEventOn(). - * We use a single future object, but we want to listen on two pumps with it. - * Since we must still adapt from (the callable constructed by) - * boost::dcoroutines::make_callback() (void return) to provide an event - * listener (bool return), we've adapted VoidListener for the purpose. The - * basic idea is that we construct a distinct instance of WaitForEventOnHelper - * -- binding different instance data -- for each of the pumps. Then, when a - * pump delivers an LLSD value to either WaitForEventOnHelper, it can combine - * that LLSD with its discriminator to feed the future object. - */ -template -class WaitForEventOnHelper -{ -public: - WaitForEventOnHelper(const LISTENER& listener, int discriminator): - mListener(listener), - mDiscrim(discriminator) - {} - // this signature is required for an LLEventPump listener - bool operator()(const LLSD& event) - { - // our future object is defined to accept LLEventWithID - mListener(LLEventWithID(event, mDiscrim)); - // don't swallow the event, let other listeners see it - return false; - } -private: - LISTENER mListener; - const int mDiscrim; -}; - -/// WaitForEventOnHelper type-inference helper -template -WaitForEventOnHelper wfeoh(const LISTENER& listener, int discriminator) -{ - return WaitForEventOnHelper(listener, discriminator); -} - -} // anonymous - -namespace llcoro -{ - LLEventWithID postAndWait2(const LLSD& event, const LLEventPumpOrPumpName& requestPump, const LLEventPumpOrPumpName& replyPump0, @@ -250,26 +159,26 @@ LLEventWithID postAndWait2(const LLSD& event, const LLSD& replyPump1NamePath) { // declare the future - boost::dcoroutines::future future(llcoro::get_self()); + boost::dcoroutines::future future(LLCoros::get_self()); // either callback will assign a value to this future; listen on // each specified LLEventPump with a callback - std::string name(listenerNameForCoro()); + std::string name(LLEventDetail::listenerNameForCoro()); LLTempBoundListener connection0( replyPump0.getPump().listen(name + "a", - wfeoh(boost::dcoroutines::make_callback(future), 0))); + LLEventDetail::wfeoh(boost::dcoroutines::make_callback(future), 0))); LLTempBoundListener connection1( replyPump1.getPump().listen(name + "b", - wfeoh(boost::dcoroutines::make_callback(future), 1))); + LLEventDetail::wfeoh(boost::dcoroutines::make_callback(future), 1))); // skip the "post" part if requestPump is default-constructed if (requestPump) { // If either replyPumpNamePath is non-empty, store the corresponding // replyPump name in the request event. LLSD modevent(event); - storeToLLSDPath(modevent, replyPump0NamePath, - replyPump0.getPump().getName()); - storeToLLSDPath(modevent, replyPump1NamePath, - replyPump1.getPump().getName()); + LLEventDetail::storeToLLSDPath(modevent, replyPump0NamePath, + replyPump0.getPump().getName()); + LLEventDetail::storeToLLSDPath(modevent, replyPump1NamePath, + replyPump1.getPump().getName()); LL_DEBUGS("lleventcoro") << "postAndWait2(): coroutine " << name << " posting to " << requestPump.getPump().getName() << ": " << modevent << LL_ENDL; @@ -282,7 +191,7 @@ LLEventWithID postAndWait2(const LLSD& event, LLEventWithID value; { // instantiate Suspending to manage "current" coroutine - llcoro::Suspending suspended; + LLCoros::Suspending suspended; value = *future; } // destroy Suspending as soon as we're back LL_DEBUGS("lleventcoro") << "postAndWait(): coroutine " << name @@ -318,5 +227,3 @@ LLSD errorLog(const LLEventWithID& result, const std::string& desc) // A simple return must therefore be from the reply pump (pump 0). return result.first; } - -} // namespace llcoro diff --git a/indra/llcommon/lleventcoro.h b/indra/llcommon/lleventcoro.h index e2ce4bb193..daf9360a2e 100755 --- a/indra/llcommon/lleventcoro.h +++ b/indra/llcommon/lleventcoro.h @@ -72,16 +72,13 @@ private: boost::optional mPump; }; -namespace llcoro -{ - /// This is an adapter for a signature like void LISTENER(const LLSD&), which /// isn't a valid LLEventPump listener: such listeners should return bool. template -class VoidListener +class LLVoidListener { public: - VoidListener(const LISTENER& listener): + LLVoidListener(const LISTENER& listener): mListener(listener) {} bool operator()(const LLSD& event) @@ -94,19 +91,50 @@ private: LISTENER mListener; }; -/// VoidListener helper function to infer the type of the LISTENER +/// LLVoidListener helper function to infer the type of the LISTENER template -VoidListener voidlistener(const LISTENER& listener) +LLVoidListener voidlistener(const LISTENER& listener) { - return VoidListener(listener); + return LLVoidListener(listener); } -/** - * Yield control from a coroutine for one "mainloop" tick. If your coroutine - * runs without suspending for nontrivial time, sprinkle in calls to this - * function to avoid stalling the rest of the viewer processing. - */ -void yield(); +namespace LLEventDetail +{ + /** + * waitForEventOn() permits a coroutine to temporarily listen on an + * LLEventPump any number of times. We don't really want to have to ask + * the caller to label each such call with a distinct string; the whole + * point of waitForEventOn() is to present a nice sequential interface to + * the underlying LLEventPump-with-named-listeners machinery. So we'll use + * LLEventPump::inventName() to generate a distinct name for each + * temporary listener. On the other hand, because a given coroutine might + * call waitForEventOn() any number of times, we don't really want to + * consume an arbitrary number of generated inventName()s: that namespace, + * though large, is nonetheless finite. So we memoize an invented name for + * each distinct coroutine instance. + */ + std::string listenerNameForCoro(); + + /** + * Implement behavior described for postAndWait()'s @a replyPumpNamePath + * parameter: + * + * * If path.isUndefined(), do nothing. + * * If path.isString(), @a dest is an LLSD map: store @a value + * into dest[path.asString()]. + * * If path.isInteger(), @a dest is an LLSD array: store @a + * value into dest[path.asInteger()]. + * * If path.isArray(), iteratively apply the rules above to step + * down through the structure of @a dest. The last array entry in @a + * path specifies the entry in the lowest-level structure in @a dest + * into which to store @a value. + * + * @note + * In the degenerate case in which @a path is an empty array, @a dest will + * @em become @a value rather than @em containing it. + */ + LL_COMMON_API void storeToLLSDPath(LLSD& dest, const LLSD& path, const LLSD& value); +} // namespace LLEventDetail /** * Post specified LLSD event on the specified LLEventPump, then wait for a @@ -168,13 +196,50 @@ LLSD waitForEventOn(const LLEventPumpOrPumpName& pump) return postAndWait(LLSD(), LLEventPumpOrPumpName(), pump); } -} // namespace llcoro - /// return type for two-pump variant of waitForEventOn() typedef std::pair LLEventWithID; -namespace llcoro +namespace LLEventDetail { + /** + * This helper is specifically for the two-pump version of waitForEventOn(). + * We use a single future object, but we want to listen on two pumps with it. + * Since we must still adapt from (the callable constructed by) + * boost::dcoroutines::make_callback() (void return) to provide an event + * listener (bool return), we've adapted LLVoidListener for the purpose. The + * basic idea is that we construct a distinct instance of WaitForEventOnHelper + * -- binding different instance data -- for each of the pumps. Then, when a + * pump delivers an LLSD value to either WaitForEventOnHelper, it can combine + * that LLSD with its discriminator to feed the future object. + */ + template + class WaitForEventOnHelper + { + public: + WaitForEventOnHelper(const LISTENER& listener, int discriminator): + mListener(listener), + mDiscrim(discriminator) + {} + // this signature is required for an LLEventPump listener + bool operator()(const LLSD& event) + { + // our future object is defined to accept LLEventWithID + mListener(LLEventWithID(event, mDiscrim)); + // don't swallow the event, let other listeners see it + return false; + } + private: + LISTENER mListener; + const int mDiscrim; + }; + + /// WaitForEventOnHelper type-inference helper + template + WaitForEventOnHelper wfeoh(const LISTENER& listener, int discriminator) + { + return WaitForEventOnHelper(listener, discriminator); + } +} // namespace LLEventDetail /** * This function waits for a reply on either of two specified LLEventPumps. @@ -243,8 +308,6 @@ waitForEventOn(const LLEventPumpOrPumpName& pump0, const LLEventPumpOrPumpName& */ LLSD errorException(const LLEventWithID& result, const std::string& desc); -} // namespace llcoro - /** * Exception thrown by errorException(). We don't call this LLEventError * because it's not an error in event processing: rather, this exception @@ -265,17 +328,12 @@ private: LLSD mData; }; -namespace llcoro -{ - /** * Like errorException(), save that this trips a fatal error using LL_ERRS * rather than throwing an exception. */ LL_COMMON_API LLSD errorLog(const LLEventWithID& result, const std::string& desc); -} // namespace llcoro - /** * Certain event APIs require the name of an LLEventPump on which they should * post results. While it works to invent a distinct name and let @@ -307,13 +365,13 @@ public: */ LLSD wait() { - return llcoro::waitForEventOn(mPump); + return ::waitForEventOn(mPump); } LLSD postAndWait(const LLSD& event, const LLEventPumpOrPumpName& requestPump, const LLSD& replyPumpNamePath=LLSD()) { - return llcoro::postAndWait(event, requestPump, mPump, replyPumpNamePath); + return ::postAndWait(event, requestPump, mPump, replyPumpNamePath); } private: @@ -352,19 +410,19 @@ public: /// waitForEventOn(either of our two LLEventPumps) LLEventWithID wait() { - return llcoro::waitForEventOn(mPump0, mPump1); + return waitForEventOn(mPump0, mPump1); } /// errorException(wait()) LLSD waitWithException() { - return llcoro::errorException(wait(), std::string("Error event on ") + getName1()); + return errorException(wait(), std::string("Error event on ") + getName1()); } /// errorLog(wait()) LLSD waitWithLog() { - return llcoro::errorLog(wait(), std::string("Error event on ") + getName1()); + return errorLog(wait(), std::string("Error event on ") + getName1()); } LLEventWithID postAndWait(const LLSD& event, @@ -372,8 +430,8 @@ public: const LLSD& replyPump0NamePath=LLSD(), const LLSD& replyPump1NamePath=LLSD()) { - return llcoro::postAndWait2(event, requestPump, mPump0, mPump1, - replyPump0NamePath, replyPump1NamePath); + return postAndWait2(event, requestPump, mPump0, mPump1, + replyPump0NamePath, replyPump1NamePath); } LLSD postAndWaitWithException(const LLSD& event, @@ -381,9 +439,9 @@ public: const LLSD& replyPump0NamePath=LLSD(), const LLSD& replyPump1NamePath=LLSD()) { - return llcoro::errorException(postAndWait(event, requestPump, - replyPump0NamePath, replyPump1NamePath), - std::string("Error event on ") + getName1()); + return errorException(postAndWait(event, requestPump, + replyPump0NamePath, replyPump1NamePath), + std::string("Error event on ") + getName1()); } LLSD postAndWaitWithLog(const LLSD& event, @@ -391,9 +449,9 @@ public: const LLSD& replyPump0NamePath=LLSD(), const LLSD& replyPump1NamePath=LLSD()) { - return llcoro::errorLog(postAndWait(event, requestPump, - replyPump0NamePath, replyPump1NamePath), - std::string("Error event on ") + getName1()); + return errorLog(postAndWait(event, requestPump, + replyPump0NamePath, replyPump1NamePath), + std::string("Error event on ") + getName1()); } private: diff --git a/indra/llcommon/tests/lleventcoro_test.cpp b/indra/llcommon/tests/lleventcoro_test.cpp index 79bcfe58ed..da927038ab 100755 --- a/indra/llcommon/tests/lleventcoro_test.cpp +++ b/indra/llcommon/tests/lleventcoro_test.cpp @@ -86,8 +86,6 @@ #include "lleventcoro.h" #include "../test/debug.h" -using namespace llcoro; - /***************************************************************************** * from the banana.cpp example program borrowed for test<1>() *****************************************************************************/ @@ -261,7 +259,8 @@ namespace tut // Construct the coroutine instance that will run explicit_wait. // Pass the ctor a callable that accepts the coroutine_type::self // param passed by the library. - boost::dcoroutines::coroutine coro(explicit_wait); + boost::dcoroutines::coroutine + coro(explicit_wait); // Start the coroutine coro(std::nothrow); // When the coroutine waits for the event pump, it returns here. diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index cd3c527241..ac1c2f8e58 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -596,7 +596,7 @@ LLSD HttpCoroutineAdapter::postAndYield_(LLCore::HttpRequest::ptr_t &request, } saveState(hhandle, request, handler); - LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); + LLSD results = waitForEventOn(handler->getReplyPump()); cleanState(); return results; @@ -697,7 +697,7 @@ LLSD HttpCoroutineAdapter::postAndYield_(LLCore::HttpRequest::ptr_t &request, } saveState(hhandle, request, handler); - LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); + LLSD results = waitForEventOn(handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; @@ -735,7 +735,7 @@ LLSD HttpCoroutineAdapter::putAndYield_(LLCore::HttpRequest::ptr_t &request, } saveState(hhandle, request, handler); - LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); + LLSD results = waitForEventOn(handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; @@ -790,7 +790,7 @@ LLSD HttpCoroutineAdapter::getAndYield_(LLCore::HttpRequest::ptr_t &request, } saveState(hhandle, request, handler); - LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); + LLSD results = waitForEventOn(handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; @@ -825,7 +825,7 @@ LLSD HttpCoroutineAdapter::deleteAndYield_(LLCore::HttpRequest::ptr_t &request, } saveState(hhandle, request, handler); - LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); + LLSD results = waitForEventOn(handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; diff --git a/indra/newview/llcoproceduremanager.cpp b/indra/newview/llcoproceduremanager.cpp index d3168985f8..1a4a906f35 100644 --- a/indra/newview/llcoproceduremanager.cpp +++ b/indra/newview/llcoproceduremanager.cpp @@ -138,7 +138,7 @@ void LLCoprocedureManager::coprocedureInvokerCoro(LLCoreHttpUtil::HttpCoroutineA while (!mShutdown) { - llcoro::waitForEventOn(mWakeupTrigger); + waitForEventOn(mWakeupTrigger); if (mShutdown) break; diff --git a/indra/newview/lleventpoll.cpp b/indra/newview/lleventpoll.cpp index 0aad1d5ba9..54da226209 100755 --- a/indra/newview/lleventpoll.cpp +++ b/indra/newview/lleventpoll.cpp @@ -197,7 +197,7 @@ namespace Details " seconds, error count is now " << errorCount << LL_ENDL; timeout.eventAfter(waitToRetry, LLSD()); - llcoro::waitForEventOn(timeout); + waitForEventOn(timeout); if (mDone) break; diff --git a/indra/viewer_components/login/lllogin.cpp b/indra/viewer_components/login/lllogin.cpp index 88415ff11a..0569e9f3e8 100755 --- a/indra/viewer_components/login/lllogin.cpp +++ b/indra/viewer_components/login/lllogin.cpp @@ -175,7 +175,7 @@ void LLLogin::Impl::login_(std::string uri, LLSD login_params) request["op"] = "rewriteURI"; request["uri"] = uri; request["reply"] = replyPump.getName(); - rewrittenURIs = llcoro::postAndWait(request, srv_pump_name, filter); + rewrittenURIs = postAndWait(request, srv_pump_name, filter); // EXP-772: If rewrittenURIs fail, try original URI as a fallback. rewrittenURIs.append(uri); } // we no longer need the filter @@ -221,10 +221,10 @@ void LLLogin::Impl::login_(std::string uri, LLSD login_params) // returns. Subsequent responses, of course, must be awaited // without posting again. for (mAuthResponse = validateResponse(loginReplyPump.getName(), - llcoro::postAndWait(request, xmlrpcPump, loginReplyPump, "reply")); + postAndWait(request, xmlrpcPump, loginReplyPump, "reply")); mAuthResponse["status"].asString() == "Downloading"; mAuthResponse = validateResponse(loginReplyPump.getName(), - llcoro::waitForEventOn(loginReplyPump))) + waitForEventOn(loginReplyPump))) { // Still Downloading -- send progress update. sendProgressEvent("offline", "downloading"); -- cgit v1.2.3 From 247eb0c9c3418c10be8f2a0e3c8116758efa702f Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 7 Jul 2015 19:41:27 +0100 Subject: Backout selfles merge 738255dbbfd679d9e615baab3398e5e345bbb3c5 --- indra/llcommon/llcoros.cpp | 86 +-- indra/llcommon/llcoros.h | 67 +- indra/llcommon/lleventcoro.cpp | 113 +--- indra/llcommon/lleventcoro.h | 176 ++++- indra/llcommon/tests/lleventcoro_test.cpp | 712 +++++++++++---------- indra/llmessage/CMakeLists.txt | 2 +- indra/llmessage/llavatarnamecache.cpp | 12 +- indra/llmessage/llcorehttputil.cpp | 72 +-- indra/llmessage/llcorehttputil.h | 66 +- indra/newview/llaccountingcostmanager.cpp | 8 +- indra/newview/llaccountingcostmanager.h | 2 +- indra/newview/llavatarrenderinfoaccountant.cpp | 12 +- indra/newview/llavatarrenderinfoaccountant.h | 4 +- indra/newview/llcoproceduremanager.cpp | 8 +- indra/newview/llcoproceduremanager.h | 4 +- indra/newview/llestateinfomodel.cpp | 6 +- indra/newview/llestateinfomodel.h | 2 +- indra/newview/lleventpoll.cpp | 10 +- indra/newview/llfacebookconnect.cpp | 46 +- indra/newview/llfacebookconnect.h | 14 +- indra/newview/llfeaturemanager.cpp | 6 +- indra/newview/llfeaturemanager.h | 2 +- indra/newview/llflickrconnect.cpp | 36 +- indra/newview/llflickrconnect.h | 12 +- indra/newview/llfloateravatarpicker.cpp | 6 +- indra/newview/llfloateravatarpicker.h | 2 +- indra/newview/llfloatermodeluploadbase.cpp | 6 +- indra/newview/llfloatermodeluploadbase.h | 2 +- indra/newview/llfloaterperms.cpp | 6 +- indra/newview/llfloaterperms.h | 2 +- indra/newview/llfloaterscriptlimits.cpp | 24 +- indra/newview/llfloaterscriptlimits.h | 8 +- indra/newview/llfloatertos.cpp | 6 +- indra/newview/llfloatertos.h | 2 +- indra/newview/llfloaterurlentry.cpp | 6 +- indra/newview/llfloaterurlentry.h | 2 +- indra/newview/llgroupmgr.cpp | 20 +- indra/newview/llgroupmgr.h | 6 +- indra/newview/llimview.cpp | 20 +- indra/newview/llinventorymodel.cpp | 6 +- indra/newview/llinventorymodel.h | 2 +- indra/newview/llmarketplacefunctions.cpp | 14 +- indra/newview/llpathfindingmanager.cpp | 46 +- indra/newview/llpathfindingmanager.h | 12 +- indra/newview/llproductinforequest.cpp | 6 +- indra/newview/llproductinforequest.h | 2 +- indra/newview/llremoteparcelrequest.cpp | 6 +- indra/newview/llremoteparcelrequest.h | 2 +- indra/newview/llspeakers.cpp | 10 +- indra/newview/llspeakers.h | 2 +- indra/newview/llsyntaxid.cpp | 6 +- indra/newview/llsyntaxid.h | 2 +- indra/newview/lltwitterconnect.cpp | 38 +- indra/newview/lltwitterconnect.h | 12 +- indra/newview/llviewerassetupload.cpp | 6 +- indra/newview/llviewerassetupload.h | 2 +- indra/newview/llviewermedia.cpp | 18 +- indra/newview/llviewermedia.h | 6 +- indra/newview/llviewermenufile.cpp | 2 +- indra/newview/llviewerobjectlist.cpp | 12 +- indra/newview/llviewerobjectlist.h | 4 +- indra/newview/llviewerregion.cpp | 24 +- indra/newview/llvoavatarself.cpp | 6 +- indra/newview/llvoavatarself.h | 2 +- indra/newview/llvoicechannel.cpp | 6 +- indra/newview/llvoicechannel.h | 2 +- indra/newview/llvoicevivox.cpp | 12 +- indra/newview/llvoicevivox.h | 4 +- indra/newview/llwebprofile.cpp | 10 +- indra/newview/llwebprofile.h | 2 +- indra/newview/llwlhandlers.cpp | 12 +- indra/newview/llwlhandlers.h | 4 +- indra/viewer_components/login/lllogin.cpp | 17 +- .../viewer_components/updater/llupdatechecker.cpp | 6 +- indra/viewer_components/updater/llupdatechecker.h | 2 +- 75 files changed, 947 insertions(+), 974 deletions(-) (limited to 'indra') diff --git a/indra/llcommon/llcoros.cpp b/indra/llcommon/llcoros.cpp index 2d0c419ae0..baaddcaed1 100755 --- a/indra/llcommon/llcoros.cpp +++ b/indra/llcommon/llcoros.cpp @@ -34,65 +34,11 @@ // std headers // external library headers #include -#include // other Linden headers #include "llevents.h" #include "llerror.h" #include "stringize.h" -namespace { - -// do nothing, when we need nothing done -void no_cleanup(LLCoros::coro::self*) {} - -// When the dcoroutine library calls a top-level callable, it implicitly -// passes coro::self& as the first parameter. All our consumer code used to -// explicitly pass coro::self& down through all levels of call stack, because -// at the leaf level we need it for context-switching. But since coroutines -// are based on cooperative switching, we can cause the top-level entry point -// to stash a static pointer to the currently-running coroutine, and manage it -// appropriately as we switch out and back in. That eliminates the need to -// pass it as an explicit parameter down through every level, which is -// unfortunately viral in nature. Finding it implicitly rather than explicitly -// allows minor maintenance in which a leaf-level function adds a new async -// I/O call that suspends the calling coroutine, WITHOUT having to propagate -// coro::self& through every function signature down to that point -- and of -// course through every other caller of every such function. -// We use a boost::thread_specific_ptr because each thread potentially has its -// own distinct pool of coroutines. -// This thread_specific_ptr does NOT own the 'self' object! It merely -// identifies it. For this reason we instantiate it with a no-op cleanup -// function. -static boost::thread_specific_ptr -sCurrentSelf(no_cleanup); - -} // anonymous - -//static -LLCoros::coro::self& LLCoros::get_self() -{ - coro::self* current_self = sCurrentSelf.get(); - if (! current_self) - { - LL_ERRS("LLCoros") << "Calling get_self() from non-coroutine context!" << LL_ENDL; - } - return *current_self; -} - -LLCoros::Suspending::Suspending(): - mSuspended(sCurrentSelf.get()) -{ - // For the duration of our time away from this coroutine, sCurrentSelf - // must NOT refer to this coroutine. - sCurrentSelf.reset(); -} - -LLCoros::Suspending::~Suspending() -{ - // Okay, we're back, reinstate previous value of sCurrentSelf. - sCurrentSelf.reset(mSuspended); -} - LLCoros::LLCoros(): // MAINT-2724: default coroutine stack size too small on Windows. // Previously we used @@ -114,7 +60,7 @@ bool LLCoros::cleanup(const LLSD&) // since last tick? if (mi->second->exited()) { - LL_INFOS("LLCoros") << "LLCoros: cleaning up coroutine " << mi->first << LL_ENDL; + LL_INFOS("LLCoros") << "LLCoros: cleaning up coroutine " << mi->first << LL_ENDL; // The erase() call will invalidate its passed iterator value -- // so increment mi FIRST -- but pass its original value to // erase(). This is what postincrement is all about. @@ -148,7 +94,7 @@ std::string LLCoros::generateDistinctName(const std::string& prefix) const { if (mCoros.find(name) == mCoros.end()) { - LL_INFOS("LLCoros") << "LLCoros: launching coroutine " << name << LL_ENDL; + LL_INFOS("LLCoros") << "LLCoros: launching coroutine " << name << LL_ENDL; return name; } } @@ -168,10 +114,10 @@ bool LLCoros::kill(const std::string& name) return true; } -std::string LLCoros::getName() const +std::string LLCoros::getNameByID(const void* self_id) const { - // Walk the existing coroutines, looking for the current one. - void* self_id = get_self().get_id(); + // Walk the existing coroutines, looking for one from which the 'self_id' + // passed to us comes. for (CoroMap::const_iterator mi(mCoros.begin()), mend(mCoros.end()); mi != mend; ++mi) { namespace coro_private = boost::dcoroutines::detail; @@ -190,24 +136,10 @@ void LLCoros::setStackSize(S32 stacksize) mStackSize = stacksize; } -namespace { - -// Top-level wrapper around caller's coroutine callable. This function accepts -// the coroutine library's implicit coro::self& parameter and sets sCurrentSelf -// but does not pass it down to the caller's callable. -void toplevel(LLCoros::coro::self& self, const LLCoros::callable_t& callable) -{ - sCurrentSelf.reset(&self); - callable(); - sCurrentSelf.reset(); -} - -} // anonymous - /***************************************************************************** * MUST BE LAST *****************************************************************************/ -// Turn off MSVC optimizations for just LLCoros::launch() -- see +// Turn off MSVC optimizations for just LLCoros::launchImpl() -- see // DEV-32777. But MSVC doesn't support push/pop for optimization flags as it // does for warning suppression, and we really don't want to force // optimization ON for other code even in Debug or RelWithDebInfo builds. @@ -218,13 +150,9 @@ void toplevel(LLCoros::coro::self& self, const LLCoros::callable_t& callable) #pragma optimize("", off) #endif // LL_MSVC -std::string LLCoros::launch(const std::string& prefix, const callable_t& callable) +std::string LLCoros::launchImpl(const std::string& prefix, coro* newCoro) { std::string name(generateDistinctName(prefix)); - // Wrap the caller's callable in our toplevel() function so we can manage - // sCurrentSelf appropriately at startup and shutdown of each coroutine. - coro* newCoro = new coro(boost::bind(toplevel, _1, callable), mStackSize); - // Store it in our pointer map mCoros.insert(name, newCoro); /* Run the coroutine until its first wait, then return here */ (*newCoro)(std::nothrow); diff --git a/indra/llcommon/llcoros.h b/indra/llcommon/llcoros.h index 3f58a17aa9..01ee11da1a 100755 --- a/indra/llcommon/llcoros.h +++ b/indra/llcommon/llcoros.h @@ -32,8 +32,10 @@ #include #include "llsingleton.h" #include -#include #include +#include +#include +#include #include /** @@ -78,8 +80,8 @@ class LL_COMMON_API LLCoros: public LLSingleton public: /// Canonical boost::dcoroutines::coroutine signature we use typedef boost::dcoroutines::coroutine coro; - /// Canonical callable type - typedef boost::function callable_t; + /// Canonical 'self' type + typedef coro::self self; /** * Create and start running a new coroutine with specified name. The name @@ -92,33 +94,39 @@ public: * { * public: * ... - * // Do NOT NOT NOT accept reference params! + * // Do NOT NOT NOT accept reference params other than 'self'! * // Pass by value only! - * void myCoroutineMethod(std::string, LLSD); + * void myCoroutineMethod(LLCoros::self& self, std::string, LLSD); * ... * }; * ... * std::string name = LLCoros::instance().launch( - * "mycoro", boost::bind(&MyClass::myCoroutineMethod, this, + * "mycoro", boost::bind(&MyClass::myCoroutineMethod, this, _1, * "somestring", LLSD(17)); * @endcode * - * Your function/method can accept any parameters you want -- but ONLY BY - * VALUE! Reference parameters are a BAD IDEA! You Have Been Warned. See + * Your function/method must accept LLCoros::self& as its first parameter. + * It can accept any other parameters you want -- but ONLY BY VALUE! + * Other reference parameters are a BAD IDEA! You Have Been Warned. See * DEV-32777 comments for an explanation. * - * Pass a nullary callable. It works to directly pass a nullary free - * function (or static method); for all other cases use boost::bind(). Of - * course, for a non-static class method, the first parameter must be the - * class instance. Any other parameters should be passed via the bind() - * expression. + * Pass a callable that accepts the single LLCoros::self& parameter. It + * may work to pass a free function whose only parameter is 'self'; for + * all other cases use boost::bind(). Of course, for a non-static class + * method, the first parameter must be the class instance. Use the + * placeholder _1 for the 'self' parameter. Any other parameters should be + * passed via the bind() expression. * * launch() tweaks the suggested name so it won't collide with any * existing coroutine instance, creates the coroutine instance, registers * it with the tweaked name and runs it until its first wait. At that * point it returns the tweaked name. */ - std::string launch(const std::string& prefix, const callable_t& callable); + template + std::string launch(const std::string& prefix, const CALLABLE& callable) + { + return launchImpl(prefix, new coro(callable, mStackSize)); + } /** * Abort a running coroutine by name. Normally, when a coroutine either @@ -130,34 +138,27 @@ public: bool kill(const std::string& name); /** - * From within a coroutine, look up the (tweaked) name string by which - * this coroutine is registered. Returns the empty string if not found - * (e.g. if the coroutine was launched by hand rather than using - * LLCoros::launch()). + * From within a coroutine, pass its @c self object to look up the + * (tweaked) name string by which this coroutine is registered. Returns + * the empty string if not found (e.g. if the coroutine was launched by + * hand rather than using LLCoros::launch()). */ - std::string getName() const; - - /// get the current coro::self& for those who really really care - static coro::self& get_self(); - - /// Instantiate one of these in a block surrounding any leaf point when - /// control literally switches away from this coroutine. - class Suspending + template + std::string getName(const COROUTINE_SELF& self) const { - public: - Suspending(); - ~Suspending(); + return getNameByID(self.get_id()); + } - private: - coro::self* mSuspended; - }; + /// getName() by self.get_id() + std::string getNameByID(const void* self_id) const; /// for delayed initialization void setStackSize(S32 stacksize); private: - LLCoros(); friend class LLSingleton; + LLCoros(); + std::string launchImpl(const std::string& prefix, coro* newCoro); std::string generateDistinctName(const std::string& prefix) const; bool cleanup(const LLSD&); diff --git a/indra/llcommon/lleventcoro.cpp b/indra/llcommon/lleventcoro.cpp index be93e9c83b..81cc33fbba 100755 --- a/indra/llcommon/lleventcoro.cpp +++ b/indra/llcommon/lleventcoro.cpp @@ -34,24 +34,33 @@ #include // std headers // external library headers -#include -#include // other Linden headers #include "llsdserialize.h" #include "llerror.h" #include "llcoros.h" -std::string LLEventDetail::listenerNameForCoro() +std::string LLEventDetail::listenerNameForCoroImpl(const void* self_id) { - // If this coroutine was launched by LLCoros::launch(), find that name. - std::string name(LLCoros::instance().getName()); + // First, if this coroutine was launched by LLCoros::launch(), find that name. + std::string name(LLCoros::instance().getNameByID(self_id)); if (! name.empty()) { return name; } + // Apparently this coroutine wasn't launched by LLCoros::launch(). Check + // whether we have a memo for this self_id. + typedef std::map MapType; + static MapType memo; + MapType::const_iterator found = memo.find(self_id); + if (found != memo.end()) + { + // this coroutine instance has called us before, reuse same name + return found->second; + } // this is the first time we've been called for this coroutine instance name = LLEventPump::inventName("coro"); - LL_INFOS("LLEventCoro") << "listenerNameForCoro(): inventing coro name '" + memo[self_id] = name; + LL_INFOS("LLEventCoro") << "listenerNameForCoroImpl(" << self_id << "): inventing coro name '" << name << "'" << LL_ENDL; return name; } @@ -109,98 +118,6 @@ void LLEventDetail::storeToLLSDPath(LLSD& dest, const LLSD& rawPath, const LLSD& *pdest = value; } -LLSD postAndWait(const LLSD& event, const LLEventPumpOrPumpName& requestPump, - const LLEventPumpOrPumpName& replyPump, const LLSD& replyPumpNamePath) -{ - // declare the future - boost::dcoroutines::future future(LLCoros::get_self()); - // make a callback that will assign a value to the future, and listen on - // the specified LLEventPump with that callback - std::string listenerName(LLEventDetail::listenerNameForCoro()); - LLTempBoundListener connection( - replyPump.getPump().listen(listenerName, - voidlistener(boost::dcoroutines::make_callback(future)))); - // skip the "post" part if requestPump is default-constructed - if (requestPump) - { - // If replyPumpNamePath is non-empty, store the replyPump name in the - // request event. - LLSD modevent(event); - LLEventDetail::storeToLLSDPath(modevent, replyPumpNamePath, replyPump.getPump().getName()); - LL_DEBUGS("lleventcoro") << "postAndWait(): coroutine " << listenerName - << " posting to " << requestPump.getPump().getName() - << LL_ENDL; - - // *NOTE:Mani - Removed because modevent could contain user's hashed passwd. - // << ": " << modevent << LL_ENDL; - requestPump.getPump().post(modevent); - } - LL_DEBUGS("lleventcoro") << "postAndWait(): coroutine " << listenerName - << " about to wait on LLEventPump " << replyPump.getPump().getName() - << LL_ENDL; - // trying to dereference ("resolve") the future makes us wait for it - LLSD value; - { - // instantiate Suspending to manage the "current" coroutine - LLCoros::Suspending suspended; - value = *future; - } // destroy Suspending as soon as we're back - LL_DEBUGS("lleventcoro") << "postAndWait(): coroutine " << listenerName - << " resuming with " << value << LL_ENDL; - // returning should disconnect the connection - return value; -} - -LLEventWithID postAndWait2(const LLSD& event, - const LLEventPumpOrPumpName& requestPump, - const LLEventPumpOrPumpName& replyPump0, - const LLEventPumpOrPumpName& replyPump1, - const LLSD& replyPump0NamePath, - const LLSD& replyPump1NamePath) -{ - // declare the future - boost::dcoroutines::future future(LLCoros::get_self()); - // either callback will assign a value to this future; listen on - // each specified LLEventPump with a callback - std::string name(LLEventDetail::listenerNameForCoro()); - LLTempBoundListener connection0( - replyPump0.getPump().listen(name + "a", - LLEventDetail::wfeoh(boost::dcoroutines::make_callback(future), 0))); - LLTempBoundListener connection1( - replyPump1.getPump().listen(name + "b", - LLEventDetail::wfeoh(boost::dcoroutines::make_callback(future), 1))); - // skip the "post" part if requestPump is default-constructed - if (requestPump) - { - // If either replyPumpNamePath is non-empty, store the corresponding - // replyPump name in the request event. - LLSD modevent(event); - LLEventDetail::storeToLLSDPath(modevent, replyPump0NamePath, - replyPump0.getPump().getName()); - LLEventDetail::storeToLLSDPath(modevent, replyPump1NamePath, - replyPump1.getPump().getName()); - LL_DEBUGS("lleventcoro") << "postAndWait2(): coroutine " << name - << " posting to " << requestPump.getPump().getName() - << ": " << modevent << LL_ENDL; - requestPump.getPump().post(modevent); - } - LL_DEBUGS("lleventcoro") << "postAndWait2(): coroutine " << name - << " about to wait on LLEventPumps " << replyPump0.getPump().getName() - << ", " << replyPump1.getPump().getName() << LL_ENDL; - // trying to dereference ("resolve") the future makes us wait for it - LLEventWithID value; - { - // instantiate Suspending to manage "current" coroutine - LLCoros::Suspending suspended; - value = *future; - } // destroy Suspending as soon as we're back - LL_DEBUGS("lleventcoro") << "postAndWait(): coroutine " << name - << " resuming with (" << value.first << ", " << value.second << ")" - << LL_ENDL; - // returning should disconnect both connections - return value; -} - LLSD errorException(const LLEventWithID& result, const std::string& desc) { // If the result arrived on the error pump (pump 1), instead of diff --git a/indra/llcommon/lleventcoro.h b/indra/llcommon/lleventcoro.h index daf9360a2e..abbeeaa373 100755 --- a/indra/llcommon/lleventcoro.h +++ b/indra/llcommon/lleventcoro.h @@ -29,6 +29,8 @@ #if ! defined(LL_LLEVENTCORO_H) #define LL_LLEVENTCORO_H +#include +#include #include #include #include @@ -100,6 +102,9 @@ LLVoidListener voidlistener(const LISTENER& listener) namespace LLEventDetail { + /// Implementation for listenerNameForCoro(), see below + LL_COMMON_API std::string listenerNameForCoroImpl(const void* self_id); + /** * waitForEventOn() permits a coroutine to temporarily listen on an * LLEventPump any number of times. We don't really want to have to ask @@ -111,9 +116,21 @@ namespace LLEventDetail * call waitForEventOn() any number of times, we don't really want to * consume an arbitrary number of generated inventName()s: that namespace, * though large, is nonetheless finite. So we memoize an invented name for - * each distinct coroutine instance. + * each distinct coroutine instance (each different 'self' object). We + * can't know the type of 'self', because it depends on the coroutine + * body's signature. So we cast its address to void*, looking for distinct + * pointer values. Yes, that means that an early coroutine could cache a + * value here, then be destroyed, only to be supplanted by a later + * coroutine (of the same or different type), and we'll end up + * "recognizing" the second one and reusing the listener name -- but + * that's okay, since it won't collide with any listener name used by the + * earlier coroutine since that earlier coroutine no longer exists. */ - std::string listenerNameForCoro(); + template + std::string listenerNameForCoro(COROUTINE_SELF& self) + { + return listenerNameForCoroImpl(self.get_id()); + } /** * Implement behavior described for postAndWait()'s @a replyPumpNamePath @@ -142,7 +159,7 @@ namespace LLEventDetail * convenience: the difference between this function and the sequence * @code * requestPump.post(myEvent); - * LLSD reply = waitForEventOn(replyPump); + * LLSD reply = waitForEventOn(self, replyPump); * @endcode * is that the sequence above fails if the reply is posted immediately on * @a replyPump, that is, before requestPump.post() returns. In the @@ -184,16 +201,51 @@ namespace LLEventDetail * @a replyPumpNamePath specifies the entry in the lowest-level structure in * @a event into which to store replyPump.getName(). */ -LLSD postAndWait(const LLSD& event, const LLEventPumpOrPumpName& requestPump, - const LLEventPumpOrPumpName& replyPump, const LLSD& replyPumpNamePath=LLSD()); +template +LLSD postAndWait(SELF& self, const LLSD& event, const LLEventPumpOrPumpName& requestPump, + const LLEventPumpOrPumpName& replyPump, const LLSD& replyPumpNamePath=LLSD()) +{ + // declare the future + boost::dcoroutines::future future(self); + // make a callback that will assign a value to the future, and listen on + // the specified LLEventPump with that callback + std::string listenerName(LLEventDetail::listenerNameForCoro(self)); + LLTempBoundListener connection( + replyPump.getPump().listen(listenerName, + voidlistener(boost::dcoroutines::make_callback(future)))); + // skip the "post" part if requestPump is default-constructed + if (requestPump) + { + // If replyPumpNamePath is non-empty, store the replyPump name in the + // request event. + LLSD modevent(event); + LLEventDetail::storeToLLSDPath(modevent, replyPumpNamePath, replyPump.getPump().getName()); + LL_DEBUGS("lleventcoro") << "postAndWait(): coroutine " << listenerName + << " posting to " << requestPump.getPump().getName() + << LL_ENDL; + + // *NOTE:Mani - Removed because modevent could contain user's hashed passwd. + // << ": " << modevent << LL_ENDL; + requestPump.getPump().post(modevent); + } + LL_DEBUGS("lleventcoro") << "postAndWait(): coroutine " << listenerName + << " about to wait on LLEventPump " << replyPump.getPump().getName() + << LL_ENDL; + // trying to dereference ("resolve") the future makes us wait for it + LLSD value(*future); + LL_DEBUGS("lleventcoro") << "postAndWait(): coroutine " << listenerName + << " resuming with " << value << LL_ENDL; + // returning should disconnect the connection + return value; +} /// Wait for the next event on the specified LLEventPump. Pass either the /// LLEventPump& or its string name. -inline -LLSD waitForEventOn(const LLEventPumpOrPumpName& pump) +template +LLSD waitForEventOn(SELF& self, const LLEventPumpOrPumpName& pump) { // This is now a convenience wrapper for postAndWait(). - return postAndWait(LLSD(), LLEventPumpOrPumpName(), pump); + return postAndWait(self, LLSD(), LLEventPumpOrPumpName(), pump); } /// return type for two-pump variant of waitForEventOn() @@ -261,7 +313,7 @@ namespace LLEventDetail * I'd have preferred to overload the name postAndWait() for both signatures. * But consider the following ambiguous call: * @code - * postAndWait(LLSD(), requestPump, replyPump, "someString"); + * postAndWait(self, LLSD(), requestPump, replyPump, "someString"); * @endcode * "someString" could be converted to either LLSD (@a replyPumpNamePath for * the single-pump function) or LLEventOrPumpName (@a replyPump1 for two-pump @@ -270,29 +322,69 @@ namespace LLEventDetail * It seems less burdensome to write postAndWait2() than to write either * LLSD("someString") or LLEventOrPumpName("someString"). */ -LLEventWithID postAndWait2(const LLSD& event, +template +LLEventWithID postAndWait2(SELF& self, const LLSD& event, const LLEventPumpOrPumpName& requestPump, const LLEventPumpOrPumpName& replyPump0, const LLEventPumpOrPumpName& replyPump1, const LLSD& replyPump0NamePath=LLSD(), - const LLSD& replyPump1NamePath=LLSD()); + const LLSD& replyPump1NamePath=LLSD()) +{ + // declare the future + boost::dcoroutines::future future(self); + // either callback will assign a value to this future; listen on + // each specified LLEventPump with a callback + std::string name(LLEventDetail::listenerNameForCoro(self)); + LLTempBoundListener connection0( + replyPump0.getPump().listen(name + "a", + LLEventDetail::wfeoh(boost::dcoroutines::make_callback(future), 0))); + LLTempBoundListener connection1( + replyPump1.getPump().listen(name + "b", + LLEventDetail::wfeoh(boost::dcoroutines::make_callback(future), 1))); + // skip the "post" part if requestPump is default-constructed + if (requestPump) + { + // If either replyPumpNamePath is non-empty, store the corresponding + // replyPump name in the request event. + LLSD modevent(event); + LLEventDetail::storeToLLSDPath(modevent, replyPump0NamePath, + replyPump0.getPump().getName()); + LLEventDetail::storeToLLSDPath(modevent, replyPump1NamePath, + replyPump1.getPump().getName()); + LL_DEBUGS("lleventcoro") << "postAndWait2(): coroutine " << name + << " posting to " << requestPump.getPump().getName() + << ": " << modevent << LL_ENDL; + requestPump.getPump().post(modevent); + } + LL_DEBUGS("lleventcoro") << "postAndWait2(): coroutine " << name + << " about to wait on LLEventPumps " << replyPump0.getPump().getName() + << ", " << replyPump1.getPump().getName() << LL_ENDL; + // trying to dereference ("resolve") the future makes us wait for it + LLEventWithID value(*future); + LL_DEBUGS("lleventcoro") << "postAndWait(): coroutine " << name + << " resuming with (" << value.first << ", " << value.second << ")" + << LL_ENDL; + // returning should disconnect both connections + return value; +} /** * Wait for the next event on either of two specified LLEventPumps. */ -inline +template LLEventWithID -waitForEventOn(const LLEventPumpOrPumpName& pump0, const LLEventPumpOrPumpName& pump1) +waitForEventOn(SELF& self, + const LLEventPumpOrPumpName& pump0, const LLEventPumpOrPumpName& pump1) { // This is now a convenience wrapper for postAndWait2(). - return postAndWait2(LLSD(), LLEventPumpOrPumpName(), pump0, pump1); + return postAndWait2(self, LLSD(), LLEventPumpOrPumpName(), pump0, pump1); } /** * Helper for the two-pump variant of waitForEventOn(), e.g.: * * @code - * LLSD reply = errorException(waitForEventOn(replyPump, errorPump), + * LLSD reply = errorException(waitForEventOn(self, replyPump, errorPump), * "error response from login.cgi"); * @endcode * @@ -362,16 +454,26 @@ public: /** * Wait for an event on this LLEventPump. + * + * @note + * The other major usage pattern we considered was to bind @c self at + * LLCoroEventPump construction time, which would avoid passing the + * parameter to each wait() call. But if we were going to bind @c self as + * a class member, we'd need to specify a class template parameter + * indicating its type. The big advantage of passing it to the wait() call + * is that the type can be implicit. */ - LLSD wait() + template + LLSD wait(SELF& self) { - return ::waitForEventOn(mPump); + return waitForEventOn(self, mPump); } - LLSD postAndWait(const LLSD& event, const LLEventPumpOrPumpName& requestPump, + template + LLSD postAndWait(SELF& self, const LLSD& event, const LLEventPumpOrPumpName& requestPump, const LLSD& replyPumpNamePath=LLSD()) { - return ::postAndWait(event, requestPump, mPump, replyPumpNamePath); + return ::postAndWait(self, event, requestPump, mPump, replyPumpNamePath); } private: @@ -407,49 +509,55 @@ public: /// request pump 1 LLEventPump& getPump1() { return mPump1; } - /// waitForEventOn(either of our two LLEventPumps) - LLEventWithID wait() + /// waitForEventOn(self, either of our two LLEventPumps) + template + LLEventWithID wait(SELF& self) { - return waitForEventOn(mPump0, mPump1); + return waitForEventOn(self, mPump0, mPump1); } - /// errorException(wait()) - LLSD waitWithException() + /// errorException(wait(self)) + template + LLSD waitWithException(SELF& self) { - return errorException(wait(), std::string("Error event on ") + getName1()); + return errorException(wait(self), std::string("Error event on ") + getName1()); } - /// errorLog(wait()) - LLSD waitWithLog() + /// errorLog(wait(self)) + template + LLSD waitWithLog(SELF& self) { - return errorLog(wait(), std::string("Error event on ") + getName1()); + return errorLog(wait(self), std::string("Error event on ") + getName1()); } - LLEventWithID postAndWait(const LLSD& event, + template + LLEventWithID postAndWait(SELF& self, const LLSD& event, const LLEventPumpOrPumpName& requestPump, const LLSD& replyPump0NamePath=LLSD(), const LLSD& replyPump1NamePath=LLSD()) { - return postAndWait2(event, requestPump, mPump0, mPump1, + return postAndWait2(self, event, requestPump, mPump0, mPump1, replyPump0NamePath, replyPump1NamePath); } - LLSD postAndWaitWithException(const LLSD& event, + template + LLSD postAndWaitWithException(SELF& self, const LLSD& event, const LLEventPumpOrPumpName& requestPump, const LLSD& replyPump0NamePath=LLSD(), const LLSD& replyPump1NamePath=LLSD()) { - return errorException(postAndWait(event, requestPump, + return errorException(postAndWait(self, event, requestPump, replyPump0NamePath, replyPump1NamePath), std::string("Error event on ") + getName1()); } - LLSD postAndWaitWithLog(const LLSD& event, + template + LLSD postAndWaitWithLog(SELF& self, const LLSD& event, const LLEventPumpOrPumpName& requestPump, const LLSD& replyPump0NamePath=LLSD(), const LLSD& replyPump1NamePath=LLSD()) { - return errorLog(postAndWait(event, requestPump, + return errorLog(postAndWait(self, event, requestPump, replyPump0NamePath, replyPump1NamePath), std::string("Error event on ") + getName1()); } diff --git a/indra/llcommon/tests/lleventcoro_test.cpp b/indra/llcommon/tests/lleventcoro_test.cpp index da927038ab..2096807e53 100755 --- a/indra/llcommon/tests/lleventcoro_test.cpp +++ b/indra/llcommon/tests/lleventcoro_test.cpp @@ -82,7 +82,6 @@ #include "llevents.h" #include "tests/wrapllerrs.h" #include "stringize.h" -#include "llcoros.h" #include "lleventcoro.h" #include "../test/debug.h" @@ -122,6 +121,9 @@ typedef coroutine match_coroutine_type; /***************************************************************************** * Test helpers *****************************************************************************/ +// I suspect this will be typical of coroutines used in Linden software +typedef boost::dcoroutines::coroutine coroutine_type; + /// Simulate an event API whose response is immediate: sent on receipt of the /// initial request, rather than after some delay. This is the case that /// distinguishes postAndWait() from calling post(), then calling @@ -160,7 +162,306 @@ private: *****************************************************************************/ namespace tut { - struct coroutine_data {}; + struct coroutine_data + { + // Define coroutine bodies as methods here so they can use ensure*() + + void explicit_wait(coroutine_type::self& self) + { + BEGIN + { + // ... do whatever preliminary stuff must happen ... + + // declare the future + boost::dcoroutines::future future(self); + // tell the future what to wait for + LLTempBoundListener connection( + LLEventPumps::instance().obtain("source").listen("coro", voidlistener(boost::dcoroutines::make_callback(future)))); + ensure("Not yet", ! future); + // attempting to dereference ("resolve") the future causes the calling + // coroutine to wait for it + debug("about to wait"); + result = *future; + ensure("Got it", future); + } + END + } + + void waitForEventOn1(coroutine_type::self& self) + { + BEGIN + { + result = waitForEventOn(self, "source"); + } + END + } + + void waitForEventOn2(coroutine_type::self& self) + { + BEGIN + { + LLEventWithID pair = waitForEventOn(self, "reply", "error"); + result = pair.first; + which = pair.second; + debug(STRINGIZE("result = " << result << ", which = " << which)); + } + END + } + + void postAndWait1(coroutine_type::self& self) + { + BEGIN + { + result = postAndWait(self, + LLSDMap("value", 17), // request event + immediateAPI.getPump(), // requestPump + "reply1", // replyPump + "reply"); // request["reply"] = name + } + END + } + + void postAndWait2(coroutine_type::self& self) + { + BEGIN + { + LLEventWithID pair = ::postAndWait2(self, + LLSDMap("value", 18), + immediateAPI.getPump(), + "reply2", + "error2", + "reply", + "error"); + result = pair.first; + which = pair.second; + debug(STRINGIZE("result = " << result << ", which = " << which)); + } + END + } + + void postAndWait2_1(coroutine_type::self& self) + { + BEGIN + { + LLEventWithID pair = ::postAndWait2(self, + LLSDMap("value", 18)("fail", LLSD()), + immediateAPI.getPump(), + "reply2", + "error2", + "reply", + "error"); + result = pair.first; + which = pair.second; + debug(STRINGIZE("result = " << result << ", which = " << which)); + } + END + } + + void coroPump(coroutine_type::self& self) + { + BEGIN + { + LLCoroEventPump waiter; + replyName = waiter.getName(); + result = waiter.wait(self); + } + END + } + + void coroPumpPost(coroutine_type::self& self) + { + BEGIN + { + LLCoroEventPump waiter; + result = waiter.postAndWait(self, LLSDMap("value", 17), + immediateAPI.getPump(), "reply"); + } + END + } + + void coroPumps(coroutine_type::self& self) + { + BEGIN + { + LLCoroEventPumps waiter; + replyName = waiter.getName0(); + errorName = waiter.getName1(); + LLEventWithID pair(waiter.wait(self)); + result = pair.first; + which = pair.second; + } + END + } + + void coroPumpsNoEx(coroutine_type::self& self) + { + BEGIN + { + LLCoroEventPumps waiter; + replyName = waiter.getName0(); + errorName = waiter.getName1(); + result = waiter.waitWithException(self); + } + END + } + + void coroPumpsEx(coroutine_type::self& self) + { + BEGIN + { + LLCoroEventPumps waiter; + replyName = waiter.getName0(); + errorName = waiter.getName1(); + try + { + result = waiter.waitWithException(self); + debug("no exception"); + } + catch (const LLErrorEvent& e) + { + debug(STRINGIZE("exception " << e.what())); + errordata = e.getData(); + } + } + END + } + + void coroPumpsNoLog(coroutine_type::self& self) + { + BEGIN + { + LLCoroEventPumps waiter; + replyName = waiter.getName0(); + errorName = waiter.getName1(); + result = waiter.waitWithLog(self); + } + END + } + + void coroPumpsLog(coroutine_type::self& self) + { + BEGIN + { + LLCoroEventPumps waiter; + replyName = waiter.getName0(); + errorName = waiter.getName1(); + WrapLLErrs capture; + try + { + result = waiter.waitWithLog(self); + debug("no exception"); + } + catch (const WrapLLErrs::FatalException& e) + { + debug(STRINGIZE("exception " << e.what())); + threw = e.what(); + } + } + END + } + + void coroPumpsPost(coroutine_type::self& self) + { + BEGIN + { + LLCoroEventPumps waiter; + LLEventWithID pair(waiter.postAndWait(self, LLSDMap("value", 23), + immediateAPI.getPump(), "reply", "error")); + result = pair.first; + which = pair.second; + } + END + } + + void coroPumpsPost_1(coroutine_type::self& self) + { + BEGIN + { + LLCoroEventPumps waiter; + LLEventWithID pair( + waiter.postAndWait(self, LLSDMap("value", 23)("fail", LLSD()), + immediateAPI.getPump(), "reply", "error")); + result = pair.first; + which = pair.second; + } + END + } + + void coroPumpsPostNoEx(coroutine_type::self& self) + { + BEGIN + { + LLCoroEventPumps waiter; + result = waiter.postAndWaitWithException(self, LLSDMap("value", 8), + immediateAPI.getPump(), "reply", "error"); + } + END + } + + void coroPumpsPostEx(coroutine_type::self& self) + { + BEGIN + { + LLCoroEventPumps waiter; + try + { + result = waiter.postAndWaitWithException(self, + LLSDMap("value", 9)("fail", LLSD()), + immediateAPI.getPump(), "reply", "error"); + debug("no exception"); + } + catch (const LLErrorEvent& e) + { + debug(STRINGIZE("exception " << e.what())); + errordata = e.getData(); + } + } + END + } + + void coroPumpsPostNoLog(coroutine_type::self& self) + { + BEGIN + { + LLCoroEventPumps waiter; + result = waiter.postAndWaitWithLog(self, LLSDMap("value", 30), + immediateAPI.getPump(), "reply", "error"); + } + END + } + + void coroPumpsPostLog(coroutine_type::self& self) + { + BEGIN + { + LLCoroEventPumps waiter; + WrapLLErrs capture; + try + { + result = waiter.postAndWaitWithLog(self, + LLSDMap("value", 31)("fail", LLSD()), + immediateAPI.getPump(), "reply", "error"); + debug("no exception"); + } + catch (const WrapLLErrs::FatalException& e) + { + debug(STRINGIZE("exception " << e.what())); + threw = e.what(); + } + } + END + } + + void ensure_done(coroutine_type& coro) + { + ensure("coroutine complete", ! coro); + } + + ImmediateAPI immediateAPI; + std::string replyName, errorName, threw; + LLSD result, errordata; + int which; + }; typedef test_group coroutine_group; typedef coroutine_group::object object; coroutine_group coroutinegrp("coroutine"); @@ -210,57 +511,16 @@ namespace tut ensure("done", ! matcher); } - // use static data so we can intersperse coroutine functions with the - // tests that engage them - ImmediateAPI immediateAPI; - std::string replyName, errorName, threw; - LLSD result, errordata; - int which; - - // reinit vars at the start of each test - void clear() - { - replyName.clear(); - errorName.clear(); - threw.clear(); - result = LLSD(); - errordata = LLSD(); - which = 0; - } - - void explicit_wait(boost::dcoroutines::coroutine::self& self) - { - BEGIN - { - // ... do whatever preliminary stuff must happen ... - - // declare the future - boost::dcoroutines::future future(self); - // tell the future what to wait for - LLTempBoundListener connection( - LLEventPumps::instance().obtain("source").listen("coro", voidlistener(boost::dcoroutines::make_callback(future)))); - ensure("Not yet", ! future); - // attempting to dereference ("resolve") the future causes the calling - // coroutine to wait for it - debug("about to wait"); - result = *future; - ensure("Got it", future); - } - END - } - template<> template<> void object::test<2>() { - clear(); set_test_name("explicit_wait"); DEBUG; // Construct the coroutine instance that will run explicit_wait. // Pass the ctor a callable that accepts the coroutine_type::self // param passed by the library. - boost::dcoroutines::coroutine - coro(explicit_wait); + coroutine_type coro(boost::bind(&coroutine_data::explicit_wait, this, _1)); // Start the coroutine coro(std::nothrow); // When the coroutine waits for the event pump, it returns here. @@ -268,56 +528,37 @@ namespace tut // Satisfy the wait. LLEventPumps::instance().obtain("source").post("received"); // Now wait for the coroutine to complete. - ensure("coroutine complete", ! coro); + ensure_done(coro); // ensure the coroutine ran and woke up again with the intended result ensure_equals(result.asString(), "received"); } - void waitForEventOn1() - { - BEGIN - { - result = waitForEventOn("source"); - } - END - } - template<> template<> void object::test<3>() { - clear(); set_test_name("waitForEventOn1"); DEBUG; - LLCoros::instance().launch("test<3>", waitForEventOn1); + coroutine_type coro(boost::bind(&coroutine_data::waitForEventOn1, this, _1)); + coro(std::nothrow); debug("about to send"); LLEventPumps::instance().obtain("source").post("received"); debug("back from send"); + ensure_done(coro); ensure_equals(result.asString(), "received"); } - void waitForEventOn2() - { - BEGIN - { - LLEventWithID pair = waitForEventOn("reply", "error"); - result = pair.first; - which = pair.second; - debug(STRINGIZE("result = " << result << ", which = " << which)); - } - END - } - template<> template<> void object::test<4>() { - clear(); set_test_name("waitForEventOn2 reply"); { DEBUG; - LLCoros::instance().launch("test<4>", waitForEventOn2); + coroutine_type coro(boost::bind(&coroutine_data::waitForEventOn2, this, _1)); + coro(std::nothrow); debug("about to send"); LLEventPumps::instance().obtain("reply").post("received"); debug("back from send"); + ensure_done(coro); } ensure_equals(result.asString(), "received"); ensure_equals("which pump", which, 0); @@ -326,65 +567,43 @@ namespace tut template<> template<> void object::test<5>() { - clear(); set_test_name("waitForEventOn2 error"); DEBUG; - LLCoros::instance().launch("test<5>", waitForEventOn2); + coroutine_type coro(boost::bind(&coroutine_data::waitForEventOn2, this, _1)); + coro(std::nothrow); debug("about to send"); LLEventPumps::instance().obtain("error").post("badness"); debug("back from send"); + ensure_done(coro); ensure_equals(result.asString(), "badness"); ensure_equals("which pump", which, 1); } - void coroPump() - { - BEGIN - { - LLCoroEventPump waiter; - replyName = waiter.getName(); - result = waiter.wait(); - } - END - } - template<> template<> void object::test<6>() { - clear(); set_test_name("coroPump"); DEBUG; - LLCoros::instance().launch("test<6>", coroPump); + coroutine_type coro(boost::bind(&coroutine_data::coroPump, this, _1)); + coro(std::nothrow); debug("about to send"); LLEventPumps::instance().obtain(replyName).post("received"); debug("back from send"); + ensure_done(coro); ensure_equals(result.asString(), "received"); } - void coroPumps() - { - BEGIN - { - LLCoroEventPumps waiter; - replyName = waiter.getName0(); - errorName = waiter.getName1(); - LLEventWithID pair(waiter.wait()); - result = pair.first; - which = pair.second; - } - END - } - template<> template<> void object::test<7>() { - clear(); set_test_name("coroPumps reply"); DEBUG; - LLCoros::instance().launch("test<7>", coroPumps); + coroutine_type coro(boost::bind(&coroutine_data::coroPumps, this, _1)); + coro(std::nothrow); debug("about to send"); LLEventPumps::instance().obtain(replyName).post("received"); debug("back from send"); + ensure_done(coro); ensure_equals(result.asString(), "received"); ensure_equals("which pump", which, 0); } @@ -392,389 +611,188 @@ namespace tut template<> template<> void object::test<8>() { - clear(); set_test_name("coroPumps error"); DEBUG; - LLCoros::instance().launch("test<8>", coroPumps); + coroutine_type coro(boost::bind(&coroutine_data::coroPumps, this, _1)); + coro(std::nothrow); debug("about to send"); LLEventPumps::instance().obtain(errorName).post("badness"); debug("back from send"); + ensure_done(coro); ensure_equals(result.asString(), "badness"); ensure_equals("which pump", which, 1); } - void coroPumpsNoEx() - { - BEGIN - { - LLCoroEventPumps waiter; - replyName = waiter.getName0(); - errorName = waiter.getName1(); - result = waiter.waitWithException(); - } - END - } - template<> template<> void object::test<9>() { - clear(); set_test_name("coroPumpsNoEx"); DEBUG; - LLCoros::instance().launch("test<9>", coroPumpsNoEx); + coroutine_type coro(boost::bind(&coroutine_data::coroPumpsNoEx, this, _1)); + coro(std::nothrow); debug("about to send"); LLEventPumps::instance().obtain(replyName).post("received"); debug("back from send"); + ensure_done(coro); ensure_equals(result.asString(), "received"); } - void coroPumpsEx() - { - BEGIN - { - LLCoroEventPumps waiter; - replyName = waiter.getName0(); - errorName = waiter.getName1(); - try - { - result = waiter.waitWithException(); - debug("no exception"); - } - catch (const LLErrorEvent& e) - { - debug(STRINGIZE("exception " << e.what())); - errordata = e.getData(); - } - } - END - } - template<> template<> void object::test<10>() { - clear(); set_test_name("coroPumpsEx"); DEBUG; - LLCoros::instance().launch("test<10>", coroPumpsEx); + coroutine_type coro(boost::bind(&coroutine_data::coroPumpsEx, this, _1)); + coro(std::nothrow); debug("about to send"); LLEventPumps::instance().obtain(errorName).post("badness"); debug("back from send"); + ensure_done(coro); ensure("no result", result.isUndefined()); ensure_equals("got error", errordata.asString(), "badness"); } - void coroPumpsNoLog() - { - BEGIN - { - LLCoroEventPumps waiter; - replyName = waiter.getName0(); - errorName = waiter.getName1(); - result = waiter.waitWithLog(); - } - END - } - template<> template<> void object::test<11>() { - clear(); set_test_name("coroPumpsNoLog"); DEBUG; - LLCoros::instance().launch("test<11>", coroPumpsNoLog); + coroutine_type coro(boost::bind(&coroutine_data::coroPumpsNoLog, this, _1)); + coro(std::nothrow); debug("about to send"); LLEventPumps::instance().obtain(replyName).post("received"); debug("back from send"); + ensure_done(coro); ensure_equals(result.asString(), "received"); } - void coroPumpsLog() - { - BEGIN - { - LLCoroEventPumps waiter; - replyName = waiter.getName0(); - errorName = waiter.getName1(); - WrapLLErrs capture; - try - { - result = waiter.waitWithLog(); - debug("no exception"); - } - catch (const WrapLLErrs::FatalException& e) - { - debug(STRINGIZE("exception " << e.what())); - threw = e.what(); - } - } - END - } - template<> template<> void object::test<12>() { - clear(); set_test_name("coroPumpsLog"); DEBUG; - LLCoros::instance().launch("test<12>", coroPumpsLog); + coroutine_type coro(boost::bind(&coroutine_data::coroPumpsLog, this, _1)); + coro(std::nothrow); debug("about to send"); LLEventPumps::instance().obtain(errorName).post("badness"); debug("back from send"); + ensure_done(coro); ensure("no result", result.isUndefined()); ensure_contains("got error", threw, "badness"); } - void postAndWait1() - { - BEGIN - { - result = postAndWait(LLSDMap("value", 17), // request event - immediateAPI.getPump(), // requestPump - "reply1", // replyPump - "reply"); // request["reply"] = name - } - END - } - template<> template<> void object::test<13>() { - clear(); set_test_name("postAndWait1"); DEBUG; - LLCoros::instance().launch("test<13>", postAndWait1); + coroutine_type coro(boost::bind(&coroutine_data::postAndWait1, this, _1)); + coro(std::nothrow); + ensure_done(coro); ensure_equals(result.asInteger(), 18); } - void postAndWait2() - { - BEGIN - { - LLEventWithID pair = ::postAndWait2(LLSDMap("value", 18), - immediateAPI.getPump(), - "reply2", - "error2", - "reply", - "error"); - result = pair.first; - which = pair.second; - debug(STRINGIZE("result = " << result << ", which = " << which)); - } - END - } - template<> template<> void object::test<14>() { - clear(); set_test_name("postAndWait2"); DEBUG; - LLCoros::instance().launch("test<14>", postAndWait2); + coroutine_type coro(boost::bind(&coroutine_data::postAndWait2, this, _1)); + coro(std::nothrow); + ensure_done(coro); ensure_equals(result.asInteger(), 19); ensure_equals(which, 0); } - void postAndWait2_1() - { - BEGIN - { - LLEventWithID pair = ::postAndWait2(LLSDMap("value", 18)("fail", LLSD()), - immediateAPI.getPump(), - "reply2", - "error2", - "reply", - "error"); - result = pair.first; - which = pair.second; - debug(STRINGIZE("result = " << result << ", which = " << which)); - } - END - } - template<> template<> void object::test<15>() { - clear(); set_test_name("postAndWait2_1"); DEBUG; - LLCoros::instance().launch("test<15>", postAndWait2_1); + coroutine_type coro(boost::bind(&coroutine_data::postAndWait2_1, this, _1)); + coro(std::nothrow); + ensure_done(coro); ensure_equals(result.asInteger(), 19); ensure_equals(which, 1); } - void coroPumpPost() - { - BEGIN - { - LLCoroEventPump waiter; - result = waiter.postAndWait(LLSDMap("value", 17), - immediateAPI.getPump(), "reply"); - } - END - } - template<> template<> void object::test<16>() { - clear(); set_test_name("coroPumpPost"); DEBUG; - LLCoros::instance().launch("test<16>", coroPumpPost); + coroutine_type coro(boost::bind(&coroutine_data::coroPumpPost, this, _1)); + coro(std::nothrow); + ensure_done(coro); ensure_equals(result.asInteger(), 18); } - void coroPumpsPost() - { - BEGIN - { - LLCoroEventPumps waiter; - LLEventWithID pair(waiter.postAndWait(LLSDMap("value", 23), - immediateAPI.getPump(), "reply", "error")); - result = pair.first; - which = pair.second; - } - END - } - template<> template<> void object::test<17>() { - clear(); set_test_name("coroPumpsPost reply"); DEBUG; - LLCoros::instance().launch("test<17>", coroPumpsPost); + coroutine_type coro(boost::bind(&coroutine_data::coroPumpsPost, this, _1)); + coro(std::nothrow); + ensure_done(coro); ensure_equals(result.asInteger(), 24); ensure_equals("which pump", which, 0); } - void coroPumpsPost_1() - { - BEGIN - { - LLCoroEventPumps waiter; - LLEventWithID pair( - waiter.postAndWait(LLSDMap("value", 23)("fail", LLSD()), - immediateAPI.getPump(), "reply", "error")); - result = pair.first; - which = pair.second; - } - END - } - template<> template<> void object::test<18>() { - clear(); set_test_name("coroPumpsPost error"); DEBUG; - LLCoros::instance().launch("test<18>", coroPumpsPost_1); + coroutine_type coro(boost::bind(&coroutine_data::coroPumpsPost_1, this, _1)); + coro(std::nothrow); + ensure_done(coro); ensure_equals(result.asInteger(), 24); ensure_equals("which pump", which, 1); } - void coroPumpsPostNoEx() - { - BEGIN - { - LLCoroEventPumps waiter; - result = waiter.postAndWaitWithException(LLSDMap("value", 8), - immediateAPI.getPump(), "reply", "error"); - } - END - } - template<> template<> void object::test<19>() { - clear(); set_test_name("coroPumpsPostNoEx"); DEBUG; - LLCoros::instance().launch("test<19>", coroPumpsPostNoEx); + coroutine_type coro(boost::bind(&coroutine_data::coroPumpsPostNoEx, this, _1)); + coro(std::nothrow); + ensure_done(coro); ensure_equals(result.asInteger(), 9); } - void coroPumpsPostEx() - { - BEGIN - { - LLCoroEventPumps waiter; - try - { - result = waiter.postAndWaitWithException( - LLSDMap("value", 9)("fail", LLSD()), - immediateAPI.getPump(), "reply", "error"); - debug("no exception"); - } - catch (const LLErrorEvent& e) - { - debug(STRINGIZE("exception " << e.what())); - errordata = e.getData(); - } - } - END - } - template<> template<> void object::test<20>() { - clear(); set_test_name("coroPumpsPostEx"); DEBUG; - LLCoros::instance().launch("test<20>", coroPumpsPostEx); + coroutine_type coro(boost::bind(&coroutine_data::coroPumpsPostEx, this, _1)); + coro(std::nothrow); + ensure_done(coro); ensure("no result", result.isUndefined()); ensure_equals("got error", errordata.asInteger(), 10); } - void coroPumpsPostNoLog() - { - BEGIN - { - LLCoroEventPumps waiter; - result = waiter.postAndWaitWithLog(LLSDMap("value", 30), - immediateAPI.getPump(), "reply", "error"); - } - END - } - template<> template<> void object::test<21>() { - clear(); set_test_name("coroPumpsPostNoLog"); DEBUG; - LLCoros::instance().launch("test<21>", coroPumpsPostNoLog); + coroutine_type coro(boost::bind(&coroutine_data::coroPumpsPostNoLog, this, _1)); + coro(std::nothrow); + ensure_done(coro); ensure_equals(result.asInteger(), 31); } - void coroPumpsPostLog() - { - BEGIN - { - LLCoroEventPumps waiter; - WrapLLErrs capture; - try - { - result = waiter.postAndWaitWithLog( - LLSDMap("value", 31)("fail", LLSD()), - immediateAPI.getPump(), "reply", "error"); - debug("no exception"); - } - catch (const WrapLLErrs::FatalException& e) - { - debug(STRINGIZE("exception " << e.what())); - threw = e.what(); - } - } - END - } - template<> template<> void object::test<22>() { - clear(); set_test_name("coroPumpsPostLog"); DEBUG; - LLCoros::instance().launch("test<22>", coroPumpsPostLog); + coroutine_type coro(boost::bind(&coroutine_data::coroPumpsPostLog, this, _1)); + coro(std::nothrow); + ensure_done(coro); ensure("no result", result.isUndefined()); ensure_contains("got error", threw, "32"); } diff --git a/indra/llmessage/CMakeLists.txt b/indra/llmessage/CMakeLists.txt index ba6e9d3939..49f825d8f8 100755 --- a/indra/llmessage/CMakeLists.txt +++ b/indra/llmessage/CMakeLists.txt @@ -256,8 +256,8 @@ if (LL_TESTS) ${LLMESSAGE_LIBRARIES} ${LLCOREHTTP_LIBRARIES} ${JSONCPP_LIBRARIES} - ${BOOST_COROUTINE_LIBRARY} ${BOOST_CONTEXT_LIBRARY} + ${BOOST_COROUTINE_LIBRARY} ${GOOGLEMOCK_LIBRARIES} ) diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index d262862c80..7014048021 100755 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -137,8 +137,8 @@ namespace LLAvatarNameCache bool expirationFromCacheControl(const LLSD& headers, F64 *expires); - // This is a coroutine. - void requestAvatarNameCache_(std::string url, std::vector agentIds); + // This is a coroutine. The only parameter that can be specified as a reference is the self + void requestAvatarNameCache_(LLCoros::self& self, std::string url, std::vector agentIds); void handleAvNameCacheSuccess(const LLSD &data, const LLSD &httpResult); } @@ -185,9 +185,9 @@ namespace LLAvatarNameCache // Coroutine for sending and processing avatar name cache requests. // Do not call directly. See documentation in lleventcoro.h and llcoro.h for // further explanation. -void LLAvatarNameCache::requestAvatarNameCache_(std::string url, std::vector agentIds) +void LLAvatarNameCache::requestAvatarNameCache_(LLCoros::self& self, std::string url, std::vector agentIds) { - LL_DEBUGS("AvNameCache") << "Entering coroutine " << LLCoros::instance().getName() + LL_DEBUGS("AvNameCache") << "Entering coroutine " << LLCoros::instance().getName(self) << " with url '" << url << "', requesting " << agentIds.size() << " Agent Ids" << LL_ENDL; try @@ -195,7 +195,7 @@ void LLAvatarNameCache::requestAvatarNameCache_(std::string url, std::vectorgetReplyPump()); + LLSD results = waitForEventOn(self, handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; } -LLSD HttpCoroutineAdapter::getAndYield(LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::getAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, const std::string & url, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { LLEventStream replyPump(mAdapterName + "Reply", true); HttpCoroHandler::ptr_t httpHandler = HttpCoroHandler::ptr_t(new HttpCoroLLSDHandler(replyPump)); - return getAndYield_(request, url, options, headers, httpHandler); + return getAndYield_(self, request, url, options, headers, httpHandler); } -LLSD HttpCoroutineAdapter::getRawAndYield(LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::getRawAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, const std::string & url, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { LLEventStream replyPump(mAdapterName + "Reply", true); HttpCoroHandler::ptr_t httpHandler = HttpCoroHandler::ptr_t(new HttpCoroRawHandler(replyPump)); - return getAndYield_(request, url, options, headers, httpHandler); + return getAndYield_(self, request, url, options, headers, httpHandler); } -LLSD HttpCoroutineAdapter::getJsonAndYield(LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::getJsonAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, const std::string & url, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { LLEventStream replyPump(mAdapterName + "Reply", true); HttpCoroHandler::ptr_t httpHandler = HttpCoroHandler::ptr_t(new HttpCoroJSONHandler(replyPump)); - return getAndYield_(request, url, options, headers, httpHandler); + return getAndYield_(self, request, url, options, headers, httpHandler); } -LLSD HttpCoroutineAdapter::getAndYield_(LLCore::HttpRequest::ptr_t &request, +LLSD HttpCoroutineAdapter::getAndYield_(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, const std::string & url, LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler) @@ -790,24 +790,24 @@ LLSD HttpCoroutineAdapter::getAndYield_(LLCore::HttpRequest::ptr_t &request, } saveState(hhandle, request, handler); - LLSD results = waitForEventOn(handler->getReplyPump()); + LLSD results = waitForEventOn(self, handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; } -LLSD HttpCoroutineAdapter::deleteAndYield(LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::deleteAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, const std::string & url, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { LLEventStream replyPump(mAdapterName + "Reply", true); HttpCoroHandler::ptr_t httpHandler = HttpCoroHandler::ptr_t(new HttpCoroLLSDHandler(replyPump)); - return deleteAndYield_(request, url, options, headers, httpHandler); + return deleteAndYield_(self, request, url, options, headers, httpHandler); } -LLSD HttpCoroutineAdapter::deleteAndYield_(LLCore::HttpRequest::ptr_t &request, +LLSD HttpCoroutineAdapter::deleteAndYield_(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, const std::string & url, LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler) { @@ -825,7 +825,7 @@ LLSD HttpCoroutineAdapter::deleteAndYield_(LLCore::HttpRequest::ptr_t &request, } saveState(hhandle, request, handler); - LLSD results = waitForEventOn(handler->getReplyPump()); + LLSD results = waitForEventOn(self, handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; @@ -907,7 +907,7 @@ LLCore::HttpStatus HttpCoroutineAdapter::getStatusFromLLSD(const LLSD &httpResul void HttpCoroutineAdapter::callbackHttpGet(const std::string &url, LLCore::HttpRequest::policy_t policyId, completionCallback_t success, completionCallback_t failure) { LLCoros::instance().launch("HttpCoroutineAdapter::genericGetCoro", - boost::bind(&HttpCoroutineAdapter::trivialGetCoro, url, policyId, success, failure)); + boost::bind(&HttpCoroutineAdapter::trivialGetCoro, _1, url, policyId, success, failure)); } /*static*/ @@ -921,7 +921,7 @@ void HttpCoroutineAdapter::messageHttpGet(const std::string &url, const std::str } /*static*/ -void HttpCoroutineAdapter::trivialGetCoro(std::string url, LLCore::HttpRequest::policy_t policyId, completionCallback_t success, completionCallback_t failure) +void HttpCoroutineAdapter::trivialGetCoro(LLCoros::self& self, std::string url, LLCore::HttpRequest::policy_t policyId, completionCallback_t success, completionCallback_t failure) { LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("genericGetCoro", policyId)); @@ -932,7 +932,7 @@ void HttpCoroutineAdapter::trivialGetCoro(std::string url, LLCore::HttpRequest:: LL_INFOS("HttpCoroutineAdapter", "genericGetCoro") << "Generic GET for " << url << LL_ENDL; - LLSD result = httpAdapter->getAndYield(httpRequest, url, httpOpts); + LLSD result = httpAdapter->getAndYield(self, httpRequest, url, httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -957,7 +957,7 @@ void HttpCoroutineAdapter::trivialGetCoro(std::string url, LLCore::HttpRequest:: void HttpCoroutineAdapter::callbackHttpPost(const std::string &url, LLCore::HttpRequest::policy_t policyId, const LLSD &postData, completionCallback_t success, completionCallback_t failure) { LLCoros::instance().launch("HttpCoroutineAdapter::genericPostCoro", - boost::bind(&HttpCoroutineAdapter::trivialPostCoro, url, policyId, postData, success, failure)); + boost::bind(&HttpCoroutineAdapter::trivialPostCoro, _1, url, policyId, postData, success, failure)); } /*static*/ @@ -972,7 +972,7 @@ void HttpCoroutineAdapter::messageHttpPost(const std::string &url, const LLSD &p } /*static*/ -void HttpCoroutineAdapter::trivialPostCoro(std::string url, LLCore::HttpRequest::policy_t policyId, LLSD postData, completionCallback_t success, completionCallback_t failure) +void HttpCoroutineAdapter::trivialPostCoro(LLCoros::self& self, std::string url, LLCore::HttpRequest::policy_t policyId, LLSD postData, completionCallback_t success, completionCallback_t failure) { LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("genericPostCoro", policyId)); @@ -983,7 +983,7 @@ void HttpCoroutineAdapter::trivialPostCoro(std::string url, LLCore::HttpRequest: LL_INFOS("HttpCoroutineAdapter", "genericPostCoro") << "Generic POST for " << url << LL_ENDL; - LLSD result = httpAdapter->postAndYield(httpRequest, url, postData, httpOpts); + LLSD result = httpAdapter->postAndYield(self, httpRequest, url, postData, httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); diff --git a/indra/llmessage/llcorehttputil.h b/indra/llmessage/llcorehttputil.h index cf35177e48..7dd161d1cd 100644 --- a/indra/llmessage/llcorehttputil.h +++ b/indra/llmessage/llcorehttputil.h @@ -320,67 +320,67 @@ public: /// /// @Note: the request's smart pointer is passed by value so that it will /// not be deallocated during the yield. - LLSD postAndYield(LLCore::HttpRequest::ptr_t request, + LLSD postAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, const std::string & url, const LLSD & body, LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders())); - LLSD postAndYield(LLCore::HttpRequest::ptr_t request, + LLSD postAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, const std::string & url, LLCore::BufferArray::ptr_t rawbody, LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders())); - LLSD postAndYield(LLCore::HttpRequest::ptr_t &request, + LLSD postAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, const std::string & url, const LLSD & body, LLCore::HttpHeaders::ptr_t &headers) { - return postAndYield(request, url, body, + return postAndYield(self, request, url, body, LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), headers); } - LLSD postAndYield(LLCore::HttpRequest::ptr_t &request, + LLSD postAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, const std::string & url, LLCore::BufferArray::ptr_t &rawbody, LLCore::HttpHeaders::ptr_t &headers) { - return postAndYield(request, url, rawbody, + return postAndYield(self, request, url, rawbody, LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), headers); } - LLSD postRawAndYield(LLCore::HttpRequest::ptr_t request, + LLSD postRawAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, const std::string & url, LLCore::BufferArray::ptr_t rawbody, LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders())); - LLSD postRawAndYield(LLCore::HttpRequest::ptr_t &request, + LLSD postRawAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, const std::string & url, LLCore::BufferArray::ptr_t &rawbody, LLCore::HttpHeaders::ptr_t &headers) { - return postRawAndYield(request, url, rawbody, + return postRawAndYield(self, request, url, rawbody, LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), headers); } - LLSD postFileAndYield(LLCore::HttpRequest::ptr_t request, + LLSD postFileAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, const std::string & url, std::string fileName, LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders())); - LLSD postFileAndYield(LLCore::HttpRequest::ptr_t &request, + LLSD postFileAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, const std::string & url, std::string fileName, LLCore::HttpHeaders::ptr_t &headers) { - return postFileAndYield(request, url, fileName, + return postFileAndYield(self, request, url, fileName, LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), headers); } - LLSD postFileAndYield(LLCore::HttpRequest::ptr_t request, + LLSD postFileAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, const std::string & url, LLUUID assetId, LLAssetType::EType assetType, LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders())); - LLSD postFileAndYield(LLCore::HttpRequest::ptr_t request, + LLSD postFileAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, const std::string & url, LLUUID assetId, LLAssetType::EType assetType, LLCore::HttpHeaders::ptr_t &headers) { - return postFileAndYield(request, url, assetId, assetType, + return postFileAndYield(self, request, url, assetId, assetType, LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), headers); } @@ -390,7 +390,7 @@ public: /// /// @Note: the request's smart pointer is passed by value so that it will /// not be deallocated during the yield. - LLSD putAndYield(LLCore::HttpRequest::ptr_t request, + LLSD putAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, const std::string & url, const LLSD & body, LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders())); @@ -400,38 +400,38 @@ public: /// /// @Note: the request's smart pointer is passed by value so that it will /// not be deallocated during the yield. - LLSD getAndYield(LLCore::HttpRequest::ptr_t request, + LLSD getAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, const std::string & url, LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders())); - LLSD getAndYield(LLCore::HttpRequest::ptr_t &request, + LLSD getAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, const std::string & url, LLCore::HttpHeaders::ptr_t &headers) { - return getAndYield(request, url, + return getAndYield(self, request, url, LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), headers); } - LLSD getRawAndYield(LLCore::HttpRequest::ptr_t request, + LLSD getRawAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, const std::string & url, LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders())); - LLSD getRawAndYield(LLCore::HttpRequest::ptr_t &request, + LLSD getRawAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, const std::string & url, LLCore::HttpHeaders::ptr_t &headers) { - return getRawAndYield(request, url, + return getRawAndYield(self, request, url, LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), headers); } - LLSD getJsonAndYield(LLCore::HttpRequest::ptr_t request, + LLSD getJsonAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, const std::string & url, LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders())); - LLSD getJsonndYield(LLCore::HttpRequest::ptr_t &request, + LLSD getJsonndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, const std::string & url, LLCore::HttpHeaders::ptr_t &headers) { - return getJsonAndYield(request, url, + return getJsonAndYield(self, request, url, LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), headers); } @@ -442,7 +442,7 @@ public: /// /// @Note: the request's smart pointer is passed by value so that it will /// not be deallocated during the yield. - LLSD deleteAndYield(LLCore::HttpRequest::ptr_t request, + LLSD deleteAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, const std::string & url, LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders())); @@ -486,31 +486,31 @@ private: HttpCoroHandler::ptr_t &handler); void cleanState(); - LLSD postAndYield_(LLCore::HttpRequest::ptr_t &request, + LLSD postAndYield_(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, const std::string & url, const LLSD & body, LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler); - LLSD postAndYield_(LLCore::HttpRequest::ptr_t &request, + LLSD postAndYield_(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, const std::string & url, LLCore::BufferArray::ptr_t &rawbody, LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler); - LLSD putAndYield_(LLCore::HttpRequest::ptr_t &request, + LLSD putAndYield_(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, const std::string & url, const LLSD & body, LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler); - LLSD getAndYield_(LLCore::HttpRequest::ptr_t &request, + LLSD getAndYield_(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, const std::string & url, LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler); - LLSD deleteAndYield_(LLCore::HttpRequest::ptr_t &request, + LLSD deleteAndYield_(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, const std::string & url, LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler); - static void trivialGetCoro(std::string url, LLCore::HttpRequest::policy_t policyId, completionCallback_t success, completionCallback_t failure); - static void trivialPostCoro(std::string url, LLCore::HttpRequest::policy_t policyId, LLSD postData, completionCallback_t success, completionCallback_t failure); + static void trivialGetCoro(LLCoros::self& self, std::string url, LLCore::HttpRequest::policy_t policyId, completionCallback_t success, completionCallback_t failure); + static void trivialPostCoro(LLCoros::self& self, std::string url, LLCore::HttpRequest::policy_t policyId, LLSD postData, completionCallback_t success, completionCallback_t failure); void checkDefaultHeaders(LLCore::HttpHeaders::ptr_t &headers); diff --git a/indra/newview/llaccountingcostmanager.cpp b/indra/newview/llaccountingcostmanager.cpp index cd9146ea16..f928c84ecb 100755 --- a/indra/newview/llaccountingcostmanager.cpp +++ b/indra/newview/llaccountingcostmanager.cpp @@ -45,10 +45,10 @@ LLAccountingCostManager::LLAccountingCostManager(): // Coroutine for sending and processing avatar name cache requests. // Do not call directly. See documentation in lleventcoro.h and llcoro.h for // further explanation. -void LLAccountingCostManager::accountingCostCoro(std::string url, +void LLAccountingCostManager::accountingCostCoro(LLCoros::self& self, std::string url, eSelectionType selectionType, const LLHandle observerHandle) { - LL_DEBUGS("LLAccountingCostManager") << "Entering coroutine " << LLCoros::instance().getName() + LL_DEBUGS("LLAccountingCostManager") << "Entering coroutine " << LLCoros::instance().getName(self) << " with url '" << url << LL_ENDL; try @@ -101,7 +101,7 @@ void LLAccountingCostManager::accountingCostCoro(std::string url, LLCoreHttpUtil::HttpCoroutineAdapter httpAdapter("AccountingCost", mHttpPolicy); - LLSD results = httpAdapter.postAndYield(mHttpRequest, url, dataToPost); + LLSD results = httpAdapter.postAndYield(self, mHttpRequest, url, dataToPost); LLSD httpResults; httpResults = results["http_result"]; @@ -181,7 +181,7 @@ void LLAccountingCostManager::fetchCosts( eSelectionType selectionType, { std::string coroname = LLCoros::instance().launch("LLAccountingCostManager::accountingCostCoro", - boost::bind(&LLAccountingCostManager::accountingCostCoro, this, url, selectionType, observer_handle)); + boost::bind(&LLAccountingCostManager::accountingCostCoro, this, _1, url, selectionType, observer_handle)); LL_DEBUGS() << coroname << " with url '" << url << LL_ENDL; } diff --git a/indra/newview/llaccountingcostmanager.h b/indra/newview/llaccountingcostmanager.h index d5a94f6fda..34748894e3 100755 --- a/indra/newview/llaccountingcostmanager.h +++ b/indra/newview/llaccountingcostmanager.h @@ -77,7 +77,7 @@ private: std::set mPendingObjectQuota; typedef std::set::iterator IDIt; - void accountingCostCoro(std::string url, eSelectionType selectionType, const LLHandle observerHandle); + void accountingCostCoro(LLCoros::self& self, std::string url, eSelectionType selectionType, const LLHandle observerHandle); LLCore::HttpRequest::ptr_t mHttpRequest; LLCore::HttpRequest::policy_t mHttpPolicy; diff --git a/indra/newview/llavatarrenderinfoaccountant.cpp b/indra/newview/llavatarrenderinfoaccountant.cpp index e260142254..73b2ecfd36 100644 --- a/indra/newview/llavatarrenderinfoaccountant.cpp +++ b/indra/newview/llavatarrenderinfoaccountant.cpp @@ -60,14 +60,14 @@ LLFrameTimer LLAvatarRenderInfoAccountant::sRenderInfoReportTimer; //LLCore::HttpRequest::ptr_t LLAvatarRenderInfoAccountant::sHttpRequest; //========================================================================= -void LLAvatarRenderInfoAccountant::avatarRenderInfoGetCoro(std::string url, U64 regionHandle) +void LLAvatarRenderInfoAccountant::avatarRenderInfoGetCoro(LLCoros::self& self, std::string url, U64 regionHandle) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("AvatarRenderInfoAccountant", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLSD result = httpAdapter->getAndYield(httpRequest, url); + LLSD result = httpAdapter->getAndYield(self, httpRequest, url); LLViewerRegion * regionp = LLWorld::getInstance()->getRegionFromHandle(regionHandle); if (!regionp) @@ -130,7 +130,7 @@ void LLAvatarRenderInfoAccountant::avatarRenderInfoGetCoro(std::string url, U64 } //------------------------------------------------------------------------- -void LLAvatarRenderInfoAccountant::avatarRenderInfoReportCoro(std::string url, U64 regionHandle) +void LLAvatarRenderInfoAccountant::avatarRenderInfoReportCoro(LLCoros::self& self, std::string url, U64 regionHandle) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -190,7 +190,7 @@ void LLAvatarRenderInfoAccountant::avatarRenderInfoReportCoro(std::string url, U report[KEY_AGENTS] = agents; regionp = NULL; - LLSD result = httpAdapter->postAndYield(httpRequest, url, report); + LLSD result = httpAdapter->postAndYield(self, httpRequest, url, report); regionp = LLWorld::getInstance()->getRegionFromHandle(regionHandle); if (!regionp) @@ -239,7 +239,7 @@ void LLAvatarRenderInfoAccountant::sendRenderInfoToRegion(LLViewerRegion * regio { std::string coroname = LLCoros::instance().launch("LLAvatarRenderInfoAccountant::avatarRenderInfoReportCoro", - boost::bind(&LLAvatarRenderInfoAccountant::avatarRenderInfoReportCoro, url, regionp->getHandle())); + boost::bind(&LLAvatarRenderInfoAccountant::avatarRenderInfoReportCoro, _1, url, regionp->getHandle())); } } @@ -264,7 +264,7 @@ void LLAvatarRenderInfoAccountant::getRenderInfoFromRegion(LLViewerRegion * regi // First send a request to get the latest data std::string coroname = LLCoros::instance().launch("LLAvatarRenderInfoAccountant::avatarRenderInfoGetCoro", - boost::bind(&LLAvatarRenderInfoAccountant::avatarRenderInfoGetCoro, url, regionp->getHandle())); + boost::bind(&LLAvatarRenderInfoAccountant::avatarRenderInfoGetCoro, _1, url, regionp->getHandle())); } } diff --git a/indra/newview/llavatarrenderinfoaccountant.h b/indra/newview/llavatarrenderinfoaccountant.h index f7a04cca2c..1736f03772 100644 --- a/indra/newview/llavatarrenderinfoaccountant.h +++ b/indra/newview/llavatarrenderinfoaccountant.h @@ -56,8 +56,8 @@ private: // Send data updates about once per minute, only need per-frame resolution static LLFrameTimer sRenderInfoReportTimer; - static void avatarRenderInfoGetCoro(std::string url, U64 regionHandle); - static void avatarRenderInfoReportCoro(std::string url, U64 regionHandle); + static void avatarRenderInfoGetCoro(LLCoros::self& self, std::string url, U64 regionHandle); + static void avatarRenderInfoReportCoro(LLCoros::self& self, std::string url, U64 regionHandle); }; diff --git a/indra/newview/llcoproceduremanager.cpp b/indra/newview/llcoproceduremanager.cpp index 1a4a906f35..3ecb323cab 100644 --- a/indra/newview/llcoproceduremanager.cpp +++ b/indra/newview/llcoproceduremanager.cpp @@ -54,7 +54,7 @@ LLCoprocedureManager::LLCoprocedureManager(): new LLCoreHttpUtil::HttpCoroutineAdapter("uploadPostAdapter", mHTTPPolicy)); std::string uploadCoro = LLCoros::instance().launch("LLCoprocedureManager::coprocedureInvokerCoro", - boost::bind(&LLCoprocedureManager::coprocedureInvokerCoro, this, httpAdapter)); + boost::bind(&LLCoprocedureManager::coprocedureInvokerCoro, this, _1, httpAdapter)); mCoroMapping.insert(CoroAdapterMap_t::value_type(uploadCoro, httpAdapter)); } @@ -132,13 +132,13 @@ void LLCoprocedureManager::cancelCoprocedure(const LLUUID &id) } //========================================================================= -void LLCoprocedureManager::coprocedureInvokerCoro(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter) +void LLCoprocedureManager::coprocedureInvokerCoro(LLCoros::self& self, LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter) { LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); while (!mShutdown) { - waitForEventOn(mWakeupTrigger); + waitForEventOn(self, mWakeupTrigger); if (mShutdown) break; @@ -152,7 +152,7 @@ void LLCoprocedureManager::coprocedureInvokerCoro(LLCoreHttpUtil::HttpCoroutineA try { - coproc->mProc(httpAdapter, coproc->mId); + coproc->mProc(self, httpAdapter, coproc->mId); } catch (std::exception &e) { diff --git a/indra/newview/llcoproceduremanager.h b/indra/newview/llcoproceduremanager.h index 6ba3891e87..4e971d42e3 100644 --- a/indra/newview/llcoproceduremanager.h +++ b/indra/newview/llcoproceduremanager.h @@ -36,7 +36,7 @@ class LLCoprocedureManager : public LLSingleton < LLCoprocedureManager > { public: - typedef boost::function CoProcedure_t; + typedef boost::function CoProcedure_t; LLCoprocedureManager(); virtual ~LLCoprocedureManager(); @@ -111,7 +111,7 @@ private: CoroAdapterMap_t mCoroMapping; - void coprocedureInvokerCoro(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter); + void coprocedureInvokerCoro(LLCoros::self& self, LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter); }; #endif diff --git a/indra/newview/llestateinfomodel.cpp b/indra/newview/llestateinfomodel.cpp index 884d1579e6..04d0dda7ac 100755 --- a/indra/newview/llestateinfomodel.cpp +++ b/indra/newview/llestateinfomodel.cpp @@ -123,12 +123,12 @@ bool LLEstateInfoModel::commitEstateInfoCaps() } LLCoros::instance().launch("LLEstateInfoModel::commitEstateInfoCapsCoro", - boost::bind(&LLEstateInfoModel::commitEstateInfoCapsCoro, this, url)); + boost::bind(&LLEstateInfoModel::commitEstateInfoCapsCoro, this, _1, url)); return true; } -void LLEstateInfoModel::commitEstateInfoCapsCoro(std::string url) +void LLEstateInfoModel::commitEstateInfoCapsCoro(LLCoros::self& self, std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -153,7 +153,7 @@ void LLEstateInfoModel::commitEstateInfoCapsCoro(std::string url) << ", sun_hour = " << getSunHour() << LL_ENDL; LL_DEBUGS() << body << LL_ENDL; - LLSD result = httpAdapter->postAndYield(httpRequest, url, body); + LLSD result = httpAdapter->postAndYield(self, httpRequest, url, body); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); diff --git a/indra/newview/llestateinfomodel.h b/indra/newview/llestateinfomodel.h index fcfbd1ce7d..2deae7e322 100755 --- a/indra/newview/llestateinfomodel.h +++ b/indra/newview/llestateinfomodel.h @@ -101,7 +101,7 @@ private: update_signal_t mUpdateSignal; /// emitted when we receive update from sim update_signal_t mCommitSignal; /// emitted when our update gets applied to sim - void commitEstateInfoCapsCoro(std::string url); + void commitEstateInfoCapsCoro(LLCoros::self& self, std::string url); }; inline bool LLEstateInfoModel::getFlag(U64 flag) const diff --git a/indra/newview/lleventpoll.cpp b/indra/newview/lleventpoll.cpp index 54da226209..03a380f2f6 100755 --- a/indra/newview/lleventpoll.cpp +++ b/indra/newview/lleventpoll.cpp @@ -61,7 +61,7 @@ namespace Details static const F32 EVENT_POLL_ERROR_RETRY_SECONDS_INC; static const S32 MAX_EVENT_POLL_HTTP_ERRORS; - void eventPollCoro(std::string url); + void eventPollCoro(LLCoros::self& self, std::string url); void handleMessage(const LLSD &content); @@ -113,7 +113,7 @@ namespace Details { std::string coroname = LLCoros::instance().launch("LLEventPollImpl::eventPollCoro", - boost::bind(&LLEventPollImpl::eventPollCoro, this, url)); + boost::bind(&LLEventPollImpl::eventPollCoro, this, _1, url)); LL_INFOS("LLEventPollImpl") << coroname << " with url '" << url << LL_ENDL; } } @@ -131,7 +131,7 @@ namespace Details } } - void LLEventPollImpl::eventPollCoro(std::string url) + void LLEventPollImpl::eventPollCoro(LLCoros::self& self, std::string url) { LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("EventPoller", mHttpPolicy)); LLSD acknowledge; @@ -154,7 +154,7 @@ namespace Details // << LLSDXMLStreamer(request) << LL_ENDL; LL_DEBUGS("LLEventPollImpl") << " <" << counter << "> posting and yielding." << LL_ENDL; - LLSD result = httpAdapter->postAndYield(mHttpRequest, url, request); + LLSD result = httpAdapter->postAndYield(self, mHttpRequest, url, request); // LL_DEBUGS("LLEventPollImpl::eventPollCoro") << "<" << counter << "> result = " // << LLSDXMLStreamer(result) << LL_ENDL; @@ -197,7 +197,7 @@ namespace Details " seconds, error count is now " << errorCount << LL_ENDL; timeout.eventAfter(waitToRetry, LLSD()); - waitForEventOn(timeout); + waitForEventOn(self, timeout); if (mDone) break; diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index 136e02953c..87d7aacda1 100755 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -144,7 +144,7 @@ LLFacebookConnectHandler gFacebookConnectHandler; /////////////////////////////////////////////////////////////////////////////// // -void LLFacebookConnect::facebookConnectCoro(std::string authCode, std::string authState) +void LLFacebookConnect::facebookConnectCoro(LLCoros::self& self, std::string authCode, std::string authState) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -167,7 +167,7 @@ void LLFacebookConnect::facebookConnectCoro(std::string authCode, std::string au setConnectionState(LLFacebookConnect::FB_CONNECTION_IN_PROGRESS); - LLSD result = httpAdapter->putAndYield(httpRequest, getFacebookConnectURL("/connection"), putData, httpOpts, get_headers()); + LLSD result = httpAdapter->putAndYield(self, httpRequest, getFacebookConnectURL("/connection"), putData, httpOpts, get_headers()); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -231,7 +231,7 @@ bool LLFacebookConnect::testShareStatus(LLSD &result) return false; } -void LLFacebookConnect::facebookShareCoro(std::string route, LLSD share) +void LLFacebookConnect::facebookShareCoro(LLCoros::self& self, std::string route, LLSD share) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -244,7 +244,7 @@ void LLFacebookConnect::facebookShareCoro(std::string route, LLSD share) setConnectionState(LLFacebookConnect::FB_POSTING); - LLSD result = httpAdapter->postAndYield(httpRequest, getFacebookConnectURL(route, true), share, httpOpts, get_headers()); + LLSD result = httpAdapter->postAndYield(self, httpRequest, getFacebookConnectURL(route, true), share, httpOpts, get_headers()); if (testShareStatus(result)) { @@ -254,7 +254,7 @@ void LLFacebookConnect::facebookShareCoro(std::string route, LLSD share) } } -void LLFacebookConnect::facebookShareImageCoro(std::string route, LLPointer image, std::string caption) +void LLFacebookConnect::facebookShareImageCoro(LLCoros::self& self, std::string route, LLPointer image, std::string caption) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -311,7 +311,7 @@ void LLFacebookConnect::facebookShareImageCoro(std::string route, LLPointerpostAndYield(httpRequest, getFacebookConnectURL(route, true), raw, httpOpts, httpHeaders); + LLSD result = httpAdapter->postAndYield(self, httpRequest, getFacebookConnectURL(route, true), raw, httpOpts, httpHeaders); if (testShareStatus(result)) { @@ -323,7 +323,7 @@ void LLFacebookConnect::facebookShareImageCoro(std::string route, LLPointersetFollowRedirects(false); - LLSD result = httpAdapter->deleteAndYield(httpRequest, getFacebookConnectURL("/connection"), httpOpts, get_headers()); + LLSD result = httpAdapter->deleteAndYield(self, httpRequest, getFacebookConnectURL("/connection"), httpOpts, get_headers()); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -358,7 +358,7 @@ void LLFacebookConnect::facebookDisconnectCoro() /////////////////////////////////////////////////////////////////////////////// // -void LLFacebookConnect::facebookConnectedCheckCoro(bool autoConnect) +void LLFacebookConnect::facebookConnectedCheckCoro(LLCoros::self& self, bool autoConnect) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -370,7 +370,7 @@ void LLFacebookConnect::facebookConnectedCheckCoro(bool autoConnect) httpOpts->setFollowRedirects(false); - LLSD result = httpAdapter->getAndYield(httpRequest, getFacebookConnectURL("/connection", true), httpOpts, get_headers()); + LLSD result = httpAdapter->getAndYield(self, httpRequest, getFacebookConnectURL("/connection", true), httpOpts, get_headers()); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -407,7 +407,7 @@ void LLFacebookConnect::facebookConnectedCheckCoro(bool autoConnect) /////////////////////////////////////////////////////////////////////////////// // -void LLFacebookConnect::facebookConnectInfoCoro() +void LLFacebookConnect::facebookConnectInfoCoro(LLCoros::self& self) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -418,7 +418,7 @@ void LLFacebookConnect::facebookConnectInfoCoro() httpOpts->setWantHeaders(true); httpOpts->setFollowRedirects(false); - LLSD result = httpAdapter->getAndYield(httpRequest, getFacebookConnectURL("/info", true), httpOpts, get_headers()); + LLSD result = httpAdapter->getAndYield(self, httpRequest, getFacebookConnectURL("/info", true), httpOpts, get_headers()); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -451,7 +451,7 @@ void LLFacebookConnect::facebookConnectInfoCoro() /////////////////////////////////////////////////////////////////////////////// // -void LLFacebookConnect::facebookConnectFriendsCoro() +void LLFacebookConnect::facebookConnectFriendsCoro(LLCoros::self& self) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -461,7 +461,7 @@ void LLFacebookConnect::facebookConnectFriendsCoro() httpOpts->setFollowRedirects(false); - LLSD result = httpAdapter->getAndYield(httpRequest, getFacebookConnectURL("/friends", true), httpOpts, get_headers()); + LLSD result = httpAdapter->getAndYield(self, httpRequest, getFacebookConnectURL("/friends", true), httpOpts, get_headers()); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -547,19 +547,19 @@ std::string LLFacebookConnect::getFacebookConnectURL(const std::string& route, b void LLFacebookConnect::connectToFacebook(const std::string& auth_code, const std::string& auth_state) { LLCoros::instance().launch("LLFacebookConnect::facebookConnectCoro", - boost::bind(&LLFacebookConnect::facebookConnectCoro, this, auth_code, auth_state)); + boost::bind(&LLFacebookConnect::facebookConnectCoro, this, _1, auth_code, auth_state)); } void LLFacebookConnect::disconnectFromFacebook() { LLCoros::instance().launch("LLFacebookConnect::facebookDisconnectCoro", - boost::bind(&LLFacebookConnect::facebookDisconnectCoro, this)); + boost::bind(&LLFacebookConnect::facebookDisconnectCoro, this, _1)); } void LLFacebookConnect::checkConnectionToFacebook(bool auto_connect) { LLCoros::instance().launch("LLFacebookConnect::facebookConnectedCheckCoro", - boost::bind(&LLFacebookConnect::facebookConnectedCheckCoro, this, auto_connect)); + boost::bind(&LLFacebookConnect::facebookConnectedCheckCoro, this, _1, auto_connect)); } void LLFacebookConnect::loadFacebookInfo() @@ -567,7 +567,7 @@ void LLFacebookConnect::loadFacebookInfo() if(mRefreshInfo) { LLCoros::instance().launch("LLFacebookConnect::facebookConnectInfoCoro", - boost::bind(&LLFacebookConnect::facebookConnectInfoCoro, this)); + boost::bind(&LLFacebookConnect::facebookConnectInfoCoro, this, _1)); } } @@ -576,7 +576,7 @@ void LLFacebookConnect::loadFacebookFriends() if(mRefreshContent) { LLCoros::instance().launch("LLFacebookConnect::facebookConnectFriendsCoro", - boost::bind(&LLFacebookConnect::facebookConnectFriendsCoro, this)); + boost::bind(&LLFacebookConnect::facebookConnectFriendsCoro, this, _1)); } } @@ -606,7 +606,7 @@ void LLFacebookConnect::postCheckin(const std::string& location, const std::stri } LLCoros::instance().launch("LLFacebookConnect::facebookShareCoro", - boost::bind(&LLFacebookConnect::facebookShareCoro, this, "/share/checkin", body)); + boost::bind(&LLFacebookConnect::facebookShareCoro, this, _1, "/share/checkin", body)); } void LLFacebookConnect::sharePhoto(const std::string& image_url, const std::string& caption) @@ -617,13 +617,13 @@ void LLFacebookConnect::sharePhoto(const std::string& image_url, const std::stri body["caption"] = caption; LLCoros::instance().launch("LLFacebookConnect::facebookShareCoro", - boost::bind(&LLFacebookConnect::facebookShareCoro, this, "/share/photo", body)); + boost::bind(&LLFacebookConnect::facebookShareCoro, this, _1, "/share/photo", body)); } void LLFacebookConnect::sharePhoto(LLPointer image, const std::string& caption) { LLCoros::instance().launch("LLFacebookConnect::facebookShareImageCoro", - boost::bind(&LLFacebookConnect::facebookShareImageCoro, this, "/share/photo", image, caption)); + boost::bind(&LLFacebookConnect::facebookShareImageCoro, this, _1, "/share/photo", image, caption)); } void LLFacebookConnect::updateStatus(const std::string& message) @@ -632,7 +632,7 @@ void LLFacebookConnect::updateStatus(const std::string& message) body["message"] = message; LLCoros::instance().launch("LLFacebookConnect::facebookShareCoro", - boost::bind(&LLFacebookConnect::facebookShareCoro, this, "/share/wall", body)); + boost::bind(&LLFacebookConnect::facebookShareCoro, this, _1, "/share/wall", body)); } void LLFacebookConnect::storeInfo(const LLSD& info) diff --git a/indra/newview/llfacebookconnect.h b/indra/newview/llfacebookconnect.h index 2a2cdb5499..f569c2f486 100644 --- a/indra/newview/llfacebookconnect.h +++ b/indra/newview/llfacebookconnect.h @@ -105,13 +105,13 @@ private: static boost::scoped_ptr sContentWatcher; bool testShareStatus(LLSD &results); - void facebookConnectCoro(std::string authCode, std::string authState); - void facebookConnectedCheckCoro(bool autoConnect); - void facebookDisconnectCoro(); - void facebookShareCoro(std::string route, LLSD share); - void facebookShareImageCoro(std::string route, LLPointer image, std::string caption); - void facebookConnectInfoCoro(); - void facebookConnectFriendsCoro(); + void facebookConnectCoro(LLCoros::self& self, std::string authCode, std::string authState); + void facebookConnectedCheckCoro(LLCoros::self& self, bool autoConnect); + void facebookDisconnectCoro(LLCoros::self& self); + void facebookShareCoro(LLCoros::self& self, std::string route, LLSD share); + void facebookShareImageCoro(LLCoros::self& self, std::string route, LLPointer image, std::string caption); + void facebookConnectInfoCoro(LLCoros::self& self); + void facebookConnectFriendsCoro(LLCoros::self& self); }; #endif // LL_LLFACEBOOKCONNECT_H diff --git a/indra/newview/llfeaturemanager.cpp b/indra/newview/llfeaturemanager.cpp index 0b76ca16a9..9a714ac962 100755 --- a/indra/newview/llfeaturemanager.cpp +++ b/indra/newview/llfeaturemanager.cpp @@ -492,7 +492,7 @@ bool LLFeatureManager::loadGPUClass() return true; // indicates that a gpu value was established } -void LLFeatureManager::fetchFeatureTableCoro(std::string tableName) +void LLFeatureManager::fetchFeatureTableCoro(LLCoros::self& self, std::string tableName) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -526,7 +526,7 @@ void LLFeatureManager::fetchFeatureTableCoro(std::string tableName) LL_INFOS() << "LLFeatureManager fetching " << url << " into " << path << LL_ENDL; - LLSD result = httpAdapter->getRawAndYield(httpRequest, url); + LLSD result = httpAdapter->getRawAndYield(self, httpRequest, url); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -553,7 +553,7 @@ void LLFeatureManager::fetchFeatureTableCoro(std::string tableName) void LLFeatureManager::fetchHTTPTables() { LLCoros::instance().launch("LLFeatureManager::fetchFeatureTableCoro", - boost::bind(&LLFeatureManager::fetchFeatureTableCoro, this, FEATURE_TABLE_VER_FILENAME)); + boost::bind(&LLFeatureManager::fetchFeatureTableCoro, this, _1, FEATURE_TABLE_VER_FILENAME)); } void LLFeatureManager::cleanupFeatureTables() diff --git a/indra/newview/llfeaturemanager.h b/indra/newview/llfeaturemanager.h index 12ea691b49..1490c2122c 100755 --- a/indra/newview/llfeaturemanager.h +++ b/indra/newview/llfeaturemanager.h @@ -166,7 +166,7 @@ protected: void initBaseMask(); - void fetchFeatureTableCoro(std::string name); + void fetchFeatureTableCoro(LLCoros::self& self, std::string name); std::map mMaskList; std::set mSkippedFeatures; diff --git a/indra/newview/llflickrconnect.cpp b/indra/newview/llflickrconnect.cpp index 83e4f19191..873b1a7138 100644 --- a/indra/newview/llflickrconnect.cpp +++ b/indra/newview/llflickrconnect.cpp @@ -67,7 +67,7 @@ void toast_user_for_flickr_success() /////////////////////////////////////////////////////////////////////////////// // -void LLFlickrConnect::flickrConnectCoro(std::string requestToken, std::string oauthVerifier) +void LLFlickrConnect::flickrConnectCoro(LLCoros::self& self, std::string requestToken, std::string oauthVerifier) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -86,7 +86,7 @@ void LLFlickrConnect::flickrConnectCoro(std::string requestToken, std::string oa setConnectionState(LLFlickrConnect::FLICKR_CONNECTION_IN_PROGRESS); - LLSD result = httpAdapter->putAndYield(httpRequest, getFlickrConnectURL("/connection"), body, httpOpts); + LLSD result = httpAdapter->putAndYield(self, httpRequest, getFlickrConnectURL("/connection"), body, httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -157,7 +157,7 @@ bool LLFlickrConnect::testShareStatus(LLSD &result) return false; } -void LLFlickrConnect::flickrShareCoro(LLSD share) +void LLFlickrConnect::flickrShareCoro(LLCoros::self& self, LLSD share) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -170,7 +170,7 @@ void LLFlickrConnect::flickrShareCoro(LLSD share) setConnectionState(LLFlickrConnect::FLICKR_POSTING); - LLSD result = httpAdapter->postAndYield(httpRequest, getFlickrConnectURL("/share/photo", true), share, httpOpts); + LLSD result = httpAdapter->postAndYield(self, httpRequest, getFlickrConnectURL("/share/photo", true), share, httpOpts); if (testShareStatus(result)) { @@ -181,7 +181,7 @@ void LLFlickrConnect::flickrShareCoro(LLSD share) } -void LLFlickrConnect::flickrShareImageCoro(LLPointer image, std::string title, std::string description, std::string tags, int safetyLevel) +void LLFlickrConnect::flickrShareImageCoro(LLCoros::self& self, LLPointer image, std::string title, std::string description, std::string tags, int safetyLevel) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -248,7 +248,7 @@ void LLFlickrConnect::flickrShareImageCoro(LLPointer image, st body << "\r\n--" << boundary << "--\r\n"; - LLSD result = httpAdapter->postAndYield(httpRequest, getFlickrConnectURL("/share/photo", true), raw, httpOpts, httpHeaders); + LLSD result = httpAdapter->postAndYield(self, httpRequest, getFlickrConnectURL("/share/photo", true), raw, httpOpts, httpHeaders); if (testShareStatus(result)) { @@ -260,7 +260,7 @@ void LLFlickrConnect::flickrShareImageCoro(LLPointer image, st /////////////////////////////////////////////////////////////////////////////// // -void LLFlickrConnect::flickrDisconnectCoro() +void LLFlickrConnect::flickrDisconnectCoro(LLCoros::self& self) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -271,7 +271,7 @@ void LLFlickrConnect::flickrDisconnectCoro() setConnectionState(LLFlickrConnect::FLICKR_DISCONNECTING); httpOpts->setFollowRedirects(false); - LLSD result = httpAdapter->deleteAndYield(httpRequest, getFlickrConnectURL("/connection"), httpOpts); + LLSD result = httpAdapter->deleteAndYield(self, httpRequest, getFlickrConnectURL("/connection"), httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -294,7 +294,7 @@ void LLFlickrConnect::flickrDisconnectCoro() /////////////////////////////////////////////////////////////////////////////// // -void LLFlickrConnect::flickrConnectedCoro(bool autoConnect) +void LLFlickrConnect::flickrConnectedCoro(LLCoros::self& self, bool autoConnect) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -306,7 +306,7 @@ void LLFlickrConnect::flickrConnectedCoro(bool autoConnect) httpOpts->setFollowRedirects(false); - LLSD result = httpAdapter->getAndYield(httpRequest, getFlickrConnectURL("/connection", true), httpOpts); + LLSD result = httpAdapter->getAndYield(self, httpRequest, getFlickrConnectURL("/connection", true), httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -344,7 +344,7 @@ void LLFlickrConnect::flickrConnectedCoro(bool autoConnect) /////////////////////////////////////////////////////////////////////////////// // -void LLFlickrConnect::flickrInfoCoro() +void LLFlickrConnect::flickrInfoCoro(LLCoros::self& self) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -355,7 +355,7 @@ void LLFlickrConnect::flickrInfoCoro() httpOpts->setWantHeaders(true); httpOpts->setFollowRedirects(false); - LLSD result = httpAdapter->getAndYield(httpRequest, getFlickrConnectURL("/info", true), httpOpts); + LLSD result = httpAdapter->getAndYield(self, httpRequest, getFlickrConnectURL("/info", true), httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -438,19 +438,19 @@ std::string LLFlickrConnect::getFlickrConnectURL(const std::string& route, bool void LLFlickrConnect::connectToFlickr(const std::string& request_token, const std::string& oauth_verifier) { LLCoros::instance().launch("LLFlickrConnect::flickrConnectCoro", - boost::bind(&LLFlickrConnect::flickrConnectCoro, this, request_token, oauth_verifier)); + boost::bind(&LLFlickrConnect::flickrConnectCoro, this, _1, request_token, oauth_verifier)); } void LLFlickrConnect::disconnectFromFlickr() { LLCoros::instance().launch("LLFlickrConnect::flickrDisconnectCoro", - boost::bind(&LLFlickrConnect::flickrDisconnectCoro, this)); + boost::bind(&LLFlickrConnect::flickrDisconnectCoro, this, _1)); } void LLFlickrConnect::checkConnectionToFlickr(bool auto_connect) { LLCoros::instance().launch("LLFlickrConnect::flickrConnectedCoro", - boost::bind(&LLFlickrConnect::flickrConnectedCoro, this, auto_connect)); + boost::bind(&LLFlickrConnect::flickrConnectedCoro, this, _1, auto_connect)); } void LLFlickrConnect::loadFlickrInfo() @@ -458,7 +458,7 @@ void LLFlickrConnect::loadFlickrInfo() if(mRefreshInfo) { LLCoros::instance().launch("LLFlickrConnect::flickrInfoCoro", - boost::bind(&LLFlickrConnect::flickrInfoCoro, this)); + boost::bind(&LLFlickrConnect::flickrInfoCoro, this, _1)); } } @@ -472,14 +472,14 @@ void LLFlickrConnect::uploadPhoto(const std::string& image_url, const std::strin body["safety_level"] = safety_level; LLCoros::instance().launch("LLFlickrConnect::flickrShareCoro", - boost::bind(&LLFlickrConnect::flickrShareCoro, this, body)); + boost::bind(&LLFlickrConnect::flickrShareCoro, this, _1, body)); } void LLFlickrConnect::uploadPhoto(LLPointer image, const std::string& title, const std::string& description, const std::string& tags, int safety_level) { LLCoros::instance().launch("LLFlickrConnect::flickrShareImageCoro", - boost::bind(&LLFlickrConnect::flickrShareImageCoro, this, image, + boost::bind(&LLFlickrConnect::flickrShareImageCoro, this, _1, image, title, description, tags, safety_level)); } diff --git a/indra/newview/llflickrconnect.h b/indra/newview/llflickrconnect.h index 0155804da0..26c63f8b08 100644 --- a/indra/newview/llflickrconnect.h +++ b/indra/newview/llflickrconnect.h @@ -97,12 +97,12 @@ private: static boost::scoped_ptr sContentWatcher; bool testShareStatus(LLSD &result); - void flickrConnectCoro(std::string requestToken, std::string oauthVerifier); - void flickrShareCoro(LLSD share); - void flickrShareImageCoro(LLPointer image, std::string title, std::string description, std::string tags, int safetyLevel); - void flickrDisconnectCoro(); - void flickrConnectedCoro(bool autoConnect); - void flickrInfoCoro(); + void flickrConnectCoro(LLCoros::self& self, std::string requestToken, std::string oauthVerifier); + void flickrShareCoro(LLCoros::self& self, LLSD share); + void flickrShareImageCoro(LLCoros::self& self, LLPointer image, std::string title, std::string description, std::string tags, int safetyLevel); + void flickrDisconnectCoro(LLCoros::self& self); + void flickrConnectedCoro(LLCoros::self& self, bool autoConnect); + void flickrInfoCoro(LLCoros::self& self); }; diff --git a/indra/newview/llfloateravatarpicker.cpp b/indra/newview/llfloateravatarpicker.cpp index 2824038f77..e5e9a794a4 100755 --- a/indra/newview/llfloateravatarpicker.cpp +++ b/indra/newview/llfloateravatarpicker.cpp @@ -457,7 +457,7 @@ BOOL LLFloaterAvatarPicker::visibleItemsSelected() const } /*static*/ -void LLFloaterAvatarPicker::findCoro(std::string url, LLUUID queryID, std::string name) +void LLFloaterAvatarPicker::findCoro(LLCoros::self& self, std::string url, LLUUID queryID, std::string name) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -466,7 +466,7 @@ void LLFloaterAvatarPicker::findCoro(std::string url, LLUUID queryID, std::strin LL_INFOS("HttpCoroutineAdapter", "genericPostCoro") << "Generic POST for " << url << LL_ENDL; - LLSD result = httpAdapter->getAndYield(httpRequest, url); + LLSD result = httpAdapter->getAndYield(self, httpRequest, url); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -513,7 +513,7 @@ void LLFloaterAvatarPicker::find() LL_INFOS() << "avatar picker " << url << LL_ENDL; LLCoros::instance().launch("LLFloaterAvatarPicker::findCoro", - boost::bind(&LLFloaterAvatarPicker::findCoro, url, mQueryID, getKey().asString())); + boost::bind(&LLFloaterAvatarPicker::findCoro, _1, url, mQueryID, getKey().asString())); } else { diff --git a/indra/newview/llfloateravatarpicker.h b/indra/newview/llfloateravatarpicker.h index fbee61b054..200f74278e 100755 --- a/indra/newview/llfloateravatarpicker.h +++ b/indra/newview/llfloateravatarpicker.h @@ -86,7 +86,7 @@ private: void populateFriend(); BOOL visibleItemsSelected() const; // Returns true if any items in the current tab are selected. - static void findCoro(std::string url, LLUUID mQueryID, std::string mName); + static void findCoro(LLCoros::self& self, std::string url, LLUUID mQueryID, std::string mName); void find(); void setAllowMultiple(BOOL allow_multiple); LLScrollListCtrl* getActiveList(); diff --git a/indra/newview/llfloatermodeluploadbase.cpp b/indra/newview/llfloatermodeluploadbase.cpp index e2f84fd990..aa91a2ce03 100755 --- a/indra/newview/llfloatermodeluploadbase.cpp +++ b/indra/newview/llfloatermodeluploadbase.cpp @@ -49,7 +49,7 @@ void LLFloaterModelUploadBase::requestAgentUploadPermissions() << "::requestAgentUploadPermissions() requesting for upload model permissions from: " << url << LL_ENDL; LLCoros::instance().launch("LLFloaterModelUploadBase::requestAgentUploadPermissionsCoro", - boost::bind(&LLFloaterModelUploadBase::requestAgentUploadPermissionsCoro, this, url, getPermObserverHandle())); + boost::bind(&LLFloaterModelUploadBase::requestAgentUploadPermissionsCoro, this, _1, url, getPermObserverHandle())); } else { @@ -61,7 +61,7 @@ void LLFloaterModelUploadBase::requestAgentUploadPermissions() } } -void LLFloaterModelUploadBase::requestAgentUploadPermissionsCoro(std::string url, +void LLFloaterModelUploadBase::requestAgentUploadPermissionsCoro(LLCoros::self& self, std::string url, LLHandle observerHandle) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); @@ -70,7 +70,7 @@ void LLFloaterModelUploadBase::requestAgentUploadPermissionsCoro(std::string url LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLSD result = httpAdapter->getAndYield(httpRequest, url); + LLSD result = httpAdapter->getAndYield(self, httpRequest, url); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); diff --git a/indra/newview/llfloatermodeluploadbase.h b/indra/newview/llfloatermodeluploadbase.h index 0d4c834122..9bb9959af0 100755 --- a/indra/newview/llfloatermodeluploadbase.h +++ b/indra/newview/llfloatermodeluploadbase.h @@ -56,7 +56,7 @@ protected: // requests agent's permissions to upload model void requestAgentUploadPermissions(); - void requestAgentUploadPermissionsCoro(std::string url, LLHandle observerHandle); + void requestAgentUploadPermissionsCoro(LLCoros::self& self, std::string url, LLHandle observerHandle); std::string mUploadModelUrl; bool mHasUploadPerm; diff --git a/indra/newview/llfloaterperms.cpp b/indra/newview/llfloaterperms.cpp index 16bb449fdb..06af2725c3 100755 --- a/indra/newview/llfloaterperms.cpp +++ b/indra/newview/llfloaterperms.cpp @@ -182,7 +182,7 @@ void LLFloaterPermsDefault::updateCap() if(!object_url.empty()) { LLCoros::instance().launch("LLFloaterPermsDefault::updateCapCoro", - boost::bind(&LLFloaterPermsDefault::updateCapCoro, object_url)); + boost::bind(&LLFloaterPermsDefault::updateCapCoro, _1, object_url)); } else { @@ -191,7 +191,7 @@ void LLFloaterPermsDefault::updateCap() } /*static*/ -void LLFloaterPermsDefault::updateCapCoro(std::string url) +void LLFloaterPermsDefault::updateCapCoro(LLCoros::self& self, std::string url) { static std::string previousReason; LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); @@ -215,7 +215,7 @@ void LLFloaterPermsDefault::updateCapCoro(std::string url) LL_CONT << sent_perms_log.str() << LL_ENDL; } - LLSD result = httpAdapter->postAndYield(httpRequest, url, postData); + LLSD result = httpAdapter->postAndYield(self, httpRequest, url, postData); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); diff --git a/indra/newview/llfloaterperms.h b/indra/newview/llfloaterperms.h index e866b6de7d..ba7d39fe89 100755 --- a/indra/newview/llfloaterperms.h +++ b/indra/newview/llfloaterperms.h @@ -82,7 +82,7 @@ private: void refresh(); static const std::string sCategoryNames[CAT_LAST]; - static void updateCapCoro(std::string url); + static void updateCapCoro(LLCoros::self& self, std::string url); // cached values only for implementing cancel. diff --git a/indra/newview/llfloaterscriptlimits.cpp b/indra/newview/llfloaterscriptlimits.cpp index 14719a77f9..be18565670 100755 --- a/indra/newview/llfloaterscriptlimits.cpp +++ b/indra/newview/llfloaterscriptlimits.cpp @@ -200,7 +200,7 @@ BOOL LLPanelScriptLimitsRegionMemory::getLandScriptResources() if (!url.empty()) { LLCoros::instance().launch("LLPanelScriptLimitsRegionMemory::getLandScriptResourcesCoro", - boost::bind(&LLPanelScriptLimitsRegionMemory::getLandScriptResourcesCoro, this, url)); + boost::bind(&LLPanelScriptLimitsRegionMemory::getLandScriptResourcesCoro, this, _1, url)); return TRUE; } else @@ -209,7 +209,7 @@ BOOL LLPanelScriptLimitsRegionMemory::getLandScriptResources() } } -void LLPanelScriptLimitsRegionMemory::getLandScriptResourcesCoro(std::string url) +void LLPanelScriptLimitsRegionMemory::getLandScriptResourcesCoro(LLCoros::self& self, std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -220,7 +220,7 @@ void LLPanelScriptLimitsRegionMemory::getLandScriptResourcesCoro(std::string url postData["parcel_id"] = mParcelId; - LLSD result = httpAdapter->postAndYield(httpRequest, url, postData); + LLSD result = httpAdapter->postAndYield(self, httpRequest, url, postData); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -240,27 +240,27 @@ void LLPanelScriptLimitsRegionMemory::getLandScriptResourcesCoro(std::string url { std::string urlResourceSummary = result["ScriptResourceSummary"].asString(); LLCoros::instance().launch("LLPanelScriptLimitsRegionMemory::getLandScriptSummaryCoro", - boost::bind(&LLPanelScriptLimitsRegionMemory::getLandScriptSummaryCoro, this, urlResourceSummary)); + boost::bind(&LLPanelScriptLimitsRegionMemory::getLandScriptSummaryCoro, this, _1, urlResourceSummary)); } if (result.has("ScriptResourceDetails")) { std::string urlResourceDetails = result["ScriptResourceDetails"].asString(); LLCoros::instance().launch("LLPanelScriptLimitsRegionMemory::getLandScriptDetailsCoro", - boost::bind(&LLPanelScriptLimitsRegionMemory::getLandScriptDetailsCoro, this, urlResourceDetails)); + boost::bind(&LLPanelScriptLimitsRegionMemory::getLandScriptDetailsCoro, this, _1, urlResourceDetails)); } } -void LLPanelScriptLimitsRegionMemory::getLandScriptSummaryCoro(std::string url) +void LLPanelScriptLimitsRegionMemory::getLandScriptSummaryCoro(LLCoros::self& self, std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("getLandScriptSummaryCoro", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLSD result = httpAdapter->getAndYield(httpRequest, url); + LLSD result = httpAdapter->getAndYield(self, httpRequest, url); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -305,14 +305,14 @@ void LLPanelScriptLimitsRegionMemory::getLandScriptSummaryCoro(std::string url) } -void LLPanelScriptLimitsRegionMemory::getLandScriptDetailsCoro(std::string url) +void LLPanelScriptLimitsRegionMemory::getLandScriptDetailsCoro(LLCoros::self& self, std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("getLandScriptDetailsCoro", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLSD result = httpAdapter->getAndYield(httpRequest, url); + LLSD result = httpAdapter->getAndYield(self, httpRequest, url); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -947,7 +947,7 @@ BOOL LLPanelScriptLimitsAttachment::requestAttachmentDetails() if (!url.empty()) { LLCoros::instance().launch("LLPanelScriptLimitsAttachment::getAttachmentLimitsCoro", - boost::bind(&LLPanelScriptLimitsAttachment::getAttachmentLimitsCoro, this, url)); + boost::bind(&LLPanelScriptLimitsAttachment::getAttachmentLimitsCoro, this, _1, url)); return TRUE; } else @@ -956,14 +956,14 @@ BOOL LLPanelScriptLimitsAttachment::requestAttachmentDetails() } } -void LLPanelScriptLimitsAttachment::getAttachmentLimitsCoro(std::string url) +void LLPanelScriptLimitsAttachment::getAttachmentLimitsCoro(LLCoros::self& self, std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("getAttachmentLimitsCoro", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLSD result = httpAdapter->getAndYield(httpRequest, url); + LLSD result = httpAdapter->getAndYield(self, httpRequest, url); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); diff --git a/indra/newview/llfloaterscriptlimits.h b/indra/newview/llfloaterscriptlimits.h index e3cbbd185f..030020087b 100755 --- a/indra/newview/llfloaterscriptlimits.h +++ b/indra/newview/llfloaterscriptlimits.h @@ -132,9 +132,9 @@ private: std::vector mObjectListItems; - void getLandScriptResourcesCoro(std::string url); - void getLandScriptSummaryCoro(std::string url); - void getLandScriptDetailsCoro(std::string url); + void getLandScriptResourcesCoro(LLCoros::self& self, std::string url); + void getLandScriptSummaryCoro(LLCoros::self& self, std::string url); + void getLandScriptDetailsCoro(LLCoros::self& self, std::string url); protected: @@ -180,7 +180,7 @@ public: void clearList(); private: - void getAttachmentLimitsCoro(std::string url); + void getAttachmentLimitsCoro(LLCoros::self& self, std::string url); bool mGotAttachmentMemoryUsed; S32 mAttachmentMemoryMax; diff --git a/indra/newview/llfloatertos.cpp b/indra/newview/llfloatertos.cpp index 6dc08417d7..27938bfbc4 100755 --- a/indra/newview/llfloatertos.cpp +++ b/indra/newview/llfloatertos.cpp @@ -190,7 +190,7 @@ void LLFloaterTOS::handleMediaEvent(LLPluginClassMedia* /*self*/, EMediaEvent ev std::string url(getString("real_url")); LLCoros::instance().launch("LLFloaterTOS::testSiteIsAliveCoro", - boost::bind(&LLFloaterTOS::testSiteIsAliveCoro, this, url)); + boost::bind(&LLFloaterTOS::testSiteIsAliveCoro, this, _1, url)); } else if(mRealNavigateBegun) { @@ -202,7 +202,7 @@ void LLFloaterTOS::handleMediaEvent(LLPluginClassMedia* /*self*/, EMediaEvent ev } } -void LLFloaterTOS::testSiteIsAliveCoro(std::string url) +void LLFloaterTOS::testSiteIsAliveCoro(LLCoros::self& self, std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -214,7 +214,7 @@ void LLFloaterTOS::testSiteIsAliveCoro(std::string url) LL_INFOS("HttpCoroutineAdapter", "genericPostCoro") << "Generic POST for " << url << LL_ENDL; - LLSD result = httpAdapter->getAndYield(httpRequest, url); + LLSD result = httpAdapter->getAndYield(self, httpRequest, url); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); diff --git a/indra/newview/llfloatertos.h b/indra/newview/llfloatertos.h index 2748b20513..90bea2fe83 100755 --- a/indra/newview/llfloatertos.h +++ b/indra/newview/llfloatertos.h @@ -62,7 +62,7 @@ public: /*virtual*/ void handleMediaEvent(LLPluginClassMedia* self, EMediaEvent event); private: - void testSiteIsAliveCoro(std::string url); + void testSiteIsAliveCoro(LLCoros::self& self, std::string url); std::string mMessage; bool mLoadingScreenLoaded; diff --git a/indra/newview/llfloaterurlentry.cpp b/indra/newview/llfloaterurlentry.cpp index 6683a6e6e6..110d760dc9 100755 --- a/indra/newview/llfloaterurlentry.cpp +++ b/indra/newview/llfloaterurlentry.cpp @@ -194,7 +194,7 @@ void LLFloaterURLEntry::onBtnOK( void* userdata ) (scheme == "http" || scheme == "https")) { LLCoros::instance().launch("LLFloaterURLEntry::getMediaTypeCoro", - boost::bind(&LLFloaterURLEntry::getMediaTypeCoro, media_url, self->getHandle())); + boost::bind(&LLFloaterURLEntry::getMediaTypeCoro, _1, media_url, self->getHandle())); } else { @@ -208,7 +208,7 @@ void LLFloaterURLEntry::onBtnOK( void* userdata ) } // static -void LLFloaterURLEntry::getMediaTypeCoro(std::string url, LLHandle parentHandle) +void LLFloaterURLEntry::getMediaTypeCoro(LLCoros::self& self, std::string url, LLHandle parentHandle) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -220,7 +220,7 @@ void LLFloaterURLEntry::getMediaTypeCoro(std::string url, LLHandle pa LL_INFOS("HttpCoroutineAdapter", "genericPostCoro") << "Generic POST for " << url << LL_ENDL; - LLSD result = httpAdapter->getAndYield(httpRequest, url, httpOpts); + LLSD result = httpAdapter->getAndYield(self, httpRequest, url, httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); diff --git a/indra/newview/llfloaterurlentry.h b/indra/newview/llfloaterurlentry.h index 20f4604907..2f5afa653d 100755 --- a/indra/newview/llfloaterurlentry.h +++ b/indra/newview/llfloaterurlentry.h @@ -60,7 +60,7 @@ private: static void onBtnClear(void*); bool callback_clear_url_list(const LLSD& notification, const LLSD& response); - static void getMediaTypeCoro(std::string url, LLHandle parentHandle); + static void getMediaTypeCoro(LLCoros::self& self, std::string url, LLHandle parentHandle); }; diff --git a/indra/newview/llgroupmgr.cpp b/indra/newview/llgroupmgr.cpp index edae0bfd19..0fb39ab02e 100755 --- a/indra/newview/llgroupmgr.cpp +++ b/indra/newview/llgroupmgr.cpp @@ -1862,7 +1862,7 @@ void LLGroupMgr::sendGroupMemberEjects(const LLUUID& group_id, group_datap->mMemberVersion.generate(); } -void LLGroupMgr::getGroupBanRequestCoro(std::string url, LLUUID groupId) +void LLGroupMgr::getGroupBanRequestCoro(LLCoros::self& self, std::string url, LLUUID groupId) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -1871,7 +1871,7 @@ void LLGroupMgr::getGroupBanRequestCoro(std::string url, LLUUID groupId) std::string finalUrl = url + "?group_id=" + groupId.asString(); - LLSD result = httpAdapter->getAndYield(httpRequest, finalUrl); + LLSD result = httpAdapter->getAndYield(self, httpRequest, finalUrl); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -1890,7 +1890,7 @@ void LLGroupMgr::getGroupBanRequestCoro(std::string url, LLUUID groupId) } } -void LLGroupMgr::postGroupBanRequestCoro(std::string url, LLUUID groupId, +void LLGroupMgr::postGroupBanRequestCoro(LLCoros::self& self, std::string url, LLUUID groupId, U32 action, uuid_vec_t banList, bool update) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); @@ -1922,7 +1922,7 @@ void LLGroupMgr::postGroupBanRequestCoro(std::string url, LLUUID groupId, LL_WARNS() << "post: " << ll_pretty_print_sd(postData) << LL_ENDL; - LLSD result = httpAdapter->postAndYield(httpRequest, finalUrl, postData, httpOptions, httpHeaders); + LLSD result = httpAdapter->postAndYield(self, httpRequest, finalUrl, postData, httpOptions, httpHeaders); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -1942,7 +1942,7 @@ void LLGroupMgr::postGroupBanRequestCoro(std::string url, LLUUID groupId, if (update) { - getGroupBanRequestCoro(url, groupId); + getGroupBanRequestCoro(self, url, groupId); } } @@ -1979,11 +1979,11 @@ void LLGroupMgr::sendGroupBanRequest( EBanRequestType request_type, { case REQUEST_GET: LLCoros::instance().launch("LLGroupMgr::getGroupBanRequestCoro", - boost::bind(&LLGroupMgr::getGroupBanRequestCoro, this, cap_url, group_id)); + boost::bind(&LLGroupMgr::getGroupBanRequestCoro, this, _1, cap_url, group_id)); break; case REQUEST_POST: LLCoros::instance().launch("LLGroupMgr::postGroupBanRequestCoro", - boost::bind(&LLGroupMgr::postGroupBanRequestCoro, this, cap_url, group_id, + boost::bind(&LLGroupMgr::postGroupBanRequestCoro, this, _1, cap_url, group_id, action, ban_list, update)); break; case REQUEST_PUT: @@ -2028,7 +2028,7 @@ void LLGroupMgr::processGroupBanRequest(const LLSD& content) LLGroupMgr::getInstance()->notifyObservers(GC_BANLIST); } -void LLGroupMgr::groupMembersRequestCoro(std::string url, LLUUID groupId) +void LLGroupMgr::groupMembersRequestCoro(LLCoros::self& self, std::string url, LLUUID groupId) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -2041,7 +2041,7 @@ void LLGroupMgr::groupMembersRequestCoro(std::string url, LLUUID groupId) LLSD postData = LLSD::emptyMap(); postData["group_id"] = groupId; - LLSD result = httpAdapter->postAndYield(httpRequest, url, postData, httpOpts); + LLSD result = httpAdapter->postAndYield(self, httpRequest, url, postData, httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -2095,7 +2095,7 @@ void LLGroupMgr::sendCapGroupMembersRequest(const LLUUID& group_id) lastGroupMemberRequestFrame = gFrameCount; LLCoros::instance().launch("LLGroupMgr::groupMembersRequestCoro", - boost::bind(&LLGroupMgr::groupMembersRequestCoro, this, cap_url, group_id)); + boost::bind(&LLGroupMgr::groupMembersRequestCoro, this, _1, cap_url, group_id)); } diff --git a/indra/newview/llgroupmgr.h b/indra/newview/llgroupmgr.h index fd0c2de854..1163923eff 100755 --- a/indra/newview/llgroupmgr.h +++ b/indra/newview/llgroupmgr.h @@ -428,11 +428,11 @@ public: void clearGroupData(const LLUUID& group_id); private: - void groupMembersRequestCoro(std::string url, LLUUID groupId); + void groupMembersRequestCoro(LLCoros::self& self, std::string url, LLUUID groupId); void processCapGroupMembersRequest(const LLSD& content); - void getGroupBanRequestCoro(std::string url, LLUUID groupId); - void postGroupBanRequestCoro(std::string url, LLUUID groupId, U32 action, uuid_vec_t banList, bool update); + void getGroupBanRequestCoro(LLCoros::self& self, std::string url, LLUUID groupId); + void postGroupBanRequestCoro(LLCoros::self& self, std::string url, LLUUID groupId, U32 action, uuid_vec_t banList, bool update); static void processGroupBanRequest(const LLSD& content); diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp index 8d670d0b0a..0e5c16752e 100755 --- a/indra/newview/llimview.cpp +++ b/indra/newview/llimview.cpp @@ -79,8 +79,8 @@ const static std::string NEARBY_P2P_BY_AGENT("nearby_P2P_by_agent"); /** Timeout of outgoing session initialization (in seconds) */ const static U32 SESSION_INITIALIZATION_TIMEOUT = 30; -void startConfrenceCoro(std::string url, LLUUID tempSessionId, LLUUID creatorId, LLUUID otherParticipantId, LLSD agents); -void chatterBoxInvitationCoro(std::string url, LLUUID sessionId, LLIMMgr::EInvitationType invitationType); +void startConfrenceCoro(LLCoros::self& self, std::string url, LLUUID tempSessionId, LLUUID creatorId, LLUUID otherParticipantId, LLSD agents); +void chatterBoxInvitationCoro(LLCoros::self& self, std::string url, LLUUID sessionId, LLIMMgr::EInvitationType invitationType); void start_deprecated_conference_chat(const LLUUID& temp_session_id, const LLUUID& creator_id, const LLUUID& other_participant_id, const LLSD& agents_to_invite); std::string LLCallDialogManager::sPreviousSessionlName = ""; @@ -389,7 +389,7 @@ void on_new_message(const LLSD& msg) notify_of_message(msg, false); } -void startConfrenceCoro(std::string url, +void startConfrenceCoro(LLCoros::self& self, std::string url, LLUUID tempSessionId, LLUUID creatorId, LLUUID otherParticipantId, LLSD agents) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); @@ -402,7 +402,7 @@ void startConfrenceCoro(std::string url, postData["session-id"] = tempSessionId; postData["params"] = agents; - LLSD result = httpAdapter->postAndYield(httpRequest, url, postData); + LLSD result = httpAdapter->postAndYield(self, httpRequest, url, postData); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -430,7 +430,7 @@ void startConfrenceCoro(std::string url, } } -void chatterBoxInvitationCoro(std::string url, LLUUID sessionId, LLIMMgr::EInvitationType invitationType) +void chatterBoxInvitationCoro(LLCoros::self& self, std::string url, LLUUID sessionId, LLIMMgr::EInvitationType invitationType) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -441,7 +441,7 @@ void chatterBoxInvitationCoro(std::string url, LLUUID sessionId, LLIMMgr::EInvit postData["method"] = "accept invitation"; postData["session-id"] = sessionId; - LLSD result = httpAdapter->postAndYield(httpRequest, url, postData); + LLSD result = httpAdapter->postAndYield(self, httpRequest, url, postData); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -1623,7 +1623,7 @@ bool LLIMModel::sendStartSession( "ChatSessionRequest"); LLCoros::instance().launch("startConfrenceCoro", - boost::bind(&startConfrenceCoro, url, + boost::bind(&startConfrenceCoro, _1, url, temp_session_id, gAgent.getID(), other_participant_id, agents)); } else @@ -2468,7 +2468,7 @@ void LLIncomingCallDialog::processCallResponse(S32 response, const LLSD &payload if (voice) { LLCoros::instance().launch("chatterBoxInvitationCoro", - boost::bind(&chatterBoxInvitationCoro, url, + boost::bind(&chatterBoxInvitationCoro, _1, url, session_id, inv_type)); // send notification message to the corresponding chat @@ -2555,7 +2555,7 @@ bool inviteUserResponse(const LLSD& notification, const LLSD& response) "ChatSessionRequest"); LLCoros::instance().launch("chatterBoxInvitationCoro", - boost::bind(&chatterBoxInvitationCoro, url, + boost::bind(&chatterBoxInvitationCoro, _1, url, session_id, inv_type)); } } @@ -3646,7 +3646,7 @@ public: if ( url != "" ) { LLCoros::instance().launch("chatterBoxInvitationCoro", - boost::bind(&chatterBoxInvitationCoro, url, + boost::bind(&chatterBoxInvitationCoro, _1, url, session_id, LLIMMgr::INVITATION_TYPE_INSTANT_MESSAGE)); } } //end if invitation has instant message diff --git a/indra/newview/llinventorymodel.cpp b/indra/newview/llinventorymodel.cpp index 25450f2317..6d21dd4ba7 100755 --- a/indra/newview/llinventorymodel.cpp +++ b/indra/newview/llinventorymodel.cpp @@ -578,7 +578,7 @@ LLUUID LLInventoryModel::createNewCategory(const LLUUID& parent_id, LL_DEBUGS(LOG_INV) << "create category request: " << ll_pretty_print_sd(request) << LL_ENDL; LLCoros::instance().launch("LLInventoryModel::createNewCategoryCoro", - boost::bind(&LLInventoryModel::createNewCategoryCoro, this, url, body, callback)); + boost::bind(&LLInventoryModel::createNewCategoryCoro, this, _1, url, body, callback)); return LLUUID::null; } @@ -607,7 +607,7 @@ LLUUID LLInventoryModel::createNewCategory(const LLUUID& parent_id, return id; } -void LLInventoryModel::createNewCategoryCoro(std::string url, LLSD postData, inventory_func_type callback) +void LLInventoryModel::createNewCategoryCoro(LLCoros::self& self, std::string url, LLSD postData, inventory_func_type callback) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -620,7 +620,7 @@ void LLInventoryModel::createNewCategoryCoro(std::string url, LLSD postData, inv LL_INFOS("HttpCoroutineAdapter", "genericPostCoro") << "Generic POST for " << url << LL_ENDL; - LLSD result = httpAdapter->postAndYield(httpRequest, url, postData, httpOpts); + LLSD result = httpAdapter->postAndYield(self, httpRequest, url, postData, httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); diff --git a/indra/newview/llinventorymodel.h b/indra/newview/llinventorymodel.h index 1f1c686ef1..26ee06535a 100755 --- a/indra/newview/llinventorymodel.h +++ b/indra/newview/llinventorymodel.h @@ -444,7 +444,7 @@ protected: void addCategory(LLViewerInventoryCategory* category); void addItem(LLViewerInventoryItem* item); - void createNewCategoryCoro(std::string url, LLSD postData, inventory_func_type callback); + void createNewCategoryCoro(LLCoros::self& self, std::string url, LLSD postData, inventory_func_type callback); /** Mutators ** ** diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index 38c4382654..bd77912a6c 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -126,7 +126,7 @@ namespace LLMarketplaceImport // Responders #if 1 - void marketplacePostCoro(std::string url) + void marketplacePostCoro(LLCoros::self& self, std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -144,7 +144,7 @@ namespace LLMarketplaceImport httpHeaders->append(HTTP_OUT_HEADER_CONTENT_TYPE, HTTP_CONTENT_XML); httpHeaders->append(HTTP_OUT_HEADER_USER_AGENT, LLViewerMedia::getCurrentUserAgent()); - LLSD result = httpAdapter->postAndYield(httpRequest, url, LLSD(), httpOpts, httpHeaders); + LLSD result = httpAdapter->postAndYield(self, httpRequest, url, LLSD(), httpOpts, httpHeaders); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -237,7 +237,7 @@ namespace LLMarketplaceImport #endif #if 1 - void marketplaceGetCoro(std::string url, bool buildHeaders) + void marketplaceGetCoro(LLCoros::self& self, std::string url, bool buildHeaders) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -263,7 +263,7 @@ namespace LLMarketplaceImport httpHeaders = LLViewerMedia::getHttpHeaders(); } - LLSD result = httpAdapter->getAndYield(httpRequest, url, httpOpts, httpHeaders); + LLSD result = httpAdapter->getAndYield(self, httpRequest, url, httpOpts, httpHeaders); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -405,7 +405,7 @@ namespace LLMarketplaceImport #if 1 LLCoros::instance().launch("marketplaceGetCoro", - boost::bind(&marketplaceGetCoro, url, false)); + boost::bind(&marketplaceGetCoro, _1, url, false)); #else if (gSavedSettings.getBOOL("InventoryOutboxLogging")) @@ -439,7 +439,7 @@ namespace LLMarketplaceImport #if 1 LLCoros::instance().launch("marketplaceGetCoro", - boost::bind(&marketplaceGetCoro, url, true)); + boost::bind(&marketplaceGetCoro, _1, url, true)); #else // Make the headers for the post @@ -482,7 +482,7 @@ namespace LLMarketplaceImport #if 1 LLCoros::instance().launch("marketplacePostCoro", - boost::bind(&marketplacePostCoro, url)); + boost::bind(&marketplacePostCoro, _1, url)); #else // Make the headers for the post diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index 2e6937a79f..5dc90c987d 100755 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -225,7 +225,7 @@ void LLPathfindingManager::requestGetNavMeshForRegion(LLViewerRegion *pRegion, b U64 regionHandle = pRegion->getHandle(); std::string coroname = LLCoros::instance().launch("LLPathfindingManager::navMeshStatusRequestCoro", - boost::bind(&LLPathfindingManager::navMeshStatusRequestCoro, this, navMeshStatusURL, regionHandle, pIsGetStatusOnly)); + boost::bind(&LLPathfindingManager::navMeshStatusRequestCoro, this, _1, navMeshStatusURL, regionHandle, pIsGetStatusOnly)); } } @@ -259,12 +259,12 @@ void LLPathfindingManager::requestGetLinksets(request_id_t pRequestId, object_re LinksetsResponder::ptr_t linksetsResponderPtr(new LinksetsResponder(pRequestId, pLinksetsCallback, true, doRequestTerrain)); std::string coroname = LLCoros::instance().launch("LLPathfindingManager::linksetObjectsCoro", - boost::bind(&LLPathfindingManager::linksetObjectsCoro, this, objectLinksetsURL, linksetsResponderPtr, LLSD())); + boost::bind(&LLPathfindingManager::linksetObjectsCoro, this, _1, objectLinksetsURL, linksetsResponderPtr, LLSD())); if (doRequestTerrain) { std::string coroname = LLCoros::instance().launch("LLPathfindingManager::linksetTerrainCoro", - boost::bind(&LLPathfindingManager::linksetTerrainCoro, this, terrainLinksetsURL, linksetsResponderPtr, LLSD())); + boost::bind(&LLPathfindingManager::linksetTerrainCoro, this, _1, terrainLinksetsURL, linksetsResponderPtr, LLSD())); } } } @@ -308,13 +308,13 @@ void LLPathfindingManager::requestSetLinksets(request_id_t pRequestId, const LLP if (!objectPostData.isUndefined()) { std::string coroname = LLCoros::instance().launch("LLPathfindingManager::linksetObjectsCoro", - boost::bind(&LLPathfindingManager::linksetObjectsCoro, this, objectLinksetsURL, linksetsResponderPtr, objectPostData)); + boost::bind(&LLPathfindingManager::linksetObjectsCoro, this, _1, objectLinksetsURL, linksetsResponderPtr, objectPostData)); } if (!terrainPostData.isUndefined()) { std::string coroname = LLCoros::instance().launch("LLPathfindingManager::linksetTerrainCoro", - boost::bind(&LLPathfindingManager::linksetTerrainCoro, this, terrainLinksetsURL, linksetsResponderPtr, terrainPostData)); + boost::bind(&LLPathfindingManager::linksetTerrainCoro, this, _1, terrainLinksetsURL, linksetsResponderPtr, terrainPostData)); } } } @@ -347,7 +347,7 @@ void LLPathfindingManager::requestGetCharacters(request_id_t pRequestId, object_ pCharactersCallback(pRequestId, kRequestStarted, emptyCharacterListPtr); std::string coroname = LLCoros::instance().launch("LLPathfindingManager::charactersCoro", - boost::bind(&LLPathfindingManager::charactersCoro, this, charactersURL, pRequestId, pCharactersCallback)); + boost::bind(&LLPathfindingManager::charactersCoro, this, _1, charactersURL, pRequestId, pCharactersCallback)); } } } @@ -381,7 +381,7 @@ void LLPathfindingManager::requestGetAgentState() llassert(!agentStateURL.empty()); std::string coroname = LLCoros::instance().launch("LLPathfindingManager::navAgentStateRequestCoro", - boost::bind(&LLPathfindingManager::navAgentStateRequestCoro, this, agentStateURL)); + boost::bind(&LLPathfindingManager::navAgentStateRequestCoro, this, _1, agentStateURL)); } } } @@ -404,7 +404,7 @@ void LLPathfindingManager::requestRebakeNavMesh(rebake_navmesh_callback_t pRebak llassert(!navMeshStatusURL.empty()); std::string coroname = LLCoros::instance().launch("LLPathfindingManager::navMeshRebakeCoro", - boost::bind(&LLPathfindingManager::navMeshRebakeCoro, this, navMeshStatusURL, pRebakeNavMeshCallback)); + boost::bind(&LLPathfindingManager::navMeshRebakeCoro, this, _1, navMeshStatusURL, pRebakeNavMeshCallback)); } } @@ -448,7 +448,7 @@ void LLPathfindingManager::handleDeferredGetCharactersForRegion(const LLUUID &pR } } -void LLPathfindingManager::navMeshStatusRequestCoro(std::string url, U64 regionHandle, bool isGetStatusOnly) +void LLPathfindingManager::navMeshStatusRequestCoro(LLCoros::self& self, std::string url, U64 regionHandle, bool isGetStatusOnly) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -464,7 +464,7 @@ void LLPathfindingManager::navMeshStatusRequestCoro(std::string url, U64 regionH LLUUID regionUUID = region->getRegionID(); region = NULL; - LLSD result = httpAdapter->getAndYield(httpRequest, url); + LLSD result = httpAdapter->getAndYield(self, httpRequest, url); region = LLWorld::getInstance()->getRegionFromHandle(regionHandle); @@ -519,7 +519,7 @@ void LLPathfindingManager::navMeshStatusRequestCoro(std::string url, U64 regionH navMeshPtr->handleNavMeshStart(navMeshStatus); LLSD postData; - result = httpAdapter->postAndYield(httpRequest, navMeshURL, postData); + result = httpAdapter->postAndYield(self, httpRequest, navMeshURL, postData); U32 navMeshVersion = navMeshStatus.getVersion(); @@ -538,14 +538,14 @@ void LLPathfindingManager::navMeshStatusRequestCoro(std::string url, U64 regionH } -void LLPathfindingManager::navAgentStateRequestCoro(std::string url) +void LLPathfindingManager::navAgentStateRequestCoro(LLCoros::self& self, std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("NavAgentStateRequest", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLSD result = httpAdapter->getAndYield(httpRequest, url); + LLSD result = httpAdapter->getAndYield(self, httpRequest, url); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -566,7 +566,7 @@ void LLPathfindingManager::navAgentStateRequestCoro(std::string url) handleAgentState(canRebake); } -void LLPathfindingManager::navMeshRebakeCoro(std::string url, rebake_navmesh_callback_t rebakeNavMeshCallback) +void LLPathfindingManager::navMeshRebakeCoro(LLCoros::self& self, std::string url, rebake_navmesh_callback_t rebakeNavMeshCallback) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -577,7 +577,7 @@ void LLPathfindingManager::navMeshRebakeCoro(std::string url, rebake_navmesh_cal LLSD postData = LLSD::emptyMap(); postData["command"] = "rebuild"; - LLSD result = httpAdapter->postAndYield(httpRequest, url, postData); + LLSD result = httpAdapter->postAndYield(self, httpRequest, url, postData); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -595,7 +595,7 @@ void LLPathfindingManager::navMeshRebakeCoro(std::string url, rebake_navmesh_cal // If called with putData undefined this coroutine will issue a get. If there // is data in putData it will be PUT to the URL. -void LLPathfindingManager::linksetObjectsCoro(std::string url, LinksetsResponder::ptr_t linksetsResponsderPtr, LLSD putData) const +void LLPathfindingManager::linksetObjectsCoro(LLCoros::self &self, std::string url, LinksetsResponder::ptr_t linksetsResponsderPtr, LLSD putData) const { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -606,11 +606,11 @@ void LLPathfindingManager::linksetObjectsCoro(std::string url, LinksetsResponder if (putData.isUndefined()) { - result = httpAdapter->getAndYield(httpRequest, url); + result = httpAdapter->getAndYield(self, httpRequest, url); } else { - result = httpAdapter->putAndYield(httpRequest, url, putData); + result = httpAdapter->putAndYield(self, httpRequest, url, putData); } LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; @@ -631,7 +631,7 @@ void LLPathfindingManager::linksetObjectsCoro(std::string url, LinksetsResponder // If called with putData undefined this coroutine will issue a GET. If there // is data in putData it will be PUT to the URL. -void LLPathfindingManager::linksetTerrainCoro(std::string url, LinksetsResponder::ptr_t linksetsResponsderPtr, LLSD putData) const +void LLPathfindingManager::linksetTerrainCoro(LLCoros::self &self, std::string url, LinksetsResponder::ptr_t linksetsResponsderPtr, LLSD putData) const { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -642,11 +642,11 @@ void LLPathfindingManager::linksetTerrainCoro(std::string url, LinksetsResponder if (putData.isUndefined()) { - result = httpAdapter->getAndYield(httpRequest, url); + result = httpAdapter->getAndYield(self, httpRequest, url); } else { - result = httpAdapter->putAndYield(httpRequest, url, putData); + result = httpAdapter->putAndYield(self, httpRequest, url, putData); } LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; @@ -666,14 +666,14 @@ void LLPathfindingManager::linksetTerrainCoro(std::string url, LinksetsResponder } -void LLPathfindingManager::charactersCoro(std::string url, request_id_t requestId, object_request_callback_t callback) const +void LLPathfindingManager::charactersCoro(LLCoros::self &self, std::string url, request_id_t requestId, object_request_callback_t callback) const { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("LinksetTerrain", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLSD result = httpAdapter->getAndYield(httpRequest, url); + LLSD result = httpAdapter->getAndYield(self, httpRequest, url); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); diff --git a/indra/newview/llpathfindingmanager.h b/indra/newview/llpathfindingmanager.h index e8fad590ba..abf611801c 100755 --- a/indra/newview/llpathfindingmanager.h +++ b/indra/newview/llpathfindingmanager.h @@ -104,12 +104,12 @@ private: void handleDeferredGetLinksetsForRegion(const LLUUID &pRegionUUID, request_id_t pRequestId, object_request_callback_t pLinksetsCallback) const; void handleDeferredGetCharactersForRegion(const LLUUID &pRegionUUID, request_id_t pRequestId, object_request_callback_t pCharactersCallback) const; - void navMeshStatusRequestCoro(std::string url, U64 regionHandle, bool isGetStatusOnly); - void navAgentStateRequestCoro(std::string url); - void navMeshRebakeCoro(std::string url, rebake_navmesh_callback_t rebakeNavMeshCallback); - void linksetObjectsCoro(std::string url, boost::shared_ptr linksetsResponsderPtr, LLSD putData) const; - void linksetTerrainCoro(std::string url, boost::shared_ptr linksetsResponsderPtr, LLSD putData) const; - void charactersCoro(std::string url, request_id_t requestId, object_request_callback_t callback) const; + void navMeshStatusRequestCoro(LLCoros::self& self, std::string url, U64 regionHandle, bool isGetStatusOnly); + void navAgentStateRequestCoro(LLCoros::self& self, std::string url); + void navMeshRebakeCoro(LLCoros::self& self, std::string url, rebake_navmesh_callback_t rebakeNavMeshCallback); + void linksetObjectsCoro(LLCoros::self &self, std::string url, boost::shared_ptr linksetsResponsderPtr, LLSD putData) const; + void linksetTerrainCoro(LLCoros::self &self, std::string url, boost::shared_ptr linksetsResponsderPtr, LLSD putData) const; + void charactersCoro(LLCoros::self &self, std::string url, request_id_t requestId, object_request_callback_t callback) const; //void handleNavMeshStatusRequest(const LLPathfindingNavMeshStatus &pNavMeshStatus, LLViewerRegion *pRegion, bool pIsGetStatusOnly); void handleNavMeshStatusUpdate(const LLPathfindingNavMeshStatus &pNavMeshStatus); diff --git a/indra/newview/llproductinforequest.cpp b/indra/newview/llproductinforequest.cpp index 467e9df482..fd948765b3 100755 --- a/indra/newview/llproductinforequest.cpp +++ b/indra/newview/llproductinforequest.cpp @@ -45,7 +45,7 @@ void LLProductInfoRequestManager::initSingleton() if (!url.empty()) { LLCoros::instance().launch("LLProductInfoRequestManager::getLandDescriptionsCoro", - boost::bind(&LLProductInfoRequestManager::getLandDescriptionsCoro, this, url)); + boost::bind(&LLProductInfoRequestManager::getLandDescriptionsCoro, this, _1, url)); } } @@ -66,14 +66,14 @@ std::string LLProductInfoRequestManager::getDescriptionForSku(const std::string& return LLTrans::getString("land_type_unknown"); } -void LLProductInfoRequestManager::getLandDescriptionsCoro(std::string url) +void LLProductInfoRequestManager::getLandDescriptionsCoro(LLCoros::self& self, std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("genericPostCoro", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLSD result = httpAdapter->getAndYield(httpRequest, url); + LLSD result = httpAdapter->getAndYield(self, httpRequest, url); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); diff --git a/indra/newview/llproductinforequest.h b/indra/newview/llproductinforequest.h index 75dbf220d1..3ddae95a93 100755 --- a/indra/newview/llproductinforequest.h +++ b/indra/newview/llproductinforequest.h @@ -49,7 +49,7 @@ private: friend class LLSingleton; /* virtual */ void initSingleton(); - void getLandDescriptionsCoro(std::string url); + void getLandDescriptionsCoro(LLCoros::self& self, std::string url); LLSD mSkuDescriptions; }; diff --git a/indra/newview/llremoteparcelrequest.cpp b/indra/newview/llremoteparcelrequest.cpp index 06bf90c7cb..7e8e9ac18e 100755 --- a/indra/newview/llremoteparcelrequest.cpp +++ b/indra/newview/llremoteparcelrequest.cpp @@ -170,7 +170,7 @@ bool LLRemoteParcelInfoProcessor::requestRegionParcelInfo(const std::string &url if (!url.empty()) { LLCoros::instance().launch("LLRemoteParcelInfoProcessor::regionParcelInfoCoro", - boost::bind(&LLRemoteParcelInfoProcessor::regionParcelInfoCoro, this, url, + boost::bind(&LLRemoteParcelInfoProcessor::regionParcelInfoCoro, this, _1, url, regionId, regionPos, globalPos, observerHandle)); return true; } @@ -178,7 +178,7 @@ bool LLRemoteParcelInfoProcessor::requestRegionParcelInfo(const std::string &url return false; } -void LLRemoteParcelInfoProcessor::regionParcelInfoCoro(std::string url, +void LLRemoteParcelInfoProcessor::regionParcelInfoCoro(LLCoros::self& self, std::string url, LLUUID regionId, LLVector3 posRegion, LLVector3d posGlobal, LLHandle observerHandle) { @@ -200,7 +200,7 @@ void LLRemoteParcelInfoProcessor::regionParcelInfoCoro(std::string url, bodyData["region_handle"] = ll_sd_from_U64(regionHandle); } - LLSD result = httpAdapter->postAndYield(httpRequest, url, bodyData); + LLSD result = httpAdapter->postAndYield(self, httpRequest, url, bodyData); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); diff --git a/indra/newview/llremoteparcelrequest.h b/indra/newview/llremoteparcelrequest.h index cb5af50c5f..982a1590e5 100755 --- a/indra/newview/llremoteparcelrequest.h +++ b/indra/newview/llremoteparcelrequest.h @@ -91,7 +91,7 @@ private: typedef std::multimap > observer_multimap_t; observer_multimap_t mObservers; - void regionParcelInfoCoro(std::string url, LLUUID regionId, LLVector3 posRegion, LLVector3d posGlobal, LLHandle observerHandle); + void regionParcelInfoCoro(LLCoros::self& self, std::string url, LLUUID regionId, LLVector3 posRegion, LLVector3d posGlobal, LLHandle observerHandle); }; #endif // LL_LLREMOTEPARCELREQUEST_H diff --git a/indra/newview/llspeakers.cpp b/indra/newview/llspeakers.cpp index 3b060d8343..9a9739c9cb 100755 --- a/indra/newview/llspeakers.cpp +++ b/indra/newview/llspeakers.cpp @@ -841,7 +841,7 @@ void LLIMSpeakerMgr::toggleAllowTextChat(const LLUUID& speaker_id) data["params"]["mute_info"]["text"] = !speakerp->mModeratorMutedText; LLCoros::instance().launch("LLIMSpeakerMgr::moderationActionCoro", - boost::bind(&LLIMSpeakerMgr::moderationActionCoro, this, url, data)); + boost::bind(&LLIMSpeakerMgr::moderationActionCoro, this, _1, url, data)); } void LLIMSpeakerMgr::moderateVoiceParticipant(const LLUUID& avatar_id, bool unmute) @@ -866,10 +866,10 @@ void LLIMSpeakerMgr::moderateVoiceParticipant(const LLUUID& avatar_id, bool unmu data["params"]["mute_info"]["voice"] = !unmute; LLCoros::instance().launch("LLIMSpeakerMgr::moderationActionCoro", - boost::bind(&LLIMSpeakerMgr::moderationActionCoro, this, url, data)); + boost::bind(&LLIMSpeakerMgr::moderationActionCoro, this, _1, url, data)); } -void LLIMSpeakerMgr::moderationActionCoro(std::string url, LLSD action) +void LLIMSpeakerMgr::moderationActionCoro(LLCoros::self& self, std::string url, LLSD action) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -881,7 +881,7 @@ void LLIMSpeakerMgr::moderationActionCoro(std::string url, LLSD action) LLUUID sessionId = action["session-id"]; - LLSD result = httpAdapter->postAndYield(httpRequest, url, action, httpOpts); + LLSD result = httpAdapter->postAndYield(self, httpRequest, url, action, httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -948,7 +948,7 @@ void LLIMSpeakerMgr::moderateVoiceSession(const LLUUID& session_id, bool disallo data["params"]["update_info"]["moderated_mode"]["voice"] = disallow_voice; LLCoros::instance().launch("LLIMSpeakerMgr::moderationActionCoro", - boost::bind(&LLIMSpeakerMgr::moderationActionCoro, this, url, data)); + boost::bind(&LLIMSpeakerMgr::moderationActionCoro, this, _1, url, data)); } void LLIMSpeakerMgr::forceVoiceModeratedMode(bool should_be_muted) diff --git a/indra/newview/llspeakers.h b/indra/newview/llspeakers.h index 5cff70f377..1f3b2f584c 100755 --- a/indra/newview/llspeakers.h +++ b/indra/newview/llspeakers.h @@ -335,7 +335,7 @@ protected: */ void forceVoiceModeratedMode(bool should_be_muted); - void moderationActionCoro(std::string url, LLSD action); + void moderationActionCoro(LLCoros::self& self, std::string url, LLSD action); }; diff --git a/indra/newview/llsyntaxid.cpp b/indra/newview/llsyntaxid.cpp index 7f286044d6..d2197dcb4f 100644 --- a/indra/newview/llsyntaxid.cpp +++ b/indra/newview/llsyntaxid.cpp @@ -108,14 +108,14 @@ bool LLSyntaxIdLSL::syntaxIdChanged() void LLSyntaxIdLSL::fetchKeywordsFile(const std::string& filespec) { LLCoros::instance().launch("LLSyntaxIdLSL::fetchKeywordsFileCoro", - boost::bind(&LLSyntaxIdLSL::fetchKeywordsFileCoro, this, mCapabilityURL, filespec)); + boost::bind(&LLSyntaxIdLSL::fetchKeywordsFileCoro, this, _1, mCapabilityURL, filespec)); LL_DEBUGS("SyntaxLSL") << "LSLSyntaxId capability URL is: " << mCapabilityURL << ". Filename to use is: '" << filespec << "'." << LL_ENDL; } //----------------------------------------------------------------------------- // fetchKeywordsFileCoro //----------------------------------------------------------------------------- -void LLSyntaxIdLSL::fetchKeywordsFileCoro(std::string url, std::string fileSpec) +void LLSyntaxIdLSL::fetchKeywordsFileCoro(LLCoros::self& self, std::string url, std::string fileSpec) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -129,7 +129,7 @@ void LLSyntaxIdLSL::fetchKeywordsFileCoro(std::string url, std::string fileSpec) return; } - LLSD result = httpAdapter->getAndYield(httpRequest, url); + LLSD result = httpAdapter->getAndYield(self, httpRequest, url); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); diff --git a/indra/newview/llsyntaxid.h b/indra/newview/llsyntaxid.h index 0afa6dc04b..47de94cea2 100644 --- a/indra/newview/llsyntaxid.h +++ b/indra/newview/llsyntaxid.h @@ -57,7 +57,7 @@ private: void loadDefaultKeywordsIntoLLSD(); void loadKeywordsIntoLLSD(); - void fetchKeywordsFileCoro(std::string url, std::string fileSpec); + void fetchKeywordsFileCoro(LLCoros::self& self, std::string url, std::string fileSpec); void cacheFile(const std::string &fileSpec, const LLSD& content_ref); std::string mCapabilityURL; diff --git a/indra/newview/lltwitterconnect.cpp b/indra/newview/lltwitterconnect.cpp index c6a0a15759..09435850c3 100644 --- a/indra/newview/lltwitterconnect.cpp +++ b/indra/newview/lltwitterconnect.cpp @@ -67,7 +67,7 @@ void toast_user_for_twitter_success() /////////////////////////////////////////////////////////////////////////////// // -void LLTwitterConnect::twitterConnectCoro(std::string requestToken, std::string oauthVerifier) +void LLTwitterConnect::twitterConnectCoro(LLCoros::self& self, std::string requestToken, std::string oauthVerifier) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -86,7 +86,7 @@ void LLTwitterConnect::twitterConnectCoro(std::string requestToken, std::string setConnectionState(LLTwitterConnect::TWITTER_CONNECTION_IN_PROGRESS); - LLSD result = httpAdapter->putAndYield(httpRequest, getTwitterConnectURL("/connection"), body, httpOpts); + LLSD result = httpAdapter->putAndYield(self, httpRequest, getTwitterConnectURL("/connection"), body, httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -157,7 +157,7 @@ bool LLTwitterConnect::testShareStatus(LLSD &result) return false; } -void LLTwitterConnect::twitterShareCoro(std::string route, LLSD share) +void LLTwitterConnect::twitterShareCoro(LLCoros::self& self, std::string route, LLSD share) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -170,7 +170,7 @@ void LLTwitterConnect::twitterShareCoro(std::string route, LLSD share) setConnectionState(LLTwitterConnect::TWITTER_POSTING); - LLSD result = httpAdapter->postAndYield(httpRequest, getTwitterConnectURL(route, true), share, httpOpts); + LLSD result = httpAdapter->postAndYield(self, httpRequest, getTwitterConnectURL(route, true), share, httpOpts); if (testShareStatus(result)) { @@ -180,7 +180,7 @@ void LLTwitterConnect::twitterShareCoro(std::string route, LLSD share) } } -void LLTwitterConnect::twitterShareImageCoro(LLPointer image, std::string status) +void LLTwitterConnect::twitterShareImageCoro(LLCoros::self& self, LLPointer image, std::string status) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -235,7 +235,7 @@ void LLTwitterConnect::twitterShareImageCoro(LLPointer image, body << "\r\n--" << boundary << "--\r\n"; - LLSD result = httpAdapter->postAndYield(httpRequest, getTwitterConnectURL("/share/photo", true), raw, httpOpts, httpHeaders); + LLSD result = httpAdapter->postAndYield(self, httpRequest, getTwitterConnectURL("/share/photo", true), raw, httpOpts, httpHeaders); if (testShareStatus(result)) { @@ -247,7 +247,7 @@ void LLTwitterConnect::twitterShareImageCoro(LLPointer image, /////////////////////////////////////////////////////////////////////////////// // -void LLTwitterConnect::twitterDisconnectCoro() +void LLTwitterConnect::twitterDisconnectCoro(LLCoros::self& self) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -259,7 +259,7 @@ void LLTwitterConnect::twitterDisconnectCoro() setConnectionState(LLTwitterConnect::TWITTER_DISCONNECTING); - LLSD result = httpAdapter->deleteAndYield(httpRequest, getTwitterConnectURL("/connection"), httpOpts); + LLSD result = httpAdapter->deleteAndYield(self, httpRequest, getTwitterConnectURL("/connection"), httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -282,7 +282,7 @@ void LLTwitterConnect::twitterDisconnectCoro() /////////////////////////////////////////////////////////////////////////////// // -void LLTwitterConnect::twitterConnectedCoro(bool autoConnect) +void LLTwitterConnect::twitterConnectedCoro(LLCoros::self& self, bool autoConnect) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -293,7 +293,7 @@ void LLTwitterConnect::twitterConnectedCoro(bool autoConnect) httpOpts->setFollowRedirects(false); setConnectionState(LLTwitterConnect::TWITTER_CONNECTION_IN_PROGRESS); - LLSD result = httpAdapter->getAndYield(httpRequest, getTwitterConnectURL("/connection", true), httpOpts); + LLSD result = httpAdapter->getAndYield(self, httpRequest, getTwitterConnectURL("/connection", true), httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -331,7 +331,7 @@ void LLTwitterConnect::twitterConnectedCoro(bool autoConnect) /////////////////////////////////////////////////////////////////////////////// // -void LLTwitterConnect::twitterInfoCoro() +void LLTwitterConnect::twitterInfoCoro(LLCoros::self& self) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -342,7 +342,7 @@ void LLTwitterConnect::twitterInfoCoro() httpOpts->setWantHeaders(true); httpOpts->setFollowRedirects(false); - LLSD result = httpAdapter->getAndYield(httpRequest, getTwitterConnectURL("/info", true), httpOpts); + LLSD result = httpAdapter->getAndYield(self, httpRequest, getTwitterConnectURL("/info", true), httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -425,19 +425,19 @@ std::string LLTwitterConnect::getTwitterConnectURL(const std::string& route, boo void LLTwitterConnect::connectToTwitter(const std::string& request_token, const std::string& oauth_verifier) { LLCoros::instance().launch("LLTwitterConnect::twitterConnectCoro", - boost::bind(&LLTwitterConnect::twitterConnectCoro, this, request_token, oauth_verifier)); + boost::bind(&LLTwitterConnect::twitterConnectCoro, this, _1, request_token, oauth_verifier)); } void LLTwitterConnect::disconnectFromTwitter() { LLCoros::instance().launch("LLTwitterConnect::twitterDisconnectCoro", - boost::bind(&LLTwitterConnect::twitterDisconnectCoro, this)); + boost::bind(&LLTwitterConnect::twitterDisconnectCoro, this, _1)); } void LLTwitterConnect::checkConnectionToTwitter(bool auto_connect) { LLCoros::instance().launch("LLTwitterConnect::twitterConnectedCoro", - boost::bind(&LLTwitterConnect::twitterConnectedCoro, this, auto_connect)); + boost::bind(&LLTwitterConnect::twitterConnectedCoro, this, _1, auto_connect)); } void LLTwitterConnect::loadTwitterInfo() @@ -445,7 +445,7 @@ void LLTwitterConnect::loadTwitterInfo() if(mRefreshInfo) { LLCoros::instance().launch("LLTwitterConnect::twitterInfoCoro", - boost::bind(&LLTwitterConnect::twitterInfoCoro, this)); + boost::bind(&LLTwitterConnect::twitterInfoCoro, this, _1)); } } @@ -456,13 +456,13 @@ void LLTwitterConnect::uploadPhoto(const std::string& image_url, const std::stri body["status"] = status; LLCoros::instance().launch("LLTwitterConnect::twitterShareCoro", - boost::bind(&LLTwitterConnect::twitterShareCoro, this, "/share/photo", body)); + boost::bind(&LLTwitterConnect::twitterShareCoro, this, _1, "/share/photo", body)); } void LLTwitterConnect::uploadPhoto(LLPointer image, const std::string& status) { LLCoros::instance().launch("LLTwitterConnect::twitterShareImageCoro", - boost::bind(&LLTwitterConnect::twitterShareImageCoro, this, image, status)); + boost::bind(&LLTwitterConnect::twitterShareImageCoro, this, _1, image, status)); } void LLTwitterConnect::updateStatus(const std::string& status) @@ -471,7 +471,7 @@ void LLTwitterConnect::updateStatus(const std::string& status) body["status"] = status; LLCoros::instance().launch("LLTwitterConnect::twitterShareCoro", - boost::bind(&LLTwitterConnect::twitterShareCoro, this, "/share/status", body)); + boost::bind(&LLTwitterConnect::twitterShareCoro, this, _1, "/share/status", body)); } void LLTwitterConnect::storeInfo(const LLSD& info) diff --git a/indra/newview/lltwitterconnect.h b/indra/newview/lltwitterconnect.h index be481a17c1..4d11118143 100644 --- a/indra/newview/lltwitterconnect.h +++ b/indra/newview/lltwitterconnect.h @@ -98,12 +98,12 @@ private: static boost::scoped_ptr sContentWatcher; bool testShareStatus(LLSD &result); - void twitterConnectCoro(std::string requestToken, std::string oauthVerifier); - void twitterDisconnectCoro(); - void twitterConnectedCoro(bool autoConnect); - void twitterInfoCoro(); - void twitterShareCoro(std::string route, LLSD share); - void twitterShareImageCoro(LLPointer image, std::string status); + void twitterConnectCoro(LLCoros::self& self, std::string requestToken, std::string oauthVerifier); + void twitterDisconnectCoro(LLCoros::self& self); + void twitterConnectedCoro(LLCoros::self& self, bool autoConnect); + void twitterInfoCoro(LLCoros::self& self); + void twitterShareCoro(LLCoros::self& self, std::string route, LLSD share); + void twitterShareImageCoro(LLCoros::self& self, LLPointer image, std::string status); }; #endif // LL_LLTWITTERCONNECT_H diff --git a/indra/newview/llviewerassetupload.cpp b/indra/newview/llviewerassetupload.cpp index cd4e7c33ef..e2394e20d5 100644 --- a/indra/newview/llviewerassetupload.cpp +++ b/indra/newview/llviewerassetupload.cpp @@ -46,7 +46,7 @@ //========================================================================= /*static*/ -void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &httpAdapter, const LLUUID &id, +void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoros::self &self, LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &httpAdapter, const LLUUID &id, std::string url, NewResourceUploadInfo::ptr_t uploadInfo) { LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); @@ -68,7 +68,7 @@ void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoreHttpUtil::HttpCorouti LLSD body = uploadInfo->generatePostBody(); - result = httpAdapter->postAndYield(httpRequest, url, body); + result = httpAdapter->postAndYield(self, httpRequest, url, body); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -82,7 +82,7 @@ void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoreHttpUtil::HttpCorouti std::string uploader = result["uploader"].asString(); - result = httpAdapter->postFileAndYield(httpRequest, uploader, uploadInfo->getAssetId(), uploadInfo->getAssetType()); + result = httpAdapter->postFileAndYield(self, httpRequest, uploader, uploadInfo->getAssetId(), uploadInfo->getAssetType()); httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); diff --git a/indra/newview/llviewerassetupload.h b/indra/newview/llviewerassetupload.h index 38167fc0c7..ad48be67a6 100644 --- a/indra/newview/llviewerassetupload.h +++ b/indra/newview/llviewerassetupload.h @@ -41,7 +41,7 @@ class LLViewerAssetUpload { public: - static void AssetInventoryUploadCoproc(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &httpAdapter, const LLUUID &id, + static void AssetInventoryUploadCoproc(LLCoros::self &self, LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &httpAdapter, const LLUUID &id, std::string url, NewResourceUploadInfo::ptr_t uploadInfo); private: diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp index f332a4e98e..6d0fce46aa 100755 --- a/indra/newview/llviewermedia.cpp +++ b/indra/newview/llviewermedia.cpp @@ -1226,12 +1226,12 @@ void LLViewerMedia::setOpenIDCookie() std::string profileUrl = getProfileURL(""); LLCoros::instance().launch("LLViewerMedia::getOpenIDCookieCoro", - boost::bind(&LLViewerMedia::getOpenIDCookieCoro, profileUrl)); + boost::bind(&LLViewerMedia::getOpenIDCookieCoro, _1, profileUrl)); } } /*static*/ -void LLViewerMedia::getOpenIDCookieCoro(std::string url) +void LLViewerMedia::getOpenIDCookieCoro(LLCoros::self& self, std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -1280,7 +1280,7 @@ void LLViewerMedia::getOpenIDCookieCoro(std::string url) LL_DEBUGS("MediaAuth") << "Requesting " << url << LL_ENDL; LL_DEBUGS("MediaAuth") << "sOpenIDCookie = [" << sOpenIDCookie << "]" << LL_ENDL; - LLSD result = httpAdapter->getRawAndYield(httpRequest, url, httpOpts, httpHeaders); + LLSD result = httpAdapter->getRawAndYield(self, httpRequest, url, httpOpts, httpHeaders); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -1317,11 +1317,11 @@ void LLViewerMedia::openIDSetup(const std::string &openidUrl, const std::string LL_DEBUGS("MediaAuth") << "url = \"" << openidUrl << "\", token = \"" << openidToken << "\"" << LL_ENDL; LLCoros::instance().launch("LLViewerMedia::openIDSetupCoro", - boost::bind(&LLViewerMedia::openIDSetupCoro, openidUrl, openidToken)); + boost::bind(&LLViewerMedia::openIDSetupCoro, _1, openidUrl, openidToken)); } /*static*/ -void LLViewerMedia::openIDSetupCoro(std::string openidUrl, std::string openidToken) +void LLViewerMedia::openIDSetupCoro(LLCoros::self& self, std::string openidUrl, std::string openidToken) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -1347,7 +1347,7 @@ void LLViewerMedia::openIDSetupCoro(std::string openidUrl, std::string openidTok bas << std::noskipws << openidToken; - LLSD result = httpAdapter->postRawAndYield(httpRequest, openidUrl, rawbody, httpOpts, httpHeaders); + LLSD result = httpAdapter->postRawAndYield(self, httpRequest, openidUrl, rawbody, httpOpts, httpHeaders); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -2553,7 +2553,7 @@ void LLViewerMediaImpl::navigateInternal() if(scheme.empty() || "http" == scheme || "https" == scheme) { LLCoros::instance().launch("LLViewerMediaImpl::mimeDiscoveryCoro", - boost::bind(&LLViewerMediaImpl::mimeDiscoveryCoro, this, mMediaURL)); + boost::bind(&LLViewerMediaImpl::mimeDiscoveryCoro, this, _1, mMediaURL)); } else if("data" == scheme || "file" == scheme || "about" == scheme) { @@ -2583,7 +2583,7 @@ void LLViewerMediaImpl::navigateInternal() } } -void LLViewerMediaImpl::mimeDiscoveryCoro(std::string url) +void LLViewerMediaImpl::mimeDiscoveryCoro(LLCoros::self& self, std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -2600,7 +2600,7 @@ void LLViewerMediaImpl::mimeDiscoveryCoro(std::string url) httpHeaders->append(HTTP_OUT_HEADER_ACCEPT, "*/*"); httpHeaders->append(HTTP_OUT_HEADER_COOKIE, ""); - LLSD result = httpAdapter->getRawAndYield(httpRequest, url, httpOpts, httpHeaders); + LLSD result = httpAdapter->getRawAndYield(self, httpRequest, url, httpOpts, httpHeaders); mMimeProbe.reset(); diff --git a/indra/newview/llviewermedia.h b/indra/newview/llviewermedia.h index 92d644c900..ff9840627c 100755 --- a/indra/newview/llviewermedia.h +++ b/indra/newview/llviewermedia.h @@ -170,8 +170,8 @@ private: static void setOpenIDCookie(); static void onTeleportFinished(); - static void openIDSetupCoro(std::string openidUrl, std::string openidToken); - static void getOpenIDCookieCoro(std::string url); + static void openIDSetupCoro(LLCoros::self& self, std::string openidUrl, std::string openidToken); + static void getOpenIDCookieCoro(LLCoros::self& self, std::string url); static LLPluginCookieStore *sCookieStore; static LLURL sOpenIDURL; @@ -475,7 +475,7 @@ private: BOOL mIsUpdated ; std::list< LLVOVolume* > mObjectList ; - void mimeDiscoveryCoro(std::string url); + void mimeDiscoveryCoro(LLCoros::self& self, std::string url); LLCoreHttpUtil::HttpCoroutineAdapter::wptr_t mMimeProbe; bool mCanceling; diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index e9eb0e807a..4772dd144b 100755 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -929,7 +929,7 @@ void upload_new_resource( if ( !url.empty() ) { - LLCoprocedureManager::CoProcedure_t proc = boost::bind(&LLViewerAssetUpload::AssetInventoryUploadCoproc, _1, _2, url, uploadInfo); + LLCoprocedureManager::CoProcedure_t proc = boost::bind(&LLViewerAssetUpload::AssetInventoryUploadCoproc, _1, _2, _3, url, uploadInfo); LLCoprocedureManager::getInstance()->enqueueCoprocedure("LLViewerAssetUpload::AssetInventoryUploadCoproc", proc); } diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp index 2a009499d3..1c3e2aec01 100755 --- a/indra/newview/llviewerobjectlist.cpp +++ b/indra/newview/llviewerobjectlist.cpp @@ -992,7 +992,7 @@ void LLViewerObjectList::fetchObjectCosts() if (!url.empty()) { LLCoros::instance().launch("LLViewerObjectList::fetchObjectCostsCoro", - boost::bind(&LLViewerObjectList::fetchObjectCostsCoro, this, url)); + boost::bind(&LLViewerObjectList::fetchObjectCostsCoro, this, _1, url)); } else { @@ -1014,7 +1014,7 @@ void LLViewerObjectList::reportObjectCostFailure(LLSD &objectList) } -void LLViewerObjectList::fetchObjectCostsCoro(std::string url) +void LLViewerObjectList::fetchObjectCostsCoro(LLCoros::self& self, std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -1052,7 +1052,7 @@ void LLViewerObjectList::fetchObjectCostsCoro(std::string url) postData["object_ids"] = idList; - LLSD result = httpAdapter->postAndYield(httpRequest, url, postData); + LLSD result = httpAdapter->postAndYield(self, httpRequest, url, postData); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -1122,7 +1122,7 @@ void LLViewerObjectList::fetchPhysicsFlags() if (!url.empty()) { LLCoros::instance().launch("LLViewerObjectList::fetchPhisicsFlagsCoro", - boost::bind(&LLViewerObjectList::fetchPhisicsFlagsCoro, this, url)); + boost::bind(&LLViewerObjectList::fetchPhisicsFlagsCoro, this, _1, url)); } else { @@ -1143,7 +1143,7 @@ void LLViewerObjectList::reportPhysicsFlagFailure(LLSD &objectList) } } -void LLViewerObjectList::fetchPhisicsFlagsCoro(std::string url) +void LLViewerObjectList::fetchPhisicsFlagsCoro(LLCoros::self& self, std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -1181,7 +1181,7 @@ void LLViewerObjectList::fetchPhisicsFlagsCoro(std::string url) postData["object_ids"] = idList; - LLSD result = httpAdapter->postAndYield(httpRequest, url, postData); + LLSD result = httpAdapter->postAndYield(self, httpRequest, url, postData); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); diff --git a/indra/newview/llviewerobjectlist.h b/indra/newview/llviewerobjectlist.h index 9ec7c4bc22..f849813f0a 100755 --- a/indra/newview/llviewerobjectlist.h +++ b/indra/newview/llviewerobjectlist.h @@ -232,10 +232,10 @@ protected: private: static void reportObjectCostFailure(LLSD &objectList); - void fetchObjectCostsCoro(std::string url); + void fetchObjectCostsCoro(LLCoros::self& self, std::string url); static void reportPhysicsFlagFailure(LLSD &obejectList); - void fetchPhisicsFlagsCoro(std::string url); + void fetchPhisicsFlagsCoro(LLCoros::self& self, std::string url); }; diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index b256482289..f0015ceef1 100755 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -219,12 +219,12 @@ public: LLVector3 mLastCameraOrigin; U32 mLastCameraUpdate; - void requestBaseCapabilitiesCoro(U64 regionHandle); - void requestBaseCapabilitiesCompleteCoro(U64 regionHandle); - void requestSimulatorFeatureCoro(std::string url, U64 regionHandle); + void requestBaseCapabilitiesCoro(LLCoros::self& self, U64 regionHandle); + void requestBaseCapabilitiesCompleteCoro(LLCoros::self& self, U64 regionHandle); + void requestSimulatorFeatureCoro(LLCoros::self& self, std::string url, U64 regionHandle); }; -void LLViewerRegionImpl::requestBaseCapabilitiesCoro(U64 regionHandle) +void LLViewerRegionImpl::requestBaseCapabilitiesCoro(LLCoros::self& self, U64 regionHandle) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -275,7 +275,7 @@ void LLViewerRegionImpl::requestBaseCapabilitiesCoro(U64 regionHandle) << " (attempt #" << mSeedCapAttempts << ")" << LL_ENDL; regionp = NULL; - result = httpAdapter->postAndYield(httpRequest, url, capabilityNames); + result = httpAdapter->postAndYield(self, httpRequest, url, capabilityNames); regionp = LLWorld::getInstance()->getRegionFromHandle(regionHandle); if (!regionp) //region was removed @@ -332,7 +332,7 @@ void LLViewerRegionImpl::requestBaseCapabilitiesCoro(U64 regionHandle) } -void LLViewerRegionImpl::requestBaseCapabilitiesCompleteCoro(U64 regionHandle) +void LLViewerRegionImpl::requestBaseCapabilitiesCompleteCoro(LLCoros::self& self, U64 regionHandle) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -365,7 +365,7 @@ void LLViewerRegionImpl::requestBaseCapabilitiesCompleteCoro(U64 regionHandle) LL_INFOS("AppInit", "Capabilities") << "Requesting second Seed from " << url << LL_ENDL; regionp = NULL; - result = httpAdapter->postAndYield(httpRequest, url, capabilityNames); + result = httpAdapter->postAndYield(self, httpRequest, url, capabilityNames); LLSD httpResults = result["http_result"]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -435,7 +435,7 @@ void LLViewerRegionImpl::requestBaseCapabilitiesCompleteCoro(U64 regionHandle) } -void LLViewerRegionImpl::requestSimulatorFeatureCoro(std::string url, U64 regionHandle) +void LLViewerRegionImpl::requestSimulatorFeatureCoro(LLCoros::self& self, std::string url, U64 regionHandle) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -464,7 +464,7 @@ void LLViewerRegionImpl::requestSimulatorFeatureCoro(std::string url, U64 region } regionp = NULL; - LLSD result = httpAdapter->getAndYield(httpRequest, url); + LLSD result = httpAdapter->getAndYield(self, httpRequest, url); LLSD httpResults = result["http_result"]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -2908,7 +2908,7 @@ void LLViewerRegion::setSeedCapability(const std::string& url) //to the "original" seed cap received and determine why there is problem! std::string coroname = LLCoros::instance().launch("LLEnvironmentRequest::requestBaseCapabilitiesCompleteCoro", - boost::bind(&LLViewerRegionImpl::requestBaseCapabilitiesCompleteCoro, mImpl, getHandle())); + boost::bind(&LLViewerRegionImpl::requestBaseCapabilitiesCompleteCoro, mImpl, _1, getHandle())); return; } @@ -2920,7 +2920,7 @@ void LLViewerRegion::setSeedCapability(const std::string& url) std::string coroname = LLCoros::instance().launch("LLEnvironmentRequest::environmentRequestCoro", - boost::bind(&LLViewerRegionImpl::requestBaseCapabilitiesCoro, mImpl, getHandle())); + boost::bind(&LLViewerRegionImpl::requestBaseCapabilitiesCoro, mImpl, _1, getHandle())); LL_INFOS("AppInit", "Capabilities") << "Launching " << coroname << " requesting seed capabilities from " << url << LL_ENDL; } @@ -2947,7 +2947,7 @@ void LLViewerRegion::setCapability(const std::string& name, const std::string& u // kick off a request for simulator features std::string coroname = LLCoros::instance().launch("LLViewerRegionImpl::requestSimulatorFeatureCoro", - boost::bind(&LLViewerRegionImpl::requestSimulatorFeatureCoro, mImpl, url, getHandle())); + boost::bind(&LLViewerRegionImpl::requestSimulatorFeatureCoro, mImpl, _1, url, getHandle())); LL_INFOS("AppInit", "SimulatorFeatures") << "Launching " << coroname << " requesting simulator features from " << url << LL_ENDL; } diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp index 7c460ce097..ba4fd59feb 100755 --- a/indra/newview/llvoavatarself.cpp +++ b/indra/newview/llvoavatarself.cpp @@ -2190,7 +2190,7 @@ const std::string LLVOAvatarSelf::debugDumpAllLocalTextureDataInfo() const return text; } -void LLVOAvatarSelf::appearanceChangeMetricsCoro(std::string url) +void LLVOAvatarSelf::appearanceChangeMetricsCoro(LLCoros::self& self, std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -2242,7 +2242,7 @@ void LLVOAvatarSelf::appearanceChangeMetricsCoro(std::string url) gPendingMetricsUploads++; - LLSD result = httpAdapter->postAndYield(httpRequest, url, msg); + LLSD result = httpAdapter->postAndYield(self, httpRequest, url, msg); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -2347,7 +2347,7 @@ void LLVOAvatarSelf::sendViewerAppearanceChangeMetrics() { LLCoros::instance().launch("LLVOAvatarSelf::appearanceChangeMetricsCoro", - boost::bind(&LLVOAvatarSelf::appearanceChangeMetricsCoro, this, caps_url)); + boost::bind(&LLVOAvatarSelf::appearanceChangeMetricsCoro, this, _1, caps_url)); mTimeSinceLastRezMessage.reset(); } } diff --git a/indra/newview/llvoavatarself.h b/indra/newview/llvoavatarself.h index d32c959fb5..b3b5fe6c2f 100755 --- a/indra/newview/llvoavatarself.h +++ b/indra/newview/llvoavatarself.h @@ -402,7 +402,7 @@ private: F32 mDebugBakedTextureTimes[LLAvatarAppearanceDefines::BAKED_NUM_INDICES][2]; // time to start upload and finish upload of each baked texture void debugTimingLocalTexLoaded(BOOL success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata); - void appearanceChangeMetricsCoro(std::string url); + void appearanceChangeMetricsCoro(LLCoros::self& self, std::string url); bool mInitialMetric; S32 mMetricSequence; /** Diagnostics diff --git a/indra/newview/llvoicechannel.cpp b/indra/newview/llvoicechannel.cpp index 192d50ae9b..338201aab1 100755 --- a/indra/newview/llvoicechannel.cpp +++ b/indra/newview/llvoicechannel.cpp @@ -481,7 +481,7 @@ void LLVoiceChannelGroup::getChannelInfo() std::string url = region->getCapability("ChatSessionRequest"); LLCoros::instance().launch("LLVoiceChannelGroup::voiceCallCapCoro", - boost::bind(&LLVoiceChannelGroup::voiceCallCapCoro, this, url)); + boost::bind(&LLVoiceChannelGroup::voiceCallCapCoro, this, _1, url)); } } @@ -604,7 +604,7 @@ void LLVoiceChannelGroup::setState(EState state) } } -void LLVoiceChannelGroup::voiceCallCapCoro(std::string url) +void LLVoiceChannelGroup::voiceCallCapCoro(LLCoros::self& self, std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -617,7 +617,7 @@ void LLVoiceChannelGroup::voiceCallCapCoro(std::string url) LL_INFOS("Voice", "voiceCallCapCoro") << "Generic POST for " << url << LL_ENDL; - LLSD result = httpAdapter->postAndYield(httpRequest, url, postData); + LLSD result = httpAdapter->postAndYield(self, httpRequest, url, postData); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); diff --git a/indra/newview/llvoicechannel.h b/indra/newview/llvoicechannel.h index ef15b2c79e..0dac0b1f6a 100755 --- a/indra/newview/llvoicechannel.h +++ b/indra/newview/llvoicechannel.h @@ -159,7 +159,7 @@ protected: virtual void setState(EState state); private: - void voiceCallCapCoro(std::string url); + void voiceCallCapCoro(LLCoros::self& self, std::string url); U32 mRetries; BOOL mIsRetrying; diff --git a/indra/newview/llvoicevivox.cpp b/indra/newview/llvoicevivox.cpp index f50ffdeae7..c70ce5801d 100755 --- a/indra/newview/llvoicevivox.cpp +++ b/indra/newview/llvoicevivox.cpp @@ -446,13 +446,13 @@ void LLVivoxVoiceClient::requestVoiceAccountProvision(S32 retries) if ( !url.empty() ) { LLCoros::instance().launch("LLVivoxVoiceClient::voiceAccountProvisionCoro", - boost::bind(&LLVivoxVoiceClient::voiceAccountProvisionCoro, this, url, retries)); + boost::bind(&LLVivoxVoiceClient::voiceAccountProvisionCoro, this, _1, url, retries)); setState(stateConnectorStart); } } } -void LLVivoxVoiceClient::voiceAccountProvisionCoro(std::string url, S32 retries) +void LLVivoxVoiceClient::voiceAccountProvisionCoro(LLCoros::self& self, std::string url, S32 retries) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -462,7 +462,7 @@ void LLVivoxVoiceClient::voiceAccountProvisionCoro(std::string url, S32 retries) httpOpts->setRetries(retries); - LLSD result = httpAdapter->postAndYield(httpRequest, url, LLSD(), httpOpts); + LLSD result = httpAdapter->postAndYield(self, httpRequest, url, LLSD(), httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -3928,12 +3928,12 @@ bool LLVivoxVoiceClient::requestParcelVoiceInfo() LL_DEBUGS("Voice") << "sending ParcelVoiceInfoRequest (" << mCurrentRegionName << ", " << mCurrentParcelLocalID << ")" << LL_ENDL; LLCoros::instance().launch("LLVivoxVoiceClient::parcelVoiceInfoRequestCoro", - boost::bind(&LLVivoxVoiceClient::parcelVoiceInfoRequestCoro, this, url)); + boost::bind(&LLVivoxVoiceClient::parcelVoiceInfoRequestCoro, this, _1, url)); return true; } } -void LLVivoxVoiceClient::parcelVoiceInfoRequestCoro(std::string url) +void LLVivoxVoiceClient::parcelVoiceInfoRequestCoro(LLCoros::self& self, std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -3941,7 +3941,7 @@ void LLVivoxVoiceClient::parcelVoiceInfoRequestCoro(std::string url) LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); state requestingState = getState(); - LLSD result = httpAdapter->postAndYield(httpRequest, url, LLSD()); + LLSD result = httpAdapter->postAndYield(self, httpRequest, url, LLSD()); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); diff --git a/indra/newview/llvoicevivox.h b/indra/newview/llvoicevivox.h index b12ed80e41..a3cdb342e2 100755 --- a/indra/newview/llvoicevivox.h +++ b/indra/newview/llvoicevivox.h @@ -637,8 +637,8 @@ protected: private: - void voiceAccountProvisionCoro(std::string url, S32 retries); - void parcelVoiceInfoRequestCoro(std::string url); + void voiceAccountProvisionCoro(LLCoros::self& self, std::string url, S32 retries); + void parcelVoiceInfoRequestCoro(LLCoros::self& self, std::string url); LLVoiceVersionInfo mVoiceVersion; diff --git a/indra/newview/llwebprofile.cpp b/indra/newview/llwebprofile.cpp index 2033a5f36a..62ba40ca32 100755 --- a/indra/newview/llwebprofile.cpp +++ b/indra/newview/llwebprofile.cpp @@ -67,7 +67,7 @@ LLWebProfile::status_callback_t LLWebProfile::mStatusCallback; void LLWebProfile::uploadImage(LLPointer image, const std::string& caption, bool add_location) { LLCoros::instance().launch("LLWebProfile::uploadImageCoro", - boost::bind(&LLWebProfile::uploadImageCoro, image, caption, add_location)); + boost::bind(&LLWebProfile::uploadImageCoro, _1, image, caption, add_location)); } @@ -95,7 +95,7 @@ LLCore::HttpHeaders::ptr_t LLWebProfile::buildDefaultHeaders() /*static*/ -void LLWebProfile::uploadImageCoro(LLPointer image, std::string caption, bool addLocation) +void LLWebProfile::uploadImageCoro(LLCoros::self& self, LLPointer image, std::string caption, bool addLocation) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -124,7 +124,7 @@ void LLWebProfile::uploadImageCoro(LLPointer image, std::strin httpHeaders = buildDefaultHeaders(); httpHeaders->append(HTTP_OUT_HEADER_COOKIE, getAuthCookie()); - LLSD result = httpAdapter->getJsonAndYield(httpRequest, configUrl, httpOpts, httpHeaders); + LLSD result = httpAdapter->getJsonAndYield(self, httpRequest, configUrl, httpOpts, httpHeaders); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -150,7 +150,7 @@ void LLWebProfile::uploadImageCoro(LLPointer image, std::strin LLCore::BufferArray::ptr_t body = LLWebProfile::buildPostData(data, image, boundary); - result = httpAdapter->postAndYield(httpRequest, uploadUrl, body, httpOpts, httpHeaders); + result = httpAdapter->postAndYield(self, httpRequest, uploadUrl, body, httpOpts, httpHeaders); body.reset(); httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; @@ -178,7 +178,7 @@ void LLWebProfile::uploadImageCoro(LLPointer image, std::strin LL_DEBUGS("Snapshots") << "Got redirection URL: " << redirUrl << LL_ENDL; - result = httpAdapter->getRawAndYield(httpRequest, redirUrl, httpOpts, httpHeaders); + result = httpAdapter->getRawAndYield(self, httpRequest, redirUrl, httpOpts, httpHeaders); httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); diff --git a/indra/newview/llwebprofile.h b/indra/newview/llwebprofile.h index 6227e00afe..604ef7aff7 100755 --- a/indra/newview/llwebprofile.h +++ b/indra/newview/llwebprofile.h @@ -60,7 +60,7 @@ public: private: static LLCore::HttpHeaders::ptr_t buildDefaultHeaders(); - static void uploadImageCoro(LLPointer image, std::string caption, bool add_location); + static void uploadImageCoro(LLCoros::self& self, LLPointer image, std::string caption, bool add_location); static LLCore::BufferArray::ptr_t buildPostData(const LLSD &data, LLPointer &image, const std::string &boundary); static void reportImageUploadStatus(bool ok); diff --git a/indra/newview/llwlhandlers.cpp b/indra/newview/llwlhandlers.cpp index ff15afa598..3145c3f38d 100755 --- a/indra/newview/llwlhandlers.cpp +++ b/indra/newview/llwlhandlers.cpp @@ -84,7 +84,7 @@ bool LLEnvironmentRequest::doRequest() std::string coroname = LLCoros::instance().launch("LLEnvironmentRequest::environmentRequestCoro", - boost::bind(&LLEnvironmentRequest::environmentRequestCoro, url)); + boost::bind(&LLEnvironmentRequest::environmentRequestCoro, _1, url)); LL_INFOS("WindlightCaps") << "Requesting region windlight settings via " << url << LL_ENDL; return true; @@ -93,7 +93,7 @@ bool LLEnvironmentRequest::doRequest() S32 LLEnvironmentRequest::sLastRequest = 0; //static -void LLEnvironmentRequest::environmentRequestCoro(std::string url) +void LLEnvironmentRequest::environmentRequestCoro(LLCoros::self& self, std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); S32 requestId = ++LLEnvironmentRequest::sLastRequest; @@ -101,7 +101,7 @@ void LLEnvironmentRequest::environmentRequestCoro(std::string url) httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("EnvironmentRequest", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLSD result = httpAdapter->getAndYield(httpRequest, url); + LLSD result = httpAdapter->getAndYield(self, httpRequest, url); if (requestId != LLEnvironmentRequest::sLastRequest) { @@ -174,18 +174,18 @@ bool LLEnvironmentApply::initiateRequest(const LLSD& content) std::string coroname = LLCoros::instance().launch("LLEnvironmentApply::environmentApplyCoro", - boost::bind(&LLEnvironmentApply::environmentApplyCoro, url, content)); + boost::bind(&LLEnvironmentApply::environmentApplyCoro, _1, url, content)); return true; } -void LLEnvironmentApply::environmentApplyCoro(std::string url, LLSD content) +void LLEnvironmentApply::environmentApplyCoro(LLCoros::self& self, std::string url, LLSD content) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("EnvironmentApply", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLSD result = httpAdapter->postAndYield(httpRequest, url, content); + LLSD result = httpAdapter->postAndYield(self, httpRequest, url, content); LLSD notify; // for error reporting. If there is something to report to user this will be defined. /* diff --git a/indra/newview/llwlhandlers.h b/indra/newview/llwlhandlers.h index eb2bbf9553..0b778901ad 100755 --- a/indra/newview/llwlhandlers.h +++ b/indra/newview/llwlhandlers.h @@ -41,7 +41,7 @@ private: static void onRegionCapsReceived(const LLUUID& region_id); static bool doRequest(); - static void environmentRequestCoro(std::string url); + static void environmentRequestCoro(LLCoros::self& self, std::string url); static S32 sLastRequest; }; @@ -57,7 +57,7 @@ private: static clock_t sLastUpdate; static clock_t UPDATE_WAIT_SECONDS; - static void environmentApplyCoro(std::string url, LLSD content); + static void environmentApplyCoro(LLCoros::self& self, std::string url, LLSD content); }; #endif // LL_LLWLHANDLERS_H diff --git a/indra/viewer_components/login/lllogin.cpp b/indra/viewer_components/login/lllogin.cpp index 0569e9f3e8..b8408a6fb4 100755 --- a/indra/viewer_components/login/lllogin.cpp +++ b/indra/viewer_components/login/lllogin.cpp @@ -107,8 +107,9 @@ private: } // In a coroutine's top-level function args, do NOT NOT NOT accept - // references (const or otherwise) to anything! Pass by value only! - void login_(std::string uri, LLSD credentials); + // references (const or otherwise) to anything but the self argument! Pass + // by value only! + void login_(LLCoros::self& self, std::string uri, LLSD credentials); LLEventStream mPump; LLSD mAuthResponse, mValidAuthResponse; @@ -122,11 +123,11 @@ void LLLogin::Impl::connect(const std::string& uri, const LLSD& login_params) // its first wait; at that point, return here. std::string coroname = LLCoros::instance().launch("LLLogin::Impl::login_", - boost::bind(&Impl::login_, this, uri, login_params)); + boost::bind(&Impl::login_, this, _1, uri, login_params)); LL_DEBUGS("LLLogin") << " connected with uri '" << uri << "', login_params " << login_params << LL_ENDL; } -void LLLogin::Impl::login_(std::string uri, LLSD login_params) +void LLLogin::Impl::login_(LLCoros::self& self, std::string uri, LLSD login_params) { try { @@ -136,7 +137,7 @@ void LLLogin::Impl::login_(std::string uri, LLSD login_params) //{ // printable_params["params"]["passwd"] = "*******"; //} - LL_DEBUGS("LLLogin") << "Entering coroutine " << LLCoros::instance().getName() + LL_DEBUGS("LLLogin") << "Entering coroutine " << LLCoros::instance().getName(self) << " with uri '" << uri << "', parameters " << printable_params << LL_ENDL; // Arriving in SRVRequest state @@ -175,7 +176,7 @@ void LLLogin::Impl::login_(std::string uri, LLSD login_params) request["op"] = "rewriteURI"; request["uri"] = uri; request["reply"] = replyPump.getName(); - rewrittenURIs = postAndWait(request, srv_pump_name, filter); + rewrittenURIs = postAndWait(self, request, srv_pump_name, filter); // EXP-772: If rewrittenURIs fail, try original URI as a fallback. rewrittenURIs.append(uri); } // we no longer need the filter @@ -221,10 +222,10 @@ void LLLogin::Impl::login_(std::string uri, LLSD login_params) // returns. Subsequent responses, of course, must be awaited // without posting again. for (mAuthResponse = validateResponse(loginReplyPump.getName(), - postAndWait(request, xmlrpcPump, loginReplyPump, "reply")); + postAndWait(self, request, xmlrpcPump, loginReplyPump, "reply")); mAuthResponse["status"].asString() == "Downloading"; mAuthResponse = validateResponse(loginReplyPump.getName(), - waitForEventOn(loginReplyPump))) + waitForEventOn(self, loginReplyPump))) { // Still Downloading -- send progress update. sendProgressEvent("offline", "downloading"); diff --git a/indra/viewer_components/updater/llupdatechecker.cpp b/indra/viewer_components/updater/llupdatechecker.cpp index e889f83aa9..29cb238892 100755 --- a/indra/viewer_components/updater/llupdatechecker.cpp +++ b/indra/viewer_components/updater/llupdatechecker.cpp @@ -117,7 +117,7 @@ void LLUpdateChecker::Implementation::checkVersion(std::string const & urlBase, LL_INFOS("UpdaterService") << "checking for updates at " << checkUrl << LL_ENDL; LLCoros::instance().launch("LLUpdateChecker::Implementation::checkVersionCoro", - boost::bind(&Implementation::checkVersionCoro, this, checkUrl)); + boost::bind(&Implementation::checkVersionCoro, this, _1, checkUrl)); } else @@ -126,7 +126,7 @@ void LLUpdateChecker::Implementation::checkVersion(std::string const & urlBase, } } -void LLUpdateChecker::Implementation::checkVersionCoro(std::string url) +void LLUpdateChecker::Implementation::checkVersionCoro(LLCoros::self& self, std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -135,7 +135,7 @@ void LLUpdateChecker::Implementation::checkVersionCoro(std::string url) LL_INFOS("checkVersionCoro") << "Getting update information from " << url << LL_ENDL; - LLSD result = httpAdapter->getAndYield(httpRequest, url); + LLSD result = httpAdapter->getAndYield(self, httpRequest, url); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); diff --git a/indra/viewer_components/updater/llupdatechecker.h b/indra/viewer_components/updater/llupdatechecker.h index d10ea4cf42..e5050bb952 100755 --- a/indra/viewer_components/updater/llupdatechecker.h +++ b/indra/viewer_components/updater/llupdatechecker.h @@ -106,7 +106,7 @@ private: unsigned char uniqueid[MD5HEX_STR_SIZE], bool willing_to_test); - void checkVersionCoro(std::string url); + void checkVersionCoro(LLCoros::self& self, std::string url); LOG_CLASS(LLUpdateChecker::Implementation); }; -- cgit v1.2.3 From 1138c57f9a8553903199e727912d7f1b092697e4 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 8 Jul 2015 10:01:27 -0700 Subject: Convert LLCore::HttpHeaders to use shared_ptr<> rather than an intrusive_ptr<> for refrence counting. --- indra/llcorehttp/_httplibcurl.cpp | 2 +- indra/llcorehttp/_httpoprequest.cpp | 41 ++++++++++--------------------- indra/llcorehttp/_httpoprequest.h | 23 ++++++++--------- indra/llcorehttp/httpheaders.cpp | 1 - indra/llcorehttp/httpheaders.h | 7 +++--- indra/llcorehttp/httprequest.cpp | 14 +++++------ indra/llcorehttp/httprequest.h | 15 +++++------ indra/llcorehttp/httpresponse.cpp | 21 +++------------- indra/llcorehttp/httpresponse.h | 12 ++++----- indra/llcrashlogger/llcrashlogger.cpp | 2 +- indra/llmessage/llcorehttputil.cpp | 14 +++++------ indra/llmessage/llcorehttputil.h | 18 +++++++------- indra/newview/llassetuploadresponders.cpp | 2 ++ indra/newview/llassetuploadresponders.h | 3 ++- indra/newview/llhttpretrypolicy.cpp | 4 +-- indra/newview/llhttpretrypolicy.h | 2 +- indra/newview/llinventorymodel.cpp | 10 +++----- indra/newview/llinventorymodel.h | 2 +- indra/newview/llmaterialmgr.cpp | 2 +- indra/newview/llmeshrepository.cpp | 17 +++---------- indra/newview/llmeshrepository.h | 4 +-- indra/newview/lltexturefetch.cpp | 29 +++++----------------- indra/newview/lltexturefetch.h | 8 +++--- indra/newview/llviewerassetupload.cpp | 4 +++ indra/newview/llviewerassetupload.h | 13 ++++++++++ indra/newview/llxmlrpctransaction.cpp | 2 +- 26 files changed, 118 insertions(+), 154 deletions(-) (limited to 'indra') diff --git a/indra/llcorehttp/_httplibcurl.cpp b/indra/llcorehttp/_httplibcurl.cpp index 81b44ab90b..17e997688f 100755 --- a/indra/llcorehttp/_httplibcurl.cpp +++ b/indra/llcorehttp/_httplibcurl.cpp @@ -554,7 +554,7 @@ void HttpLibcurl::HandleCache::freeHandle(CURL * handle) // --------------------------------------- -struct curl_slist * append_headers_to_slist(const HttpHeaders * headers, struct curl_slist * slist) +struct curl_slist * append_headers_to_slist(const HttpHeaders::ptr_t &headers, struct curl_slist * slist) { const HttpHeaders::const_iterator end(headers->end()); for (HttpHeaders::const_iterator it(headers->begin()); end != it; ++it) diff --git a/indra/llcorehttp/_httpoprequest.cpp b/indra/llcorehttp/_httpoprequest.cpp index 799587ff22..5d118a9afb 100755 --- a/indra/llcorehttp/_httpoprequest.cpp +++ b/indra/llcorehttp/_httpoprequest.cpp @@ -122,7 +122,7 @@ HttpOpRequest::HttpOpRequest() mReqBody(NULL), mReqOffset(0), mReqLength(0), - mReqHeaders(NULL), + mReqHeaders(), mReqOptions(NULL), mCurlActive(false), mCurlHandle(NULL), @@ -135,7 +135,7 @@ HttpOpRequest::HttpOpRequest() mReplyOffset(0), mReplyLength(0), mReplyFullLength(0), - mReplyHeaders(NULL), + mReplyHeaders(), mPolicyRetries(0), mPolicy503Retries(0), mPolicyRetryAt(HttpTime(0)), @@ -162,12 +162,6 @@ HttpOpRequest::~HttpOpRequest() mReqOptions = NULL; } - if (mReqHeaders) - { - mReqHeaders->release(); - mReqHeaders = NULL; - } - if (mCurlHandle) { // Uncertain of thread context so free using @@ -194,11 +188,6 @@ HttpOpRequest::~HttpOpRequest() mReplyBody = NULL; } - if (mReplyHeaders) - { - mReplyHeaders->release(); - mReplyHeaders = NULL; - } } @@ -299,7 +288,7 @@ HttpStatus HttpOpRequest::setupGet(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, HttpOptions * options, - HttpHeaders * headers) + HttpHeaders::ptr_t &headers) { setupCommon(policy_id, priority, url, NULL, options, headers); mReqMethod = HOR_GET; @@ -314,7 +303,7 @@ HttpStatus HttpOpRequest::setupGetByteRange(HttpRequest::policy_t policy_id, size_t offset, size_t len, HttpOptions * options, - HttpHeaders * headers) + HttpHeaders::ptr_t &headers) { setupCommon(policy_id, priority, url, NULL, options, headers); mReqMethod = HOR_GET; @@ -334,7 +323,7 @@ HttpStatus HttpOpRequest::setupPost(HttpRequest::policy_t policy_id, const std::string & url, BufferArray * body, HttpOptions * options, - HttpHeaders * headers) + HttpHeaders::ptr_t &headers) { setupCommon(policy_id, priority, url, body, options, headers); mReqMethod = HOR_POST; @@ -348,7 +337,7 @@ HttpStatus HttpOpRequest::setupPut(HttpRequest::policy_t policy_id, const std::string & url, BufferArray * body, HttpOptions * options, - HttpHeaders * headers) + HttpHeaders::ptr_t &headers) { setupCommon(policy_id, priority, url, body, options, headers); mReqMethod = HOR_PUT; @@ -361,7 +350,7 @@ HttpStatus HttpOpRequest::setupDelete(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, HttpOptions * options, - HttpHeaders * headers) + HttpHeaders::ptr_t &headers) { setupCommon(policy_id, priority, url, NULL, options, headers); mReqMethod = HOR_DELETE; @@ -375,7 +364,7 @@ HttpStatus HttpOpRequest::setupPatch(HttpRequest::policy_t policy_id, const std::string & url, BufferArray * body, HttpOptions * options, - HttpHeaders * headers) + HttpHeaders::ptr_t &headers) { setupCommon(policy_id, priority, url, body, options, headers); mReqMethod = HOR_PATCH; @@ -388,7 +377,7 @@ HttpStatus HttpOpRequest::setupCopy(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, HttpOptions * options, - HttpHeaders * headers) + HttpHeaders::ptr_t &headers) { setupCommon(policy_id, priority, url, NULL, options, headers); mReqMethod = HOR_COPY; @@ -402,7 +391,7 @@ void HttpOpRequest::setupCommon(HttpRequest::policy_t policy_id, const std::string & url, BufferArray * body, HttpOptions * options, - HttpHeaders * headers) + HttpHeaders::ptr_t &headers) { mProcFlags = 0U; mReqPolicy = policy_id; @@ -415,7 +404,7 @@ void HttpOpRequest::setupCommon(HttpRequest::policy_t policy_id, } if (headers && ! mReqHeaders) { - headers->addRef(); + //headers->addRef(); mReqHeaders = headers; } if (options && ! mReqOptions) @@ -467,11 +456,7 @@ HttpStatus HttpOpRequest::prepareRequest(HttpService * service) mReplyOffset = 0; mReplyLength = 0; mReplyFullLength = 0; - if (mReplyHeaders) - { - mReplyHeaders->release(); - mReplyHeaders = NULL; - } + mReplyHeaders.reset(); mReplyConType.clear(); // *FIXME: better error handling later @@ -946,7 +931,7 @@ size_t HttpOpRequest::headerCallback(void * data, size_t size, size_t nmemb, voi // Save headers in response if (! op->mReplyHeaders) { - op->mReplyHeaders = new HttpHeaders; + op->mReplyHeaders = HttpHeaders::ptr_t(new HttpHeaders); } op->mReplyHeaders->append(name, value ? value : ""); } diff --git a/indra/llcorehttp/_httpoprequest.h b/indra/llcorehttp/_httpoprequest.h index b1bb101bea..0465c2b83f 100755 --- a/indra/llcorehttp/_httpoprequest.h +++ b/indra/llcorehttp/_httpoprequest.h @@ -41,6 +41,7 @@ #include "_httpoperation.h" #include "_refcounted.h" +#include "httpheaders.h" namespace LLCore { @@ -105,7 +106,7 @@ public: HttpRequest::priority_t priority, const std::string & url, HttpOptions * options, - HttpHeaders * headers); + HttpHeaders::ptr_t & headers); HttpStatus setupGetByteRange(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, @@ -113,40 +114,40 @@ public: size_t offset, size_t len, HttpOptions * options, - HttpHeaders * headers); + HttpHeaders::ptr_t & headers); HttpStatus setupPost(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, BufferArray * body, HttpOptions * options, - HttpHeaders * headers); + HttpHeaders::ptr_t & headers); HttpStatus setupPut(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, BufferArray * body, HttpOptions * options, - HttpHeaders * headers); + HttpHeaders::ptr_t & headers); HttpStatus setupDelete(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, HttpOptions * options, - HttpHeaders * headers); + HttpHeaders::ptr_t & headers); HttpStatus setupPatch(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, BufferArray * body, HttpOptions * options, - HttpHeaders * headers); + HttpHeaders::ptr_t & headers); HttpStatus setupCopy(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, HttpOptions * options, - HttpHeaders * headers); + HttpHeaders::ptr_t & headers); // Internal method used to setup the libcurl options for a request. // Does all the libcurl handle setup in one place. @@ -167,7 +168,7 @@ protected: const std::string & url, BufferArray * body, HttpOptions * options, - HttpHeaders * headers); + HttpHeaders::ptr_t &headers); // libcurl operational callbacks // @@ -197,7 +198,7 @@ public: BufferArray * mReqBody; off_t mReqOffset; size_t mReqLength; - HttpHeaders * mReqHeaders; + HttpHeaders::ptr_t mReqHeaders; HttpOptions * mReqOptions; // Transport data @@ -215,7 +216,7 @@ public: off_t mReplyOffset; size_t mReplyLength; size_t mReplyFullLength; - HttpHeaders * mReplyHeaders; + HttpHeaders::ptr_t mReplyHeaders; std::string mReplyConType; int mReplyRetryAfter; @@ -246,7 +247,7 @@ public: // Internal function to append the contents of an HttpHeaders // instance to a curl_slist object. -curl_slist * append_headers_to_slist(const HttpHeaders *, curl_slist * slist); +curl_slist * append_headers_to_slist(const HttpHeaders::ptr_t &, curl_slist * slist); } // end namespace LLCore diff --git a/indra/llcorehttp/httpheaders.cpp b/indra/llcorehttp/httpheaders.cpp index e03b1b080d..f586191a7c 100755 --- a/indra/llcorehttp/httpheaders.cpp +++ b/indra/llcorehttp/httpheaders.cpp @@ -34,7 +34,6 @@ namespace LLCore HttpHeaders::HttpHeaders() - : RefCounted(true) {} diff --git a/indra/llcorehttp/httpheaders.h b/indra/llcorehttp/httpheaders.h index 8f14568fa3..a97bae5537 100755 --- a/indra/llcorehttp/httpheaders.h +++ b/indra/llcorehttp/httpheaders.h @@ -74,7 +74,7 @@ namespace LLCore /// constructor is given a refcount. /// -class HttpHeaders : public LLCoreInt::RefCounted +class HttpHeaders: private boost::noncopyable { public: typedef std::pair header_t; @@ -91,10 +91,11 @@ public: /// to the instance. A call to @see release() will destroy /// the instance. HttpHeaders(); + virtual ~HttpHeaders(); // Use release() - typedef LLCoreInt::IntrusivePtr ptr_t; + //typedef LLCoreInt::IntrusivePtr ptr_t; + typedef boost::shared_ptr ptr_t; protected: - virtual ~HttpHeaders(); // Use release() HttpHeaders(const HttpHeaders &); // Not defined void operator=(const HttpHeaders &); // Not defined diff --git a/indra/llcorehttp/httprequest.cpp b/indra/llcorehttp/httprequest.cpp index d4c60a6f14..b5ea0b44b0 100755 --- a/indra/llcorehttp/httprequest.cpp +++ b/indra/llcorehttp/httprequest.cpp @@ -198,7 +198,7 @@ HttpHandle HttpRequest::requestGet(policy_t policy_id, priority_t priority, const std::string & url, HttpOptions * options, - HttpHeaders * headers, + HttpHeaders::ptr_t &headers, HttpHandler * user_handler) { HttpStatus status; @@ -232,7 +232,7 @@ HttpHandle HttpRequest::requestGetByteRange(policy_t policy_id, size_t offset, size_t len, HttpOptions * options, - HttpHeaders * headers, + HttpHeaders::ptr_t &headers, HttpHandler * user_handler) { HttpStatus status; @@ -265,7 +265,7 @@ HttpHandle HttpRequest::requestPost(policy_t policy_id, const std::string & url, BufferArray * body, HttpOptions * options, - HttpHeaders * headers, + HttpHeaders::ptr_t &headers, HttpHandler * user_handler) { HttpStatus status; @@ -298,7 +298,7 @@ HttpHandle HttpRequest::requestPut(policy_t policy_id, const std::string & url, BufferArray * body, HttpOptions * options, - HttpHeaders * headers, + HttpHeaders::ptr_t &headers, HttpHandler * user_handler) { HttpStatus status; @@ -329,7 +329,7 @@ HttpHandle HttpRequest::requestDelete(policy_t policy_id, priority_t priority, const std::string & url, HttpOptions * options, - HttpHeaders * headers, + HttpHeaders::ptr_t &headers, HttpHandler * user_handler) { HttpStatus status; @@ -361,7 +361,7 @@ HttpHandle HttpRequest::requestPatch(policy_t policy_id, const std::string & url, BufferArray * body, HttpOptions * options, - HttpHeaders * headers, + HttpHeaders::ptr_t &headers, HttpHandler * user_handler) { HttpStatus status; @@ -392,7 +392,7 @@ HttpHandle HttpRequest::requestCopy(policy_t policy_id, priority_t priority, const std::string & url, HttpOptions * options, - HttpHeaders * headers, + HttpHeaders::ptr_t &headers, HttpHandler * user_handler) { HttpStatus status; diff --git a/indra/llcorehttp/httprequest.h b/indra/llcorehttp/httprequest.h index e87a8b691a..c0622372e1 100755 --- a/indra/llcorehttp/httprequest.h +++ b/indra/llcorehttp/httprequest.h @@ -31,6 +31,7 @@ #include "httpcommon.h" #include "httphandler.h" +#include "httpheaders.h" namespace LLCore { @@ -349,7 +350,7 @@ public: priority_t priority, const std::string & url, HttpOptions * options, - HttpHeaders * headers, + HttpHeaders::ptr_t &headers, HttpHandler * handler); @@ -392,7 +393,7 @@ public: size_t offset, size_t len, HttpOptions * options, - HttpHeaders * headers, + HttpHeaders::ptr_t &headers, HttpHandler * handler); @@ -433,7 +434,7 @@ public: const std::string & url, BufferArray * body, HttpOptions * options, - HttpHeaders * headers, + HttpHeaders::ptr_t &headers, HttpHandler * handler); @@ -474,7 +475,7 @@ public: const std::string & url, BufferArray * body, HttpOptions * options, - HttpHeaders * headers, + HttpHeaders::ptr_t &headers, HttpHandler * handler); @@ -494,7 +495,7 @@ public: priority_t priority, const std::string & url, HttpOptions * options, - HttpHeaders * headers, + HttpHeaders::ptr_t &headers, HttpHandler * user_handler); /// Queue a full HTTP PUT. Query arguments and body may @@ -517,7 +518,7 @@ public: const std::string & url, BufferArray * body, HttpOptions * options, - HttpHeaders * headers, + HttpHeaders::ptr_t &headers, HttpHandler * user_handler); /// Queue a full HTTP PUT. Query arguments and body may @@ -536,7 +537,7 @@ public: priority_t priority, const std::string & url, HttpOptions * options, - HttpHeaders * headers, + HttpHeaders::ptr_t &headers, HttpHandler * user_handler); /// Queue a NoOp request. diff --git a/indra/llcorehttp/httpresponse.cpp b/indra/llcorehttp/httpresponse.cpp index 7d88f02527..f5ad2ebd47 100755 --- a/indra/llcorehttp/httpresponse.cpp +++ b/indra/llcorehttp/httpresponse.cpp @@ -39,7 +39,7 @@ HttpResponse::HttpResponse() mReplyLength(0U), mReplyFullLength(0U), mBufferArray(NULL), - mHeaders(NULL), + mHeaders(), mRetries(0U), m503Retries(0U), mRequestUrl() @@ -49,7 +49,7 @@ HttpResponse::HttpResponse() HttpResponse::~HttpResponse() { setBody(NULL); - setHeaders(NULL); + //setHeaders(); } @@ -72,22 +72,9 @@ void HttpResponse::setBody(BufferArray * ba) } -void HttpResponse::setHeaders(HttpHeaders * headers) +void HttpResponse::setHeaders(HttpHeaders::ptr_t &headers) { - if (mHeaders == headers) - return; - - if (mHeaders) - { - mHeaders->release(); - } - - if (headers) - { - headers->addRef(); - } - - mHeaders = headers; + mHeaders = headers; } size_t HttpResponse::getBodySize() const diff --git a/indra/llcorehttp/httpresponse.h b/indra/llcorehttp/httpresponse.h index 6c3b4da5e6..0bfa4585c7 100755 --- a/indra/llcorehttp/httpresponse.h +++ b/indra/llcorehttp/httpresponse.h @@ -31,7 +31,7 @@ #include #include "httpcommon.h" - +#include "httpheaders.h" #include "_refcounted.h" @@ -120,13 +120,13 @@ public: /// /// Caller can hold onto the headers by incrementing the reference /// count of the returned object. - HttpHeaders * getHeaders() const - { + HttpHeaders::ptr_t getHeaders() const + { return mHeaders; - } + } /// Behaves like @see setResponse() but for header data. - void setHeaders(HttpHeaders * headers); + void setHeaders(HttpHeaders::ptr_t &headers); /// If a 'Range:' header was used, these methods are involved /// in setting and returning data about the actual response. @@ -212,7 +212,7 @@ protected: unsigned int mReplyLength; unsigned int mReplyFullLength; BufferArray * mBufferArray; - HttpHeaders * mHeaders; + HttpHeaders::ptr_t mHeaders; std::string mContentType; unsigned int mRetries; unsigned int m503Retries; diff --git a/indra/llcrashlogger/llcrashlogger.cpp b/indra/llcrashlogger/llcrashlogger.cpp index cb05c4ff03..ed585ff64e 100755 --- a/indra/llcrashlogger/llcrashlogger.cpp +++ b/indra/llcrashlogger/llcrashlogger.cpp @@ -407,7 +407,7 @@ bool LLCrashLogger::runCrashLogPost(std::string host, LLSD data, std::string msg updateApplication(llformat("%s, try %d...", msg.c_str(), i+1)); LLCoreHttpUtil::requestPostWithLLSD(httpRequest.get(), LLCore::HttpRequest::DEFAULT_POLICY_ID, 0, - host, data, httpOpts.get(), NULL, new LLCrashLoggerHandler); + host, data, httpOpts.get(), LLCore::HttpHeaders::ptr_t(), new LLCrashLoggerHandler); while(!gBreak) { diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index 4ec01aa405..e3588b74ee 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -103,7 +103,7 @@ HttpHandle requestPostWithLLSD(HttpRequest * request, const std::string & url, const LLSD & body, HttpOptions * options, - HttpHeaders * headers, + HttpHeaders::ptr_t &headers, HttpHandler * handler) { HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); @@ -130,7 +130,7 @@ HttpHandle requestPutWithLLSD(HttpRequest * request, const std::string & url, const LLSD & body, HttpOptions * options, - HttpHeaders * headers, + HttpHeaders::ptr_t &headers, HttpHandler * handler) { HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); @@ -156,7 +156,7 @@ HttpHandle requestPatchWithLLSD(HttpRequest * request, const std::string & url, const LLSD & body, HttpOptions * options, - HttpHeaders * headers, + HttpHeaders::ptr_t &headers, HttpHandler * handler) { HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); @@ -286,7 +286,7 @@ void HttpCoroHandler::buildStatusEntry(LLCore::HttpResponse *response, LLCore::H writeStatusCodes(status, response->getRequestURL(), httpresults); LLSD httpHeaders = LLSD::emptyMap(); - LLCore::HttpHeaders * hdrs = response->getHeaders(); + LLCore::HttpHeaders::ptr_t hdrs = response->getHeaders(); if (hdrs) { @@ -689,7 +689,7 @@ LLSD HttpCoroutineAdapter::postAndYield_(LLCoros::self & self, LLCore::HttpReque // The HTTPCoroHandler does not self delete, so retrieval of a the contained // pointer from the smart pointer is safe in this case. LLCore::HttpHandle hhandle = request->requestPost(mPolicyId, mPriority, url, rawbody.get(), - options.get(), headers.get(), handler.get()); + options.get(), headers, handler.get()); if (hhandle == LLCORE_HTTP_HANDLE_INVALID) { @@ -782,7 +782,7 @@ LLSD HttpCoroutineAdapter::getAndYield_(LLCoros::self & self, LLCore::HttpReques // The HTTPCoroHandler does not self delete, so retrieval of a the contained // pointer from the smart pointer is safe in this case. LLCore::HttpHandle hhandle = request->requestGet(mPolicyId, mPriority, - url, options.get(), headers.get(), handler.get()); + url, options.get(), headers, handler.get()); if (hhandle == LLCORE_HTTP_HANDLE_INVALID) { @@ -817,7 +817,7 @@ LLSD HttpCoroutineAdapter::deleteAndYield_(LLCoros::self & self, LLCore::HttpReq // The HTTPCoroHandler does not self delete, so retrieval of a the contained // pointer from the smart pointer is safe in this case. LLCore::HttpHandle hhandle = request->requestDelete(mPolicyId, mPriority, - url, options.get(), headers.get(), handler.get()); + url, options.get(), headers, handler.get()); if (hhandle == LLCORE_HTTP_HANDLE_INVALID) { diff --git a/indra/llmessage/llcorehttputil.h b/indra/llmessage/llcorehttputil.h index 7dd161d1cd..a54f94e6f0 100644 --- a/indra/llmessage/llcorehttputil.h +++ b/indra/llmessage/llcorehttputil.h @@ -112,7 +112,7 @@ LLCore::HttpHandle requestPostWithLLSD(LLCore::HttpRequest * request, const std::string & url, const LLSD & body, LLCore::HttpOptions * options, - LLCore::HttpHeaders * headers, + LLCore::HttpHeaders::ptr_t &headers, LLCore::HttpHandler * handler); inline LLCore::HttpHandle requestPostWithLLSD(LLCore::HttpRequest::ptr_t & request, @@ -125,7 +125,7 @@ inline LLCore::HttpHandle requestPostWithLLSD(LLCore::HttpRequest::ptr_t & reque LLCore::HttpHandler * handler) { return requestPostWithLLSD(request.get(), policy_id, priority, - url, body, options.get(), headers.get(), handler); + url, body, options.get(), headers, handler); } inline LLCore::HttpHandle requestPostWithLLSD(LLCore::HttpRequest::ptr_t & request, @@ -136,7 +136,7 @@ inline LLCore::HttpHandle requestPostWithLLSD(LLCore::HttpRequest::ptr_t & reque LLCore::HttpHandler * handler) { return requestPostWithLLSD(request.get(), policy_id, priority, - url, body, NULL, NULL, handler); + url, body, NULL, LLCore::HttpHeaders::ptr_t(), handler); } @@ -162,7 +162,7 @@ LLCore::HttpHandle requestPutWithLLSD(LLCore::HttpRequest * request, const std::string & url, const LLSD & body, LLCore::HttpOptions * options, - LLCore::HttpHeaders * headers, + LLCore::HttpHeaders::ptr_t &headers, LLCore::HttpHandler * handler); inline LLCore::HttpHandle requestPutWithLLSD(LLCore::HttpRequest::ptr_t & request, @@ -175,7 +175,7 @@ inline LLCore::HttpHandle requestPutWithLLSD(LLCore::HttpRequest::ptr_t & reques LLCore::HttpHandler * handler) { return requestPutWithLLSD(request.get(), policy_id, priority, - url, body, options.get(), headers.get(), handler); + url, body, options.get(), headers, handler); } inline LLCore::HttpHandle requestPutWithLLSD(LLCore::HttpRequest::ptr_t & request, @@ -186,7 +186,7 @@ inline LLCore::HttpHandle requestPutWithLLSD(LLCore::HttpRequest::ptr_t & reques LLCore::HttpHandler * handler) { return requestPutWithLLSD(request.get(), policy_id, priority, - url, body, NULL, NULL, handler); + url, body, NULL, LLCore::HttpHeaders::ptr_t(), handler); } /// Issue a standard HttpRequest::requestPatch() call but using @@ -211,7 +211,7 @@ LLCore::HttpHandle requestPatchWithLLSD(LLCore::HttpRequest * request, const std::string & url, const LLSD & body, LLCore::HttpOptions * options, - LLCore::HttpHeaders * headers, + LLCore::HttpHeaders::ptr_t &headers, LLCore::HttpHandler * handler); inline LLCore::HttpHandle requestPatchWithLLSD(LLCore::HttpRequest::ptr_t & request, @@ -224,7 +224,7 @@ inline LLCore::HttpHandle requestPatchWithLLSD(LLCore::HttpRequest::ptr_t & requ LLCore::HttpHandler * handler) { return requestPatchWithLLSD(request.get(), policy_id, priority, - url, body, options.get(), headers.get(), handler); + url, body, options.get(), headers, handler); } inline LLCore::HttpHandle requestPatchWithLLSD(LLCore::HttpRequest::ptr_t & request, @@ -235,7 +235,7 @@ inline LLCore::HttpHandle requestPatchWithLLSD(LLCore::HttpRequest::ptr_t & requ LLCore::HttpHandler * handler) { return requestPatchWithLLSD(request.get(), policy_id, priority, - url, body, NULL, NULL, handler); + url, body, NULL, LLCore::HttpHeaders::ptr_t(), handler); } //========================================================================= diff --git a/indra/newview/llassetuploadresponders.cpp b/indra/newview/llassetuploadresponders.cpp index e492b8cf5d..fe01288e23 100755 --- a/indra/newview/llassetuploadresponders.cpp +++ b/indra/newview/llassetuploadresponders.cpp @@ -352,6 +352,7 @@ void LLAssetUploadResponder::uploadComplete(const LLSD& content) { } +#if 0 LLNewAgentInventoryResponder::LLNewAgentInventoryResponder( const LLSD& post_data, const LLUUID& vfile_id, @@ -473,6 +474,7 @@ void LLNewAgentInventoryResponder::uploadComplete(const LLSD& content) //LLImportColladaAssetCache::getInstance()->assetUploaded(mVFileID, content["new_asset"], TRUE); } +#endif LLUpdateAgentInventoryResponder::LLUpdateAgentInventoryResponder( const LLSD& post_data, diff --git a/indra/newview/llassetuploadresponders.h b/indra/newview/llassetuploadresponders.h index 18968bb1af..6828678f09 100755 --- a/indra/newview/llassetuploadresponders.h +++ b/indra/newview/llassetuploadresponders.h @@ -60,6 +60,7 @@ protected: std::string mFileName; }; +#if 0 // TODO*: Remove this once deprecated class LLNewAgentInventoryResponder : public LLAssetUploadResponder { @@ -78,7 +79,7 @@ public: protected: virtual void httpFailure(); }; - +#endif #if 0 // A base class which goes through and performs some default // actions for variable price uploads. If more specific actions diff --git a/indra/newview/llhttpretrypolicy.cpp b/indra/newview/llhttpretrypolicy.cpp index 530eb685fa..e2e151eb63 100755 --- a/indra/newview/llhttpretrypolicy.cpp +++ b/indra/newview/llhttpretrypolicy.cpp @@ -56,7 +56,7 @@ bool LLAdaptiveRetryPolicy::getRetryAfter(const LLSD& headers, F32& retry_header && getSecondsUntilRetryAfter(headers[HTTP_IN_HEADER_RETRY_AFTER].asStringRef(), retry_header_time)); } -bool LLAdaptiveRetryPolicy::getRetryAfter(const LLCore::HttpHeaders *headers, F32& retry_header_time) +bool LLAdaptiveRetryPolicy::getRetryAfter(const LLCore::HttpHeaders::ptr_t &headers, F32& retry_header_time) { if (headers) { @@ -85,7 +85,7 @@ void LLAdaptiveRetryPolicy::onFailure(S32 status, const LLSD& headers) void LLAdaptiveRetryPolicy::onFailure(const LLCore::HttpResponse *response) { F32 retry_header_time; - const LLCore::HttpHeaders *headers = response->getHeaders(); + const LLCore::HttpHeaders::ptr_t headers = response->getHeaders(); bool has_retry_header_time = getRetryAfter(headers,retry_header_time); onFailureCommon(response->getStatus().getType(), has_retry_header_time, retry_header_time); } diff --git a/indra/newview/llhttpretrypolicy.h b/indra/newview/llhttpretrypolicy.h index cf79e0b401..c0cc263546 100755 --- a/indra/newview/llhttpretrypolicy.h +++ b/indra/newview/llhttpretrypolicy.h @@ -79,7 +79,7 @@ public: protected: void init(); bool getRetryAfter(const LLSD& headers, F32& retry_header_time); - bool getRetryAfter(const LLCore::HttpHeaders *headers, F32& retry_header_time); + bool getRetryAfter(const LLCore::HttpHeaders::ptr_t &headers, F32& retry_header_time); void onFailureCommon(S32 status, bool has_retry_header_time, F32 retry_header_time); private: diff --git a/indra/newview/llinventorymodel.cpp b/indra/newview/llinventorymodel.cpp index 6d21dd4ba7..cf550c20c5 100755 --- a/indra/newview/llinventorymodel.cpp +++ b/indra/newview/llinventorymodel.cpp @@ -149,7 +149,7 @@ LLInventoryModel::LLInventoryModel() mHttpRequestFG(NULL), mHttpRequestBG(NULL), mHttpOptions(NULL), - mHttpHeaders(NULL), + mHttpHeaders(), mHttpPolicyClass(LLCore::HttpRequest::DEFAULT_POLICY_ID), mHttpPriorityFG(0), mHttpPriorityBG(0), @@ -178,11 +178,7 @@ void LLInventoryModel::cleanupInventory() mObservers.clear(); // Run down HTTP transport - if (mHttpHeaders) - { - mHttpHeaders->release(); - mHttpHeaders = NULL; - } + mHttpHeaders.reset(); if (mHttpOptions) { mHttpOptions->release(); @@ -2422,7 +2418,7 @@ void LLInventoryModel::initHttpRequest() mHttpOptions->setTransferTimeout(300); mHttpOptions->setUseRetryAfter(true); // mHttpOptions->setTrace(2); // Do tracing of requests - mHttpHeaders = new LLCore::HttpHeaders; + mHttpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders); mHttpHeaders->append(HTTP_OUT_HEADER_CONTENT_TYPE, HTTP_CONTENT_LLSD_XML); mHttpHeaders->append(HTTP_OUT_HEADER_ACCEPT, HTTP_CONTENT_LLSD_XML); mHttpPolicyClass = app_core_http.getPolicy(LLAppCoreHttp::AP_INVENTORY); diff --git a/indra/newview/llinventorymodel.h b/indra/newview/llinventorymodel.h index 26ee06535a..9711fb95f6 100755 --- a/indra/newview/llinventorymodel.h +++ b/indra/newview/llinventorymodel.h @@ -572,7 +572,7 @@ private: LLCore::HttpRequest * mHttpRequestFG; LLCore::HttpRequest * mHttpRequestBG; LLCore::HttpOptions * mHttpOptions; - LLCore::HttpHeaders * mHttpHeaders; + LLCore::HttpHeaders::ptr_t mHttpHeaders; LLCore::HttpRequest::policy_t mHttpPolicyClass; LLCore::HttpRequest::priority_t mHttpPriorityFG; LLCore::HttpRequest::priority_t mHttpPriorityBG; diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index aef5bcf0dd..e6f3540877 100755 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -712,7 +712,7 @@ void LLMaterialMgr::processGetAllQueue() ); LLCore::HttpHandle handle = mHttpRequest->requestGet(mHttpPolicy, mHttpPriority, capURL, - mHttpOptions.get(), mHttpHeaders.get(), handler); + mHttpOptions.get(), mHttpHeaders, handler); if (handle == LLCORE_HTTP_HANDLE_INVALID) { diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp index 648056484e..7f8e357e33 100755 --- a/indra/newview/llmeshrepository.cpp +++ b/indra/newview/llmeshrepository.cpp @@ -740,7 +740,7 @@ LLMeshRepoThread::LLMeshRepoThread() mHttpRequest(NULL), mHttpOptions(NULL), mHttpLargeOptions(NULL), - mHttpHeaders(NULL), + mHttpHeaders(), mHttpPolicyClass(LLCore::HttpRequest::DEFAULT_POLICY_ID), mHttpLegacyPolicyClass(LLCore::HttpRequest::DEFAULT_POLICY_ID), mHttpLargePolicyClass(LLCore::HttpRequest::DEFAULT_POLICY_ID), @@ -759,7 +759,7 @@ LLMeshRepoThread::LLMeshRepoThread() mHttpLargeOptions = new LLCore::HttpOptions; mHttpLargeOptions->setTransferTimeout(LARGE_MESH_XFER_TIMEOUT); mHttpLargeOptions->setUseRetryAfter(gSavedSettings.getBOOL("MeshUseHttpRetryAfter")); - mHttpHeaders = new LLCore::HttpHeaders; + mHttpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders); mHttpHeaders->append(HTTP_OUT_HEADER_ACCEPT, HTTP_CONTENT_VND_LL_MESH); mHttpPolicyClass = app_core_http.getPolicy(LLAppCoreHttp::AP_MESH2); mHttpLegacyPolicyClass = app_core_http.getPolicy(LLAppCoreHttp::AP_MESH1); @@ -781,11 +781,7 @@ LLMeshRepoThread::~LLMeshRepoThread() delete *iter; } mHttpRequestSet.clear(); - if (mHttpHeaders) - { - mHttpHeaders->release(); - mHttpHeaders = NULL; - } + mHttpHeaders.reset(); if (mHttpOptions) { mHttpOptions->release(); @@ -1886,7 +1882,7 @@ LLMeshUploadThread::LLMeshUploadThread(LLMeshUploadThread::instance_list& data, mHttpOptions->setTransferTimeout(mMeshUploadTimeOut); mHttpOptions->setUseRetryAfter(gSavedSettings.getBOOL("MeshUseHttpRetryAfter")); mHttpOptions->setRetries(UPLOAD_RETRY_LIMIT); - mHttpHeaders = new LLCore::HttpHeaders; + mHttpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders); mHttpHeaders->append(HTTP_OUT_HEADER_CONTENT_TYPE, HTTP_CONTENT_LLSD_XML); mHttpPolicyClass = LLAppViewer::instance()->getAppCoreHttp().getPolicy(LLAppCoreHttp::AP_UPLOADS); mHttpPriority = 0; @@ -1894,11 +1890,6 @@ LLMeshUploadThread::LLMeshUploadThread(LLMeshUploadThread::instance_list& data, LLMeshUploadThread::~LLMeshUploadThread() { - if (mHttpHeaders) - { - mHttpHeaders->release(); - mHttpHeaders = NULL; - } if (mHttpOptions) { mHttpOptions->release(); diff --git a/indra/newview/llmeshrepository.h b/indra/newview/llmeshrepository.h index 39280bea3a..dc1fa883b3 100755 --- a/indra/newview/llmeshrepository.h +++ b/indra/newview/llmeshrepository.h @@ -324,7 +324,7 @@ public: LLCore::HttpRequest * mHttpRequest; LLCore::HttpOptions * mHttpOptions; LLCore::HttpOptions * mHttpLargeOptions; - LLCore::HttpHeaders * mHttpHeaders; + LLCore::HttpHeaders::ptr_t mHttpHeaders; LLCore::HttpRequest::policy_t mHttpPolicyClass; LLCore::HttpRequest::policy_t mHttpLegacyPolicyClass; LLCore::HttpRequest::policy_t mHttpLargePolicyClass; @@ -494,7 +494,7 @@ private: LLCore::HttpStatus mHttpStatus; LLCore::HttpRequest * mHttpRequest; LLCore::HttpOptions * mHttpOptions; - LLCore::HttpHeaders * mHttpHeaders; + LLCore::HttpHeaders::ptr_t mHttpHeaders; LLCore::HttpRequest::policy_t mHttpPolicyClass; LLCore::HttpRequest::priority_t mHttpPriority; }; diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp index f4b1ff7313..1055216b65 100755 --- a/indra/newview/lltexturefetch.cpp +++ b/indra/newview/lltexturefetch.cpp @@ -2511,9 +2511,9 @@ LLTextureFetch::LLTextureFetch(LLTextureCache* cache, LLImageDecodeThread* image mHttpRequest(NULL), mHttpOptions(NULL), mHttpOptionsWithHeaders(NULL), - mHttpHeaders(NULL), + mHttpHeaders(), mHttpPolicyClass(LLCore::HttpRequest::DEFAULT_POLICY_ID), - mHttpMetricsHeaders(NULL), + mHttpMetricsHeaders(), mHttpMetricsPolicyClass(LLCore::HttpRequest::DEFAULT_POLICY_ID), mTotalCacheReadCount(0U), mTotalCacheWriteCount(0U), @@ -2531,10 +2531,10 @@ LLTextureFetch::LLTextureFetch(LLTextureCache* cache, LLImageDecodeThread* image mHttpOptions = new LLCore::HttpOptions; mHttpOptionsWithHeaders = new LLCore::HttpOptions; mHttpOptionsWithHeaders->setWantHeaders(true); - mHttpHeaders = new LLCore::HttpHeaders; + mHttpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders); mHttpHeaders->append(HTTP_OUT_HEADER_ACCEPT, HTTP_CONTENT_IMAGE_X_J2C); mHttpPolicyClass = app_core_http.getPolicy(LLAppCoreHttp::AP_TEXTURE); - mHttpMetricsHeaders = new LLCore::HttpHeaders; + mHttpMetricsHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders); mHttpMetricsHeaders->append(HTTP_OUT_HEADER_CONTENT_TYPE, HTTP_CONTENT_LLSD_XML); mHttpMetricsPolicyClass = app_core_http.getPolicy(LLAppCoreHttp::AP_REPORTING); mHttpHighWater = HTTP_NONPIPE_REQUESTS_HIGH_WATER; @@ -2580,18 +2580,6 @@ LLTextureFetch::~LLTextureFetch() mHttpOptionsWithHeaders = NULL; } - if (mHttpHeaders) - { - mHttpHeaders->release(); - mHttpHeaders = NULL; - } - - if (mHttpMetricsHeaders) - { - mHttpMetricsHeaders->release(); - mHttpMetricsHeaders = NULL; - } - mHttpWaitResource.clear(); delete mHttpRequest; @@ -4162,7 +4150,7 @@ LLTextureFetchDebugger::LLTextureFetchDebugger(LLTextureFetch* fetcher, LLTextur mFetcher(fetcher), mTextureCache(cache), mImageDecodeThread(imagedecodethread), - mHttpHeaders(NULL), + mHttpHeaders(), mHttpPolicyClass(fetcher->getPolicyClass()), mNbCurlCompleted(0), mTempIndex(0), @@ -4176,11 +4164,6 @@ LLTextureFetchDebugger::~LLTextureFetchDebugger() mFetchingHistory.clear(); mStopDebug = TRUE; tryToStopDebug(); - if (mHttpHeaders) - { - mHttpHeaders->release(); - mHttpHeaders = NULL; - } } void LLTextureFetchDebugger::init() @@ -4225,7 +4208,7 @@ void LLTextureFetchDebugger::init() if (! mHttpHeaders) { - mHttpHeaders = new LLCore::HttpHeaders; + mHttpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders); mHttpHeaders->append(HTTP_OUT_HEADER_ACCEPT, HTTP_CONTENT_IMAGE_X_J2C); } } diff --git a/indra/newview/lltexturefetch.h b/indra/newview/lltexturefetch.h index 27779a31e0..a5d6cd63d7 100755 --- a/indra/newview/lltexturefetch.h +++ b/indra/newview/lltexturefetch.h @@ -177,7 +177,7 @@ public: // to do that to hold a reference for any length of time. // // Threads: T* - LLCore::HttpHeaders * getMetricsHeaders() const { return mHttpMetricsHeaders; } + LLCore::HttpHeaders::ptr_t getMetricsHeaders() const { return mHttpMetricsHeaders; } // Threads: T* LLCore::HttpRequest::policy_t getMetricsPolicyClass() const { return mHttpMetricsPolicyClass; } @@ -356,9 +356,9 @@ private: LLCore::HttpRequest * mHttpRequest; // Ttf LLCore::HttpOptions * mHttpOptions; // Ttf LLCore::HttpOptions * mHttpOptionsWithHeaders; // Ttf - LLCore::HttpHeaders * mHttpHeaders; // Ttf + LLCore::HttpHeaders::ptr_t mHttpHeaders; // Ttf LLCore::HttpRequest::policy_t mHttpPolicyClass; // T* - LLCore::HttpHeaders * mHttpMetricsHeaders; // Ttf + LLCore::HttpHeaders::ptr_t mHttpMetricsHeaders; // Ttf LLCore::HttpRequest::policy_t mHttpMetricsPolicyClass; // T* S32 mHttpHighWater; // Ttf S32 mHttpLowWater; // Ttf @@ -510,7 +510,7 @@ private: LLTextureFetch* mFetcher; LLTextureCache* mTextureCache; LLImageDecodeThread* mImageDecodeThread; - LLCore::HttpHeaders* mHttpHeaders; + LLCore::HttpHeaders::ptr_t mHttpHeaders; LLCore::HttpRequest::policy_t mHttpPolicyClass; S32 mNumFetchedTextures; diff --git a/indra/newview/llviewerassetupload.cpp b/indra/newview/llviewerassetupload.cpp index bfcdbfc109..efaf95444d 100644 --- a/indra/newview/llviewerassetupload.cpp +++ b/indra/newview/llviewerassetupload.cpp @@ -393,6 +393,9 @@ LLSD NewFileResourceUploadInfo::exportTempFile() } +//========================================================================= + + //========================================================================= /*static*/ void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoros::self &self, LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &httpAdapter, const LLUUID &id, @@ -552,3 +555,4 @@ void LLViewerAssetUpload::HandleUploadError(LLCore::HttpStatus status, LLSD &res } } + diff --git a/indra/newview/llviewerassetupload.h b/indra/newview/llviewerassetupload.h index 771828b393..a2b250b33b 100644 --- a/indra/newview/llviewerassetupload.h +++ b/indra/newview/llviewerassetupload.h @@ -176,6 +176,19 @@ private: }; +#if 0 +class NotecardResourceUploadInfo : public NewResourceUploadInfo +{ +public: + NotecardResourceUploadInfo( + ); + + +protected: + +private: +}; +#endif class LLViewerAssetUpload { diff --git a/indra/newview/llxmlrpctransaction.cpp b/indra/newview/llxmlrpctransaction.cpp index 066970614a..63ad4bd49b 100755 --- a/indra/newview/llxmlrpctransaction.cpp +++ b/indra/newview/llxmlrpctransaction.cpp @@ -390,7 +390,7 @@ void LLXMLRPCTransaction::Impl::init(XMLRPC_REQUEST request, bool useGzip) mHandler = LLXMLRPCTransaction::Handler::ptr_t(new Handler( mHttpRequest, this )); mPostH = mHttpRequest->requestPost(LLCore::HttpRequest::DEFAULT_POLICY_ID, 0, - mURI, body.get(), httpOpts.get(), httpHeaders.get(), mHandler.get()); + mURI, body.get(), httpOpts.get(), httpHeaders, mHandler.get()); } -- cgit v1.2.3 From fe5567639d7d4b6f13f66da0a1fb4bf2af295283 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 8 Jul 2015 12:09:36 -0700 Subject: Change HttpOptions::ptr_t to be shared_ptr<> rather than intrusive. --- indra/llcorehttp/_httpoprequest.cpp | 42 ++++++++++--------------- indra/llcorehttp/_httpoprequest.h | 23 +++++++------- indra/llcorehttp/examples/http_texture_load.cpp | 6 ++-- indra/llcorehttp/httpheaders.h | 2 +- indra/llcorehttp/httpoptions.cpp | 2 +- indra/llcorehttp/httpoptions.h | 7 +++-- indra/llcorehttp/httprequest.cpp | 28 ++++++++--------- indra/llcorehttp/httprequest.h | 31 +++++++++--------- indra/llcrashlogger/llcrashlogger.cpp | 2 +- indra/llmessage/llcorehttputil.cpp | 12 +++---- indra/llmessage/llcorehttputil.h | 18 +++++------ indra/newview/llinventorymodel.cpp | 13 +++----- indra/newview/llinventorymodel.h | 2 +- indra/newview/llmaterialmgr.cpp | 2 +- indra/newview/llmeshrepository.cpp | 28 +++++------------ indra/newview/llmeshrepository.h | 6 ++-- indra/newview/lltexturefetch.cpp | 26 +++++---------- indra/newview/lltexturefetch.h | 4 +-- indra/newview/llxmlrpctransaction.cpp | 2 +- 19 files changed, 109 insertions(+), 147 deletions(-) (limited to 'indra') diff --git a/indra/llcorehttp/_httpoprequest.cpp b/indra/llcorehttp/_httpoprequest.cpp index 5d118a9afb..7baef25aca 100755 --- a/indra/llcorehttp/_httpoprequest.cpp +++ b/indra/llcorehttp/_httpoprequest.cpp @@ -123,7 +123,7 @@ HttpOpRequest::HttpOpRequest() mReqOffset(0), mReqLength(0), mReqHeaders(), - mReqOptions(NULL), + mReqOptions(), mCurlActive(false), mCurlHandle(NULL), mCurlService(NULL), @@ -156,12 +156,6 @@ HttpOpRequest::~HttpOpRequest() mReqBody = NULL; } - if (mReqOptions) - { - mReqOptions->release(); - mReqOptions = NULL; - } - if (mCurlHandle) { // Uncertain of thread context so free using @@ -287,8 +281,8 @@ HttpStatus HttpOpRequest::cancel() HttpStatus HttpOpRequest::setupGet(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, - HttpOptions * options, - HttpHeaders::ptr_t &headers) + HttpOptions::ptr_t & options, + HttpHeaders::ptr_t & headers) { setupCommon(policy_id, priority, url, NULL, options, headers); mReqMethod = HOR_GET; @@ -302,8 +296,8 @@ HttpStatus HttpOpRequest::setupGetByteRange(HttpRequest::policy_t policy_id, const std::string & url, size_t offset, size_t len, - HttpOptions * options, - HttpHeaders::ptr_t &headers) + HttpOptions::ptr_t & options, + HttpHeaders::ptr_t & headers) { setupCommon(policy_id, priority, url, NULL, options, headers); mReqMethod = HOR_GET; @@ -322,8 +316,8 @@ HttpStatus HttpOpRequest::setupPost(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, BufferArray * body, - HttpOptions * options, - HttpHeaders::ptr_t &headers) + HttpOptions::ptr_t & options, + HttpHeaders::ptr_t & headers) { setupCommon(policy_id, priority, url, body, options, headers); mReqMethod = HOR_POST; @@ -336,8 +330,8 @@ HttpStatus HttpOpRequest::setupPut(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, BufferArray * body, - HttpOptions * options, - HttpHeaders::ptr_t &headers) + HttpOptions::ptr_t & options, + HttpHeaders::ptr_t & headers) { setupCommon(policy_id, priority, url, body, options, headers); mReqMethod = HOR_PUT; @@ -349,8 +343,8 @@ HttpStatus HttpOpRequest::setupPut(HttpRequest::policy_t policy_id, HttpStatus HttpOpRequest::setupDelete(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, - HttpOptions * options, - HttpHeaders::ptr_t &headers) + HttpOptions::ptr_t & options, + HttpHeaders::ptr_t & headers) { setupCommon(policy_id, priority, url, NULL, options, headers); mReqMethod = HOR_DELETE; @@ -363,8 +357,8 @@ HttpStatus HttpOpRequest::setupPatch(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, BufferArray * body, - HttpOptions * options, - HttpHeaders::ptr_t &headers) + HttpOptions::ptr_t & options, + HttpHeaders::ptr_t & headers) { setupCommon(policy_id, priority, url, body, options, headers); mReqMethod = HOR_PATCH; @@ -376,7 +370,7 @@ HttpStatus HttpOpRequest::setupPatch(HttpRequest::policy_t policy_id, HttpStatus HttpOpRequest::setupCopy(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, - HttpOptions * options, + HttpOptions::ptr_t & options, HttpHeaders::ptr_t &headers) { setupCommon(policy_id, priority, url, NULL, options, headers); @@ -390,8 +384,8 @@ void HttpOpRequest::setupCommon(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, BufferArray * body, - HttpOptions * options, - HttpHeaders::ptr_t &headers) + HttpOptions::ptr_t & options, + HttpHeaders::ptr_t & headers) { mProcFlags = 0U; mReqPolicy = policy_id; @@ -404,12 +398,10 @@ void HttpOpRequest::setupCommon(HttpRequest::policy_t policy_id, } if (headers && ! mReqHeaders) { - //headers->addRef(); mReqHeaders = headers; } - if (options && ! mReqOptions) + if (options && !mReqOptions) { - options->addRef(); mReqOptions = options; if (options->getWantHeaders()) { diff --git a/indra/llcorehttp/_httpoprequest.h b/indra/llcorehttp/_httpoprequest.h index 0465c2b83f..42db71e7a0 100755 --- a/indra/llcorehttp/_httpoprequest.h +++ b/indra/llcorehttp/_httpoprequest.h @@ -42,14 +42,13 @@ #include "_refcounted.h" #include "httpheaders.h" +#include "httpoptions.h" namespace LLCore { class BufferArray; -class HttpHeaders; -class HttpOptions; /// HttpOpRequest requests a supported HTTP method invocation with @@ -105,7 +104,7 @@ public: HttpStatus setupGet(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, - HttpOptions * options, + HttpOptions::ptr_t & options, HttpHeaders::ptr_t & headers); HttpStatus setupGetByteRange(HttpRequest::policy_t policy_id, @@ -113,40 +112,40 @@ public: const std::string & url, size_t offset, size_t len, - HttpOptions * options, + HttpOptions::ptr_t & options, HttpHeaders::ptr_t & headers); HttpStatus setupPost(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, BufferArray * body, - HttpOptions * options, + HttpOptions::ptr_t & options, HttpHeaders::ptr_t & headers); HttpStatus setupPut(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, BufferArray * body, - HttpOptions * options, + HttpOptions::ptr_t & options, HttpHeaders::ptr_t & headers); HttpStatus setupDelete(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, - HttpOptions * options, + HttpOptions::ptr_t & options, HttpHeaders::ptr_t & headers); HttpStatus setupPatch(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, BufferArray * body, - HttpOptions * options, + HttpOptions::ptr_t & options, HttpHeaders::ptr_t & headers); HttpStatus setupCopy(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, - HttpOptions * options, + HttpOptions::ptr_t & options, HttpHeaders::ptr_t & headers); // Internal method used to setup the libcurl options for a request. @@ -167,8 +166,8 @@ protected: HttpRequest::priority_t priority, const std::string & url, BufferArray * body, - HttpOptions * options, - HttpHeaders::ptr_t &headers); + HttpOptions::ptr_t & options, + HttpHeaders::ptr_t & headers); // libcurl operational callbacks // @@ -199,7 +198,7 @@ public: off_t mReqOffset; size_t mReqLength; HttpHeaders::ptr_t mReqHeaders; - HttpOptions * mReqOptions; + HttpOptions::ptr_t mReqOptions; // Transport data bool mCurlActive; diff --git a/indra/llcorehttp/examples/http_texture_load.cpp b/indra/llcorehttp/examples/http_texture_load.cpp index 9d9631b980..13c9f90b2e 100755 --- a/indra/llcorehttp/examples/http_texture_load.cpp +++ b/indra/llcorehttp/examples/http_texture_load.cpp @@ -83,7 +83,7 @@ public: WorkingSet(); ~WorkingSet(); - bool reload(LLCore::HttpRequest *, LLCore::HttpOptions *); + bool reload(LLCore::HttpRequest *, LLCore::HttpOptions::ptr_t &); virtual void onCompleted(LLCore::HttpHandle handle, LLCore::HttpResponse * response); @@ -304,7 +304,7 @@ int main(int argc, char** argv) LLCore::HttpRequest * hr = new LLCore::HttpRequest(); // Get request options - LLCore::HttpOptions * opt = new LLCore::HttpOptions(); + LLCore::HttpOptions::ptr_t opt = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()); opt->setRetries(12); opt->setUseRetryAfter(true); @@ -442,7 +442,7 @@ WorkingSet::~WorkingSet() } -bool WorkingSet::reload(LLCore::HttpRequest * hr, LLCore::HttpOptions * opt) +bool WorkingSet::reload(LLCore::HttpRequest * hr, LLCore::HttpOptions::ptr_t & opt) { if (mRequestLowWater <= mHandles.size()) { diff --git a/indra/llcorehttp/httpheaders.h b/indra/llcorehttp/httpheaders.h index a97bae5537..b9168cb6ec 100755 --- a/indra/llcorehttp/httpheaders.h +++ b/indra/llcorehttp/httpheaders.h @@ -85,6 +85,7 @@ public: typedef container_t::const_reverse_iterator const_reverse_iterator; typedef container_t::value_type value_type; typedef container_t::size_type size_type; + typedef boost::shared_ptr ptr_t; public: /// @post In addition to the instance, caller has a refcount @@ -94,7 +95,6 @@ public: virtual ~HttpHeaders(); // Use release() //typedef LLCoreInt::IntrusivePtr ptr_t; - typedef boost::shared_ptr ptr_t; protected: HttpHeaders(const HttpHeaders &); // Not defined diff --git a/indra/llcorehttp/httpoptions.cpp b/indra/llcorehttp/httpoptions.cpp index 3459a37aff..aab447f2dd 100755 --- a/indra/llcorehttp/httpoptions.cpp +++ b/indra/llcorehttp/httpoptions.cpp @@ -33,7 +33,7 @@ namespace LLCore { -HttpOptions::HttpOptions() : RefCounted(true), +HttpOptions::HttpOptions() : mWantHeaders(false), mTracing(HTTP_TRACE_OFF), mTimeout(HTTP_REQUEST_TIMEOUT_DEFAULT), diff --git a/indra/llcorehttp/httpoptions.h b/indra/llcorehttp/httpoptions.h index 2fe05a65ff..510eaa45bb 100755 --- a/indra/llcorehttp/httpoptions.h +++ b/indra/llcorehttp/httpoptions.h @@ -55,15 +55,16 @@ namespace LLCore /// Allocation: Refcounted, heap only. Caller of the constructor /// is given a refcount. /// -class HttpOptions : public LLCoreInt::RefCounted +class HttpOptions : private boost::noncopyable { public: HttpOptions(); - typedef LLCoreInt::IntrusivePtr ptr_t; + typedef boost::shared_ptr ptr_t; + + virtual ~HttpOptions(); // Use release() protected: - virtual ~HttpOptions(); // Use release() HttpOptions(const HttpOptions &); // Not defined void operator=(const HttpOptions &); // Not defined diff --git a/indra/llcorehttp/httprequest.cpp b/indra/llcorehttp/httprequest.cpp index b5ea0b44b0..4a7352c962 100755 --- a/indra/llcorehttp/httprequest.cpp +++ b/indra/llcorehttp/httprequest.cpp @@ -197,8 +197,8 @@ HttpStatus HttpRequest::getStatus() const HttpHandle HttpRequest::requestGet(policy_t policy_id, priority_t priority, const std::string & url, - HttpOptions * options, - HttpHeaders::ptr_t &headers, + HttpOptions::ptr_t & options, + HttpHeaders::ptr_t & headers, HttpHandler * user_handler) { HttpStatus status; @@ -231,8 +231,8 @@ HttpHandle HttpRequest::requestGetByteRange(policy_t policy_id, const std::string & url, size_t offset, size_t len, - HttpOptions * options, - HttpHeaders::ptr_t &headers, + HttpOptions::ptr_t & options, + HttpHeaders::ptr_t & headers, HttpHandler * user_handler) { HttpStatus status; @@ -264,8 +264,8 @@ HttpHandle HttpRequest::requestPost(policy_t policy_id, priority_t priority, const std::string & url, BufferArray * body, - HttpOptions * options, - HttpHeaders::ptr_t &headers, + HttpOptions::ptr_t & options, + HttpHeaders::ptr_t & headers, HttpHandler * user_handler) { HttpStatus status; @@ -297,8 +297,8 @@ HttpHandle HttpRequest::requestPut(policy_t policy_id, priority_t priority, const std::string & url, BufferArray * body, - HttpOptions * options, - HttpHeaders::ptr_t &headers, + HttpOptions::ptr_t & options, + HttpHeaders::ptr_t & headers, HttpHandler * user_handler) { HttpStatus status; @@ -328,8 +328,8 @@ HttpHandle HttpRequest::requestPut(policy_t policy_id, HttpHandle HttpRequest::requestDelete(policy_t policy_id, priority_t priority, const std::string & url, - HttpOptions * options, - HttpHeaders::ptr_t &headers, + HttpOptions::ptr_t & options, + HttpHeaders::ptr_t & headers, HttpHandler * user_handler) { HttpStatus status; @@ -360,8 +360,8 @@ HttpHandle HttpRequest::requestPatch(policy_t policy_id, priority_t priority, const std::string & url, BufferArray * body, - HttpOptions * options, - HttpHeaders::ptr_t &headers, + HttpOptions::ptr_t & options, + HttpHeaders::ptr_t & headers, HttpHandler * user_handler) { HttpStatus status; @@ -391,8 +391,8 @@ HttpHandle HttpRequest::requestPatch(policy_t policy_id, HttpHandle HttpRequest::requestCopy(policy_t policy_id, priority_t priority, const std::string & url, - HttpOptions * options, - HttpHeaders::ptr_t &headers, + HttpOptions::ptr_t & options, + HttpHeaders::ptr_t & headers, HttpHandler * user_handler) { HttpStatus status; diff --git a/indra/llcorehttp/httprequest.h b/indra/llcorehttp/httprequest.h index c0622372e1..58aea1444c 100755 --- a/indra/llcorehttp/httprequest.h +++ b/indra/llcorehttp/httprequest.h @@ -32,6 +32,7 @@ #include "httphandler.h" #include "httpheaders.h" +#include "httpoptions.h" namespace LLCore { @@ -39,8 +40,6 @@ namespace LLCore class HttpRequestQueue; class HttpReplyQueue; class HttpService; -class HttpOptions; -class HttpHeaders; class HttpOperation; class BufferArray; @@ -349,8 +348,8 @@ public: HttpHandle requestGet(policy_t policy_id, priority_t priority, const std::string & url, - HttpOptions * options, - HttpHeaders::ptr_t &headers, + HttpOptions::ptr_t & options, + HttpHeaders::ptr_t & headers, HttpHandler * handler); @@ -392,8 +391,8 @@ public: const std::string & url, size_t offset, size_t len, - HttpOptions * options, - HttpHeaders::ptr_t &headers, + HttpOptions::ptr_t & options, + HttpHeaders::ptr_t & headers, HttpHandler * handler); @@ -433,8 +432,8 @@ public: priority_t priority, const std::string & url, BufferArray * body, - HttpOptions * options, - HttpHeaders::ptr_t &headers, + HttpOptions::ptr_t & options, + HttpHeaders::ptr_t & headers, HttpHandler * handler); @@ -474,8 +473,8 @@ public: priority_t priority, const std::string & url, BufferArray * body, - HttpOptions * options, - HttpHeaders::ptr_t &headers, + HttpOptions::ptr_t & options, + HttpHeaders::ptr_t & headers, HttpHandler * handler); @@ -494,8 +493,8 @@ public: HttpHandle requestDelete(policy_t policy_id, priority_t priority, const std::string & url, - HttpOptions * options, - HttpHeaders::ptr_t &headers, + HttpOptions::ptr_t & options, + HttpHeaders::ptr_t & headers, HttpHandler * user_handler); /// Queue a full HTTP PUT. Query arguments and body may @@ -517,8 +516,8 @@ public: priority_t priority, const std::string & url, BufferArray * body, - HttpOptions * options, - HttpHeaders::ptr_t &headers, + HttpOptions::ptr_t & options, + HttpHeaders::ptr_t & headers, HttpHandler * user_handler); /// Queue a full HTTP PUT. Query arguments and body may @@ -536,8 +535,8 @@ public: HttpHandle requestCopy(policy_t policy_id, priority_t priority, const std::string & url, - HttpOptions * options, - HttpHeaders::ptr_t &headers, + HttpOptions::ptr_t & options, + HttpHeaders::ptr_t & headers, HttpHandler * user_handler); /// Queue a NoOp request. diff --git a/indra/llcrashlogger/llcrashlogger.cpp b/indra/llcrashlogger/llcrashlogger.cpp index ed585ff64e..4caf6dcd05 100755 --- a/indra/llcrashlogger/llcrashlogger.cpp +++ b/indra/llcrashlogger/llcrashlogger.cpp @@ -407,7 +407,7 @@ bool LLCrashLogger::runCrashLogPost(std::string host, LLSD data, std::string msg updateApplication(llformat("%s, try %d...", msg.c_str(), i+1)); LLCoreHttpUtil::requestPostWithLLSD(httpRequest.get(), LLCore::HttpRequest::DEFAULT_POLICY_ID, 0, - host, data, httpOpts.get(), LLCore::HttpHeaders::ptr_t(), new LLCrashLoggerHandler); + host, data, httpOpts, LLCore::HttpHeaders::ptr_t(), new LLCrashLoggerHandler); while(!gBreak) { diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index e3588b74ee..24f5d77ee1 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -102,7 +102,7 @@ HttpHandle requestPostWithLLSD(HttpRequest * request, HttpRequest::priority_t priority, const std::string & url, const LLSD & body, - HttpOptions * options, + HttpOptions::ptr_t &options, HttpHeaders::ptr_t &headers, HttpHandler * handler) { @@ -129,7 +129,7 @@ HttpHandle requestPutWithLLSD(HttpRequest * request, HttpRequest::priority_t priority, const std::string & url, const LLSD & body, - HttpOptions * options, + HttpOptions::ptr_t &options, HttpHeaders::ptr_t &headers, HttpHandler * handler) { @@ -155,7 +155,7 @@ HttpHandle requestPatchWithLLSD(HttpRequest * request, HttpRequest::priority_t priority, const std::string & url, const LLSD & body, - HttpOptions * options, + HttpOptions::ptr_t &options, HttpHeaders::ptr_t &headers, HttpHandler * handler) { @@ -689,7 +689,7 @@ LLSD HttpCoroutineAdapter::postAndYield_(LLCoros::self & self, LLCore::HttpReque // The HTTPCoroHandler does not self delete, so retrieval of a the contained // pointer from the smart pointer is safe in this case. LLCore::HttpHandle hhandle = request->requestPost(mPolicyId, mPriority, url, rawbody.get(), - options.get(), headers, handler.get()); + options, headers, handler.get()); if (hhandle == LLCORE_HTTP_HANDLE_INVALID) { @@ -782,7 +782,7 @@ LLSD HttpCoroutineAdapter::getAndYield_(LLCoros::self & self, LLCore::HttpReques // The HTTPCoroHandler does not self delete, so retrieval of a the contained // pointer from the smart pointer is safe in this case. LLCore::HttpHandle hhandle = request->requestGet(mPolicyId, mPriority, - url, options.get(), headers, handler.get()); + url, options, headers, handler.get()); if (hhandle == LLCORE_HTTP_HANDLE_INVALID) { @@ -817,7 +817,7 @@ LLSD HttpCoroutineAdapter::deleteAndYield_(LLCoros::self & self, LLCore::HttpReq // The HTTPCoroHandler does not self delete, so retrieval of a the contained // pointer from the smart pointer is safe in this case. LLCore::HttpHandle hhandle = request->requestDelete(mPolicyId, mPriority, - url, options.get(), headers, handler.get()); + url, options, headers, handler.get()); if (hhandle == LLCORE_HTTP_HANDLE_INVALID) { diff --git a/indra/llmessage/llcorehttputil.h b/indra/llmessage/llcorehttputil.h index a54f94e6f0..1e575e0e0c 100644 --- a/indra/llmessage/llcorehttputil.h +++ b/indra/llmessage/llcorehttputil.h @@ -111,7 +111,7 @@ LLCore::HttpHandle requestPostWithLLSD(LLCore::HttpRequest * request, LLCore::HttpRequest::priority_t priority, const std::string & url, const LLSD & body, - LLCore::HttpOptions * options, + LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, LLCore::HttpHandler * handler); @@ -125,7 +125,7 @@ inline LLCore::HttpHandle requestPostWithLLSD(LLCore::HttpRequest::ptr_t & reque LLCore::HttpHandler * handler) { return requestPostWithLLSD(request.get(), policy_id, priority, - url, body, options.get(), headers, handler); + url, body, options, headers, handler); } inline LLCore::HttpHandle requestPostWithLLSD(LLCore::HttpRequest::ptr_t & request, @@ -136,7 +136,7 @@ inline LLCore::HttpHandle requestPostWithLLSD(LLCore::HttpRequest::ptr_t & reque LLCore::HttpHandler * handler) { return requestPostWithLLSD(request.get(), policy_id, priority, - url, body, NULL, LLCore::HttpHeaders::ptr_t(), handler); + url, body, LLCore::HttpOptions::ptr_t(), LLCore::HttpHeaders::ptr_t(), handler); } @@ -161,7 +161,7 @@ LLCore::HttpHandle requestPutWithLLSD(LLCore::HttpRequest * request, LLCore::HttpRequest::priority_t priority, const std::string & url, const LLSD & body, - LLCore::HttpOptions * options, + LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, LLCore::HttpHandler * handler); @@ -175,7 +175,7 @@ inline LLCore::HttpHandle requestPutWithLLSD(LLCore::HttpRequest::ptr_t & reques LLCore::HttpHandler * handler) { return requestPutWithLLSD(request.get(), policy_id, priority, - url, body, options.get(), headers, handler); + url, body, options, headers, handler); } inline LLCore::HttpHandle requestPutWithLLSD(LLCore::HttpRequest::ptr_t & request, @@ -186,7 +186,7 @@ inline LLCore::HttpHandle requestPutWithLLSD(LLCore::HttpRequest::ptr_t & reques LLCore::HttpHandler * handler) { return requestPutWithLLSD(request.get(), policy_id, priority, - url, body, NULL, LLCore::HttpHeaders::ptr_t(), handler); + url, body, LLCore::HttpOptions::ptr_t(), LLCore::HttpHeaders::ptr_t(), handler); } /// Issue a standard HttpRequest::requestPatch() call but using @@ -210,7 +210,7 @@ LLCore::HttpHandle requestPatchWithLLSD(LLCore::HttpRequest * request, LLCore::HttpRequest::priority_t priority, const std::string & url, const LLSD & body, - LLCore::HttpOptions * options, + LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, LLCore::HttpHandler * handler); @@ -224,7 +224,7 @@ inline LLCore::HttpHandle requestPatchWithLLSD(LLCore::HttpRequest::ptr_t & requ LLCore::HttpHandler * handler) { return requestPatchWithLLSD(request.get(), policy_id, priority, - url, body, options.get(), headers, handler); + url, body, options, headers, handler); } inline LLCore::HttpHandle requestPatchWithLLSD(LLCore::HttpRequest::ptr_t & request, @@ -235,7 +235,7 @@ inline LLCore::HttpHandle requestPatchWithLLSD(LLCore::HttpRequest::ptr_t & requ LLCore::HttpHandler * handler) { return requestPatchWithLLSD(request.get(), policy_id, priority, - url, body, NULL, LLCore::HttpHeaders::ptr_t(), handler); + url, body, LLCore::HttpOptions::ptr_t(), LLCore::HttpHeaders::ptr_t(), handler); } //========================================================================= diff --git a/indra/newview/llinventorymodel.cpp b/indra/newview/llinventorymodel.cpp index cf550c20c5..39aeab22e5 100755 --- a/indra/newview/llinventorymodel.cpp +++ b/indra/newview/llinventorymodel.cpp @@ -148,7 +148,7 @@ LLInventoryModel::LLInventoryModel() mObservers(), mHttpRequestFG(NULL), mHttpRequestBG(NULL), - mHttpOptions(NULL), + mHttpOptions(), mHttpHeaders(), mHttpPolicyClass(LLCore::HttpRequest::DEFAULT_POLICY_ID), mHttpPriorityFG(0), @@ -179,11 +179,8 @@ void LLInventoryModel::cleanupInventory() // Run down HTTP transport mHttpHeaders.reset(); - if (mHttpOptions) - { - mHttpOptions->release(); - mHttpOptions = NULL; - } + mHttpOptions.reset(); + delete mHttpRequestFG; mHttpRequestFG = NULL; delete mHttpRequestBG; @@ -609,7 +606,7 @@ void LLInventoryModel::createNewCategoryCoro(LLCoros::self& self, std::string ur LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("createNewCategoryCoro", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLCore::HttpOptions::ptr_t httpOpts = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); httpOpts->setWantHeaders(true); @@ -2414,7 +2411,7 @@ void LLInventoryModel::initHttpRequest() mHttpRequestFG = new LLCore::HttpRequest; mHttpRequestBG = new LLCore::HttpRequest; - mHttpOptions = new LLCore::HttpOptions; + mHttpOptions = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions); mHttpOptions->setTransferTimeout(300); mHttpOptions->setUseRetryAfter(true); // mHttpOptions->setTrace(2); // Do tracing of requests diff --git a/indra/newview/llinventorymodel.h b/indra/newview/llinventorymodel.h index 9711fb95f6..f768e61ccb 100755 --- a/indra/newview/llinventorymodel.h +++ b/indra/newview/llinventorymodel.h @@ -571,7 +571,7 @@ private: // Usual plumbing for LLCore:: HTTP operations. LLCore::HttpRequest * mHttpRequestFG; LLCore::HttpRequest * mHttpRequestBG; - LLCore::HttpOptions * mHttpOptions; + LLCore::HttpOptions::ptr_t mHttpOptions; LLCore::HttpHeaders::ptr_t mHttpHeaders; LLCore::HttpRequest::policy_t mHttpPolicyClass; LLCore::HttpRequest::priority_t mHttpPriorityFG; diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index e6f3540877..1045def72e 100755 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -712,7 +712,7 @@ void LLMaterialMgr::processGetAllQueue() ); LLCore::HttpHandle handle = mHttpRequest->requestGet(mHttpPolicy, mHttpPriority, capURL, - mHttpOptions.get(), mHttpHeaders, handler); + mHttpOptions, mHttpHeaders, handler); if (handle == LLCORE_HTTP_HANDLE_INVALID) { diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp index 7f8e357e33..d6aaf18cb7 100755 --- a/indra/newview/llmeshrepository.cpp +++ b/indra/newview/llmeshrepository.cpp @@ -738,8 +738,8 @@ void log_upload_error(LLCore::HttpStatus status, const LLSD& content, LLMeshRepoThread::LLMeshRepoThread() : LLThread("mesh repo"), mHttpRequest(NULL), - mHttpOptions(NULL), - mHttpLargeOptions(NULL), + mHttpOptions(), + mHttpLargeOptions(), mHttpHeaders(), mHttpPolicyClass(LLCore::HttpRequest::DEFAULT_POLICY_ID), mHttpLegacyPolicyClass(LLCore::HttpRequest::DEFAULT_POLICY_ID), @@ -753,10 +753,10 @@ LLMeshRepoThread::LLMeshRepoThread() mHeaderMutex = new LLMutex(NULL); mSignal = new LLCondition(NULL); mHttpRequest = new LLCore::HttpRequest; - mHttpOptions = new LLCore::HttpOptions; + mHttpOptions = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions); mHttpOptions->setTransferTimeout(SMALL_MESH_XFER_TIMEOUT); mHttpOptions->setUseRetryAfter(gSavedSettings.getBOOL("MeshUseHttpRetryAfter")); - mHttpLargeOptions = new LLCore::HttpOptions; + mHttpLargeOptions = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions); mHttpLargeOptions->setTransferTimeout(LARGE_MESH_XFER_TIMEOUT); mHttpLargeOptions->setUseRetryAfter(gSavedSettings.getBOOL("MeshUseHttpRetryAfter")); mHttpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders); @@ -782,17 +782,8 @@ LLMeshRepoThread::~LLMeshRepoThread() } mHttpRequestSet.clear(); mHttpHeaders.reset(); - if (mHttpOptions) - { - mHttpOptions->release(); - mHttpOptions = NULL; - } - if (mHttpLargeOptions) - { - mHttpLargeOptions->release(); - mHttpLargeOptions = NULL; - } - delete mHttpRequest; + + delete mHttpRequest; mHttpRequest = NULL; delete mMutex; mMutex = NULL; @@ -1878,7 +1869,7 @@ LLMeshUploadThread::LLMeshUploadThread(LLMeshUploadThread::instance_list& data, mMeshUploadTimeOut = gSavedSettings.getS32("MeshUploadTimeOut") ; mHttpRequest = new LLCore::HttpRequest; - mHttpOptions = new LLCore::HttpOptions; + mHttpOptions = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions); mHttpOptions->setTransferTimeout(mMeshUploadTimeOut); mHttpOptions->setUseRetryAfter(gSavedSettings.getBOOL("MeshUseHttpRetryAfter")); mHttpOptions->setRetries(UPLOAD_RETRY_LIMIT); @@ -1890,11 +1881,6 @@ LLMeshUploadThread::LLMeshUploadThread(LLMeshUploadThread::instance_list& data, LLMeshUploadThread::~LLMeshUploadThread() { - if (mHttpOptions) - { - mHttpOptions->release(); - mHttpOptions = NULL; - } delete mHttpRequest; mHttpRequest = NULL; } diff --git a/indra/newview/llmeshrepository.h b/indra/newview/llmeshrepository.h index dc1fa883b3..55157cc040 100755 --- a/indra/newview/llmeshrepository.h +++ b/indra/newview/llmeshrepository.h @@ -322,8 +322,8 @@ public: // llcorehttp library interface objects. LLCore::HttpStatus mHttpStatus; LLCore::HttpRequest * mHttpRequest; - LLCore::HttpOptions * mHttpOptions; - LLCore::HttpOptions * mHttpLargeOptions; + LLCore::HttpOptions::ptr_t mHttpOptions; + LLCore::HttpOptions::ptr_t mHttpLargeOptions; LLCore::HttpHeaders::ptr_t mHttpHeaders; LLCore::HttpRequest::policy_t mHttpPolicyClass; LLCore::HttpRequest::policy_t mHttpLegacyPolicyClass; @@ -493,7 +493,7 @@ private: // llcorehttp library interface objects. LLCore::HttpStatus mHttpStatus; LLCore::HttpRequest * mHttpRequest; - LLCore::HttpOptions * mHttpOptions; + LLCore::HttpOptions::ptr_t mHttpOptions; LLCore::HttpHeaders::ptr_t mHttpHeaders; LLCore::HttpRequest::policy_t mHttpPolicyClass; LLCore::HttpRequest::priority_t mHttpPriority; diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp index 1055216b65..e61eeb2f4e 100755 --- a/indra/newview/lltexturefetch.cpp +++ b/indra/newview/lltexturefetch.cpp @@ -1557,7 +1557,7 @@ bool LLTextureFetchWorker::doWork(S32 param) // Will call callbackHttpGet when curl request completes // Only server bake images use the returned headers currently, for getting retry-after field. - LLCore::HttpOptions *options = (mFTType == FTT_SERVER_BAKE) ? mFetcher->mHttpOptionsWithHeaders: mFetcher->mHttpOptions; + LLCore::HttpOptions::ptr_t options = (mFTType == FTT_SERVER_BAKE) ? mFetcher->mHttpOptionsWithHeaders: mFetcher->mHttpOptions; if (disable_range_req) { // 'Range:' requests may be disabled in which case all HTTP @@ -2509,8 +2509,8 @@ LLTextureFetch::LLTextureFetch(LLTextureCache* cache, LLImageDecodeThread* image mTotalHTTPRequests(0), mQAMode(qa_mode), mHttpRequest(NULL), - mHttpOptions(NULL), - mHttpOptionsWithHeaders(NULL), + mHttpOptions(), + mHttpOptionsWithHeaders(), mHttpHeaders(), mHttpPolicyClass(LLCore::HttpRequest::DEFAULT_POLICY_ID), mHttpMetricsHeaders(), @@ -2528,8 +2528,8 @@ LLTextureFetch::LLTextureFetch(LLTextureCache* cache, LLImageDecodeThread* image LLAppCoreHttp & app_core_http(LLAppViewer::instance()->getAppCoreHttp()); mHttpRequest = new LLCore::HttpRequest; - mHttpOptions = new LLCore::HttpOptions; - mHttpOptionsWithHeaders = new LLCore::HttpOptions; + mHttpOptions = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions); + mHttpOptionsWithHeaders = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions); mHttpOptionsWithHeaders->setWantHeaders(true); mHttpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders); mHttpHeaders->append(HTTP_OUT_HEADER_ACCEPT, HTTP_CONTENT_IMAGE_X_J2C); @@ -2568,18 +2568,6 @@ LLTextureFetch::~LLTextureFetch() delete req; } - if (mHttpOptions) - { - mHttpOptions->release(); - mHttpOptions = NULL; - } - - if (mHttpOptionsWithHeaders) - { - mHttpOptionsWithHeaders->release(); - mHttpOptionsWithHeaders = NULL; - } - mHttpWaitResource.clear(); delete mHttpRequest; @@ -4031,7 +4019,7 @@ TFReqSendMetrics::doWork(LLTextureFetch * fetcher) report_priority, mCapsURL, sd, - NULL, + LLCore::HttpOptions::ptr_t(), fetcher->getMetricsHeaders(), handler); LLTextureFetch::svMetricsDataBreak = false; @@ -4608,7 +4596,7 @@ S32 LLTextureFetchDebugger::fillCurlQueue() texture_url, 0, requestedSize, - NULL, + LLCore::HttpOptions::ptr_t(), mHttpHeaders, this); if (LLCORE_HTTP_HANDLE_INVALID != handle) diff --git a/indra/newview/lltexturefetch.h b/indra/newview/lltexturefetch.h index a5d6cd63d7..e569175e8f 100755 --- a/indra/newview/lltexturefetch.h +++ b/indra/newview/lltexturefetch.h @@ -354,8 +354,8 @@ private: // to make our HTTP requests. These replace the various // LLCurl interfaces used in the past. LLCore::HttpRequest * mHttpRequest; // Ttf - LLCore::HttpOptions * mHttpOptions; // Ttf - LLCore::HttpOptions * mHttpOptionsWithHeaders; // Ttf + LLCore::HttpOptions::ptr_t mHttpOptions; // Ttf + LLCore::HttpOptions::ptr_t mHttpOptionsWithHeaders; // Ttf LLCore::HttpHeaders::ptr_t mHttpHeaders; // Ttf LLCore::HttpRequest::policy_t mHttpPolicyClass; // T* LLCore::HttpHeaders::ptr_t mHttpMetricsHeaders; // Ttf diff --git a/indra/newview/llxmlrpctransaction.cpp b/indra/newview/llxmlrpctransaction.cpp index 63ad4bd49b..5828aee7fc 100755 --- a/indra/newview/llxmlrpctransaction.cpp +++ b/indra/newview/llxmlrpctransaction.cpp @@ -390,7 +390,7 @@ void LLXMLRPCTransaction::Impl::init(XMLRPC_REQUEST request, bool useGzip) mHandler = LLXMLRPCTransaction::Handler::ptr_t(new Handler( mHttpRequest, this )); mPostH = mHttpRequest->requestPost(LLCore::HttpRequest::DEFAULT_POLICY_ID, 0, - mURI, body.get(), httpOpts.get(), httpHeaders, mHandler.get()); + mURI, body.get(), httpOpts, httpHeaders, mHandler.get()); } -- cgit v1.2.3 From 7ff38e34eaea52b4d1b856efa9de685cbdbd28ba Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 8 Jul 2015 12:44:57 -0700 Subject: Update the unit tests to use the new pointer type. --- indra/llcorehttp/tests/test_httpheaders.hpp | 27 +- indra/llcorehttp/tests/test_httprequest.hpp | 328 ++++++++----------------- indra/newview/tests/llhttpretrypolicy_test.cpp | 6 +- 3 files changed, 119 insertions(+), 242 deletions(-) (limited to 'indra') diff --git a/indra/llcorehttp/tests/test_httpheaders.hpp b/indra/llcorehttp/tests/test_httpheaders.hpp index 668c36dc66..c05f1d9429 100755 --- a/indra/llcorehttp/tests/test_httpheaders.hpp +++ b/indra/llcorehttp/tests/test_httpheaders.hpp @@ -59,13 +59,12 @@ void HttpHeadersTestObjectType::test<1>() mMemTotal = GetMemTotal(); // create a new ref counted object with an implicit reference - HttpHeaders * headers = new HttpHeaders(); - ensure("One ref on construction of HttpHeaders", headers->getRefCount() == 1); + HttpHeaders::ptr_t headers = HttpHeaders::ptr_t(new HttpHeaders()); ensure("Memory being used", mMemTotal < GetMemTotal()); ensure("Nothing in headers", 0 == headers->size()); // release the implicit reference, causing the object to be released - headers->release(); + headers.reset(); // make sure we didn't leak any memory ensure(mMemTotal == GetMemTotal()); @@ -80,7 +79,7 @@ void HttpHeadersTestObjectType::test<2>() mMemTotal = GetMemTotal(); // create a new ref counted object with an implicit reference - HttpHeaders * headers = new HttpHeaders(); + HttpHeaders::ptr_t headers = HttpHeaders::ptr_t(new HttpHeaders()); { // Append a few strings @@ -101,7 +100,7 @@ void HttpHeadersTestObjectType::test<2>() } // release the implicit reference, causing the object to be released - headers->release(); + headers.reset(); // make sure we didn't leak any memory ensure(mMemTotal == GetMemTotal()); @@ -116,7 +115,7 @@ void HttpHeadersTestObjectType::test<3>() mMemTotal = GetMemTotal(); // create a new ref counted object with an implicit reference - HttpHeaders * headers = new HttpHeaders(); + HttpHeaders::ptr_t headers = HttpHeaders::ptr_t(new HttpHeaders()); { // Append a few strings @@ -151,7 +150,7 @@ void HttpHeadersTestObjectType::test<3>() } // release the implicit reference, causing the object to be released - headers->release(); + headers.reset(); // make sure we didn't leak any memory ensure(mMemTotal == GetMemTotal()); @@ -166,8 +165,8 @@ void HttpHeadersTestObjectType::test<4>() mMemTotal = GetMemTotal(); // create a new ref counted object with an implicit reference - HttpHeaders * headers = new HttpHeaders(); - + HttpHeaders::ptr_t headers = HttpHeaders::ptr_t(new HttpHeaders()); + { static char line1[] = " AcCePT : image/yourfacehere"; static char line1v[] = "image/yourfacehere"; @@ -251,7 +250,7 @@ void HttpHeadersTestObjectType::test<4>() } // release the implicit reference, causing the object to be released - headers->release(); + headers.reset(); // make sure we didn't leak any memory ensure(mMemTotal == GetMemTotal()); @@ -267,7 +266,7 @@ void HttpHeadersTestObjectType::test<5>() mMemTotal = GetMemTotal(); // create a new ref counted object with an implicit reference - HttpHeaders * headers = new HttpHeaders(); + HttpHeaders::ptr_t headers = HttpHeaders::ptr_t(new HttpHeaders()); HttpHeaders::iterator end(headers->end()), begin(headers->begin()); ensure("Empty container has equal begin/end const iterators", end == begin); @@ -337,7 +336,7 @@ void HttpHeadersTestObjectType::test<5>() } // release the implicit reference, causing the object to be released - headers->release(); + headers.reset(); // make sure we didn't leak any memory ensure(mMemTotal == GetMemTotal()); @@ -353,7 +352,7 @@ void HttpHeadersTestObjectType::test<6>() mMemTotal = GetMemTotal(); // create a new ref counted object with an implicit reference - HttpHeaders * headers = new HttpHeaders(); + HttpHeaders::ptr_t headers = HttpHeaders::ptr_t(new HttpHeaders()); HttpHeaders::reverse_iterator rend(headers->rend()), rbegin(headers->rbegin()); ensure("Empty container has equal rbegin/rend const iterators", rend == rbegin); @@ -421,7 +420,7 @@ void HttpHeadersTestObjectType::test<6>() } // release the implicit reference, causing the object to be released - headers->release(); + headers.reset(); // make sure we didn't leak any memory ensure(mMemTotal == GetMemTotal()); diff --git a/indra/llcorehttp/tests/test_httprequest.hpp b/indra/llcorehttp/tests/test_httprequest.hpp index 43f7e36da5..1f606bd0c1 100755 --- a/indra/llcorehttp/tests/test_httprequest.hpp +++ b/indra/llcorehttp/tests/test_httprequest.hpp @@ -112,7 +112,7 @@ public: if (! mHeadersRequired.empty() || ! mHeadersDisallowed.empty()) { ensure("Response required with header check", response != NULL); - HttpHeaders * header(response->getHeaders()); // Will not hold onto this + HttpHeaders::ptr_t header(response->getHeaders()); // Will not hold onto this ensure("Some quantity of headers returned", header != NULL); if (! mHeadersRequired.empty()) @@ -638,7 +638,7 @@ void HttpRequestTestObjectType::test<7>() mHandlerCalls = 0; HttpRequest * req = NULL; - HttpOptions * opts = NULL; + HttpOptions::ptr_t opts; try { @@ -653,7 +653,7 @@ void HttpRequestTestObjectType::test<7>() req = new HttpRequest(); ensure("Memory allocated on construction", mMemTotal < GetMemTotal()); - opts = new HttpOptions(); + opts = HttpOptions::ptr_t(new HttpOptions()); opts->setRetries(1); // Don't try for too long - default retries take about 18S // Issue a GET that can't connect @@ -664,7 +664,7 @@ void HttpRequestTestObjectType::test<7>() 0, 0, opts, - NULL, + HttpHeaders::ptr_t(), &handler); ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID); @@ -705,8 +705,7 @@ void HttpRequestTestObjectType::test<7>() ensure("Thread actually stopped running", HttpService::isStopped()); // release options - opts->release(); - opts = NULL; + opts.reset(); // release the request object delete req; @@ -728,11 +727,7 @@ void HttpRequestTestObjectType::test<7>() catch (...) { stop_thread(req); - if (opts) - { - opts->release(); - opts = NULL; - } + opts.reset(); delete req; HttpRequest::destroyService(); throw; @@ -779,8 +774,8 @@ void HttpRequestTestObjectType::test<8>() HttpHandle handle = req->requestGet(HttpRequest::DEFAULT_POLICY_ID, 0U, url_base, - NULL, - NULL, + HttpOptions::ptr_t(), + HttpHeaders::ptr_t(), &handler); ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID); @@ -889,8 +884,8 @@ void HttpRequestTestObjectType::test<9>() url_base, 0, 0, - NULL, - NULL, + HttpOptions::ptr_t(), + HttpHeaders::ptr_t(), &handler); ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID); @@ -1001,9 +996,9 @@ void HttpRequestTestObjectType::test<10>() 0U, url_base, body, - NULL, - NULL, - &handler); + HttpOptions::ptr_t(), + HttpHeaders::ptr_t(), + &handler); ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID); // Run the notification pump. @@ -1119,9 +1114,9 @@ void HttpRequestTestObjectType::test<11>() 0U, url_base, body, - NULL, - NULL, - &handler); + HttpOptions::ptr_t(), + HttpHeaders::ptr_t(), + &handler); ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID); // Run the notification pump. @@ -1239,9 +1234,9 @@ void HttpRequestTestObjectType::test<12>() url_base, 0, 0, - NULL, - NULL, - &handler); + HttpOptions::ptr_t(), + HttpHeaders::ptr_t(), + &handler); ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID); // Run the notification pump. @@ -1332,7 +1327,7 @@ void HttpRequestTestObjectType::test<13>() mHandlerCalls = 0; HttpRequest * req = NULL; - HttpOptions * opts = NULL; + HttpOptions::ptr_t opts; try { @@ -1350,7 +1345,7 @@ void HttpRequestTestObjectType::test<13>() req = new HttpRequest(); ensure("Memory allocated on construction", mMemTotal < GetMemTotal()); - opts = new HttpOptions(); + opts = HttpOptions::ptr_t(new HttpOptions()); opts->setWantHeaders(true); // Issue a GET that succeeds @@ -1364,13 +1359,12 @@ void HttpRequestTestObjectType::test<13>() 0, 0, opts, - NULL, - &handler); + HttpHeaders::ptr_t(), + &handler); ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID); // release options - opts->release(); - opts = NULL; + opts.reset(); // Run the notification pump. int count(0); @@ -1430,11 +1424,7 @@ void HttpRequestTestObjectType::test<13>() catch (...) { stop_thread(req); - if (opts) - { - opts->release(); - opts = NULL; - } + opts.reset(); delete req; HttpRequest::destroyService(); throw; @@ -1460,7 +1450,7 @@ void HttpRequestTestObjectType::test<14>() mHandlerCalls = 0; HttpRequest * req = NULL; - HttpOptions * opts = NULL; + HttpOptions::ptr_t opts; try { @@ -1475,7 +1465,7 @@ void HttpRequestTestObjectType::test<14>() req = new HttpRequest(); ensure("Memory allocated on construction", mMemTotal < GetMemTotal()); - opts = new HttpOptions(); + opts = HttpOptions::ptr_t(new HttpOptions); opts->setRetries(0); // Don't retry opts->setTimeout(2); @@ -1487,8 +1477,8 @@ void HttpRequestTestObjectType::test<14>() 0, 0, opts, - NULL, - &handler); + HttpHeaders::ptr_t(), + &handler); ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID); // Run the notification pump. @@ -1528,8 +1518,7 @@ void HttpRequestTestObjectType::test<14>() ensure("Thread actually stopped running", HttpService::isStopped()); // release options - opts->release(); - opts = NULL; + opts.reset(); // release the request object delete req; @@ -1552,11 +1541,7 @@ void HttpRequestTestObjectType::test<14>() catch (...) { stop_thread(req); - if (opts) - { - opts->release(); - opts = NULL; - } + opts.reset(); delete req; HttpRequest::destroyService(); throw; @@ -1609,9 +1594,9 @@ void HttpRequestTestObjectType::test<15>() HttpHandle handle = req->requestGet(HttpRequest::DEFAULT_POLICY_ID, 0U, url_base, - NULL, - NULL, - &handler); + HttpOptions::ptr_t(), + HttpHeaders::ptr_t(), + &handler); ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID); // Run the notification pump. @@ -1703,8 +1688,8 @@ void HttpRequestTestObjectType::test<16>() mHandlerCalls = 0; HttpRequest * req = NULL; - HttpOptions * options = NULL; - HttpHeaders * headers = NULL; + HttpOptions::ptr_t options; + HttpHeaders::ptr_t headers; try { @@ -1719,7 +1704,7 @@ void HttpRequestTestObjectType::test<16>() req = new HttpRequest(); // options set - options = new HttpOptions(); + options = HttpOptions::ptr_t(new HttpOptions()); options->setWantHeaders(true); // Issue a GET that *can* connect @@ -1776,7 +1761,7 @@ void HttpRequestTestObjectType::test<16>() 0U, url_base + "reflect/", options, - NULL, + HttpHeaders::ptr_t(), &handler); ensure("Valid handle returned for get request", handle != LLCORE_HTTP_HANDLE_INVALID); @@ -1792,7 +1777,7 @@ void HttpRequestTestObjectType::test<16>() ensure("One handler invocation for request", mHandlerCalls == 1); // Do a texture-style fetch - headers = new HttpHeaders; + headers = HttpHeaders::ptr_t(new HttpHeaders); headers->append("Accept", "image/x-j2c"); mStatus = HttpStatus(200); @@ -1897,17 +1882,8 @@ void HttpRequestTestObjectType::test<16>() ensure("Thread actually stopped running", HttpService::isStopped()); // release options & headers - if (options) - { - options->release(); - } - options = NULL; - - if (headers) - { - headers->release(); - } - headers = NULL; + options.reset(); + headers.reset(); // release the request object delete req; @@ -1919,16 +1895,9 @@ void HttpRequestTestObjectType::test<16>() catch (...) { stop_thread(req); - if (options) - { - options->release(); - options = NULL; - } - if (headers) - { - headers->release(); - headers = NULL; - } + options.reset(); + headers.reset(); + delete req; HttpRequest::destroyService(); throw; @@ -1960,8 +1929,8 @@ void HttpRequestTestObjectType::test<17>() mHandlerCalls = 0; HttpRequest * req = NULL; - HttpOptions * options = NULL; - HttpHeaders * headers = NULL; + HttpOptions::ptr_t options; + HttpHeaders::ptr_t headers; BufferArray * ba = NULL; try @@ -1977,7 +1946,7 @@ void HttpRequestTestObjectType::test<17>() req = new HttpRequest(); // options set - options = new HttpOptions(); + options = HttpOptions::ptr_t(new HttpOptions()); options->setWantHeaders(true); // And a buffer array @@ -2049,7 +2018,7 @@ void HttpRequestTestObjectType::test<17>() url_base + "reflect/", ba, options, - NULL, + HttpHeaders::ptr_t(), &handler); ensure("Valid handle returned for get request", handle != LLCORE_HTTP_HANDLE_INVALID); ba->release(); @@ -2095,17 +2064,8 @@ void HttpRequestTestObjectType::test<17>() ensure("Thread actually stopped running", HttpService::isStopped()); // release options & headers - if (options) - { - options->release(); - } - options = NULL; - - if (headers) - { - headers->release(); - } - headers = NULL; + options.reset(); + headers.reset(); // release the request object delete req; @@ -2122,17 +2082,10 @@ void HttpRequestTestObjectType::test<17>() ba->release(); ba = NULL; } - if (options) - { - options->release(); - options = NULL; - } - if (headers) - { - headers->release(); - headers = NULL; - } - delete req; + options.reset(); + headers.reset(); + + delete req; HttpRequest::destroyService(); throw; } @@ -2163,8 +2116,8 @@ void HttpRequestTestObjectType::test<18>() mHandlerCalls = 0; HttpRequest * req = NULL; - HttpOptions * options = NULL; - HttpHeaders * headers = NULL; + HttpOptions::ptr_t options; + HttpHeaders::ptr_t headers; BufferArray * ba = NULL; try @@ -2180,7 +2133,7 @@ void HttpRequestTestObjectType::test<18>() req = new HttpRequest(); // options set - options = new HttpOptions(); + options = HttpOptions::ptr_t(new HttpOptions()); options->setWantHeaders(true); // And a buffer array @@ -2253,7 +2206,7 @@ void HttpRequestTestObjectType::test<18>() url_base + "reflect/", ba, options, - NULL, + HttpHeaders::ptr_t(), &handler); ensure("Valid handle returned for get request", handle != LLCORE_HTTP_HANDLE_INVALID); ba->release(); @@ -2299,17 +2252,8 @@ void HttpRequestTestObjectType::test<18>() ensure("Thread actually stopped running", HttpService::isStopped()); // release options & headers - if (options) - { - options->release(); - } - options = NULL; - - if (headers) - { - headers->release(); - } - headers = NULL; + options.reset(); + headers.reset(); // release the request object delete req; @@ -2326,17 +2270,10 @@ void HttpRequestTestObjectType::test<18>() ba->release(); ba = NULL; } - if (options) - { - options->release(); - options = NULL; - } - if (headers) - { - headers->release(); - headers = NULL; - } - delete req; + options.reset(); + headers.reset(); + + delete req; HttpRequest::destroyService(); throw; } @@ -2367,8 +2304,8 @@ void HttpRequestTestObjectType::test<19>() mHandlerCalls = 0; HttpRequest * req = NULL; - HttpOptions * options = NULL; - HttpHeaders * headers = NULL; + HttpOptions::ptr_t options; + HttpHeaders::ptr_t headers; try { @@ -2383,11 +2320,11 @@ void HttpRequestTestObjectType::test<19>() req = new HttpRequest(); // options set - options = new HttpOptions(); + options = HttpOptions::ptr_t(new HttpOptions()); options->setWantHeaders(true); // headers - headers = new HttpHeaders; + headers = HttpHeaders::ptr_t(new HttpHeaders); headers->append("Keep-Alive", "120"); headers->append("Accept-encoding", "deflate"); headers->append("Accept", "text/plain"); @@ -2502,17 +2439,8 @@ void HttpRequestTestObjectType::test<19>() ensure("Thread actually stopped running", HttpService::isStopped()); // release options & headers - if (options) - { - options->release(); - } - options = NULL; - - if (headers) - { - headers->release(); - } - headers = NULL; + options.reset(); + headers.reset(); // release the request object delete req; @@ -2524,16 +2452,9 @@ void HttpRequestTestObjectType::test<19>() catch (...) { stop_thread(req); - if (options) - { - options->release(); - options = NULL; - } - if (headers) - { - headers->release(); - headers = NULL; - } + options.reset(); + headers.reset(); + delete req; HttpRequest::destroyService(); throw; @@ -2565,8 +2486,8 @@ void HttpRequestTestObjectType::test<20>() mHandlerCalls = 0; HttpRequest * req = NULL; - HttpOptions * options = NULL; - HttpHeaders * headers = NULL; + HttpOptions::ptr_t options; + HttpHeaders::ptr_t headers; BufferArray * ba = NULL; try @@ -2582,11 +2503,11 @@ void HttpRequestTestObjectType::test<20>() req = new HttpRequest(); // options set - options = new HttpOptions(); + options = HttpOptions::ptr_t(new HttpOptions()); options->setWantHeaders(true); // headers - headers = new HttpHeaders(); + headers = HttpHeaders::ptr_t(new HttpHeaders()); headers->append("keep-Alive", "120"); headers->append("Accept", "text/html"); headers->append("content-type", "application/llsd+xml"); @@ -2720,17 +2641,8 @@ void HttpRequestTestObjectType::test<20>() ensure("Thread actually stopped running", HttpService::isStopped()); // release options & headers - if (options) - { - options->release(); - } - options = NULL; - - if (headers) - { - headers->release(); - } - headers = NULL; + options.reset(); + headers.reset(); // release the request object delete req; @@ -2747,16 +2659,8 @@ void HttpRequestTestObjectType::test<20>() ba->release(); ba = NULL; } - if (options) - { - options->release(); - options = NULL; - } - if (headers) - { - headers->release(); - headers = NULL; - } + options.reset(); + headers.reset(); delete req; HttpRequest::destroyService(); throw; @@ -2788,8 +2692,8 @@ void HttpRequestTestObjectType::test<21>() mHandlerCalls = 0; HttpRequest * req = NULL; - HttpOptions * options = NULL; - HttpHeaders * headers = NULL; + HttpOptions::ptr_t options; + HttpHeaders::ptr_t headers; BufferArray * ba = NULL; try @@ -2805,11 +2709,11 @@ void HttpRequestTestObjectType::test<21>() req = new HttpRequest(); // options set - options = new HttpOptions(); + options = HttpOptions::ptr_t(new HttpOptions()); options->setWantHeaders(true); // headers - headers = new HttpHeaders; + headers = HttpHeaders::ptr_t(new HttpHeaders); headers->append("content-type", "text/plain"); headers->append("content-type", "text/html"); headers->append("content-type", "application/llsd+xml"); @@ -2937,17 +2841,8 @@ void HttpRequestTestObjectType::test<21>() ensure("Thread actually stopped running", HttpService::isStopped()); // release options & headers - if (options) - { - options->release(); - } - options = NULL; - - if (headers) - { - headers->release(); - } - headers = NULL; + options.reset(); + headers.reset(); // release the request object delete req; @@ -2964,16 +2859,8 @@ void HttpRequestTestObjectType::test<21>() ba->release(); ba = NULL; } - if (options) - { - options->release(); - options = NULL; - } - if (headers) - { - headers->release(); - headers = NULL; - } + options.reset(); + headers.reset(); delete req; HttpRequest::destroyService(); throw; @@ -3000,13 +2887,13 @@ void HttpRequestTestObjectType::test<22>() mMemTotal = GetMemTotal(); mHandlerCalls = 0; - HttpOptions * options = NULL; + HttpOptions::ptr_t options; HttpRequest * req = NULL; try { // options set - options = new HttpOptions(); + options = HttpOptions::ptr_t(new HttpOptions()); options->setRetries(1); // Partial_File is retryable and can timeout in here // Get singletons created @@ -3035,8 +2922,8 @@ void HttpRequestTestObjectType::test<22>() 0, 25, options, - NULL, - &handler); + HttpHeaders::ptr_t(), + &handler); ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID); } @@ -3067,7 +2954,7 @@ void HttpRequestTestObjectType::test<22>() 0, 25, options, - NULL, + HttpHeaders::ptr_t(), &handler); ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID); } @@ -3099,8 +2986,8 @@ void HttpRequestTestObjectType::test<22>() 0, 25, options, - NULL, - &handler); + HttpHeaders::ptr_t(), + &handler); ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID); } @@ -3144,11 +3031,7 @@ void HttpRequestTestObjectType::test<22>() ensure("Thread actually stopped running", HttpService::isStopped()); // release options - if (options) - { - options->release(); - options = NULL; - } + options.reset(); // release the request object delete req; @@ -3198,7 +3081,7 @@ void HttpRequestTestObjectType::test<23>() mHandlerCalls = 0; HttpRequest * req = NULL; - HttpOptions * opts = NULL; + HttpOptions::ptr_t opts; try { @@ -3213,7 +3096,7 @@ void HttpRequestTestObjectType::test<23>() req = new HttpRequest(); ensure("Memory allocated on construction", mMemTotal < GetMemTotal()); - opts = new HttpOptions(); + opts = HttpOptions::ptr_t(new HttpOptions()); opts->setRetries(1); // Retry once only opts->setUseRetryAfter(true); // Try to parse the retry-after header @@ -3230,8 +3113,8 @@ void HttpRequestTestObjectType::test<23>() 0, 0, opts, - NULL, - &handler); + HttpHeaders::ptr_t(), + &handler); std::ostringstream testtag; testtag << "Valid handle returned for 503 request #" << i; @@ -3277,8 +3160,7 @@ void HttpRequestTestObjectType::test<23>() ensure("Thread actually stopped running", HttpService::isStopped()); // release options - opts->release(); - opts = NULL; + opts.reset(); // release the request object delete req; @@ -3299,11 +3181,7 @@ void HttpRequestTestObjectType::test<23>() catch (...) { stop_thread(req); - if (opts) - { - opts->release(); - opts = NULL; - } + opts.reset(); delete req; HttpRequest::destroyService(); throw; diff --git a/indra/newview/tests/llhttpretrypolicy_test.cpp b/indra/newview/tests/llhttpretrypolicy_test.cpp index 25e6de46d9..8bd6cc2690 100755 --- a/indra/newview/tests/llhttpretrypolicy_test.cpp +++ b/indra/newview/tests/llhttpretrypolicy_test.cpp @@ -285,10 +285,10 @@ void RetryPolicyTestObject::test<7>() ensure_approximately_equals_range("header 2", seconds_to_wait, 7.0F, 2.0F); LLCore::HttpResponse *response; - LLCore::HttpHeaders *headers; + LLCore::HttpHeaders::ptr_t headers; response = new LLCore::HttpResponse(); - headers = new LLCore::HttpHeaders(); + headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders()); response->setStatus(503); response->setHeaders(headers); headers->append(HTTP_IN_HEADER_RETRY_AFTER, std::string("600")); @@ -299,7 +299,7 @@ void RetryPolicyTestObject::test<7>() response->release(); response = new LLCore::HttpResponse(); - headers = new LLCore::HttpHeaders(); + headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders()); response->setStatus(503); response->setHeaders(headers); time(&nowseconds); -- cgit v1.2.3 From ef3d1d642eb384fff853e227b92e20d66dbb8db7 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 8 Jul 2015 13:41:07 -0700 Subject: Replace ref parameter with value --- indra/llmessage/llcorehttputil.cpp | 12 ++++++------ indra/llmessage/llcorehttputil.h | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) (limited to 'indra') diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index 24f5d77ee1..5b5929383a 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -102,8 +102,8 @@ HttpHandle requestPostWithLLSD(HttpRequest * request, HttpRequest::priority_t priority, const std::string & url, const LLSD & body, - HttpOptions::ptr_t &options, - HttpHeaders::ptr_t &headers, + HttpOptions::ptr_t options, + HttpHeaders::ptr_t headers, HttpHandler * handler) { HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); @@ -129,8 +129,8 @@ HttpHandle requestPutWithLLSD(HttpRequest * request, HttpRequest::priority_t priority, const std::string & url, const LLSD & body, - HttpOptions::ptr_t &options, - HttpHeaders::ptr_t &headers, + HttpOptions::ptr_t options, + HttpHeaders::ptr_t headers, HttpHandler * handler) { HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); @@ -155,8 +155,8 @@ HttpHandle requestPatchWithLLSD(HttpRequest * request, HttpRequest::priority_t priority, const std::string & url, const LLSD & body, - HttpOptions::ptr_t &options, - HttpHeaders::ptr_t &headers, + HttpOptions::ptr_t options, + HttpHeaders::ptr_t headers, HttpHandler * handler) { HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); diff --git a/indra/llmessage/llcorehttputil.h b/indra/llmessage/llcorehttputil.h index 1e575e0e0c..4fada92666 100644 --- a/indra/llmessage/llcorehttputil.h +++ b/indra/llmessage/llcorehttputil.h @@ -111,8 +111,8 @@ LLCore::HttpHandle requestPostWithLLSD(LLCore::HttpRequest * request, LLCore::HttpRequest::priority_t priority, const std::string & url, const LLSD & body, - LLCore::HttpOptions::ptr_t &options, - LLCore::HttpHeaders::ptr_t &headers, + LLCore::HttpOptions::ptr_t options, + LLCore::HttpHeaders::ptr_t headers, LLCore::HttpHandler * handler); inline LLCore::HttpHandle requestPostWithLLSD(LLCore::HttpRequest::ptr_t & request, @@ -161,8 +161,8 @@ LLCore::HttpHandle requestPutWithLLSD(LLCore::HttpRequest * request, LLCore::HttpRequest::priority_t priority, const std::string & url, const LLSD & body, - LLCore::HttpOptions::ptr_t &options, - LLCore::HttpHeaders::ptr_t &headers, + LLCore::HttpOptions::ptr_t options, + LLCore::HttpHeaders::ptr_t headers, LLCore::HttpHandler * handler); inline LLCore::HttpHandle requestPutWithLLSD(LLCore::HttpRequest::ptr_t & request, @@ -210,8 +210,8 @@ LLCore::HttpHandle requestPatchWithLLSD(LLCore::HttpRequest * request, LLCore::HttpRequest::priority_t priority, const std::string & url, const LLSD & body, - LLCore::HttpOptions::ptr_t &options, - LLCore::HttpHeaders::ptr_t &headers, + LLCore::HttpOptions::ptr_t options, + LLCore::HttpHeaders::ptr_t headers, LLCore::HttpHandler * handler); inline LLCore::HttpHandle requestPatchWithLLSD(LLCore::HttpRequest::ptr_t & request, -- cgit v1.2.3 From fed4463cb90efc29525128db21a16899b63fbcc0 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 8 Jul 2015 14:02:12 -0700 Subject: This should be semantically the same thing that was there. --- indra/llmessage/llcorehttputil.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'indra') diff --git a/indra/llmessage/llcorehttputil.h b/indra/llmessage/llcorehttputil.h index 4fada92666..3dd13d0a0c 100644 --- a/indra/llmessage/llcorehttputil.h +++ b/indra/llmessage/llcorehttputil.h @@ -135,8 +135,11 @@ inline LLCore::HttpHandle requestPostWithLLSD(LLCore::HttpRequest::ptr_t & reque const LLSD & body, LLCore::HttpHandler * handler) { + LLCore::HttpOptions::ptr_t options; + LLCore::HttpHeaders::ptr_t headers; + return requestPostWithLLSD(request.get(), policy_id, priority, - url, body, LLCore::HttpOptions::ptr_t(), LLCore::HttpHeaders::ptr_t(), handler); + url, body, options, headers, handler); } @@ -185,8 +188,11 @@ inline LLCore::HttpHandle requestPutWithLLSD(LLCore::HttpRequest::ptr_t & reques const LLSD & body, LLCore::HttpHandler * handler) { + LLCore::HttpOptions::ptr_t options; + LLCore::HttpHeaders::ptr_t headers; + return requestPutWithLLSD(request.get(), policy_id, priority, - url, body, LLCore::HttpOptions::ptr_t(), LLCore::HttpHeaders::ptr_t(), handler); + url, body, options, headers, handler); } /// Issue a standard HttpRequest::requestPatch() call but using @@ -234,8 +240,11 @@ inline LLCore::HttpHandle requestPatchWithLLSD(LLCore::HttpRequest::ptr_t & requ const LLSD & body, LLCore::HttpHandler * handler) { + LLCore::HttpOptions::ptr_t options; + LLCore::HttpHeaders::ptr_t headers; + return requestPatchWithLLSD(request.get(), policy_id, priority, - url, body, LLCore::HttpOptions::ptr_t(), LLCore::HttpHeaders::ptr_t(), handler); + url, body, options, headers, handler); } //========================================================================= -- cgit v1.2.3 From 75b12d79e1aeeef297182e4419df7022ede485f3 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 8 Jul 2015 14:49:08 -0700 Subject: Enforcing constness of refs --- indra/llcorehttp/_httpoprequest.cpp | 32 ++++++++++++++++---------------- indra/llcorehttp/_httpoprequest.h | 32 ++++++++++++++++---------------- indra/llcorehttp/httprequest.cpp | 28 ++++++++++++++-------------- indra/llcorehttp/httprequest.h | 28 ++++++++++++++-------------- indra/llmessage/llcorehttputil.cpp | 12 ++++++------ indra/llmessage/llcorehttputil.h | 34 +++++++++++++++++----------------- 6 files changed, 83 insertions(+), 83 deletions(-) (limited to 'indra') diff --git a/indra/llcorehttp/_httpoprequest.cpp b/indra/llcorehttp/_httpoprequest.cpp index 7baef25aca..e588ed8a9b 100755 --- a/indra/llcorehttp/_httpoprequest.cpp +++ b/indra/llcorehttp/_httpoprequest.cpp @@ -281,8 +281,8 @@ HttpStatus HttpOpRequest::cancel() HttpStatus HttpOpRequest::setupGet(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers) + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers) { setupCommon(policy_id, priority, url, NULL, options, headers); mReqMethod = HOR_GET; @@ -296,8 +296,8 @@ HttpStatus HttpOpRequest::setupGetByteRange(HttpRequest::policy_t policy_id, const std::string & url, size_t offset, size_t len, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers) + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers) { setupCommon(policy_id, priority, url, NULL, options, headers); mReqMethod = HOR_GET; @@ -316,8 +316,8 @@ HttpStatus HttpOpRequest::setupPost(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, BufferArray * body, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers) + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers) { setupCommon(policy_id, priority, url, body, options, headers); mReqMethod = HOR_POST; @@ -330,8 +330,8 @@ HttpStatus HttpOpRequest::setupPut(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, BufferArray * body, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers) + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers) { setupCommon(policy_id, priority, url, body, options, headers); mReqMethod = HOR_PUT; @@ -343,8 +343,8 @@ HttpStatus HttpOpRequest::setupPut(HttpRequest::policy_t policy_id, HttpStatus HttpOpRequest::setupDelete(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers) + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers) { setupCommon(policy_id, priority, url, NULL, options, headers); mReqMethod = HOR_DELETE; @@ -357,8 +357,8 @@ HttpStatus HttpOpRequest::setupPatch(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, BufferArray * body, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers) + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers) { setupCommon(policy_id, priority, url, body, options, headers); mReqMethod = HOR_PATCH; @@ -370,8 +370,8 @@ HttpStatus HttpOpRequest::setupPatch(HttpRequest::policy_t policy_id, HttpStatus HttpOpRequest::setupCopy(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t &headers) + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t &headers) { setupCommon(policy_id, priority, url, NULL, options, headers); mReqMethod = HOR_COPY; @@ -384,8 +384,8 @@ void HttpOpRequest::setupCommon(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, BufferArray * body, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers) + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers) { mProcFlags = 0U; mReqPolicy = policy_id; diff --git a/indra/llcorehttp/_httpoprequest.h b/indra/llcorehttp/_httpoprequest.h index 42db71e7a0..a9083be02b 100755 --- a/indra/llcorehttp/_httpoprequest.h +++ b/indra/llcorehttp/_httpoprequest.h @@ -104,49 +104,49 @@ public: HttpStatus setupGet(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers); + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers); HttpStatus setupGetByteRange(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, size_t offset, size_t len, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers); + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers); HttpStatus setupPost(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, BufferArray * body, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers); + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers); HttpStatus setupPut(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, BufferArray * body, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers); + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers); HttpStatus setupDelete(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers); + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers); HttpStatus setupPatch(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, BufferArray * body, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers); + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers); HttpStatus setupCopy(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers); + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers); // Internal method used to setup the libcurl options for a request. // Does all the libcurl handle setup in one place. @@ -166,8 +166,8 @@ protected: HttpRequest::priority_t priority, const std::string & url, BufferArray * body, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers); + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers); // libcurl operational callbacks // diff --git a/indra/llcorehttp/httprequest.cpp b/indra/llcorehttp/httprequest.cpp index 4a7352c962..f0dfde6153 100755 --- a/indra/llcorehttp/httprequest.cpp +++ b/indra/llcorehttp/httprequest.cpp @@ -197,8 +197,8 @@ HttpStatus HttpRequest::getStatus() const HttpHandle HttpRequest::requestGet(policy_t policy_id, priority_t priority, const std::string & url, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers, + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers, HttpHandler * user_handler) { HttpStatus status; @@ -231,8 +231,8 @@ HttpHandle HttpRequest::requestGetByteRange(policy_t policy_id, const std::string & url, size_t offset, size_t len, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers, + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers, HttpHandler * user_handler) { HttpStatus status; @@ -264,8 +264,8 @@ HttpHandle HttpRequest::requestPost(policy_t policy_id, priority_t priority, const std::string & url, BufferArray * body, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers, + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers, HttpHandler * user_handler) { HttpStatus status; @@ -297,8 +297,8 @@ HttpHandle HttpRequest::requestPut(policy_t policy_id, priority_t priority, const std::string & url, BufferArray * body, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers, + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers, HttpHandler * user_handler) { HttpStatus status; @@ -328,8 +328,8 @@ HttpHandle HttpRequest::requestPut(policy_t policy_id, HttpHandle HttpRequest::requestDelete(policy_t policy_id, priority_t priority, const std::string & url, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers, + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers, HttpHandler * user_handler) { HttpStatus status; @@ -360,8 +360,8 @@ HttpHandle HttpRequest::requestPatch(policy_t policy_id, priority_t priority, const std::string & url, BufferArray * body, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers, + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers, HttpHandler * user_handler) { HttpStatus status; @@ -391,8 +391,8 @@ HttpHandle HttpRequest::requestPatch(policy_t policy_id, HttpHandle HttpRequest::requestCopy(policy_t policy_id, priority_t priority, const std::string & url, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers, + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers, HttpHandler * user_handler) { HttpStatus status; diff --git a/indra/llcorehttp/httprequest.h b/indra/llcorehttp/httprequest.h index 58aea1444c..20a223c482 100755 --- a/indra/llcorehttp/httprequest.h +++ b/indra/llcorehttp/httprequest.h @@ -348,8 +348,8 @@ public: HttpHandle requestGet(policy_t policy_id, priority_t priority, const std::string & url, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers, + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers, HttpHandler * handler); @@ -391,8 +391,8 @@ public: const std::string & url, size_t offset, size_t len, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers, + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers, HttpHandler * handler); @@ -432,8 +432,8 @@ public: priority_t priority, const std::string & url, BufferArray * body, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers, + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers, HttpHandler * handler); @@ -473,8 +473,8 @@ public: priority_t priority, const std::string & url, BufferArray * body, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers, + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers, HttpHandler * handler); @@ -493,8 +493,8 @@ public: HttpHandle requestDelete(policy_t policy_id, priority_t priority, const std::string & url, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers, + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers, HttpHandler * user_handler); /// Queue a full HTTP PUT. Query arguments and body may @@ -516,8 +516,8 @@ public: priority_t priority, const std::string & url, BufferArray * body, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers, + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers, HttpHandler * user_handler); /// Queue a full HTTP PUT. Query arguments and body may @@ -535,8 +535,8 @@ public: HttpHandle requestCopy(policy_t policy_id, priority_t priority, const std::string & url, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers, + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers, HttpHandler * user_handler); /// Queue a NoOp request. diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index 5b5929383a..a2004db30a 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -102,8 +102,8 @@ HttpHandle requestPostWithLLSD(HttpRequest * request, HttpRequest::priority_t priority, const std::string & url, const LLSD & body, - HttpOptions::ptr_t options, - HttpHeaders::ptr_t headers, + const HttpOptions::ptr_t &options, + const HttpHeaders::ptr_t &headers, HttpHandler * handler) { HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); @@ -129,8 +129,8 @@ HttpHandle requestPutWithLLSD(HttpRequest * request, HttpRequest::priority_t priority, const std::string & url, const LLSD & body, - HttpOptions::ptr_t options, - HttpHeaders::ptr_t headers, + const HttpOptions::ptr_t &options, + const HttpHeaders::ptr_t &headers, HttpHandler * handler) { HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); @@ -155,8 +155,8 @@ HttpHandle requestPatchWithLLSD(HttpRequest * request, HttpRequest::priority_t priority, const std::string & url, const LLSD & body, - HttpOptions::ptr_t options, - HttpHeaders::ptr_t headers, + const HttpOptions::ptr_t &options, + const HttpHeaders::ptr_t &headers, HttpHandler * handler) { HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); diff --git a/indra/llmessage/llcorehttputil.h b/indra/llmessage/llcorehttputil.h index 3dd13d0a0c..6d8f333c72 100644 --- a/indra/llmessage/llcorehttputil.h +++ b/indra/llmessage/llcorehttputil.h @@ -107,21 +107,21 @@ std::string responseToString(LLCore::HttpResponse * response); /// a now-useless HttpHandler object. /// LLCore::HttpHandle requestPostWithLLSD(LLCore::HttpRequest * request, - LLCore::HttpRequest::policy_t policy_id, - LLCore::HttpRequest::priority_t priority, - const std::string & url, - const LLSD & body, - LLCore::HttpOptions::ptr_t options, - LLCore::HttpHeaders::ptr_t headers, - LLCore::HttpHandler * handler); + LLCore::HttpRequest::policy_t policy_id, + LLCore::HttpRequest::priority_t priority, + const std::string & url, + const LLSD & body, + const LLCore::HttpOptions::ptr_t &options, + const LLCore::HttpHeaders::ptr_t &headers, + LLCore::HttpHandler * handler); inline LLCore::HttpHandle requestPostWithLLSD(LLCore::HttpRequest::ptr_t & request, LLCore::HttpRequest::policy_t policy_id, LLCore::HttpRequest::priority_t priority, const std::string & url, const LLSD & body, - LLCore::HttpOptions::ptr_t & options, - LLCore::HttpHeaders::ptr_t & headers, + const LLCore::HttpOptions::ptr_t & options, + const LLCore::HttpHeaders::ptr_t & headers, LLCore::HttpHandler * handler) { return requestPostWithLLSD(request.get(), policy_id, priority, @@ -164,8 +164,8 @@ LLCore::HttpHandle requestPutWithLLSD(LLCore::HttpRequest * request, LLCore::HttpRequest::priority_t priority, const std::string & url, const LLSD & body, - LLCore::HttpOptions::ptr_t options, - LLCore::HttpHeaders::ptr_t headers, + const LLCore::HttpOptions::ptr_t &options, + const LLCore::HttpHeaders::ptr_t &headers, LLCore::HttpHandler * handler); inline LLCore::HttpHandle requestPutWithLLSD(LLCore::HttpRequest::ptr_t & request, @@ -173,8 +173,8 @@ inline LLCore::HttpHandle requestPutWithLLSD(LLCore::HttpRequest::ptr_t & reques LLCore::HttpRequest::priority_t priority, const std::string & url, const LLSD & body, - LLCore::HttpOptions::ptr_t & options, - LLCore::HttpHeaders::ptr_t & headers, + const LLCore::HttpOptions::ptr_t & options, + const LLCore::HttpHeaders::ptr_t & headers, LLCore::HttpHandler * handler) { return requestPutWithLLSD(request.get(), policy_id, priority, @@ -216,8 +216,8 @@ LLCore::HttpHandle requestPatchWithLLSD(LLCore::HttpRequest * request, LLCore::HttpRequest::priority_t priority, const std::string & url, const LLSD & body, - LLCore::HttpOptions::ptr_t options, - LLCore::HttpHeaders::ptr_t headers, + const LLCore::HttpOptions::ptr_t &options, + const LLCore::HttpHeaders::ptr_t &headers, LLCore::HttpHandler * handler); inline LLCore::HttpHandle requestPatchWithLLSD(LLCore::HttpRequest::ptr_t & request, @@ -225,8 +225,8 @@ inline LLCore::HttpHandle requestPatchWithLLSD(LLCore::HttpRequest::ptr_t & requ LLCore::HttpRequest::priority_t priority, const std::string & url, const LLSD & body, - LLCore::HttpOptions::ptr_t & options, - LLCore::HttpHeaders::ptr_t & headers, + const LLCore::HttpOptions::ptr_t & options, + const LLCore::HttpHeaders::ptr_t & headers, LLCore::HttpHandler * handler) { return requestPatchWithLLSD(request.get(), policy_id, priority, -- cgit v1.2.3 From 675b6a807435a2c36297285dc307014141dd7960 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 8 Jul 2015 15:16:54 -0700 Subject: Fix the sample. --- indra/llcorehttp/examples/http_texture_load.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'indra') diff --git a/indra/llcorehttp/examples/http_texture_load.cpp b/indra/llcorehttp/examples/http_texture_load.cpp index 13c9f90b2e..737282c7df 100755 --- a/indra/llcorehttp/examples/http_texture_load.cpp +++ b/indra/llcorehttp/examples/http_texture_load.cpp @@ -121,7 +121,7 @@ public: int mRetriesHttp503; int mSuccesses; long mByteCount; - LLCore::HttpHeaders * mHeaders; + LLCore::HttpHeaders::ptr_t mHeaders; }; @@ -363,8 +363,7 @@ int main(int argc, char** argv) // Clean up hr->requestStopThread(NULL); ms_sleep(1000); - opt->release(); - opt = NULL; + opt.reset(); delete hr; LLCore::HttpRequest::destroyService(); term_curl(); @@ -427,18 +426,13 @@ WorkingSet::WorkingSet() { mAssets.reserve(30000); - mHeaders = new LLCore::HttpHeaders; + mHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders); mHeaders->append("Accept", "image/x-j2c"); } WorkingSet::~WorkingSet() { - if (mHeaders) - { - mHeaders->release(); - mHeaders = NULL; - } } -- cgit v1.2.3 From 657944cda7228ba824239d94b270160ac0460934 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 9 Jul 2015 21:42:34 -0400 Subject: Suppress http_proxy env var for llcorehttp integration test. Sometimes it can be useful to have http_proxy set in the environment, but if we leave it set while INTEGRATION_TEST_llcorehttp is running, the test hangs. Suppress that variable for that integration test. --- indra/llcorehttp/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'indra') diff --git a/indra/llcorehttp/CMakeLists.txt b/indra/llcorehttp/CMakeLists.txt index a0b1ea13b1..9631e960c5 100755 --- a/indra/llcorehttp/CMakeLists.txt +++ b/indra/llcorehttp/CMakeLists.txt @@ -134,9 +134,13 @@ if (LL_TESTS) ${BOOST_THREAD_LIBRARY} ) + # If http_proxy is in the current environment (e.g. to fetch s3-proxy + # autobuild packages), suppress it for this integration test: it screws up + # the tests. LL_ADD_INTEGRATION_TEST(llcorehttp "${llcorehttp_TEST_SOURCE_FILES}" "${test_libs}" + "-Dhttp_proxy" ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/tests/test_llcorehttp_peer.py" ) -- cgit v1.2.3 From fdb9a50d4ba3ee86b2878e1eba68d4e1536c4a15 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Fri, 10 Jul 2015 11:39:49 -0400 Subject: MAINT-4952: correct name of LLViewerRegionImpl::requestBaseCapabilitiesCoro. The string name being passed to LLCoros didn't match. --- indra/newview/llviewerregion.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index b256482289..291af28bc3 100755 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -2919,7 +2919,7 @@ void LLViewerRegion::setSeedCapability(const std::string& url) setCapability("Seed", url); std::string coroname = - LLCoros::instance().launch("LLEnvironmentRequest::environmentRequestCoro", + LLCoros::instance().launch("LLViewerRegionImpl::requestBaseCapabilitiesCoro", boost::bind(&LLViewerRegionImpl::requestBaseCapabilitiesCoro, mImpl, getHandle())); LL_INFOS("AppInit", "Capabilities") << "Launching " << coroname << " requesting seed capabilities from " << url << LL_ENDL; -- cgit v1.2.3 From 0c915913fd05007bb3fb6cc84be89799b7d85ae5 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Fri, 10 Jul 2015 16:01:15 -0400 Subject: MAINT-5351: Improve management of "current" coroutine information. Our first cut at tracking the "current" coroutine simply reset the pointer to NULL every time we context-switched away. But that strategy doesn't handle the case of coroutine A launching coroutine B. Introduce LLCoros::CoroData to track, among other things, the previous value of the current-coroutine pointer each time we switch into a coroutine. Restore THAT value when we switch back out. --- indra/llcommon/llcoros.cpp | 111 +++++++++++++++++++---------------------- indra/llcommon/llcoros.h | 57 +++++++++++++++++++-- indra/llcommon/lleventcoro.cpp | 4 +- 3 files changed, 106 insertions(+), 66 deletions(-) (limited to 'indra') diff --git a/indra/llcommon/llcoros.cpp b/indra/llcommon/llcoros.cpp index 957fe034e1..d76401d01b 100755 --- a/indra/llcommon/llcoros.cpp +++ b/indra/llcommon/llcoros.cpp @@ -34,63 +34,47 @@ // std headers // external library headers #include -#include // other Linden headers #include "llevents.h" #include "llerror.h" #include "stringize.h" -namespace { - // do nothing, when we need nothing done -void no_cleanup(LLCoros::coro::self*) {} - -// When the dcoroutine library calls a top-level callable, it implicitly -// passes coro::self& as the first parameter. All our consumer code used to -// explicitly pass coro::self& down through all levels of call stack, because -// at the leaf level we need it for context-switching. But since coroutines -// are based on cooperative switching, we can cause the top-level entry point -// to stash a static pointer to the currently-running coroutine, and manage it -// appropriately as we switch out and back in. That eliminates the need to -// pass it as an explicit parameter down through every level, which is -// unfortunately viral in nature. Finding it implicitly rather than explicitly -// allows minor maintenance in which a leaf-level function adds a new async -// I/O call that suspends the calling coroutine, WITHOUT having to propagate -// coro::self& through every function signature down to that point -- and of -// course through every other caller of every such function. -// We use a boost::thread_specific_ptr because each thread potentially has its -// own distinct pool of coroutines. -// This thread_specific_ptr does NOT own the 'self' object! It merely -// identifies it. For this reason we instantiate it with a no-op cleanup -// function. -static boost::thread_specific_ptr -sCurrentSelf(no_cleanup); - -} // anonymous +void LLCoros::no_cleanup(CoroData*) {} + +// CoroData for the currently-running coroutine. Use a thread_specific_ptr +// because each thread potentially has its own distinct pool of coroutines. +// This thread_specific_ptr does NOT own the CoroData object! That's owned by +// LLCoros::mCoros. It merely identifies it. For this reason we instantiate +// it with a no-op cleanup function. +boost::thread_specific_ptr +LLCoros::sCurrentCoro(LLCoros::no_cleanup); //static -LLCoros::coro::self& llcoro::get_self() +LLCoros::coro::self& LLCoros::get_self() { - LLCoros::coro::self* current_self = sCurrentSelf.get(); - if (! current_self) + CoroData* current = sCurrentCoro.get(); + if (! current) { LL_ERRS("LLCoros") << "Calling get_self() from non-coroutine context!" << LL_ENDL; } - return *current_self; + return *current->mSelf; } llcoro::Suspending::Suspending(): - mSuspended(sCurrentSelf.get()) + mSuspended(LLCoros::sCurrentCoro.get()) { - // For the duration of our time away from this coroutine, sCurrentSelf - // must NOT refer to this coroutine. - sCurrentSelf.reset(); + // Revert mCurrentCoro to the value it had at the moment we last switched + // into this coroutine. + LLCoros::sCurrentCoro.reset(mSuspended->mPrev); } llcoro::Suspending::~Suspending() { - // Okay, we're back, reinstate previous value of sCurrentSelf. - sCurrentSelf.reset(mSuspended); + // Okay, we're back, update our mPrev + mSuspended->mPrev = LLCoros::sCurrentCoro.get(); + // and reinstate our sCurrentCoro. + LLCoros::sCurrentCoro.reset(mSuspended); } LLCoros::LLCoros(): @@ -112,7 +96,7 @@ bool LLCoros::cleanup(const LLSD&) { // Has this coroutine exited (normal return, exception, exit() call) // since last tick? - if (mi->second->exited()) + if (mi->second->mCoro.exited()) { LL_INFOS("LLCoros") << "LLCoros: cleaning up coroutine " << mi->first << LL_ENDL; // The erase() call will invalidate its passed iterator value -- @@ -170,18 +154,13 @@ bool LLCoros::kill(const std::string& name) std::string LLCoros::getName() const { - // Walk the existing coroutines, looking for the current one. - void* self_id = llcoro::get_self().get_id(); - for (CoroMap::const_iterator mi(mCoros.begin()), mend(mCoros.end()); mi != mend; ++mi) + CoroData* current = sCurrentCoro.get(); + if (! current) { - namespace coro_private = boost::dcoroutines::detail; - if (static_cast(coro_private::coroutine_accessor::get_impl(const_cast(*mi->second)).get()) - == self_id) - { - return mi->first; - } + // not in a coroutine + return ""; } - return ""; + return current->mName; } void LLCoros::setStackSize(S32 stacksize) @@ -190,20 +169,20 @@ void LLCoros::setStackSize(S32 stacksize) mStackSize = stacksize; } -namespace { - // Top-level wrapper around caller's coroutine callable. This function accepts // the coroutine library's implicit coro::self& parameter and sets sCurrentSelf // but does not pass it down to the caller's callable. -void toplevel(LLCoros::coro::self& self, const LLCoros::callable_t& callable) +void LLCoros::toplevel(coro::self& self, CoroData* data, const callable_t& callable) { - sCurrentSelf.reset(&self); + // capture the 'self' param in CoroData + data->mSelf = &self; + // run the code the caller actually wants in the coroutine callable(); - sCurrentSelf.reset(); + // This cleanup isn't perfectly symmetrical with the way we initially set + // data->mPrev, but this is our last chance to reset mCurrentCoro. + sCurrentCoro.reset(data->mPrev); } -} // anonymous - /***************************************************************************** * MUST BE LAST *****************************************************************************/ @@ -215,19 +194,33 @@ void toplevel(LLCoros::coro::self& self, const LLCoros::callable_t& callable) #if LL_MSVC // work around broken optimizations #pragma warning(disable: 4748) +#pragma warning(disable: 4355) // 'this' used in initializer list: yes, intentionally #pragma optimize("", off) #endif // LL_MSVC +LLCoros::CoroData::CoroData(CoroData* prev, const std::string& name, + const callable_t& callable, S32 stacksize): + mPrev(prev), + mName(name), + // Wrap the caller's callable in our toplevel() function so we can manage + // sCurrentCoro appropriately at startup and shutdown of each coroutine. + mCoro(boost::bind(toplevel, _1, this, callable), stacksize), + mSelf(0) +{ +} + std::string LLCoros::launch(const std::string& prefix, const callable_t& callable) { std::string name(generateDistinctName(prefix)); - // Wrap the caller's callable in our toplevel() function so we can manage - // sCurrentSelf appropriately at startup and shutdown of each coroutine. - coro* newCoro = new coro(boost::bind(toplevel, _1, callable), mStackSize); + // pass the current value of sCurrentCoro as previous context + CoroData* newCoro = new CoroData(sCurrentCoro.get(), name, + callable, mStackSize); // Store it in our pointer map mCoros.insert(name, newCoro); + // also set it as current + sCurrentCoro.reset(newCoro); /* Run the coroutine until its first wait, then return here */ - (*newCoro)(std::nothrow); + (newCoro->mCoro)(std::nothrow); return name; } diff --git a/indra/llcommon/llcoros.h b/indra/llcommon/llcoros.h index e478600f00..56eed8cafe 100755 --- a/indra/llcommon/llcoros.h +++ b/indra/llcommon/llcoros.h @@ -33,9 +33,16 @@ #include "llsingleton.h" #include #include +#include #include #include +// forward-declare helper class +namespace llcoro +{ +class Suspending; +} + /** * Registry of named Boost.Coroutine instances * @@ -140,23 +147,63 @@ public: /// for delayed initialization void setStackSize(S32 stacksize); + /// get the current coro::self& for those who really really care + static coro::self& get_self(); + private: LLCoros(); friend class LLSingleton; + friend class llcoro::Suspending; std::string generateDistinctName(const std::string& prefix) const; bool cleanup(const LLSD&); + struct CoroData; + static void no_cleanup(CoroData*); + static void toplevel(coro::self& self, CoroData* data, const callable_t& callable); S32 mStackSize; - typedef boost::ptr_map CoroMap; + + // coroutine-local storage, as it were: one per coro we track + struct CoroData + { + CoroData(CoroData* prev, const std::string& name, + const callable_t& callable, S32 stacksize); + + // The boost::dcoroutines library supports asymmetric coroutines. Every + // time we context switch out of a coroutine, we pass control to the + // previously-active one (or to the non-coroutine stack owned by the + // thread). So our management of the "current" coroutine must be able to + // restore the previous value when we're about to switch away. + CoroData* mPrev; + // tweaked name of the current coroutine + const std::string mName; + // the actual coroutine instance + LLCoros::coro mCoro; + // When the dcoroutine library calls a top-level callable, it implicitly + // passes coro::self& as the first parameter. All our consumer code used + // to explicitly pass coro::self& down through all levels of call stack, + // because at the leaf level we need it for context-switching. But since + // coroutines are based on cooperative switching, we can cause the + // top-level entry point to stash a pointer to the currently-running + // coroutine, and manage it appropriately as we switch out and back in. + // That eliminates the need to pass it as an explicit parameter down + // through every level, which is unfortunately viral in nature. Finding it + // implicitly rather than explicitly allows minor maintenance in which a + // leaf-level function adds a new async I/O call that suspends the calling + // coroutine, WITHOUT having to propagate coro::self& through every + // function signature down to that point -- and of course through every + // other caller of every such function. + LLCoros::coro::self* mSelf; + }; + typedef boost::ptr_map CoroMap; CoroMap mCoros; + + // identify the current coroutine's CoroData + static boost::thread_specific_ptr sCurrentCoro; }; namespace llcoro { -/// get the current coro::self& for those who really really care -LLCoros::coro::self& get_self(); - /// Instantiate one of these in a block surrounding any leaf point when /// control literally switches away from this coroutine. class Suspending @@ -166,7 +213,7 @@ public: ~Suspending(); private: - LLCoros::coro::self* mSuspended; + LLCoros::CoroData* mSuspended; }; } // namespace llcoro diff --git a/indra/llcommon/lleventcoro.cpp b/indra/llcommon/lleventcoro.cpp index ad02e139b8..85af0d9b9f 100755 --- a/indra/llcommon/lleventcoro.cpp +++ b/indra/llcommon/lleventcoro.cpp @@ -157,7 +157,7 @@ LLSD llcoro::postAndWait(const LLSD& event, const LLEventPumpOrPumpName& request const LLEventPumpOrPumpName& replyPump, const LLSD& replyPumpNamePath) { // declare the future - boost::dcoroutines::future future(llcoro::get_self()); + boost::dcoroutines::future future(LLCoros::get_self()); // make a callback that will assign a value to the future, and listen on // the specified LLEventPump with that callback std::string listenerName(listenerNameForCoro()); @@ -250,7 +250,7 @@ LLEventWithID postAndWait2(const LLSD& event, const LLSD& replyPump1NamePath) { // declare the future - boost::dcoroutines::future future(llcoro::get_self()); + boost::dcoroutines::future future(LLCoros::get_self()); // either callback will assign a value to this future; listen on // each specified LLEventPump with a callback std::string name(listenerNameForCoro()); -- cgit v1.2.3 From 6f9f89ee71751a0e88bbda91fef1a575a5a68ed9 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Fri, 10 Jul 2015 16:47:07 -0400 Subject: Backed out changeset 6e1fa9518747: reapply 'selfless' changes --- indra/llcommon/llcoros.cpp | 10 +-- indra/llcommon/llcoros.h | 35 ++++---- indra/llcommon/lleventcoro.cpp | 127 ++++++++++++++++++++++++---- indra/llcommon/lleventcoro.h | 132 +++++++++--------------------- indra/llcommon/tests/lleventcoro_test.cpp | 5 +- indra/llmessage/llcorehttputil.cpp | 10 +-- indra/newview/llcoproceduremanager.cpp | 2 +- indra/newview/lleventpoll.cpp | 2 +- indra/viewer_components/login/lllogin.cpp | 6 +- 9 files changed, 185 insertions(+), 144 deletions(-) (limited to 'indra') diff --git a/indra/llcommon/llcoros.cpp b/indra/llcommon/llcoros.cpp index 2d0c419ae0..957fe034e1 100755 --- a/indra/llcommon/llcoros.cpp +++ b/indra/llcommon/llcoros.cpp @@ -69,9 +69,9 @@ sCurrentSelf(no_cleanup); } // anonymous //static -LLCoros::coro::self& LLCoros::get_self() +LLCoros::coro::self& llcoro::get_self() { - coro::self* current_self = sCurrentSelf.get(); + LLCoros::coro::self* current_self = sCurrentSelf.get(); if (! current_self) { LL_ERRS("LLCoros") << "Calling get_self() from non-coroutine context!" << LL_ENDL; @@ -79,7 +79,7 @@ LLCoros::coro::self& LLCoros::get_self() return *current_self; } -LLCoros::Suspending::Suspending(): +llcoro::Suspending::Suspending(): mSuspended(sCurrentSelf.get()) { // For the duration of our time away from this coroutine, sCurrentSelf @@ -87,7 +87,7 @@ LLCoros::Suspending::Suspending(): sCurrentSelf.reset(); } -LLCoros::Suspending::~Suspending() +llcoro::Suspending::~Suspending() { // Okay, we're back, reinstate previous value of sCurrentSelf. sCurrentSelf.reset(mSuspended); @@ -171,7 +171,7 @@ bool LLCoros::kill(const std::string& name) std::string LLCoros::getName() const { // Walk the existing coroutines, looking for the current one. - void* self_id = get_self().get_id(); + void* self_id = llcoro::get_self().get_id(); for (CoroMap::const_iterator mi(mCoros.begin()), mend(mCoros.end()); mi != mend; ++mi) { namespace coro_private = boost::dcoroutines::detail; diff --git a/indra/llcommon/llcoros.h b/indra/llcommon/llcoros.h index 3f58a17aa9..e478600f00 100755 --- a/indra/llcommon/llcoros.h +++ b/indra/llcommon/llcoros.h @@ -137,21 +137,6 @@ public: */ std::string getName() const; - /// get the current coro::self& for those who really really care - static coro::self& get_self(); - - /// Instantiate one of these in a block surrounding any leaf point when - /// control literally switches away from this coroutine. - class Suspending - { - public: - Suspending(); - ~Suspending(); - - private: - coro::self* mSuspended; - }; - /// for delayed initialization void setStackSize(S32 stacksize); @@ -166,4 +151,24 @@ private: CoroMap mCoros; }; +namespace llcoro +{ + +/// get the current coro::self& for those who really really care +LLCoros::coro::self& get_self(); + +/// Instantiate one of these in a block surrounding any leaf point when +/// control literally switches away from this coroutine. +class Suspending +{ +public: + Suspending(); + ~Suspending(); + +private: + LLCoros::coro::self* mSuspended; +}; + +} // namespace llcoro + #endif /* ! defined(LL_LLCOROS_H) */ diff --git a/indra/llcommon/lleventcoro.cpp b/indra/llcommon/lleventcoro.cpp index be93e9c83b..ad02e139b8 100755 --- a/indra/llcommon/lleventcoro.cpp +++ b/indra/llcommon/lleventcoro.cpp @@ -41,7 +41,23 @@ #include "llerror.h" #include "llcoros.h" -std::string LLEventDetail::listenerNameForCoro() +namespace +{ + +/** + * waitForEventOn() permits a coroutine to temporarily listen on an + * LLEventPump any number of times. We don't really want to have to ask + * the caller to label each such call with a distinct string; the whole + * point of waitForEventOn() is to present a nice sequential interface to + * the underlying LLEventPump-with-named-listeners machinery. So we'll use + * LLEventPump::inventName() to generate a distinct name for each + * temporary listener. On the other hand, because a given coroutine might + * call waitForEventOn() any number of times, we don't really want to + * consume an arbitrary number of generated inventName()s: that namespace, + * though large, is nonetheless finite. So we memoize an invented name for + * each distinct coroutine instance. + */ +std::string listenerNameForCoro() { // If this coroutine was launched by LLCoros::launch(), find that name. std::string name(LLCoros::instance().getName()); @@ -56,7 +72,25 @@ std::string LLEventDetail::listenerNameForCoro() return name; } -void LLEventDetail::storeToLLSDPath(LLSD& dest, const LLSD& rawPath, const LLSD& value) +/** + * Implement behavior described for postAndWait()'s @a replyPumpNamePath + * parameter: + * + * * If path.isUndefined(), do nothing. + * * If path.isString(), @a dest is an LLSD map: store @a value + * into dest[path.asString()]. + * * If path.isInteger(), @a dest is an LLSD array: store @a + * value into dest[path.asInteger()]. + * * If path.isArray(), iteratively apply the rules above to step + * down through the structure of @a dest. The last array entry in @a + * path specifies the entry in the lowest-level structure in @a dest + * into which to store @a value. + * + * @note + * In the degenerate case in which @a path is an empty array, @a dest will + * @em become @a value rather than @em containing it. + */ +void storeToLLSDPath(LLSD& dest, const LLSD& rawPath, const LLSD& value) { if (rawPath.isUndefined()) { @@ -109,14 +143,24 @@ void LLEventDetail::storeToLLSDPath(LLSD& dest, const LLSD& rawPath, const LLSD& *pdest = value; } -LLSD postAndWait(const LLSD& event, const LLEventPumpOrPumpName& requestPump, - const LLEventPumpOrPumpName& replyPump, const LLSD& replyPumpNamePath) +} // anonymous + +void llcoro::yield() +{ + // By viewer convention, we post an event on the "mainloop" LLEventPump + // each iteration of the main event-handling loop. So waiting for a single + // event on "mainloop" gives us a one-frame yield. + waitForEventOn("mainloop"); +} + +LLSD llcoro::postAndWait(const LLSD& event, const LLEventPumpOrPumpName& requestPump, + const LLEventPumpOrPumpName& replyPump, const LLSD& replyPumpNamePath) { // declare the future - boost::dcoroutines::future future(LLCoros::get_self()); + boost::dcoroutines::future future(llcoro::get_self()); // make a callback that will assign a value to the future, and listen on // the specified LLEventPump with that callback - std::string listenerName(LLEventDetail::listenerNameForCoro()); + std::string listenerName(listenerNameForCoro()); LLTempBoundListener connection( replyPump.getPump().listen(listenerName, voidlistener(boost::dcoroutines::make_callback(future)))); @@ -126,7 +170,7 @@ LLSD postAndWait(const LLSD& event, const LLEventPumpOrPumpName& requestPump, // If replyPumpNamePath is non-empty, store the replyPump name in the // request event. LLSD modevent(event); - LLEventDetail::storeToLLSDPath(modevent, replyPumpNamePath, replyPump.getPump().getName()); + storeToLLSDPath(modevent, replyPumpNamePath, replyPump.getPump().getName()); LL_DEBUGS("lleventcoro") << "postAndWait(): coroutine " << listenerName << " posting to " << requestPump.getPump().getName() << LL_ENDL; @@ -142,7 +186,7 @@ LLSD postAndWait(const LLSD& event, const LLEventPumpOrPumpName& requestPump, LLSD value; { // instantiate Suspending to manage the "current" coroutine - LLCoros::Suspending suspended; + llcoro::Suspending suspended; value = *future; } // destroy Suspending as soon as we're back LL_DEBUGS("lleventcoro") << "postAndWait(): coroutine " << listenerName @@ -151,6 +195,53 @@ LLSD postAndWait(const LLSD& event, const LLEventPumpOrPumpName& requestPump, return value; } +namespace +{ + +/** + * This helper is specifically for the two-pump version of waitForEventOn(). + * We use a single future object, but we want to listen on two pumps with it. + * Since we must still adapt from (the callable constructed by) + * boost::dcoroutines::make_callback() (void return) to provide an event + * listener (bool return), we've adapted VoidListener for the purpose. The + * basic idea is that we construct a distinct instance of WaitForEventOnHelper + * -- binding different instance data -- for each of the pumps. Then, when a + * pump delivers an LLSD value to either WaitForEventOnHelper, it can combine + * that LLSD with its discriminator to feed the future object. + */ +template +class WaitForEventOnHelper +{ +public: + WaitForEventOnHelper(const LISTENER& listener, int discriminator): + mListener(listener), + mDiscrim(discriminator) + {} + // this signature is required for an LLEventPump listener + bool operator()(const LLSD& event) + { + // our future object is defined to accept LLEventWithID + mListener(LLEventWithID(event, mDiscrim)); + // don't swallow the event, let other listeners see it + return false; + } +private: + LISTENER mListener; + const int mDiscrim; +}; + +/// WaitForEventOnHelper type-inference helper +template +WaitForEventOnHelper wfeoh(const LISTENER& listener, int discriminator) +{ + return WaitForEventOnHelper(listener, discriminator); +} + +} // anonymous + +namespace llcoro +{ + LLEventWithID postAndWait2(const LLSD& event, const LLEventPumpOrPumpName& requestPump, const LLEventPumpOrPumpName& replyPump0, @@ -159,26 +250,26 @@ LLEventWithID postAndWait2(const LLSD& event, const LLSD& replyPump1NamePath) { // declare the future - boost::dcoroutines::future future(LLCoros::get_self()); + boost::dcoroutines::future future(llcoro::get_self()); // either callback will assign a value to this future; listen on // each specified LLEventPump with a callback - std::string name(LLEventDetail::listenerNameForCoro()); + std::string name(listenerNameForCoro()); LLTempBoundListener connection0( replyPump0.getPump().listen(name + "a", - LLEventDetail::wfeoh(boost::dcoroutines::make_callback(future), 0))); + wfeoh(boost::dcoroutines::make_callback(future), 0))); LLTempBoundListener connection1( replyPump1.getPump().listen(name + "b", - LLEventDetail::wfeoh(boost::dcoroutines::make_callback(future), 1))); + wfeoh(boost::dcoroutines::make_callback(future), 1))); // skip the "post" part if requestPump is default-constructed if (requestPump) { // If either replyPumpNamePath is non-empty, store the corresponding // replyPump name in the request event. LLSD modevent(event); - LLEventDetail::storeToLLSDPath(modevent, replyPump0NamePath, - replyPump0.getPump().getName()); - LLEventDetail::storeToLLSDPath(modevent, replyPump1NamePath, - replyPump1.getPump().getName()); + storeToLLSDPath(modevent, replyPump0NamePath, + replyPump0.getPump().getName()); + storeToLLSDPath(modevent, replyPump1NamePath, + replyPump1.getPump().getName()); LL_DEBUGS("lleventcoro") << "postAndWait2(): coroutine " << name << " posting to " << requestPump.getPump().getName() << ": " << modevent << LL_ENDL; @@ -191,7 +282,7 @@ LLEventWithID postAndWait2(const LLSD& event, LLEventWithID value; { // instantiate Suspending to manage "current" coroutine - LLCoros::Suspending suspended; + llcoro::Suspending suspended; value = *future; } // destroy Suspending as soon as we're back LL_DEBUGS("lleventcoro") << "postAndWait(): coroutine " << name @@ -227,3 +318,5 @@ LLSD errorLog(const LLEventWithID& result, const std::string& desc) // A simple return must therefore be from the reply pump (pump 0). return result.first; } + +} // namespace llcoro diff --git a/indra/llcommon/lleventcoro.h b/indra/llcommon/lleventcoro.h index daf9360a2e..e2ce4bb193 100755 --- a/indra/llcommon/lleventcoro.h +++ b/indra/llcommon/lleventcoro.h @@ -72,13 +72,16 @@ private: boost::optional mPump; }; +namespace llcoro +{ + /// This is an adapter for a signature like void LISTENER(const LLSD&), which /// isn't a valid LLEventPump listener: such listeners should return bool. template -class LLVoidListener +class VoidListener { public: - LLVoidListener(const LISTENER& listener): + VoidListener(const LISTENER& listener): mListener(listener) {} bool operator()(const LLSD& event) @@ -91,50 +94,19 @@ private: LISTENER mListener; }; -/// LLVoidListener helper function to infer the type of the LISTENER +/// VoidListener helper function to infer the type of the LISTENER template -LLVoidListener voidlistener(const LISTENER& listener) +VoidListener voidlistener(const LISTENER& listener) { - return LLVoidListener(listener); + return VoidListener(listener); } -namespace LLEventDetail -{ - /** - * waitForEventOn() permits a coroutine to temporarily listen on an - * LLEventPump any number of times. We don't really want to have to ask - * the caller to label each such call with a distinct string; the whole - * point of waitForEventOn() is to present a nice sequential interface to - * the underlying LLEventPump-with-named-listeners machinery. So we'll use - * LLEventPump::inventName() to generate a distinct name for each - * temporary listener. On the other hand, because a given coroutine might - * call waitForEventOn() any number of times, we don't really want to - * consume an arbitrary number of generated inventName()s: that namespace, - * though large, is nonetheless finite. So we memoize an invented name for - * each distinct coroutine instance. - */ - std::string listenerNameForCoro(); - - /** - * Implement behavior described for postAndWait()'s @a replyPumpNamePath - * parameter: - * - * * If path.isUndefined(), do nothing. - * * If path.isString(), @a dest is an LLSD map: store @a value - * into dest[path.asString()]. - * * If path.isInteger(), @a dest is an LLSD array: store @a - * value into dest[path.asInteger()]. - * * If path.isArray(), iteratively apply the rules above to step - * down through the structure of @a dest. The last array entry in @a - * path specifies the entry in the lowest-level structure in @a dest - * into which to store @a value. - * - * @note - * In the degenerate case in which @a path is an empty array, @a dest will - * @em become @a value rather than @em containing it. - */ - LL_COMMON_API void storeToLLSDPath(LLSD& dest, const LLSD& path, const LLSD& value); -} // namespace LLEventDetail +/** + * Yield control from a coroutine for one "mainloop" tick. If your coroutine + * runs without suspending for nontrivial time, sprinkle in calls to this + * function to avoid stalling the rest of the viewer processing. + */ +void yield(); /** * Post specified LLSD event on the specified LLEventPump, then wait for a @@ -196,50 +168,13 @@ LLSD waitForEventOn(const LLEventPumpOrPumpName& pump) return postAndWait(LLSD(), LLEventPumpOrPumpName(), pump); } +} // namespace llcoro + /// return type for two-pump variant of waitForEventOn() typedef std::pair LLEventWithID; -namespace LLEventDetail +namespace llcoro { - /** - * This helper is specifically for the two-pump version of waitForEventOn(). - * We use a single future object, but we want to listen on two pumps with it. - * Since we must still adapt from (the callable constructed by) - * boost::dcoroutines::make_callback() (void return) to provide an event - * listener (bool return), we've adapted LLVoidListener for the purpose. The - * basic idea is that we construct a distinct instance of WaitForEventOnHelper - * -- binding different instance data -- for each of the pumps. Then, when a - * pump delivers an LLSD value to either WaitForEventOnHelper, it can combine - * that LLSD with its discriminator to feed the future object. - */ - template - class WaitForEventOnHelper - { - public: - WaitForEventOnHelper(const LISTENER& listener, int discriminator): - mListener(listener), - mDiscrim(discriminator) - {} - // this signature is required for an LLEventPump listener - bool operator()(const LLSD& event) - { - // our future object is defined to accept LLEventWithID - mListener(LLEventWithID(event, mDiscrim)); - // don't swallow the event, let other listeners see it - return false; - } - private: - LISTENER mListener; - const int mDiscrim; - }; - - /// WaitForEventOnHelper type-inference helper - template - WaitForEventOnHelper wfeoh(const LISTENER& listener, int discriminator) - { - return WaitForEventOnHelper(listener, discriminator); - } -} // namespace LLEventDetail /** * This function waits for a reply on either of two specified LLEventPumps. @@ -308,6 +243,8 @@ waitForEventOn(const LLEventPumpOrPumpName& pump0, const LLEventPumpOrPumpName& */ LLSD errorException(const LLEventWithID& result, const std::string& desc); +} // namespace llcoro + /** * Exception thrown by errorException(). We don't call this LLEventError * because it's not an error in event processing: rather, this exception @@ -328,12 +265,17 @@ private: LLSD mData; }; +namespace llcoro +{ + /** * Like errorException(), save that this trips a fatal error using LL_ERRS * rather than throwing an exception. */ LL_COMMON_API LLSD errorLog(const LLEventWithID& result, const std::string& desc); +} // namespace llcoro + /** * Certain event APIs require the name of an LLEventPump on which they should * post results. While it works to invent a distinct name and let @@ -365,13 +307,13 @@ public: */ LLSD wait() { - return ::waitForEventOn(mPump); + return llcoro::waitForEventOn(mPump); } LLSD postAndWait(const LLSD& event, const LLEventPumpOrPumpName& requestPump, const LLSD& replyPumpNamePath=LLSD()) { - return ::postAndWait(event, requestPump, mPump, replyPumpNamePath); + return llcoro::postAndWait(event, requestPump, mPump, replyPumpNamePath); } private: @@ -410,19 +352,19 @@ public: /// waitForEventOn(either of our two LLEventPumps) LLEventWithID wait() { - return waitForEventOn(mPump0, mPump1); + return llcoro::waitForEventOn(mPump0, mPump1); } /// errorException(wait()) LLSD waitWithException() { - return errorException(wait(), std::string("Error event on ") + getName1()); + return llcoro::errorException(wait(), std::string("Error event on ") + getName1()); } /// errorLog(wait()) LLSD waitWithLog() { - return errorLog(wait(), std::string("Error event on ") + getName1()); + return llcoro::errorLog(wait(), std::string("Error event on ") + getName1()); } LLEventWithID postAndWait(const LLSD& event, @@ -430,8 +372,8 @@ public: const LLSD& replyPump0NamePath=LLSD(), const LLSD& replyPump1NamePath=LLSD()) { - return postAndWait2(event, requestPump, mPump0, mPump1, - replyPump0NamePath, replyPump1NamePath); + return llcoro::postAndWait2(event, requestPump, mPump0, mPump1, + replyPump0NamePath, replyPump1NamePath); } LLSD postAndWaitWithException(const LLSD& event, @@ -439,9 +381,9 @@ public: const LLSD& replyPump0NamePath=LLSD(), const LLSD& replyPump1NamePath=LLSD()) { - return errorException(postAndWait(event, requestPump, - replyPump0NamePath, replyPump1NamePath), - std::string("Error event on ") + getName1()); + return llcoro::errorException(postAndWait(event, requestPump, + replyPump0NamePath, replyPump1NamePath), + std::string("Error event on ") + getName1()); } LLSD postAndWaitWithLog(const LLSD& event, @@ -449,9 +391,9 @@ public: const LLSD& replyPump0NamePath=LLSD(), const LLSD& replyPump1NamePath=LLSD()) { - return errorLog(postAndWait(event, requestPump, - replyPump0NamePath, replyPump1NamePath), - std::string("Error event on ") + getName1()); + return llcoro::errorLog(postAndWait(event, requestPump, + replyPump0NamePath, replyPump1NamePath), + std::string("Error event on ") + getName1()); } private: diff --git a/indra/llcommon/tests/lleventcoro_test.cpp b/indra/llcommon/tests/lleventcoro_test.cpp index da927038ab..79bcfe58ed 100755 --- a/indra/llcommon/tests/lleventcoro_test.cpp +++ b/indra/llcommon/tests/lleventcoro_test.cpp @@ -86,6 +86,8 @@ #include "lleventcoro.h" #include "../test/debug.h" +using namespace llcoro; + /***************************************************************************** * from the banana.cpp example program borrowed for test<1>() *****************************************************************************/ @@ -259,8 +261,7 @@ namespace tut // Construct the coroutine instance that will run explicit_wait. // Pass the ctor a callable that accepts the coroutine_type::self // param passed by the library. - boost::dcoroutines::coroutine - coro(explicit_wait); + boost::dcoroutines::coroutine coro(explicit_wait); // Start the coroutine coro(std::nothrow); // When the coroutine waits for the event pump, it returns here. diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index ac1c2f8e58..cd3c527241 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -596,7 +596,7 @@ LLSD HttpCoroutineAdapter::postAndYield_(LLCore::HttpRequest::ptr_t &request, } saveState(hhandle, request, handler); - LLSD results = waitForEventOn(handler->getReplyPump()); + LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); cleanState(); return results; @@ -697,7 +697,7 @@ LLSD HttpCoroutineAdapter::postAndYield_(LLCore::HttpRequest::ptr_t &request, } saveState(hhandle, request, handler); - LLSD results = waitForEventOn(handler->getReplyPump()); + LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; @@ -735,7 +735,7 @@ LLSD HttpCoroutineAdapter::putAndYield_(LLCore::HttpRequest::ptr_t &request, } saveState(hhandle, request, handler); - LLSD results = waitForEventOn(handler->getReplyPump()); + LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; @@ -790,7 +790,7 @@ LLSD HttpCoroutineAdapter::getAndYield_(LLCore::HttpRequest::ptr_t &request, } saveState(hhandle, request, handler); - LLSD results = waitForEventOn(handler->getReplyPump()); + LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; @@ -825,7 +825,7 @@ LLSD HttpCoroutineAdapter::deleteAndYield_(LLCore::HttpRequest::ptr_t &request, } saveState(hhandle, request, handler); - LLSD results = waitForEventOn(handler->getReplyPump()); + LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; diff --git a/indra/newview/llcoproceduremanager.cpp b/indra/newview/llcoproceduremanager.cpp index 1a4a906f35..d3168985f8 100644 --- a/indra/newview/llcoproceduremanager.cpp +++ b/indra/newview/llcoproceduremanager.cpp @@ -138,7 +138,7 @@ void LLCoprocedureManager::coprocedureInvokerCoro(LLCoreHttpUtil::HttpCoroutineA while (!mShutdown) { - waitForEventOn(mWakeupTrigger); + llcoro::waitForEventOn(mWakeupTrigger); if (mShutdown) break; diff --git a/indra/newview/lleventpoll.cpp b/indra/newview/lleventpoll.cpp index 54da226209..0aad1d5ba9 100755 --- a/indra/newview/lleventpoll.cpp +++ b/indra/newview/lleventpoll.cpp @@ -197,7 +197,7 @@ namespace Details " seconds, error count is now " << errorCount << LL_ENDL; timeout.eventAfter(waitToRetry, LLSD()); - waitForEventOn(timeout); + llcoro::waitForEventOn(timeout); if (mDone) break; diff --git a/indra/viewer_components/login/lllogin.cpp b/indra/viewer_components/login/lllogin.cpp index 0569e9f3e8..88415ff11a 100755 --- a/indra/viewer_components/login/lllogin.cpp +++ b/indra/viewer_components/login/lllogin.cpp @@ -175,7 +175,7 @@ void LLLogin::Impl::login_(std::string uri, LLSD login_params) request["op"] = "rewriteURI"; request["uri"] = uri; request["reply"] = replyPump.getName(); - rewrittenURIs = postAndWait(request, srv_pump_name, filter); + rewrittenURIs = llcoro::postAndWait(request, srv_pump_name, filter); // EXP-772: If rewrittenURIs fail, try original URI as a fallback. rewrittenURIs.append(uri); } // we no longer need the filter @@ -221,10 +221,10 @@ void LLLogin::Impl::login_(std::string uri, LLSD login_params) // returns. Subsequent responses, of course, must be awaited // without posting again. for (mAuthResponse = validateResponse(loginReplyPump.getName(), - postAndWait(request, xmlrpcPump, loginReplyPump, "reply")); + llcoro::postAndWait(request, xmlrpcPump, loginReplyPump, "reply")); mAuthResponse["status"].asString() == "Downloading"; mAuthResponse = validateResponse(loginReplyPump.getName(), - waitForEventOn(loginReplyPump))) + llcoro::waitForEventOn(loginReplyPump))) { // Still Downloading -- send progress update. sendProgressEvent("offline", "downloading"); -- cgit v1.2.3 From efa9a0f99c17b2b937120bcad6e3d45944122ed9 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Fri, 10 Jul 2015 19:30:10 -0400 Subject: Backed out changeset bab1000e1b2d: restore 'selfless' changes --- indra/llcommon/llcoros.cpp | 86 ++- indra/llcommon/llcoros.h | 67 +- indra/llcommon/lleventcoro.cpp | 113 +++- indra/llcommon/lleventcoro.h | 176 +---- indra/llcommon/tests/lleventcoro_test.cpp | 712 ++++++++++----------- indra/llmessage/CMakeLists.txt | 2 +- indra/llmessage/llavatarnamecache.cpp | 12 +- indra/llmessage/llcorehttputil.cpp | 72 +-- indra/llmessage/llcorehttputil.h | 66 +- indra/newview/llaccountingcostmanager.cpp | 8 +- indra/newview/llaccountingcostmanager.h | 2 +- indra/newview/llavatarrenderinfoaccountant.cpp | 12 +- indra/newview/llavatarrenderinfoaccountant.h | 4 +- indra/newview/llcoproceduremanager.cpp | 8 +- indra/newview/llcoproceduremanager.h | 4 +- indra/newview/llestateinfomodel.cpp | 6 +- indra/newview/llestateinfomodel.h | 2 +- indra/newview/lleventpoll.cpp | 10 +- indra/newview/llfacebookconnect.cpp | 46 +- indra/newview/llfacebookconnect.h | 14 +- indra/newview/llfeaturemanager.cpp | 6 +- indra/newview/llfeaturemanager.h | 2 +- indra/newview/llflickrconnect.cpp | 36 +- indra/newview/llflickrconnect.h | 12 +- indra/newview/llfloateravatarpicker.cpp | 6 +- indra/newview/llfloateravatarpicker.h | 2 +- indra/newview/llfloatermodeluploadbase.cpp | 6 +- indra/newview/llfloatermodeluploadbase.h | 2 +- indra/newview/llfloaterperms.cpp | 6 +- indra/newview/llfloaterperms.h | 2 +- indra/newview/llfloaterscriptlimits.cpp | 24 +- indra/newview/llfloaterscriptlimits.h | 8 +- indra/newview/llfloatertos.cpp | 6 +- indra/newview/llfloatertos.h | 2 +- indra/newview/llfloaterurlentry.cpp | 6 +- indra/newview/llfloaterurlentry.h | 2 +- indra/newview/llgroupmgr.cpp | 20 +- indra/newview/llgroupmgr.h | 6 +- indra/newview/llimview.cpp | 20 +- indra/newview/llinventorymodel.cpp | 6 +- indra/newview/llinventorymodel.h | 2 +- indra/newview/llmarketplacefunctions.cpp | 14 +- indra/newview/llpathfindingmanager.cpp | 46 +- indra/newview/llpathfindingmanager.h | 12 +- indra/newview/llproductinforequest.cpp | 6 +- indra/newview/llproductinforequest.h | 2 +- indra/newview/llremoteparcelrequest.cpp | 6 +- indra/newview/llremoteparcelrequest.h | 2 +- indra/newview/llspeakers.cpp | 10 +- indra/newview/llspeakers.h | 2 +- indra/newview/llsyntaxid.cpp | 6 +- indra/newview/llsyntaxid.h | 2 +- indra/newview/lltwitterconnect.cpp | 38 +- indra/newview/lltwitterconnect.h | 12 +- indra/newview/llviewerassetupload.cpp | 6 +- indra/newview/llviewerassetupload.h | 2 +- indra/newview/llviewermedia.cpp | 18 +- indra/newview/llviewermedia.h | 6 +- indra/newview/llviewermenufile.cpp | 2 +- indra/newview/llviewerobjectlist.cpp | 12 +- indra/newview/llviewerobjectlist.h | 4 +- indra/newview/llviewerregion.cpp | 24 +- indra/newview/llvoavatarself.cpp | 6 +- indra/newview/llvoavatarself.h | 2 +- indra/newview/llvoicechannel.cpp | 6 +- indra/newview/llvoicechannel.h | 2 +- indra/newview/llvoicevivox.cpp | 12 +- indra/newview/llvoicevivox.h | 4 +- indra/newview/llwebprofile.cpp | 10 +- indra/newview/llwebprofile.h | 2 +- indra/newview/llwlhandlers.cpp | 12 +- indra/newview/llwlhandlers.h | 4 +- indra/viewer_components/login/lllogin.cpp | 17 +- .../viewer_components/updater/llupdatechecker.cpp | 6 +- indra/viewer_components/updater/llupdatechecker.h | 2 +- 75 files changed, 974 insertions(+), 947 deletions(-) (limited to 'indra') diff --git a/indra/llcommon/llcoros.cpp b/indra/llcommon/llcoros.cpp index baaddcaed1..2d0c419ae0 100755 --- a/indra/llcommon/llcoros.cpp +++ b/indra/llcommon/llcoros.cpp @@ -34,11 +34,65 @@ // std headers // external library headers #include +#include // other Linden headers #include "llevents.h" #include "llerror.h" #include "stringize.h" +namespace { + +// do nothing, when we need nothing done +void no_cleanup(LLCoros::coro::self*) {} + +// When the dcoroutine library calls a top-level callable, it implicitly +// passes coro::self& as the first parameter. All our consumer code used to +// explicitly pass coro::self& down through all levels of call stack, because +// at the leaf level we need it for context-switching. But since coroutines +// are based on cooperative switching, we can cause the top-level entry point +// to stash a static pointer to the currently-running coroutine, and manage it +// appropriately as we switch out and back in. That eliminates the need to +// pass it as an explicit parameter down through every level, which is +// unfortunately viral in nature. Finding it implicitly rather than explicitly +// allows minor maintenance in which a leaf-level function adds a new async +// I/O call that suspends the calling coroutine, WITHOUT having to propagate +// coro::self& through every function signature down to that point -- and of +// course through every other caller of every such function. +// We use a boost::thread_specific_ptr because each thread potentially has its +// own distinct pool of coroutines. +// This thread_specific_ptr does NOT own the 'self' object! It merely +// identifies it. For this reason we instantiate it with a no-op cleanup +// function. +static boost::thread_specific_ptr +sCurrentSelf(no_cleanup); + +} // anonymous + +//static +LLCoros::coro::self& LLCoros::get_self() +{ + coro::self* current_self = sCurrentSelf.get(); + if (! current_self) + { + LL_ERRS("LLCoros") << "Calling get_self() from non-coroutine context!" << LL_ENDL; + } + return *current_self; +} + +LLCoros::Suspending::Suspending(): + mSuspended(sCurrentSelf.get()) +{ + // For the duration of our time away from this coroutine, sCurrentSelf + // must NOT refer to this coroutine. + sCurrentSelf.reset(); +} + +LLCoros::Suspending::~Suspending() +{ + // Okay, we're back, reinstate previous value of sCurrentSelf. + sCurrentSelf.reset(mSuspended); +} + LLCoros::LLCoros(): // MAINT-2724: default coroutine stack size too small on Windows. // Previously we used @@ -60,7 +114,7 @@ bool LLCoros::cleanup(const LLSD&) // since last tick? if (mi->second->exited()) { - LL_INFOS("LLCoros") << "LLCoros: cleaning up coroutine " << mi->first << LL_ENDL; + LL_INFOS("LLCoros") << "LLCoros: cleaning up coroutine " << mi->first << LL_ENDL; // The erase() call will invalidate its passed iterator value -- // so increment mi FIRST -- but pass its original value to // erase(). This is what postincrement is all about. @@ -94,7 +148,7 @@ std::string LLCoros::generateDistinctName(const std::string& prefix) const { if (mCoros.find(name) == mCoros.end()) { - LL_INFOS("LLCoros") << "LLCoros: launching coroutine " << name << LL_ENDL; + LL_INFOS("LLCoros") << "LLCoros: launching coroutine " << name << LL_ENDL; return name; } } @@ -114,10 +168,10 @@ bool LLCoros::kill(const std::string& name) return true; } -std::string LLCoros::getNameByID(const void* self_id) const +std::string LLCoros::getName() const { - // Walk the existing coroutines, looking for one from which the 'self_id' - // passed to us comes. + // Walk the existing coroutines, looking for the current one. + void* self_id = get_self().get_id(); for (CoroMap::const_iterator mi(mCoros.begin()), mend(mCoros.end()); mi != mend; ++mi) { namespace coro_private = boost::dcoroutines::detail; @@ -136,10 +190,24 @@ void LLCoros::setStackSize(S32 stacksize) mStackSize = stacksize; } +namespace { + +// Top-level wrapper around caller's coroutine callable. This function accepts +// the coroutine library's implicit coro::self& parameter and sets sCurrentSelf +// but does not pass it down to the caller's callable. +void toplevel(LLCoros::coro::self& self, const LLCoros::callable_t& callable) +{ + sCurrentSelf.reset(&self); + callable(); + sCurrentSelf.reset(); +} + +} // anonymous + /***************************************************************************** * MUST BE LAST *****************************************************************************/ -// Turn off MSVC optimizations for just LLCoros::launchImpl() -- see +// Turn off MSVC optimizations for just LLCoros::launch() -- see // DEV-32777. But MSVC doesn't support push/pop for optimization flags as it // does for warning suppression, and we really don't want to force // optimization ON for other code even in Debug or RelWithDebInfo builds. @@ -150,9 +218,13 @@ void LLCoros::setStackSize(S32 stacksize) #pragma optimize("", off) #endif // LL_MSVC -std::string LLCoros::launchImpl(const std::string& prefix, coro* newCoro) +std::string LLCoros::launch(const std::string& prefix, const callable_t& callable) { std::string name(generateDistinctName(prefix)); + // Wrap the caller's callable in our toplevel() function so we can manage + // sCurrentSelf appropriately at startup and shutdown of each coroutine. + coro* newCoro = new coro(boost::bind(toplevel, _1, callable), mStackSize); + // Store it in our pointer map mCoros.insert(name, newCoro); /* Run the coroutine until its first wait, then return here */ (*newCoro)(std::nothrow); diff --git a/indra/llcommon/llcoros.h b/indra/llcommon/llcoros.h index 01ee11da1a..3f58a17aa9 100755 --- a/indra/llcommon/llcoros.h +++ b/indra/llcommon/llcoros.h @@ -32,10 +32,8 @@ #include #include "llsingleton.h" #include +#include #include -#include -#include -#include #include /** @@ -80,8 +78,8 @@ class LL_COMMON_API LLCoros: public LLSingleton public: /// Canonical boost::dcoroutines::coroutine signature we use typedef boost::dcoroutines::coroutine coro; - /// Canonical 'self' type - typedef coro::self self; + /// Canonical callable type + typedef boost::function callable_t; /** * Create and start running a new coroutine with specified name. The name @@ -94,39 +92,33 @@ public: * { * public: * ... - * // Do NOT NOT NOT accept reference params other than 'self'! + * // Do NOT NOT NOT accept reference params! * // Pass by value only! - * void myCoroutineMethod(LLCoros::self& self, std::string, LLSD); + * void myCoroutineMethod(std::string, LLSD); * ... * }; * ... * std::string name = LLCoros::instance().launch( - * "mycoro", boost::bind(&MyClass::myCoroutineMethod, this, _1, + * "mycoro", boost::bind(&MyClass::myCoroutineMethod, this, * "somestring", LLSD(17)); * @endcode * - * Your function/method must accept LLCoros::self& as its first parameter. - * It can accept any other parameters you want -- but ONLY BY VALUE! - * Other reference parameters are a BAD IDEA! You Have Been Warned. See + * Your function/method can accept any parameters you want -- but ONLY BY + * VALUE! Reference parameters are a BAD IDEA! You Have Been Warned. See * DEV-32777 comments for an explanation. * - * Pass a callable that accepts the single LLCoros::self& parameter. It - * may work to pass a free function whose only parameter is 'self'; for - * all other cases use boost::bind(). Of course, for a non-static class - * method, the first parameter must be the class instance. Use the - * placeholder _1 for the 'self' parameter. Any other parameters should be - * passed via the bind() expression. + * Pass a nullary callable. It works to directly pass a nullary free + * function (or static method); for all other cases use boost::bind(). Of + * course, for a non-static class method, the first parameter must be the + * class instance. Any other parameters should be passed via the bind() + * expression. * * launch() tweaks the suggested name so it won't collide with any * existing coroutine instance, creates the coroutine instance, registers * it with the tweaked name and runs it until its first wait. At that * point it returns the tweaked name. */ - template - std::string launch(const std::string& prefix, const CALLABLE& callable) - { - return launchImpl(prefix, new coro(callable, mStackSize)); - } + std::string launch(const std::string& prefix, const callable_t& callable); /** * Abort a running coroutine by name. Normally, when a coroutine either @@ -138,27 +130,34 @@ public: bool kill(const std::string& name); /** - * From within a coroutine, pass its @c self object to look up the - * (tweaked) name string by which this coroutine is registered. Returns - * the empty string if not found (e.g. if the coroutine was launched by - * hand rather than using LLCoros::launch()). + * From within a coroutine, look up the (tweaked) name string by which + * this coroutine is registered. Returns the empty string if not found + * (e.g. if the coroutine was launched by hand rather than using + * LLCoros::launch()). */ - template - std::string getName(const COROUTINE_SELF& self) const + std::string getName() const; + + /// get the current coro::self& for those who really really care + static coro::self& get_self(); + + /// Instantiate one of these in a block surrounding any leaf point when + /// control literally switches away from this coroutine. + class Suspending { - return getNameByID(self.get_id()); - } + public: + Suspending(); + ~Suspending(); - /// getName() by self.get_id() - std::string getNameByID(const void* self_id) const; + private: + coro::self* mSuspended; + }; /// for delayed initialization void setStackSize(S32 stacksize); private: - friend class LLSingleton; LLCoros(); - std::string launchImpl(const std::string& prefix, coro* newCoro); + friend class LLSingleton; std::string generateDistinctName(const std::string& prefix) const; bool cleanup(const LLSD&); diff --git a/indra/llcommon/lleventcoro.cpp b/indra/llcommon/lleventcoro.cpp index 81cc33fbba..be93e9c83b 100755 --- a/indra/llcommon/lleventcoro.cpp +++ b/indra/llcommon/lleventcoro.cpp @@ -34,33 +34,24 @@ #include // std headers // external library headers +#include +#include // other Linden headers #include "llsdserialize.h" #include "llerror.h" #include "llcoros.h" -std::string LLEventDetail::listenerNameForCoroImpl(const void* self_id) +std::string LLEventDetail::listenerNameForCoro() { - // First, if this coroutine was launched by LLCoros::launch(), find that name. - std::string name(LLCoros::instance().getNameByID(self_id)); + // If this coroutine was launched by LLCoros::launch(), find that name. + std::string name(LLCoros::instance().getName()); if (! name.empty()) { return name; } - // Apparently this coroutine wasn't launched by LLCoros::launch(). Check - // whether we have a memo for this self_id. - typedef std::map MapType; - static MapType memo; - MapType::const_iterator found = memo.find(self_id); - if (found != memo.end()) - { - // this coroutine instance has called us before, reuse same name - return found->second; - } // this is the first time we've been called for this coroutine instance name = LLEventPump::inventName("coro"); - memo[self_id] = name; - LL_INFOS("LLEventCoro") << "listenerNameForCoroImpl(" << self_id << "): inventing coro name '" + LL_INFOS("LLEventCoro") << "listenerNameForCoro(): inventing coro name '" << name << "'" << LL_ENDL; return name; } @@ -118,6 +109,98 @@ void LLEventDetail::storeToLLSDPath(LLSD& dest, const LLSD& rawPath, const LLSD& *pdest = value; } +LLSD postAndWait(const LLSD& event, const LLEventPumpOrPumpName& requestPump, + const LLEventPumpOrPumpName& replyPump, const LLSD& replyPumpNamePath) +{ + // declare the future + boost::dcoroutines::future future(LLCoros::get_self()); + // make a callback that will assign a value to the future, and listen on + // the specified LLEventPump with that callback + std::string listenerName(LLEventDetail::listenerNameForCoro()); + LLTempBoundListener connection( + replyPump.getPump().listen(listenerName, + voidlistener(boost::dcoroutines::make_callback(future)))); + // skip the "post" part if requestPump is default-constructed + if (requestPump) + { + // If replyPumpNamePath is non-empty, store the replyPump name in the + // request event. + LLSD modevent(event); + LLEventDetail::storeToLLSDPath(modevent, replyPumpNamePath, replyPump.getPump().getName()); + LL_DEBUGS("lleventcoro") << "postAndWait(): coroutine " << listenerName + << " posting to " << requestPump.getPump().getName() + << LL_ENDL; + + // *NOTE:Mani - Removed because modevent could contain user's hashed passwd. + // << ": " << modevent << LL_ENDL; + requestPump.getPump().post(modevent); + } + LL_DEBUGS("lleventcoro") << "postAndWait(): coroutine " << listenerName + << " about to wait on LLEventPump " << replyPump.getPump().getName() + << LL_ENDL; + // trying to dereference ("resolve") the future makes us wait for it + LLSD value; + { + // instantiate Suspending to manage the "current" coroutine + LLCoros::Suspending suspended; + value = *future; + } // destroy Suspending as soon as we're back + LL_DEBUGS("lleventcoro") << "postAndWait(): coroutine " << listenerName + << " resuming with " << value << LL_ENDL; + // returning should disconnect the connection + return value; +} + +LLEventWithID postAndWait2(const LLSD& event, + const LLEventPumpOrPumpName& requestPump, + const LLEventPumpOrPumpName& replyPump0, + const LLEventPumpOrPumpName& replyPump1, + const LLSD& replyPump0NamePath, + const LLSD& replyPump1NamePath) +{ + // declare the future + boost::dcoroutines::future future(LLCoros::get_self()); + // either callback will assign a value to this future; listen on + // each specified LLEventPump with a callback + std::string name(LLEventDetail::listenerNameForCoro()); + LLTempBoundListener connection0( + replyPump0.getPump().listen(name + "a", + LLEventDetail::wfeoh(boost::dcoroutines::make_callback(future), 0))); + LLTempBoundListener connection1( + replyPump1.getPump().listen(name + "b", + LLEventDetail::wfeoh(boost::dcoroutines::make_callback(future), 1))); + // skip the "post" part if requestPump is default-constructed + if (requestPump) + { + // If either replyPumpNamePath is non-empty, store the corresponding + // replyPump name in the request event. + LLSD modevent(event); + LLEventDetail::storeToLLSDPath(modevent, replyPump0NamePath, + replyPump0.getPump().getName()); + LLEventDetail::storeToLLSDPath(modevent, replyPump1NamePath, + replyPump1.getPump().getName()); + LL_DEBUGS("lleventcoro") << "postAndWait2(): coroutine " << name + << " posting to " << requestPump.getPump().getName() + << ": " << modevent << LL_ENDL; + requestPump.getPump().post(modevent); + } + LL_DEBUGS("lleventcoro") << "postAndWait2(): coroutine " << name + << " about to wait on LLEventPumps " << replyPump0.getPump().getName() + << ", " << replyPump1.getPump().getName() << LL_ENDL; + // trying to dereference ("resolve") the future makes us wait for it + LLEventWithID value; + { + // instantiate Suspending to manage "current" coroutine + LLCoros::Suspending suspended; + value = *future; + } // destroy Suspending as soon as we're back + LL_DEBUGS("lleventcoro") << "postAndWait(): coroutine " << name + << " resuming with (" << value.first << ", " << value.second << ")" + << LL_ENDL; + // returning should disconnect both connections + return value; +} + LLSD errorException(const LLEventWithID& result, const std::string& desc) { // If the result arrived on the error pump (pump 1), instead of diff --git a/indra/llcommon/lleventcoro.h b/indra/llcommon/lleventcoro.h index abbeeaa373..daf9360a2e 100755 --- a/indra/llcommon/lleventcoro.h +++ b/indra/llcommon/lleventcoro.h @@ -29,8 +29,6 @@ #if ! defined(LL_LLEVENTCORO_H) #define LL_LLEVENTCORO_H -#include -#include #include #include #include @@ -102,9 +100,6 @@ LLVoidListener voidlistener(const LISTENER& listener) namespace LLEventDetail { - /// Implementation for listenerNameForCoro(), see below - LL_COMMON_API std::string listenerNameForCoroImpl(const void* self_id); - /** * waitForEventOn() permits a coroutine to temporarily listen on an * LLEventPump any number of times. We don't really want to have to ask @@ -116,21 +111,9 @@ namespace LLEventDetail * call waitForEventOn() any number of times, we don't really want to * consume an arbitrary number of generated inventName()s: that namespace, * though large, is nonetheless finite. So we memoize an invented name for - * each distinct coroutine instance (each different 'self' object). We - * can't know the type of 'self', because it depends on the coroutine - * body's signature. So we cast its address to void*, looking for distinct - * pointer values. Yes, that means that an early coroutine could cache a - * value here, then be destroyed, only to be supplanted by a later - * coroutine (of the same or different type), and we'll end up - * "recognizing" the second one and reusing the listener name -- but - * that's okay, since it won't collide with any listener name used by the - * earlier coroutine since that earlier coroutine no longer exists. + * each distinct coroutine instance. */ - template - std::string listenerNameForCoro(COROUTINE_SELF& self) - { - return listenerNameForCoroImpl(self.get_id()); - } + std::string listenerNameForCoro(); /** * Implement behavior described for postAndWait()'s @a replyPumpNamePath @@ -159,7 +142,7 @@ namespace LLEventDetail * convenience: the difference between this function and the sequence * @code * requestPump.post(myEvent); - * LLSD reply = waitForEventOn(self, replyPump); + * LLSD reply = waitForEventOn(replyPump); * @endcode * is that the sequence above fails if the reply is posted immediately on * @a replyPump, that is, before requestPump.post() returns. In the @@ -201,51 +184,16 @@ namespace LLEventDetail * @a replyPumpNamePath specifies the entry in the lowest-level structure in * @a event into which to store replyPump.getName(). */ -template -LLSD postAndWait(SELF& self, const LLSD& event, const LLEventPumpOrPumpName& requestPump, - const LLEventPumpOrPumpName& replyPump, const LLSD& replyPumpNamePath=LLSD()) -{ - // declare the future - boost::dcoroutines::future future(self); - // make a callback that will assign a value to the future, and listen on - // the specified LLEventPump with that callback - std::string listenerName(LLEventDetail::listenerNameForCoro(self)); - LLTempBoundListener connection( - replyPump.getPump().listen(listenerName, - voidlistener(boost::dcoroutines::make_callback(future)))); - // skip the "post" part if requestPump is default-constructed - if (requestPump) - { - // If replyPumpNamePath is non-empty, store the replyPump name in the - // request event. - LLSD modevent(event); - LLEventDetail::storeToLLSDPath(modevent, replyPumpNamePath, replyPump.getPump().getName()); - LL_DEBUGS("lleventcoro") << "postAndWait(): coroutine " << listenerName - << " posting to " << requestPump.getPump().getName() - << LL_ENDL; - - // *NOTE:Mani - Removed because modevent could contain user's hashed passwd. - // << ": " << modevent << LL_ENDL; - requestPump.getPump().post(modevent); - } - LL_DEBUGS("lleventcoro") << "postAndWait(): coroutine " << listenerName - << " about to wait on LLEventPump " << replyPump.getPump().getName() - << LL_ENDL; - // trying to dereference ("resolve") the future makes us wait for it - LLSD value(*future); - LL_DEBUGS("lleventcoro") << "postAndWait(): coroutine " << listenerName - << " resuming with " << value << LL_ENDL; - // returning should disconnect the connection - return value; -} +LLSD postAndWait(const LLSD& event, const LLEventPumpOrPumpName& requestPump, + const LLEventPumpOrPumpName& replyPump, const LLSD& replyPumpNamePath=LLSD()); /// Wait for the next event on the specified LLEventPump. Pass either the /// LLEventPump& or its string name. -template -LLSD waitForEventOn(SELF& self, const LLEventPumpOrPumpName& pump) +inline +LLSD waitForEventOn(const LLEventPumpOrPumpName& pump) { // This is now a convenience wrapper for postAndWait(). - return postAndWait(self, LLSD(), LLEventPumpOrPumpName(), pump); + return postAndWait(LLSD(), LLEventPumpOrPumpName(), pump); } /// return type for two-pump variant of waitForEventOn() @@ -313,7 +261,7 @@ namespace LLEventDetail * I'd have preferred to overload the name postAndWait() for both signatures. * But consider the following ambiguous call: * @code - * postAndWait(self, LLSD(), requestPump, replyPump, "someString"); + * postAndWait(LLSD(), requestPump, replyPump, "someString"); * @endcode * "someString" could be converted to either LLSD (@a replyPumpNamePath for * the single-pump function) or LLEventOrPumpName (@a replyPump1 for two-pump @@ -322,69 +270,29 @@ namespace LLEventDetail * It seems less burdensome to write postAndWait2() than to write either * LLSD("someString") or LLEventOrPumpName("someString"). */ -template -LLEventWithID postAndWait2(SELF& self, const LLSD& event, +LLEventWithID postAndWait2(const LLSD& event, const LLEventPumpOrPumpName& requestPump, const LLEventPumpOrPumpName& replyPump0, const LLEventPumpOrPumpName& replyPump1, const LLSD& replyPump0NamePath=LLSD(), - const LLSD& replyPump1NamePath=LLSD()) -{ - // declare the future - boost::dcoroutines::future future(self); - // either callback will assign a value to this future; listen on - // each specified LLEventPump with a callback - std::string name(LLEventDetail::listenerNameForCoro(self)); - LLTempBoundListener connection0( - replyPump0.getPump().listen(name + "a", - LLEventDetail::wfeoh(boost::dcoroutines::make_callback(future), 0))); - LLTempBoundListener connection1( - replyPump1.getPump().listen(name + "b", - LLEventDetail::wfeoh(boost::dcoroutines::make_callback(future), 1))); - // skip the "post" part if requestPump is default-constructed - if (requestPump) - { - // If either replyPumpNamePath is non-empty, store the corresponding - // replyPump name in the request event. - LLSD modevent(event); - LLEventDetail::storeToLLSDPath(modevent, replyPump0NamePath, - replyPump0.getPump().getName()); - LLEventDetail::storeToLLSDPath(modevent, replyPump1NamePath, - replyPump1.getPump().getName()); - LL_DEBUGS("lleventcoro") << "postAndWait2(): coroutine " << name - << " posting to " << requestPump.getPump().getName() - << ": " << modevent << LL_ENDL; - requestPump.getPump().post(modevent); - } - LL_DEBUGS("lleventcoro") << "postAndWait2(): coroutine " << name - << " about to wait on LLEventPumps " << replyPump0.getPump().getName() - << ", " << replyPump1.getPump().getName() << LL_ENDL; - // trying to dereference ("resolve") the future makes us wait for it - LLEventWithID value(*future); - LL_DEBUGS("lleventcoro") << "postAndWait(): coroutine " << name - << " resuming with (" << value.first << ", " << value.second << ")" - << LL_ENDL; - // returning should disconnect both connections - return value; -} + const LLSD& replyPump1NamePath=LLSD()); /** * Wait for the next event on either of two specified LLEventPumps. */ -template +inline LLEventWithID -waitForEventOn(SELF& self, - const LLEventPumpOrPumpName& pump0, const LLEventPumpOrPumpName& pump1) +waitForEventOn(const LLEventPumpOrPumpName& pump0, const LLEventPumpOrPumpName& pump1) { // This is now a convenience wrapper for postAndWait2(). - return postAndWait2(self, LLSD(), LLEventPumpOrPumpName(), pump0, pump1); + return postAndWait2(LLSD(), LLEventPumpOrPumpName(), pump0, pump1); } /** * Helper for the two-pump variant of waitForEventOn(), e.g.: * * @code - * LLSD reply = errorException(waitForEventOn(self, replyPump, errorPump), + * LLSD reply = errorException(waitForEventOn(replyPump, errorPump), * "error response from login.cgi"); * @endcode * @@ -454,26 +362,16 @@ public: /** * Wait for an event on this LLEventPump. - * - * @note - * The other major usage pattern we considered was to bind @c self at - * LLCoroEventPump construction time, which would avoid passing the - * parameter to each wait() call. But if we were going to bind @c self as - * a class member, we'd need to specify a class template parameter - * indicating its type. The big advantage of passing it to the wait() call - * is that the type can be implicit. */ - template - LLSD wait(SELF& self) + LLSD wait() { - return waitForEventOn(self, mPump); + return ::waitForEventOn(mPump); } - template - LLSD postAndWait(SELF& self, const LLSD& event, const LLEventPumpOrPumpName& requestPump, + LLSD postAndWait(const LLSD& event, const LLEventPumpOrPumpName& requestPump, const LLSD& replyPumpNamePath=LLSD()) { - return ::postAndWait(self, event, requestPump, mPump, replyPumpNamePath); + return ::postAndWait(event, requestPump, mPump, replyPumpNamePath); } private: @@ -509,55 +407,49 @@ public: /// request pump 1 LLEventPump& getPump1() { return mPump1; } - /// waitForEventOn(self, either of our two LLEventPumps) - template - LLEventWithID wait(SELF& self) + /// waitForEventOn(either of our two LLEventPumps) + LLEventWithID wait() { - return waitForEventOn(self, mPump0, mPump1); + return waitForEventOn(mPump0, mPump1); } - /// errorException(wait(self)) - template - LLSD waitWithException(SELF& self) + /// errorException(wait()) + LLSD waitWithException() { - return errorException(wait(self), std::string("Error event on ") + getName1()); + return errorException(wait(), std::string("Error event on ") + getName1()); } - /// errorLog(wait(self)) - template - LLSD waitWithLog(SELF& self) + /// errorLog(wait()) + LLSD waitWithLog() { - return errorLog(wait(self), std::string("Error event on ") + getName1()); + return errorLog(wait(), std::string("Error event on ") + getName1()); } - template - LLEventWithID postAndWait(SELF& self, const LLSD& event, + LLEventWithID postAndWait(const LLSD& event, const LLEventPumpOrPumpName& requestPump, const LLSD& replyPump0NamePath=LLSD(), const LLSD& replyPump1NamePath=LLSD()) { - return postAndWait2(self, event, requestPump, mPump0, mPump1, + return postAndWait2(event, requestPump, mPump0, mPump1, replyPump0NamePath, replyPump1NamePath); } - template - LLSD postAndWaitWithException(SELF& self, const LLSD& event, + LLSD postAndWaitWithException(const LLSD& event, const LLEventPumpOrPumpName& requestPump, const LLSD& replyPump0NamePath=LLSD(), const LLSD& replyPump1NamePath=LLSD()) { - return errorException(postAndWait(self, event, requestPump, + return errorException(postAndWait(event, requestPump, replyPump0NamePath, replyPump1NamePath), std::string("Error event on ") + getName1()); } - template - LLSD postAndWaitWithLog(SELF& self, const LLSD& event, + LLSD postAndWaitWithLog(const LLSD& event, const LLEventPumpOrPumpName& requestPump, const LLSD& replyPump0NamePath=LLSD(), const LLSD& replyPump1NamePath=LLSD()) { - return errorLog(postAndWait(self, event, requestPump, + return errorLog(postAndWait(event, requestPump, replyPump0NamePath, replyPump1NamePath), std::string("Error event on ") + getName1()); } diff --git a/indra/llcommon/tests/lleventcoro_test.cpp b/indra/llcommon/tests/lleventcoro_test.cpp index 2096807e53..da927038ab 100755 --- a/indra/llcommon/tests/lleventcoro_test.cpp +++ b/indra/llcommon/tests/lleventcoro_test.cpp @@ -82,6 +82,7 @@ #include "llevents.h" #include "tests/wrapllerrs.h" #include "stringize.h" +#include "llcoros.h" #include "lleventcoro.h" #include "../test/debug.h" @@ -121,9 +122,6 @@ typedef coroutine match_coroutine_type; /***************************************************************************** * Test helpers *****************************************************************************/ -// I suspect this will be typical of coroutines used in Linden software -typedef boost::dcoroutines::coroutine coroutine_type; - /// Simulate an event API whose response is immediate: sent on receipt of the /// initial request, rather than after some delay. This is the case that /// distinguishes postAndWait() from calling post(), then calling @@ -162,306 +160,7 @@ private: *****************************************************************************/ namespace tut { - struct coroutine_data - { - // Define coroutine bodies as methods here so they can use ensure*() - - void explicit_wait(coroutine_type::self& self) - { - BEGIN - { - // ... do whatever preliminary stuff must happen ... - - // declare the future - boost::dcoroutines::future future(self); - // tell the future what to wait for - LLTempBoundListener connection( - LLEventPumps::instance().obtain("source").listen("coro", voidlistener(boost::dcoroutines::make_callback(future)))); - ensure("Not yet", ! future); - // attempting to dereference ("resolve") the future causes the calling - // coroutine to wait for it - debug("about to wait"); - result = *future; - ensure("Got it", future); - } - END - } - - void waitForEventOn1(coroutine_type::self& self) - { - BEGIN - { - result = waitForEventOn(self, "source"); - } - END - } - - void waitForEventOn2(coroutine_type::self& self) - { - BEGIN - { - LLEventWithID pair = waitForEventOn(self, "reply", "error"); - result = pair.first; - which = pair.second; - debug(STRINGIZE("result = " << result << ", which = " << which)); - } - END - } - - void postAndWait1(coroutine_type::self& self) - { - BEGIN - { - result = postAndWait(self, - LLSDMap("value", 17), // request event - immediateAPI.getPump(), // requestPump - "reply1", // replyPump - "reply"); // request["reply"] = name - } - END - } - - void postAndWait2(coroutine_type::self& self) - { - BEGIN - { - LLEventWithID pair = ::postAndWait2(self, - LLSDMap("value", 18), - immediateAPI.getPump(), - "reply2", - "error2", - "reply", - "error"); - result = pair.first; - which = pair.second; - debug(STRINGIZE("result = " << result << ", which = " << which)); - } - END - } - - void postAndWait2_1(coroutine_type::self& self) - { - BEGIN - { - LLEventWithID pair = ::postAndWait2(self, - LLSDMap("value", 18)("fail", LLSD()), - immediateAPI.getPump(), - "reply2", - "error2", - "reply", - "error"); - result = pair.first; - which = pair.second; - debug(STRINGIZE("result = " << result << ", which = " << which)); - } - END - } - - void coroPump(coroutine_type::self& self) - { - BEGIN - { - LLCoroEventPump waiter; - replyName = waiter.getName(); - result = waiter.wait(self); - } - END - } - - void coroPumpPost(coroutine_type::self& self) - { - BEGIN - { - LLCoroEventPump waiter; - result = waiter.postAndWait(self, LLSDMap("value", 17), - immediateAPI.getPump(), "reply"); - } - END - } - - void coroPumps(coroutine_type::self& self) - { - BEGIN - { - LLCoroEventPumps waiter; - replyName = waiter.getName0(); - errorName = waiter.getName1(); - LLEventWithID pair(waiter.wait(self)); - result = pair.first; - which = pair.second; - } - END - } - - void coroPumpsNoEx(coroutine_type::self& self) - { - BEGIN - { - LLCoroEventPumps waiter; - replyName = waiter.getName0(); - errorName = waiter.getName1(); - result = waiter.waitWithException(self); - } - END - } - - void coroPumpsEx(coroutine_type::self& self) - { - BEGIN - { - LLCoroEventPumps waiter; - replyName = waiter.getName0(); - errorName = waiter.getName1(); - try - { - result = waiter.waitWithException(self); - debug("no exception"); - } - catch (const LLErrorEvent& e) - { - debug(STRINGIZE("exception " << e.what())); - errordata = e.getData(); - } - } - END - } - - void coroPumpsNoLog(coroutine_type::self& self) - { - BEGIN - { - LLCoroEventPumps waiter; - replyName = waiter.getName0(); - errorName = waiter.getName1(); - result = waiter.waitWithLog(self); - } - END - } - - void coroPumpsLog(coroutine_type::self& self) - { - BEGIN - { - LLCoroEventPumps waiter; - replyName = waiter.getName0(); - errorName = waiter.getName1(); - WrapLLErrs capture; - try - { - result = waiter.waitWithLog(self); - debug("no exception"); - } - catch (const WrapLLErrs::FatalException& e) - { - debug(STRINGIZE("exception " << e.what())); - threw = e.what(); - } - } - END - } - - void coroPumpsPost(coroutine_type::self& self) - { - BEGIN - { - LLCoroEventPumps waiter; - LLEventWithID pair(waiter.postAndWait(self, LLSDMap("value", 23), - immediateAPI.getPump(), "reply", "error")); - result = pair.first; - which = pair.second; - } - END - } - - void coroPumpsPost_1(coroutine_type::self& self) - { - BEGIN - { - LLCoroEventPumps waiter; - LLEventWithID pair( - waiter.postAndWait(self, LLSDMap("value", 23)("fail", LLSD()), - immediateAPI.getPump(), "reply", "error")); - result = pair.first; - which = pair.second; - } - END - } - - void coroPumpsPostNoEx(coroutine_type::self& self) - { - BEGIN - { - LLCoroEventPumps waiter; - result = waiter.postAndWaitWithException(self, LLSDMap("value", 8), - immediateAPI.getPump(), "reply", "error"); - } - END - } - - void coroPumpsPostEx(coroutine_type::self& self) - { - BEGIN - { - LLCoroEventPumps waiter; - try - { - result = waiter.postAndWaitWithException(self, - LLSDMap("value", 9)("fail", LLSD()), - immediateAPI.getPump(), "reply", "error"); - debug("no exception"); - } - catch (const LLErrorEvent& e) - { - debug(STRINGIZE("exception " << e.what())); - errordata = e.getData(); - } - } - END - } - - void coroPumpsPostNoLog(coroutine_type::self& self) - { - BEGIN - { - LLCoroEventPumps waiter; - result = waiter.postAndWaitWithLog(self, LLSDMap("value", 30), - immediateAPI.getPump(), "reply", "error"); - } - END - } - - void coroPumpsPostLog(coroutine_type::self& self) - { - BEGIN - { - LLCoroEventPumps waiter; - WrapLLErrs capture; - try - { - result = waiter.postAndWaitWithLog(self, - LLSDMap("value", 31)("fail", LLSD()), - immediateAPI.getPump(), "reply", "error"); - debug("no exception"); - } - catch (const WrapLLErrs::FatalException& e) - { - debug(STRINGIZE("exception " << e.what())); - threw = e.what(); - } - } - END - } - - void ensure_done(coroutine_type& coro) - { - ensure("coroutine complete", ! coro); - } - - ImmediateAPI immediateAPI; - std::string replyName, errorName, threw; - LLSD result, errordata; - int which; - }; + struct coroutine_data {}; typedef test_group coroutine_group; typedef coroutine_group::object object; coroutine_group coroutinegrp("coroutine"); @@ -511,16 +210,57 @@ namespace tut ensure("done", ! matcher); } + // use static data so we can intersperse coroutine functions with the + // tests that engage them + ImmediateAPI immediateAPI; + std::string replyName, errorName, threw; + LLSD result, errordata; + int which; + + // reinit vars at the start of each test + void clear() + { + replyName.clear(); + errorName.clear(); + threw.clear(); + result = LLSD(); + errordata = LLSD(); + which = 0; + } + + void explicit_wait(boost::dcoroutines::coroutine::self& self) + { + BEGIN + { + // ... do whatever preliminary stuff must happen ... + + // declare the future + boost::dcoroutines::future future(self); + // tell the future what to wait for + LLTempBoundListener connection( + LLEventPumps::instance().obtain("source").listen("coro", voidlistener(boost::dcoroutines::make_callback(future)))); + ensure("Not yet", ! future); + // attempting to dereference ("resolve") the future causes the calling + // coroutine to wait for it + debug("about to wait"); + result = *future; + ensure("Got it", future); + } + END + } + template<> template<> void object::test<2>() { + clear(); set_test_name("explicit_wait"); DEBUG; // Construct the coroutine instance that will run explicit_wait. // Pass the ctor a callable that accepts the coroutine_type::self // param passed by the library. - coroutine_type coro(boost::bind(&coroutine_data::explicit_wait, this, _1)); + boost::dcoroutines::coroutine + coro(explicit_wait); // Start the coroutine coro(std::nothrow); // When the coroutine waits for the event pump, it returns here. @@ -528,37 +268,56 @@ namespace tut // Satisfy the wait. LLEventPumps::instance().obtain("source").post("received"); // Now wait for the coroutine to complete. - ensure_done(coro); + ensure("coroutine complete", ! coro); // ensure the coroutine ran and woke up again with the intended result ensure_equals(result.asString(), "received"); } + void waitForEventOn1() + { + BEGIN + { + result = waitForEventOn("source"); + } + END + } + template<> template<> void object::test<3>() { + clear(); set_test_name("waitForEventOn1"); DEBUG; - coroutine_type coro(boost::bind(&coroutine_data::waitForEventOn1, this, _1)); - coro(std::nothrow); + LLCoros::instance().launch("test<3>", waitForEventOn1); debug("about to send"); LLEventPumps::instance().obtain("source").post("received"); debug("back from send"); - ensure_done(coro); ensure_equals(result.asString(), "received"); } + void waitForEventOn2() + { + BEGIN + { + LLEventWithID pair = waitForEventOn("reply", "error"); + result = pair.first; + which = pair.second; + debug(STRINGIZE("result = " << result << ", which = " << which)); + } + END + } + template<> template<> void object::test<4>() { + clear(); set_test_name("waitForEventOn2 reply"); { DEBUG; - coroutine_type coro(boost::bind(&coroutine_data::waitForEventOn2, this, _1)); - coro(std::nothrow); + LLCoros::instance().launch("test<4>", waitForEventOn2); debug("about to send"); LLEventPumps::instance().obtain("reply").post("received"); debug("back from send"); - ensure_done(coro); } ensure_equals(result.asString(), "received"); ensure_equals("which pump", which, 0); @@ -567,43 +326,65 @@ namespace tut template<> template<> void object::test<5>() { + clear(); set_test_name("waitForEventOn2 error"); DEBUG; - coroutine_type coro(boost::bind(&coroutine_data::waitForEventOn2, this, _1)); - coro(std::nothrow); + LLCoros::instance().launch("test<5>", waitForEventOn2); debug("about to send"); LLEventPumps::instance().obtain("error").post("badness"); debug("back from send"); - ensure_done(coro); ensure_equals(result.asString(), "badness"); ensure_equals("which pump", which, 1); } + void coroPump() + { + BEGIN + { + LLCoroEventPump waiter; + replyName = waiter.getName(); + result = waiter.wait(); + } + END + } + template<> template<> void object::test<6>() { + clear(); set_test_name("coroPump"); DEBUG; - coroutine_type coro(boost::bind(&coroutine_data::coroPump, this, _1)); - coro(std::nothrow); + LLCoros::instance().launch("test<6>", coroPump); debug("about to send"); LLEventPumps::instance().obtain(replyName).post("received"); debug("back from send"); - ensure_done(coro); ensure_equals(result.asString(), "received"); } + void coroPumps() + { + BEGIN + { + LLCoroEventPumps waiter; + replyName = waiter.getName0(); + errorName = waiter.getName1(); + LLEventWithID pair(waiter.wait()); + result = pair.first; + which = pair.second; + } + END + } + template<> template<> void object::test<7>() { + clear(); set_test_name("coroPumps reply"); DEBUG; - coroutine_type coro(boost::bind(&coroutine_data::coroPumps, this, _1)); - coro(std::nothrow); + LLCoros::instance().launch("test<7>", coroPumps); debug("about to send"); LLEventPumps::instance().obtain(replyName).post("received"); debug("back from send"); - ensure_done(coro); ensure_equals(result.asString(), "received"); ensure_equals("which pump", which, 0); } @@ -611,188 +392,389 @@ namespace tut template<> template<> void object::test<8>() { + clear(); set_test_name("coroPumps error"); DEBUG; - coroutine_type coro(boost::bind(&coroutine_data::coroPumps, this, _1)); - coro(std::nothrow); + LLCoros::instance().launch("test<8>", coroPumps); debug("about to send"); LLEventPumps::instance().obtain(errorName).post("badness"); debug("back from send"); - ensure_done(coro); ensure_equals(result.asString(), "badness"); ensure_equals("which pump", which, 1); } + void coroPumpsNoEx() + { + BEGIN + { + LLCoroEventPumps waiter; + replyName = waiter.getName0(); + errorName = waiter.getName1(); + result = waiter.waitWithException(); + } + END + } + template<> template<> void object::test<9>() { + clear(); set_test_name("coroPumpsNoEx"); DEBUG; - coroutine_type coro(boost::bind(&coroutine_data::coroPumpsNoEx, this, _1)); - coro(std::nothrow); + LLCoros::instance().launch("test<9>", coroPumpsNoEx); debug("about to send"); LLEventPumps::instance().obtain(replyName).post("received"); debug("back from send"); - ensure_done(coro); ensure_equals(result.asString(), "received"); } + void coroPumpsEx() + { + BEGIN + { + LLCoroEventPumps waiter; + replyName = waiter.getName0(); + errorName = waiter.getName1(); + try + { + result = waiter.waitWithException(); + debug("no exception"); + } + catch (const LLErrorEvent& e) + { + debug(STRINGIZE("exception " << e.what())); + errordata = e.getData(); + } + } + END + } + template<> template<> void object::test<10>() { + clear(); set_test_name("coroPumpsEx"); DEBUG; - coroutine_type coro(boost::bind(&coroutine_data::coroPumpsEx, this, _1)); - coro(std::nothrow); + LLCoros::instance().launch("test<10>", coroPumpsEx); debug("about to send"); LLEventPumps::instance().obtain(errorName).post("badness"); debug("back from send"); - ensure_done(coro); ensure("no result", result.isUndefined()); ensure_equals("got error", errordata.asString(), "badness"); } + void coroPumpsNoLog() + { + BEGIN + { + LLCoroEventPumps waiter; + replyName = waiter.getName0(); + errorName = waiter.getName1(); + result = waiter.waitWithLog(); + } + END + } + template<> template<> void object::test<11>() { + clear(); set_test_name("coroPumpsNoLog"); DEBUG; - coroutine_type coro(boost::bind(&coroutine_data::coroPumpsNoLog, this, _1)); - coro(std::nothrow); + LLCoros::instance().launch("test<11>", coroPumpsNoLog); debug("about to send"); LLEventPumps::instance().obtain(replyName).post("received"); debug("back from send"); - ensure_done(coro); ensure_equals(result.asString(), "received"); } + void coroPumpsLog() + { + BEGIN + { + LLCoroEventPumps waiter; + replyName = waiter.getName0(); + errorName = waiter.getName1(); + WrapLLErrs capture; + try + { + result = waiter.waitWithLog(); + debug("no exception"); + } + catch (const WrapLLErrs::FatalException& e) + { + debug(STRINGIZE("exception " << e.what())); + threw = e.what(); + } + } + END + } + template<> template<> void object::test<12>() { + clear(); set_test_name("coroPumpsLog"); DEBUG; - coroutine_type coro(boost::bind(&coroutine_data::coroPumpsLog, this, _1)); - coro(std::nothrow); + LLCoros::instance().launch("test<12>", coroPumpsLog); debug("about to send"); LLEventPumps::instance().obtain(errorName).post("badness"); debug("back from send"); - ensure_done(coro); ensure("no result", result.isUndefined()); ensure_contains("got error", threw, "badness"); } + void postAndWait1() + { + BEGIN + { + result = postAndWait(LLSDMap("value", 17), // request event + immediateAPI.getPump(), // requestPump + "reply1", // replyPump + "reply"); // request["reply"] = name + } + END + } + template<> template<> void object::test<13>() { + clear(); set_test_name("postAndWait1"); DEBUG; - coroutine_type coro(boost::bind(&coroutine_data::postAndWait1, this, _1)); - coro(std::nothrow); - ensure_done(coro); + LLCoros::instance().launch("test<13>", postAndWait1); ensure_equals(result.asInteger(), 18); } + void postAndWait2() + { + BEGIN + { + LLEventWithID pair = ::postAndWait2(LLSDMap("value", 18), + immediateAPI.getPump(), + "reply2", + "error2", + "reply", + "error"); + result = pair.first; + which = pair.second; + debug(STRINGIZE("result = " << result << ", which = " << which)); + } + END + } + template<> template<> void object::test<14>() { + clear(); set_test_name("postAndWait2"); DEBUG; - coroutine_type coro(boost::bind(&coroutine_data::postAndWait2, this, _1)); - coro(std::nothrow); - ensure_done(coro); + LLCoros::instance().launch("test<14>", postAndWait2); ensure_equals(result.asInteger(), 19); ensure_equals(which, 0); } + void postAndWait2_1() + { + BEGIN + { + LLEventWithID pair = ::postAndWait2(LLSDMap("value", 18)("fail", LLSD()), + immediateAPI.getPump(), + "reply2", + "error2", + "reply", + "error"); + result = pair.first; + which = pair.second; + debug(STRINGIZE("result = " << result << ", which = " << which)); + } + END + } + template<> template<> void object::test<15>() { + clear(); set_test_name("postAndWait2_1"); DEBUG; - coroutine_type coro(boost::bind(&coroutine_data::postAndWait2_1, this, _1)); - coro(std::nothrow); - ensure_done(coro); + LLCoros::instance().launch("test<15>", postAndWait2_1); ensure_equals(result.asInteger(), 19); ensure_equals(which, 1); } + void coroPumpPost() + { + BEGIN + { + LLCoroEventPump waiter; + result = waiter.postAndWait(LLSDMap("value", 17), + immediateAPI.getPump(), "reply"); + } + END + } + template<> template<> void object::test<16>() { + clear(); set_test_name("coroPumpPost"); DEBUG; - coroutine_type coro(boost::bind(&coroutine_data::coroPumpPost, this, _1)); - coro(std::nothrow); - ensure_done(coro); + LLCoros::instance().launch("test<16>", coroPumpPost); ensure_equals(result.asInteger(), 18); } + void coroPumpsPost() + { + BEGIN + { + LLCoroEventPumps waiter; + LLEventWithID pair(waiter.postAndWait(LLSDMap("value", 23), + immediateAPI.getPump(), "reply", "error")); + result = pair.first; + which = pair.second; + } + END + } + template<> template<> void object::test<17>() { + clear(); set_test_name("coroPumpsPost reply"); DEBUG; - coroutine_type coro(boost::bind(&coroutine_data::coroPumpsPost, this, _1)); - coro(std::nothrow); - ensure_done(coro); + LLCoros::instance().launch("test<17>", coroPumpsPost); ensure_equals(result.asInteger(), 24); ensure_equals("which pump", which, 0); } + void coroPumpsPost_1() + { + BEGIN + { + LLCoroEventPumps waiter; + LLEventWithID pair( + waiter.postAndWait(LLSDMap("value", 23)("fail", LLSD()), + immediateAPI.getPump(), "reply", "error")); + result = pair.first; + which = pair.second; + } + END + } + template<> template<> void object::test<18>() { + clear(); set_test_name("coroPumpsPost error"); DEBUG; - coroutine_type coro(boost::bind(&coroutine_data::coroPumpsPost_1, this, _1)); - coro(std::nothrow); - ensure_done(coro); + LLCoros::instance().launch("test<18>", coroPumpsPost_1); ensure_equals(result.asInteger(), 24); ensure_equals("which pump", which, 1); } + void coroPumpsPostNoEx() + { + BEGIN + { + LLCoroEventPumps waiter; + result = waiter.postAndWaitWithException(LLSDMap("value", 8), + immediateAPI.getPump(), "reply", "error"); + } + END + } + template<> template<> void object::test<19>() { + clear(); set_test_name("coroPumpsPostNoEx"); DEBUG; - coroutine_type coro(boost::bind(&coroutine_data::coroPumpsPostNoEx, this, _1)); - coro(std::nothrow); - ensure_done(coro); + LLCoros::instance().launch("test<19>", coroPumpsPostNoEx); ensure_equals(result.asInteger(), 9); } + void coroPumpsPostEx() + { + BEGIN + { + LLCoroEventPumps waiter; + try + { + result = waiter.postAndWaitWithException( + LLSDMap("value", 9)("fail", LLSD()), + immediateAPI.getPump(), "reply", "error"); + debug("no exception"); + } + catch (const LLErrorEvent& e) + { + debug(STRINGIZE("exception " << e.what())); + errordata = e.getData(); + } + } + END + } + template<> template<> void object::test<20>() { + clear(); set_test_name("coroPumpsPostEx"); DEBUG; - coroutine_type coro(boost::bind(&coroutine_data::coroPumpsPostEx, this, _1)); - coro(std::nothrow); - ensure_done(coro); + LLCoros::instance().launch("test<20>", coroPumpsPostEx); ensure("no result", result.isUndefined()); ensure_equals("got error", errordata.asInteger(), 10); } + void coroPumpsPostNoLog() + { + BEGIN + { + LLCoroEventPumps waiter; + result = waiter.postAndWaitWithLog(LLSDMap("value", 30), + immediateAPI.getPump(), "reply", "error"); + } + END + } + template<> template<> void object::test<21>() { + clear(); set_test_name("coroPumpsPostNoLog"); DEBUG; - coroutine_type coro(boost::bind(&coroutine_data::coroPumpsPostNoLog, this, _1)); - coro(std::nothrow); - ensure_done(coro); + LLCoros::instance().launch("test<21>", coroPumpsPostNoLog); ensure_equals(result.asInteger(), 31); } + void coroPumpsPostLog() + { + BEGIN + { + LLCoroEventPumps waiter; + WrapLLErrs capture; + try + { + result = waiter.postAndWaitWithLog( + LLSDMap("value", 31)("fail", LLSD()), + immediateAPI.getPump(), "reply", "error"); + debug("no exception"); + } + catch (const WrapLLErrs::FatalException& e) + { + debug(STRINGIZE("exception " << e.what())); + threw = e.what(); + } + } + END + } + template<> template<> void object::test<22>() { + clear(); set_test_name("coroPumpsPostLog"); DEBUG; - coroutine_type coro(boost::bind(&coroutine_data::coroPumpsPostLog, this, _1)); - coro(std::nothrow); - ensure_done(coro); + LLCoros::instance().launch("test<22>", coroPumpsPostLog); ensure("no result", result.isUndefined()); ensure_contains("got error", threw, "32"); } diff --git a/indra/llmessage/CMakeLists.txt b/indra/llmessage/CMakeLists.txt index 49f825d8f8..ba6e9d3939 100755 --- a/indra/llmessage/CMakeLists.txt +++ b/indra/llmessage/CMakeLists.txt @@ -256,8 +256,8 @@ if (LL_TESTS) ${LLMESSAGE_LIBRARIES} ${LLCOREHTTP_LIBRARIES} ${JSONCPP_LIBRARIES} - ${BOOST_CONTEXT_LIBRARY} ${BOOST_COROUTINE_LIBRARY} + ${BOOST_CONTEXT_LIBRARY} ${GOOGLEMOCK_LIBRARIES} ) diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index 7014048021..d262862c80 100755 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -137,8 +137,8 @@ namespace LLAvatarNameCache bool expirationFromCacheControl(const LLSD& headers, F64 *expires); - // This is a coroutine. The only parameter that can be specified as a reference is the self - void requestAvatarNameCache_(LLCoros::self& self, std::string url, std::vector agentIds); + // This is a coroutine. + void requestAvatarNameCache_(std::string url, std::vector agentIds); void handleAvNameCacheSuccess(const LLSD &data, const LLSD &httpResult); } @@ -185,9 +185,9 @@ namespace LLAvatarNameCache // Coroutine for sending and processing avatar name cache requests. // Do not call directly. See documentation in lleventcoro.h and llcoro.h for // further explanation. -void LLAvatarNameCache::requestAvatarNameCache_(LLCoros::self& self, std::string url, std::vector agentIds) +void LLAvatarNameCache::requestAvatarNameCache_(std::string url, std::vector agentIds) { - LL_DEBUGS("AvNameCache") << "Entering coroutine " << LLCoros::instance().getName(self) + LL_DEBUGS("AvNameCache") << "Entering coroutine " << LLCoros::instance().getName() << " with url '" << url << "', requesting " << agentIds.size() << " Agent Ids" << LL_ENDL; try @@ -195,7 +195,7 @@ void LLAvatarNameCache::requestAvatarNameCache_(LLCoros::self& self, std::string bool success = true; LLCoreHttpUtil::HttpCoroutineAdapter httpAdapter("NameCache", LLAvatarNameCache::sHttpPolicy); - LLSD results = httpAdapter.getAndYield(self, sHttpRequest, url); + LLSD results = httpAdapter.getAndYield(sHttpRequest, url); LLSD httpResults; LL_DEBUGS() << results << LL_ENDL; @@ -401,7 +401,7 @@ void LLAvatarNameCache::requestNamesViaCapability() std::string coroname = LLCoros::instance().launch("LLAvatarNameCache::requestAvatarNameCache_", - boost::bind(&LLAvatarNameCache::requestAvatarNameCache_, _1, url, agent_ids)); + boost::bind(&LLAvatarNameCache::requestAvatarNameCache_, url, agent_ids)); LL_DEBUGS("AvNameCache") << coroname << " with url '" << url << "', agent_ids.size()=" << agent_ids.size() << LL_ENDL; } diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index 4ec01aa405..ac1c2f8e58 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -565,17 +565,17 @@ HttpCoroutineAdapter::~HttpCoroutineAdapter() cancelYieldingOperation(); } -LLSD HttpCoroutineAdapter::postAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::postAndYield(LLCore::HttpRequest::ptr_t request, const std::string & url, const LLSD & body, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { LLEventStream replyPump(mAdapterName, true); HttpCoroHandler::ptr_t httpHandler = HttpCoroHandler::ptr_t(new HttpCoroLLSDHandler(replyPump)); - return postAndYield_(self, request, url, body, options, headers, httpHandler); + return postAndYield_(request, url, body, options, headers, httpHandler); } -LLSD HttpCoroutineAdapter::postAndYield_(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, +LLSD HttpCoroutineAdapter::postAndYield_(LLCore::HttpRequest::ptr_t &request, const std::string & url, const LLSD & body, LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler) @@ -596,35 +596,35 @@ LLSD HttpCoroutineAdapter::postAndYield_(LLCoros::self & self, LLCore::HttpReque } saveState(hhandle, request, handler); - LLSD results = waitForEventOn(self, handler->getReplyPump()); + LLSD results = waitForEventOn(handler->getReplyPump()); cleanState(); return results; } -LLSD HttpCoroutineAdapter::postAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::postAndYield(LLCore::HttpRequest::ptr_t request, const std::string & url, LLCore::BufferArray::ptr_t rawbody, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { LLEventStream replyPump(mAdapterName, true); HttpCoroHandler::ptr_t httpHandler = HttpCoroHandler::ptr_t(new HttpCoroLLSDHandler(replyPump)); - return postAndYield_(self, request, url, rawbody, options, headers, httpHandler); + return postAndYield_(request, url, rawbody, options, headers, httpHandler); } -LLSD HttpCoroutineAdapter::postRawAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::postRawAndYield(LLCore::HttpRequest::ptr_t request, const std::string & url, LLCore::BufferArray::ptr_t rawbody, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { LLEventStream replyPump(mAdapterName, true); HttpCoroHandler::ptr_t httpHandler = HttpCoroHandler::ptr_t(new HttpCoroRawHandler(replyPump)); - return postAndYield_(self, request, url, rawbody, options, headers, httpHandler); + return postAndYield_(request, url, rawbody, options, headers, httpHandler); } // *TODO: This functionality could be moved into the LLCore::Http library itself // by having the CURL layer read the file directly. -LLSD HttpCoroutineAdapter::postFileAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::postFileAndYield(LLCore::HttpRequest::ptr_t request, const std::string & url, std::string fileName, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { @@ -648,12 +648,12 @@ LLSD HttpCoroutineAdapter::postFileAndYield(LLCoros::self & self, LLCore::HttpRe } } - return postAndYield(self, request, url, fileData, options, headers); + return postAndYield(request, url, fileData, options, headers); } // *TODO: This functionality could be moved into the LLCore::Http library itself // by having the CURL layer read the file directly. -LLSD HttpCoroutineAdapter::postFileAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::postFileAndYield(LLCore::HttpRequest::ptr_t request, const std::string & url, LLUUID assetId, LLAssetType::EType assetType, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { @@ -673,11 +673,11 @@ LLSD HttpCoroutineAdapter::postFileAndYield(LLCoros::self & self, LLCore::HttpRe delete[] fileBuffer; } - return postAndYield(self, request, url, fileData, options, headers); + return postAndYield(request, url, fileData, options, headers); } -LLSD HttpCoroutineAdapter::postAndYield_(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, +LLSD HttpCoroutineAdapter::postAndYield_(LLCore::HttpRequest::ptr_t &request, const std::string & url, LLCore::BufferArray::ptr_t &rawbody, LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler) @@ -697,24 +697,24 @@ LLSD HttpCoroutineAdapter::postAndYield_(LLCoros::self & self, LLCore::HttpReque } saveState(hhandle, request, handler); - LLSD results = waitForEventOn(self, handler->getReplyPump()); + LLSD results = waitForEventOn(handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; } -LLSD HttpCoroutineAdapter::putAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::putAndYield(LLCore::HttpRequest::ptr_t request, const std::string & url, const LLSD & body, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { LLEventStream replyPump(mAdapterName + "Reply", true); HttpCoroHandler::ptr_t httpHandler = HttpCoroHandler::ptr_t(new HttpCoroLLSDHandler(replyPump)); - return putAndYield_(self, request, url, body, options, headers, httpHandler); + return putAndYield_(request, url, body, options, headers, httpHandler); } -LLSD HttpCoroutineAdapter::putAndYield_(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, +LLSD HttpCoroutineAdapter::putAndYield_(LLCore::HttpRequest::ptr_t &request, const std::string & url, const LLSD & body, LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler) @@ -735,43 +735,43 @@ LLSD HttpCoroutineAdapter::putAndYield_(LLCoros::self & self, LLCore::HttpReques } saveState(hhandle, request, handler); - LLSD results = waitForEventOn(self, handler->getReplyPump()); + LLSD results = waitForEventOn(handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; } -LLSD HttpCoroutineAdapter::getAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::getAndYield(LLCore::HttpRequest::ptr_t request, const std::string & url, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { LLEventStream replyPump(mAdapterName + "Reply", true); HttpCoroHandler::ptr_t httpHandler = HttpCoroHandler::ptr_t(new HttpCoroLLSDHandler(replyPump)); - return getAndYield_(self, request, url, options, headers, httpHandler); + return getAndYield_(request, url, options, headers, httpHandler); } -LLSD HttpCoroutineAdapter::getRawAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::getRawAndYield(LLCore::HttpRequest::ptr_t request, const std::string & url, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { LLEventStream replyPump(mAdapterName + "Reply", true); HttpCoroHandler::ptr_t httpHandler = HttpCoroHandler::ptr_t(new HttpCoroRawHandler(replyPump)); - return getAndYield_(self, request, url, options, headers, httpHandler); + return getAndYield_(request, url, options, headers, httpHandler); } -LLSD HttpCoroutineAdapter::getJsonAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::getJsonAndYield(LLCore::HttpRequest::ptr_t request, const std::string & url, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { LLEventStream replyPump(mAdapterName + "Reply", true); HttpCoroHandler::ptr_t httpHandler = HttpCoroHandler::ptr_t(new HttpCoroJSONHandler(replyPump)); - return getAndYield_(self, request, url, options, headers, httpHandler); + return getAndYield_(request, url, options, headers, httpHandler); } -LLSD HttpCoroutineAdapter::getAndYield_(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, +LLSD HttpCoroutineAdapter::getAndYield_(LLCore::HttpRequest::ptr_t &request, const std::string & url, LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler) @@ -790,24 +790,24 @@ LLSD HttpCoroutineAdapter::getAndYield_(LLCoros::self & self, LLCore::HttpReques } saveState(hhandle, request, handler); - LLSD results = waitForEventOn(self, handler->getReplyPump()); + LLSD results = waitForEventOn(handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; } -LLSD HttpCoroutineAdapter::deleteAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::deleteAndYield(LLCore::HttpRequest::ptr_t request, const std::string & url, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { LLEventStream replyPump(mAdapterName + "Reply", true); HttpCoroHandler::ptr_t httpHandler = HttpCoroHandler::ptr_t(new HttpCoroLLSDHandler(replyPump)); - return deleteAndYield_(self, request, url, options, headers, httpHandler); + return deleteAndYield_(request, url, options, headers, httpHandler); } -LLSD HttpCoroutineAdapter::deleteAndYield_(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, +LLSD HttpCoroutineAdapter::deleteAndYield_(LLCore::HttpRequest::ptr_t &request, const std::string & url, LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler) { @@ -825,7 +825,7 @@ LLSD HttpCoroutineAdapter::deleteAndYield_(LLCoros::self & self, LLCore::HttpReq } saveState(hhandle, request, handler); - LLSD results = waitForEventOn(self, handler->getReplyPump()); + LLSD results = waitForEventOn(handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; @@ -907,7 +907,7 @@ LLCore::HttpStatus HttpCoroutineAdapter::getStatusFromLLSD(const LLSD &httpResul void HttpCoroutineAdapter::callbackHttpGet(const std::string &url, LLCore::HttpRequest::policy_t policyId, completionCallback_t success, completionCallback_t failure) { LLCoros::instance().launch("HttpCoroutineAdapter::genericGetCoro", - boost::bind(&HttpCoroutineAdapter::trivialGetCoro, _1, url, policyId, success, failure)); + boost::bind(&HttpCoroutineAdapter::trivialGetCoro, url, policyId, success, failure)); } /*static*/ @@ -921,7 +921,7 @@ void HttpCoroutineAdapter::messageHttpGet(const std::string &url, const std::str } /*static*/ -void HttpCoroutineAdapter::trivialGetCoro(LLCoros::self& self, std::string url, LLCore::HttpRequest::policy_t policyId, completionCallback_t success, completionCallback_t failure) +void HttpCoroutineAdapter::trivialGetCoro(std::string url, LLCore::HttpRequest::policy_t policyId, completionCallback_t success, completionCallback_t failure) { LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("genericGetCoro", policyId)); @@ -932,7 +932,7 @@ void HttpCoroutineAdapter::trivialGetCoro(LLCoros::self& self, std::string url, LL_INFOS("HttpCoroutineAdapter", "genericGetCoro") << "Generic GET for " << url << LL_ENDL; - LLSD result = httpAdapter->getAndYield(self, httpRequest, url, httpOpts); + LLSD result = httpAdapter->getAndYield(httpRequest, url, httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -957,7 +957,7 @@ void HttpCoroutineAdapter::trivialGetCoro(LLCoros::self& self, std::string url, void HttpCoroutineAdapter::callbackHttpPost(const std::string &url, LLCore::HttpRequest::policy_t policyId, const LLSD &postData, completionCallback_t success, completionCallback_t failure) { LLCoros::instance().launch("HttpCoroutineAdapter::genericPostCoro", - boost::bind(&HttpCoroutineAdapter::trivialPostCoro, _1, url, policyId, postData, success, failure)); + boost::bind(&HttpCoroutineAdapter::trivialPostCoro, url, policyId, postData, success, failure)); } /*static*/ @@ -972,7 +972,7 @@ void HttpCoroutineAdapter::messageHttpPost(const std::string &url, const LLSD &p } /*static*/ -void HttpCoroutineAdapter::trivialPostCoro(LLCoros::self& self, std::string url, LLCore::HttpRequest::policy_t policyId, LLSD postData, completionCallback_t success, completionCallback_t failure) +void HttpCoroutineAdapter::trivialPostCoro(std::string url, LLCore::HttpRequest::policy_t policyId, LLSD postData, completionCallback_t success, completionCallback_t failure) { LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("genericPostCoro", policyId)); @@ -983,7 +983,7 @@ void HttpCoroutineAdapter::trivialPostCoro(LLCoros::self& self, std::string url, LL_INFOS("HttpCoroutineAdapter", "genericPostCoro") << "Generic POST for " << url << LL_ENDL; - LLSD result = httpAdapter->postAndYield(self, httpRequest, url, postData, httpOpts); + LLSD result = httpAdapter->postAndYield(httpRequest, url, postData, httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); diff --git a/indra/llmessage/llcorehttputil.h b/indra/llmessage/llcorehttputil.h index 7dd161d1cd..cf35177e48 100644 --- a/indra/llmessage/llcorehttputil.h +++ b/indra/llmessage/llcorehttputil.h @@ -320,67 +320,67 @@ public: /// /// @Note: the request's smart pointer is passed by value so that it will /// not be deallocated during the yield. - LLSD postAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, + LLSD postAndYield(LLCore::HttpRequest::ptr_t request, const std::string & url, const LLSD & body, LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders())); - LLSD postAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, + LLSD postAndYield(LLCore::HttpRequest::ptr_t request, const std::string & url, LLCore::BufferArray::ptr_t rawbody, LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders())); - LLSD postAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, + LLSD postAndYield(LLCore::HttpRequest::ptr_t &request, const std::string & url, const LLSD & body, LLCore::HttpHeaders::ptr_t &headers) { - return postAndYield(self, request, url, body, + return postAndYield(request, url, body, LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), headers); } - LLSD postAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, + LLSD postAndYield(LLCore::HttpRequest::ptr_t &request, const std::string & url, LLCore::BufferArray::ptr_t &rawbody, LLCore::HttpHeaders::ptr_t &headers) { - return postAndYield(self, request, url, rawbody, + return postAndYield(request, url, rawbody, LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), headers); } - LLSD postRawAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, + LLSD postRawAndYield(LLCore::HttpRequest::ptr_t request, const std::string & url, LLCore::BufferArray::ptr_t rawbody, LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders())); - LLSD postRawAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, + LLSD postRawAndYield(LLCore::HttpRequest::ptr_t &request, const std::string & url, LLCore::BufferArray::ptr_t &rawbody, LLCore::HttpHeaders::ptr_t &headers) { - return postRawAndYield(self, request, url, rawbody, + return postRawAndYield(request, url, rawbody, LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), headers); } - LLSD postFileAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, + LLSD postFileAndYield(LLCore::HttpRequest::ptr_t request, const std::string & url, std::string fileName, LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders())); - LLSD postFileAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, + LLSD postFileAndYield(LLCore::HttpRequest::ptr_t &request, const std::string & url, std::string fileName, LLCore::HttpHeaders::ptr_t &headers) { - return postFileAndYield(self, request, url, fileName, + return postFileAndYield(request, url, fileName, LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), headers); } - LLSD postFileAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, + LLSD postFileAndYield(LLCore::HttpRequest::ptr_t request, const std::string & url, LLUUID assetId, LLAssetType::EType assetType, LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders())); - LLSD postFileAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, + LLSD postFileAndYield(LLCore::HttpRequest::ptr_t request, const std::string & url, LLUUID assetId, LLAssetType::EType assetType, LLCore::HttpHeaders::ptr_t &headers) { - return postFileAndYield(self, request, url, assetId, assetType, + return postFileAndYield(request, url, assetId, assetType, LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), headers); } @@ -390,7 +390,7 @@ public: /// /// @Note: the request's smart pointer is passed by value so that it will /// not be deallocated during the yield. - LLSD putAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, + LLSD putAndYield(LLCore::HttpRequest::ptr_t request, const std::string & url, const LLSD & body, LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders())); @@ -400,38 +400,38 @@ public: /// /// @Note: the request's smart pointer is passed by value so that it will /// not be deallocated during the yield. - LLSD getAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, + LLSD getAndYield(LLCore::HttpRequest::ptr_t request, const std::string & url, LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders())); - LLSD getAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, + LLSD getAndYield(LLCore::HttpRequest::ptr_t &request, const std::string & url, LLCore::HttpHeaders::ptr_t &headers) { - return getAndYield(self, request, url, + return getAndYield(request, url, LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), headers); } - LLSD getRawAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, + LLSD getRawAndYield(LLCore::HttpRequest::ptr_t request, const std::string & url, LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders())); - LLSD getRawAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, + LLSD getRawAndYield(LLCore::HttpRequest::ptr_t &request, const std::string & url, LLCore::HttpHeaders::ptr_t &headers) { - return getRawAndYield(self, request, url, + return getRawAndYield(request, url, LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), headers); } - LLSD getJsonAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, + LLSD getJsonAndYield(LLCore::HttpRequest::ptr_t request, const std::string & url, LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders())); - LLSD getJsonndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, + LLSD getJsonndYield(LLCore::HttpRequest::ptr_t &request, const std::string & url, LLCore::HttpHeaders::ptr_t &headers) { - return getJsonAndYield(self, request, url, + return getJsonAndYield(request, url, LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), headers); } @@ -442,7 +442,7 @@ public: /// /// @Note: the request's smart pointer is passed by value so that it will /// not be deallocated during the yield. - LLSD deleteAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, + LLSD deleteAndYield(LLCore::HttpRequest::ptr_t request, const std::string & url, LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders())); @@ -486,31 +486,31 @@ private: HttpCoroHandler::ptr_t &handler); void cleanState(); - LLSD postAndYield_(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, + LLSD postAndYield_(LLCore::HttpRequest::ptr_t &request, const std::string & url, const LLSD & body, LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler); - LLSD postAndYield_(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, + LLSD postAndYield_(LLCore::HttpRequest::ptr_t &request, const std::string & url, LLCore::BufferArray::ptr_t &rawbody, LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler); - LLSD putAndYield_(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, + LLSD putAndYield_(LLCore::HttpRequest::ptr_t &request, const std::string & url, const LLSD & body, LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler); - LLSD getAndYield_(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, + LLSD getAndYield_(LLCore::HttpRequest::ptr_t &request, const std::string & url, LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler); - LLSD deleteAndYield_(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, + LLSD deleteAndYield_(LLCore::HttpRequest::ptr_t &request, const std::string & url, LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler); - static void trivialGetCoro(LLCoros::self& self, std::string url, LLCore::HttpRequest::policy_t policyId, completionCallback_t success, completionCallback_t failure); - static void trivialPostCoro(LLCoros::self& self, std::string url, LLCore::HttpRequest::policy_t policyId, LLSD postData, completionCallback_t success, completionCallback_t failure); + static void trivialGetCoro(std::string url, LLCore::HttpRequest::policy_t policyId, completionCallback_t success, completionCallback_t failure); + static void trivialPostCoro(std::string url, LLCore::HttpRequest::policy_t policyId, LLSD postData, completionCallback_t success, completionCallback_t failure); void checkDefaultHeaders(LLCore::HttpHeaders::ptr_t &headers); diff --git a/indra/newview/llaccountingcostmanager.cpp b/indra/newview/llaccountingcostmanager.cpp index f928c84ecb..cd9146ea16 100755 --- a/indra/newview/llaccountingcostmanager.cpp +++ b/indra/newview/llaccountingcostmanager.cpp @@ -45,10 +45,10 @@ LLAccountingCostManager::LLAccountingCostManager(): // Coroutine for sending and processing avatar name cache requests. // Do not call directly. See documentation in lleventcoro.h and llcoro.h for // further explanation. -void LLAccountingCostManager::accountingCostCoro(LLCoros::self& self, std::string url, +void LLAccountingCostManager::accountingCostCoro(std::string url, eSelectionType selectionType, const LLHandle observerHandle) { - LL_DEBUGS("LLAccountingCostManager") << "Entering coroutine " << LLCoros::instance().getName(self) + LL_DEBUGS("LLAccountingCostManager") << "Entering coroutine " << LLCoros::instance().getName() << " with url '" << url << LL_ENDL; try @@ -101,7 +101,7 @@ void LLAccountingCostManager::accountingCostCoro(LLCoros::self& self, std::strin LLCoreHttpUtil::HttpCoroutineAdapter httpAdapter("AccountingCost", mHttpPolicy); - LLSD results = httpAdapter.postAndYield(self, mHttpRequest, url, dataToPost); + LLSD results = httpAdapter.postAndYield(mHttpRequest, url, dataToPost); LLSD httpResults; httpResults = results["http_result"]; @@ -181,7 +181,7 @@ void LLAccountingCostManager::fetchCosts( eSelectionType selectionType, { std::string coroname = LLCoros::instance().launch("LLAccountingCostManager::accountingCostCoro", - boost::bind(&LLAccountingCostManager::accountingCostCoro, this, _1, url, selectionType, observer_handle)); + boost::bind(&LLAccountingCostManager::accountingCostCoro, this, url, selectionType, observer_handle)); LL_DEBUGS() << coroname << " with url '" << url << LL_ENDL; } diff --git a/indra/newview/llaccountingcostmanager.h b/indra/newview/llaccountingcostmanager.h index 34748894e3..d5a94f6fda 100755 --- a/indra/newview/llaccountingcostmanager.h +++ b/indra/newview/llaccountingcostmanager.h @@ -77,7 +77,7 @@ private: std::set mPendingObjectQuota; typedef std::set::iterator IDIt; - void accountingCostCoro(LLCoros::self& self, std::string url, eSelectionType selectionType, const LLHandle observerHandle); + void accountingCostCoro(std::string url, eSelectionType selectionType, const LLHandle observerHandle); LLCore::HttpRequest::ptr_t mHttpRequest; LLCore::HttpRequest::policy_t mHttpPolicy; diff --git a/indra/newview/llavatarrenderinfoaccountant.cpp b/indra/newview/llavatarrenderinfoaccountant.cpp index 73b2ecfd36..e260142254 100644 --- a/indra/newview/llavatarrenderinfoaccountant.cpp +++ b/indra/newview/llavatarrenderinfoaccountant.cpp @@ -60,14 +60,14 @@ LLFrameTimer LLAvatarRenderInfoAccountant::sRenderInfoReportTimer; //LLCore::HttpRequest::ptr_t LLAvatarRenderInfoAccountant::sHttpRequest; //========================================================================= -void LLAvatarRenderInfoAccountant::avatarRenderInfoGetCoro(LLCoros::self& self, std::string url, U64 regionHandle) +void LLAvatarRenderInfoAccountant::avatarRenderInfoGetCoro(std::string url, U64 regionHandle) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("AvatarRenderInfoAccountant", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLSD result = httpAdapter->getAndYield(self, httpRequest, url); + LLSD result = httpAdapter->getAndYield(httpRequest, url); LLViewerRegion * regionp = LLWorld::getInstance()->getRegionFromHandle(regionHandle); if (!regionp) @@ -130,7 +130,7 @@ void LLAvatarRenderInfoAccountant::avatarRenderInfoGetCoro(LLCoros::self& self, } //------------------------------------------------------------------------- -void LLAvatarRenderInfoAccountant::avatarRenderInfoReportCoro(LLCoros::self& self, std::string url, U64 regionHandle) +void LLAvatarRenderInfoAccountant::avatarRenderInfoReportCoro(std::string url, U64 regionHandle) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -190,7 +190,7 @@ void LLAvatarRenderInfoAccountant::avatarRenderInfoReportCoro(LLCoros::self& sel report[KEY_AGENTS] = agents; regionp = NULL; - LLSD result = httpAdapter->postAndYield(self, httpRequest, url, report); + LLSD result = httpAdapter->postAndYield(httpRequest, url, report); regionp = LLWorld::getInstance()->getRegionFromHandle(regionHandle); if (!regionp) @@ -239,7 +239,7 @@ void LLAvatarRenderInfoAccountant::sendRenderInfoToRegion(LLViewerRegion * regio { std::string coroname = LLCoros::instance().launch("LLAvatarRenderInfoAccountant::avatarRenderInfoReportCoro", - boost::bind(&LLAvatarRenderInfoAccountant::avatarRenderInfoReportCoro, _1, url, regionp->getHandle())); + boost::bind(&LLAvatarRenderInfoAccountant::avatarRenderInfoReportCoro, url, regionp->getHandle())); } } @@ -264,7 +264,7 @@ void LLAvatarRenderInfoAccountant::getRenderInfoFromRegion(LLViewerRegion * regi // First send a request to get the latest data std::string coroname = LLCoros::instance().launch("LLAvatarRenderInfoAccountant::avatarRenderInfoGetCoro", - boost::bind(&LLAvatarRenderInfoAccountant::avatarRenderInfoGetCoro, _1, url, regionp->getHandle())); + boost::bind(&LLAvatarRenderInfoAccountant::avatarRenderInfoGetCoro, url, regionp->getHandle())); } } diff --git a/indra/newview/llavatarrenderinfoaccountant.h b/indra/newview/llavatarrenderinfoaccountant.h index 1736f03772..f7a04cca2c 100644 --- a/indra/newview/llavatarrenderinfoaccountant.h +++ b/indra/newview/llavatarrenderinfoaccountant.h @@ -56,8 +56,8 @@ private: // Send data updates about once per minute, only need per-frame resolution static LLFrameTimer sRenderInfoReportTimer; - static void avatarRenderInfoGetCoro(LLCoros::self& self, std::string url, U64 regionHandle); - static void avatarRenderInfoReportCoro(LLCoros::self& self, std::string url, U64 regionHandle); + static void avatarRenderInfoGetCoro(std::string url, U64 regionHandle); + static void avatarRenderInfoReportCoro(std::string url, U64 regionHandle); }; diff --git a/indra/newview/llcoproceduremanager.cpp b/indra/newview/llcoproceduremanager.cpp index 3ecb323cab..1a4a906f35 100644 --- a/indra/newview/llcoproceduremanager.cpp +++ b/indra/newview/llcoproceduremanager.cpp @@ -54,7 +54,7 @@ LLCoprocedureManager::LLCoprocedureManager(): new LLCoreHttpUtil::HttpCoroutineAdapter("uploadPostAdapter", mHTTPPolicy)); std::string uploadCoro = LLCoros::instance().launch("LLCoprocedureManager::coprocedureInvokerCoro", - boost::bind(&LLCoprocedureManager::coprocedureInvokerCoro, this, _1, httpAdapter)); + boost::bind(&LLCoprocedureManager::coprocedureInvokerCoro, this, httpAdapter)); mCoroMapping.insert(CoroAdapterMap_t::value_type(uploadCoro, httpAdapter)); } @@ -132,13 +132,13 @@ void LLCoprocedureManager::cancelCoprocedure(const LLUUID &id) } //========================================================================= -void LLCoprocedureManager::coprocedureInvokerCoro(LLCoros::self& self, LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter) +void LLCoprocedureManager::coprocedureInvokerCoro(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter) { LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); while (!mShutdown) { - waitForEventOn(self, mWakeupTrigger); + waitForEventOn(mWakeupTrigger); if (mShutdown) break; @@ -152,7 +152,7 @@ void LLCoprocedureManager::coprocedureInvokerCoro(LLCoros::self& self, LLCoreHtt try { - coproc->mProc(self, httpAdapter, coproc->mId); + coproc->mProc(httpAdapter, coproc->mId); } catch (std::exception &e) { diff --git a/indra/newview/llcoproceduremanager.h b/indra/newview/llcoproceduremanager.h index 4e971d42e3..6ba3891e87 100644 --- a/indra/newview/llcoproceduremanager.h +++ b/indra/newview/llcoproceduremanager.h @@ -36,7 +36,7 @@ class LLCoprocedureManager : public LLSingleton < LLCoprocedureManager > { public: - typedef boost::function CoProcedure_t; + typedef boost::function CoProcedure_t; LLCoprocedureManager(); virtual ~LLCoprocedureManager(); @@ -111,7 +111,7 @@ private: CoroAdapterMap_t mCoroMapping; - void coprocedureInvokerCoro(LLCoros::self& self, LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter); + void coprocedureInvokerCoro(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter); }; #endif diff --git a/indra/newview/llestateinfomodel.cpp b/indra/newview/llestateinfomodel.cpp index 04d0dda7ac..884d1579e6 100755 --- a/indra/newview/llestateinfomodel.cpp +++ b/indra/newview/llestateinfomodel.cpp @@ -123,12 +123,12 @@ bool LLEstateInfoModel::commitEstateInfoCaps() } LLCoros::instance().launch("LLEstateInfoModel::commitEstateInfoCapsCoro", - boost::bind(&LLEstateInfoModel::commitEstateInfoCapsCoro, this, _1, url)); + boost::bind(&LLEstateInfoModel::commitEstateInfoCapsCoro, this, url)); return true; } -void LLEstateInfoModel::commitEstateInfoCapsCoro(LLCoros::self& self, std::string url) +void LLEstateInfoModel::commitEstateInfoCapsCoro(std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -153,7 +153,7 @@ void LLEstateInfoModel::commitEstateInfoCapsCoro(LLCoros::self& self, std::strin << ", sun_hour = " << getSunHour() << LL_ENDL; LL_DEBUGS() << body << LL_ENDL; - LLSD result = httpAdapter->postAndYield(self, httpRequest, url, body); + LLSD result = httpAdapter->postAndYield(httpRequest, url, body); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); diff --git a/indra/newview/llestateinfomodel.h b/indra/newview/llestateinfomodel.h index 2deae7e322..fcfbd1ce7d 100755 --- a/indra/newview/llestateinfomodel.h +++ b/indra/newview/llestateinfomodel.h @@ -101,7 +101,7 @@ private: update_signal_t mUpdateSignal; /// emitted when we receive update from sim update_signal_t mCommitSignal; /// emitted when our update gets applied to sim - void commitEstateInfoCapsCoro(LLCoros::self& self, std::string url); + void commitEstateInfoCapsCoro(std::string url); }; inline bool LLEstateInfoModel::getFlag(U64 flag) const diff --git a/indra/newview/lleventpoll.cpp b/indra/newview/lleventpoll.cpp index 03a380f2f6..54da226209 100755 --- a/indra/newview/lleventpoll.cpp +++ b/indra/newview/lleventpoll.cpp @@ -61,7 +61,7 @@ namespace Details static const F32 EVENT_POLL_ERROR_RETRY_SECONDS_INC; static const S32 MAX_EVENT_POLL_HTTP_ERRORS; - void eventPollCoro(LLCoros::self& self, std::string url); + void eventPollCoro(std::string url); void handleMessage(const LLSD &content); @@ -113,7 +113,7 @@ namespace Details { std::string coroname = LLCoros::instance().launch("LLEventPollImpl::eventPollCoro", - boost::bind(&LLEventPollImpl::eventPollCoro, this, _1, url)); + boost::bind(&LLEventPollImpl::eventPollCoro, this, url)); LL_INFOS("LLEventPollImpl") << coroname << " with url '" << url << LL_ENDL; } } @@ -131,7 +131,7 @@ namespace Details } } - void LLEventPollImpl::eventPollCoro(LLCoros::self& self, std::string url) + void LLEventPollImpl::eventPollCoro(std::string url) { LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("EventPoller", mHttpPolicy)); LLSD acknowledge; @@ -154,7 +154,7 @@ namespace Details // << LLSDXMLStreamer(request) << LL_ENDL; LL_DEBUGS("LLEventPollImpl") << " <" << counter << "> posting and yielding." << LL_ENDL; - LLSD result = httpAdapter->postAndYield(self, mHttpRequest, url, request); + LLSD result = httpAdapter->postAndYield(mHttpRequest, url, request); // LL_DEBUGS("LLEventPollImpl::eventPollCoro") << "<" << counter << "> result = " // << LLSDXMLStreamer(result) << LL_ENDL; @@ -197,7 +197,7 @@ namespace Details " seconds, error count is now " << errorCount << LL_ENDL; timeout.eventAfter(waitToRetry, LLSD()); - waitForEventOn(self, timeout); + waitForEventOn(timeout); if (mDone) break; diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index 87d7aacda1..136e02953c 100755 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -144,7 +144,7 @@ LLFacebookConnectHandler gFacebookConnectHandler; /////////////////////////////////////////////////////////////////////////////// // -void LLFacebookConnect::facebookConnectCoro(LLCoros::self& self, std::string authCode, std::string authState) +void LLFacebookConnect::facebookConnectCoro(std::string authCode, std::string authState) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -167,7 +167,7 @@ void LLFacebookConnect::facebookConnectCoro(LLCoros::self& self, std::string aut setConnectionState(LLFacebookConnect::FB_CONNECTION_IN_PROGRESS); - LLSD result = httpAdapter->putAndYield(self, httpRequest, getFacebookConnectURL("/connection"), putData, httpOpts, get_headers()); + LLSD result = httpAdapter->putAndYield(httpRequest, getFacebookConnectURL("/connection"), putData, httpOpts, get_headers()); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -231,7 +231,7 @@ bool LLFacebookConnect::testShareStatus(LLSD &result) return false; } -void LLFacebookConnect::facebookShareCoro(LLCoros::self& self, std::string route, LLSD share) +void LLFacebookConnect::facebookShareCoro(std::string route, LLSD share) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -244,7 +244,7 @@ void LLFacebookConnect::facebookShareCoro(LLCoros::self& self, std::string route setConnectionState(LLFacebookConnect::FB_POSTING); - LLSD result = httpAdapter->postAndYield(self, httpRequest, getFacebookConnectURL(route, true), share, httpOpts, get_headers()); + LLSD result = httpAdapter->postAndYield(httpRequest, getFacebookConnectURL(route, true), share, httpOpts, get_headers()); if (testShareStatus(result)) { @@ -254,7 +254,7 @@ void LLFacebookConnect::facebookShareCoro(LLCoros::self& self, std::string route } } -void LLFacebookConnect::facebookShareImageCoro(LLCoros::self& self, std::string route, LLPointer image, std::string caption) +void LLFacebookConnect::facebookShareImageCoro(std::string route, LLPointer image, std::string caption) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -311,7 +311,7 @@ void LLFacebookConnect::facebookShareImageCoro(LLCoros::self& self, std::string setConnectionState(LLFacebookConnect::FB_POSTING); - LLSD result = httpAdapter->postAndYield(self, httpRequest, getFacebookConnectURL(route, true), raw, httpOpts, httpHeaders); + LLSD result = httpAdapter->postAndYield(httpRequest, getFacebookConnectURL(route, true), raw, httpOpts, httpHeaders); if (testShareStatus(result)) { @@ -323,7 +323,7 @@ void LLFacebookConnect::facebookShareImageCoro(LLCoros::self& self, std::string /////////////////////////////////////////////////////////////////////////////// // -void LLFacebookConnect::facebookDisconnectCoro(LLCoros::self& self) +void LLFacebookConnect::facebookDisconnectCoro() { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -334,7 +334,7 @@ void LLFacebookConnect::facebookDisconnectCoro(LLCoros::self& self) setConnectionState(LLFacebookConnect::FB_DISCONNECTING); httpOpts->setFollowRedirects(false); - LLSD result = httpAdapter->deleteAndYield(self, httpRequest, getFacebookConnectURL("/connection"), httpOpts, get_headers()); + LLSD result = httpAdapter->deleteAndYield(httpRequest, getFacebookConnectURL("/connection"), httpOpts, get_headers()); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -358,7 +358,7 @@ void LLFacebookConnect::facebookDisconnectCoro(LLCoros::self& self) /////////////////////////////////////////////////////////////////////////////// // -void LLFacebookConnect::facebookConnectedCheckCoro(LLCoros::self& self, bool autoConnect) +void LLFacebookConnect::facebookConnectedCheckCoro(bool autoConnect) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -370,7 +370,7 @@ void LLFacebookConnect::facebookConnectedCheckCoro(LLCoros::self& self, bool aut httpOpts->setFollowRedirects(false); - LLSD result = httpAdapter->getAndYield(self, httpRequest, getFacebookConnectURL("/connection", true), httpOpts, get_headers()); + LLSD result = httpAdapter->getAndYield(httpRequest, getFacebookConnectURL("/connection", true), httpOpts, get_headers()); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -407,7 +407,7 @@ void LLFacebookConnect::facebookConnectedCheckCoro(LLCoros::self& self, bool aut /////////////////////////////////////////////////////////////////////////////// // -void LLFacebookConnect::facebookConnectInfoCoro(LLCoros::self& self) +void LLFacebookConnect::facebookConnectInfoCoro() { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -418,7 +418,7 @@ void LLFacebookConnect::facebookConnectInfoCoro(LLCoros::self& self) httpOpts->setWantHeaders(true); httpOpts->setFollowRedirects(false); - LLSD result = httpAdapter->getAndYield(self, httpRequest, getFacebookConnectURL("/info", true), httpOpts, get_headers()); + LLSD result = httpAdapter->getAndYield(httpRequest, getFacebookConnectURL("/info", true), httpOpts, get_headers()); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -451,7 +451,7 @@ void LLFacebookConnect::facebookConnectInfoCoro(LLCoros::self& self) /////////////////////////////////////////////////////////////////////////////// // -void LLFacebookConnect::facebookConnectFriendsCoro(LLCoros::self& self) +void LLFacebookConnect::facebookConnectFriendsCoro() { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -461,7 +461,7 @@ void LLFacebookConnect::facebookConnectFriendsCoro(LLCoros::self& self) httpOpts->setFollowRedirects(false); - LLSD result = httpAdapter->getAndYield(self, httpRequest, getFacebookConnectURL("/friends", true), httpOpts, get_headers()); + LLSD result = httpAdapter->getAndYield(httpRequest, getFacebookConnectURL("/friends", true), httpOpts, get_headers()); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -547,19 +547,19 @@ std::string LLFacebookConnect::getFacebookConnectURL(const std::string& route, b void LLFacebookConnect::connectToFacebook(const std::string& auth_code, const std::string& auth_state) { LLCoros::instance().launch("LLFacebookConnect::facebookConnectCoro", - boost::bind(&LLFacebookConnect::facebookConnectCoro, this, _1, auth_code, auth_state)); + boost::bind(&LLFacebookConnect::facebookConnectCoro, this, auth_code, auth_state)); } void LLFacebookConnect::disconnectFromFacebook() { LLCoros::instance().launch("LLFacebookConnect::facebookDisconnectCoro", - boost::bind(&LLFacebookConnect::facebookDisconnectCoro, this, _1)); + boost::bind(&LLFacebookConnect::facebookDisconnectCoro, this)); } void LLFacebookConnect::checkConnectionToFacebook(bool auto_connect) { LLCoros::instance().launch("LLFacebookConnect::facebookConnectedCheckCoro", - boost::bind(&LLFacebookConnect::facebookConnectedCheckCoro, this, _1, auto_connect)); + boost::bind(&LLFacebookConnect::facebookConnectedCheckCoro, this, auto_connect)); } void LLFacebookConnect::loadFacebookInfo() @@ -567,7 +567,7 @@ void LLFacebookConnect::loadFacebookInfo() if(mRefreshInfo) { LLCoros::instance().launch("LLFacebookConnect::facebookConnectInfoCoro", - boost::bind(&LLFacebookConnect::facebookConnectInfoCoro, this, _1)); + boost::bind(&LLFacebookConnect::facebookConnectInfoCoro, this)); } } @@ -576,7 +576,7 @@ void LLFacebookConnect::loadFacebookFriends() if(mRefreshContent) { LLCoros::instance().launch("LLFacebookConnect::facebookConnectFriendsCoro", - boost::bind(&LLFacebookConnect::facebookConnectFriendsCoro, this, _1)); + boost::bind(&LLFacebookConnect::facebookConnectFriendsCoro, this)); } } @@ -606,7 +606,7 @@ void LLFacebookConnect::postCheckin(const std::string& location, const std::stri } LLCoros::instance().launch("LLFacebookConnect::facebookShareCoro", - boost::bind(&LLFacebookConnect::facebookShareCoro, this, _1, "/share/checkin", body)); + boost::bind(&LLFacebookConnect::facebookShareCoro, this, "/share/checkin", body)); } void LLFacebookConnect::sharePhoto(const std::string& image_url, const std::string& caption) @@ -617,13 +617,13 @@ void LLFacebookConnect::sharePhoto(const std::string& image_url, const std::stri body["caption"] = caption; LLCoros::instance().launch("LLFacebookConnect::facebookShareCoro", - boost::bind(&LLFacebookConnect::facebookShareCoro, this, _1, "/share/photo", body)); + boost::bind(&LLFacebookConnect::facebookShareCoro, this, "/share/photo", body)); } void LLFacebookConnect::sharePhoto(LLPointer image, const std::string& caption) { LLCoros::instance().launch("LLFacebookConnect::facebookShareImageCoro", - boost::bind(&LLFacebookConnect::facebookShareImageCoro, this, _1, "/share/photo", image, caption)); + boost::bind(&LLFacebookConnect::facebookShareImageCoro, this, "/share/photo", image, caption)); } void LLFacebookConnect::updateStatus(const std::string& message) @@ -632,7 +632,7 @@ void LLFacebookConnect::updateStatus(const std::string& message) body["message"] = message; LLCoros::instance().launch("LLFacebookConnect::facebookShareCoro", - boost::bind(&LLFacebookConnect::facebookShareCoro, this, _1, "/share/wall", body)); + boost::bind(&LLFacebookConnect::facebookShareCoro, this, "/share/wall", body)); } void LLFacebookConnect::storeInfo(const LLSD& info) diff --git a/indra/newview/llfacebookconnect.h b/indra/newview/llfacebookconnect.h index f569c2f486..2a2cdb5499 100644 --- a/indra/newview/llfacebookconnect.h +++ b/indra/newview/llfacebookconnect.h @@ -105,13 +105,13 @@ private: static boost::scoped_ptr sContentWatcher; bool testShareStatus(LLSD &results); - void facebookConnectCoro(LLCoros::self& self, std::string authCode, std::string authState); - void facebookConnectedCheckCoro(LLCoros::self& self, bool autoConnect); - void facebookDisconnectCoro(LLCoros::self& self); - void facebookShareCoro(LLCoros::self& self, std::string route, LLSD share); - void facebookShareImageCoro(LLCoros::self& self, std::string route, LLPointer image, std::string caption); - void facebookConnectInfoCoro(LLCoros::self& self); - void facebookConnectFriendsCoro(LLCoros::self& self); + void facebookConnectCoro(std::string authCode, std::string authState); + void facebookConnectedCheckCoro(bool autoConnect); + void facebookDisconnectCoro(); + void facebookShareCoro(std::string route, LLSD share); + void facebookShareImageCoro(std::string route, LLPointer image, std::string caption); + void facebookConnectInfoCoro(); + void facebookConnectFriendsCoro(); }; #endif // LL_LLFACEBOOKCONNECT_H diff --git a/indra/newview/llfeaturemanager.cpp b/indra/newview/llfeaturemanager.cpp index 9a714ac962..0b76ca16a9 100755 --- a/indra/newview/llfeaturemanager.cpp +++ b/indra/newview/llfeaturemanager.cpp @@ -492,7 +492,7 @@ bool LLFeatureManager::loadGPUClass() return true; // indicates that a gpu value was established } -void LLFeatureManager::fetchFeatureTableCoro(LLCoros::self& self, std::string tableName) +void LLFeatureManager::fetchFeatureTableCoro(std::string tableName) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -526,7 +526,7 @@ void LLFeatureManager::fetchFeatureTableCoro(LLCoros::self& self, std::string ta LL_INFOS() << "LLFeatureManager fetching " << url << " into " << path << LL_ENDL; - LLSD result = httpAdapter->getRawAndYield(self, httpRequest, url); + LLSD result = httpAdapter->getRawAndYield(httpRequest, url); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -553,7 +553,7 @@ void LLFeatureManager::fetchFeatureTableCoro(LLCoros::self& self, std::string ta void LLFeatureManager::fetchHTTPTables() { LLCoros::instance().launch("LLFeatureManager::fetchFeatureTableCoro", - boost::bind(&LLFeatureManager::fetchFeatureTableCoro, this, _1, FEATURE_TABLE_VER_FILENAME)); + boost::bind(&LLFeatureManager::fetchFeatureTableCoro, this, FEATURE_TABLE_VER_FILENAME)); } void LLFeatureManager::cleanupFeatureTables() diff --git a/indra/newview/llfeaturemanager.h b/indra/newview/llfeaturemanager.h index 1490c2122c..12ea691b49 100755 --- a/indra/newview/llfeaturemanager.h +++ b/indra/newview/llfeaturemanager.h @@ -166,7 +166,7 @@ protected: void initBaseMask(); - void fetchFeatureTableCoro(LLCoros::self& self, std::string name); + void fetchFeatureTableCoro(std::string name); std::map mMaskList; std::set mSkippedFeatures; diff --git a/indra/newview/llflickrconnect.cpp b/indra/newview/llflickrconnect.cpp index 873b1a7138..83e4f19191 100644 --- a/indra/newview/llflickrconnect.cpp +++ b/indra/newview/llflickrconnect.cpp @@ -67,7 +67,7 @@ void toast_user_for_flickr_success() /////////////////////////////////////////////////////////////////////////////// // -void LLFlickrConnect::flickrConnectCoro(LLCoros::self& self, std::string requestToken, std::string oauthVerifier) +void LLFlickrConnect::flickrConnectCoro(std::string requestToken, std::string oauthVerifier) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -86,7 +86,7 @@ void LLFlickrConnect::flickrConnectCoro(LLCoros::self& self, std::string request setConnectionState(LLFlickrConnect::FLICKR_CONNECTION_IN_PROGRESS); - LLSD result = httpAdapter->putAndYield(self, httpRequest, getFlickrConnectURL("/connection"), body, httpOpts); + LLSD result = httpAdapter->putAndYield(httpRequest, getFlickrConnectURL("/connection"), body, httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -157,7 +157,7 @@ bool LLFlickrConnect::testShareStatus(LLSD &result) return false; } -void LLFlickrConnect::flickrShareCoro(LLCoros::self& self, LLSD share) +void LLFlickrConnect::flickrShareCoro(LLSD share) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -170,7 +170,7 @@ void LLFlickrConnect::flickrShareCoro(LLCoros::self& self, LLSD share) setConnectionState(LLFlickrConnect::FLICKR_POSTING); - LLSD result = httpAdapter->postAndYield(self, httpRequest, getFlickrConnectURL("/share/photo", true), share, httpOpts); + LLSD result = httpAdapter->postAndYield(httpRequest, getFlickrConnectURL("/share/photo", true), share, httpOpts); if (testShareStatus(result)) { @@ -181,7 +181,7 @@ void LLFlickrConnect::flickrShareCoro(LLCoros::self& self, LLSD share) } -void LLFlickrConnect::flickrShareImageCoro(LLCoros::self& self, LLPointer image, std::string title, std::string description, std::string tags, int safetyLevel) +void LLFlickrConnect::flickrShareImageCoro(LLPointer image, std::string title, std::string description, std::string tags, int safetyLevel) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -248,7 +248,7 @@ void LLFlickrConnect::flickrShareImageCoro(LLCoros::self& self, LLPointerpostAndYield(self, httpRequest, getFlickrConnectURL("/share/photo", true), raw, httpOpts, httpHeaders); + LLSD result = httpAdapter->postAndYield(httpRequest, getFlickrConnectURL("/share/photo", true), raw, httpOpts, httpHeaders); if (testShareStatus(result)) { @@ -260,7 +260,7 @@ void LLFlickrConnect::flickrShareImageCoro(LLCoros::self& self, LLPointersetFollowRedirects(false); - LLSD result = httpAdapter->deleteAndYield(self, httpRequest, getFlickrConnectURL("/connection"), httpOpts); + LLSD result = httpAdapter->deleteAndYield(httpRequest, getFlickrConnectURL("/connection"), httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -294,7 +294,7 @@ void LLFlickrConnect::flickrDisconnectCoro(LLCoros::self& self) /////////////////////////////////////////////////////////////////////////////// // -void LLFlickrConnect::flickrConnectedCoro(LLCoros::self& self, bool autoConnect) +void LLFlickrConnect::flickrConnectedCoro(bool autoConnect) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -306,7 +306,7 @@ void LLFlickrConnect::flickrConnectedCoro(LLCoros::self& self, bool autoConnect) httpOpts->setFollowRedirects(false); - LLSD result = httpAdapter->getAndYield(self, httpRequest, getFlickrConnectURL("/connection", true), httpOpts); + LLSD result = httpAdapter->getAndYield(httpRequest, getFlickrConnectURL("/connection", true), httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -344,7 +344,7 @@ void LLFlickrConnect::flickrConnectedCoro(LLCoros::self& self, bool autoConnect) /////////////////////////////////////////////////////////////////////////////// // -void LLFlickrConnect::flickrInfoCoro(LLCoros::self& self) +void LLFlickrConnect::flickrInfoCoro() { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -355,7 +355,7 @@ void LLFlickrConnect::flickrInfoCoro(LLCoros::self& self) httpOpts->setWantHeaders(true); httpOpts->setFollowRedirects(false); - LLSD result = httpAdapter->getAndYield(self, httpRequest, getFlickrConnectURL("/info", true), httpOpts); + LLSD result = httpAdapter->getAndYield(httpRequest, getFlickrConnectURL("/info", true), httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -438,19 +438,19 @@ std::string LLFlickrConnect::getFlickrConnectURL(const std::string& route, bool void LLFlickrConnect::connectToFlickr(const std::string& request_token, const std::string& oauth_verifier) { LLCoros::instance().launch("LLFlickrConnect::flickrConnectCoro", - boost::bind(&LLFlickrConnect::flickrConnectCoro, this, _1, request_token, oauth_verifier)); + boost::bind(&LLFlickrConnect::flickrConnectCoro, this, request_token, oauth_verifier)); } void LLFlickrConnect::disconnectFromFlickr() { LLCoros::instance().launch("LLFlickrConnect::flickrDisconnectCoro", - boost::bind(&LLFlickrConnect::flickrDisconnectCoro, this, _1)); + boost::bind(&LLFlickrConnect::flickrDisconnectCoro, this)); } void LLFlickrConnect::checkConnectionToFlickr(bool auto_connect) { LLCoros::instance().launch("LLFlickrConnect::flickrConnectedCoro", - boost::bind(&LLFlickrConnect::flickrConnectedCoro, this, _1, auto_connect)); + boost::bind(&LLFlickrConnect::flickrConnectedCoro, this, auto_connect)); } void LLFlickrConnect::loadFlickrInfo() @@ -458,7 +458,7 @@ void LLFlickrConnect::loadFlickrInfo() if(mRefreshInfo) { LLCoros::instance().launch("LLFlickrConnect::flickrInfoCoro", - boost::bind(&LLFlickrConnect::flickrInfoCoro, this, _1)); + boost::bind(&LLFlickrConnect::flickrInfoCoro, this)); } } @@ -472,14 +472,14 @@ void LLFlickrConnect::uploadPhoto(const std::string& image_url, const std::strin body["safety_level"] = safety_level; LLCoros::instance().launch("LLFlickrConnect::flickrShareCoro", - boost::bind(&LLFlickrConnect::flickrShareCoro, this, _1, body)); + boost::bind(&LLFlickrConnect::flickrShareCoro, this, body)); } void LLFlickrConnect::uploadPhoto(LLPointer image, const std::string& title, const std::string& description, const std::string& tags, int safety_level) { LLCoros::instance().launch("LLFlickrConnect::flickrShareImageCoro", - boost::bind(&LLFlickrConnect::flickrShareImageCoro, this, _1, image, + boost::bind(&LLFlickrConnect::flickrShareImageCoro, this, image, title, description, tags, safety_level)); } diff --git a/indra/newview/llflickrconnect.h b/indra/newview/llflickrconnect.h index 26c63f8b08..0155804da0 100644 --- a/indra/newview/llflickrconnect.h +++ b/indra/newview/llflickrconnect.h @@ -97,12 +97,12 @@ private: static boost::scoped_ptr sContentWatcher; bool testShareStatus(LLSD &result); - void flickrConnectCoro(LLCoros::self& self, std::string requestToken, std::string oauthVerifier); - void flickrShareCoro(LLCoros::self& self, LLSD share); - void flickrShareImageCoro(LLCoros::self& self, LLPointer image, std::string title, std::string description, std::string tags, int safetyLevel); - void flickrDisconnectCoro(LLCoros::self& self); - void flickrConnectedCoro(LLCoros::self& self, bool autoConnect); - void flickrInfoCoro(LLCoros::self& self); + void flickrConnectCoro(std::string requestToken, std::string oauthVerifier); + void flickrShareCoro(LLSD share); + void flickrShareImageCoro(LLPointer image, std::string title, std::string description, std::string tags, int safetyLevel); + void flickrDisconnectCoro(); + void flickrConnectedCoro(bool autoConnect); + void flickrInfoCoro(); }; diff --git a/indra/newview/llfloateravatarpicker.cpp b/indra/newview/llfloateravatarpicker.cpp index e5e9a794a4..2824038f77 100755 --- a/indra/newview/llfloateravatarpicker.cpp +++ b/indra/newview/llfloateravatarpicker.cpp @@ -457,7 +457,7 @@ BOOL LLFloaterAvatarPicker::visibleItemsSelected() const } /*static*/ -void LLFloaterAvatarPicker::findCoro(LLCoros::self& self, std::string url, LLUUID queryID, std::string name) +void LLFloaterAvatarPicker::findCoro(std::string url, LLUUID queryID, std::string name) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -466,7 +466,7 @@ void LLFloaterAvatarPicker::findCoro(LLCoros::self& self, std::string url, LLUUI LL_INFOS("HttpCoroutineAdapter", "genericPostCoro") << "Generic POST for " << url << LL_ENDL; - LLSD result = httpAdapter->getAndYield(self, httpRequest, url); + LLSD result = httpAdapter->getAndYield(httpRequest, url); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -513,7 +513,7 @@ void LLFloaterAvatarPicker::find() LL_INFOS() << "avatar picker " << url << LL_ENDL; LLCoros::instance().launch("LLFloaterAvatarPicker::findCoro", - boost::bind(&LLFloaterAvatarPicker::findCoro, _1, url, mQueryID, getKey().asString())); + boost::bind(&LLFloaterAvatarPicker::findCoro, url, mQueryID, getKey().asString())); } else { diff --git a/indra/newview/llfloateravatarpicker.h b/indra/newview/llfloateravatarpicker.h index 200f74278e..fbee61b054 100755 --- a/indra/newview/llfloateravatarpicker.h +++ b/indra/newview/llfloateravatarpicker.h @@ -86,7 +86,7 @@ private: void populateFriend(); BOOL visibleItemsSelected() const; // Returns true if any items in the current tab are selected. - static void findCoro(LLCoros::self& self, std::string url, LLUUID mQueryID, std::string mName); + static void findCoro(std::string url, LLUUID mQueryID, std::string mName); void find(); void setAllowMultiple(BOOL allow_multiple); LLScrollListCtrl* getActiveList(); diff --git a/indra/newview/llfloatermodeluploadbase.cpp b/indra/newview/llfloatermodeluploadbase.cpp index aa91a2ce03..e2f84fd990 100755 --- a/indra/newview/llfloatermodeluploadbase.cpp +++ b/indra/newview/llfloatermodeluploadbase.cpp @@ -49,7 +49,7 @@ void LLFloaterModelUploadBase::requestAgentUploadPermissions() << "::requestAgentUploadPermissions() requesting for upload model permissions from: " << url << LL_ENDL; LLCoros::instance().launch("LLFloaterModelUploadBase::requestAgentUploadPermissionsCoro", - boost::bind(&LLFloaterModelUploadBase::requestAgentUploadPermissionsCoro, this, _1, url, getPermObserverHandle())); + boost::bind(&LLFloaterModelUploadBase::requestAgentUploadPermissionsCoro, this, url, getPermObserverHandle())); } else { @@ -61,7 +61,7 @@ void LLFloaterModelUploadBase::requestAgentUploadPermissions() } } -void LLFloaterModelUploadBase::requestAgentUploadPermissionsCoro(LLCoros::self& self, std::string url, +void LLFloaterModelUploadBase::requestAgentUploadPermissionsCoro(std::string url, LLHandle observerHandle) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); @@ -70,7 +70,7 @@ void LLFloaterModelUploadBase::requestAgentUploadPermissionsCoro(LLCoros::self& LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLSD result = httpAdapter->getAndYield(self, httpRequest, url); + LLSD result = httpAdapter->getAndYield(httpRequest, url); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); diff --git a/indra/newview/llfloatermodeluploadbase.h b/indra/newview/llfloatermodeluploadbase.h index 9bb9959af0..0d4c834122 100755 --- a/indra/newview/llfloatermodeluploadbase.h +++ b/indra/newview/llfloatermodeluploadbase.h @@ -56,7 +56,7 @@ protected: // requests agent's permissions to upload model void requestAgentUploadPermissions(); - void requestAgentUploadPermissionsCoro(LLCoros::self& self, std::string url, LLHandle observerHandle); + void requestAgentUploadPermissionsCoro(std::string url, LLHandle observerHandle); std::string mUploadModelUrl; bool mHasUploadPerm; diff --git a/indra/newview/llfloaterperms.cpp b/indra/newview/llfloaterperms.cpp index 06af2725c3..16bb449fdb 100755 --- a/indra/newview/llfloaterperms.cpp +++ b/indra/newview/llfloaterperms.cpp @@ -182,7 +182,7 @@ void LLFloaterPermsDefault::updateCap() if(!object_url.empty()) { LLCoros::instance().launch("LLFloaterPermsDefault::updateCapCoro", - boost::bind(&LLFloaterPermsDefault::updateCapCoro, _1, object_url)); + boost::bind(&LLFloaterPermsDefault::updateCapCoro, object_url)); } else { @@ -191,7 +191,7 @@ void LLFloaterPermsDefault::updateCap() } /*static*/ -void LLFloaterPermsDefault::updateCapCoro(LLCoros::self& self, std::string url) +void LLFloaterPermsDefault::updateCapCoro(std::string url) { static std::string previousReason; LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); @@ -215,7 +215,7 @@ void LLFloaterPermsDefault::updateCapCoro(LLCoros::self& self, std::string url) LL_CONT << sent_perms_log.str() << LL_ENDL; } - LLSD result = httpAdapter->postAndYield(self, httpRequest, url, postData); + LLSD result = httpAdapter->postAndYield(httpRequest, url, postData); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); diff --git a/indra/newview/llfloaterperms.h b/indra/newview/llfloaterperms.h index ba7d39fe89..e866b6de7d 100755 --- a/indra/newview/llfloaterperms.h +++ b/indra/newview/llfloaterperms.h @@ -82,7 +82,7 @@ private: void refresh(); static const std::string sCategoryNames[CAT_LAST]; - static void updateCapCoro(LLCoros::self& self, std::string url); + static void updateCapCoro(std::string url); // cached values only for implementing cancel. diff --git a/indra/newview/llfloaterscriptlimits.cpp b/indra/newview/llfloaterscriptlimits.cpp index be18565670..14719a77f9 100755 --- a/indra/newview/llfloaterscriptlimits.cpp +++ b/indra/newview/llfloaterscriptlimits.cpp @@ -200,7 +200,7 @@ BOOL LLPanelScriptLimitsRegionMemory::getLandScriptResources() if (!url.empty()) { LLCoros::instance().launch("LLPanelScriptLimitsRegionMemory::getLandScriptResourcesCoro", - boost::bind(&LLPanelScriptLimitsRegionMemory::getLandScriptResourcesCoro, this, _1, url)); + boost::bind(&LLPanelScriptLimitsRegionMemory::getLandScriptResourcesCoro, this, url)); return TRUE; } else @@ -209,7 +209,7 @@ BOOL LLPanelScriptLimitsRegionMemory::getLandScriptResources() } } -void LLPanelScriptLimitsRegionMemory::getLandScriptResourcesCoro(LLCoros::self& self, std::string url) +void LLPanelScriptLimitsRegionMemory::getLandScriptResourcesCoro(std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -220,7 +220,7 @@ void LLPanelScriptLimitsRegionMemory::getLandScriptResourcesCoro(LLCoros::self& postData["parcel_id"] = mParcelId; - LLSD result = httpAdapter->postAndYield(self, httpRequest, url, postData); + LLSD result = httpAdapter->postAndYield(httpRequest, url, postData); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -240,27 +240,27 @@ void LLPanelScriptLimitsRegionMemory::getLandScriptResourcesCoro(LLCoros::self& { std::string urlResourceSummary = result["ScriptResourceSummary"].asString(); LLCoros::instance().launch("LLPanelScriptLimitsRegionMemory::getLandScriptSummaryCoro", - boost::bind(&LLPanelScriptLimitsRegionMemory::getLandScriptSummaryCoro, this, _1, urlResourceSummary)); + boost::bind(&LLPanelScriptLimitsRegionMemory::getLandScriptSummaryCoro, this, urlResourceSummary)); } if (result.has("ScriptResourceDetails")) { std::string urlResourceDetails = result["ScriptResourceDetails"].asString(); LLCoros::instance().launch("LLPanelScriptLimitsRegionMemory::getLandScriptDetailsCoro", - boost::bind(&LLPanelScriptLimitsRegionMemory::getLandScriptDetailsCoro, this, _1, urlResourceDetails)); + boost::bind(&LLPanelScriptLimitsRegionMemory::getLandScriptDetailsCoro, this, urlResourceDetails)); } } -void LLPanelScriptLimitsRegionMemory::getLandScriptSummaryCoro(LLCoros::self& self, std::string url) +void LLPanelScriptLimitsRegionMemory::getLandScriptSummaryCoro(std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("getLandScriptSummaryCoro", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLSD result = httpAdapter->getAndYield(self, httpRequest, url); + LLSD result = httpAdapter->getAndYield(httpRequest, url); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -305,14 +305,14 @@ void LLPanelScriptLimitsRegionMemory::getLandScriptSummaryCoro(LLCoros::self& se } -void LLPanelScriptLimitsRegionMemory::getLandScriptDetailsCoro(LLCoros::self& self, std::string url) +void LLPanelScriptLimitsRegionMemory::getLandScriptDetailsCoro(std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("getLandScriptDetailsCoro", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLSD result = httpAdapter->getAndYield(self, httpRequest, url); + LLSD result = httpAdapter->getAndYield(httpRequest, url); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -947,7 +947,7 @@ BOOL LLPanelScriptLimitsAttachment::requestAttachmentDetails() if (!url.empty()) { LLCoros::instance().launch("LLPanelScriptLimitsAttachment::getAttachmentLimitsCoro", - boost::bind(&LLPanelScriptLimitsAttachment::getAttachmentLimitsCoro, this, _1, url)); + boost::bind(&LLPanelScriptLimitsAttachment::getAttachmentLimitsCoro, this, url)); return TRUE; } else @@ -956,14 +956,14 @@ BOOL LLPanelScriptLimitsAttachment::requestAttachmentDetails() } } -void LLPanelScriptLimitsAttachment::getAttachmentLimitsCoro(LLCoros::self& self, std::string url) +void LLPanelScriptLimitsAttachment::getAttachmentLimitsCoro(std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("getAttachmentLimitsCoro", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLSD result = httpAdapter->getAndYield(self, httpRequest, url); + LLSD result = httpAdapter->getAndYield(httpRequest, url); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); diff --git a/indra/newview/llfloaterscriptlimits.h b/indra/newview/llfloaterscriptlimits.h index 030020087b..e3cbbd185f 100755 --- a/indra/newview/llfloaterscriptlimits.h +++ b/indra/newview/llfloaterscriptlimits.h @@ -132,9 +132,9 @@ private: std::vector mObjectListItems; - void getLandScriptResourcesCoro(LLCoros::self& self, std::string url); - void getLandScriptSummaryCoro(LLCoros::self& self, std::string url); - void getLandScriptDetailsCoro(LLCoros::self& self, std::string url); + void getLandScriptResourcesCoro(std::string url); + void getLandScriptSummaryCoro(std::string url); + void getLandScriptDetailsCoro(std::string url); protected: @@ -180,7 +180,7 @@ public: void clearList(); private: - void getAttachmentLimitsCoro(LLCoros::self& self, std::string url); + void getAttachmentLimitsCoro(std::string url); bool mGotAttachmentMemoryUsed; S32 mAttachmentMemoryMax; diff --git a/indra/newview/llfloatertos.cpp b/indra/newview/llfloatertos.cpp index 27938bfbc4..6dc08417d7 100755 --- a/indra/newview/llfloatertos.cpp +++ b/indra/newview/llfloatertos.cpp @@ -190,7 +190,7 @@ void LLFloaterTOS::handleMediaEvent(LLPluginClassMedia* /*self*/, EMediaEvent ev std::string url(getString("real_url")); LLCoros::instance().launch("LLFloaterTOS::testSiteIsAliveCoro", - boost::bind(&LLFloaterTOS::testSiteIsAliveCoro, this, _1, url)); + boost::bind(&LLFloaterTOS::testSiteIsAliveCoro, this, url)); } else if(mRealNavigateBegun) { @@ -202,7 +202,7 @@ void LLFloaterTOS::handleMediaEvent(LLPluginClassMedia* /*self*/, EMediaEvent ev } } -void LLFloaterTOS::testSiteIsAliveCoro(LLCoros::self& self, std::string url) +void LLFloaterTOS::testSiteIsAliveCoro(std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -214,7 +214,7 @@ void LLFloaterTOS::testSiteIsAliveCoro(LLCoros::self& self, std::string url) LL_INFOS("HttpCoroutineAdapter", "genericPostCoro") << "Generic POST for " << url << LL_ENDL; - LLSD result = httpAdapter->getAndYield(self, httpRequest, url); + LLSD result = httpAdapter->getAndYield(httpRequest, url); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); diff --git a/indra/newview/llfloatertos.h b/indra/newview/llfloatertos.h index 90bea2fe83..2748b20513 100755 --- a/indra/newview/llfloatertos.h +++ b/indra/newview/llfloatertos.h @@ -62,7 +62,7 @@ public: /*virtual*/ void handleMediaEvent(LLPluginClassMedia* self, EMediaEvent event); private: - void testSiteIsAliveCoro(LLCoros::self& self, std::string url); + void testSiteIsAliveCoro(std::string url); std::string mMessage; bool mLoadingScreenLoaded; diff --git a/indra/newview/llfloaterurlentry.cpp b/indra/newview/llfloaterurlentry.cpp index 110d760dc9..6683a6e6e6 100755 --- a/indra/newview/llfloaterurlentry.cpp +++ b/indra/newview/llfloaterurlentry.cpp @@ -194,7 +194,7 @@ void LLFloaterURLEntry::onBtnOK( void* userdata ) (scheme == "http" || scheme == "https")) { LLCoros::instance().launch("LLFloaterURLEntry::getMediaTypeCoro", - boost::bind(&LLFloaterURLEntry::getMediaTypeCoro, _1, media_url, self->getHandle())); + boost::bind(&LLFloaterURLEntry::getMediaTypeCoro, media_url, self->getHandle())); } else { @@ -208,7 +208,7 @@ void LLFloaterURLEntry::onBtnOK( void* userdata ) } // static -void LLFloaterURLEntry::getMediaTypeCoro(LLCoros::self& self, std::string url, LLHandle parentHandle) +void LLFloaterURLEntry::getMediaTypeCoro(std::string url, LLHandle parentHandle) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -220,7 +220,7 @@ void LLFloaterURLEntry::getMediaTypeCoro(LLCoros::self& self, std::string url, L LL_INFOS("HttpCoroutineAdapter", "genericPostCoro") << "Generic POST for " << url << LL_ENDL; - LLSD result = httpAdapter->getAndYield(self, httpRequest, url, httpOpts); + LLSD result = httpAdapter->getAndYield(httpRequest, url, httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); diff --git a/indra/newview/llfloaterurlentry.h b/indra/newview/llfloaterurlentry.h index 2f5afa653d..20f4604907 100755 --- a/indra/newview/llfloaterurlentry.h +++ b/indra/newview/llfloaterurlentry.h @@ -60,7 +60,7 @@ private: static void onBtnClear(void*); bool callback_clear_url_list(const LLSD& notification, const LLSD& response); - static void getMediaTypeCoro(LLCoros::self& self, std::string url, LLHandle parentHandle); + static void getMediaTypeCoro(std::string url, LLHandle parentHandle); }; diff --git a/indra/newview/llgroupmgr.cpp b/indra/newview/llgroupmgr.cpp index 0fb39ab02e..edae0bfd19 100755 --- a/indra/newview/llgroupmgr.cpp +++ b/indra/newview/llgroupmgr.cpp @@ -1862,7 +1862,7 @@ void LLGroupMgr::sendGroupMemberEjects(const LLUUID& group_id, group_datap->mMemberVersion.generate(); } -void LLGroupMgr::getGroupBanRequestCoro(LLCoros::self& self, std::string url, LLUUID groupId) +void LLGroupMgr::getGroupBanRequestCoro(std::string url, LLUUID groupId) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -1871,7 +1871,7 @@ void LLGroupMgr::getGroupBanRequestCoro(LLCoros::self& self, std::string url, LL std::string finalUrl = url + "?group_id=" + groupId.asString(); - LLSD result = httpAdapter->getAndYield(self, httpRequest, finalUrl); + LLSD result = httpAdapter->getAndYield(httpRequest, finalUrl); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -1890,7 +1890,7 @@ void LLGroupMgr::getGroupBanRequestCoro(LLCoros::self& self, std::string url, LL } } -void LLGroupMgr::postGroupBanRequestCoro(LLCoros::self& self, std::string url, LLUUID groupId, +void LLGroupMgr::postGroupBanRequestCoro(std::string url, LLUUID groupId, U32 action, uuid_vec_t banList, bool update) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); @@ -1922,7 +1922,7 @@ void LLGroupMgr::postGroupBanRequestCoro(LLCoros::self& self, std::string url, L LL_WARNS() << "post: " << ll_pretty_print_sd(postData) << LL_ENDL; - LLSD result = httpAdapter->postAndYield(self, httpRequest, finalUrl, postData, httpOptions, httpHeaders); + LLSD result = httpAdapter->postAndYield(httpRequest, finalUrl, postData, httpOptions, httpHeaders); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -1942,7 +1942,7 @@ void LLGroupMgr::postGroupBanRequestCoro(LLCoros::self& self, std::string url, L if (update) { - getGroupBanRequestCoro(self, url, groupId); + getGroupBanRequestCoro(url, groupId); } } @@ -1979,11 +1979,11 @@ void LLGroupMgr::sendGroupBanRequest( EBanRequestType request_type, { case REQUEST_GET: LLCoros::instance().launch("LLGroupMgr::getGroupBanRequestCoro", - boost::bind(&LLGroupMgr::getGroupBanRequestCoro, this, _1, cap_url, group_id)); + boost::bind(&LLGroupMgr::getGroupBanRequestCoro, this, cap_url, group_id)); break; case REQUEST_POST: LLCoros::instance().launch("LLGroupMgr::postGroupBanRequestCoro", - boost::bind(&LLGroupMgr::postGroupBanRequestCoro, this, _1, cap_url, group_id, + boost::bind(&LLGroupMgr::postGroupBanRequestCoro, this, cap_url, group_id, action, ban_list, update)); break; case REQUEST_PUT: @@ -2028,7 +2028,7 @@ void LLGroupMgr::processGroupBanRequest(const LLSD& content) LLGroupMgr::getInstance()->notifyObservers(GC_BANLIST); } -void LLGroupMgr::groupMembersRequestCoro(LLCoros::self& self, std::string url, LLUUID groupId) +void LLGroupMgr::groupMembersRequestCoro(std::string url, LLUUID groupId) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -2041,7 +2041,7 @@ void LLGroupMgr::groupMembersRequestCoro(LLCoros::self& self, std::string url, L LLSD postData = LLSD::emptyMap(); postData["group_id"] = groupId; - LLSD result = httpAdapter->postAndYield(self, httpRequest, url, postData, httpOpts); + LLSD result = httpAdapter->postAndYield(httpRequest, url, postData, httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -2095,7 +2095,7 @@ void LLGroupMgr::sendCapGroupMembersRequest(const LLUUID& group_id) lastGroupMemberRequestFrame = gFrameCount; LLCoros::instance().launch("LLGroupMgr::groupMembersRequestCoro", - boost::bind(&LLGroupMgr::groupMembersRequestCoro, this, _1, cap_url, group_id)); + boost::bind(&LLGroupMgr::groupMembersRequestCoro, this, cap_url, group_id)); } diff --git a/indra/newview/llgroupmgr.h b/indra/newview/llgroupmgr.h index 1163923eff..fd0c2de854 100755 --- a/indra/newview/llgroupmgr.h +++ b/indra/newview/llgroupmgr.h @@ -428,11 +428,11 @@ public: void clearGroupData(const LLUUID& group_id); private: - void groupMembersRequestCoro(LLCoros::self& self, std::string url, LLUUID groupId); + void groupMembersRequestCoro(std::string url, LLUUID groupId); void processCapGroupMembersRequest(const LLSD& content); - void getGroupBanRequestCoro(LLCoros::self& self, std::string url, LLUUID groupId); - void postGroupBanRequestCoro(LLCoros::self& self, std::string url, LLUUID groupId, U32 action, uuid_vec_t banList, bool update); + void getGroupBanRequestCoro(std::string url, LLUUID groupId); + void postGroupBanRequestCoro(std::string url, LLUUID groupId, U32 action, uuid_vec_t banList, bool update); static void processGroupBanRequest(const LLSD& content); diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp index 0e5c16752e..8d670d0b0a 100755 --- a/indra/newview/llimview.cpp +++ b/indra/newview/llimview.cpp @@ -79,8 +79,8 @@ const static std::string NEARBY_P2P_BY_AGENT("nearby_P2P_by_agent"); /** Timeout of outgoing session initialization (in seconds) */ const static U32 SESSION_INITIALIZATION_TIMEOUT = 30; -void startConfrenceCoro(LLCoros::self& self, std::string url, LLUUID tempSessionId, LLUUID creatorId, LLUUID otherParticipantId, LLSD agents); -void chatterBoxInvitationCoro(LLCoros::self& self, std::string url, LLUUID sessionId, LLIMMgr::EInvitationType invitationType); +void startConfrenceCoro(std::string url, LLUUID tempSessionId, LLUUID creatorId, LLUUID otherParticipantId, LLSD agents); +void chatterBoxInvitationCoro(std::string url, LLUUID sessionId, LLIMMgr::EInvitationType invitationType); void start_deprecated_conference_chat(const LLUUID& temp_session_id, const LLUUID& creator_id, const LLUUID& other_participant_id, const LLSD& agents_to_invite); std::string LLCallDialogManager::sPreviousSessionlName = ""; @@ -389,7 +389,7 @@ void on_new_message(const LLSD& msg) notify_of_message(msg, false); } -void startConfrenceCoro(LLCoros::self& self, std::string url, +void startConfrenceCoro(std::string url, LLUUID tempSessionId, LLUUID creatorId, LLUUID otherParticipantId, LLSD agents) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); @@ -402,7 +402,7 @@ void startConfrenceCoro(LLCoros::self& self, std::string url, postData["session-id"] = tempSessionId; postData["params"] = agents; - LLSD result = httpAdapter->postAndYield(self, httpRequest, url, postData); + LLSD result = httpAdapter->postAndYield(httpRequest, url, postData); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -430,7 +430,7 @@ void startConfrenceCoro(LLCoros::self& self, std::string url, } } -void chatterBoxInvitationCoro(LLCoros::self& self, std::string url, LLUUID sessionId, LLIMMgr::EInvitationType invitationType) +void chatterBoxInvitationCoro(std::string url, LLUUID sessionId, LLIMMgr::EInvitationType invitationType) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -441,7 +441,7 @@ void chatterBoxInvitationCoro(LLCoros::self& self, std::string url, LLUUID sessi postData["method"] = "accept invitation"; postData["session-id"] = sessionId; - LLSD result = httpAdapter->postAndYield(self, httpRequest, url, postData); + LLSD result = httpAdapter->postAndYield(httpRequest, url, postData); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -1623,7 +1623,7 @@ bool LLIMModel::sendStartSession( "ChatSessionRequest"); LLCoros::instance().launch("startConfrenceCoro", - boost::bind(&startConfrenceCoro, _1, url, + boost::bind(&startConfrenceCoro, url, temp_session_id, gAgent.getID(), other_participant_id, agents)); } else @@ -2468,7 +2468,7 @@ void LLIncomingCallDialog::processCallResponse(S32 response, const LLSD &payload if (voice) { LLCoros::instance().launch("chatterBoxInvitationCoro", - boost::bind(&chatterBoxInvitationCoro, _1, url, + boost::bind(&chatterBoxInvitationCoro, url, session_id, inv_type)); // send notification message to the corresponding chat @@ -2555,7 +2555,7 @@ bool inviteUserResponse(const LLSD& notification, const LLSD& response) "ChatSessionRequest"); LLCoros::instance().launch("chatterBoxInvitationCoro", - boost::bind(&chatterBoxInvitationCoro, _1, url, + boost::bind(&chatterBoxInvitationCoro, url, session_id, inv_type)); } } @@ -3646,7 +3646,7 @@ public: if ( url != "" ) { LLCoros::instance().launch("chatterBoxInvitationCoro", - boost::bind(&chatterBoxInvitationCoro, _1, url, + boost::bind(&chatterBoxInvitationCoro, url, session_id, LLIMMgr::INVITATION_TYPE_INSTANT_MESSAGE)); } } //end if invitation has instant message diff --git a/indra/newview/llinventorymodel.cpp b/indra/newview/llinventorymodel.cpp index 6d21dd4ba7..25450f2317 100755 --- a/indra/newview/llinventorymodel.cpp +++ b/indra/newview/llinventorymodel.cpp @@ -578,7 +578,7 @@ LLUUID LLInventoryModel::createNewCategory(const LLUUID& parent_id, LL_DEBUGS(LOG_INV) << "create category request: " << ll_pretty_print_sd(request) << LL_ENDL; LLCoros::instance().launch("LLInventoryModel::createNewCategoryCoro", - boost::bind(&LLInventoryModel::createNewCategoryCoro, this, _1, url, body, callback)); + boost::bind(&LLInventoryModel::createNewCategoryCoro, this, url, body, callback)); return LLUUID::null; } @@ -607,7 +607,7 @@ LLUUID LLInventoryModel::createNewCategory(const LLUUID& parent_id, return id; } -void LLInventoryModel::createNewCategoryCoro(LLCoros::self& self, std::string url, LLSD postData, inventory_func_type callback) +void LLInventoryModel::createNewCategoryCoro(std::string url, LLSD postData, inventory_func_type callback) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -620,7 +620,7 @@ void LLInventoryModel::createNewCategoryCoro(LLCoros::self& self, std::string ur LL_INFOS("HttpCoroutineAdapter", "genericPostCoro") << "Generic POST for " << url << LL_ENDL; - LLSD result = httpAdapter->postAndYield(self, httpRequest, url, postData, httpOpts); + LLSD result = httpAdapter->postAndYield(httpRequest, url, postData, httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); diff --git a/indra/newview/llinventorymodel.h b/indra/newview/llinventorymodel.h index 26ee06535a..1f1c686ef1 100755 --- a/indra/newview/llinventorymodel.h +++ b/indra/newview/llinventorymodel.h @@ -444,7 +444,7 @@ protected: void addCategory(LLViewerInventoryCategory* category); void addItem(LLViewerInventoryItem* item); - void createNewCategoryCoro(LLCoros::self& self, std::string url, LLSD postData, inventory_func_type callback); + void createNewCategoryCoro(std::string url, LLSD postData, inventory_func_type callback); /** Mutators ** ** diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index bd77912a6c..38c4382654 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -126,7 +126,7 @@ namespace LLMarketplaceImport // Responders #if 1 - void marketplacePostCoro(LLCoros::self& self, std::string url) + void marketplacePostCoro(std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -144,7 +144,7 @@ namespace LLMarketplaceImport httpHeaders->append(HTTP_OUT_HEADER_CONTENT_TYPE, HTTP_CONTENT_XML); httpHeaders->append(HTTP_OUT_HEADER_USER_AGENT, LLViewerMedia::getCurrentUserAgent()); - LLSD result = httpAdapter->postAndYield(self, httpRequest, url, LLSD(), httpOpts, httpHeaders); + LLSD result = httpAdapter->postAndYield(httpRequest, url, LLSD(), httpOpts, httpHeaders); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -237,7 +237,7 @@ namespace LLMarketplaceImport #endif #if 1 - void marketplaceGetCoro(LLCoros::self& self, std::string url, bool buildHeaders) + void marketplaceGetCoro(std::string url, bool buildHeaders) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -263,7 +263,7 @@ namespace LLMarketplaceImport httpHeaders = LLViewerMedia::getHttpHeaders(); } - LLSD result = httpAdapter->getAndYield(self, httpRequest, url, httpOpts, httpHeaders); + LLSD result = httpAdapter->getAndYield(httpRequest, url, httpOpts, httpHeaders); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -405,7 +405,7 @@ namespace LLMarketplaceImport #if 1 LLCoros::instance().launch("marketplaceGetCoro", - boost::bind(&marketplaceGetCoro, _1, url, false)); + boost::bind(&marketplaceGetCoro, url, false)); #else if (gSavedSettings.getBOOL("InventoryOutboxLogging")) @@ -439,7 +439,7 @@ namespace LLMarketplaceImport #if 1 LLCoros::instance().launch("marketplaceGetCoro", - boost::bind(&marketplaceGetCoro, _1, url, true)); + boost::bind(&marketplaceGetCoro, url, true)); #else // Make the headers for the post @@ -482,7 +482,7 @@ namespace LLMarketplaceImport #if 1 LLCoros::instance().launch("marketplacePostCoro", - boost::bind(&marketplacePostCoro, _1, url)); + boost::bind(&marketplacePostCoro, url)); #else // Make the headers for the post diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index 5dc90c987d..2e6937a79f 100755 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -225,7 +225,7 @@ void LLPathfindingManager::requestGetNavMeshForRegion(LLViewerRegion *pRegion, b U64 regionHandle = pRegion->getHandle(); std::string coroname = LLCoros::instance().launch("LLPathfindingManager::navMeshStatusRequestCoro", - boost::bind(&LLPathfindingManager::navMeshStatusRequestCoro, this, _1, navMeshStatusURL, regionHandle, pIsGetStatusOnly)); + boost::bind(&LLPathfindingManager::navMeshStatusRequestCoro, this, navMeshStatusURL, regionHandle, pIsGetStatusOnly)); } } @@ -259,12 +259,12 @@ void LLPathfindingManager::requestGetLinksets(request_id_t pRequestId, object_re LinksetsResponder::ptr_t linksetsResponderPtr(new LinksetsResponder(pRequestId, pLinksetsCallback, true, doRequestTerrain)); std::string coroname = LLCoros::instance().launch("LLPathfindingManager::linksetObjectsCoro", - boost::bind(&LLPathfindingManager::linksetObjectsCoro, this, _1, objectLinksetsURL, linksetsResponderPtr, LLSD())); + boost::bind(&LLPathfindingManager::linksetObjectsCoro, this, objectLinksetsURL, linksetsResponderPtr, LLSD())); if (doRequestTerrain) { std::string coroname = LLCoros::instance().launch("LLPathfindingManager::linksetTerrainCoro", - boost::bind(&LLPathfindingManager::linksetTerrainCoro, this, _1, terrainLinksetsURL, linksetsResponderPtr, LLSD())); + boost::bind(&LLPathfindingManager::linksetTerrainCoro, this, terrainLinksetsURL, linksetsResponderPtr, LLSD())); } } } @@ -308,13 +308,13 @@ void LLPathfindingManager::requestSetLinksets(request_id_t pRequestId, const LLP if (!objectPostData.isUndefined()) { std::string coroname = LLCoros::instance().launch("LLPathfindingManager::linksetObjectsCoro", - boost::bind(&LLPathfindingManager::linksetObjectsCoro, this, _1, objectLinksetsURL, linksetsResponderPtr, objectPostData)); + boost::bind(&LLPathfindingManager::linksetObjectsCoro, this, objectLinksetsURL, linksetsResponderPtr, objectPostData)); } if (!terrainPostData.isUndefined()) { std::string coroname = LLCoros::instance().launch("LLPathfindingManager::linksetTerrainCoro", - boost::bind(&LLPathfindingManager::linksetTerrainCoro, this, _1, terrainLinksetsURL, linksetsResponderPtr, terrainPostData)); + boost::bind(&LLPathfindingManager::linksetTerrainCoro, this, terrainLinksetsURL, linksetsResponderPtr, terrainPostData)); } } } @@ -347,7 +347,7 @@ void LLPathfindingManager::requestGetCharacters(request_id_t pRequestId, object_ pCharactersCallback(pRequestId, kRequestStarted, emptyCharacterListPtr); std::string coroname = LLCoros::instance().launch("LLPathfindingManager::charactersCoro", - boost::bind(&LLPathfindingManager::charactersCoro, this, _1, charactersURL, pRequestId, pCharactersCallback)); + boost::bind(&LLPathfindingManager::charactersCoro, this, charactersURL, pRequestId, pCharactersCallback)); } } } @@ -381,7 +381,7 @@ void LLPathfindingManager::requestGetAgentState() llassert(!agentStateURL.empty()); std::string coroname = LLCoros::instance().launch("LLPathfindingManager::navAgentStateRequestCoro", - boost::bind(&LLPathfindingManager::navAgentStateRequestCoro, this, _1, agentStateURL)); + boost::bind(&LLPathfindingManager::navAgentStateRequestCoro, this, agentStateURL)); } } } @@ -404,7 +404,7 @@ void LLPathfindingManager::requestRebakeNavMesh(rebake_navmesh_callback_t pRebak llassert(!navMeshStatusURL.empty()); std::string coroname = LLCoros::instance().launch("LLPathfindingManager::navMeshRebakeCoro", - boost::bind(&LLPathfindingManager::navMeshRebakeCoro, this, _1, navMeshStatusURL, pRebakeNavMeshCallback)); + boost::bind(&LLPathfindingManager::navMeshRebakeCoro, this, navMeshStatusURL, pRebakeNavMeshCallback)); } } @@ -448,7 +448,7 @@ void LLPathfindingManager::handleDeferredGetCharactersForRegion(const LLUUID &pR } } -void LLPathfindingManager::navMeshStatusRequestCoro(LLCoros::self& self, std::string url, U64 regionHandle, bool isGetStatusOnly) +void LLPathfindingManager::navMeshStatusRequestCoro(std::string url, U64 regionHandle, bool isGetStatusOnly) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -464,7 +464,7 @@ void LLPathfindingManager::navMeshStatusRequestCoro(LLCoros::self& self, std::st LLUUID regionUUID = region->getRegionID(); region = NULL; - LLSD result = httpAdapter->getAndYield(self, httpRequest, url); + LLSD result = httpAdapter->getAndYield(httpRequest, url); region = LLWorld::getInstance()->getRegionFromHandle(regionHandle); @@ -519,7 +519,7 @@ void LLPathfindingManager::navMeshStatusRequestCoro(LLCoros::self& self, std::st navMeshPtr->handleNavMeshStart(navMeshStatus); LLSD postData; - result = httpAdapter->postAndYield(self, httpRequest, navMeshURL, postData); + result = httpAdapter->postAndYield(httpRequest, navMeshURL, postData); U32 navMeshVersion = navMeshStatus.getVersion(); @@ -538,14 +538,14 @@ void LLPathfindingManager::navMeshStatusRequestCoro(LLCoros::self& self, std::st } -void LLPathfindingManager::navAgentStateRequestCoro(LLCoros::self& self, std::string url) +void LLPathfindingManager::navAgentStateRequestCoro(std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("NavAgentStateRequest", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLSD result = httpAdapter->getAndYield(self, httpRequest, url); + LLSD result = httpAdapter->getAndYield(httpRequest, url); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -566,7 +566,7 @@ void LLPathfindingManager::navAgentStateRequestCoro(LLCoros::self& self, std::st handleAgentState(canRebake); } -void LLPathfindingManager::navMeshRebakeCoro(LLCoros::self& self, std::string url, rebake_navmesh_callback_t rebakeNavMeshCallback) +void LLPathfindingManager::navMeshRebakeCoro(std::string url, rebake_navmesh_callback_t rebakeNavMeshCallback) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -577,7 +577,7 @@ void LLPathfindingManager::navMeshRebakeCoro(LLCoros::self& self, std::string ur LLSD postData = LLSD::emptyMap(); postData["command"] = "rebuild"; - LLSD result = httpAdapter->postAndYield(self, httpRequest, url, postData); + LLSD result = httpAdapter->postAndYield(httpRequest, url, postData); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -595,7 +595,7 @@ void LLPathfindingManager::navMeshRebakeCoro(LLCoros::self& self, std::string ur // If called with putData undefined this coroutine will issue a get. If there // is data in putData it will be PUT to the URL. -void LLPathfindingManager::linksetObjectsCoro(LLCoros::self &self, std::string url, LinksetsResponder::ptr_t linksetsResponsderPtr, LLSD putData) const +void LLPathfindingManager::linksetObjectsCoro(std::string url, LinksetsResponder::ptr_t linksetsResponsderPtr, LLSD putData) const { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -606,11 +606,11 @@ void LLPathfindingManager::linksetObjectsCoro(LLCoros::self &self, std::string u if (putData.isUndefined()) { - result = httpAdapter->getAndYield(self, httpRequest, url); + result = httpAdapter->getAndYield(httpRequest, url); } else { - result = httpAdapter->putAndYield(self, httpRequest, url, putData); + result = httpAdapter->putAndYield(httpRequest, url, putData); } LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; @@ -631,7 +631,7 @@ void LLPathfindingManager::linksetObjectsCoro(LLCoros::self &self, std::string u // If called with putData undefined this coroutine will issue a GET. If there // is data in putData it will be PUT to the URL. -void LLPathfindingManager::linksetTerrainCoro(LLCoros::self &self, std::string url, LinksetsResponder::ptr_t linksetsResponsderPtr, LLSD putData) const +void LLPathfindingManager::linksetTerrainCoro(std::string url, LinksetsResponder::ptr_t linksetsResponsderPtr, LLSD putData) const { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -642,11 +642,11 @@ void LLPathfindingManager::linksetTerrainCoro(LLCoros::self &self, std::string u if (putData.isUndefined()) { - result = httpAdapter->getAndYield(self, httpRequest, url); + result = httpAdapter->getAndYield(httpRequest, url); } else { - result = httpAdapter->putAndYield(self, httpRequest, url, putData); + result = httpAdapter->putAndYield(httpRequest, url, putData); } LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; @@ -666,14 +666,14 @@ void LLPathfindingManager::linksetTerrainCoro(LLCoros::self &self, std::string u } -void LLPathfindingManager::charactersCoro(LLCoros::self &self, std::string url, request_id_t requestId, object_request_callback_t callback) const +void LLPathfindingManager::charactersCoro(std::string url, request_id_t requestId, object_request_callback_t callback) const { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("LinksetTerrain", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLSD result = httpAdapter->getAndYield(self, httpRequest, url); + LLSD result = httpAdapter->getAndYield(httpRequest, url); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); diff --git a/indra/newview/llpathfindingmanager.h b/indra/newview/llpathfindingmanager.h index abf611801c..e8fad590ba 100755 --- a/indra/newview/llpathfindingmanager.h +++ b/indra/newview/llpathfindingmanager.h @@ -104,12 +104,12 @@ private: void handleDeferredGetLinksetsForRegion(const LLUUID &pRegionUUID, request_id_t pRequestId, object_request_callback_t pLinksetsCallback) const; void handleDeferredGetCharactersForRegion(const LLUUID &pRegionUUID, request_id_t pRequestId, object_request_callback_t pCharactersCallback) const; - void navMeshStatusRequestCoro(LLCoros::self& self, std::string url, U64 regionHandle, bool isGetStatusOnly); - void navAgentStateRequestCoro(LLCoros::self& self, std::string url); - void navMeshRebakeCoro(LLCoros::self& self, std::string url, rebake_navmesh_callback_t rebakeNavMeshCallback); - void linksetObjectsCoro(LLCoros::self &self, std::string url, boost::shared_ptr linksetsResponsderPtr, LLSD putData) const; - void linksetTerrainCoro(LLCoros::self &self, std::string url, boost::shared_ptr linksetsResponsderPtr, LLSD putData) const; - void charactersCoro(LLCoros::self &self, std::string url, request_id_t requestId, object_request_callback_t callback) const; + void navMeshStatusRequestCoro(std::string url, U64 regionHandle, bool isGetStatusOnly); + void navAgentStateRequestCoro(std::string url); + void navMeshRebakeCoro(std::string url, rebake_navmesh_callback_t rebakeNavMeshCallback); + void linksetObjectsCoro(std::string url, boost::shared_ptr linksetsResponsderPtr, LLSD putData) const; + void linksetTerrainCoro(std::string url, boost::shared_ptr linksetsResponsderPtr, LLSD putData) const; + void charactersCoro(std::string url, request_id_t requestId, object_request_callback_t callback) const; //void handleNavMeshStatusRequest(const LLPathfindingNavMeshStatus &pNavMeshStatus, LLViewerRegion *pRegion, bool pIsGetStatusOnly); void handleNavMeshStatusUpdate(const LLPathfindingNavMeshStatus &pNavMeshStatus); diff --git a/indra/newview/llproductinforequest.cpp b/indra/newview/llproductinforequest.cpp index fd948765b3..467e9df482 100755 --- a/indra/newview/llproductinforequest.cpp +++ b/indra/newview/llproductinforequest.cpp @@ -45,7 +45,7 @@ void LLProductInfoRequestManager::initSingleton() if (!url.empty()) { LLCoros::instance().launch("LLProductInfoRequestManager::getLandDescriptionsCoro", - boost::bind(&LLProductInfoRequestManager::getLandDescriptionsCoro, this, _1, url)); + boost::bind(&LLProductInfoRequestManager::getLandDescriptionsCoro, this, url)); } } @@ -66,14 +66,14 @@ std::string LLProductInfoRequestManager::getDescriptionForSku(const std::string& return LLTrans::getString("land_type_unknown"); } -void LLProductInfoRequestManager::getLandDescriptionsCoro(LLCoros::self& self, std::string url) +void LLProductInfoRequestManager::getLandDescriptionsCoro(std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("genericPostCoro", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLSD result = httpAdapter->getAndYield(self, httpRequest, url); + LLSD result = httpAdapter->getAndYield(httpRequest, url); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); diff --git a/indra/newview/llproductinforequest.h b/indra/newview/llproductinforequest.h index 3ddae95a93..75dbf220d1 100755 --- a/indra/newview/llproductinforequest.h +++ b/indra/newview/llproductinforequest.h @@ -49,7 +49,7 @@ private: friend class LLSingleton; /* virtual */ void initSingleton(); - void getLandDescriptionsCoro(LLCoros::self& self, std::string url); + void getLandDescriptionsCoro(std::string url); LLSD mSkuDescriptions; }; diff --git a/indra/newview/llremoteparcelrequest.cpp b/indra/newview/llremoteparcelrequest.cpp index 7e8e9ac18e..06bf90c7cb 100755 --- a/indra/newview/llremoteparcelrequest.cpp +++ b/indra/newview/llremoteparcelrequest.cpp @@ -170,7 +170,7 @@ bool LLRemoteParcelInfoProcessor::requestRegionParcelInfo(const std::string &url if (!url.empty()) { LLCoros::instance().launch("LLRemoteParcelInfoProcessor::regionParcelInfoCoro", - boost::bind(&LLRemoteParcelInfoProcessor::regionParcelInfoCoro, this, _1, url, + boost::bind(&LLRemoteParcelInfoProcessor::regionParcelInfoCoro, this, url, regionId, regionPos, globalPos, observerHandle)); return true; } @@ -178,7 +178,7 @@ bool LLRemoteParcelInfoProcessor::requestRegionParcelInfo(const std::string &url return false; } -void LLRemoteParcelInfoProcessor::regionParcelInfoCoro(LLCoros::self& self, std::string url, +void LLRemoteParcelInfoProcessor::regionParcelInfoCoro(std::string url, LLUUID regionId, LLVector3 posRegion, LLVector3d posGlobal, LLHandle observerHandle) { @@ -200,7 +200,7 @@ void LLRemoteParcelInfoProcessor::regionParcelInfoCoro(LLCoros::self& self, std: bodyData["region_handle"] = ll_sd_from_U64(regionHandle); } - LLSD result = httpAdapter->postAndYield(self, httpRequest, url, bodyData); + LLSD result = httpAdapter->postAndYield(httpRequest, url, bodyData); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); diff --git a/indra/newview/llremoteparcelrequest.h b/indra/newview/llremoteparcelrequest.h index 982a1590e5..cb5af50c5f 100755 --- a/indra/newview/llremoteparcelrequest.h +++ b/indra/newview/llremoteparcelrequest.h @@ -91,7 +91,7 @@ private: typedef std::multimap > observer_multimap_t; observer_multimap_t mObservers; - void regionParcelInfoCoro(LLCoros::self& self, std::string url, LLUUID regionId, LLVector3 posRegion, LLVector3d posGlobal, LLHandle observerHandle); + void regionParcelInfoCoro(std::string url, LLUUID regionId, LLVector3 posRegion, LLVector3d posGlobal, LLHandle observerHandle); }; #endif // LL_LLREMOTEPARCELREQUEST_H diff --git a/indra/newview/llspeakers.cpp b/indra/newview/llspeakers.cpp index 9a9739c9cb..3b060d8343 100755 --- a/indra/newview/llspeakers.cpp +++ b/indra/newview/llspeakers.cpp @@ -841,7 +841,7 @@ void LLIMSpeakerMgr::toggleAllowTextChat(const LLUUID& speaker_id) data["params"]["mute_info"]["text"] = !speakerp->mModeratorMutedText; LLCoros::instance().launch("LLIMSpeakerMgr::moderationActionCoro", - boost::bind(&LLIMSpeakerMgr::moderationActionCoro, this, _1, url, data)); + boost::bind(&LLIMSpeakerMgr::moderationActionCoro, this, url, data)); } void LLIMSpeakerMgr::moderateVoiceParticipant(const LLUUID& avatar_id, bool unmute) @@ -866,10 +866,10 @@ void LLIMSpeakerMgr::moderateVoiceParticipant(const LLUUID& avatar_id, bool unmu data["params"]["mute_info"]["voice"] = !unmute; LLCoros::instance().launch("LLIMSpeakerMgr::moderationActionCoro", - boost::bind(&LLIMSpeakerMgr::moderationActionCoro, this, _1, url, data)); + boost::bind(&LLIMSpeakerMgr::moderationActionCoro, this, url, data)); } -void LLIMSpeakerMgr::moderationActionCoro(LLCoros::self& self, std::string url, LLSD action) +void LLIMSpeakerMgr::moderationActionCoro(std::string url, LLSD action) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -881,7 +881,7 @@ void LLIMSpeakerMgr::moderationActionCoro(LLCoros::self& self, std::string url, LLUUID sessionId = action["session-id"]; - LLSD result = httpAdapter->postAndYield(self, httpRequest, url, action, httpOpts); + LLSD result = httpAdapter->postAndYield(httpRequest, url, action, httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -948,7 +948,7 @@ void LLIMSpeakerMgr::moderateVoiceSession(const LLUUID& session_id, bool disallo data["params"]["update_info"]["moderated_mode"]["voice"] = disallow_voice; LLCoros::instance().launch("LLIMSpeakerMgr::moderationActionCoro", - boost::bind(&LLIMSpeakerMgr::moderationActionCoro, this, _1, url, data)); + boost::bind(&LLIMSpeakerMgr::moderationActionCoro, this, url, data)); } void LLIMSpeakerMgr::forceVoiceModeratedMode(bool should_be_muted) diff --git a/indra/newview/llspeakers.h b/indra/newview/llspeakers.h index 1f3b2f584c..5cff70f377 100755 --- a/indra/newview/llspeakers.h +++ b/indra/newview/llspeakers.h @@ -335,7 +335,7 @@ protected: */ void forceVoiceModeratedMode(bool should_be_muted); - void moderationActionCoro(LLCoros::self& self, std::string url, LLSD action); + void moderationActionCoro(std::string url, LLSD action); }; diff --git a/indra/newview/llsyntaxid.cpp b/indra/newview/llsyntaxid.cpp index d2197dcb4f..7f286044d6 100644 --- a/indra/newview/llsyntaxid.cpp +++ b/indra/newview/llsyntaxid.cpp @@ -108,14 +108,14 @@ bool LLSyntaxIdLSL::syntaxIdChanged() void LLSyntaxIdLSL::fetchKeywordsFile(const std::string& filespec) { LLCoros::instance().launch("LLSyntaxIdLSL::fetchKeywordsFileCoro", - boost::bind(&LLSyntaxIdLSL::fetchKeywordsFileCoro, this, _1, mCapabilityURL, filespec)); + boost::bind(&LLSyntaxIdLSL::fetchKeywordsFileCoro, this, mCapabilityURL, filespec)); LL_DEBUGS("SyntaxLSL") << "LSLSyntaxId capability URL is: " << mCapabilityURL << ". Filename to use is: '" << filespec << "'." << LL_ENDL; } //----------------------------------------------------------------------------- // fetchKeywordsFileCoro //----------------------------------------------------------------------------- -void LLSyntaxIdLSL::fetchKeywordsFileCoro(LLCoros::self& self, std::string url, std::string fileSpec) +void LLSyntaxIdLSL::fetchKeywordsFileCoro(std::string url, std::string fileSpec) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -129,7 +129,7 @@ void LLSyntaxIdLSL::fetchKeywordsFileCoro(LLCoros::self& self, std::string url, return; } - LLSD result = httpAdapter->getAndYield(self, httpRequest, url); + LLSD result = httpAdapter->getAndYield(httpRequest, url); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); diff --git a/indra/newview/llsyntaxid.h b/indra/newview/llsyntaxid.h index 47de94cea2..0afa6dc04b 100644 --- a/indra/newview/llsyntaxid.h +++ b/indra/newview/llsyntaxid.h @@ -57,7 +57,7 @@ private: void loadDefaultKeywordsIntoLLSD(); void loadKeywordsIntoLLSD(); - void fetchKeywordsFileCoro(LLCoros::self& self, std::string url, std::string fileSpec); + void fetchKeywordsFileCoro(std::string url, std::string fileSpec); void cacheFile(const std::string &fileSpec, const LLSD& content_ref); std::string mCapabilityURL; diff --git a/indra/newview/lltwitterconnect.cpp b/indra/newview/lltwitterconnect.cpp index 09435850c3..c6a0a15759 100644 --- a/indra/newview/lltwitterconnect.cpp +++ b/indra/newview/lltwitterconnect.cpp @@ -67,7 +67,7 @@ void toast_user_for_twitter_success() /////////////////////////////////////////////////////////////////////////////// // -void LLTwitterConnect::twitterConnectCoro(LLCoros::self& self, std::string requestToken, std::string oauthVerifier) +void LLTwitterConnect::twitterConnectCoro(std::string requestToken, std::string oauthVerifier) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -86,7 +86,7 @@ void LLTwitterConnect::twitterConnectCoro(LLCoros::self& self, std::string reque setConnectionState(LLTwitterConnect::TWITTER_CONNECTION_IN_PROGRESS); - LLSD result = httpAdapter->putAndYield(self, httpRequest, getTwitterConnectURL("/connection"), body, httpOpts); + LLSD result = httpAdapter->putAndYield(httpRequest, getTwitterConnectURL("/connection"), body, httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -157,7 +157,7 @@ bool LLTwitterConnect::testShareStatus(LLSD &result) return false; } -void LLTwitterConnect::twitterShareCoro(LLCoros::self& self, std::string route, LLSD share) +void LLTwitterConnect::twitterShareCoro(std::string route, LLSD share) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -170,7 +170,7 @@ void LLTwitterConnect::twitterShareCoro(LLCoros::self& self, std::string route, setConnectionState(LLTwitterConnect::TWITTER_POSTING); - LLSD result = httpAdapter->postAndYield(self, httpRequest, getTwitterConnectURL(route, true), share, httpOpts); + LLSD result = httpAdapter->postAndYield(httpRequest, getTwitterConnectURL(route, true), share, httpOpts); if (testShareStatus(result)) { @@ -180,7 +180,7 @@ void LLTwitterConnect::twitterShareCoro(LLCoros::self& self, std::string route, } } -void LLTwitterConnect::twitterShareImageCoro(LLCoros::self& self, LLPointer image, std::string status) +void LLTwitterConnect::twitterShareImageCoro(LLPointer image, std::string status) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -235,7 +235,7 @@ void LLTwitterConnect::twitterShareImageCoro(LLCoros::self& self, LLPointerpostAndYield(self, httpRequest, getTwitterConnectURL("/share/photo", true), raw, httpOpts, httpHeaders); + LLSD result = httpAdapter->postAndYield(httpRequest, getTwitterConnectURL("/share/photo", true), raw, httpOpts, httpHeaders); if (testShareStatus(result)) { @@ -247,7 +247,7 @@ void LLTwitterConnect::twitterShareImageCoro(LLCoros::self& self, LLPointerdeleteAndYield(self, httpRequest, getTwitterConnectURL("/connection"), httpOpts); + LLSD result = httpAdapter->deleteAndYield(httpRequest, getTwitterConnectURL("/connection"), httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -282,7 +282,7 @@ void LLTwitterConnect::twitterDisconnectCoro(LLCoros::self& self) /////////////////////////////////////////////////////////////////////////////// // -void LLTwitterConnect::twitterConnectedCoro(LLCoros::self& self, bool autoConnect) +void LLTwitterConnect::twitterConnectedCoro(bool autoConnect) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -293,7 +293,7 @@ void LLTwitterConnect::twitterConnectedCoro(LLCoros::self& self, bool autoConnec httpOpts->setFollowRedirects(false); setConnectionState(LLTwitterConnect::TWITTER_CONNECTION_IN_PROGRESS); - LLSD result = httpAdapter->getAndYield(self, httpRequest, getTwitterConnectURL("/connection", true), httpOpts); + LLSD result = httpAdapter->getAndYield(httpRequest, getTwitterConnectURL("/connection", true), httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -331,7 +331,7 @@ void LLTwitterConnect::twitterConnectedCoro(LLCoros::self& self, bool autoConnec /////////////////////////////////////////////////////////////////////////////// // -void LLTwitterConnect::twitterInfoCoro(LLCoros::self& self) +void LLTwitterConnect::twitterInfoCoro() { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -342,7 +342,7 @@ void LLTwitterConnect::twitterInfoCoro(LLCoros::self& self) httpOpts->setWantHeaders(true); httpOpts->setFollowRedirects(false); - LLSD result = httpAdapter->getAndYield(self, httpRequest, getTwitterConnectURL("/info", true), httpOpts); + LLSD result = httpAdapter->getAndYield(httpRequest, getTwitterConnectURL("/info", true), httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -425,19 +425,19 @@ std::string LLTwitterConnect::getTwitterConnectURL(const std::string& route, boo void LLTwitterConnect::connectToTwitter(const std::string& request_token, const std::string& oauth_verifier) { LLCoros::instance().launch("LLTwitterConnect::twitterConnectCoro", - boost::bind(&LLTwitterConnect::twitterConnectCoro, this, _1, request_token, oauth_verifier)); + boost::bind(&LLTwitterConnect::twitterConnectCoro, this, request_token, oauth_verifier)); } void LLTwitterConnect::disconnectFromTwitter() { LLCoros::instance().launch("LLTwitterConnect::twitterDisconnectCoro", - boost::bind(&LLTwitterConnect::twitterDisconnectCoro, this, _1)); + boost::bind(&LLTwitterConnect::twitterDisconnectCoro, this)); } void LLTwitterConnect::checkConnectionToTwitter(bool auto_connect) { LLCoros::instance().launch("LLTwitterConnect::twitterConnectedCoro", - boost::bind(&LLTwitterConnect::twitterConnectedCoro, this, _1, auto_connect)); + boost::bind(&LLTwitterConnect::twitterConnectedCoro, this, auto_connect)); } void LLTwitterConnect::loadTwitterInfo() @@ -445,7 +445,7 @@ void LLTwitterConnect::loadTwitterInfo() if(mRefreshInfo) { LLCoros::instance().launch("LLTwitterConnect::twitterInfoCoro", - boost::bind(&LLTwitterConnect::twitterInfoCoro, this, _1)); + boost::bind(&LLTwitterConnect::twitterInfoCoro, this)); } } @@ -456,13 +456,13 @@ void LLTwitterConnect::uploadPhoto(const std::string& image_url, const std::stri body["status"] = status; LLCoros::instance().launch("LLTwitterConnect::twitterShareCoro", - boost::bind(&LLTwitterConnect::twitterShareCoro, this, _1, "/share/photo", body)); + boost::bind(&LLTwitterConnect::twitterShareCoro, this, "/share/photo", body)); } void LLTwitterConnect::uploadPhoto(LLPointer image, const std::string& status) { LLCoros::instance().launch("LLTwitterConnect::twitterShareImageCoro", - boost::bind(&LLTwitterConnect::twitterShareImageCoro, this, _1, image, status)); + boost::bind(&LLTwitterConnect::twitterShareImageCoro, this, image, status)); } void LLTwitterConnect::updateStatus(const std::string& status) @@ -471,7 +471,7 @@ void LLTwitterConnect::updateStatus(const std::string& status) body["status"] = status; LLCoros::instance().launch("LLTwitterConnect::twitterShareCoro", - boost::bind(&LLTwitterConnect::twitterShareCoro, this, _1, "/share/status", body)); + boost::bind(&LLTwitterConnect::twitterShareCoro, this, "/share/status", body)); } void LLTwitterConnect::storeInfo(const LLSD& info) diff --git a/indra/newview/lltwitterconnect.h b/indra/newview/lltwitterconnect.h index 4d11118143..be481a17c1 100644 --- a/indra/newview/lltwitterconnect.h +++ b/indra/newview/lltwitterconnect.h @@ -98,12 +98,12 @@ private: static boost::scoped_ptr sContentWatcher; bool testShareStatus(LLSD &result); - void twitterConnectCoro(LLCoros::self& self, std::string requestToken, std::string oauthVerifier); - void twitterDisconnectCoro(LLCoros::self& self); - void twitterConnectedCoro(LLCoros::self& self, bool autoConnect); - void twitterInfoCoro(LLCoros::self& self); - void twitterShareCoro(LLCoros::self& self, std::string route, LLSD share); - void twitterShareImageCoro(LLCoros::self& self, LLPointer image, std::string status); + void twitterConnectCoro(std::string requestToken, std::string oauthVerifier); + void twitterDisconnectCoro(); + void twitterConnectedCoro(bool autoConnect); + void twitterInfoCoro(); + void twitterShareCoro(std::string route, LLSD share); + void twitterShareImageCoro(LLPointer image, std::string status); }; #endif // LL_LLTWITTERCONNECT_H diff --git a/indra/newview/llviewerassetupload.cpp b/indra/newview/llviewerassetupload.cpp index e2394e20d5..cd4e7c33ef 100644 --- a/indra/newview/llviewerassetupload.cpp +++ b/indra/newview/llviewerassetupload.cpp @@ -46,7 +46,7 @@ //========================================================================= /*static*/ -void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoros::self &self, LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &httpAdapter, const LLUUID &id, +void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &httpAdapter, const LLUUID &id, std::string url, NewResourceUploadInfo::ptr_t uploadInfo) { LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); @@ -68,7 +68,7 @@ void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoros::self &self, LLCore LLSD body = uploadInfo->generatePostBody(); - result = httpAdapter->postAndYield(self, httpRequest, url, body); + result = httpAdapter->postAndYield(httpRequest, url, body); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -82,7 +82,7 @@ void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoros::self &self, LLCore std::string uploader = result["uploader"].asString(); - result = httpAdapter->postFileAndYield(self, httpRequest, uploader, uploadInfo->getAssetId(), uploadInfo->getAssetType()); + result = httpAdapter->postFileAndYield(httpRequest, uploader, uploadInfo->getAssetId(), uploadInfo->getAssetType()); httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); diff --git a/indra/newview/llviewerassetupload.h b/indra/newview/llviewerassetupload.h index ad48be67a6..38167fc0c7 100644 --- a/indra/newview/llviewerassetupload.h +++ b/indra/newview/llviewerassetupload.h @@ -41,7 +41,7 @@ class LLViewerAssetUpload { public: - static void AssetInventoryUploadCoproc(LLCoros::self &self, LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &httpAdapter, const LLUUID &id, + static void AssetInventoryUploadCoproc(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &httpAdapter, const LLUUID &id, std::string url, NewResourceUploadInfo::ptr_t uploadInfo); private: diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp index 6d0fce46aa..f332a4e98e 100755 --- a/indra/newview/llviewermedia.cpp +++ b/indra/newview/llviewermedia.cpp @@ -1226,12 +1226,12 @@ void LLViewerMedia::setOpenIDCookie() std::string profileUrl = getProfileURL(""); LLCoros::instance().launch("LLViewerMedia::getOpenIDCookieCoro", - boost::bind(&LLViewerMedia::getOpenIDCookieCoro, _1, profileUrl)); + boost::bind(&LLViewerMedia::getOpenIDCookieCoro, profileUrl)); } } /*static*/ -void LLViewerMedia::getOpenIDCookieCoro(LLCoros::self& self, std::string url) +void LLViewerMedia::getOpenIDCookieCoro(std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -1280,7 +1280,7 @@ void LLViewerMedia::getOpenIDCookieCoro(LLCoros::self& self, std::string url) LL_DEBUGS("MediaAuth") << "Requesting " << url << LL_ENDL; LL_DEBUGS("MediaAuth") << "sOpenIDCookie = [" << sOpenIDCookie << "]" << LL_ENDL; - LLSD result = httpAdapter->getRawAndYield(self, httpRequest, url, httpOpts, httpHeaders); + LLSD result = httpAdapter->getRawAndYield(httpRequest, url, httpOpts, httpHeaders); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -1317,11 +1317,11 @@ void LLViewerMedia::openIDSetup(const std::string &openidUrl, const std::string LL_DEBUGS("MediaAuth") << "url = \"" << openidUrl << "\", token = \"" << openidToken << "\"" << LL_ENDL; LLCoros::instance().launch("LLViewerMedia::openIDSetupCoro", - boost::bind(&LLViewerMedia::openIDSetupCoro, _1, openidUrl, openidToken)); + boost::bind(&LLViewerMedia::openIDSetupCoro, openidUrl, openidToken)); } /*static*/ -void LLViewerMedia::openIDSetupCoro(LLCoros::self& self, std::string openidUrl, std::string openidToken) +void LLViewerMedia::openIDSetupCoro(std::string openidUrl, std::string openidToken) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -1347,7 +1347,7 @@ void LLViewerMedia::openIDSetupCoro(LLCoros::self& self, std::string openidUrl, bas << std::noskipws << openidToken; - LLSD result = httpAdapter->postRawAndYield(self, httpRequest, openidUrl, rawbody, httpOpts, httpHeaders); + LLSD result = httpAdapter->postRawAndYield(httpRequest, openidUrl, rawbody, httpOpts, httpHeaders); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -2553,7 +2553,7 @@ void LLViewerMediaImpl::navigateInternal() if(scheme.empty() || "http" == scheme || "https" == scheme) { LLCoros::instance().launch("LLViewerMediaImpl::mimeDiscoveryCoro", - boost::bind(&LLViewerMediaImpl::mimeDiscoveryCoro, this, _1, mMediaURL)); + boost::bind(&LLViewerMediaImpl::mimeDiscoveryCoro, this, mMediaURL)); } else if("data" == scheme || "file" == scheme || "about" == scheme) { @@ -2583,7 +2583,7 @@ void LLViewerMediaImpl::navigateInternal() } } -void LLViewerMediaImpl::mimeDiscoveryCoro(LLCoros::self& self, std::string url) +void LLViewerMediaImpl::mimeDiscoveryCoro(std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -2600,7 +2600,7 @@ void LLViewerMediaImpl::mimeDiscoveryCoro(LLCoros::self& self, std::string url) httpHeaders->append(HTTP_OUT_HEADER_ACCEPT, "*/*"); httpHeaders->append(HTTP_OUT_HEADER_COOKIE, ""); - LLSD result = httpAdapter->getRawAndYield(self, httpRequest, url, httpOpts, httpHeaders); + LLSD result = httpAdapter->getRawAndYield(httpRequest, url, httpOpts, httpHeaders); mMimeProbe.reset(); diff --git a/indra/newview/llviewermedia.h b/indra/newview/llviewermedia.h index ff9840627c..92d644c900 100755 --- a/indra/newview/llviewermedia.h +++ b/indra/newview/llviewermedia.h @@ -170,8 +170,8 @@ private: static void setOpenIDCookie(); static void onTeleportFinished(); - static void openIDSetupCoro(LLCoros::self& self, std::string openidUrl, std::string openidToken); - static void getOpenIDCookieCoro(LLCoros::self& self, std::string url); + static void openIDSetupCoro(std::string openidUrl, std::string openidToken); + static void getOpenIDCookieCoro(std::string url); static LLPluginCookieStore *sCookieStore; static LLURL sOpenIDURL; @@ -475,7 +475,7 @@ private: BOOL mIsUpdated ; std::list< LLVOVolume* > mObjectList ; - void mimeDiscoveryCoro(LLCoros::self& self, std::string url); + void mimeDiscoveryCoro(std::string url); LLCoreHttpUtil::HttpCoroutineAdapter::wptr_t mMimeProbe; bool mCanceling; diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index 4772dd144b..e9eb0e807a 100755 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -929,7 +929,7 @@ void upload_new_resource( if ( !url.empty() ) { - LLCoprocedureManager::CoProcedure_t proc = boost::bind(&LLViewerAssetUpload::AssetInventoryUploadCoproc, _1, _2, _3, url, uploadInfo); + LLCoprocedureManager::CoProcedure_t proc = boost::bind(&LLViewerAssetUpload::AssetInventoryUploadCoproc, _1, _2, url, uploadInfo); LLCoprocedureManager::getInstance()->enqueueCoprocedure("LLViewerAssetUpload::AssetInventoryUploadCoproc", proc); } diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp index 1c3e2aec01..2a009499d3 100755 --- a/indra/newview/llviewerobjectlist.cpp +++ b/indra/newview/llviewerobjectlist.cpp @@ -992,7 +992,7 @@ void LLViewerObjectList::fetchObjectCosts() if (!url.empty()) { LLCoros::instance().launch("LLViewerObjectList::fetchObjectCostsCoro", - boost::bind(&LLViewerObjectList::fetchObjectCostsCoro, this, _1, url)); + boost::bind(&LLViewerObjectList::fetchObjectCostsCoro, this, url)); } else { @@ -1014,7 +1014,7 @@ void LLViewerObjectList::reportObjectCostFailure(LLSD &objectList) } -void LLViewerObjectList::fetchObjectCostsCoro(LLCoros::self& self, std::string url) +void LLViewerObjectList::fetchObjectCostsCoro(std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -1052,7 +1052,7 @@ void LLViewerObjectList::fetchObjectCostsCoro(LLCoros::self& self, std::string u postData["object_ids"] = idList; - LLSD result = httpAdapter->postAndYield(self, httpRequest, url, postData); + LLSD result = httpAdapter->postAndYield(httpRequest, url, postData); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -1122,7 +1122,7 @@ void LLViewerObjectList::fetchPhysicsFlags() if (!url.empty()) { LLCoros::instance().launch("LLViewerObjectList::fetchPhisicsFlagsCoro", - boost::bind(&LLViewerObjectList::fetchPhisicsFlagsCoro, this, _1, url)); + boost::bind(&LLViewerObjectList::fetchPhisicsFlagsCoro, this, url)); } else { @@ -1143,7 +1143,7 @@ void LLViewerObjectList::reportPhysicsFlagFailure(LLSD &objectList) } } -void LLViewerObjectList::fetchPhisicsFlagsCoro(LLCoros::self& self, std::string url) +void LLViewerObjectList::fetchPhisicsFlagsCoro(std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -1181,7 +1181,7 @@ void LLViewerObjectList::fetchPhisicsFlagsCoro(LLCoros::self& self, std::string postData["object_ids"] = idList; - LLSD result = httpAdapter->postAndYield(self, httpRequest, url, postData); + LLSD result = httpAdapter->postAndYield(httpRequest, url, postData); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); diff --git a/indra/newview/llviewerobjectlist.h b/indra/newview/llviewerobjectlist.h index f849813f0a..9ec7c4bc22 100755 --- a/indra/newview/llviewerobjectlist.h +++ b/indra/newview/llviewerobjectlist.h @@ -232,10 +232,10 @@ protected: private: static void reportObjectCostFailure(LLSD &objectList); - void fetchObjectCostsCoro(LLCoros::self& self, std::string url); + void fetchObjectCostsCoro(std::string url); static void reportPhysicsFlagFailure(LLSD &obejectList); - void fetchPhisicsFlagsCoro(LLCoros::self& self, std::string url); + void fetchPhisicsFlagsCoro(std::string url); }; diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index f0015ceef1..b256482289 100755 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -219,12 +219,12 @@ public: LLVector3 mLastCameraOrigin; U32 mLastCameraUpdate; - void requestBaseCapabilitiesCoro(LLCoros::self& self, U64 regionHandle); - void requestBaseCapabilitiesCompleteCoro(LLCoros::self& self, U64 regionHandle); - void requestSimulatorFeatureCoro(LLCoros::self& self, std::string url, U64 regionHandle); + void requestBaseCapabilitiesCoro(U64 regionHandle); + void requestBaseCapabilitiesCompleteCoro(U64 regionHandle); + void requestSimulatorFeatureCoro(std::string url, U64 regionHandle); }; -void LLViewerRegionImpl::requestBaseCapabilitiesCoro(LLCoros::self& self, U64 regionHandle) +void LLViewerRegionImpl::requestBaseCapabilitiesCoro(U64 regionHandle) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -275,7 +275,7 @@ void LLViewerRegionImpl::requestBaseCapabilitiesCoro(LLCoros::self& self, U64 re << " (attempt #" << mSeedCapAttempts << ")" << LL_ENDL; regionp = NULL; - result = httpAdapter->postAndYield(self, httpRequest, url, capabilityNames); + result = httpAdapter->postAndYield(httpRequest, url, capabilityNames); regionp = LLWorld::getInstance()->getRegionFromHandle(regionHandle); if (!regionp) //region was removed @@ -332,7 +332,7 @@ void LLViewerRegionImpl::requestBaseCapabilitiesCoro(LLCoros::self& self, U64 re } -void LLViewerRegionImpl::requestBaseCapabilitiesCompleteCoro(LLCoros::self& self, U64 regionHandle) +void LLViewerRegionImpl::requestBaseCapabilitiesCompleteCoro(U64 regionHandle) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -365,7 +365,7 @@ void LLViewerRegionImpl::requestBaseCapabilitiesCompleteCoro(LLCoros::self& self LL_INFOS("AppInit", "Capabilities") << "Requesting second Seed from " << url << LL_ENDL; regionp = NULL; - result = httpAdapter->postAndYield(self, httpRequest, url, capabilityNames); + result = httpAdapter->postAndYield(httpRequest, url, capabilityNames); LLSD httpResults = result["http_result"]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -435,7 +435,7 @@ void LLViewerRegionImpl::requestBaseCapabilitiesCompleteCoro(LLCoros::self& self } -void LLViewerRegionImpl::requestSimulatorFeatureCoro(LLCoros::self& self, std::string url, U64 regionHandle) +void LLViewerRegionImpl::requestSimulatorFeatureCoro(std::string url, U64 regionHandle) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -464,7 +464,7 @@ void LLViewerRegionImpl::requestSimulatorFeatureCoro(LLCoros::self& self, std::s } regionp = NULL; - LLSD result = httpAdapter->getAndYield(self, httpRequest, url); + LLSD result = httpAdapter->getAndYield(httpRequest, url); LLSD httpResults = result["http_result"]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -2908,7 +2908,7 @@ void LLViewerRegion::setSeedCapability(const std::string& url) //to the "original" seed cap received and determine why there is problem! std::string coroname = LLCoros::instance().launch("LLEnvironmentRequest::requestBaseCapabilitiesCompleteCoro", - boost::bind(&LLViewerRegionImpl::requestBaseCapabilitiesCompleteCoro, mImpl, _1, getHandle())); + boost::bind(&LLViewerRegionImpl::requestBaseCapabilitiesCompleteCoro, mImpl, getHandle())); return; } @@ -2920,7 +2920,7 @@ void LLViewerRegion::setSeedCapability(const std::string& url) std::string coroname = LLCoros::instance().launch("LLEnvironmentRequest::environmentRequestCoro", - boost::bind(&LLViewerRegionImpl::requestBaseCapabilitiesCoro, mImpl, _1, getHandle())); + boost::bind(&LLViewerRegionImpl::requestBaseCapabilitiesCoro, mImpl, getHandle())); LL_INFOS("AppInit", "Capabilities") << "Launching " << coroname << " requesting seed capabilities from " << url << LL_ENDL; } @@ -2947,7 +2947,7 @@ void LLViewerRegion::setCapability(const std::string& name, const std::string& u // kick off a request for simulator features std::string coroname = LLCoros::instance().launch("LLViewerRegionImpl::requestSimulatorFeatureCoro", - boost::bind(&LLViewerRegionImpl::requestSimulatorFeatureCoro, mImpl, _1, url, getHandle())); + boost::bind(&LLViewerRegionImpl::requestSimulatorFeatureCoro, mImpl, url, getHandle())); LL_INFOS("AppInit", "SimulatorFeatures") << "Launching " << coroname << " requesting simulator features from " << url << LL_ENDL; } diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp index ba4fd59feb..7c460ce097 100755 --- a/indra/newview/llvoavatarself.cpp +++ b/indra/newview/llvoavatarself.cpp @@ -2190,7 +2190,7 @@ const std::string LLVOAvatarSelf::debugDumpAllLocalTextureDataInfo() const return text; } -void LLVOAvatarSelf::appearanceChangeMetricsCoro(LLCoros::self& self, std::string url) +void LLVOAvatarSelf::appearanceChangeMetricsCoro(std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -2242,7 +2242,7 @@ void LLVOAvatarSelf::appearanceChangeMetricsCoro(LLCoros::self& self, std::strin gPendingMetricsUploads++; - LLSD result = httpAdapter->postAndYield(self, httpRequest, url, msg); + LLSD result = httpAdapter->postAndYield(httpRequest, url, msg); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -2347,7 +2347,7 @@ void LLVOAvatarSelf::sendViewerAppearanceChangeMetrics() { LLCoros::instance().launch("LLVOAvatarSelf::appearanceChangeMetricsCoro", - boost::bind(&LLVOAvatarSelf::appearanceChangeMetricsCoro, this, _1, caps_url)); + boost::bind(&LLVOAvatarSelf::appearanceChangeMetricsCoro, this, caps_url)); mTimeSinceLastRezMessage.reset(); } } diff --git a/indra/newview/llvoavatarself.h b/indra/newview/llvoavatarself.h index b3b5fe6c2f..d32c959fb5 100755 --- a/indra/newview/llvoavatarself.h +++ b/indra/newview/llvoavatarself.h @@ -402,7 +402,7 @@ private: F32 mDebugBakedTextureTimes[LLAvatarAppearanceDefines::BAKED_NUM_INDICES][2]; // time to start upload and finish upload of each baked texture void debugTimingLocalTexLoaded(BOOL success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata); - void appearanceChangeMetricsCoro(LLCoros::self& self, std::string url); + void appearanceChangeMetricsCoro(std::string url); bool mInitialMetric; S32 mMetricSequence; /** Diagnostics diff --git a/indra/newview/llvoicechannel.cpp b/indra/newview/llvoicechannel.cpp index 338201aab1..192d50ae9b 100755 --- a/indra/newview/llvoicechannel.cpp +++ b/indra/newview/llvoicechannel.cpp @@ -481,7 +481,7 @@ void LLVoiceChannelGroup::getChannelInfo() std::string url = region->getCapability("ChatSessionRequest"); LLCoros::instance().launch("LLVoiceChannelGroup::voiceCallCapCoro", - boost::bind(&LLVoiceChannelGroup::voiceCallCapCoro, this, _1, url)); + boost::bind(&LLVoiceChannelGroup::voiceCallCapCoro, this, url)); } } @@ -604,7 +604,7 @@ void LLVoiceChannelGroup::setState(EState state) } } -void LLVoiceChannelGroup::voiceCallCapCoro(LLCoros::self& self, std::string url) +void LLVoiceChannelGroup::voiceCallCapCoro(std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -617,7 +617,7 @@ void LLVoiceChannelGroup::voiceCallCapCoro(LLCoros::self& self, std::string url) LL_INFOS("Voice", "voiceCallCapCoro") << "Generic POST for " << url << LL_ENDL; - LLSD result = httpAdapter->postAndYield(self, httpRequest, url, postData); + LLSD result = httpAdapter->postAndYield(httpRequest, url, postData); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); diff --git a/indra/newview/llvoicechannel.h b/indra/newview/llvoicechannel.h index 0dac0b1f6a..ef15b2c79e 100755 --- a/indra/newview/llvoicechannel.h +++ b/indra/newview/llvoicechannel.h @@ -159,7 +159,7 @@ protected: virtual void setState(EState state); private: - void voiceCallCapCoro(LLCoros::self& self, std::string url); + void voiceCallCapCoro(std::string url); U32 mRetries; BOOL mIsRetrying; diff --git a/indra/newview/llvoicevivox.cpp b/indra/newview/llvoicevivox.cpp index c70ce5801d..f50ffdeae7 100755 --- a/indra/newview/llvoicevivox.cpp +++ b/indra/newview/llvoicevivox.cpp @@ -446,13 +446,13 @@ void LLVivoxVoiceClient::requestVoiceAccountProvision(S32 retries) if ( !url.empty() ) { LLCoros::instance().launch("LLVivoxVoiceClient::voiceAccountProvisionCoro", - boost::bind(&LLVivoxVoiceClient::voiceAccountProvisionCoro, this, _1, url, retries)); + boost::bind(&LLVivoxVoiceClient::voiceAccountProvisionCoro, this, url, retries)); setState(stateConnectorStart); } } } -void LLVivoxVoiceClient::voiceAccountProvisionCoro(LLCoros::self& self, std::string url, S32 retries) +void LLVivoxVoiceClient::voiceAccountProvisionCoro(std::string url, S32 retries) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -462,7 +462,7 @@ void LLVivoxVoiceClient::voiceAccountProvisionCoro(LLCoros::self& self, std::str httpOpts->setRetries(retries); - LLSD result = httpAdapter->postAndYield(self, httpRequest, url, LLSD(), httpOpts); + LLSD result = httpAdapter->postAndYield(httpRequest, url, LLSD(), httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -3928,12 +3928,12 @@ bool LLVivoxVoiceClient::requestParcelVoiceInfo() LL_DEBUGS("Voice") << "sending ParcelVoiceInfoRequest (" << mCurrentRegionName << ", " << mCurrentParcelLocalID << ")" << LL_ENDL; LLCoros::instance().launch("LLVivoxVoiceClient::parcelVoiceInfoRequestCoro", - boost::bind(&LLVivoxVoiceClient::parcelVoiceInfoRequestCoro, this, _1, url)); + boost::bind(&LLVivoxVoiceClient::parcelVoiceInfoRequestCoro, this, url)); return true; } } -void LLVivoxVoiceClient::parcelVoiceInfoRequestCoro(LLCoros::self& self, std::string url) +void LLVivoxVoiceClient::parcelVoiceInfoRequestCoro(std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -3941,7 +3941,7 @@ void LLVivoxVoiceClient::parcelVoiceInfoRequestCoro(LLCoros::self& self, std::st LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); state requestingState = getState(); - LLSD result = httpAdapter->postAndYield(self, httpRequest, url, LLSD()); + LLSD result = httpAdapter->postAndYield(httpRequest, url, LLSD()); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); diff --git a/indra/newview/llvoicevivox.h b/indra/newview/llvoicevivox.h index a3cdb342e2..b12ed80e41 100755 --- a/indra/newview/llvoicevivox.h +++ b/indra/newview/llvoicevivox.h @@ -637,8 +637,8 @@ protected: private: - void voiceAccountProvisionCoro(LLCoros::self& self, std::string url, S32 retries); - void parcelVoiceInfoRequestCoro(LLCoros::self& self, std::string url); + void voiceAccountProvisionCoro(std::string url, S32 retries); + void parcelVoiceInfoRequestCoro(std::string url); LLVoiceVersionInfo mVoiceVersion; diff --git a/indra/newview/llwebprofile.cpp b/indra/newview/llwebprofile.cpp index 62ba40ca32..2033a5f36a 100755 --- a/indra/newview/llwebprofile.cpp +++ b/indra/newview/llwebprofile.cpp @@ -67,7 +67,7 @@ LLWebProfile::status_callback_t LLWebProfile::mStatusCallback; void LLWebProfile::uploadImage(LLPointer image, const std::string& caption, bool add_location) { LLCoros::instance().launch("LLWebProfile::uploadImageCoro", - boost::bind(&LLWebProfile::uploadImageCoro, _1, image, caption, add_location)); + boost::bind(&LLWebProfile::uploadImageCoro, image, caption, add_location)); } @@ -95,7 +95,7 @@ LLCore::HttpHeaders::ptr_t LLWebProfile::buildDefaultHeaders() /*static*/ -void LLWebProfile::uploadImageCoro(LLCoros::self& self, LLPointer image, std::string caption, bool addLocation) +void LLWebProfile::uploadImageCoro(LLPointer image, std::string caption, bool addLocation) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -124,7 +124,7 @@ void LLWebProfile::uploadImageCoro(LLCoros::self& self, LLPointerappend(HTTP_OUT_HEADER_COOKIE, getAuthCookie()); - LLSD result = httpAdapter->getJsonAndYield(self, httpRequest, configUrl, httpOpts, httpHeaders); + LLSD result = httpAdapter->getJsonAndYield(httpRequest, configUrl, httpOpts, httpHeaders); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -150,7 +150,7 @@ void LLWebProfile::uploadImageCoro(LLCoros::self& self, LLPointerpostAndYield(self, httpRequest, uploadUrl, body, httpOpts, httpHeaders); + result = httpAdapter->postAndYield(httpRequest, uploadUrl, body, httpOpts, httpHeaders); body.reset(); httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; @@ -178,7 +178,7 @@ void LLWebProfile::uploadImageCoro(LLCoros::self& self, LLPointergetRawAndYield(self, httpRequest, redirUrl, httpOpts, httpHeaders); + result = httpAdapter->getRawAndYield(httpRequest, redirUrl, httpOpts, httpHeaders); httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); diff --git a/indra/newview/llwebprofile.h b/indra/newview/llwebprofile.h index 604ef7aff7..6227e00afe 100755 --- a/indra/newview/llwebprofile.h +++ b/indra/newview/llwebprofile.h @@ -60,7 +60,7 @@ public: private: static LLCore::HttpHeaders::ptr_t buildDefaultHeaders(); - static void uploadImageCoro(LLCoros::self& self, LLPointer image, std::string caption, bool add_location); + static void uploadImageCoro(LLPointer image, std::string caption, bool add_location); static LLCore::BufferArray::ptr_t buildPostData(const LLSD &data, LLPointer &image, const std::string &boundary); static void reportImageUploadStatus(bool ok); diff --git a/indra/newview/llwlhandlers.cpp b/indra/newview/llwlhandlers.cpp index 3145c3f38d..ff15afa598 100755 --- a/indra/newview/llwlhandlers.cpp +++ b/indra/newview/llwlhandlers.cpp @@ -84,7 +84,7 @@ bool LLEnvironmentRequest::doRequest() std::string coroname = LLCoros::instance().launch("LLEnvironmentRequest::environmentRequestCoro", - boost::bind(&LLEnvironmentRequest::environmentRequestCoro, _1, url)); + boost::bind(&LLEnvironmentRequest::environmentRequestCoro, url)); LL_INFOS("WindlightCaps") << "Requesting region windlight settings via " << url << LL_ENDL; return true; @@ -93,7 +93,7 @@ bool LLEnvironmentRequest::doRequest() S32 LLEnvironmentRequest::sLastRequest = 0; //static -void LLEnvironmentRequest::environmentRequestCoro(LLCoros::self& self, std::string url) +void LLEnvironmentRequest::environmentRequestCoro(std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); S32 requestId = ++LLEnvironmentRequest::sLastRequest; @@ -101,7 +101,7 @@ void LLEnvironmentRequest::environmentRequestCoro(LLCoros::self& self, std::stri httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("EnvironmentRequest", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLSD result = httpAdapter->getAndYield(self, httpRequest, url); + LLSD result = httpAdapter->getAndYield(httpRequest, url); if (requestId != LLEnvironmentRequest::sLastRequest) { @@ -174,18 +174,18 @@ bool LLEnvironmentApply::initiateRequest(const LLSD& content) std::string coroname = LLCoros::instance().launch("LLEnvironmentApply::environmentApplyCoro", - boost::bind(&LLEnvironmentApply::environmentApplyCoro, _1, url, content)); + boost::bind(&LLEnvironmentApply::environmentApplyCoro, url, content)); return true; } -void LLEnvironmentApply::environmentApplyCoro(LLCoros::self& self, std::string url, LLSD content) +void LLEnvironmentApply::environmentApplyCoro(std::string url, LLSD content) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("EnvironmentApply", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLSD result = httpAdapter->postAndYield(self, httpRequest, url, content); + LLSD result = httpAdapter->postAndYield(httpRequest, url, content); LLSD notify; // for error reporting. If there is something to report to user this will be defined. /* diff --git a/indra/newview/llwlhandlers.h b/indra/newview/llwlhandlers.h index 0b778901ad..eb2bbf9553 100755 --- a/indra/newview/llwlhandlers.h +++ b/indra/newview/llwlhandlers.h @@ -41,7 +41,7 @@ private: static void onRegionCapsReceived(const LLUUID& region_id); static bool doRequest(); - static void environmentRequestCoro(LLCoros::self& self, std::string url); + static void environmentRequestCoro(std::string url); static S32 sLastRequest; }; @@ -57,7 +57,7 @@ private: static clock_t sLastUpdate; static clock_t UPDATE_WAIT_SECONDS; - static void environmentApplyCoro(LLCoros::self& self, std::string url, LLSD content); + static void environmentApplyCoro(std::string url, LLSD content); }; #endif // LL_LLWLHANDLERS_H diff --git a/indra/viewer_components/login/lllogin.cpp b/indra/viewer_components/login/lllogin.cpp index b8408a6fb4..0569e9f3e8 100755 --- a/indra/viewer_components/login/lllogin.cpp +++ b/indra/viewer_components/login/lllogin.cpp @@ -107,9 +107,8 @@ private: } // In a coroutine's top-level function args, do NOT NOT NOT accept - // references (const or otherwise) to anything but the self argument! Pass - // by value only! - void login_(LLCoros::self& self, std::string uri, LLSD credentials); + // references (const or otherwise) to anything! Pass by value only! + void login_(std::string uri, LLSD credentials); LLEventStream mPump; LLSD mAuthResponse, mValidAuthResponse; @@ -123,11 +122,11 @@ void LLLogin::Impl::connect(const std::string& uri, const LLSD& login_params) // its first wait; at that point, return here. std::string coroname = LLCoros::instance().launch("LLLogin::Impl::login_", - boost::bind(&Impl::login_, this, _1, uri, login_params)); + boost::bind(&Impl::login_, this, uri, login_params)); LL_DEBUGS("LLLogin") << " connected with uri '" << uri << "', login_params " << login_params << LL_ENDL; } -void LLLogin::Impl::login_(LLCoros::self& self, std::string uri, LLSD login_params) +void LLLogin::Impl::login_(std::string uri, LLSD login_params) { try { @@ -137,7 +136,7 @@ void LLLogin::Impl::login_(LLCoros::self& self, std::string uri, LLSD login_para //{ // printable_params["params"]["passwd"] = "*******"; //} - LL_DEBUGS("LLLogin") << "Entering coroutine " << LLCoros::instance().getName(self) + LL_DEBUGS("LLLogin") << "Entering coroutine " << LLCoros::instance().getName() << " with uri '" << uri << "', parameters " << printable_params << LL_ENDL; // Arriving in SRVRequest state @@ -176,7 +175,7 @@ void LLLogin::Impl::login_(LLCoros::self& self, std::string uri, LLSD login_para request["op"] = "rewriteURI"; request["uri"] = uri; request["reply"] = replyPump.getName(); - rewrittenURIs = postAndWait(self, request, srv_pump_name, filter); + rewrittenURIs = postAndWait(request, srv_pump_name, filter); // EXP-772: If rewrittenURIs fail, try original URI as a fallback. rewrittenURIs.append(uri); } // we no longer need the filter @@ -222,10 +221,10 @@ void LLLogin::Impl::login_(LLCoros::self& self, std::string uri, LLSD login_para // returns. Subsequent responses, of course, must be awaited // without posting again. for (mAuthResponse = validateResponse(loginReplyPump.getName(), - postAndWait(self, request, xmlrpcPump, loginReplyPump, "reply")); + postAndWait(request, xmlrpcPump, loginReplyPump, "reply")); mAuthResponse["status"].asString() == "Downloading"; mAuthResponse = validateResponse(loginReplyPump.getName(), - waitForEventOn(self, loginReplyPump))) + waitForEventOn(loginReplyPump))) { // Still Downloading -- send progress update. sendProgressEvent("offline", "downloading"); diff --git a/indra/viewer_components/updater/llupdatechecker.cpp b/indra/viewer_components/updater/llupdatechecker.cpp index 29cb238892..e889f83aa9 100755 --- a/indra/viewer_components/updater/llupdatechecker.cpp +++ b/indra/viewer_components/updater/llupdatechecker.cpp @@ -117,7 +117,7 @@ void LLUpdateChecker::Implementation::checkVersion(std::string const & urlBase, LL_INFOS("UpdaterService") << "checking for updates at " << checkUrl << LL_ENDL; LLCoros::instance().launch("LLUpdateChecker::Implementation::checkVersionCoro", - boost::bind(&Implementation::checkVersionCoro, this, _1, checkUrl)); + boost::bind(&Implementation::checkVersionCoro, this, checkUrl)); } else @@ -126,7 +126,7 @@ void LLUpdateChecker::Implementation::checkVersion(std::string const & urlBase, } } -void LLUpdateChecker::Implementation::checkVersionCoro(LLCoros::self& self, std::string url) +void LLUpdateChecker::Implementation::checkVersionCoro(std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -135,7 +135,7 @@ void LLUpdateChecker::Implementation::checkVersionCoro(LLCoros::self& self, std: LL_INFOS("checkVersionCoro") << "Getting update information from " << url << LL_ENDL; - LLSD result = httpAdapter->getAndYield(self, httpRequest, url); + LLSD result = httpAdapter->getAndYield(httpRequest, url); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); diff --git a/indra/viewer_components/updater/llupdatechecker.h b/indra/viewer_components/updater/llupdatechecker.h index e5050bb952..d10ea4cf42 100755 --- a/indra/viewer_components/updater/llupdatechecker.h +++ b/indra/viewer_components/updater/llupdatechecker.h @@ -106,7 +106,7 @@ private: unsigned char uniqueid[MD5HEX_STR_SIZE], bool willing_to_test); - void checkVersionCoro(LLCoros::self& self, std::string url); + void checkVersionCoro(std::string url); LOG_CLASS(LLUpdateChecker::Implementation); }; -- cgit v1.2.3 From 68f42e4e102bd578386aeec3485233e332cbdcff Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Fri, 10 Jul 2015 19:44:47 -0400 Subject: MAINT-5351: Finish cleaning up messy merge from backing out backout --- indra/llcommon/llcoros.cpp | 4 +- indra/llcommon/llcoros.h | 12 --- indra/llcommon/lleventcoro.cpp | 127 +++++++++++++----------------- indra/llcommon/lleventcoro.h | 18 ++--- indra/llcommon/tests/lleventcoro_test.cpp | 3 +- 5 files changed, 67 insertions(+), 97 deletions(-) (limited to 'indra') diff --git a/indra/llcommon/llcoros.cpp b/indra/llcommon/llcoros.cpp index 6cca5e7c60..d76401d01b 100755 --- a/indra/llcommon/llcoros.cpp +++ b/indra/llcommon/llcoros.cpp @@ -61,7 +61,7 @@ LLCoros::coro::self& LLCoros::get_self() return *current->mSelf; } -LLCoros::Suspending::Suspending(): +llcoro::Suspending::Suspending(): mSuspended(LLCoros::sCurrentCoro.get()) { // Revert mCurrentCoro to the value it had at the moment we last switched @@ -69,7 +69,7 @@ LLCoros::Suspending::Suspending(): LLCoros::sCurrentCoro.reset(mSuspended->mPrev); } -LLCoros::Suspending::~Suspending() +llcoro::Suspending::~Suspending() { // Okay, we're back, update our mPrev mSuspended->mPrev = LLCoros::sCurrentCoro.get(); diff --git a/indra/llcommon/llcoros.h b/indra/llcommon/llcoros.h index 05bd87dc3c..56eed8cafe 100755 --- a/indra/llcommon/llcoros.h +++ b/indra/llcommon/llcoros.h @@ -144,18 +144,6 @@ public: */ std::string getName() const; - /// get the current coro::self& for those who really really care - static coro::self& get_self(); - - /// Instantiate one of these in a block surrounding any leaf point when - /// control literally switches away from this coroutine. - class Suspending - public: - Suspending(); - ~Suspending(); - private: - coro::self* mSuspended; - }; /// for delayed initialization void setStackSize(S32 stacksize); diff --git a/indra/llcommon/lleventcoro.cpp b/indra/llcommon/lleventcoro.cpp index a37b87f085..66cc7cada0 100755 --- a/indra/llcommon/lleventcoro.cpp +++ b/indra/llcommon/lleventcoro.cpp @@ -41,7 +41,7 @@ #include "llerror.h" #include "llcoros.h" -std::string LLEventDetail::listenerNameForCoro() +namespace { /** @@ -143,14 +143,24 @@ void storeToLLSDPath(LLSD& dest, const LLSD& rawPath, const LLSD& value) *pdest = value; } -LLSD postAndWait(const LLSD& event, const LLEventPumpOrPumpName& requestPump, +} // anonymous + +void llcoro::yield() +{ + // By viewer convention, we post an event on the "mainloop" LLEventPump + // each iteration of the main event-handling loop. So waiting for a single + // event on "mainloop" gives us a one-frame yield. + waitForEventOn("mainloop"); +} + +LLSD llcoro::postAndWait(const LLSD& event, const LLEventPumpOrPumpName& requestPump, const LLEventPumpOrPumpName& replyPump, const LLSD& replyPumpNamePath) { // declare the future boost::dcoroutines::future future(LLCoros::get_self()); // make a callback that will assign a value to the future, and listen on // the specified LLEventPump with that callback - std::string listenerName(LLEventDetail::listenerNameForCoro()); + std::string listenerName(listenerNameForCoro()); LLTempBoundListener connection( replyPump.getPump().listen(listenerName, voidlistener(boost::dcoroutines::make_callback(future)))); @@ -160,7 +170,7 @@ LLSD postAndWait(const LLSD& event, const LLEventPumpOrPumpName& requestPump, // If replyPumpNamePath is non-empty, store the replyPump name in the // request event. LLSD modevent(event); - LLEventDetail::storeToLLSDPath(modevent, replyPumpNamePath, replyPump.getPump().getName()); + storeToLLSDPath(modevent, replyPumpNamePath, replyPump.getPump().getName()); LL_DEBUGS("lleventcoro") << "postAndWait(): coroutine " << listenerName << " posting to " << requestPump.getPump().getName() << LL_ENDL; @@ -176,7 +186,7 @@ LLSD postAndWait(const LLSD& event, const LLEventPumpOrPumpName& requestPump, LLSD value; { // instantiate Suspending to manage the "current" coroutine - LLCoros::Suspending suspended; + llcoro::Suspending suspended; value = *future; } // destroy Suspending as soon as we're back LL_DEBUGS("lleventcoro") << "postAndWait(): coroutine " << listenerName @@ -185,72 +195,6 @@ LLSD postAndWait(const LLSD& event, const LLEventPumpOrPumpName& requestPump, return value; } -LLEventWithID postAndWait2(const LLSD& event, - const LLEventPumpOrPumpName& requestPump, - const LLEventPumpOrPumpName& replyPump0, - const LLEventPumpOrPumpName& replyPump1, - const LLSD& replyPump0NamePath, - const LLSD& replyPump1NamePath) -{ - // declare the future - boost::dcoroutines::future future(LLCoros::get_self()); - // either callback will assign a value to this future; listen on - // each specified LLEventPump with a callback - std::string name(LLEventDetail::listenerNameForCoro()); - LLTempBoundListener connection0( - replyPump0.getPump().listen(name + "a", - LLEventDetail::wfeoh(boost::dcoroutines::make_callback(future), 0))); - LLTempBoundListener connection1( - replyPump1.getPump().listen(name + "b", - LLEventDetail::wfeoh(boost::dcoroutines::make_callback(future), 1))); - // skip the "post" part if requestPump is default-constructed - if (requestPump) - { - // If either replyPumpNamePath is non-empty, store the corresponding - // replyPump name in the request event. - LLSD modevent(event); - LLEventDetail::storeToLLSDPath(modevent, replyPump0NamePath, - replyPump0.getPump().getName()); - LLEventDetail::storeToLLSDPath(modevent, replyPump1NamePath, - replyPump1.getPump().getName()); - LL_DEBUGS("lleventcoro") << "postAndWait2(): coroutine " << name - << " posting to " << requestPump.getPump().getName() - << ": " << modevent << LL_ENDL; - requestPump.getPump().post(modevent); - } - LL_DEBUGS("lleventcoro") << "postAndWait2(): coroutine " << name - << " about to wait on LLEventPumps " << replyPump0.getPump().getName() - << ", " << replyPump1.getPump().getName() << LL_ENDL; - // trying to dereference ("resolve") the future makes us wait for it - LLEventWithID value; - { - // instantiate Suspending to manage "current" coroutine - LLCoros::Suspending suspended; - value = *future; - } // destroy Suspending as soon as we're back - LL_DEBUGS("lleventcoro") << "postAndWait(): coroutine " << name - << " resuming with (" << value.first << ", " << value.second << ")" - << LL_ENDL; - // returning should disconnect both connections - return value; -} - -} // anonymous - -void llcoro::yield() -{ - // By viewer convention, we post an event on the "mainloop" LLEventPump - // each iteration of the main event-handling loop. So waiting for a single - // event on "mainloop" gives us a one-frame yield. - waitForEventOn("mainloop"); -} - -LLSD llcoro::postAndWait(const LLSD& event, const LLEventPumpOrPumpName& requestPump, - const LLEventPumpOrPumpName& replyPump, const LLSD& replyPumpNamePath) - boost::dcoroutines::future future(llcoro::get_self()); - std::string listenerName(listenerNameForCoro()); - storeToLLSDPath(modevent, replyPumpNamePath, replyPump.getPump().getName()); - llcoro::Suspending suspended; namespace { @@ -298,15 +242,56 @@ WaitForEventOnHelper wfeoh(const LISTENER& listener, int discriminator namespace llcoro { +LLEventWithID postAndWait2(const LLSD& event, + const LLEventPumpOrPumpName& requestPump, + const LLEventPumpOrPumpName& replyPump0, + const LLEventPumpOrPumpName& replyPump1, + const LLSD& replyPump0NamePath, + const LLSD& replyPump1NamePath) +{ + // declare the future boost::dcoroutines::future future(LLCoros::get_self()); + // either callback will assign a value to this future; listen on + // each specified LLEventPump with a callback std::string name(listenerNameForCoro()); + LLTempBoundListener connection0( + replyPump0.getPump().listen(name + "a", wfeoh(boost::dcoroutines::make_callback(future), 0))); + LLTempBoundListener connection1( + replyPump1.getPump().listen(name + "b", wfeoh(boost::dcoroutines::make_callback(future), 1))); + // skip the "post" part if requestPump is default-constructed + if (requestPump) + { + // If either replyPumpNamePath is non-empty, store the corresponding + // replyPump name in the request event. + LLSD modevent(event); storeToLLSDPath(modevent, replyPump0NamePath, replyPump0.getPump().getName()); storeToLLSDPath(modevent, replyPump1NamePath, replyPump1.getPump().getName()); + LL_DEBUGS("lleventcoro") << "postAndWait2(): coroutine " << name + << " posting to " << requestPump.getPump().getName() + << ": " << modevent << LL_ENDL; + requestPump.getPump().post(modevent); + } + LL_DEBUGS("lleventcoro") << "postAndWait2(): coroutine " << name + << " about to wait on LLEventPumps " << replyPump0.getPump().getName() + << ", " << replyPump1.getPump().getName() << LL_ENDL; + // trying to dereference ("resolve") the future makes us wait for it + LLEventWithID value; + { + // instantiate Suspending to manage "current" coroutine llcoro::Suspending suspended; + value = *future; + } // destroy Suspending as soon as we're back + LL_DEBUGS("lleventcoro") << "postAndWait(): coroutine " << name + << " resuming with (" << value.first << ", " << value.second << ")" + << LL_ENDL; + // returning should disconnect both connections + return value; +} + LLSD errorException(const LLEventWithID& result, const std::string& desc) { // If the result arrived on the error pump (pump 1), instead of diff --git a/indra/llcommon/lleventcoro.h b/indra/llcommon/lleventcoro.h index 20fc422a68..e2ce4bb193 100755 --- a/indra/llcommon/lleventcoro.h +++ b/indra/llcommon/lleventcoro.h @@ -101,8 +101,6 @@ VoidListener voidlistener(const LISTENER& listener) return VoidListener(listener); } - * each distinct coroutine instance. - std::string listenerNameForCoro(); /** * Yield control from a coroutine for one "mainloop" tick. If your coroutine * runs without suspending for nontrivial time, sprinkle in calls to this @@ -309,13 +307,13 @@ public: */ LLSD wait() { - return ::waitForEventOn(mPump); + return llcoro::waitForEventOn(mPump); } LLSD postAndWait(const LLSD& event, const LLEventPumpOrPumpName& requestPump, const LLSD& replyPumpNamePath=LLSD()) { - return ::postAndWait(event, requestPump, mPump, replyPumpNamePath); + return llcoro::postAndWait(event, requestPump, mPump, replyPumpNamePath); } private: @@ -354,19 +352,19 @@ public: /// waitForEventOn(either of our two LLEventPumps) LLEventWithID wait() { - return waitForEventOn(mPump0, mPump1); + return llcoro::waitForEventOn(mPump0, mPump1); } /// errorException(wait()) LLSD waitWithException() { - return errorException(wait(), std::string("Error event on ") + getName1()); + return llcoro::errorException(wait(), std::string("Error event on ") + getName1()); } /// errorLog(wait()) LLSD waitWithLog() { - return errorLog(wait(), std::string("Error event on ") + getName1()); + return llcoro::errorLog(wait(), std::string("Error event on ") + getName1()); } LLEventWithID postAndWait(const LLSD& event, @@ -374,7 +372,7 @@ public: const LLSD& replyPump0NamePath=LLSD(), const LLSD& replyPump1NamePath=LLSD()) { - return postAndWait2(event, requestPump, mPump0, mPump1, + return llcoro::postAndWait2(event, requestPump, mPump0, mPump1, replyPump0NamePath, replyPump1NamePath); } @@ -383,7 +381,7 @@ public: const LLSD& replyPump0NamePath=LLSD(), const LLSD& replyPump1NamePath=LLSD()) { - return errorException(postAndWait(event, requestPump, + return llcoro::errorException(postAndWait(event, requestPump, replyPump0NamePath, replyPump1NamePath), std::string("Error event on ") + getName1()); } @@ -393,7 +391,7 @@ public: const LLSD& replyPump0NamePath=LLSD(), const LLSD& replyPump1NamePath=LLSD()) { - return errorLog(postAndWait(event, requestPump, + return llcoro::errorLog(postAndWait(event, requestPump, replyPump0NamePath, replyPump1NamePath), std::string("Error event on ") + getName1()); } diff --git a/indra/llcommon/tests/lleventcoro_test.cpp b/indra/llcommon/tests/lleventcoro_test.cpp index b8d9d8002f..00be5035f2 100755 --- a/indra/llcommon/tests/lleventcoro_test.cpp +++ b/indra/llcommon/tests/lleventcoro_test.cpp @@ -264,8 +264,7 @@ namespace tut // Construct the coroutine instance that will run explicit_wait. // Pass the ctor a callable that accepts the coroutine_type::self // param passed by the library. - boost::dcoroutines::coroutine - coro(explicit_wait); + boost::dcoroutines::coroutine coro(explicit_wait); // Start the coroutine coro(std::nothrow); // When the coroutine waits for the event pump, it returns here. -- cgit v1.2.3 From 91f636f23a6db27c4ca4c5df2325a7053ca3044e Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 10 Jul 2015 16:45:07 -0700 Subject: MAINT-5356: Conversion of Notecards and Gesture to use new coroutine uploading. Minor reorganization of Upload Info classes. --- indra/newview/llfloaternamedesc.cpp | 11 --- indra/newview/llpreviewgesture.cpp | 149 +++++++++++++++++++++++++++++ indra/newview/llpreviewnotecard.cpp | 133 ++++++++++++++++---------- indra/newview/llviewerassetupload.cpp | 170 ++++++++++++++++++++++++++++++++-- indra/newview/llviewerassetupload.h | 113 +++++++++++----------- 5 files changed, 450 insertions(+), 126 deletions(-) (limited to 'indra') diff --git a/indra/newview/llfloaternamedesc.cpp b/indra/newview/llfloaternamedesc.cpp index 4960ecf5fe..6912adfcff 100755 --- a/indra/newview/llfloaternamedesc.cpp +++ b/indra/newview/llfloaternamedesc.cpp @@ -176,17 +176,6 @@ void LLFloaterNameDesc::onBtnOK( ) upload_new_resource(uploadInfo, callback, nruserdata); -#if 0 - upload_new_resource(mFilenameAndPath, // file - getChild("name_form")->getValue().asString(), - getChild("description_form")->getValue().asString(), - 0, LLFolderType::FT_NONE, LLInventoryType::IT_NONE, - LLFloaterPerms::getNextOwnerPerms("Uploads"), - LLFloaterPerms::getGroupPerms("Uploads"), - LLFloaterPerms::getEveryonePerms("Uploads"), - display_name, callback, expected_upload_cost, nruserdata); -#endif - closeFloater(false); } diff --git a/indra/newview/llpreviewgesture.cpp b/indra/newview/llpreviewgesture.cpp index c378738b05..6c12885864 100755 --- a/indra/newview/llpreviewgesture.cpp +++ b/indra/newview/llpreviewgesture.cpp @@ -52,6 +52,8 @@ #include "llviewerobjectlist.h" #include "llviewerregion.h" #include "llviewerstats.h" +#include "llviewerassetupload.h" +#include "llcoproceduremanager.h" std::string NONE_LABEL; std::string SHIFT_LABEL; @@ -1015,6 +1017,27 @@ struct LLSaveInfo }; +void finishInventoryUpload(LLUUID itemId, LLUUID newAssetId) +{ + // If this gesture is active, then we need to update the in-memory + // active map with the new pointer. + if (LLGestureMgr::instance().isGestureActive(itemId)) + { + //*TODO: This is crashing for some reason. Fix it. + // Active gesture edited from menu. + LLGestureMgr::instance().replaceGesture(itemId, newAssetId); + gInventory.notifyObservers(); + } + + //gesture will have a new asset_id + LLPreviewGesture* previewp = LLFloaterReg::findTypedInstance("preview_gesture", LLSD(itemId)); + if (previewp) + { + previewp->onUpdateSucceeded(); + } +} + + void LLPreviewGesture::saveIfNeeded() { if (!gAssetStorage) @@ -1028,6 +1051,131 @@ void LLPreviewGesture::saveIfNeeded() return; } +#if 0 + // Copy the UI into a gesture + LLMultiGesture* gesture = createGesture(); + + // Serialize the gesture + S32 maxSize = gesture->getMaxSerialSize(); + char* buffer = new char[maxSize]; + + LLDataPackerAsciiBuffer dp(buffer, maxSize); + + bool ok = gesture->serialize(dp); + + if (dp.getCurrentSize() > 1000) + { + LLNotificationsUtil::add("GestureSaveFailedTooManySteps"); + + delete gesture; + gesture = NULL; + return; + } + else if (!ok) + { + LLNotificationsUtil::add("GestureSaveFailedTryAgain"); + delete gesture; + gesture = NULL; + return; + } + + LLAssetID assetId; + LLPreview::onCommit(); + bool delayedUpload(false); + + LLViewerInventoryItem* item = (LLViewerInventoryItem*) getItem(); + if (item) + { + const LLViewerRegion* region = gAgent.getRegion(); + if (!region) + { + LL_WARNS() << "Not connected to a region, cannot save notecard." << LL_ENDL; + return; + } + std::string agent_url = region->getCapability("UpdateGestureAgentInventory"); + std::string task_url = region->getCapability("UpdateGestureTaskInventory"); + + if (!agent_url.empty() && !task_url.empty()) + { + std::string url; + NewResourceUploadInfo::ptr_t uploadInfo; + + if (mObjectUUID.isNull() && !agent_url.empty()) + { + //need to disable the preview floater so item + //isn't re-saved before new asset arrives + //fake out refresh. + item->setComplete(false); + refresh(); + item->setComplete(true); + + uploadInfo = NewResourceUploadInfo::ptr_t(new LLBufferedAssetUploadInfo(mItemUUID, LLAssetType::AT_GESTURE, buffer, + boost::bind(&finishInventoryUpload, _1, _2))); + url = agent_url; + } + else if (!mObjectUUID.isNull() && !task_url.empty()) + { + uploadInfo = NewResourceUploadInfo::ptr_t(new LLBufferedAssetUploadInfo(mObjectUUID, mItemUUID, LLAssetType::AT_GESTURE, buffer, NULL)); + url = task_url; + } + + if (!url.empty() && uploadInfo) + { + delayedUpload = true; + + LLCoprocedureManager::CoProcedure_t proc = boost::bind(&LLViewerAssetUpload::AssetInventoryUploadCoproc, _1, _2, _3, url, uploadInfo); + + LLCoprocedureManager::getInstance()->enqueueCoprocedure("LLViewerAssetUpload::AssetInventoryUploadCoproc", proc); + } + + } + else if (gAssetStorage) + { + // Every save gets a new UUID. Yup. + LLTransactionID tid; + tid.generate(); + assetId = tid.makeAssetID(gAgent.getSecureSessionID()); + + LLVFile file(gVFS, assetId, LLAssetType::AT_GESTURE, LLVFile::APPEND); + + S32 size = dp.getCurrentSize(); + file.setMaxSize(size); + file.write((U8*)buffer, size); + + LLLineEditor* descEditor = getChild("desc"); + LLSaveInfo* info = new LLSaveInfo(mItemUUID, mObjectUUID, descEditor->getText(), tid); + gAssetStorage->storeAssetData(tid, LLAssetType::AT_GESTURE, onSaveComplete, info, FALSE); + } + + } + + // If this gesture is active, then we need to update the in-memory + // active map with the new pointer. + if (!delayedUpload && LLGestureMgr::instance().isGestureActive(mItemUUID)) + { + // gesture manager now owns the pointer + LLGestureMgr::instance().replaceGesture(mItemUUID, gesture, assetId); + + // replaceGesture may deactivate other gestures so let the + // inventory know. + gInventory.notifyObservers(); + } + else + { + // we're done with this gesture + delete gesture; + gesture = NULL; + } + + mDirty = false; + // refresh will be called when callback + // if triggered when delayedUpload + if(!delayedUpload) + { + refresh(); + } + +#else // Copy the UI into a gesture LLMultiGesture* gesture = createGesture(); @@ -1138,6 +1286,7 @@ void LLPreviewGesture::saveIfNeeded() delete [] buffer; buffer = NULL; +#endif } diff --git a/indra/newview/llpreviewnotecard.cpp b/indra/newview/llpreviewnotecard.cpp index 1308d1e9a7..b9941b7591 100755 --- a/indra/newview/llpreviewnotecard.cpp +++ b/indra/newview/llpreviewnotecard.cpp @@ -56,6 +56,8 @@ #include "llappviewer.h" // app_abort_quit() #include "lllineeditor.h" #include "lluictrlfactory.h" +#include "llcoproceduremanager.h" +#include "llviewerassetupload.h" ///---------------------------------------------------------------------------- /// Class LLPreviewNotecard @@ -404,6 +406,35 @@ struct LLSaveNotecardInfo } }; +void finishInventoryUpload(LLUUID itemId, LLUUID newAssetId, LLUUID newItemId) +{ + // Update the UI with the new asset. + LLPreviewNotecard* nc = LLFloaterReg::findTypedInstance("preview_notecard", LLSD(itemId)); + if (nc) + { + // *HACK: we have to delete the asset in the VFS so + // that the viewer will redownload it. This is only + // really necessary if the asset had to be modified by + // the uploader, so this can be optimized away in some + // cases. A better design is to have a new uuid if the + // script actually changed the asset. + if (nc->hasEmbeddedInventory()) + { + gVFS->removeFile(newAssetId, LLAssetType::AT_NOTECARD); + } + if (newItemId.isNull()) + { + nc->setAssetId(newAssetId); + nc->refreshFromInventory(); + } + else + { + nc->refreshFromInventory(newItemId); + } + } +} + + bool LLPreviewNotecard::saveIfNeeded(LLInventoryItem* copyitem) { LLViewerTextEditor* editor = getChild("Notecard Editor"); @@ -416,14 +447,6 @@ bool LLPreviewNotecard::saveIfNeeded(LLInventoryItem* copyitem) if(!editor->isPristine()) { - // We need to update the asset information - LLTransactionID tid; - LLAssetID asset_id; - tid.generate(); - asset_id = tid.makeAssetID(gAgent.getSecureSessionID()); - - LLVFile file(gVFS, asset_id, LLAssetType::AT_NOTECARD, LLVFile::APPEND); - std::string buffer; if (!editor->exportBuffer(buffer)) { @@ -432,52 +455,66 @@ bool LLPreviewNotecard::saveIfNeeded(LLInventoryItem* copyitem) editor->makePristine(); - S32 size = buffer.length() + 1; - file.setMaxSize(size); - file.write((U8*)buffer.c_str(), size); - const LLInventoryItem* item = getItem(); // save it out to database - if (item) - { - const LLViewerRegion* region = gAgent.getRegion(); - if (!region) - { - LL_WARNS() << "Not connected to a region, cannot save notecard." << LL_ENDL; - return false; - } - std::string agent_url = region->getCapability("UpdateNotecardAgentInventory"); - std::string task_url = region->getCapability("UpdateNotecardTaskInventory"); - - if (mObjectUUID.isNull() && !agent_url.empty()) - { - // Saving into agent inventory - mAssetStatus = PREVIEW_ASSET_LOADING; - setEnabled(FALSE); - LLSD body; - body["item_id"] = mItemUUID; - LL_INFOS() << "Saving notecard " << mItemUUID - << " into agent inventory via " << agent_url << LL_ENDL; - LLHTTPClient::post(agent_url, body, - new LLUpdateAgentInventoryResponder(body, asset_id, LLAssetType::AT_NOTECARD)); - } - else if (!mObjectUUID.isNull() && !task_url.empty()) - { - // Saving into task inventory - mAssetStatus = PREVIEW_ASSET_LOADING; - setEnabled(FALSE); - LLSD body; - body["task_id"] = mObjectUUID; - body["item_id"] = mItemUUID; - LL_INFOS() << "Saving notecard " << mItemUUID << " into task " - << mObjectUUID << " via " << task_url << LL_ENDL; - LLHTTPClient::post(task_url, body, - new LLUpdateTaskInventoryResponder(body, asset_id, LLAssetType::AT_NOTECARD)); - } + if (item) + { + const LLViewerRegion* region = gAgent.getRegion(); + if (!region) + { + LL_WARNS() << "Not connected to a region, cannot save notecard." << LL_ENDL; + return false; + } + std::string agent_url = region->getCapability("UpdateNotecardAgentInventory"); + std::string task_url = region->getCapability("UpdateNotecardTaskInventory"); + + if (!agent_url.empty() && !task_url.empty()) + { + std::string url; + NewResourceUploadInfo::ptr_t uploadInfo; + + if (mObjectUUID.isNull() && !agent_url.empty()) + { + uploadInfo = NewResourceUploadInfo::ptr_t(new LLBufferedAssetUploadInfo(mItemUUID, LLAssetType::AT_NOTECARD, buffer, + boost::bind(&finishInventoryUpload, _1, _2, _3))); + url = agent_url; + } + else if (!mObjectUUID.isNull() && !task_url.empty()) + { + uploadInfo = NewResourceUploadInfo::ptr_t(new LLBufferedAssetUploadInfo(mObjectUUID, mItemUUID, LLAssetType::AT_NOTECARD, buffer, + boost::bind(&finishInventoryUpload, _1, _3, LLUUID::null))); + url = task_url; + } + + if (!url.empty() && uploadInfo) + { + mAssetStatus = PREVIEW_ASSET_LOADING; + setEnabled(false); + + LLCoprocedureManager::CoProcedure_t proc = boost::bind(&LLViewerAssetUpload::AssetInventoryUploadCoproc, _1, _2, _3, url, uploadInfo); + + LLCoprocedureManager::getInstance()->enqueueCoprocedure("LLViewerAssetUpload::AssetInventoryUploadCoproc", proc); + } + + } else if (gAssetStorage) { + // We need to update the asset information + LLTransactionID tid; + LLAssetID asset_id; + tid.generate(); + asset_id = tid.makeAssetID(gAgent.getSecureSessionID()); + + LLVFile file(gVFS, asset_id, LLAssetType::AT_NOTECARD, LLVFile::APPEND); + + LLSaveNotecardInfo* info = new LLSaveNotecardInfo(this, mItemUUID, mObjectUUID, tid, copyitem); + + S32 size = buffer.length() + 1; + file.setMaxSize(size); + file.write((U8*)buffer.c_str(), size); + gAssetStorage->storeAssetData(tid, LLAssetType::AT_NOTECARD, &onSaveComplete, (void*)info, diff --git a/indra/newview/llviewerassetupload.cpp b/indra/newview/llviewerassetupload.cpp index efaf95444d..04014a6ecb 100644 --- a/indra/newview/llviewerassetupload.cpp +++ b/indra/newview/llviewerassetupload.cpp @@ -46,6 +46,56 @@ #include "llappviewer.h" #include "llviewerstats.h" #include "llvfile.h" +#include "llgesturemgr.h" +#include "llpreviewnotecard.h" +#include "llpreviewgesture.h" + +void dialog_refresh_all(); + +NewResourceUploadInfo::NewResourceUploadInfo(LLTransactionID transactId, + LLAssetType::EType assetType, std::string name, std::string description, + S32 compressionInfo, LLFolderType::EType destinationType, + LLInventoryType::EType inventoryType, U32 nextOWnerPerms, + U32 groupPerms, U32 everyonePerms, S32 expectedCost) : + mTransactionId(transactId), + mAssetType(assetType), + mName(name), + mDescription(description), + mCompressionInfo(compressionInfo), + mDestinationFolderType(destinationType), + mInventoryType(inventoryType), + mNextOwnerPerms(nextOWnerPerms), + mGroupPerms(groupPerms), + mEveryonePerms(everyonePerms), + mExpectedUploadCost(expectedCost), + mFolderId(LLUUID::null), + mItemId(LLUUID::null), + mAssetId(LLAssetID::null) +{ } + + +NewResourceUploadInfo::NewResourceUploadInfo(std::string name, + std::string description, S32 compressionInfo, + LLFolderType::EType destinationType, LLInventoryType::EType inventoryType, + U32 nextOWnerPerms, U32 groupPerms, U32 everyonePerms, S32 expectedCost): + mName(name), + mDescription(description), + mCompressionInfo(compressionInfo), + mDestinationFolderType(destinationType), + mInventoryType(inventoryType), + mNextOwnerPerms(nextOWnerPerms), + mGroupPerms(groupPerms), + mEveryonePerms(everyonePerms), + mExpectedUploadCost(expectedCost), + mTransactionId(), + mAssetType(LLAssetType::AT_NONE), + mFolderId(LLUUID::null), + mItemId(LLUUID::null), + mAssetId(LLAssetID::null) +{ + mTransactionId.generate(); +} + LLSD NewResourceUploadInfo::prepareUpload() { @@ -251,16 +301,14 @@ NewFileResourceUploadInfo::NewFileResourceUploadInfo( nextOWnerPerms, groupPerms, everyonePerms, expectedCost), mFileName(fileName) { - LLTransactionID tid; - tid.generate(); - setTransactionId(tid); } LLSD NewFileResourceUploadInfo::prepareUpload() { - generateNewAssetId(); + if (getAssetId().isNull()) + generateNewAssetId(); LLSD result = exportTempFile(); if (result.has("error")) @@ -394,7 +442,103 @@ LLSD NewFileResourceUploadInfo::exportTempFile() } //========================================================================= +LLBufferedAssetUploadInfo::LLBufferedAssetUploadInfo(LLUUID itemId, LLAssetType::EType assetType, std::string buffer, invnUploadFinish_f finish) : + NewResourceUploadInfo(std::string(), std::string(), 0, LLFolderType::FT_NONE, LLInventoryType::IT_NONE, + 0, 0, 0, 0), + mTaskUpload(false), + mTaskId(LLUUID::null), + mContents(buffer), + mInvnFinishFn(finish), + mTaskFinishFn(NULL) +{ + setItemId(itemId); + setAssetType(assetType); + +} + +LLBufferedAssetUploadInfo::LLBufferedAssetUploadInfo(LLUUID taskId, LLUUID itemId, LLAssetType::EType assetType, std::string buffer, taskUploadFinish_f finish) : + NewResourceUploadInfo(std::string(), std::string(), 0, LLFolderType::FT_NONE, LLInventoryType::IT_NONE, + 0, 0, 0, 0), + mTaskUpload(true), + mTaskId(taskId), + mContents(buffer), + mInvnFinishFn(NULL), + mTaskFinishFn(finish) +{ + setItemId(itemId); + setAssetType(assetType); +} + + +LLSD LLBufferedAssetUploadInfo::prepareUpload() +{ + if (getAssetId().isNull()) + generateNewAssetId(); + + LLVFile file(gVFS, getAssetId(), getAssetType(), LLVFile::APPEND); + + S32 size = mContents.length() + 1; + file.setMaxSize(size); + file.write((U8*)mContents.c_str(), size); + + return LLSD().with("success", LLSD::Boolean(true)); +} + +LLSD LLBufferedAssetUploadInfo::generatePostBody() +{ + LLSD body; + + if (!getTaskId().isNull()) + { + body["task_id"] = getTaskId(); + } + body["item_id"] = getItemId(); + + return body; +} + +LLUUID LLBufferedAssetUploadInfo::finishUpload(LLSD &result) +{ + LLUUID newAssetId = result["new_asset"].asUUID(); + LLUUID itemId = getItemId(); + + if (mTaskUpload) + { + LLUUID taskId = getTaskId(); + + dialog_refresh_all(); + + if (mTaskFinishFn) + { + mTaskFinishFn(itemId, taskId, newAssetId, result); + } + } + else + { + LLViewerInventoryItem* item = (LLViewerInventoryItem*)gInventory.getItem(itemId); + if(!item) + { + LL_WARNS() << "Inventory item for " << getDisplayName() << " is no longer in agent inventory." << LL_ENDL; + return newAssetId; + } + // Update viewer inventory item + LLPointer newItem = new LLViewerInventoryItem(item); + newItem->setAssetUUID(newAssetId); + + gInventory.updateItem(newItem); + + LL_INFOS() << "Inventory item " << item->getName() << " saved into " << newAssetId.asString() << LL_ENDL; + + if (mInvnFinishFn) + { + mInvnFinishFn(itemId, newAssetId, newItem->getUUID(), result); + } + gInventory.notifyObservers(); + } + + return newAssetId; +} //========================================================================= /*static*/ @@ -414,9 +558,12 @@ void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoros::self &self, LLCore //self.yield(); - std::string uploadMessage = "Uploading...\n\n"; - uploadMessage.append(uploadInfo->getDisplayName()); - LLUploadDialog::modalUploadDialog(uploadMessage); + if (uploadInfo->showUploadDialog()) + { + std::string uploadMessage = "Uploading...\n\n"; + uploadMessage.append(uploadInfo->getDisplayName()); + LLUploadDialog::modalUploadDialog(uploadMessage); + } LLSD body = uploadInfo->generatePostBody(); @@ -428,7 +575,8 @@ void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoros::self &self, LLCore if ((!status) || (result.has("error"))) { HandleUploadError(status, result, uploadInfo); - LLUploadDialog::modalUploadFinished(); + if (uploadInfo->showUploadDialog()) + LLUploadDialog::modalUploadFinished(); return; } @@ -441,7 +589,8 @@ void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoros::self &self, LLCore if (!status) { HandleUploadError(status, result, uploadInfo); - LLUploadDialog::modalUploadFinished(); + if (uploadInfo->showUploadDialog()) + LLUploadDialog::modalUploadFinished(); return; } @@ -494,7 +643,8 @@ void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoros::self &self, LLCore } // remove the "Uploading..." message - LLUploadDialog::modalUploadFinished(); + if (uploadInfo->showUploadDialog()) + LLUploadDialog::modalUploadFinished(); // Let the Snapshot floater know we have finished uploading a snapshot to inventory. LLFloater* floater_snapshot = LLFloaterReg::findInstance("snapshot"); diff --git a/indra/newview/llviewerassetupload.h b/indra/newview/llviewerassetupload.h index a2b250b33b..d44999472c 100644 --- a/indra/newview/llviewerassetupload.h +++ b/indra/newview/llviewerassetupload.h @@ -41,32 +41,17 @@ public: typedef boost::shared_ptr ptr_t; NewResourceUploadInfo( - LLTransactionID transactId, - LLAssetType::EType assetType, - std::string name, - std::string description, - S32 compressionInfo, - LLFolderType::EType destinationType, - LLInventoryType::EType inventoryType, - U32 nextOWnerPerms, - U32 groupPerms, - U32 everyonePerms, - S32 expectedCost) : - mTransactionId(transactId), - mAssetType(assetType), - mName(name), - mDescription(description), - mCompressionInfo(compressionInfo), - mDestinationFolderType(destinationType), - mInventoryType(inventoryType), - mNextOwnerPerms(nextOWnerPerms), - mGroupPerms(groupPerms), - mEveryonePerms(everyonePerms), - mExpectedUploadCost(expectedCost), - mFolderId(LLUUID::null), - mItemId(LLUUID::null), - mAssetId(LLAssetID::null) - { } + LLTransactionID transactId, + LLAssetType::EType assetType, + std::string name, + std::string description, + S32 compressionInfo, + LLFolderType::EType destinationType, + LLInventoryType::EType inventoryType, + U32 nextOWnerPerms, + U32 groupPerms, + U32 everyonePerms, + S32 expectedCost); virtual ~NewResourceUploadInfo() { } @@ -90,6 +75,8 @@ public: U32 getEveryonePerms() const { return mEveryonePerms; }; S32 getExpectedUploadCost() const { return mExpectedUploadCost; }; + virtual bool showUploadDialog() const { return true; } + virtual std::string getDisplayName() const; LLUUID getFolderId() const { return mFolderId; } @@ -98,33 +85,19 @@ public: protected: NewResourceUploadInfo( - std::string name, - std::string description, - S32 compressionInfo, - LLFolderType::EType destinationType, - LLInventoryType::EType inventoryType, - U32 nextOWnerPerms, - U32 groupPerms, - U32 everyonePerms, - S32 expectedCost) : - mName(name), - mDescription(description), - mCompressionInfo(compressionInfo), - mDestinationFolderType(destinationType), - mInventoryType(inventoryType), - mNextOwnerPerms(nextOWnerPerms), - mGroupPerms(groupPerms), - mEveryonePerms(everyonePerms), - mExpectedUploadCost(expectedCost), - mTransactionId(), - mAssetType(LLAssetType::AT_NONE), - mFolderId(LLUUID::null), - mItemId(LLUUID::null), - mAssetId(LLAssetID::null) - { } + std::string name, + std::string description, + S32 compressionInfo, + LLFolderType::EType destinationType, + LLInventoryType::EType inventoryType, + U32 nextOWnerPerms, + U32 groupPerms, + U32 everyonePerms, + S32 expectedCost); void setTransactionId(LLTransactionID tid) { mTransactionId = tid; } void setAssetType(LLAssetType::EType assetType) { mAssetType = assetType; } + void setItemId(LLUUID itemId) { mItemId = itemId; } LLAssetID generateNewAssetId(); void incrementUploadStats() const; @@ -176,26 +149,52 @@ private: }; -#if 0 -class NotecardResourceUploadInfo : public NewResourceUploadInfo + +class LLBufferedAssetUploadInfo : public NewResourceUploadInfo { public: - NotecardResourceUploadInfo( - ); + typedef boost::function invnUploadFinish_f; + typedef boost::function taskUploadFinish_f; + + LLBufferedAssetUploadInfo(LLUUID itemId, LLAssetType::EType assetType, std::string buffer, invnUploadFinish_f finish); + LLBufferedAssetUploadInfo(LLUUID taskId, LLUUID itemId, LLAssetType::EType assetType, std::string buffer, taskUploadFinish_f finish); + + virtual LLSD prepareUpload(); + virtual LLSD generatePostBody(); + virtual LLUUID finishUpload(LLSD &result); + LLUUID getTaskId() const { return mTaskId; } + const std::string & getContents() const { return mContents; } + + virtual bool showUploadDialog() const { return false; } protected: + private: + bool mTaskUpload; + LLUUID mTaskId; + std::string mContents; + invnUploadFinish_f mInvnFinishFn; + taskUploadFinish_f mTaskFinishFn; +}; + +class LLScriptAssetUpload : public LLBufferedAssetUploadInfo +{ +public: + LLScriptAssetUpload(LLUUID itemId, LLAssetType::EType assetType, std::string buffer, invnUploadFinish_f finish); + LLScriptAssetUpload(LLUUID taskId, LLUUID itemId, LLAssetType::EType assetType, std::string buffer, taskUploadFinish_f finish); + + virtual LLSD generatePostBody(); + }; -#endif class LLViewerAssetUpload { public: - static void AssetInventoryUploadCoproc(LLCoros::self &self, LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &httpAdapter, const LLUUID &id, - std::string url, NewResourceUploadInfo::ptr_t uploadInfo); + static void AssetInventoryUploadCoproc(LLCoros::self &self, LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &httpAdapter, + const LLUUID &id, std::string url, NewResourceUploadInfo::ptr_t uploadInfo); private: static void HandleUploadError(LLCore::HttpStatus status, LLSD &result, NewResourceUploadInfo::ptr_t &uploadInfo); -- cgit v1.2.3 From f1be78f7e235bfe9395eed748154d77763d5ea65 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Sat, 11 Jul 2015 08:06:15 -0400 Subject: MAINT-5351: Finish messy merge restoring 'selfless' changes. --- indra/llmessage/llcorehttputil.cpp | 10 +++++----- indra/newview/llcoproceduremanager.cpp | 2 +- indra/newview/lleventpoll.cpp | 2 +- indra/newview/llpreviewnotecard.cpp | 2 +- indra/newview/llviewerassetupload.h | 3 +-- 5 files changed, 9 insertions(+), 10 deletions(-) (limited to 'indra') diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index 05d74a45a2..a6ed287aeb 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -596,7 +596,7 @@ LLSD HttpCoroutineAdapter::postAndYield_(LLCore::HttpRequest::ptr_t &request, } saveState(hhandle, request, handler); - LLSD results = waitForEventOn(handler->getReplyPump()); + LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); cleanState(); return results; @@ -697,7 +697,7 @@ LLSD HttpCoroutineAdapter::postAndYield_(LLCore::HttpRequest::ptr_t &request, } saveState(hhandle, request, handler); - LLSD results = waitForEventOn(handler->getReplyPump()); + LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; @@ -735,7 +735,7 @@ LLSD HttpCoroutineAdapter::putAndYield_(LLCore::HttpRequest::ptr_t &request, } saveState(hhandle, request, handler); - LLSD results = waitForEventOn(handler->getReplyPump()); + LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; @@ -790,7 +790,7 @@ LLSD HttpCoroutineAdapter::getAndYield_(LLCore::HttpRequest::ptr_t &request, } saveState(hhandle, request, handler); - LLSD results = waitForEventOn(handler->getReplyPump()); + LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; @@ -825,7 +825,7 @@ LLSD HttpCoroutineAdapter::deleteAndYield_(LLCore::HttpRequest::ptr_t &request, } saveState(hhandle, request, handler); - LLSD results = waitForEventOn(handler->getReplyPump()); + LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; diff --git a/indra/newview/llcoproceduremanager.cpp b/indra/newview/llcoproceduremanager.cpp index 1a4a906f35..d3168985f8 100644 --- a/indra/newview/llcoproceduremanager.cpp +++ b/indra/newview/llcoproceduremanager.cpp @@ -138,7 +138,7 @@ void LLCoprocedureManager::coprocedureInvokerCoro(LLCoreHttpUtil::HttpCoroutineA while (!mShutdown) { - waitForEventOn(mWakeupTrigger); + llcoro::waitForEventOn(mWakeupTrigger); if (mShutdown) break; diff --git a/indra/newview/lleventpoll.cpp b/indra/newview/lleventpoll.cpp index 54da226209..0aad1d5ba9 100755 --- a/indra/newview/lleventpoll.cpp +++ b/indra/newview/lleventpoll.cpp @@ -197,7 +197,7 @@ namespace Details " seconds, error count is now " << errorCount << LL_ENDL; timeout.eventAfter(waitToRetry, LLSD()); - waitForEventOn(timeout); + llcoro::waitForEventOn(timeout); if (mDone) break; diff --git a/indra/newview/llpreviewnotecard.cpp b/indra/newview/llpreviewnotecard.cpp index b9941b7591..cbd940fb99 100755 --- a/indra/newview/llpreviewnotecard.cpp +++ b/indra/newview/llpreviewnotecard.cpp @@ -491,7 +491,7 @@ bool LLPreviewNotecard::saveIfNeeded(LLInventoryItem* copyitem) mAssetStatus = PREVIEW_ASSET_LOADING; setEnabled(false); - LLCoprocedureManager::CoProcedure_t proc = boost::bind(&LLViewerAssetUpload::AssetInventoryUploadCoproc, _1, _2, _3, url, uploadInfo); + LLCoprocedureManager::CoProcedure_t proc = boost::bind(&LLViewerAssetUpload::AssetInventoryUploadCoproc, _1, _2, url, uploadInfo); LLCoprocedureManager::getInstance()->enqueueCoprocedure("LLViewerAssetUpload::AssetInventoryUploadCoproc", proc); } diff --git a/indra/newview/llviewerassetupload.h b/indra/newview/llviewerassetupload.h index b3957c361e..351c2267b7 100644 --- a/indra/newview/llviewerassetupload.h +++ b/indra/newview/llviewerassetupload.h @@ -193,8 +193,7 @@ class LLViewerAssetUpload { public: - static void AssetInventoryUploadCoproc(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &httpAdapter, const LLUUID &id, - const LLUUID &id, std::string url, NewResourceUploadInfo::ptr_t uploadInfo); + static void AssetInventoryUploadCoproc(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &httpAdapter, const LLUUID &id, std::string url, NewResourceUploadInfo::ptr_t uploadInfo); private: static void HandleUploadError(LLCore::HttpStatus status, LLSD &result, NewResourceUploadInfo::ptr_t &uploadInfo); -- cgit v1.2.3 From 8e6bea61a9763703b89e1da220b9d67573f9fb7c Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Sun, 12 Jul 2015 10:57:13 -0400 Subject: MAINT-5351: llupdaterservice_test now needs Boost System library. --- indra/viewer_components/updater/CMakeLists.txt | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'indra') diff --git a/indra/viewer_components/updater/CMakeLists.txt b/indra/viewer_components/updater/CMakeLists.txt index 53e309290f..0d44334276 100755 --- a/indra/viewer_components/updater/CMakeLists.txt +++ b/indra/viewer_components/updater/CMakeLists.txt @@ -6,6 +6,7 @@ include(00-Common) if(LL_TESTS) include(LLAddBuildTest) endif(LL_TESTS) +include(Boost) include(CMakeCopyIfDifferent) include(CURL) include(LLCommon) @@ -72,14 +73,16 @@ if(LL_TESTS) llupdaterservice.cpp ) + +set_source_files_properties( + llupdaterservice.cpp + PROPERTIES + LL_TEST_ADDITIONAL_LIBRARIES "${BOOST_SYSTEM_LIBRARY}" # *NOTE:Mani - I was trying to use the preprocessor seam to mock out -# llifstream (and other) llcommon classes. I didn't work +# llifstream (and other) llcommon classes. It didn't work # because of the windows declspec(dllimport)attribute. -#set_source_files_properties( -# llupdaterservice.cpp -# PROPERTIES -# LL_TEST_ADDITIONAL_CFLAGS "-Dllifstream=llus_mock_llifstream" -# ) +# LL_TEST_ADDITIONAL_CFLAGS "-Dllifstream=llus_mock_llifstream" + ) LL_ADD_PROJECT_UNIT_TESTS(llupdaterservice "${llupdater_service_TEST_SOURCE_FILES}") endif(LL_TESTS) -- cgit v1.2.3 From ec466b2f5ea5149a4d5d5ead12891d308a96b8ff Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Sun, 12 Jul 2015 14:38:06 -0400 Subject: MAINT-5351: glh-linear 'equivalent' macro has been destroyed. Hopefully we no longer need to brute-force remove any more macros with the same name. --- indra/llcommon/fix_macros.h | 4 ---- 1 file changed, 4 deletions(-) (limited to 'indra') diff --git a/indra/llcommon/fix_macros.h b/indra/llcommon/fix_macros.h index ef959decff..43c09c54bc 100755 --- a/indra/llcommon/fix_macros.h +++ b/indra/llcommon/fix_macros.h @@ -16,10 +16,6 @@ // these macros all over again. // who injects MACROS with such generic names?! Grr. -#ifdef equivalent -#undef equivalent -#endif - #ifdef check #undef check #endif -- cgit v1.2.3 From 0ba39810a90c5feaa741e5b1283c55e126bcaf66 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 13 Jul 2015 12:42:23 -0700 Subject: Rename the file in VFS with the new asset AID (prevents crash on gesture change and fixes notecard update) --- indra/newview/llpreviewgesture.cpp | 4 ++-- indra/newview/llviewerassetupload.cpp | 19 +++++++++++++++---- indra/newview/llviewerassetupload.h | 1 + 3 files changed, 18 insertions(+), 6 deletions(-) (limited to 'indra') diff --git a/indra/newview/llpreviewgesture.cpp b/indra/newview/llpreviewgesture.cpp index 6c12885864..fc6023beb2 100755 --- a/indra/newview/llpreviewgesture.cpp +++ b/indra/newview/llpreviewgesture.cpp @@ -1051,7 +1051,7 @@ void LLPreviewGesture::saveIfNeeded() return; } -#if 0 +#if 1 // Copy the UI into a gesture LLMultiGesture* gesture = createGesture(); @@ -1123,7 +1123,7 @@ void LLPreviewGesture::saveIfNeeded() { delayedUpload = true; - LLCoprocedureManager::CoProcedure_t proc = boost::bind(&LLViewerAssetUpload::AssetInventoryUploadCoproc, _1, _2, _3, url, uploadInfo); + LLCoprocedureManager::CoProcedure_t proc = boost::bind(&LLViewerAssetUpload::AssetInventoryUploadCoproc, _1, _2, url, uploadInfo); LLCoprocedureManager::getInstance()->enqueueCoprocedure("LLViewerAssetUpload::AssetInventoryUploadCoproc", proc); } diff --git a/indra/newview/llviewerassetupload.cpp b/indra/newview/llviewerassetupload.cpp index f1a253a421..910e1dc6c5 100644 --- a/indra/newview/llviewerassetupload.cpp +++ b/indra/newview/llviewerassetupload.cpp @@ -449,7 +449,8 @@ LLBufferedAssetUploadInfo::LLBufferedAssetUploadInfo(LLUUID itemId, LLAssetType: mTaskId(LLUUID::null), mContents(buffer), mInvnFinishFn(finish), - mTaskFinishFn(NULL) + mTaskFinishFn(NULL), + mStoredToVFS(false) { setItemId(itemId); setAssetType(assetType); @@ -463,7 +464,8 @@ LLBufferedAssetUploadInfo::LLBufferedAssetUploadInfo(LLUUID taskId, LLUUID itemI mTaskId(taskId), mContents(buffer), mInvnFinishFn(NULL), - mTaskFinishFn(finish) + mTaskFinishFn(finish), + mStoredToVFS(false) { setItemId(itemId); setAssetType(assetType); @@ -481,6 +483,9 @@ LLSD LLBufferedAssetUploadInfo::prepareUpload() file.setMaxSize(size); file.write((U8*)mContents.c_str(), size); + mStoredToVFS = true; + + return LLSD().with("success", LLSD::Boolean(true)); } @@ -502,6 +507,12 @@ LLUUID LLBufferedAssetUploadInfo::finishUpload(LLSD &result) LLUUID newAssetId = result["new_asset"].asUUID(); LLUUID itemId = getItemId(); + if (mStoredToVFS) + { + LLAssetType::EType assetType(getAssetType()); + gVFS->renameFile(getAssetId(), assetType, newAssetId, assetType); + } + if (mTaskUpload) { LLUUID taskId = getTaskId(); @@ -542,8 +553,8 @@ LLUUID LLBufferedAssetUploadInfo::finishUpload(LLSD &result) //========================================================================= /*static*/ -void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &httpAdapter, const LLUUID &id, - std::string url, NewResourceUploadInfo::ptr_t uploadInfo) +void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &httpAdapter, + const LLUUID &id, std::string url, NewResourceUploadInfo::ptr_t uploadInfo) { LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); diff --git a/indra/newview/llviewerassetupload.h b/indra/newview/llviewerassetupload.h index 351c2267b7..b80166a874 100644 --- a/indra/newview/llviewerassetupload.h +++ b/indra/newview/llviewerassetupload.h @@ -177,6 +177,7 @@ private: std::string mContents; invnUploadFinish_f mInvnFinishFn; taskUploadFinish_f mTaskFinishFn; + bool mStoredToVFS; }; class LLScriptAssetUpload : public LLBufferedAssetUploadInfo -- cgit v1.2.3 From 03c202a47545cac1d7643f5e5c9973f4a476f83d Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 13 Jul 2015 12:51:11 -0700 Subject: Remove the dead code. --- indra/newview/llpreviewgesture.cpp | 113 ------------------------------------- 1 file changed, 113 deletions(-) (limited to 'indra') diff --git a/indra/newview/llpreviewgesture.cpp b/indra/newview/llpreviewgesture.cpp index fc6023beb2..05e4eaf9cf 100755 --- a/indra/newview/llpreviewgesture.cpp +++ b/indra/newview/llpreviewgesture.cpp @@ -1051,7 +1051,6 @@ void LLPreviewGesture::saveIfNeeded() return; } -#if 1 // Copy the UI into a gesture LLMultiGesture* gesture = createGesture(); @@ -1175,118 +1174,6 @@ void LLPreviewGesture::saveIfNeeded() refresh(); } -#else - // Copy the UI into a gesture - LLMultiGesture* gesture = createGesture(); - - // Serialize the gesture - S32 max_size = gesture->getMaxSerialSize(); - char* buffer = new char[max_size]; - - LLDataPackerAsciiBuffer dp(buffer, max_size); - - BOOL ok = gesture->serialize(dp); - - if (dp.getCurrentSize() > 1000) - { - LLNotificationsUtil::add("GestureSaveFailedTooManySteps"); - - delete gesture; - gesture = NULL; - } - else if (!ok) - { - LLNotificationsUtil::add("GestureSaveFailedTryAgain"); - delete gesture; - gesture = NULL; - } - else - { - LLPreview::onCommit(); - - // Every save gets a new UUID. Yup. - LLTransactionID tid; - LLAssetID asset_id; - tid.generate(); - asset_id = tid.makeAssetID(gAgent.getSecureSessionID()); - - LLVFile file(gVFS, asset_id, LLAssetType::AT_GESTURE, LLVFile::APPEND); - - S32 size = dp.getCurrentSize(); - file.setMaxSize(size); - file.write((U8*)buffer, size); - - BOOL delayedUpload = FALSE; - - // Upload that asset to the database - LLViewerInventoryItem* item = (LLViewerInventoryItem*) getItem(); - if (item) - { - std::string agent_url = gAgent.getRegion()->getCapability("UpdateGestureAgentInventory"); - std::string task_url = gAgent.getRegion()->getCapability("UpdateGestureTaskInventory"); - if (mObjectUUID.isNull() && !agent_url.empty()) - { - //need to disable the preview floater so item - //isn't re-saved before new asset arrives - //fake out refresh. - item->setComplete(FALSE); - refresh(); - item->setComplete(TRUE); - - // Saving into agent inventory - LLSD body; - body["item_id"] = mItemUUID; - LLHTTPClient::post(agent_url, body, - new LLUpdateAgentInventoryResponder(body, asset_id, LLAssetType::AT_GESTURE)); - delayedUpload = TRUE; - } - else if (!mObjectUUID.isNull() && !task_url.empty()) - { - // Saving into task inventory - LLSD body; - body["task_id"] = mObjectUUID; - body["item_id"] = mItemUUID; - LLHTTPClient::post(task_url, body, - new LLUpdateTaskInventoryResponder(body, asset_id, LLAssetType::AT_GESTURE)); - } - else if (gAssetStorage) - { - LLLineEditor* descEditor = getChild("desc"); - LLSaveInfo* info = new LLSaveInfo(mItemUUID, mObjectUUID, descEditor->getText(), tid); - gAssetStorage->storeAssetData(tid, LLAssetType::AT_GESTURE, onSaveComplete, info, FALSE); - } - } - - // If this gesture is active, then we need to update the in-memory - // active map with the new pointer. - if (!delayedUpload && LLGestureMgr::instance().isGestureActive(mItemUUID)) - { - // gesture manager now owns the pointer - LLGestureMgr::instance().replaceGesture(mItemUUID, gesture, asset_id); - - // replaceGesture may deactivate other gestures so let the - // inventory know. - gInventory.notifyObservers(); - } - else - { - // we're done with this gesture - delete gesture; - gesture = NULL; - } - - mDirty = FALSE; - // refresh will be called when callback - // if triggered when delayedUpload - if(!delayedUpload) - { - refresh(); - } - } - - delete [] buffer; - buffer = NULL; -#endif } -- cgit v1.2.3 From 1a6a6c786dcb4164c51734e51a4c86c722835e56 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 15 Jul 2015 14:35:53 -0700 Subject: LSL Script upload from inventory. --- indra/newview/llassetuploadresponders.cpp | 3 +- indra/newview/llassetuploadresponders.h | 2 + indra/newview/llfloaterbvhpreview.cpp | 2 +- indra/newview/llfloaternamedesc.cpp | 2 +- indra/newview/llpreviewgesture.cpp | 11 ++--- indra/newview/llpreviewnotecard.cpp | 11 ++--- indra/newview/llpreviewscript.cpp | 79 +++++++++++++++++++++++++++---- indra/newview/llpreviewscript.h | 2 + indra/newview/llsnapshotlivepreview.cpp | 2 +- indra/newview/llviewerassetupload.cpp | 74 ++++++++++++++++++++++------- indra/newview/llviewerassetupload.h | 27 ++++++----- indra/newview/llviewermenufile.cpp | 11 ++--- indra/newview/llviewermenufile.h | 2 +- 13 files changed, 165 insertions(+), 63 deletions(-) (limited to 'indra') diff --git a/indra/newview/llassetuploadresponders.cpp b/indra/newview/llassetuploadresponders.cpp index fe01288e23..14020af166 100755 --- a/indra/newview/llassetuploadresponders.cpp +++ b/indra/newview/llassetuploadresponders.cpp @@ -476,6 +476,7 @@ void LLNewAgentInventoryResponder::uploadComplete(const LLSD& content) } #endif +#if 0 LLUpdateAgentInventoryResponder::LLUpdateAgentInventoryResponder( const LLSD& post_data, const LLUUID& vfile_id, @@ -582,7 +583,7 @@ void LLUpdateAgentInventoryResponder::uploadComplete(const LLSD& content) break; } } - +#endif LLUpdateTaskInventoryResponder::LLUpdateTaskInventoryResponder(const LLSD& post_data, const LLUUID& vfile_id, diff --git a/indra/newview/llassetuploadresponders.h b/indra/newview/llassetuploadresponders.h index 6828678f09..71995873fa 100755 --- a/indra/newview/llassetuploadresponders.h +++ b/indra/newview/llassetuploadresponders.h @@ -119,6 +119,7 @@ private: }; #endif +#if 0 class LLUpdateAgentInventoryResponder : public LLAssetUploadResponder { public: @@ -130,6 +131,7 @@ public: LLAssetType::EType asset_type); virtual void uploadComplete(const LLSD& content); }; +#endif class LLUpdateTaskInventoryResponder : public LLAssetUploadResponder { diff --git a/indra/newview/llfloaterbvhpreview.cpp b/indra/newview/llfloaterbvhpreview.cpp index 39b5a40efc..e5df417ca9 100755 --- a/indra/newview/llfloaterbvhpreview.cpp +++ b/indra/newview/llfloaterbvhpreview.cpp @@ -994,7 +994,7 @@ void LLFloaterBvhPreview::onBtnOK(void* userdata) std::string desc = floaterp->getChild("description_form")->getValue().asString(); S32 expected_upload_cost = LLGlobalEconomy::Singleton::getInstance()->getPriceUpload(); - NewResourceUploadInfo::ptr_t assetUpdloadInfo(new NewResourceUploadInfo( + LLResourceUploadInfo::ptr_t assetUpdloadInfo(new LLResourceUploadInfo( floaterp->mTransactionID, LLAssetType::AT_ANIMATION, name, desc, 0, LLFolderType::FT_NONE, LLInventoryType::IT_ANIMATION, diff --git a/indra/newview/llfloaternamedesc.cpp b/indra/newview/llfloaternamedesc.cpp index 6912adfcff..46dbf85dfa 100755 --- a/indra/newview/llfloaternamedesc.cpp +++ b/indra/newview/llfloaternamedesc.cpp @@ -164,7 +164,7 @@ void LLFloaterNameDesc::onBtnOK( ) void *nruserdata = NULL; std::string display_name = LLStringUtil::null; - NewResourceUploadInfo::ptr_t uploadInfo(new NewFileResourceUploadInfo( + LLResourceUploadInfo::ptr_t uploadInfo(new NewFileResourceUploadInfo( mFilenameAndPath, getChild("name_form")->getValue().asString(), getChild("description_form")->getValue().asString(), 0, diff --git a/indra/newview/llpreviewgesture.cpp b/indra/newview/llpreviewgesture.cpp index 05e4eaf9cf..c1d1b9b03c 100755 --- a/indra/newview/llpreviewgesture.cpp +++ b/indra/newview/llpreviewgesture.cpp @@ -53,7 +53,6 @@ #include "llviewerregion.h" #include "llviewerstats.h" #include "llviewerassetupload.h" -#include "llcoproceduremanager.h" std::string NONE_LABEL; std::string SHIFT_LABEL; @@ -1097,7 +1096,7 @@ void LLPreviewGesture::saveIfNeeded() if (!agent_url.empty() && !task_url.empty()) { std::string url; - NewResourceUploadInfo::ptr_t uploadInfo; + LLResourceUploadInfo::ptr_t uploadInfo; if (mObjectUUID.isNull() && !agent_url.empty()) { @@ -1108,13 +1107,13 @@ void LLPreviewGesture::saveIfNeeded() refresh(); item->setComplete(true); - uploadInfo = NewResourceUploadInfo::ptr_t(new LLBufferedAssetUploadInfo(mItemUUID, LLAssetType::AT_GESTURE, buffer, + uploadInfo = LLResourceUploadInfo::ptr_t(new LLBufferedAssetUploadInfo(mItemUUID, LLAssetType::AT_GESTURE, buffer, boost::bind(&finishInventoryUpload, _1, _2))); url = agent_url; } else if (!mObjectUUID.isNull() && !task_url.empty()) { - uploadInfo = NewResourceUploadInfo::ptr_t(new LLBufferedAssetUploadInfo(mObjectUUID, mItemUUID, LLAssetType::AT_GESTURE, buffer, NULL)); + uploadInfo = LLResourceUploadInfo::ptr_t(new LLBufferedAssetUploadInfo(mObjectUUID, mItemUUID, LLAssetType::AT_GESTURE, buffer, NULL)); url = task_url; } @@ -1122,9 +1121,7 @@ void LLPreviewGesture::saveIfNeeded() { delayedUpload = true; - LLCoprocedureManager::CoProcedure_t proc = boost::bind(&LLViewerAssetUpload::AssetInventoryUploadCoproc, _1, _2, url, uploadInfo); - - LLCoprocedureManager::getInstance()->enqueueCoprocedure("LLViewerAssetUpload::AssetInventoryUploadCoproc", proc); + LLViewerAssetUpload::EnqueueInventoryUpload(url, uploadInfo); } } diff --git a/indra/newview/llpreviewnotecard.cpp b/indra/newview/llpreviewnotecard.cpp index cbd940fb99..be44fbd300 100755 --- a/indra/newview/llpreviewnotecard.cpp +++ b/indra/newview/llpreviewnotecard.cpp @@ -56,7 +56,6 @@ #include "llappviewer.h" // app_abort_quit() #include "lllineeditor.h" #include "lluictrlfactory.h" -#include "llcoproceduremanager.h" #include "llviewerassetupload.h" ///---------------------------------------------------------------------------- @@ -471,17 +470,17 @@ bool LLPreviewNotecard::saveIfNeeded(LLInventoryItem* copyitem) if (!agent_url.empty() && !task_url.empty()) { std::string url; - NewResourceUploadInfo::ptr_t uploadInfo; + LLResourceUploadInfo::ptr_t uploadInfo; if (mObjectUUID.isNull() && !agent_url.empty()) { - uploadInfo = NewResourceUploadInfo::ptr_t(new LLBufferedAssetUploadInfo(mItemUUID, LLAssetType::AT_NOTECARD, buffer, + uploadInfo = LLResourceUploadInfo::ptr_t(new LLBufferedAssetUploadInfo(mItemUUID, LLAssetType::AT_NOTECARD, buffer, boost::bind(&finishInventoryUpload, _1, _2, _3))); url = agent_url; } else if (!mObjectUUID.isNull() && !task_url.empty()) { - uploadInfo = NewResourceUploadInfo::ptr_t(new LLBufferedAssetUploadInfo(mObjectUUID, mItemUUID, LLAssetType::AT_NOTECARD, buffer, + uploadInfo = LLResourceUploadInfo::ptr_t(new LLBufferedAssetUploadInfo(mObjectUUID, mItemUUID, LLAssetType::AT_NOTECARD, buffer, boost::bind(&finishInventoryUpload, _1, _3, LLUUID::null))); url = task_url; } @@ -491,9 +490,7 @@ bool LLPreviewNotecard::saveIfNeeded(LLInventoryItem* copyitem) mAssetStatus = PREVIEW_ASSET_LOADING; setEnabled(false); - LLCoprocedureManager::CoProcedure_t proc = boost::bind(&LLViewerAssetUpload::AssetInventoryUploadCoproc, _1, _2, url, uploadInfo); - - LLCoprocedureManager::getInstance()->enqueueCoprocedure("LLViewerAssetUpload::AssetInventoryUploadCoproc", proc); + LLViewerAssetUpload::EnqueueInventoryUpload(url, uploadInfo); } } diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index 1bbb22416d..fc565ffa20 100755 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -89,6 +89,7 @@ #include "llexperiencecache.h" #include "llfloaterexperienceprofile.h" #include "llexperienceassociationresponder.h" +#include "llviewerassetupload.h" const std::string HELLO_LSL = "default\n" @@ -1641,20 +1642,79 @@ void LLPreviewLSL::onSave(void* userdata, BOOL close_after_save) self->saveIfNeeded(); } +void finishedLSLUpload(LLUUID itemId, LLSD response) +{ + // Find our window and close it if requested. + LLPreviewLSL* preview = LLFloaterReg::findTypedInstance("preview_script", LLSD(itemId)); + if (preview) + { + // Bytecode save completed + if (response["compiled"]) + { + preview->callbackLSLCompileSucceeded(); + } + else + { + preview->callbackLSLCompileFailed(response["errors"]); + } + } +} + // Save needs to compile the text in the buffer. If the compile // succeeds, then save both assets out to the database. If the compile // fails, go ahead and save the text anyway. void LLPreviewLSL::saveIfNeeded(bool sync /*= true*/) { + if (!mScriptEd->hasChanged()) + { + return; + } + + mPendingUploads = 0; + mScriptEd->mErrorList->deleteAllItems(); + mScriptEd->mEditor->makePristine(); + +#if 1 + if (sync) + { + mScriptEd->sync(); + } + + const LLInventoryItem *inv_item = getItem(); + // save it out to asset server + std::string url = gAgent.getRegion()->getCapability("UpdateScriptAgent"); + if(inv_item) + { + getWindow()->incBusyCount(); + mPendingUploads++; + if (!url.empty()) + { + std::string buffer(mScriptEd->mEditor->getText()); + LLBufferedAssetUploadInfo::invnUploadFinish_f proc = boost::bind(&finishedLSLUpload, _1, _4); + + LLResourceUploadInfo::ptr_t uploadInfo(new LLScriptAssetUpload(mItemUUID, buffer, proc)); + + LLViewerAssetUpload::EnqueueInventoryUpload(url, uploadInfo); + + } + else if (gAssetStorage) + { + // save off asset into file + LLTransactionID tid; + tid.generate(); + LLAssetID asset_id = tid.makeAssetID(gAgent.getSecureSessionID()); + std::string filepath = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, asset_id.asString()); + std::string filename = filepath + ".lsl"; + + mScriptEd->writeToFile(filename); + + uploadAssetLegacy(filename, mItemUUID, tid); + } + } + + +#else // LL_INFOS() << "LLPreviewLSL::saveIfNeeded()" << LL_ENDL; - if(!mScriptEd->hasChanged()) - { - return; - } - - mPendingUploads = 0; - mScriptEd->mErrorList->deleteAllItems(); - mScriptEd->mEditor->makePristine(); // save off asset into file LLTransactionID tid; @@ -1686,8 +1746,10 @@ void LLPreviewLSL::saveIfNeeded(bool sync /*= true*/) uploadAssetLegacy(filename, mItemUUID, tid); } } +#endif } +#if 0 void LLPreviewLSL::uploadAssetViaCaps(const std::string& url, const std::string& filename, const LLUUID& item_id) @@ -1698,6 +1760,7 @@ void LLPreviewLSL::uploadAssetViaCaps(const std::string& url, body["target"] = "lsl2"; LLHTTPClient::post(url, body, new LLUpdateAgentInventoryResponder(body, filename, LLAssetType::AT_LSL_TEXT)); } +#endif void LLPreviewLSL::uploadAssetLegacy(const std::string& filename, const LLUUID& item_id, diff --git a/indra/newview/llpreviewscript.h b/indra/newview/llpreviewscript.h index 5f65be7383..954d040bda 100755 --- a/indra/newview/llpreviewscript.h +++ b/indra/newview/llpreviewscript.h @@ -203,9 +203,11 @@ protected: virtual void loadAsset(); /*virtual*/ void saveIfNeeded(bool sync = true); +#if 0 void uploadAssetViaCaps(const std::string& url, const std::string& filename, const LLUUID& item_id); +#endif // 0 void uploadAssetLegacy(const std::string& filename, const LLUUID& item_id, const LLTransactionID& tid); diff --git a/indra/newview/llsnapshotlivepreview.cpp b/indra/newview/llsnapshotlivepreview.cpp index bbb5db4a0a..16f70a1c95 100644 --- a/indra/newview/llsnapshotlivepreview.cpp +++ b/indra/newview/llsnapshotlivepreview.cpp @@ -1009,7 +1009,7 @@ void LLSnapshotLivePreview::saveTexture() std::string name = "Snapshot: " + pos_string; std::string desc = "Taken by " + who_took_it + " at " + pos_string; - NewResourceUploadInfo::ptr_t assetUploadInfo(new NewResourceUploadInfo( + LLResourceUploadInfo::ptr_t assetUploadInfo(new LLResourceUploadInfo( tid, LLAssetType::AT_TEXTURE, name, desc, 0, LLFolderType::FT_SNAPSHOT_CATEGORY, LLInventoryType::IT_SNAPSHOT, PERM_ALL, LLFloaterPerms::getGroupPerms("Uploads"), LLFloaterPerms::getEveryonePerms("Uploads"), diff --git a/indra/newview/llviewerassetupload.cpp b/indra/newview/llviewerassetupload.cpp index 910e1dc6c5..426e89b9d5 100644 --- a/indra/newview/llviewerassetupload.cpp +++ b/indra/newview/llviewerassetupload.cpp @@ -49,10 +49,11 @@ #include "llgesturemgr.h" #include "llpreviewnotecard.h" #include "llpreviewgesture.h" +#include "llcoproceduremanager.h" void dialog_refresh_all(); -NewResourceUploadInfo::NewResourceUploadInfo(LLTransactionID transactId, +LLResourceUploadInfo::LLResourceUploadInfo(LLTransactionID transactId, LLAssetType::EType assetType, std::string name, std::string description, S32 compressionInfo, LLFolderType::EType destinationType, LLInventoryType::EType inventoryType, U32 nextOWnerPerms, @@ -74,7 +75,7 @@ NewResourceUploadInfo::NewResourceUploadInfo(LLTransactionID transactId, { } -NewResourceUploadInfo::NewResourceUploadInfo(std::string name, +LLResourceUploadInfo::LLResourceUploadInfo(std::string name, std::string description, S32 compressionInfo, LLFolderType::EType destinationType, LLInventoryType::EType inventoryType, U32 nextOWnerPerms, U32 groupPerms, U32 everyonePerms, S32 expectedCost): @@ -97,7 +98,7 @@ NewResourceUploadInfo::NewResourceUploadInfo(std::string name, } -LLSD NewResourceUploadInfo::prepareUpload() +LLSD LLResourceUploadInfo::prepareUpload() { if (mAssetId.isNull()) generateNewAssetId(); @@ -108,17 +109,17 @@ LLSD NewResourceUploadInfo::prepareUpload() return LLSD().with("success", LLSD::Boolean(true)); } -std::string NewResourceUploadInfo::getAssetTypeString() const +std::string LLResourceUploadInfo::getAssetTypeString() const { return LLAssetType::lookup(mAssetType); } -std::string NewResourceUploadInfo::getInventoryTypeString() const +std::string LLResourceUploadInfo::getInventoryTypeString() const { return LLInventoryType::lookup(mInventoryType); } -LLSD NewResourceUploadInfo::generatePostBody() +LLSD LLResourceUploadInfo::generatePostBody() { LLSD body; @@ -135,7 +136,7 @@ LLSD NewResourceUploadInfo::generatePostBody() } -void NewResourceUploadInfo::logPreparedUpload() +void LLResourceUploadInfo::logPreparedUpload() { LL_INFOS() << "*** Uploading: " << std::endl << "Type: " << LLAssetType::lookup(mAssetType) << std::endl << @@ -147,7 +148,7 @@ void NewResourceUploadInfo::logPreparedUpload() "Asset Type: " << LLAssetType::lookup(mAssetType) << LL_ENDL; } -LLUUID NewResourceUploadInfo::finishUpload(LLSD &result) +LLUUID LLResourceUploadInfo::finishUpload(LLSD &result) { if (getFolderId().isNull()) { @@ -225,7 +226,7 @@ LLUUID NewResourceUploadInfo::finishUpload(LLSD &result) } -LLAssetID NewResourceUploadInfo::generateNewAssetId() +LLAssetID LLResourceUploadInfo::generateNewAssetId() { if (gDisconnected) { @@ -239,7 +240,7 @@ LLAssetID NewResourceUploadInfo::generateNewAssetId() return mAssetId; } -void NewResourceUploadInfo::incrementUploadStats() const +void LLResourceUploadInfo::incrementUploadStats() const { if (LLAssetType::AT_SOUND == mAssetType) { @@ -255,7 +256,7 @@ void NewResourceUploadInfo::incrementUploadStats() const } } -void NewResourceUploadInfo::assignDefaults() +void LLResourceUploadInfo::assignDefaults() { if (LLInventoryType::IT_NONE == mInventoryType) { @@ -279,7 +280,7 @@ void NewResourceUploadInfo::assignDefaults() } -std::string NewResourceUploadInfo::getDisplayName() const +std::string LLResourceUploadInfo::getDisplayName() const { return (mName.empty()) ? mAssetId.asString() : mName; }; @@ -296,7 +297,7 @@ NewFileResourceUploadInfo::NewFileResourceUploadInfo( U32 groupPerms, U32 everyonePerms, S32 expectedCost) : - NewResourceUploadInfo(name, description, compressionInfo, + LLResourceUploadInfo(name, description, compressionInfo, destinationType, inventoryType, nextOWnerPerms, groupPerms, everyonePerms, expectedCost), mFileName(fileName) @@ -314,7 +315,7 @@ LLSD NewFileResourceUploadInfo::prepareUpload() if (result.has("error")) return result; - return NewResourceUploadInfo::prepareUpload(); + return LLResourceUploadInfo::prepareUpload(); } LLSD NewFileResourceUploadInfo::exportTempFile() @@ -443,7 +444,7 @@ LLSD NewFileResourceUploadInfo::exportTempFile() //========================================================================= LLBufferedAssetUploadInfo::LLBufferedAssetUploadInfo(LLUUID itemId, LLAssetType::EType assetType, std::string buffer, invnUploadFinish_f finish) : - NewResourceUploadInfo(std::string(), std::string(), 0, LLFolderType::FT_NONE, LLInventoryType::IT_NONE, + LLResourceUploadInfo(std::string(), std::string(), 0, LLFolderType::FT_NONE, LLInventoryType::IT_NONE, 0, 0, 0, 0), mTaskUpload(false), mTaskId(LLUUID::null), @@ -458,7 +459,7 @@ LLBufferedAssetUploadInfo::LLBufferedAssetUploadInfo(LLUUID itemId, LLAssetType: } LLBufferedAssetUploadInfo::LLBufferedAssetUploadInfo(LLUUID taskId, LLUUID itemId, LLAssetType::EType assetType, std::string buffer, taskUploadFinish_f finish) : - NewResourceUploadInfo(std::string(), std::string(), 0, LLFolderType::FT_NONE, LLInventoryType::IT_NONE, + LLResourceUploadInfo(std::string(), std::string(), 0, LLFolderType::FT_NONE, LLInventoryType::IT_NONE, 0, 0, 0, 0), mTaskUpload(true), mTaskId(taskId), @@ -551,10 +552,47 @@ LLUUID LLBufferedAssetUploadInfo::finishUpload(LLSD &result) return newAssetId; } +//========================================================================= + +LLScriptAssetUpload::LLScriptAssetUpload(LLUUID itemId, std::string buffer, invnUploadFinish_f finish): + LLBufferedAssetUploadInfo(itemId, LLAssetType::AT_LSL_TEXT, buffer, finish) +{ +} + +// LLScriptAssetUpload::LLScriptAssetUpload(LLUUID taskId, LLUUID itemId, LLAssetType::EType assetType, std::string buffer, taskUploadFinish_f finish): +// LLBufferedAssetUploadInfo() +// { +// } + +LLSD LLScriptAssetUpload::generatePostBody() +{ + LLSD body; + + if (getTaskId().isNull()) + { + body["item_id"] = getItemId(); + body["target"] = "lsl2"; + } + + return body; +} + +//========================================================================= +/*static*/ +LLUUID LLViewerAssetUpload::EnqueueInventoryUpload(const std::string &url, const LLResourceUploadInfo::ptr_t &uploadInfo) +{ + std::string procName("LLViewerAssetUpload::AssetInventoryUploadCoproc("); + + LLUUID queueId = LLCoprocedureManager::getInstance()->enqueueCoprocedure(procName + LLAssetType::lookup(uploadInfo->getAssetType()) + ")", + boost::bind(&LLViewerAssetUpload::AssetInventoryUploadCoproc, _1, _2, url, uploadInfo)); + + return queueId; +} + //========================================================================= /*static*/ void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &httpAdapter, - const LLUUID &id, std::string url, NewResourceUploadInfo::ptr_t uploadInfo) + const LLUUID &id, std::string url, LLResourceUploadInfo::ptr_t uploadInfo) { LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); @@ -667,7 +705,7 @@ void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoreHttpUtil::HttpCorouti //========================================================================= /*static*/ -void LLViewerAssetUpload::HandleUploadError(LLCore::HttpStatus status, LLSD &result, NewResourceUploadInfo::ptr_t &uploadInfo) +void LLViewerAssetUpload::HandleUploadError(LLCore::HttpStatus status, LLSD &result, LLResourceUploadInfo::ptr_t &uploadInfo) { std::string reason; std::string label("CannotUploadReason"); diff --git a/indra/newview/llviewerassetupload.h b/indra/newview/llviewerassetupload.h index b80166a874..fa8247cb64 100644 --- a/indra/newview/llviewerassetupload.h +++ b/indra/newview/llviewerassetupload.h @@ -35,12 +35,13 @@ #include "llcoros.h" #include "llcorehttputil.h" -class NewResourceUploadInfo +//========================================================================= +class LLResourceUploadInfo { public: - typedef boost::shared_ptr ptr_t; + typedef boost::shared_ptr ptr_t; - NewResourceUploadInfo( + LLResourceUploadInfo( LLTransactionID transactId, LLAssetType::EType assetType, std::string name, @@ -53,7 +54,7 @@ public: U32 everyonePerms, S32 expectedCost); - virtual ~NewResourceUploadInfo() + virtual ~LLResourceUploadInfo() { } virtual LLSD prepareUpload(); @@ -84,7 +85,7 @@ public: LLAssetID getAssetId() const { return mAssetId; } protected: - NewResourceUploadInfo( + LLResourceUploadInfo( std::string name, std::string description, S32 compressionInfo, @@ -121,7 +122,8 @@ private: LLAssetID mAssetId; }; -class NewFileResourceUploadInfo : public NewResourceUploadInfo +//------------------------------------------------------------------------- +class NewFileResourceUploadInfo : public LLResourceUploadInfo { public: NewFileResourceUploadInfo( @@ -149,8 +151,8 @@ private: }; - -class LLBufferedAssetUploadInfo : public NewResourceUploadInfo +//------------------------------------------------------------------------- +class LLBufferedAssetUploadInfo : public LLResourceUploadInfo { public: typedef boost::function invnUploadFinish_f; @@ -180,24 +182,27 @@ private: bool mStoredToVFS; }; +//------------------------------------------------------------------------- class LLScriptAssetUpload : public LLBufferedAssetUploadInfo { public: - LLScriptAssetUpload(LLUUID itemId, LLAssetType::EType assetType, std::string buffer, invnUploadFinish_f finish); + LLScriptAssetUpload(LLUUID itemId, std::string buffer, invnUploadFinish_f finish); LLScriptAssetUpload(LLUUID taskId, LLUUID itemId, LLAssetType::EType assetType, std::string buffer, taskUploadFinish_f finish); virtual LLSD generatePostBody(); }; +//========================================================================= class LLViewerAssetUpload { public: + static LLUUID EnqueueInventoryUpload(const std::string &url, const LLResourceUploadInfo::ptr_t &uploadInfo); - static void AssetInventoryUploadCoproc(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &httpAdapter, const LLUUID &id, std::string url, NewResourceUploadInfo::ptr_t uploadInfo); + static void AssetInventoryUploadCoproc(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &httpAdapter, const LLUUID &id, std::string url, LLResourceUploadInfo::ptr_t uploadInfo); private: - static void HandleUploadError(LLCore::HttpStatus status, LLSD &result, NewResourceUploadInfo::ptr_t &uploadInfo); + static void HandleUploadError(LLCore::HttpStatus status, LLSD &result, LLResourceUploadInfo::ptr_t &uploadInfo); }; #endif // !VIEWER_ASSET_UPLOAD_H diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index 9c4045fa1e..163ae4f4ec 100755 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -62,7 +62,6 @@ #include "lluploaddialog.h" #include "lltrans.h" #include "llfloaterbuycurrency.h" -#include "llcoproceduremanager.h" #include "llviewerassetupload.h" // linden libraries @@ -437,7 +436,7 @@ class LLFileUploadBulk : public view_listener_t LLStringUtil::stripNonprintable(asset_name); LLStringUtil::trim(asset_name); - NewResourceUploadInfo::ptr_t uploadInfo(new NewFileResourceUploadInfo( + LLResourceUploadInfo::ptr_t uploadInfo(new NewFileResourceUploadInfo( filename, asset_name, asset_name, 0, @@ -636,7 +635,7 @@ LLUUID upload_new_resource( void *userdata) { - NewResourceUploadInfo::ptr_t uploadInfo(new NewFileResourceUploadInfo( + LLResourceUploadInfo::ptr_t uploadInfo(new NewFileResourceUploadInfo( src_filename, name, desc, compression_info, destination_folder_type, inv_type, @@ -775,7 +774,7 @@ void upload_done_callback( } void upload_new_resource( - NewResourceUploadInfo::ptr_t &uploadInfo, + LLResourceUploadInfo::ptr_t &uploadInfo, LLAssetStorage::LLStoreAssetCallback callback, void *userdata) { @@ -792,9 +791,7 @@ void upload_new_resource( if ( !url.empty() ) { - LLCoprocedureManager::CoProcedure_t proc = boost::bind(&LLViewerAssetUpload::AssetInventoryUploadCoproc, _1, _2, url, uploadInfo); - - LLCoprocedureManager::getInstance()->enqueueCoprocedure("LLViewerAssetUpload::AssetInventoryUploadCoproc", proc); + LLViewerAssetUpload::EnqueueInventoryUpload(url, uploadInfo); } else { diff --git a/indra/newview/llviewermenufile.h b/indra/newview/llviewermenufile.h index 616eaed373..0f8fa56b52 100755 --- a/indra/newview/llviewermenufile.h +++ b/indra/newview/llviewermenufile.h @@ -58,7 +58,7 @@ LLUUID upload_new_resource( void *userdata); void upload_new_resource( - NewResourceUploadInfo::ptr_t &uploadInfo, + LLResourceUploadInfo::ptr_t &uploadInfo, LLAssetStorage::LLStoreAssetCallback callback = NULL, void *userdata = NULL); -- cgit v1.2.3 From d22812a8c8cf96992bcf8d159be76a7bd962de63 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 17 Jul 2015 14:32:14 -0700 Subject: LSL Compile and upload from task object. Fix auto open when finished on all uploads... --- indra/newview/llassetuploadqueue.cpp | 1 - indra/newview/llpreviewgesture.cpp | 4 +- indra/newview/llpreviewgesture.h | 1 + indra/newview/llpreviewnotecard.cpp | 6 +- indra/newview/llpreviewnotecard.h | 2 + indra/newview/llpreviewscript.cpp | 203 ++++++++++++++-------------------- indra/newview/llpreviewscript.h | 16 +-- indra/newview/llviewerassetupload.cpp | 53 +++++---- indra/newview/llviewerassetupload.h | 20 +++- 9 files changed, 150 insertions(+), 156 deletions(-) (limited to 'indra') diff --git a/indra/newview/llassetuploadqueue.cpp b/indra/newview/llassetuploadqueue.cpp index 359ee1e221..9e52807d02 100755 --- a/indra/newview/llassetuploadqueue.cpp +++ b/indra/newview/llassetuploadqueue.cpp @@ -142,7 +142,6 @@ public: std::string mScriptName; }; - LLAssetUploadQueue::LLAssetUploadQueue(LLAssetUploadQueueSupplier *supplier) : mSupplier(supplier) { diff --git a/indra/newview/llpreviewgesture.cpp b/indra/newview/llpreviewgesture.cpp index c1d1b9b03c..2604eb1840 100755 --- a/indra/newview/llpreviewgesture.cpp +++ b/indra/newview/llpreviewgesture.cpp @@ -1016,7 +1016,7 @@ struct LLSaveInfo }; -void finishInventoryUpload(LLUUID itemId, LLUUID newAssetId) +void LLPreviewGesture::finishInventoryUpload(LLUUID itemId, LLUUID newAssetId) { // If this gesture is active, then we need to update the in-memory // active map with the new pointer. @@ -1108,7 +1108,7 @@ void LLPreviewGesture::saveIfNeeded() item->setComplete(true); uploadInfo = LLResourceUploadInfo::ptr_t(new LLBufferedAssetUploadInfo(mItemUUID, LLAssetType::AT_GESTURE, buffer, - boost::bind(&finishInventoryUpload, _1, _2))); + boost::bind(&LLPreviewGesture::finishInventoryUpload, _1, _2))); url = agent_url; } else if (!mObjectUUID.isNull() && !task_url.empty()) diff --git a/indra/newview/llpreviewgesture.h b/indra/newview/llpreviewgesture.h index 7ce5706a0d..3ba4f56295 100755 --- a/indra/newview/llpreviewgesture.h +++ b/indra/newview/llpreviewgesture.h @@ -132,6 +132,7 @@ protected: static void onDonePreview(LLMultiGesture* gesture, void* data); + static void finishInventoryUpload(LLUUID itemId, LLUUID newAssetId); private: // LLPreview contains mDescEditor LLLineEditor* mTriggerEditor; diff --git a/indra/newview/llpreviewnotecard.cpp b/indra/newview/llpreviewnotecard.cpp index be44fbd300..9273e06d65 100755 --- a/indra/newview/llpreviewnotecard.cpp +++ b/indra/newview/llpreviewnotecard.cpp @@ -405,7 +405,7 @@ struct LLSaveNotecardInfo } }; -void finishInventoryUpload(LLUUID itemId, LLUUID newAssetId, LLUUID newItemId) +void LLPreviewNotecard::finishInventoryUpload(LLUUID itemId, LLUUID newAssetId, LLUUID newItemId) { // Update the UI with the new asset. LLPreviewNotecard* nc = LLFloaterReg::findTypedInstance("preview_notecard", LLSD(itemId)); @@ -475,13 +475,13 @@ bool LLPreviewNotecard::saveIfNeeded(LLInventoryItem* copyitem) if (mObjectUUID.isNull() && !agent_url.empty()) { uploadInfo = LLResourceUploadInfo::ptr_t(new LLBufferedAssetUploadInfo(mItemUUID, LLAssetType::AT_NOTECARD, buffer, - boost::bind(&finishInventoryUpload, _1, _2, _3))); + boost::bind(&LLPreviewNotecard::finishInventoryUpload, _1, _2, _3))); url = agent_url; } else if (!mObjectUUID.isNull() && !task_url.empty()) { uploadInfo = LLResourceUploadInfo::ptr_t(new LLBufferedAssetUploadInfo(mObjectUUID, mItemUUID, LLAssetType::AT_NOTECARD, buffer, - boost::bind(&finishInventoryUpload, _1, _3, LLUUID::null))); + boost::bind(&LLPreviewNotecard::finishInventoryUpload, _1, _3, LLUUID::null))); url = task_url; } diff --git a/indra/newview/llpreviewnotecard.h b/indra/newview/llpreviewnotecard.h index 1cf08dedd6..ba571995f6 100755 --- a/indra/newview/llpreviewnotecard.h +++ b/indra/newview/llpreviewnotecard.h @@ -95,6 +95,8 @@ protected: bool handleSaveChangesDialog(const LLSD& notification, const LLSD& response); bool handleConfirmDeleteDialog(const LLSD& notification, const LLSD& response); + static void finishInventoryUpload(LLUUID itemId, LLUUID newAssetId, LLUUID newItemId); + protected: LLViewerTextEditor* mEditor; LLButton* mSaveBtn; diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index fc565ffa20..2f09214dd6 100755 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -1642,7 +1642,8 @@ void LLPreviewLSL::onSave(void* userdata, BOOL close_after_save) self->saveIfNeeded(); } -void finishedLSLUpload(LLUUID itemId, LLSD response) +/*static*/ +void LLPreviewLSL::finishedLSLUpload(LLUUID itemId, LLSD response) { // Find our window and close it if requested. LLPreviewLSL* preview = LLFloaterReg::findTypedInstance("preview_script", LLSD(itemId)); @@ -1674,7 +1675,6 @@ void LLPreviewLSL::saveIfNeeded(bool sync /*= true*/) mScriptEd->mErrorList->deleteAllItems(); mScriptEd->mEditor->makePristine(); -#if 1 if (sync) { mScriptEd->sync(); @@ -1690,12 +1690,11 @@ void LLPreviewLSL::saveIfNeeded(bool sync /*= true*/) if (!url.empty()) { std::string buffer(mScriptEd->mEditor->getText()); - LLBufferedAssetUploadInfo::invnUploadFinish_f proc = boost::bind(&finishedLSLUpload, _1, _4); + LLBufferedAssetUploadInfo::invnUploadFinish_f proc = boost::bind(&LLPreviewLSL::finishedLSLUpload, _1, _4); LLResourceUploadInfo::ptr_t uploadInfo(new LLScriptAssetUpload(mItemUUID, buffer, proc)); LLViewerAssetUpload::EnqueueInventoryUpload(url, uploadInfo); - } else if (gAssetStorage) { @@ -1711,56 +1710,7 @@ void LLPreviewLSL::saveIfNeeded(bool sync /*= true*/) uploadAssetLegacy(filename, mItemUUID, tid); } } - - -#else - // LL_INFOS() << "LLPreviewLSL::saveIfNeeded()" << LL_ENDL; - - // save off asset into file - LLTransactionID tid; - tid.generate(); - LLAssetID asset_id = tid.makeAssetID(gAgent.getSecureSessionID()); - std::string filepath = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,asset_id.asString()); - std::string filename = filepath + ".lsl"; - - mScriptEd->writeToFile(filename); - - if (sync) - { - mScriptEd->sync(); - } - - const LLInventoryItem *inv_item = getItem(); - // save it out to asset server - std::string url = gAgent.getRegion()->getCapability("UpdateScriptAgent"); - if(inv_item) - { - getWindow()->incBusyCount(); - mPendingUploads++; - if (!url.empty()) - { - uploadAssetViaCaps(url, filename, mItemUUID); - } - else if (gAssetStorage) - { - uploadAssetLegacy(filename, mItemUUID, tid); - } - } -#endif -} - -#if 0 -void LLPreviewLSL::uploadAssetViaCaps(const std::string& url, - const std::string& filename, - const LLUUID& item_id) -{ - LL_INFOS() << "Update Agent Inventory via capability" << LL_ENDL; - LLSD body; - body["item_id"] = item_id; - body["target"] = "lsl2"; - LLHTTPClient::post(url, body, new LLUpdateAgentInventoryResponder(body, filename, LLAssetType::AT_LSL_TEXT)); } -#endif void LLPreviewLSL::uploadAssetLegacy(const std::string& filename, const LLUUID& item_id, @@ -2384,6 +2334,33 @@ LLLiveLSLSaveData::LLLiveLSLSaveData(const LLUUID& id, mItem = new LLViewerInventoryItem(item); } + +/*static*/ +void LLLiveLSLEditor::finishLSLUpload(LLUUID itemId, LLUUID taskId, LLUUID newAssetId, LLSD response, bool isRunning) +{ + LLSD floater_key; + floater_key["taskid"] = taskId; + floater_key["itemid"] = itemId; + + LLLiveLSLEditor* preview = LLFloaterReg::findTypedInstance("preview_scriptedit", floater_key); + if (preview) + { + preview->mItem->setAssetUUID(newAssetId); + + // Bytecode save completed + if (response["compiled"]) + { + preview->callbackLSLCompileSucceeded(taskId, itemId, isRunning); + } + else + { + preview->callbackLSLCompileFailed(response["errors"]); + } + } + +} + + // virtual void LLLiveLSLEditor::saveIfNeeded(bool sync /*= true*/) { @@ -2394,7 +2371,7 @@ void LLLiveLSLEditor::saveIfNeeded(bool sync /*= true*/) return; } - if(mItem.isNull() || !mItem->isFinished()) + if (mItem.isNull() || !mItem->isFinished()) { // $NOTE: While the error message may not be exactly correct, // it's pretty close. @@ -2402,78 +2379,68 @@ void LLLiveLSLEditor::saveIfNeeded(bool sync /*= true*/) return; } - // get the latest info about it. We used to be losing the script - // name on save, because the viewer object version of the item, - // and the editor version would get out of synch. Here's a good - // place to synch them back up. - LLInventoryItem* inv_item = dynamic_cast(object->getInventoryObject(mItemUUID)); - if(inv_item) - { - mItem->copyItem(inv_item); - } + // get the latest info about it. We used to be losing the script + // name on save, because the viewer object version of the item, + // and the editor version would get out of synch. Here's a good + // place to synch them back up. + LLInventoryItem* inv_item = dynamic_cast(object->getInventoryObject(mItemUUID)); + if (inv_item) + { + mItem->copyItem(inv_item); + } - // Don't need to save if we're pristine - if(!mScriptEd->hasChanged()) - { - return; - } + // Don't need to save if we're pristine + if(!mScriptEd->hasChanged()) + { + return; + } - mPendingUploads = 0; + mPendingUploads = 0; - // save the script - mScriptEd->enableSave(FALSE); - mScriptEd->mEditor->makePristine(); - mScriptEd->mErrorList->deleteAllItems(); + // save the script + mScriptEd->enableSave(FALSE); + mScriptEd->mEditor->makePristine(); + mScriptEd->mErrorList->deleteAllItems(); + mScriptEd->mEditor->makePristine(); - // set up the save on the local machine. - mScriptEd->mEditor->makePristine(); - LLTransactionID tid; - tid.generate(); - LLAssetID asset_id = tid.makeAssetID(gAgent.getSecureSessionID()); - std::string filepath = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,asset_id.asString()); - std::string filename = llformat("%s.lsl", filepath.c_str()); + if (sync) + { + mScriptEd->sync(); + } + bool isRunning = getChild("running")->get(); + getWindow()->incBusyCount(); + mPendingUploads++; - mItem->setAssetUUID(asset_id); - mItem->setTransactionID(tid); + std::string url = object->getRegion()->getCapability("UpdateScriptTask"); - mScriptEd->writeToFile(filename); + if (!url.empty()) + { + std::string buffer(mScriptEd->mEditor->getText()); + LLBufferedAssetUploadInfo::taskUploadFinish_f proc = boost::bind(&LLLiveLSLEditor::finishLSLUpload, _1, _2, _3, _4, isRunning); - if (sync) - { - mScriptEd->sync(); - } - - // save it out to asset server - std::string url = object->getRegion()->getCapability("UpdateScriptTask"); - getWindow()->incBusyCount(); - mPendingUploads++; - BOOL is_running = getChild( "running")->get(); - if (!url.empty()) - { - uploadAssetViaCaps(url, filename, mObjectUUID, mItemUUID, is_running, mScriptEd->getAssociatedExperience()); - } - else if (gAssetStorage) - { - uploadAssetLegacy(filename, object, tid, is_running); - } -} + LLResourceUploadInfo::ptr_t uploadInfo(new LLScriptAssetUpload(mObjectUUID, mItemUUID, + monoChecked() ? LLScriptAssetUpload::MONO : LLScriptAssetUpload::LSL2, + isRunning, mScriptEd->getAssociatedExperience(), buffer, proc)); + + LLViewerAssetUpload::EnqueueInventoryUpload(url, uploadInfo); + } + else if (gAssetStorage) + { + // set up the save on the local machine. + LLTransactionID tid; + tid.generate(); + LLAssetID asset_id = tid.makeAssetID(gAgent.getSecureSessionID()); + std::string filepath = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, asset_id.asString()); + std::string filename = llformat("%s.lsl", filepath.c_str()); + + mItem->setAssetUUID(asset_id); + mItem->setTransactionID(tid); + + mScriptEd->writeToFile(filename); + + uploadAssetLegacy(filename, object, tid, isRunning); + } -void LLLiveLSLEditor::uploadAssetViaCaps(const std::string& url, - const std::string& filename, - const LLUUID& task_id, - const LLUUID& item_id, - BOOL is_running, - const LLUUID& experience_public_id ) -{ - LL_INFOS() << "Update Task Inventory via capability " << url << LL_ENDL; - LLSD body; - body["task_id"] = task_id; - body["item_id"] = item_id; - body["is_script_running"] = is_running; - body["target"] = monoChecked() ? "mono" : "lsl2"; - body["experience"] = experience_public_id; - LLHTTPClient::post(url, body, - new LLUpdateTaskInventoryResponder(body, filename, LLAssetType::AT_LSL_TEXT)); } void LLLiveLSLEditor::uploadAssetLegacy(const std::string& filename, diff --git a/indra/newview/llpreviewscript.h b/indra/newview/llpreviewscript.h index 954d040bda..55ac64677a 100755 --- a/indra/newview/llpreviewscript.h +++ b/indra/newview/llpreviewscript.h @@ -203,11 +203,7 @@ protected: virtual void loadAsset(); /*virtual*/ void saveIfNeeded(bool sync = true); -#if 0 - void uploadAssetViaCaps(const std::string& url, - const std::string& filename, - const LLUUID& item_id); -#endif // 0 + void uploadAssetLegacy(const std::string& filename, const LLUUID& item_id, const LLTransactionID& tid); @@ -225,7 +221,7 @@ protected: protected: static void* createScriptEdPanel(void* userdata); - + static void finishedLSLUpload(LLUUID itemId, LLSD response); protected: // Can safely close only after both text and bytecode are uploaded @@ -272,12 +268,6 @@ private: virtual void loadAsset(); void loadAsset(BOOL is_new); /*virtual*/ void saveIfNeeded(bool sync = true); - void uploadAssetViaCaps(const std::string& url, - const std::string& filename, - const LLUUID& task_id, - const LLUUID& item_id, - BOOL is_running, - const LLUUID& experience_public_id); void uploadAssetLegacy(const std::string& filename, LLViewerObject* object, const LLTransactionID& tid, @@ -305,6 +295,8 @@ private: static void onMonoCheckboxClicked(LLUICtrl*, void* userdata); + static void finishLSLUpload(LLUUID itemId, LLUUID taskId, LLUUID newAssetId, LLSD response, bool isRunning); + private: bool mIsNew; //LLUUID mTransmitID; diff --git a/indra/newview/llviewerassetupload.cpp b/indra/newview/llviewerassetupload.cpp index 426e89b9d5..b29a9a6114 100644 --- a/indra/newview/llviewerassetupload.cpp +++ b/indra/newview/llviewerassetupload.cpp @@ -559,10 +559,14 @@ LLScriptAssetUpload::LLScriptAssetUpload(LLUUID itemId, std::string buffer, invn { } -// LLScriptAssetUpload::LLScriptAssetUpload(LLUUID taskId, LLUUID itemId, LLAssetType::EType assetType, std::string buffer, taskUploadFinish_f finish): -// LLBufferedAssetUploadInfo() -// { -// } +LLScriptAssetUpload::LLScriptAssetUpload(LLUUID taskId, LLUUID itemId, TargetType_t targetType, + bool isRunning, LLUUID exerienceId, std::string buffer, taskUploadFinish_f finish): + LLBufferedAssetUploadInfo(taskId, itemId, LLAssetType::AT_LSL_TEXT, buffer, finish), + mExerienceId(exerienceId), + mTargetType(targetType), + mIsRunning(isRunning) +{ +} LLSD LLScriptAssetUpload::generatePostBody() { @@ -573,6 +577,14 @@ LLSD LLScriptAssetUpload::generatePostBody() body["item_id"] = getItemId(); body["target"] = "lsl2"; } + else + { + body["task_id"] = getTaskId(); + body["item_id"] = getItemId(); + body["is_script_running"] = getIsRunning(); + body["target"] = (getTargetType() == MONO) ? "mono" : "lsl2"; + body["experience"] = getExerienceId(); + } return body; } @@ -670,25 +682,28 @@ void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoreHttpUtil::HttpCorouti LLUUID serverInventoryItem = uploadInfo->finishUpload(result); - if (serverInventoryItem.notNull()) + if (uploadInfo->showInventoryPanel()) { - success = true; - - // Show the preview panel for textures and sounds to let - // user know that the image (or snapshot) arrived intact. - LLInventoryPanel* panel = LLInventoryPanel::getActiveInventoryPanel(); - if (panel) + if (serverInventoryItem.notNull()) { - LLFocusableElement* focus = gFocusMgr.getKeyboardFocus(); - panel->setSelection(serverInventoryItem, TAKE_FOCUS_NO); + success = true; - // restore keyboard focus - gFocusMgr.setKeyboardFocus(focus); + // Show the preview panel for textures and sounds to let + // user know that the image (or snapshot) arrived intact. + LLInventoryPanel* panel = LLInventoryPanel::getActiveInventoryPanel(); + if (panel) + { + LLFocusableElement* focus = gFocusMgr.getKeyboardFocus(); + panel->setSelection(serverInventoryItem, TAKE_FOCUS_NO); + + // restore keyboard focus + gFocusMgr.setKeyboardFocus(focus); + } + } + else + { + LL_WARNS() << "Can't find a folder to put it in" << LL_ENDL; } - } - else - { - LL_WARNS() << "Can't find a folder to put it in" << LL_ENDL; } // remove the "Uploading..." message diff --git a/indra/newview/llviewerassetupload.h b/indra/newview/llviewerassetupload.h index fa8247cb64..e7145068c5 100644 --- a/indra/newview/llviewerassetupload.h +++ b/indra/newview/llviewerassetupload.h @@ -77,6 +77,7 @@ public: S32 getExpectedUploadCost() const { return mExpectedUploadCost; }; virtual bool showUploadDialog() const { return true; } + virtual bool showInventoryPanel() const { return true; } virtual std::string getDisplayName() const; @@ -169,6 +170,7 @@ public: const std::string & getContents() const { return mContents; } virtual bool showUploadDialog() const { return false; } + virtual bool showInventoryPanel() const { return false; } protected: @@ -186,11 +188,27 @@ private: class LLScriptAssetUpload : public LLBufferedAssetUploadInfo { public: + enum TargetType_t + { + LSL2, + MONO + }; + LLScriptAssetUpload(LLUUID itemId, std::string buffer, invnUploadFinish_f finish); - LLScriptAssetUpload(LLUUID taskId, LLUUID itemId, LLAssetType::EType assetType, std::string buffer, taskUploadFinish_f finish); + LLScriptAssetUpload(LLUUID taskId, LLUUID itemId, TargetType_t targetType, + bool isRunning, LLUUID exerienceId, std::string buffer, taskUploadFinish_f finish); virtual LLSD generatePostBody(); + LLUUID getExerienceId() const { return mExerienceId; } + TargetType_t getTargetType() const { return mTargetType; } + bool getIsRunning() const { return mIsRunning; } + +private: + LLUUID mExerienceId; + TargetType_t mTargetType; + bool mIsRunning; + }; //========================================================================= -- cgit v1.2.3 From 2fc4ddb92bfb7b05851372adcfda7e0ab4886718 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 17 Jul 2015 15:58:03 -0700 Subject: Added a couple LL_WARNS to track why upload button disabled. --- indra/newview/llfloatermodelpreview.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'indra') diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index 72c9170b06..e6a1f84b23 100755 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -5997,6 +5997,15 @@ void LLFloaterModelPreview::onPermissionsReceived(const LLSD& result) // BAP HACK: handle "" for case that MeshUploadFlag cap is broken. mHasUploadPerm = (("" == upload_status) || ("valid" == upload_status)); + if (!mHasUploadPerm) + { + LL_WARNS() << "Upload permission set to false because upload_status=\"" << upload_status << "\"" << LL_ENDL; + } + else if (mHasUploadPerm && mUploadModelUrl.empty()) + { + LL_WARNS() << "Upload permission set to true but uploadModelUrl is empty!" << LL_ENDL; + } + //mUploadBtn->setEnabled(mHasUploadPerm); mUploadBtn->setEnabled(mHasUploadPerm && !mUploadModelUrl.empty()); getChild("warning_title")->setVisible(!mHasUploadPerm); -- cgit v1.2.3 From 37d17eaebd05325f0ddb3334cbabf7a8710d5843 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 20 Jul 2015 15:57:10 -0700 Subject: Remove old "compile queue" and replace with the coroutine based upload queue. --- indra/newview/CMakeLists.txt | 2 - indra/newview/llassetuploadqueue.cpp | 219 ------------------------------ indra/newview/llassetuploadqueue.h | 93 ------------- indra/newview/llassetuploadresponders.cpp | 3 +- indra/newview/llassetuploadresponders.h | 2 + indra/newview/llcompilequeue.cpp | 163 ++++++++++++---------- indra/newview/llcompilequeue.h | 7 +- indra/newview/llviewerassetupload.cpp | 7 +- indra/newview/llviewerassetupload.h | 3 + 9 files changed, 107 insertions(+), 392 deletions(-) delete mode 100755 indra/newview/llassetuploadqueue.cpp delete mode 100755 indra/newview/llassetuploadqueue.h (limited to 'indra') diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 7a6267251e..e79fa8b084 100755 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -123,7 +123,6 @@ set(viewer_SOURCE_FILES llappearancemgr.cpp llappviewer.cpp llappviewerlistener.cpp - llassetuploadqueue.cpp llassetuploadresponders.cpp llattachmentsmgr.cpp llaudiosourcevo.cpp @@ -735,7 +734,6 @@ set(viewer_HEADER_FILES llappearancemgr.h llappviewer.h llappviewerlistener.h - llassetuploadqueue.h llassetuploadresponders.h llattachmentsmgr.h llaudiosourcevo.h diff --git a/indra/newview/llassetuploadqueue.cpp b/indra/newview/llassetuploadqueue.cpp deleted file mode 100755 index 9e52807d02..0000000000 --- a/indra/newview/llassetuploadqueue.cpp +++ /dev/null @@ -1,219 +0,0 @@ -/** - * @file llassetupload.cpp - * @brief Serializes asset upload request - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#include "llviewerprecompiledheaders.h" - -#include "llassetuploadqueue.h" -#include "llviewerregion.h" -#include "llviewerobjectlist.h" - -#include "llassetuploadresponders.h" -#include "llsd.h" -#include - -class LLAssetUploadChainResponder : public LLUpdateTaskInventoryResponder -{ - LOG_CLASS(LLAssetUploadChainResponder); -public: - - LLAssetUploadChainResponder(const LLSD& post_data, - const std::string& file_name, - const LLUUID& queue_id, - U8* data, - U32 data_size, - std::string script_name, - LLAssetUploadQueueSupplier *supplier) : - LLUpdateTaskInventoryResponder(post_data, file_name, queue_id, LLAssetType::AT_LSL_TEXT), - mSupplier(supplier), - mData(data), - mDataSize(data_size), - mScriptName(script_name) - { - } - - virtual ~LLAssetUploadChainResponder() - { - if(mSupplier) - { - LLAssetUploadQueue *queue = mSupplier->get(); - if (queue) - { - // Give ownership of supplier back to queue. - queue->mSupplier = mSupplier; - mSupplier = NULL; - } - } - delete mSupplier; - delete mData; - } - -protected: - virtual void httpFailure() - { - // Parent class will spam the failure. - //LL_WARNS() << dumpResponse() << LL_ENDL; - LLUpdateTaskInventoryResponder::httpFailure(); - LLAssetUploadQueue *queue = mSupplier->get(); - if (queue) - { - queue->request(&mSupplier); - } - } - - virtual void httpSuccess() - { - LLUpdateTaskInventoryResponder::httpSuccess(); - LLAssetUploadQueue *queue = mSupplier->get(); - if (queue) - { - // Responder is reused across 2 phase upload, - // so only start next upload after 2nd phase complete. - const std::string& state = getContent()["state"].asStringRef(); - if(state == "complete") - { - queue->request(&mSupplier); - } - } - } - -public: - virtual void uploadUpload(const LLSD& content) - { - std::string uploader = content["uploader"]; - - mSupplier->log(std::string("Compiling " + mScriptName).c_str()); - LL_INFOS() << "Compiling " << LL_ENDL; - - // postRaw takes ownership of mData and will delete it. - LLHTTPClient::postRaw(uploader, mData, mDataSize, this); - mData = NULL; - mDataSize = 0; - } - - virtual void uploadComplete(const LLSD& content) - { - // Bytecode save completed - if (content["compiled"]) - { - mSupplier->log("Compilation succeeded"); - LL_INFOS() << "Compiled!" << LL_ENDL; - } - else - { - LLSD compile_errors = content["errors"]; - for(LLSD::array_const_iterator line = compile_errors.beginArray(); - line < compile_errors.endArray(); line++) - { - std::string str = line->asString(); - str.erase(std::remove(str.begin(), str.end(), '\n'), str.end()); - mSupplier->log(str); - LL_INFOS() << content["errors"] << LL_ENDL; - } - } - LLUpdateTaskInventoryResponder::uploadComplete(content); - } - - LLAssetUploadQueueSupplier *mSupplier; - U8* mData; - U32 mDataSize; - std::string mScriptName; -}; - -LLAssetUploadQueue::LLAssetUploadQueue(LLAssetUploadQueueSupplier *supplier) : - mSupplier(supplier) -{ -} - -//virtual -LLAssetUploadQueue::~LLAssetUploadQueue() -{ - delete mSupplier; -} - -// Takes ownership of supplier. -void LLAssetUploadQueue::request(LLAssetUploadQueueSupplier** supplier) -{ - if (mQueue.empty()) - return; - - UploadData data = mQueue.front(); - mQueue.pop_front(); - - LLSD body; - body["task_id"] = data.mTaskId; - body["item_id"] = data.mItemId; - body["is_script_running"] = data.mIsRunning; - body["target"] = data.mIsTargetMono? "mono" : "lsl2"; - body["experience"] = data.mExperienceId; - - std::string url = ""; - LLViewerObject* object = gObjectList.findObject(data.mTaskId); - if (object) - { - url = object->getRegion()->getCapability("UpdateScriptTask"); - LLHTTPClient::post(url, body, - new LLAssetUploadChainResponder( - body, data.mFilename, data.mQueueId, - data.mData, data.mDataSize, data.mScriptName, *supplier)); - } - - *supplier = NULL; -} - -void LLAssetUploadQueue::queue(const std::string& filename, - const LLUUID& task_id, - const LLUUID& item_id, - BOOL is_running, - BOOL is_target_mono, - const LLUUID& queue_id, - U8* script_data, - U32 data_size, - std::string script_name, - const LLUUID& experience_id) -{ - UploadData data; - data.mTaskId = task_id; - data.mItemId = item_id; - data.mIsRunning = is_running; - data.mIsTargetMono = is_target_mono; - data.mQueueId = queue_id; - data.mFilename = filename; - data.mData = script_data; - data.mDataSize = data_size; - data.mScriptName = script_name; - data.mExperienceId = experience_id; - - mQueue.push_back(data); - - if(mSupplier) - { - request(&mSupplier); - } -} - -LLAssetUploadQueueSupplier::~LLAssetUploadQueueSupplier() -{ -} diff --git a/indra/newview/llassetuploadqueue.h b/indra/newview/llassetuploadqueue.h deleted file mode 100755 index 2ceee8f700..0000000000 --- a/indra/newview/llassetuploadqueue.h +++ /dev/null @@ -1,93 +0,0 @@ -/** - * @file llassetuploadqueue.h - * @brief Serializes asset upload request - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifndef LL_LLASSETUPLOADQUEUE_H -#define LL_LLASSETUPLOADQUEUE_H - -#include "lluuid.h" - -#include -#include - -class LLAssetUploadQueueSupplier; - -class LLAssetUploadQueue -{ -public: - - // Takes ownership of supplier. - LLAssetUploadQueue(LLAssetUploadQueueSupplier* supplier); - virtual ~LLAssetUploadQueue(); - - void queue(const std::string& filename, - const LLUUID& task_id, - const LLUUID& item_id, - BOOL is_running, - BOOL is_target_mono, - const LLUUID& queue_id, - U8* data, - U32 data_size, - std::string script_name, - const LLUUID& experience_id); - - bool isEmpty() const {return mQueue.empty();} - -private: - - friend class LLAssetUploadChainResponder; - - struct UploadData - { - std::string mFilename; - LLUUID mTaskId; - LLUUID mItemId; - BOOL mIsRunning; - BOOL mIsTargetMono; - LLUUID mQueueId; - U8* mData; - U32 mDataSize; - std::string mScriptName; - LLUUID mExperienceId; - }; - - // Ownership of mSupplier passed to currently waiting responder - // and returned to queue when no requests in progress. - LLAssetUploadQueueSupplier* mSupplier; - std::deque mQueue; - - // Passes on ownership of mSupplier if request is made. - void request(LLAssetUploadQueueSupplier** supplier); -}; - -class LLAssetUploadQueueSupplier -{ -public: - virtual ~LLAssetUploadQueueSupplier(); - virtual LLAssetUploadQueue* get() const = 0; - virtual void log(std::string message) const = 0; -}; - -#endif // LL_LLASSETUPLOADQUEUE_H diff --git a/indra/newview/llassetuploadresponders.cpp b/indra/newview/llassetuploadresponders.cpp index 14020af166..f62c57b2b3 100755 --- a/indra/newview/llassetuploadresponders.cpp +++ b/indra/newview/llassetuploadresponders.cpp @@ -585,6 +585,7 @@ void LLUpdateAgentInventoryResponder::uploadComplete(const LLSD& content) } #endif +#if 0 LLUpdateTaskInventoryResponder::LLUpdateTaskInventoryResponder(const LLSD& post_data, const LLUUID& vfile_id, LLAssetType::EType asset_type) @@ -675,7 +676,7 @@ void LLUpdateTaskInventoryResponder::uploadComplete(const LLSD& content) break; } } - +#endif #if 0 ///////////////////////////////////////////////////// diff --git a/indra/newview/llassetuploadresponders.h b/indra/newview/llassetuploadresponders.h index 71995873fa..d3457ce450 100755 --- a/indra/newview/llassetuploadresponders.h +++ b/indra/newview/llassetuploadresponders.h @@ -133,6 +133,7 @@ public: }; #endif +#if 0 class LLUpdateTaskInventoryResponder : public LLAssetUploadResponder { public: @@ -152,5 +153,6 @@ public: private: LLUUID mQueueId; }; +#endif #endif // LL_LLASSETUPLOADRESPONDER_H diff --git a/indra/newview/llcompilequeue.cpp b/indra/newview/llcompilequeue.cpp index d9fd4509a5..c4b0b96d4c 100755 --- a/indra/newview/llcompilequeue.cpp +++ b/indra/newview/llcompilequeue.cpp @@ -37,7 +37,6 @@ #include "llcompilequeue.h" #include "llagent.h" -#include "llassetuploadqueue.h" #include "llassetuploadresponders.h" #include "llchat.h" #include "llfloaterreg.h" @@ -62,8 +61,51 @@ #include "llexperienceassociationresponder.h" #include "llexperiencecache.h" -// *TODO: This should be separated into the script queue, and the floater views of that queue. -// There should only be one floater class that can view any queue type +#include "llviewerassetupload.h" + +// *NOTE$: A minor specialization of LLScriptAssetUpload, it does not require a buffer +// (and does not save a buffer to the vFS) and it finds the compile queue window and +// displays a compiling message. +class LLQueuedScriptAssetUpload : public LLScriptAssetUpload +{ +public: + LLQueuedScriptAssetUpload(LLUUID taskId, LLUUID itemId, LLUUID assetId, TargetType_t targetType, + bool isRunning, std::string scriptName, LLUUID queueId, LLUUID exerienceId, taskUploadFinish_f finish) : + LLScriptAssetUpload(taskId, itemId, targetType, isRunning, + exerienceId, std::string(), finish), + mScriptName(scriptName), + mQueueId(queueId) + { + setAssetId(assetId); + } + + virtual LLSD prepareUpload() + { + /* *NOTE$: The parent class (LLScriptAssetUpload will attempt to save + * the script buffer into to the VFS. Since the resource is already in + * the VFS we don't want to do that. Just put a compiling message in + * the window and move on + */ + LLFloaterCompileQueue* queue = LLFloaterReg::findTypedInstance("compile_queue", LLSD(mQueueId)); + if (queue) + { + std::string message = std::string("Compiling \"") + getScriptName() + std::string("\"..."); + + queue->getChild("queue output")->addSimpleElement(message, ADD_BOTTOM); + } + + return LLSD().with("success", LLSD::Boolean(true)); + } + + + std::string getScriptName() const { return mScriptName; } + +private: + void setScriptName(const std::string &scriptName) { mScriptName = scriptName; } + + LLUUID mQueueId; + std::string mScriptName; +}; ///---------------------------------------------------------------------------- /// Local function declarations, constants, enums, and typedefs @@ -127,7 +169,7 @@ void LLFloaterScriptQueue::inventoryChanged(LLViewerObject* viewer_object, //which it internally stores. //If we call this further down in the function, calls to handleInventory - //and nextObject may update the interally stored viewer object causing + //and nextObject may update the internally stored viewer object causing //the removal of the incorrect listener from an incorrect object. //Fixes SL-6119:Recompile scripts fails to complete @@ -275,48 +317,13 @@ public: ///---------------------------------------------------------------------------- /// Class LLFloaterCompileQueue ///---------------------------------------------------------------------------- - -class LLCompileFloaterUploadQueueSupplier : public LLAssetUploadQueueSupplier -{ -public: - - LLCompileFloaterUploadQueueSupplier(const LLUUID& queue_id) : - mQueueId(queue_id) - { - } - - virtual LLAssetUploadQueue* get() const - { - LLFloaterCompileQueue* queue = LLFloaterReg::findTypedInstance("compile_queue", LLSD(mQueueId)); - if(NULL == queue) - { - return NULL; - } - return queue->getUploadQueue(); - } - - virtual void log(std::string message) const - { - LLFloaterCompileQueue* queue = LLFloaterReg::findTypedInstance("compile_queue", LLSD(mQueueId)); - if(NULL == queue) - { - return; - } - - queue->getChild("queue output")->addSimpleElement(message, ADD_BOTTOM); - } - -private: - LLUUID mQueueId; -}; - LLFloaterCompileQueue::LLFloaterCompileQueue(const LLSD& key) : LLFloaterScriptQueue(key) { setTitle(LLTrans::getString("CompileQueueTitle")); setStartString(LLTrans::getString("CompileQueueStart")); - mUploadQueue = new LLAssetUploadQueue(new LLCompileFloaterUploadQueueSupplier(key.asUUID())); +// mUploadQueue = new LLAssetUploadQueue(new LLCompileFloaterUploadQueueSupplier(key.asUUID())); } LLFloaterCompileQueue::~LLFloaterCompileQueue() @@ -423,6 +430,37 @@ void LLFloaterCompileQueue::requestAsset( LLScriptQueueData* datap, const LLSD& (void*)datap); } +/*static*/ +void LLFloaterCompileQueue::finishLSLUpload(LLUUID itemId, LLUUID taskId, LLUUID newAssetId, LLSD response, std::string scriptName, LLUUID queueId) +{ + + LLFloaterCompileQueue* queue = LLFloaterReg::findTypedInstance("compile_queue", LLSD(queueId)); + if (queue) + { + // Bytecode save completed + if (response["compiled"]) + { + std::string message = std::string("Compilation of \"") + scriptName + std::string("\" succeeded"); + + queue->getChild("queue output")->addSimpleElement(message, ADD_BOTTOM); + LL_INFOS() << message << LL_ENDL; + } + else + { + LLSD compile_errors = response["errors"]; + for (LLSD::array_const_iterator line = compile_errors.beginArray(); + line < compile_errors.endArray(); line++) + { + std::string str = line->asString(); + str.erase(std::remove(str.begin(), str.end(), '\n'), str.end()); + + queue->getChild("queue output")->addSimpleElement(str, ADD_BOTTOM); + } + LL_INFOS() << response["errors"] << LL_ENDL; + } + + } +} // This is the callback for when each script arrives // static @@ -441,36 +479,21 @@ void LLFloaterCompileQueue::scriptArrived(LLVFS *vfs, const LLUUID& asset_id, std::string buffer; if(queue && (0 == status)) { - //LL_INFOS() << "ITEM NAME 3: " << data->mScriptName << LL_ENDL; - - // Dump this into a file on the local disk so we can compile it. - std::string filename; - LLVFile file(vfs, asset_id, type); - std::string uuid_str; - asset_id.toString(uuid_str); - filename = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,uuid_str) + llformat(".%s",LLAssetType::lookup(type)); - - const bool is_running = true; - LLViewerObject* object = gObjectList.findObject(data->mTaskId); - if (object) - { - std::string url = object->getRegion()->getCapability("UpdateScriptTask"); - if(!url.empty()) - { - // Read script source in to buffer. - U32 script_size = file.getSize(); - U8* script_data = new U8[script_size]; - file.read(script_data, script_size); - - queue->mUploadQueue->queue(filename, data->mTaskId, - data->mItem->getUUID(), is_running, queue->mMono, queue->getKey().asUUID(), - script_data, script_size, data->mItem->getName(), data->mExperienceId); - } - else - { - buffer = LLTrans::getString("CompileQueueServiceUnavailable") + (": ") + data->mItem->getName(); - } - } + LLViewerObject* object = gObjectList.findObject(data->mTaskId); + if (object) + { + std::string url = object->getRegion()->getCapability("UpdateScriptTask"); + std::string scriptName = data->mItem->getName(); + + LLBufferedAssetUploadInfo::taskUploadFinish_f proc = boost::bind(&LLFloaterCompileQueue::finishLSLUpload, _1, _2, _3, _4, + scriptName, data->mQueueID); + + LLResourceUploadInfo::ptr_t uploadInfo(new LLQueuedScriptAssetUpload(data->mTaskId, data->mItem->getUUID(), asset_id, + (queue->mMono) ? LLScriptAssetUpload::MONO : LLScriptAssetUpload::LSL2, + true, scriptName, data->mQueueID, data->mExperienceId, proc)); + + LLViewerAssetUpload::EnqueueInventoryUpload(url, uploadInfo); + } } else { diff --git a/indra/newview/llcompilequeue.h b/indra/newview/llcompilequeue.h index 54842bb302..c7be4fbe3b 100755 --- a/indra/newview/llcompilequeue.h +++ b/indra/newview/llcompilequeue.h @@ -118,8 +118,6 @@ struct LLCompileQueueData mQueueID(q_id), mItemId(item_id) {} }; -class LLAssetUploadQueue; - class LLFloaterCompileQueue : public LLFloaterScriptQueue { friend class LLFloaterReg; @@ -131,8 +129,6 @@ public: // remove any object in mScriptScripts with the matching uuid. void removeItemByItemID(const LLUUID& item_id); - LLAssetUploadQueue* getUploadQueue() { return mUploadQueue; } - void experienceIdsReceived( const LLSD& content ); BOOL hasExperience(const LLUUID& id)const; @@ -147,6 +143,8 @@ protected: static void requestAsset(struct LLScriptQueueData* datap, const LLSD& experience); + static void finishLSLUpload(LLUUID itemId, LLUUID taskId, LLUUID newAssetId, LLSD response, std::string scriptName, LLUUID queueId); + // This is the callback for when each script arrives static void scriptArrived(LLVFS *vfs, const LLUUID& asset_id, LLAssetType::EType type, @@ -157,7 +155,6 @@ protected: LLViewerInventoryItem::item_array_t mCurrentScripts; private: - LLAssetUploadQueue* mUploadQueue; uuid_list_t mExperienceIds; }; diff --git a/indra/newview/llviewerassetupload.cpp b/indra/newview/llviewerassetupload.cpp index b29a9a6114..9982d68f52 100644 --- a/indra/newview/llviewerassetupload.cpp +++ b/indra/newview/llviewerassetupload.cpp @@ -486,7 +486,6 @@ LLSD LLBufferedAssetUploadInfo::prepareUpload() mStoredToVFS = true; - return LLSD().with("success", LLSD::Boolean(true)); } @@ -555,7 +554,10 @@ LLUUID LLBufferedAssetUploadInfo::finishUpload(LLSD &result) //========================================================================= LLScriptAssetUpload::LLScriptAssetUpload(LLUUID itemId, std::string buffer, invnUploadFinish_f finish): - LLBufferedAssetUploadInfo(itemId, LLAssetType::AT_LSL_TEXT, buffer, finish) + LLBufferedAssetUploadInfo(itemId, LLAssetType::AT_LSL_TEXT, buffer, finish), + mExerienceId(), + mTargetType(LSL2), + mIsRunning(false) { } @@ -568,6 +570,7 @@ LLScriptAssetUpload::LLScriptAssetUpload(LLUUID taskId, LLUUID itemId, TargetTyp { } + LLSD LLScriptAssetUpload::generatePostBody() { LLSD body; diff --git a/indra/newview/llviewerassetupload.h b/indra/newview/llviewerassetupload.h index e7145068c5..23013ac664 100644 --- a/indra/newview/llviewerassetupload.h +++ b/indra/newview/llviewerassetupload.h @@ -105,6 +105,8 @@ protected: void incrementUploadStats() const; virtual void assignDefaults(); + void setAssetId(LLUUID assetId) { mAssetId = assetId; } + private: LLTransactionID mTransactionId; LLAssetType::EType mAssetType; @@ -205,6 +207,7 @@ public: bool getIsRunning() const { return mIsRunning; } private: + bool mSaveToVFS; LLUUID mExerienceId; TargetType_t mTargetType; bool mIsRunning; -- cgit v1.2.3 From f2850548abf8c103d6b11051a168d4f01ca154f4 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 20 Jul 2015 17:00:06 -0700 Subject: Forgot to remove an unused varable and renamed NewFileResourceUploadInfo to LLNewFileResourceUploadInfo --- indra/newview/llfloaternamedesc.cpp | 2 +- indra/newview/llviewerassetupload.cpp | 6 +++--- indra/newview/llviewerassetupload.h | 5 ++--- indra/newview/llviewermenufile.cpp | 4 ++-- 4 files changed, 8 insertions(+), 9 deletions(-) (limited to 'indra') diff --git a/indra/newview/llfloaternamedesc.cpp b/indra/newview/llfloaternamedesc.cpp index 46dbf85dfa..135bbb335e 100755 --- a/indra/newview/llfloaternamedesc.cpp +++ b/indra/newview/llfloaternamedesc.cpp @@ -164,7 +164,7 @@ void LLFloaterNameDesc::onBtnOK( ) void *nruserdata = NULL; std::string display_name = LLStringUtil::null; - LLResourceUploadInfo::ptr_t uploadInfo(new NewFileResourceUploadInfo( + LLResourceUploadInfo::ptr_t uploadInfo(new LLNewFileResourceUploadInfo( mFilenameAndPath, getChild("name_form")->getValue().asString(), getChild("description_form")->getValue().asString(), 0, diff --git a/indra/newview/llviewerassetupload.cpp b/indra/newview/llviewerassetupload.cpp index 9982d68f52..51374922e8 100644 --- a/indra/newview/llviewerassetupload.cpp +++ b/indra/newview/llviewerassetupload.cpp @@ -286,7 +286,7 @@ std::string LLResourceUploadInfo::getDisplayName() const }; //========================================================================= -NewFileResourceUploadInfo::NewFileResourceUploadInfo( +LLNewFileResourceUploadInfo::LLNewFileResourceUploadInfo( std::string fileName, std::string name, std::string description, @@ -306,7 +306,7 @@ NewFileResourceUploadInfo::NewFileResourceUploadInfo( -LLSD NewFileResourceUploadInfo::prepareUpload() +LLSD LLNewFileResourceUploadInfo::prepareUpload() { if (getAssetId().isNull()) generateNewAssetId(); @@ -318,7 +318,7 @@ LLSD NewFileResourceUploadInfo::prepareUpload() return LLResourceUploadInfo::prepareUpload(); } -LLSD NewFileResourceUploadInfo::exportTempFile() +LLSD LLNewFileResourceUploadInfo::exportTempFile() { std::string filename = gDirUtilp->getTempFilename(); diff --git a/indra/newview/llviewerassetupload.h b/indra/newview/llviewerassetupload.h index 23013ac664..604db808b1 100644 --- a/indra/newview/llviewerassetupload.h +++ b/indra/newview/llviewerassetupload.h @@ -126,10 +126,10 @@ private: }; //------------------------------------------------------------------------- -class NewFileResourceUploadInfo : public LLResourceUploadInfo +class LLNewFileResourceUploadInfo : public LLResourceUploadInfo { public: - NewFileResourceUploadInfo( + LLNewFileResourceUploadInfo( std::string fileName, std::string name, std::string description, @@ -207,7 +207,6 @@ public: bool getIsRunning() const { return mIsRunning; } private: - bool mSaveToVFS; LLUUID mExerienceId; TargetType_t mTargetType; bool mIsRunning; diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index 163ae4f4ec..904fa7fcbe 100755 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -436,7 +436,7 @@ class LLFileUploadBulk : public view_listener_t LLStringUtil::stripNonprintable(asset_name); LLStringUtil::trim(asset_name); - LLResourceUploadInfo::ptr_t uploadInfo(new NewFileResourceUploadInfo( + LLResourceUploadInfo::ptr_t uploadInfo(new LLNewFileResourceUploadInfo( filename, asset_name, asset_name, 0, @@ -635,7 +635,7 @@ LLUUID upload_new_resource( void *userdata) { - LLResourceUploadInfo::ptr_t uploadInfo(new NewFileResourceUploadInfo( + LLResourceUploadInfo::ptr_t uploadInfo(new LLNewFileResourceUploadInfo( src_filename, name, desc, compression_info, destination_folder_type, inv_type, -- cgit v1.2.3 From 22bd85441b488dd9576bbdeffe9936650f010d78 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 22 Jul 2015 09:33:21 -0700 Subject: Clean up for postcard post. --- indra/newview/llpanelsnapshotpostcard.cpp | 52 +++++++++---- indra/newview/llpostcard.cpp | 123 ++++++------------------------ indra/newview/llpostcard.h | 26 ++++++- indra/newview/llviewerassetupload.cpp | 62 ++++++++++++--- indra/newview/llviewerassetupload.h | 2 + 5 files changed, 137 insertions(+), 128 deletions(-) (limited to 'indra') diff --git a/indra/newview/llpanelsnapshotpostcard.cpp b/indra/newview/llpanelsnapshotpostcard.cpp index 8e37b1418c..e4f39aac04 100755 --- a/indra/newview/llpanelsnapshotpostcard.cpp +++ b/indra/newview/llpanelsnapshotpostcard.cpp @@ -40,6 +40,7 @@ #include "llpostcard.h" #include "llviewercontrol.h" // gSavedSettings #include "llviewerwindow.h" +#include "llviewerregion.h" #include @@ -67,7 +68,8 @@ private: /*virtual*/ void updateControls(const LLSD& info); bool missingSubjMsgAlertCallback(const LLSD& notification, const LLSD& response); - void sendPostcard(); + static void sendPostcardFinished(LLSD result); + void sendPostcard(); void onMsgFormFocusRecieved(); void onFormatComboCommit(LLUICtrl* ctrl); @@ -166,24 +168,44 @@ bool LLPanelSnapshotPostcard::missingSubjMsgAlertCallback(const LLSD& notificati } -void LLPanelSnapshotPostcard::sendPostcard() +void LLPanelSnapshotPostcard::sendPostcardFinished(LLSD result) { - std::string to(getChild("to_form")->getValue().asString()); - std::string subject(getChild("subject_form")->getValue().asString()); + LL_WARNS() << result << LL_ENDL; - LLSD postcard = LLSD::emptyMap(); - postcard["pos-global"] = LLFloaterSnapshot::getPosTakenGlobal().getValue(); - postcard["to"] = to; - postcard["from"] = mAgentEmail; - postcard["name"] = getChild("name_form")->getValue().asString(); - postcard["subject"] = subject; - postcard["msg"] = getChild("msg_form")->getValue().asString(); - LLPostCard::send(LLFloaterSnapshot::getImageData(), postcard); + std::string state = result["state"].asString(); - // Give user feedback of the event. - gViewerWindow->playSnapshotAnimAndSound(); + LLPostCard::reportPostResult((state == "complete")); +} - LLFloaterSnapshot::postSave(); + +void LLPanelSnapshotPostcard::sendPostcard() +{ + // upload the image + std::string url = gAgent.getRegion()->getCapability("SendPostcard"); + if (!url.empty()) + { + LLResourceUploadInfo::ptr_t uploadInfo(new LLPostcardUploadInfo( + mAgentEmail, + getChild("name_form")->getValue().asString(), + getChild("to_form")->getValue().asString(), + getChild("subject_form")->getValue().asString(), + getChild("msg_form")->getValue().asString(), + LLFloaterSnapshot::getPosTakenGlobal(), + LLFloaterSnapshot::getImageData(), + boost::bind(&LLPanelSnapshotPostcard::sendPostcardFinished, _4))); + + LLViewerAssetUpload::EnqueueInventoryUpload(url, uploadInfo); + } + else + { + LL_WARNS() << "Postcards unavailable in this region." << LL_ENDL; + } + + + // Give user feedback of the event. + gViewerWindow->playSnapshotAnimAndSound(); + + LLFloaterSnapshot::postSave(); } void LLPanelSnapshotPostcard::onMsgFormFocusRecieved() diff --git a/indra/newview/llpostcard.cpp b/indra/newview/llpostcard.cpp index 5987044bff..4e34ec912e 100755 --- a/indra/newview/llpostcard.cpp +++ b/indra/newview/llpostcard.cpp @@ -37,121 +37,42 @@ #include "llagent.h" #include "llassetstorage.h" #include "llassetuploadresponders.h" +#include "llviewerassetupload.h" /////////////////////////////////////////////////////////////////////////////// -// misc -static void postcard_upload_callback(const LLUUID& asset_id, void *user_data, S32 result, LLExtStat ext_status) +LLPostcardUploadInfo::LLPostcardUploadInfo(std::string emailFrom, std::string nameFrom, std::string emailTo, + std::string subject, std::string message, LLVector3d globalPosition, + LLPointer image, invnUploadFinish_f finish) : + LLBufferedAssetUploadInfo(LLUUID::null, image, finish), + mEmailFrom(emailFrom), + mNameFrom(nameFrom), + mEmailTo(emailTo), + mSubject(subject), + mMessage(message), + mGlobalPosition(globalPosition) { - LLSD* postcard_data = (LLSD*)user_data; - - if (result) - { - // TODO: display the error messages in UI - LL_WARNS() << "Failed to send postcard: " << LLAssetStorage::getErrorString(result) << LL_ENDL; - LLPostCard::reportPostResult(false); - } - else - { - // only create the postcard once the upload succeeds - - // request the postcard - const LLSD& data = *postcard_data; - LLMessageSystem* msg = gMessageSystem; - msg->newMessage("SendPostcard"); - msg->nextBlock("AgentData"); - msg->addUUID("AgentID", gAgent.getID()); - msg->addUUID("SessionID", gAgent.getSessionID()); - msg->addUUID("AssetID", data["asset-id"].asUUID()); - msg->addVector3d("PosGlobal", LLVector3d(data["pos-global"])); - msg->addString("To", data["to"]); - msg->addString("From", data["from"]); - msg->addString("Name", data["name"]); - msg->addString("Subject", data["subject"]); - msg->addString("Msg", data["msg"]); - msg->addBOOL("AllowPublish", FALSE); - msg->addBOOL("MaturePublish", FALSE); - gAgent.sendReliableMessage(); - - LLPostCard::reportPostResult(true); - } - - delete postcard_data; } - -/////////////////////////////////////////////////////////////////////////////// -// LLPostcardSendResponder - -class LLPostcardSendResponder : public LLAssetUploadResponder +LLSD LLPostcardUploadInfo::generatePostBody() { - LOG_CLASS(LLPostcardSendResponder); - -public: - LLPostcardSendResponder(const LLSD &post_data, - const LLUUID& vfile_id, - LLAssetType::EType asset_type): - LLAssetUploadResponder(post_data, vfile_id, asset_type) - { - } - - /*virtual*/ void httpFailure() - { - LL_WARNS() << "Sending postcard failed, status: " << getStatus() << LL_ENDL; - LLPostCard::reportPostResult(false); - } - - /*virtual*/ void uploadComplete(const LLSD& content) - { - LL_INFOS() << "Postcard sent" << LL_ENDL; - LL_DEBUGS("Snapshots") << "content: " << content << LL_ENDL; - LLPostCard::reportPostResult(true); - } + LLSD postcard = LLSD::emptyMap(); + postcard["pos-global"] = mGlobalPosition.getValue(); + postcard["to"] = mEmailTo; + postcard["from"] = mEmailFrom; + postcard["name"] = mNameFrom; + postcard["subject"] = mSubject; + postcard["msg"] = mMessage; + + return postcard; +} - /*virtual*/ void uploadFailure(const LLSD& content) - { - LL_WARNS() << "Sending postcard failed: " << content << LL_ENDL; - LLPostCard::reportPostResult(false); - } -}; /////////////////////////////////////////////////////////////////////////////// // LLPostCard LLPostCard::result_callback_t LLPostCard::mResultCallback; -// static -void LLPostCard::send(LLPointer image, const LLSD& postcard_data) -{ - LLTransactionID transaction_id; - LLAssetID asset_id; - - transaction_id.generate(); - asset_id = transaction_id.makeAssetID(gAgent.getSecureSessionID()); - LLVFile::writeFile(image->getData(), image->getDataSize(), gVFS, asset_id, LLAssetType::AT_IMAGE_JPEG); - - // upload the image - std::string url = gAgent.getRegion()->getCapability("SendPostcard"); - if (!url.empty()) - { - LL_INFOS() << "Sending postcard via capability" << LL_ENDL; - // the capability already encodes: agent ID, region ID - LL_DEBUGS("Snapshots") << "url: " << url << LL_ENDL; - LL_DEBUGS("Snapshots") << "body: " << postcard_data << LL_ENDL; - LL_DEBUGS("Snapshots") << "data size: " << image->getDataSize() << LL_ENDL; - LLHTTPClient::post(url, postcard_data, - new LLPostcardSendResponder(postcard_data, asset_id, LLAssetType::AT_IMAGE_JPEG)); - } - else - { - LL_INFOS() << "Sending postcard" << LL_ENDL; - LLSD* data = new LLSD(postcard_data); - (*data)["asset-id"] = asset_id; - gAssetStorage->storeAssetData(transaction_id, LLAssetType::AT_IMAGE_JPEG, - &postcard_upload_callback, (void *)data, FALSE); - } -} - // static void LLPostCard::reportPostResult(bool ok) { diff --git a/indra/newview/llpostcard.h b/indra/newview/llpostcard.h index 0eb118b906..24157be636 100755 --- a/indra/newview/llpostcard.h +++ b/indra/newview/llpostcard.h @@ -29,7 +29,12 @@ #include "llimage.h" #include "lluuid.h" +#include "llviewerassetupload.h" +/// *TODO$: this LLPostCard class is a hold over and should be removed. Right now +/// all it does is hold a pointer to a call back function which is invoked by +/// llpanelsnapshotpostcard's finish function. (and all that call back does is +/// set the status in the floater. class LLPostCard { LOG_CLASS(LLPostCard); @@ -37,7 +42,6 @@ class LLPostCard public: typedef boost::function result_callback_t; - static void send(LLPointer image, const LLSD& postcard_data); static void setPostResultCallback(result_callback_t cb) { mResultCallback = cb; } static void reportPostResult(bool ok); @@ -45,4 +49,24 @@ private: static result_callback_t mResultCallback; }; + +class LLPostcardUploadInfo : public LLBufferedAssetUploadInfo +{ +public: + LLPostcardUploadInfo(std::string emailFrom, std::string nameFrom, std::string emailTo, + std::string subject, std::string message, LLVector3d globalPosition, + LLPointer image, invnUploadFinish_f finish); + + virtual LLSD generatePostBody(); +private: + std::string mEmailFrom; + std::string mNameFrom; + std::string mEmailTo; + std::string mSubject; + std::string mMessage; + LLVector3d mGlobalPosition; + +}; + + #endif // LL_LLPOSTCARD_H diff --git a/indra/newview/llviewerassetupload.cpp b/indra/newview/llviewerassetupload.cpp index 51374922e8..b00f99cf5c 100644 --- a/indra/newview/llviewerassetupload.cpp +++ b/indra/newview/llviewerassetupload.cpp @@ -458,6 +458,40 @@ LLBufferedAssetUploadInfo::LLBufferedAssetUploadInfo(LLUUID itemId, LLAssetType: } +LLBufferedAssetUploadInfo::LLBufferedAssetUploadInfo(LLUUID itemId, LLPointer image, invnUploadFinish_f finish) : + LLResourceUploadInfo(std::string(), std::string(), 0, LLFolderType::FT_NONE, LLInventoryType::IT_NONE, + 0, 0, 0, 0), + mTaskUpload(false), + mTaskId(LLUUID::null), + mContents(), + mInvnFinishFn(finish), + mTaskFinishFn(NULL), + mStoredToVFS(false) +{ + setItemId(itemId); + + EImageCodec codec = static_cast(image->getCodec()); + + switch (codec) + { + case IMG_CODEC_JPEG: + setAssetType(LLAssetType::AT_IMAGE_JPEG); + LL_INFOS() << "Upload Asset type set to JPEG." << LL_ENDL; + break; + case IMG_CODEC_TGA: + setAssetType(LLAssetType::AT_IMAGE_TGA); + LL_INFOS() << "Upload Asset type set to TGA." << LL_ENDL; + break; + default: + LL_WARNS() << "Unknown codec to asset type transition. Codec=" << (int)codec << "." << LL_ENDL; + break; + } + + size_t imageSize = image->getDataSize(); + mContents.reserve(imageSize); + mContents.assign((char *)image->getData(), imageSize); +} + LLBufferedAssetUploadInfo::LLBufferedAssetUploadInfo(LLUUID taskId, LLUUID itemId, LLAssetType::EType assetType, std::string buffer, taskUploadFinish_f finish) : LLResourceUploadInfo(std::string(), std::string(), 0, LLFolderType::FT_NONE, LLInventoryType::IT_NONE, 0, 0, 0, 0), @@ -526,24 +560,30 @@ LLUUID LLBufferedAssetUploadInfo::finishUpload(LLSD &result) } else { - LLViewerInventoryItem* item = (LLViewerInventoryItem*)gInventory.getItem(itemId); - if(!item) + LLUUID newItemId(LLUUID::null); + + if (itemId.notNull()) { - LL_WARNS() << "Inventory item for " << getDisplayName() << " is no longer in agent inventory." << LL_ENDL; - return newAssetId; - } + LLViewerInventoryItem* item = (LLViewerInventoryItem*)gInventory.getItem(itemId); + if (!item) + { + LL_WARNS() << "Inventory item for " << getDisplayName() << " is no longer in agent inventory." << LL_ENDL; + return newAssetId; + } - // Update viewer inventory item - LLPointer newItem = new LLViewerInventoryItem(item); - newItem->setAssetUUID(newAssetId); + // Update viewer inventory item + LLPointer newItem = new LLViewerInventoryItem(item); + newItem->setAssetUUID(newAssetId); - gInventory.updateItem(newItem); + gInventory.updateItem(newItem); - LL_INFOS() << "Inventory item " << item->getName() << " saved into " << newAssetId.asString() << LL_ENDL; + newItemId = newItem->getUUID(); + LL_INFOS() << "Inventory item " << item->getName() << " saved into " << newAssetId.asString() << LL_ENDL; + } if (mInvnFinishFn) { - mInvnFinishFn(itemId, newAssetId, newItem->getUUID(), result); + mInvnFinishFn(itemId, newAssetId, newItemId, result); } gInventory.notifyObservers(); } diff --git a/indra/newview/llviewerassetupload.h b/indra/newview/llviewerassetupload.h index 604db808b1..6e036fe526 100644 --- a/indra/newview/llviewerassetupload.h +++ b/indra/newview/llviewerassetupload.h @@ -34,6 +34,7 @@ #include "lleventcoro.h" #include "llcoros.h" #include "llcorehttputil.h" +#include "llimage.h" //========================================================================= class LLResourceUploadInfo @@ -162,6 +163,7 @@ public: typedef boost::function taskUploadFinish_f; LLBufferedAssetUploadInfo(LLUUID itemId, LLAssetType::EType assetType, std::string buffer, invnUploadFinish_f finish); + LLBufferedAssetUploadInfo(LLUUID itemId, LLPointer image, invnUploadFinish_f finish); LLBufferedAssetUploadInfo(LLUUID taskId, LLUUID itemId, LLAssetType::EType assetType, std::string buffer, taskUploadFinish_f finish); virtual LLSD prepareUpload(); -- cgit v1.2.3 From 62e83193c55e505d83a9be33cbc30353b6b887d2 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 22 Jul 2015 14:56:49 -0700 Subject: MAINT-5357: Added yield between prepare and post in upload. Removed some commented out code I had missed earlier Moved costing to virtual function in uploadinfo. --- indra/newview/llsnapshotlivepreview.cpp | 18 -------- indra/newview/llviewerassetupload.cpp | 73 +++++++++++++++++++-------------- indra/newview/llviewerassetupload.h | 1 + 3 files changed, 43 insertions(+), 49 deletions(-) (limited to 'indra') diff --git a/indra/newview/llsnapshotlivepreview.cpp b/indra/newview/llsnapshotlivepreview.cpp index 16f70a1c95..8fb3340db0 100644 --- a/indra/newview/llsnapshotlivepreview.cpp +++ b/indra/newview/llsnapshotlivepreview.cpp @@ -1005,7 +1005,6 @@ void LLSnapshotLivePreview::saveTexture() std::string who_took_it; LLAgentUI::buildFullname(who_took_it); S32 expected_upload_cost = LLGlobalEconomy::Singleton::getInstance()->getPriceUpload(); -#if 1 std::string name = "Snapshot: " + pos_string; std::string desc = "Taken by " + who_took_it + " at " + pos_string; @@ -1017,23 +1016,6 @@ void LLSnapshotLivePreview::saveTexture() upload_new_resource(assetUploadInfo); -#else - LLAssetStorage::LLStoreAssetCallback callback = NULL; - void *userdata = NULL; - - upload_new_resource(tid, // tid - LLAssetType::AT_TEXTURE, - "Snapshot : " + pos_string, - "Taken by " + who_took_it + " at " + pos_string, - 0, - LLFolderType::FT_SNAPSHOT_CATEGORY, - LLInventoryType::IT_SNAPSHOT, - PERM_ALL, // Note: Snapshots to inventory is a special case of content upload - LLFloaterPerms::getGroupPerms("Uploads"), // that is more permissive than other uploads - LLFloaterPerms::getEveryonePerms("Uploads"), - "Snapshot : " + pos_string, - callback, expected_upload_cost, userdata); -#endif gViewerWindow->playSnapshotAnimAndSound(); } else diff --git a/indra/newview/llviewerassetupload.cpp b/indra/newview/llviewerassetupload.cpp index b00f99cf5c..83d3449b96 100644 --- a/indra/newview/llviewerassetupload.cpp +++ b/indra/newview/llviewerassetupload.cpp @@ -148,6 +148,22 @@ void LLResourceUploadInfo::logPreparedUpload() "Asset Type: " << LLAssetType::lookup(mAssetType) << LL_ENDL; } +S32 LLResourceUploadInfo::getEconomyUploadCost() +{ + // Update L$ and ownership credit information + // since it probably changed on the server + if (getAssetType() == LLAssetType::AT_TEXTURE || + getAssetType() == LLAssetType::AT_SOUND || + getAssetType() == LLAssetType::AT_ANIMATION || + getAssetType() == LLAssetType::AT_MESH) + { + return LLGlobalEconomy::Singleton::getInstance()->getPriceUpload(); + } + + return 0; +} + + LLUUID LLResourceUploadInfo::finishUpload(LLSD &result) { if (getFolderId().isNull()) @@ -660,7 +676,7 @@ void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoreHttpUtil::HttpCorouti return; } - //self.yield(); + llcoro::yield(); if (uploadInfo->showUploadDialog()) { @@ -686,43 +702,38 @@ void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoreHttpUtil::HttpCorouti std::string uploader = result["uploader"].asString(); - result = httpAdapter->postFileAndYield(httpRequest, uploader, uploadInfo->getAssetId(), uploadInfo->getAssetType()); - httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; - status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); - - if (!status) + bool success = false; + if (!uploader.empty() && uploadInfo->getAssetId().notNull()) { - HandleUploadError(status, result, uploadInfo); - if (uploadInfo->showUploadDialog()) - LLUploadDialog::modalUploadFinished(); - return; - } + result = httpAdapter->postFileAndYield(httpRequest, uploader, uploadInfo->getAssetId(), uploadInfo->getAssetType()); + httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); - S32 uploadPrice = 0; + if (!status) + { + HandleUploadError(status, result, uploadInfo); + if (uploadInfo->showUploadDialog()) + LLUploadDialog::modalUploadFinished(); + return; + } - // Update L$ and ownership credit information - // since it probably changed on the server - if (uploadInfo->getAssetType() == LLAssetType::AT_TEXTURE || - uploadInfo->getAssetType() == LLAssetType::AT_SOUND || - uploadInfo->getAssetType() == LLAssetType::AT_ANIMATION || - uploadInfo->getAssetType() == LLAssetType::AT_MESH) - { - uploadPrice = LLGlobalEconomy::Singleton::getInstance()->getPriceUpload(); - } + S32 uploadPrice = uploadInfo->getEconomyUploadCost(); - bool success = false; + if (uploadPrice > 0) + { + // this upload costed us L$, update our balance + // and display something saying that it cost L$ + LLStatusBar::sendMoneyBalanceRequest(); - if (uploadPrice > 0) + LLSD args; + args["AMOUNT"] = llformat("%d", uploadPrice); + LLNotificationsUtil::add("UploadPayment", args); + } + } + else { - // this upload costed us L$, update our balance - // and display something saying that it cost L$ - LLStatusBar::sendMoneyBalanceRequest(); - - LLSD args; - args["AMOUNT"] = llformat("%d", uploadPrice); - LLNotificationsUtil::add("UploadPayment", args); + LL_WARNS() << "No upload url provided. Nothing uploaded, responding with previous result." << LL_ENDL; } - LLUUID serverInventoryItem = uploadInfo->finishUpload(result); if (uploadInfo->showInventoryPanel()) diff --git a/indra/newview/llviewerassetupload.h b/indra/newview/llviewerassetupload.h index 6e036fe526..d41ba7f61b 100644 --- a/indra/newview/llviewerassetupload.h +++ b/indra/newview/llviewerassetupload.h @@ -61,6 +61,7 @@ public: virtual LLSD prepareUpload(); virtual LLSD generatePostBody(); virtual void logPreparedUpload(); + virtual S32 getEconomyUploadCost(); virtual LLUUID finishUpload(LLSD &result); LLTransactionID getTransactionId() const { return mTransactionId; } -- cgit v1.2.3 From a035d78e25551a77a7a1513c3cee8b9dca117540 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 23 Jul 2015 11:28:21 -0700 Subject: AR Reports now use coroutines. --- indra/newview/llfloaterreporter.cpp | 107 ++++++++++++++++++++-------------- indra/newview/llfloaterreporter.h | 2 + indra/newview/llviewerassetupload.cpp | 22 +++++-- indra/newview/llviewerassetupload.h | 5 ++ 4 files changed, 88 insertions(+), 48 deletions(-) (limited to 'indra') diff --git a/indra/newview/llfloaterreporter.cpp b/indra/newview/llfloaterreporter.cpp index 5e028e6d43..b38362e180 100755 --- a/indra/newview/llfloaterreporter.cpp +++ b/indra/newview/llfloaterreporter.cpp @@ -83,6 +83,61 @@ #include "lltrans.h" #include "llexperiencecache.h" +#include "llcorehttputil.h" +#include "llviewerassetupload.h" + + +//========================================================================= +//----------------------------------------------------------------------------- +// Support classes +//----------------------------------------------------------------------------- +class LLARScreenShotUploader : public LLResourceUploadInfo +{ +public: + LLARScreenShotUploader(LLSD report, LLUUID assetId, LLAssetType::EType assetType); + + virtual LLSD prepareUpload(); + virtual LLSD generatePostBody(); + virtual S32 getEconomyUploadCost(); + virtual LLUUID finishUpload(LLSD &result); + + virtual bool showInventoryPanel() const { return false; } + virtual std::string getDisplayName() const { return "Abuse Report"; } + +private: + + LLSD mReport; +}; + +LLARScreenShotUploader::LLARScreenShotUploader(LLSD report, LLUUID assetId, LLAssetType::EType assetType) : + LLResourceUploadInfo(assetId, assetType, "Abuse Report"), + mReport(report) +{ +} + +LLSD LLARScreenShotUploader::prepareUpload() +{ + return LLSD().with("success", LLSD::Boolean(true)); +} + +LLSD LLARScreenShotUploader::generatePostBody() +{ // The report was pregenerated and passed in the constructor. + return mReport; +} + +S32 LLARScreenShotUploader::getEconomyUploadCost() +{ // Abuse report screen shots do not cost anything to upload. + return 0; +} + +LLUUID LLARScreenShotUploader::finishUpload(LLSD &result) +{ + /* *TODO$: Report success or failure. Carried over from previous todo on responder*/ + return LLUUID::null; +} + + +//========================================================================= //----------------------------------------------------------------------------- // Globals //----------------------------------------------------------------------------- @@ -724,59 +779,25 @@ void LLFloaterReporter::sendReportViaLegacy(const LLSD & report) msg->sendReliable(regionp->getHost()); } -class LLUserReportScreenshotResponder : public LLAssetUploadResponder +void LLFloaterReporter::finishedARPost(const LLSD &) { -public: - LLUserReportScreenshotResponder(const LLSD & post_data, - const LLUUID & vfile_id, - LLAssetType::EType asset_type): - LLAssetUploadResponder(post_data, vfile_id, asset_type) - { - } - void uploadFailed(const LLSD& content) - { - // *TODO pop up a dialog so the user knows their report screenshot didn't make it - LLUploadDialog::modalUploadFinished(); - } - void uploadComplete(const LLSD& content) - { - // we don't care about what the server returns from this post, just clean up the UI - LLUploadDialog::modalUploadFinished(); - } -}; + LLUploadDialog::modalUploadFinished(); -class LLUserReportResponder : public LLHTTPClient::Responder -{ - LOG_CLASS(LLUserReportResponder); -public: - LLUserReportResponder(): LLHTTPClient::Responder() {} - -private: - void httpCompleted() - { - if (!isGoodStatus()) - { - // *TODO do some user messaging here - LL_WARNS("UserReport") << dumpResponse() << LL_ENDL; - } - // we don't care about what the server returns - LLUploadDialog::modalUploadFinished(); - } -}; +} void LLFloaterReporter::sendReportViaCaps(std::string url, std::string sshot_url, const LLSD& report) { if(getChild("screen_check")->getValue().asBoolean() && !sshot_url.empty()) - { + { // try to upload screenshot - LLHTTPClient::post(sshot_url, report, new LLUserReportScreenshotResponder(report, - mResourceDatap->mAssetInfo.mUuid, - mResourceDatap->mAssetInfo.mType)); + LLResourceUploadInfo::ptr_t uploadInfo(new LLARScreenShotUploader(report, mResourceDatap->mAssetInfo.mUuid, mResourceDatap->mAssetInfo.mType)); + LLViewerAssetUpload::EnqueueInventoryUpload(sshot_url, uploadInfo); } else { - // screenshot not wanted or we don't have screenshot cap - LLHTTPClient::post(url, report, new LLUserReportResponder()); + LLCoreHttpUtil::HttpCoroutineAdapter::completionCallback_t proc = boost::bind(&LLFloaterReporter::finishedARPost, _1); + LLUploadDialog::modalUploadDialog("Abuse Report"); + LLCoreHttpUtil::HttpCoroutineAdapter::callbackHttpPost(url, report, proc, proc); } } diff --git a/indra/newview/llfloaterreporter.h b/indra/newview/llfloaterreporter.h index 5eb5c20665..83050d73ca 100755 --- a/indra/newview/llfloaterreporter.h +++ b/indra/newview/llfloaterreporter.h @@ -125,6 +125,8 @@ private: void setFromAvatarID(const LLUUID& avatar_id); void onAvatarNameCache(const LLUUID& avatar_id, const LLAvatarName& av_name); + static void finishedARPost(const LLSD &); + private: EReportType mReportType; LLUUID mObjectID; diff --git a/indra/newview/llviewerassetupload.cpp b/indra/newview/llviewerassetupload.cpp index 83d3449b96..4ef398d314 100644 --- a/indra/newview/llviewerassetupload.cpp +++ b/indra/newview/llviewerassetupload.cpp @@ -97,6 +97,23 @@ LLResourceUploadInfo::LLResourceUploadInfo(std::string name, mTransactionId.generate(); } +LLResourceUploadInfo::LLResourceUploadInfo(LLAssetID assetId, LLAssetType::EType assetType, std::string name) : + mAssetId(assetId), + mAssetType(assetType), + mName(name), + mDescription(), + mCompressionInfo(0), + mDestinationFolderType(LLFolderType::FT_NONE), + mInventoryType(LLInventoryType::IT_NONE), + mNextOwnerPerms(0), + mGroupPerms(0), + mEveryonePerms(0), + mExpectedUploadCost(0), + mTransactionId(), + mFolderId(LLUUID::null), + mItemId(LLUUID::null) +{ +} LLSD LLResourceUploadInfo::prepareUpload() { @@ -320,8 +337,6 @@ LLNewFileResourceUploadInfo::LLNewFileResourceUploadInfo( { } - - LLSD LLNewFileResourceUploadInfo::prepareUpload() { if (getAssetId().isNull()) @@ -471,7 +486,6 @@ LLBufferedAssetUploadInfo::LLBufferedAssetUploadInfo(LLUUID itemId, LLAssetType: { setItemId(itemId); setAssetType(assetType); - } LLBufferedAssetUploadInfo::LLBufferedAssetUploadInfo(LLUUID itemId, LLPointer image, invnUploadFinish_f finish) : @@ -522,7 +536,6 @@ LLBufferedAssetUploadInfo::LLBufferedAssetUploadInfo(LLUUID taskId, LLUUID itemI setAssetType(assetType); } - LLSD LLBufferedAssetUploadInfo::prepareUpload() { if (getAssetId().isNull()) @@ -626,7 +639,6 @@ LLScriptAssetUpload::LLScriptAssetUpload(LLUUID taskId, LLUUID itemId, TargetTyp { } - LLSD LLScriptAssetUpload::generatePostBody() { LLSD body; diff --git a/indra/newview/llviewerassetupload.h b/indra/newview/llviewerassetupload.h index d41ba7f61b..43e23a0d42 100644 --- a/indra/newview/llviewerassetupload.h +++ b/indra/newview/llviewerassetupload.h @@ -99,6 +99,11 @@ protected: U32 everyonePerms, S32 expectedCost); + LLResourceUploadInfo( + LLAssetID assetId, + LLAssetType::EType assetType, + std::string name ); + void setTransactionId(LLTransactionID tid) { mTransactionId = tid; } void setAssetType(LLAssetType::EType assetType) { mAssetType = assetType; } void setItemId(LLUUID itemId) { mItemId = itemId; } -- cgit v1.2.3 From 7882396811fdf8b297f6d0c92d8e1e37859fde9d Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 23 Jul 2015 13:06:24 -0700 Subject: Remove unused code and llassetuploadresponders files. --- indra/newview/CMakeLists.txt | 2 - indra/newview/llassetuploadresponders.cpp | 1153 ----------------------------- indra/newview/llassetuploadresponders.h | 158 ---- indra/newview/llcompilequeue.cpp | 1 - indra/newview/llfloaterreporter.cpp | 1 - indra/newview/llmeshrepository.cpp | 134 ++++ indra/newview/llpostcard.cpp | 1 - indra/newview/llpreviewgesture.cpp | 1 - indra/newview/llpreviewnotecard.cpp | 1 - indra/newview/llpreviewscript.cpp | 1 - indra/newview/llviewermenufile.cpp | 1 - indra/newview/llviewermenufile.h | 10 - 12 files changed, 134 insertions(+), 1330 deletions(-) delete mode 100755 indra/newview/llassetuploadresponders.cpp delete mode 100755 indra/newview/llassetuploadresponders.h (limited to 'indra') diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index e79fa8b084..fd4f9f7f45 100755 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -123,7 +123,6 @@ set(viewer_SOURCE_FILES llappearancemgr.cpp llappviewer.cpp llappviewerlistener.cpp - llassetuploadresponders.cpp llattachmentsmgr.cpp llaudiosourcevo.cpp llautoreplace.cpp @@ -734,7 +733,6 @@ set(viewer_HEADER_FILES llappearancemgr.h llappviewer.h llappviewerlistener.h - llassetuploadresponders.h llattachmentsmgr.h llaudiosourcevo.h llautoreplace.h diff --git a/indra/newview/llassetuploadresponders.cpp b/indra/newview/llassetuploadresponders.cpp deleted file mode 100755 index f62c57b2b3..0000000000 --- a/indra/newview/llassetuploadresponders.cpp +++ /dev/null @@ -1,1153 +0,0 @@ -/** - * @file llassetuploadresponders.cpp - * @brief Processes responses received for asset upload requests. - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#include "llviewerprecompiledheaders.h" - -#include "llassetuploadresponders.h" - -// viewer includes -#include "llagent.h" -#include "llcompilequeue.h" -#include "llbuycurrencyhtml.h" -#include "llfilepicker.h" -#include "llinventorydefines.h" -#include "llinventoryobserver.h" -#include "llinventorypanel.h" -#include "llpermissionsflags.h" -#include "llpreviewnotecard.h" -#include "llpreviewscript.h" -#include "llpreviewgesture.h" -#include "llgesturemgr.h" -#include "llstatusbar.h" // sendMoneyBalanceRequest() -#include "llsdserialize.h" -#include "lluploaddialog.h" -#include "llviewerobject.h" -#include "llviewercontrol.h" -#include "llviewerobjectlist.h" -#include "llviewermenufile.h" -#include "llviewertexlayer.h" -#include "llviewerwindow.h" -#include "lltrans.h" - -// library includes -#include "lldir.h" -#include "lleconomy.h" -#include "llfloaterreg.h" -#include "llfocusmgr.h" -#include "llnotificationsutil.h" -#include "llscrolllistctrl.h" -#include "llsdserialize.h" -#include "llsdutil.h" -#include "llvfs.h" - -void dialog_refresh_all(); - -void on_new_single_inventory_upload_complete( - LLAssetType::EType asset_type, - LLInventoryType::EType inventory_type, - const std::string inventory_type_string, - const LLUUID& item_folder_id, - const std::string& item_name, - const std::string& item_description, - const LLSD& server_response, - S32 upload_price) -{ - bool success = false; - - if ( upload_price > 0 ) - { - // this upload costed us L$, update our balance - // and display something saying that it cost L$ - LLStatusBar::sendMoneyBalanceRequest(); - - LLSD args; - args["AMOUNT"] = llformat("%d", upload_price); - LLNotificationsUtil::add("UploadPayment", args); - } - - if( item_folder_id.notNull() ) - { - U32 everyone_perms = PERM_NONE; - U32 group_perms = PERM_NONE; - U32 next_owner_perms = PERM_ALL; - if( server_response.has("new_next_owner_mask") ) - { - // The server provided creation perms so use them. - // Do not assume we got the perms we asked for in - // since the server may not have granted them all. - everyone_perms = server_response["new_everyone_mask"].asInteger(); - group_perms = server_response["new_group_mask"].asInteger(); - next_owner_perms = server_response["new_next_owner_mask"].asInteger(); - } - else - { - // The server doesn't provide creation perms - // so use old assumption-based perms. - if( inventory_type_string != "snapshot") - { - next_owner_perms = PERM_MOVE | PERM_TRANSFER; - } - } - - LLPermissions new_perms; - new_perms.init( - gAgent.getID(), - gAgent.getID(), - LLUUID::null, - LLUUID::null); - - new_perms.initMasks( - PERM_ALL, - PERM_ALL, - everyone_perms, - group_perms, - next_owner_perms); - - U32 inventory_item_flags = 0; - if (server_response.has("inventory_flags")) - { - inventory_item_flags = (U32) server_response["inventory_flags"].asInteger(); - if (inventory_item_flags != 0) - { - LL_INFOS() << "inventory_item_flags " << inventory_item_flags << LL_ENDL; - } - } - S32 creation_date_now = time_corrected(); - LLPointer item = new LLViewerInventoryItem( - server_response["new_inventory_item"].asUUID(), - item_folder_id, - new_perms, - server_response["new_asset"].asUUID(), - asset_type, - inventory_type, - item_name, - item_description, - LLSaleInfo::DEFAULT, - inventory_item_flags, - creation_date_now); - - gInventory.updateItem(item); - gInventory.notifyObservers(); - success = true; - - // Show the preview panel for textures and sounds to let - // user know that the image (or snapshot) arrived intact. - LLInventoryPanel* panel = LLInventoryPanel::getActiveInventoryPanel(); - if ( panel ) - { - LLFocusableElement* focus = gFocusMgr.getKeyboardFocus(); - - panel->setSelection( - server_response["new_inventory_item"].asUUID(), - TAKE_FOCUS_NO); - - // restore keyboard focus - gFocusMgr.setKeyboardFocus(focus); - } - } - else - { - LL_WARNS() << "Can't find a folder to put it in" << LL_ENDL; - } - - // remove the "Uploading..." message - LLUploadDialog::modalUploadFinished(); - - // Let the Snapshot floater know we have finished uploading a snapshot to inventory. - LLFloater* floater_snapshot = LLFloaterReg::findInstance("snapshot"); - if (asset_type == LLAssetType::AT_TEXTURE && floater_snapshot) - { - floater_snapshot->notify(LLSD().with("set-finished", LLSD().with("ok", success).with("msg", "inventory"))); - } -} - -LLAssetUploadResponder::LLAssetUploadResponder(const LLSD &post_data, - const LLUUID& vfile_id, - LLAssetType::EType asset_type) - : LLHTTPClient::Responder(), - mPostData(post_data), - mVFileID(vfile_id), - mAssetType(asset_type) -{ - if (!gVFS->getExists(vfile_id, asset_type)) - { - LL_WARNS() << "LLAssetUploadResponder called with nonexistant vfile_id" << LL_ENDL; - mVFileID.setNull(); - mAssetType = LLAssetType::AT_NONE; - return; - } -} - -LLAssetUploadResponder::LLAssetUploadResponder( - const LLSD &post_data, - const std::string& file_name, - LLAssetType::EType asset_type) - : LLHTTPClient::Responder(), - mPostData(post_data), - mFileName(file_name), - mAssetType(asset_type) -{ -} - -LLAssetUploadResponder::~LLAssetUploadResponder() -{ - if (!mFileName.empty()) - { - // Delete temp file - LLFile::remove(mFileName); - } -} - -// virtual -void LLAssetUploadResponder::httpFailure() -{ - // *TODO: Add adaptive retry policy? - LL_WARNS() << dumpResponse() << LL_ENDL; - std::string reason; - if (isHttpClientErrorStatus(getStatus())) - { - reason = "Error in upload request. Please visit " - "http://secondlife.com/support for help fixing this problem."; - } - else - { - reason = "The server is experiencing unexpected " - "difficulties."; - } - LLSD args; - args["FILE"] = (mFileName.empty() ? mVFileID.asString() : mFileName); - args["REASON"] = reason; - LLNotificationsUtil::add("CannotUploadReason", args); - - // unfreeze script preview - if(mAssetType == LLAssetType::AT_LSL_TEXT) - { - LLPreviewLSL* preview = LLFloaterReg::findTypedInstance("preview_script", mPostData["item_id"]); - if (preview) - { - LLSD errors; - errors.append(LLTrans::getString("UploadFailed") + reason); - preview->callbackLSLCompileFailed(errors); - } - } - - LLUploadDialog::modalUploadFinished(); - LLFilePicker::instance().reset(); // unlock file picker when bulk upload fails -} - -//virtual -void LLAssetUploadResponder::httpSuccess() -{ - const LLSD& content = getContent(); - if (!content.isMap()) - { - failureResult(HTTP_INTERNAL_ERROR, "Malformed response contents", content); - return; - } - LL_DEBUGS() << "LLAssetUploadResponder::result from capabilities" << LL_ENDL; - - const std::string& state = content["state"].asStringRef(); - - if (state == "upload") - { - uploadUpload(content); - } - else if (state == "complete") - { - // rename file in VFS with new asset id - if (mFileName.empty()) - { - // rename the file in the VFS to the actual asset id - // LL_INFOS() << "Changing uploaded asset UUID to " << content["new_asset"].asUUID() << LL_ENDL; - gVFS->renameFile(mVFileID, mAssetType, content["new_asset"].asUUID(), mAssetType); - } - uploadComplete(content); - } - else - { - uploadFailure(content); - } -} - -void LLAssetUploadResponder::uploadUpload(const LLSD& content) -{ - const std::string& uploader = content["uploader"].asStringRef(); - if (mFileName.empty()) - { - LLHTTPClient::postFile(uploader, mVFileID, mAssetType, this); - } - else - { - LLHTTPClient::postFile(uploader, mFileName, this); - } -} - -void LLAssetUploadResponder::uploadFailure(const LLSD& content) -{ - LL_WARNS() << dumpResponse() << LL_ENDL; - - // unfreeze script preview - if(mAssetType == LLAssetType::AT_LSL_TEXT) - { - LLPreviewLSL* preview = LLFloaterReg::findTypedInstance("preview_script", mPostData["item_id"]); - if (preview) - { - LLSD errors; - errors.append(LLTrans::getString("UploadFailed") + content["message"].asString()); - preview->callbackLSLCompileFailed(errors); - } - } - - // remove the "Uploading..." message - LLUploadDialog::modalUploadFinished(); - - LLFloater* floater_snapshot = LLFloaterReg::findInstance("snapshot"); - if (floater_snapshot) - { - floater_snapshot->notify(LLSD().with("set-finished", LLSD().with("ok", false).with("msg", "inventory"))); - } - - const std::string& reason = content["state"].asStringRef(); - // deal with L$ errors - if (reason == "insufficient funds") - { - S32 price = LLGlobalEconomy::Singleton::getInstance()->getPriceUpload(); - LLStringUtil::format_map_t args; - args["AMOUNT"] = llformat("%d", price); - LLBuyCurrencyHTML::openCurrencyFloater( LLTrans::getString("uploading_costs", args), price ); - } - else - { - LLSD args; - args["FILE"] = (mFileName.empty() ? mVFileID.asString() : mFileName); - args["REASON"] = content["message"].asString(); - LLNotificationsUtil::add("CannotUploadReason", args); - } -} - -void LLAssetUploadResponder::uploadComplete(const LLSD& content) -{ -} - -#if 0 -LLNewAgentInventoryResponder::LLNewAgentInventoryResponder( - const LLSD& post_data, - const LLUUID& vfile_id, - LLAssetType::EType asset_type) - : LLAssetUploadResponder(post_data, vfile_id, asset_type) -{ -} - -LLNewAgentInventoryResponder::LLNewAgentInventoryResponder( - const LLSD& post_data, - const std::string& file_name, - LLAssetType::EType asset_type) - : LLAssetUploadResponder(post_data, file_name, asset_type) -{ -} - -// virtual -void LLNewAgentInventoryResponder::httpFailure() -{ - LLAssetUploadResponder::httpFailure(); - //LLImportColladaAssetCache::getInstance()->assetUploaded(mVFileID, LLUUID(), FALSE); -} - - -//virtual -void LLNewAgentInventoryResponder::uploadFailure(const LLSD& content) -{ - LLAssetUploadResponder::uploadFailure(content); - - //LLImportColladaAssetCache::getInstance()->assetUploaded(mVFileID, content["new_asset"], FALSE); -} - -//virtual -void LLNewAgentInventoryResponder::uploadComplete(const LLSD& content) -{ - LL_DEBUGS() << "LLNewAgentInventoryResponder::result from capabilities" << LL_ENDL; - - //std::ostringstream llsdxml; - //LLSDSerialize::toXML(content, llsdxml); - //LL_INFOS() << "upload complete content:\n " << llsdxml.str() << LL_ENDL; - - LLAssetType::EType asset_type = LLAssetType::lookup(mPostData["asset_type"].asString()); - LLInventoryType::EType inventory_type = LLInventoryType::lookup(mPostData["inventory_type"].asString()); - S32 expected_upload_cost = 0; - - // Update L$ and ownership credit information - // since it probably changed on the server - if (asset_type == LLAssetType::AT_TEXTURE || - asset_type == LLAssetType::AT_SOUND || - asset_type == LLAssetType::AT_ANIMATION || - asset_type == LLAssetType::AT_MESH) - { - expected_upload_cost = - LLGlobalEconomy::Singleton::getInstance()->getPriceUpload(); - } - - on_new_single_inventory_upload_complete( - asset_type, - inventory_type, - mPostData["asset_type"].asString(), - mPostData["folder_id"].asUUID(), - mPostData["name"], - mPostData["description"], - content, - expected_upload_cost); - - // continue uploading for bulk uploads - - // *FIX: This is a pretty big hack. What this does is check the - // file picker if there are any more pending uploads. If so, - // upload that file. - std::string next_file = LLFilePicker::instance().getNextFile(); - if(!next_file.empty()) - { - std::string name = gDirUtilp->getBaseFileName(next_file, true); - - std::string asset_name = name; - LLStringUtil::replaceNonstandardASCII( asset_name, '?' ); - LLStringUtil::replaceChar(asset_name, '|', '?'); - LLStringUtil::stripNonprintable(asset_name); - LLStringUtil::trim(asset_name); - - // Continuing the horrible hack above, we need to extract the originally requested permissions data, if any, - // and use them for each next file to be uploaded. Note the requested perms are not the same as the - U32 everyone_perms = - content.has("new_everyone_mask") ? - content["new_everyone_mask"].asInteger() : - PERM_NONE; - - U32 group_perms = - content.has("new_group_mask") ? - content["new_group_mask"].asInteger() : - PERM_NONE; - - U32 next_owner_perms = - content.has("new_next_owner_mask") ? - content["new_next_owner_mask"].asInteger() : - PERM_NONE; - - std::string display_name = LLStringUtil::null; - LLAssetStorage::LLStoreAssetCallback callback = NULL; - void *userdata = NULL; - - upload_new_resource( - next_file, - asset_name, - asset_name, - 0, - LLFolderType::FT_NONE, - LLInventoryType::IT_NONE, - next_owner_perms, - group_perms, - everyone_perms, - display_name, - callback, - LLGlobalEconomy::Singleton::getInstance()->getPriceUpload(), - userdata); - } - - //LLImportColladaAssetCache::getInstance()->assetUploaded(mVFileID, content["new_asset"], TRUE); -} -#endif - -#if 0 -LLUpdateAgentInventoryResponder::LLUpdateAgentInventoryResponder( - const LLSD& post_data, - const LLUUID& vfile_id, - LLAssetType::EType asset_type) - : LLAssetUploadResponder(post_data, vfile_id, asset_type) -{ -} - -LLUpdateAgentInventoryResponder::LLUpdateAgentInventoryResponder( - const LLSD& post_data, - const std::string& file_name, - LLAssetType::EType asset_type) - : LLAssetUploadResponder(post_data, file_name, asset_type) -{ -} - -//virtual -void LLUpdateAgentInventoryResponder::uploadComplete(const LLSD& content) -{ - LL_INFOS() << "LLUpdateAgentInventoryResponder::result from capabilities" << LL_ENDL; - LLUUID item_id = mPostData["item_id"]; - - LLViewerInventoryItem* item = (LLViewerInventoryItem*)gInventory.getItem(item_id); - if(!item) - { - LL_WARNS() << "Inventory item for " << mVFileID - << " is no longer in agent inventory." << LL_ENDL; - return; - } - - // Update viewer inventory item - LLPointer new_item = new LLViewerInventoryItem(item); - new_item->setAssetUUID(content["new_asset"].asUUID()); - gInventory.updateItem(new_item); - gInventory.notifyObservers(); - - LL_INFOS() << "Inventory item " << item->getName() << " saved into " - << content["new_asset"].asString() << LL_ENDL; - - LLInventoryType::EType inventory_type = new_item->getInventoryType(); - switch(inventory_type) - { - case LLInventoryType::IT_NOTECARD: - { - // Update the UI with the new asset. - LLPreviewNotecard* nc = LLFloaterReg::findTypedInstance("preview_notecard", LLSD(item_id)); - if(nc) - { - // *HACK: we have to delete the asset in the VFS so - // that the viewer will redownload it. This is only - // really necessary if the asset had to be modified by - // the uploader, so this can be optimized away in some - // cases. A better design is to have a new uuid if the - // script actually changed the asset. - if(nc->hasEmbeddedInventory()) - { - gVFS->removeFile(content["new_asset"].asUUID(), LLAssetType::AT_NOTECARD); - } - nc->refreshFromInventory(new_item->getUUID()); - } - break; - } - case LLInventoryType::IT_LSL: - { - // Find our window and close it if requested. - LLPreviewLSL* preview = LLFloaterReg::findTypedInstance("preview_script", LLSD(item_id)); - if (preview) - { - // Bytecode save completed - if (content["compiled"]) - { - preview->callbackLSLCompileSucceeded(); - } - else - { - preview->callbackLSLCompileFailed(content["errors"]); - } - } - break; - } - - case LLInventoryType::IT_GESTURE: - { - // If this gesture is active, then we need to update the in-memory - // active map with the new pointer. - if (LLGestureMgr::instance().isGestureActive(item_id)) - { - LLUUID asset_id = new_item->getAssetUUID(); - LLGestureMgr::instance().replaceGesture(item_id, asset_id); - gInventory.notifyObservers(); - } - - //gesture will have a new asset_id - LLPreviewGesture* previewp = LLFloaterReg::findTypedInstance("preview_gesture", LLSD(item_id)); - if(previewp) - { - previewp->onUpdateSucceeded(); - } - - break; - } - case LLInventoryType::IT_WEARABLE: - default: - break; - } -} -#endif - -#if 0 -LLUpdateTaskInventoryResponder::LLUpdateTaskInventoryResponder(const LLSD& post_data, - const LLUUID& vfile_id, - LLAssetType::EType asset_type) -: LLAssetUploadResponder(post_data, vfile_id, asset_type) -{ -} - -LLUpdateTaskInventoryResponder::LLUpdateTaskInventoryResponder(const LLSD& post_data, - const std::string& file_name, - LLAssetType::EType asset_type) -: LLAssetUploadResponder(post_data, file_name, asset_type) -{ -} - -LLUpdateTaskInventoryResponder::LLUpdateTaskInventoryResponder(const LLSD& post_data, - const std::string& file_name, - const LLUUID& queue_id, - LLAssetType::EType asset_type) -: LLAssetUploadResponder(post_data, file_name, asset_type), mQueueId(queue_id) -{ -} - -//virtual -void LLUpdateTaskInventoryResponder::uploadComplete(const LLSD& content) -{ - LL_INFOS() << "LLUpdateTaskInventoryResponder::result from capabilities" << LL_ENDL; - LLUUID item_id = mPostData["item_id"]; - LLUUID task_id = mPostData["task_id"]; - - dialog_refresh_all(); - - switch(mAssetType) - { - case LLAssetType::AT_NOTECARD: - { - // Update the UI with the new asset. - LLPreviewNotecard* nc = LLFloaterReg::findTypedInstance("preview_notecard", LLSD(item_id)); - if(nc) - { - // *HACK: we have to delete the asset in the VFS so - // that the viewer will redownload it. This is only - // really necessary if the asset had to be modified by - // the uploader, so this can be optimized away in some - // cases. A better design is to have a new uuid if the - // script actually changed the asset. - if(nc->hasEmbeddedInventory()) - { - gVFS->removeFile(content["new_asset"].asUUID(), - LLAssetType::AT_NOTECARD); - } - nc->setAssetId(content["new_asset"].asUUID()); - nc->refreshFromInventory(); - } - break; - } - case LLAssetType::AT_LSL_TEXT: - { - if(mQueueId.notNull()) - { - LLFloaterCompileQueue* queue = LLFloaterReg::findTypedInstance("compile_queue", mQueueId); - if(NULL != queue) - { - queue->removeItemByItemID(item_id); - } - } - else - { - LLSD floater_key; - floater_key["taskid"] = task_id; - floater_key["itemid"] = item_id; - LLLiveLSLEditor* preview = LLFloaterReg::findTypedInstance("preview_scriptedit", floater_key); - if (preview) - { - // Bytecode save completed - if (content["compiled"]) - { - preview->callbackLSLCompileSucceeded(task_id, item_id, mPostData["is_script_running"]); - } - else - { - preview->callbackLSLCompileFailed(content["errors"]); - } - } - } - break; - } - default: - break; - } -} -#endif - -#if 0 -///////////////////////////////////////////////////// -// LLNewAgentInventoryVariablePriceResponder::Impl // -///////////////////////////////////////////////////// -class LLNewAgentInventoryVariablePriceResponder::Impl -{ -public: - Impl( - const LLUUID& vfile_id, - LLAssetType::EType asset_type, - const LLSD& inventory_data) : - mVFileID(vfile_id), - mAssetType(asset_type), - mInventoryData(inventory_data), - mFileName("") - { - if (!gVFS->getExists(vfile_id, asset_type)) - { - LL_WARNS() - << "LLAssetUploadResponder called with nonexistant " - << "vfile_id " << vfile_id << LL_ENDL; - mVFileID.setNull(); - mAssetType = LLAssetType::AT_NONE; - } - } - - Impl( - const std::string& file_name, - LLAssetType::EType asset_type, - const LLSD& inventory_data) : - mFileName(file_name), - mAssetType(asset_type), - mInventoryData(inventory_data) - { - mVFileID.setNull(); - } - - std::string getFilenameOrIDString() const - { - return (mFileName.empty() ? mVFileID.asString() : mFileName); - } - - LLUUID getVFileID() const - { - return mVFileID; - } - - std::string getFilename() const - { - return mFileName; - } - - LLAssetType::EType getAssetType() const - { - return mAssetType; - } - - LLInventoryType::EType getInventoryType() const - { - return LLInventoryType::lookup( - mInventoryData["inventory_type"].asString()); - } - - std::string getInventoryTypeString() const - { - return mInventoryData["inventory_type"].asString(); - } - - LLUUID getFolderID() const - { - return mInventoryData["folder_id"].asUUID(); - } - - std::string getItemName() const - { - return mInventoryData["name"].asString(); - } - - std::string getItemDescription() const - { - return mInventoryData["description"].asString(); - } - - void displayCannotUploadReason(const std::string& reason) - { - LLSD args; - args["FILE"] = getFilenameOrIDString(); - args["REASON"] = reason; - - - LLNotificationsUtil::add("CannotUploadReason", args); - LLUploadDialog::modalUploadFinished(); - } - - void onApplicationLevelError(const LLSD& error) - { - static const std::string _IDENTIFIER = "identifier"; - - static const std::string _INSUFFICIENT_FUNDS = - "NewAgentInventory_InsufficientLindenDollarBalance"; - static const std::string _MISSING_REQUIRED_PARAMETER = - "NewAgentInventory_MissingRequiredParamater"; - static const std::string _INVALID_REQUEST_BODY = - "NewAgentInventory_InvalidRequestBody"; - static const std::string _RESOURCE_COST_DIFFERS = - "NewAgentInventory_ResourceCostDiffers"; - - static const std::string _MISSING_PARAMETER = "missing_parameter"; - static const std::string _INVALID_PARAMETER = "invalid_parameter"; - static const std::string _MISSING_RESOURCE = "missing_resource"; - static const std::string _INVALID_RESOURCE = "invalid_resource"; - - // TODO* Add the other error_identifiers - - std::string error_identifier = error[_IDENTIFIER].asString(); - - // TODO*: Pull these user visible strings from an xml file - // to be localized - if ( _INSUFFICIENT_FUNDS == error_identifier ) - { - displayCannotUploadReason("You do not have a sufficient L$ balance to complete this upload."); - } - else if ( _MISSING_REQUIRED_PARAMETER == error_identifier ) - { - // Missing parameters - if (error.has(_MISSING_PARAMETER) ) - { - std::string message = - "Upload request was missing required parameter '[P]'"; - LLStringUtil::replaceString( - message, - "[P]", - error[_MISSING_PARAMETER].asString()); - - displayCannotUploadReason(message); - } - else - { - std::string message = - "Upload request was missing a required parameter"; - displayCannotUploadReason(message); - } - } - else if ( _INVALID_REQUEST_BODY == error_identifier ) - { - // Invalid request body, check to see if - // a particular parameter was invalid - if ( error.has(_INVALID_PARAMETER) ) - { - std::string message = "Upload parameter '[P]' is invalid."; - LLStringUtil::replaceString( - message, - "[P]", - error[_INVALID_PARAMETER].asString()); - - // See if the server also responds with what resource - // is missing. - if ( error.has(_MISSING_RESOURCE) ) - { - message += "\nMissing resource '[R]'."; - - LLStringUtil::replaceString( - message, - "[R]", - error[_MISSING_RESOURCE].asString()); - } - else if ( error.has(_INVALID_RESOURCE) ) - { - message += "\nInvalid resource '[R]'."; - - LLStringUtil::replaceString( - message, - "[R]", - error[_INVALID_RESOURCE].asString()); - } - - displayCannotUploadReason(message); - } - else - { - std::string message = "Upload request was malformed"; - displayCannotUploadReason(message); - } - } - else if ( _RESOURCE_COST_DIFFERS == error_identifier ) - { - displayCannotUploadReason("The resource cost associated with this upload is not consistent with the server."); - } - else - { - displayCannotUploadReason("Unknown Error"); - } - } - - void onTransportError() - { - displayCannotUploadReason( - "The server is experiencing unexpected difficulties."); - } - - void onTransportError(const LLSD& error) - { - static const std::string _IDENTIFIER = "identifier"; - - static const std::string _SERVER_ERROR_AFTER_CHARGE = - "NewAgentInventory_ServerErrorAfterCharge"; - - std::string error_identifier = error[_IDENTIFIER].asString(); - - // TODO*: Pull the user visible strings from an xml file - // to be localized - - if ( _SERVER_ERROR_AFTER_CHARGE == error_identifier ) - { - displayCannotUploadReason( - "The server is experiencing unexpected difficulties. You may have been charged for the upload."); - } - else - { - displayCannotUploadReason( - "The server is experiencing unexpected difficulties."); - } - } - - bool uploadConfirmationCallback( - const LLSD& notification, - const LLSD& response, - LLPointer responder) - { - S32 option; - std::string confirmation_url; - - option = LLNotificationsUtil::getSelectedOption( - notification, - response); - - confirmation_url = - notification["payload"]["confirmation_url"].asString(); - - // Yay! We are confirming or cancelling our upload - switch(option) - { - case 0: - { - confirmUpload(confirmation_url, responder); - } - break; - case 1: - default: - break; - } - - return false; - } - - void confirmUpload( - const std::string& confirmation_url, - LLPointer responder) - { - if ( getFilename().empty() ) - { - // we have no filename, use virtual file ID instead - LLHTTPClient::postFile( - confirmation_url, - getVFileID(), - getAssetType(), - responder); - } - else - { - LLHTTPClient::postFile( - confirmation_url, - getFilename(), - responder); - } - } - - -private: - std::string mFileName; - - LLSD mInventoryData; - LLAssetType::EType mAssetType; - LLUUID mVFileID; -}; - -/////////////////////////////////////////////// -// LLNewAgentInventoryVariablePriceResponder // -/////////////////////////////////////////////// -LLNewAgentInventoryVariablePriceResponder::LLNewAgentInventoryVariablePriceResponder( - const LLUUID& vfile_id, - LLAssetType::EType asset_type, - const LLSD& inventory_info) -{ - mImpl = new Impl( - vfile_id, - asset_type, - inventory_info); -} - -LLNewAgentInventoryVariablePriceResponder::LLNewAgentInventoryVariablePriceResponder( - const std::string& file_name, - LLAssetType::EType asset_type, - const LLSD& inventory_info) -{ - mImpl = new Impl( - file_name, - asset_type, - inventory_info); -} - -LLNewAgentInventoryVariablePriceResponder::~LLNewAgentInventoryVariablePriceResponder() -{ - delete mImpl; -} - -void LLNewAgentInventoryVariablePriceResponder::httpFailure() -{ - const LLSD& content = getContent(); - LL_WARNS("Upload") << dumpResponse() << LL_ENDL; - - static const std::string _ERROR = "error"; - if ( content.has(_ERROR) ) - { - mImpl->onTransportError(content[_ERROR]); - } - else - { - mImpl->onTransportError(); - } -} - -void LLNewAgentInventoryVariablePriceResponder::httpSuccess() -{ - const LLSD& content = getContent(); - if (!content.isMap()) - { - failureResult(HTTP_INTERNAL_ERROR, "Malformed response contents", content); - return; - } - // Parse out application level errors and the appropriate - // responses for them - static const std::string _ERROR = "error"; - static const std::string _STATE = "state"; - - static const std::string _COMPLETE = "complete"; - static const std::string _CONFIRM_UPLOAD = "confirm_upload"; - - static const std::string _UPLOAD_PRICE = "upload_price"; - static const std::string _RESOURCE_COST = "resource_cost"; - static const std::string _RSVP = "rsvp"; - - // Check for application level errors - if ( content.has(_ERROR) ) - { - LL_WARNS("Upload") << dumpResponse() << LL_ENDL; - onApplicationLevelError(content[_ERROR]); - return; - } - - std::string state = content[_STATE]; - LLAssetType::EType asset_type = mImpl->getAssetType(); - - if ( _COMPLETE == state ) - { - // rename file in VFS with new asset id - if (mImpl->getFilename().empty()) - { - // rename the file in the VFS to the actual asset id - // LL_INFOS() << "Changing uploaded asset UUID to " << content["new_asset"].asUUID() << LL_ENDL; - gVFS->renameFile( - mImpl->getVFileID(), - asset_type, - content["new_asset"].asUUID(), - asset_type); - } - - on_new_single_inventory_upload_complete( - asset_type, - mImpl->getInventoryType(), - mImpl->getInventoryTypeString(), - mImpl->getFolderID(), - mImpl->getItemName(), - mImpl->getItemDescription(), - content, - content[_UPLOAD_PRICE].asInteger()); - - // TODO* Add bulk (serial) uploading or add - // a super class of this that does so - } - else if ( _CONFIRM_UPLOAD == state ) - { - showConfirmationDialog( - content[_UPLOAD_PRICE].asInteger(), - content[_RESOURCE_COST].asInteger(), - content[_RSVP].asString()); - } - else - { - LL_WARNS("Upload") << dumpResponse() << LL_ENDL; - onApplicationLevelError(""); - } -} - -void LLNewAgentInventoryVariablePriceResponder::onApplicationLevelError( - const LLSD& error) -{ - mImpl->onApplicationLevelError(error); -} - -void LLNewAgentInventoryVariablePriceResponder::showConfirmationDialog( - S32 upload_price, - S32 resource_cost, - const std::string& confirmation_url) -{ - if ( 0 == upload_price ) - { - // don't show confirmation dialog for free uploads, I mean, - // they're free! - - // The creating of a new instrusive_ptr(this) - // creates a new boost::intrusive_ptr - // which is a copy of this. This code is required because - // 'this' is always of type Class* and not the intrusive_ptr, - // and thus, a reference to 'this' is not registered - // by using just plain 'this'. - - // Since LLNewAgentInventoryVariablePriceResponder is a - // reference counted class, it is possible (since the - // reference to a plain 'this' would be missed here) that, - // when using plain ol' 'this', that this object - // would be deleted before the callback is triggered - // and cause sadness. - mImpl->confirmUpload( - confirmation_url, - LLPointer(this)); - } - else - { - LLSD substitutions; - LLSD payload; - - substitutions["PRICE"] = upload_price; - - payload["confirmation_url"] = confirmation_url; - - // The creating of a new instrusive_ptr(this) - // creates a new boost::intrusive_ptr - // which is a copy of this. This code is required because - // 'this' is always of type Class* and not the intrusive_ptr, - // and thus, a reference to 'this' is not registered - // by using just plain 'this'. - - // Since LLNewAgentInventoryVariablePriceResponder is a - // reference counted class, it is possible (since the - // reference to a plain 'this' would be missed here) that, - // when using plain ol' 'this', that this object - // would be deleted before the callback is triggered - // and cause sadness. - LLNotificationsUtil::add( - "UploadCostConfirmation", - substitutions, - payload, - boost::bind( - &LLNewAgentInventoryVariablePriceResponder::Impl::uploadConfirmationCallback, - mImpl, - _1, - _2, - LLPointer(this))); - } -} -#endif - diff --git a/indra/newview/llassetuploadresponders.h b/indra/newview/llassetuploadresponders.h deleted file mode 100755 index d3457ce450..0000000000 --- a/indra/newview/llassetuploadresponders.h +++ /dev/null @@ -1,158 +0,0 @@ -/** - * @file llassetuploadresponders.h - * @brief Processes responses received for asset upload requests. - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifndef LL_LLASSETUPLOADRESPONDER_H -#define LL_LLASSETUPLOADRESPONDER_H - -#include "llhttpclient.h" - -// Abstract class for supporting asset upload -// via capabilities -class LLAssetUploadResponder : public LLHTTPClient::Responder -{ -protected: - LOG_CLASS(LLAssetUploadResponder); -public: - LLAssetUploadResponder(const LLSD& post_data, - const LLUUID& vfile_id, - LLAssetType::EType asset_type); - LLAssetUploadResponder(const LLSD& post_data, - const std::string& file_name, - LLAssetType::EType asset_type); - ~LLAssetUploadResponder(); - -protected: - virtual void httpFailure(); - virtual void httpSuccess(); - -public: - virtual void uploadUpload(const LLSD& content); - virtual void uploadComplete(const LLSD& content); - virtual void uploadFailure(const LLSD& content); - -protected: - LLSD mPostData; - LLAssetType::EType mAssetType; - LLUUID mVFileID; - std::string mFileName; -}; - -#if 0 -// TODO*: Remove this once deprecated -class LLNewAgentInventoryResponder : public LLAssetUploadResponder -{ - LOG_CLASS(LLNewAgentInventoryResponder); -public: - LLNewAgentInventoryResponder( - const LLSD& post_data, - const LLUUID& vfile_id, - LLAssetType::EType asset_type); - LLNewAgentInventoryResponder( - const LLSD& post_data, - const std::string& file_name, - LLAssetType::EType asset_type); - virtual void uploadComplete(const LLSD& content); - virtual void uploadFailure(const LLSD& content); -protected: - virtual void httpFailure(); -}; -#endif -#if 0 -// A base class which goes through and performs some default -// actions for variable price uploads. If more specific actions -// are needed (such as different confirmation messages, etc.) -// the functions onApplicationLevelError and showConfirmationDialog. -class LLNewAgentInventoryVariablePriceResponder : - public LLHTTPClient::Responder -{ - LOG_CLASS(LLNewAgentInventoryVariablePriceResponder); -public: - LLNewAgentInventoryVariablePriceResponder( - const LLUUID& vfile_id, - LLAssetType::EType asset_type, - const LLSD& inventory_info); - - LLNewAgentInventoryVariablePriceResponder( - const std::string& file_name, - LLAssetType::EType asset_type, - const LLSD& inventory_info); - virtual ~LLNewAgentInventoryVariablePriceResponder(); - -private: - /* virtual */ void httpFailure(); - /* virtual */ void httpSuccess(); - -public: - virtual void onApplicationLevelError( - const LLSD& error); - virtual void showConfirmationDialog( - S32 upload_price, - S32 resource_cost, - const std::string& confirmation_url); - -private: - class Impl; - Impl* mImpl; -}; -#endif - -#if 0 -class LLUpdateAgentInventoryResponder : public LLAssetUploadResponder -{ -public: - LLUpdateAgentInventoryResponder(const LLSD& post_data, - const LLUUID& vfile_id, - LLAssetType::EType asset_type); - LLUpdateAgentInventoryResponder(const LLSD& post_data, - const std::string& file_name, - LLAssetType::EType asset_type); - virtual void uploadComplete(const LLSD& content); -}; -#endif - -#if 0 -class LLUpdateTaskInventoryResponder : public LLAssetUploadResponder -{ -public: - LLUpdateTaskInventoryResponder(const LLSD& post_data, - const LLUUID& vfile_id, - LLAssetType::EType asset_type); - LLUpdateTaskInventoryResponder(const LLSD& post_data, - const std::string& file_name, - LLAssetType::EType asset_type); - LLUpdateTaskInventoryResponder(const LLSD& post_data, - const std::string& file_name, - const LLUUID& queue_id, - LLAssetType::EType asset_type); - - virtual void uploadComplete(const LLSD& content); - -private: - LLUUID mQueueId; -}; -#endif - -#endif // LL_LLASSETUPLOADRESPONDER_H diff --git a/indra/newview/llcompilequeue.cpp b/indra/newview/llcompilequeue.cpp index c4b0b96d4c..24e662ee50 100755 --- a/indra/newview/llcompilequeue.cpp +++ b/indra/newview/llcompilequeue.cpp @@ -37,7 +37,6 @@ #include "llcompilequeue.h" #include "llagent.h" -#include "llassetuploadresponders.h" #include "llchat.h" #include "llfloaterreg.h" #include "llviewerwindow.h" diff --git a/indra/newview/llfloaterreporter.cpp b/indra/newview/llfloaterreporter.cpp index b38362e180..d8f5f27681 100755 --- a/indra/newview/llfloaterreporter.cpp +++ b/indra/newview/llfloaterreporter.cpp @@ -77,7 +77,6 @@ #include "lluictrlfactory.h" #include "llviewernetwork.h" -#include "llassetuploadresponders.h" #include "llagentui.h" #include "lltrans.h" diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp index d6aaf18cb7..c34d04c98e 100755 --- a/indra/newview/llmeshrepository.cpp +++ b/indra/newview/llmeshrepository.cpp @@ -72,6 +72,10 @@ #include "bufferstream.h" #include "llfasttimer.h" #include "llcorehttputil.h" +#include "llstatusbar.h" +#include "llinventorypanel.h" +#include "lluploaddialog.h" +#include "llfloaterreg.h" #include "boost/lexical_cast.hpp" @@ -412,6 +416,17 @@ static unsigned int metrics_teleport_start_count = 0; boost::signals2::connection metrics_teleport_started_signal; static void teleport_started(); +void on_new_single_inventory_upload_complete( + LLAssetType::EType asset_type, + LLInventoryType::EType inventory_type, + const std::string inventory_type_string, + const LLUUID& item_folder_id, + const std::string& item_name, + const std::string& item_description, + const LLSD& server_response, + S32 upload_price); + + //get the number of bytes resident in memory for given volume U32 get_volume_memory_size(const LLVolume* volume) { @@ -4567,3 +4582,122 @@ void teleport_started() LLMeshRepository::metricsStart(); } + +void on_new_single_inventory_upload_complete( + LLAssetType::EType asset_type, + LLInventoryType::EType inventory_type, + const std::string inventory_type_string, + const LLUUID& item_folder_id, + const std::string& item_name, + const std::string& item_description, + const LLSD& server_response, + S32 upload_price) +{ + bool success = false; + + if (upload_price > 0) + { + // this upload costed us L$, update our balance + // and display something saying that it cost L$ + LLStatusBar::sendMoneyBalanceRequest(); + + LLSD args; + args["AMOUNT"] = llformat("%d", upload_price); + LLNotificationsUtil::add("UploadPayment", args); + } + + if (item_folder_id.notNull()) + { + U32 everyone_perms = PERM_NONE; + U32 group_perms = PERM_NONE; + U32 next_owner_perms = PERM_ALL; + if (server_response.has("new_next_owner_mask")) + { + // The server provided creation perms so use them. + // Do not assume we got the perms we asked for in + // since the server may not have granted them all. + everyone_perms = server_response["new_everyone_mask"].asInteger(); + group_perms = server_response["new_group_mask"].asInteger(); + next_owner_perms = server_response["new_next_owner_mask"].asInteger(); + } + else + { + // The server doesn't provide creation perms + // so use old assumption-based perms. + if (inventory_type_string != "snapshot") + { + next_owner_perms = PERM_MOVE | PERM_TRANSFER; + } + } + + LLPermissions new_perms; + new_perms.init( + gAgent.getID(), + gAgent.getID(), + LLUUID::null, + LLUUID::null); + + new_perms.initMasks( + PERM_ALL, + PERM_ALL, + everyone_perms, + group_perms, + next_owner_perms); + + U32 inventory_item_flags = 0; + if (server_response.has("inventory_flags")) + { + inventory_item_flags = (U32)server_response["inventory_flags"].asInteger(); + if (inventory_item_flags != 0) + { + LL_INFOS() << "inventory_item_flags " << inventory_item_flags << LL_ENDL; + } + } + S32 creation_date_now = time_corrected(); + LLPointer item = new LLViewerInventoryItem( + server_response["new_inventory_item"].asUUID(), + item_folder_id, + new_perms, + server_response["new_asset"].asUUID(), + asset_type, + inventory_type, + item_name, + item_description, + LLSaleInfo::DEFAULT, + inventory_item_flags, + creation_date_now); + + gInventory.updateItem(item); + gInventory.notifyObservers(); + success = true; + + // Show the preview panel for textures and sounds to let + // user know that the image (or snapshot) arrived intact. + LLInventoryPanel* panel = LLInventoryPanel::getActiveInventoryPanel(); + if (panel) + { + LLFocusableElement* focus = gFocusMgr.getKeyboardFocus(); + + panel->setSelection( + server_response["new_inventory_item"].asUUID(), + TAKE_FOCUS_NO); + + // restore keyboard focus + gFocusMgr.setKeyboardFocus(focus); + } + } + else + { + LL_WARNS() << "Can't find a folder to put it in" << LL_ENDL; + } + + // remove the "Uploading..." message + LLUploadDialog::modalUploadFinished(); + + // Let the Snapshot floater know we have finished uploading a snapshot to inventory. + LLFloater* floater_snapshot = LLFloaterReg::findInstance("snapshot"); + if (asset_type == LLAssetType::AT_TEXTURE && floater_snapshot) + { + floater_snapshot->notify(LLSD().with("set-finished", LLSD().with("ok", success).with("msg", "inventory"))); + } +} diff --git a/indra/newview/llpostcard.cpp b/indra/newview/llpostcard.cpp index 4e34ec912e..2e639b56eb 100755 --- a/indra/newview/llpostcard.cpp +++ b/indra/newview/llpostcard.cpp @@ -36,7 +36,6 @@ #include "llagent.h" #include "llassetstorage.h" -#include "llassetuploadresponders.h" #include "llviewerassetupload.h" /////////////////////////////////////////////////////////////////////////////// diff --git a/indra/newview/llpreviewgesture.cpp b/indra/newview/llpreviewgesture.cpp index 2604eb1840..ff9a70d05c 100755 --- a/indra/newview/llpreviewgesture.cpp +++ b/indra/newview/llpreviewgesture.cpp @@ -31,7 +31,6 @@ #include "llanimstatelabels.h" #include "llanimationstates.h" #include "llappviewer.h" // gVFS -#include "llassetuploadresponders.h" #include "llcheckboxctrl.h" #include "llcombobox.h" #include "lldatapacker.h" diff --git a/indra/newview/llpreviewnotecard.cpp b/indra/newview/llpreviewnotecard.cpp index 9273e06d65..2c609d902c 100755 --- a/indra/newview/llpreviewnotecard.cpp +++ b/indra/newview/llpreviewnotecard.cpp @@ -31,7 +31,6 @@ #include "llinventory.h" #include "llagent.h" -#include "llassetuploadresponders.h" #include "lldraghandle.h" #include "llviewerwindow.h" #include "llbutton.h" diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index 2f09214dd6..11a503e71f 100755 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -29,7 +29,6 @@ #include "llpreviewscript.h" #include "llassetstorage.h" -#include "llassetuploadresponders.h" #include "llbutton.h" #include "llcheckboxctrl.h" #include "llcombobox.h" diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index 904fa7fcbe..782a27a846 100755 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -65,7 +65,6 @@ #include "llviewerassetupload.h" // linden libraries -#include "llassetuploadresponders.h" #include "lleconomy.h" #include "llhttpclient.h" #include "llnotificationsutil.h" diff --git a/indra/newview/llviewermenufile.h b/indra/newview/llviewermenufile.h index 0f8fa56b52..6941b4dc0e 100755 --- a/indra/newview/llviewermenufile.h +++ b/indra/newview/llviewermenufile.h @@ -70,16 +70,6 @@ void assign_defaults_and_show_upload_message( const std::string& display_name, std::string& description); -void on_new_single_inventory_upload_complete( - LLAssetType::EType asset_type, - LLInventoryType::EType inventory_type, - const std::string inventory_type_string, - const LLUUID& item_folder_id, - const std::string& item_name, - const std::string& item_description, - const LLSD& server_response, - S32 upload_price); - class LLFilePickerThread : public LLThread { //multi-threaded file picker (runs system specific file picker in background and calls "notify" from main thread) public: -- cgit v1.2.3 From b57b0d97bb2fb880084cbcca1b915f8e67b442a5 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 28 Jul 2015 15:29:51 -0700 Subject: Named pools of coroutines. --- indra/newview/app_settings/settings.xml | 18 ++ indra/newview/llcoproceduremanager.cpp | 288 ++++++++++++++++++++++++++++---- indra/newview/llcoproceduremanager.h | 56 ++----- indra/newview/llviewerassetupload.cpp | 3 +- 4 files changed, 291 insertions(+), 74 deletions(-) (limited to 'indra') diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 2180a7f1a1..b4a4e41884 100755 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -14340,6 +14340,24 @@ Value 1 + PoolSizeAIS + + Comment + Coroutine Pool size for AIS + Type + U32 + Value + 25 + + PoolSizeUpload + + Comment + Coroutine Pool size for Upload + Type + U32 + Value + 1 +