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.
meow-7.2.2
Rider Linden 2015-05-14 15:47:36 -07:00
parent 9ec050a067
commit 21701459ee
8 changed files with 101 additions and 217 deletions

View File

@ -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);
}
}

View File

@ -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

View File

@ -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;
}

View File

@ -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

View File

@ -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<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);
}
}

View File

@ -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)

View File

@ -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;
};

View File

@ -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;
}
}