diff options
| -rw-r--r-- | indra/llmessage/llcorehttputil.cpp | 23 | ||||
| -rwxr-xr-x | indra/newview/CMakeLists.txt | 2 | ||||
| -rwxr-xr-x | indra/newview/llclassifiedstatsresponder.cpp | 72 | ||||
| -rwxr-xr-x | indra/newview/llclassifiedstatsresponder.h | 50 | ||||
| -rwxr-xr-x | indra/newview/llfloaterabout.cpp | 99 | ||||
| -rwxr-xr-x | indra/newview/llpanelclassified.cpp | 41 | ||||
| -rwxr-xr-x | indra/newview/llpanelclassified.h | 5 | ||||
| -rwxr-xr-x | indra/newview/llvoavatarself.cpp | 26 | 
8 files changed, 101 insertions, 217 deletions
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<LLSD::Binary &>( 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" @@ -70,18 +71,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  ///----------------------------------------------------------------------------  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<LLFloaterAbout>("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<LLFloaterAbout>);  } - -///---------------------------------------------------------------------------- -/// 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<LLFloaterAbout>("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<LLPanelClassifiedInfo*> 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;  	}  }  | 
