This commit is contained in:
Siana Gearz
2013-11-20 01:11:13 +01:00
19 changed files with 177 additions and 76 deletions

View File

@@ -526,7 +526,7 @@ private:
LLSD mResponse;
protected:
/*virtual*/ LLSD const& getLLSD(void) const { llassert(mFinished && mCode == CURLE_OK && mStatus == HTTP_OK); return mResponse; }
/*virtual*/ LLSD const& getLLSD(void) const { llassert(mFinished && mCode == CURLE_OK); return mResponse; }
/*virtual*/ void completedRaw(U32 status, std::string const& reason, LLChannelDescriptors const& channels, buffer_ptr_t const& buffer)
{
decode_llsd_body(status, reason, channels, buffer, mResponse); // This puts the body asString() in mResponse in case of http error.
@@ -539,7 +539,7 @@ private:
std::string mResponse;
protected:
/*virtual*/ std::string const& getRaw(void) const { llassert(mFinished && mCode == CURLE_OK && mStatus == HTTP_OK); return mResponse; }
/*virtual*/ std::string const& getRaw(void) const { llassert(mFinished && mCode == CURLE_OK); return mResponse; }
/*virtual*/ void completedRaw(U32 status, std::string const& reason, LLChannelDescriptors const& channels, buffer_ptr_t const& buffer)
{
decode_raw_body(mCode, reason, channels, buffer, mResponse);

View File

@@ -16,6 +16,7 @@
#include "lltrans.h"
#include "llviewercontrol.h"
#include "llweb.h"
#include "aialert.h"
// ********************************************************************
// Global Variables
@@ -157,18 +158,32 @@ void HippoGridInfo::setGridNick(std::string gridNick)
}
}
void HippoGridInfo::useHttps()
{
// If the Login URI starts with "http:", replace that with "https:".
if (mLoginUri.substr(0, 5) == "http:")
{
mLoginUri = "https:" + mLoginUri.substr(5);
}
}
void HippoGridInfo::setLoginUri(const std::string& loginUri)
{
std::string uri = loginUri;
mLoginUri = sanitizeUri(uri);
if (utf8str_tolower(LLURI(uri).hostName()) == "login.agni.lindenlab.com")
mLoginUri = sanitizeUri(loginUri);
if (utf8str_tolower(LLURI(mLoginUri).hostName()) == "login.agni.lindenlab.com")
{
mIsInProductionGrid = true;
useHttps();
}
if (utf8str_tolower(LLURI(uri).hostName()) == "login.avination.com" ||
utf8str_tolower(LLURI(uri).hostName()) == "login.avination.net")
if (utf8str_tolower(LLURI(mLoginUri).hostName()) == "login.aditi.lindenlab.com")
{
useHttps();
}
if (utf8str_tolower(LLURI(mLoginUri).hostName()) == "login.avination.com" ||
utf8str_tolower(LLURI(mLoginUri).hostName()) == "login.avination.net")
{
mIsInAvination = true;
useHttps();
}
}
@@ -179,8 +194,7 @@ void HippoGridInfo::setLoginPage(const std::string& loginPage)
void HippoGridInfo::setHelperUri(const std::string& helperUri)
{
std::string uri = helperUri;
mHelperUri = sanitizeUri(uri);
mHelperUri = sanitizeUri(helperUri);
}
void HippoGridInfo::setWebSite(const std::string& website)
@@ -398,15 +412,13 @@ void HippoGridInfo::onXmlCharacterData(void* userData, const XML_Char* s, int le
case XML_LOGINURI:
{
std::string loginuri(s, len);
self->mLoginUri = sanitizeUri( loginuri );
self->setLoginUri(std::string(s, len));
break;
}
case XML_HELPERURI:
{
std::string helperuri(s, len);
self->mHelperUri = sanitizeUri( helperuri );
self->setHelperUri(std::string(s, len));
break;
}
@@ -437,24 +449,45 @@ void HippoGridInfo::onXmlCharacterData(void* userData, const XML_Char* s, int le
}
}
bool HippoGridInfo::retrieveGridInfo()
// Throws AIAlert::ErrorCode with the http status as 'code' (HTTP_OK on XML parse error).
void HippoGridInfo::getGridInfo()
{
if (mLoginUri == "") return false;
// If last character in uri is not "/"
std::string uri = mLoginUri;
if (uri.compare(uri.length()-1, 1, "/") != 0)
if (mLoginUri.empty())
{
uri += '/';
// By passing 0 we automatically get GridInfoErrorInstruction appended.
THROW_ALERTC(0, "GridInfoErrorNoLoginURI");
}
// Make sure the uri ends on a '/'.
std::string uri = mLoginUri;
if (uri.compare(uri.length() - 1, 1, "/") != 0)
{
uri += '/';
}
std::string reply;
int result = LLHTTPClient::blockingGetRaw(uri + "get_grid_info", reply);
if (result != 200) return false;
if (result != HTTP_OK)
{
char const* xml_desc;
switch (result)
{
case HTTP_NOT_FOUND:
xml_desc = "GridInfoErrorNotFound";
break;
case HTTP_METHOD_NOT_ALLOWED:
xml_desc = "GridInfoErrorNotAllowed";
break;
default:
xml_desc = "AIError";
break;
}
// LLHTTPClient::blockingGetRaw puts any error message in the reply.
THROW_ALERTC(result, xml_desc, AIArgs("[ERROR]", reply));
}
llinfos << "Received: " << reply << llendl;
bool success = true;
XML_Parser parser = XML_ParserCreate(0);
XML_SetUserData(parser, this);
XML_SetElementHandler(parser, onXmlElementStart, onXmlElementEnd);
@@ -462,15 +495,11 @@ bool HippoGridInfo::retrieveGridInfo()
mXmlState = XML_VOID;
if (!XML_Parse(parser, reply.data(), reply.size(), TRUE))
{
llwarns << "XML Parse Error: " << XML_ErrorString(XML_GetErrorCode(parser)) << llendl;
success = false;
THROW_ALERTC(HTTP_OK, "GridInfoParseError", AIArgs("[XML_ERROR]", XML_ErrorString(XML_GetErrorCode(parser))));
}
XML_ParserFree(parser);
return success;
}
std::string HippoGridInfo::getUploadFee() const
{
std::string fee;
@@ -558,22 +587,40 @@ const char* HippoGridInfo::getPlatformString(Platform platform)
}
// static
std::string HippoGridInfo::sanitizeUri(std::string &uri)
std::string HippoGridInfo::sanitizeUri(std::string const& uri_in)
{
// if (uri.empty()) {
// return "";
// }
std::string uri = uri_in;
// // If last character in uri is not "/"
// // NOTE: This wrongly assumes that all URIs should end with "/"!
// if (uri.compare(uri.length()-1, 1, "/") != 0) {
// return uri + '/';
// }
// Strip any leading and trailing spaces.
LLStringUtil::trim(uri);
// Only use https when it was entered.
bool use_https = uri.substr(0, 6) == "https:";
// Strip off attempts to use some prefix that is just wrong.
// We accept the following:
// "" (nothing)
// "http:" or "https:", optionally followed by one or more '/'.
std::string::size_type pos = uri.find_first_not_of("htps");
if (pos != std::string::npos && pos < 6 && uri[pos] == ':')
{
do { ++pos; } while(uri[pos] == '/');
uri = uri.substr(pos);
}
// Add (back) the prefix.
if (use_https)
{
uri = "https://" + uri;
}
else
{
uri = "http://" + uri;
}
return uri;
}
void HippoGridInfo::initFallback()
{
FALLBACK_GRIDINFO.setPlatform(PLATFORM_OPENSIM);

View File

@@ -98,7 +98,7 @@ public:
bool getAutoUpdate();
void setAutoUpdate(bool b);
bool retrieveGridInfo();
void getGridInfo();
static const char* getPlatformString(Platform platform);
static std::string sanitizeGridNick(const std::string &gridnick);
@@ -142,7 +142,8 @@ private:
};
XmlState mXmlState;
static std::string sanitizeUri(std::string &uri);
static std::string sanitizeUri(std::string const& uri_in);
void useHttps(void);
void formatFee(std::string &fee, int cost, bool showFree) const;
static void onXmlElementStart(void* userData, const XML_Char* name, const XML_Char** atts);

View File

@@ -42,7 +42,7 @@
#include "lluictrlfactory.h"
#include "llviewerwindow.h"
#include "llnotificationsutil.h"
#include "llhttpstatuscodes.h"
// ********************************************************************
@@ -152,7 +152,7 @@ BOOL HippoPanelGridsImpl::postBuild()
childSetCommitCallback("grid_selector", onSelectGrid, this);
childSetCommitCallback("platform", onSelectPlatform, this);
// !!!### server_choice_combo->setFocusLostCallback(onServerComboLostFocus);
reset();
@@ -294,7 +294,7 @@ bool HippoPanelGridsImpl::saveCurGrid()
HippoGridInfo *gridInfo = 0;
gridInfo = gHippoGridManager->getGrid(mCurGrid);
//gridInfo->retrieveGridInfo();
//gridInfo->getGridInfo();
refresh();
std::string gridname = childGetValue("gridname");
@@ -333,9 +333,30 @@ bool HippoPanelGridsImpl::saveCurGrid()
mCurGrid = gridname;
gridInfo = new HippoGridInfo(gridname);
gHippoGridManager->addGrid(gridInfo);
gridInfo->retrieveGridInfo();
try
{
gridInfo->getGridInfo();
}
catch (AIAlert::ErrorCode const& error)
{
if (error.getCode() == HTTP_NOT_FOUND || error.getCode() == HTTP_METHOD_NOT_ALLOWED)
{
// Ignore this error; it might be a user entered entry for a grid that has no get_grid_info support.
llwarns << AIAlert::text(error) << llendl;
}
else if (error.getCode() == HTTP_OK)
{
// XML parse error.
AIAlert::add("GridInfoError", error);
}
else
{
// Append GridInfoErrorInstruction to error message.
AIAlert::add("GridInfoError", AIAlert::Error(AIAlert::Prefix(), AIAlert::not_modal, error, "GridInfoErrorInstruction"));
}
}
}
if (!gridInfo) {
llwarns << "Grid not found, ignoring changes." << llendl;
return true;
@@ -394,7 +415,10 @@ void HippoPanelGridsImpl::retrieveGridInfo()
}
grid->setLoginUri(loginuri);
if (grid->retrieveGridInfo()) {
try
{
grid->getGridInfo();
if (grid->getPlatform() != HippoGridInfo::PLATFORM_OTHER)
getChild<LLComboBox>("platform")->setCurrentByIndex(grid->getPlatform());
if (grid->getGridName() != "") childSetText("gridname", grid->getGridName());
@@ -407,10 +431,20 @@ void HippoPanelGridsImpl::retrieveGridInfo()
if (grid->getPasswordUrl() != "") childSetText("password", grid->getPasswordUrl());
if (grid->getSearchUrl() != "") childSetText("search", grid->getSearchUrl());
if (grid->getGridMessage() != "") childSetText("gridmessage", grid->getGridMessage());
} else {
LLNotificationsUtil::add("GridInfoError");
}
catch(AIAlert::ErrorCode const& error)
{
if (error.getCode() == HTTP_METHOD_NOT_ALLOWED || error.getCode() == HTTP_OK)
{
AIAlert::add("GridInfoError", error);
}
else
{
// Append GridInfoErrorInstruction to error message.
AIAlert::add("GridInfoError", AIAlert::Error(AIAlert::Prefix(), AIAlert::not_modal, error, "GridInfoErrorInstruction"));
}
}
if (cleanupGrid) delete grid;
}
@@ -472,8 +506,10 @@ void HippoPanelGridsImpl::onClickDefault(void *data)
{
HippoPanelGridsImpl *self = (HippoPanelGridsImpl*)data;
if (self->mState == NORMAL) {
self->saveCurGrid();
gHippoGridManager->setDefaultGrid(self->mCurGrid);
if (self->saveCurGrid())
{
gHippoGridManager->setDefaultGrid(self->mCurGrid);
}
self->refresh();
}
}

View File

@@ -1038,8 +1038,10 @@ void LLPanelLogin::onSelectGrid(LLUICtrl *ctrl)
{
HippoGridInfo* info(new HippoGridInfo("")); // Start off with empty grid name, otherwise we don't know what to name
info->setLoginUri(grid);
if (info->retrieveGridInfo()) // There's info from this URI
try
{
info->getGridInfo();
grid = info->getGridName();
if (HippoGridInfo* nick_info = gHippoGridManager->getGrid(info->getGridNick())) // Grid of same nick exists
{
@@ -1051,8 +1053,23 @@ void LLPanelLogin::onSelectGrid(LLUICtrl *ctrl)
gHippoGridManager->addGrid(info); // deletes info if not needed (existing or no name)
}
}
else
catch(AIAlert::ErrorCode const& error)
{
// Inform the user of the problem, but only if something was entered that at least looks like a Login URI.
std::string::size_type pos1 = grid.find('.');
std::string::size_type pos2 = grid.find_last_of(".:");
if (grid.substr(0, 4) == "http" || (pos1 != std::string::npos && pos1 != pos2))
{
if (error.getCode() == HTTP_METHOD_NOT_ALLOWED || error.getCode() == HTTP_OK)
{
AIAlert::add("GridInfoError", error);
}
else
{
// Append GridInfoErrorInstruction to error message.
AIAlert::add("GridInfoError", AIAlert::Error(AIAlert::Prefix(), AIAlert::not_modal, error, "GridInfoErrorInstruction"));
}
}
delete info;
grid = gHippoGridManager->getCurrentGridName();
}

View File

@@ -237,7 +237,7 @@ Um direkt zu kaufen, klicken Sie auf dem betreffenden Land in der Titelleiste au
<button tooltip="Zurücksetzen" name="reset_btn"/>
<button tool_tip="Zurücksetzen" name="reset_btn"/>
<web_browser name="market_browser" trusted_content="true"/>
<string name="loading_text">Wird geladen...</string>

View File

@@ -280,7 +280,7 @@ Um direkt zu kaufen, klicken Sie auf dem betreffenden Land in der Titelleiste au
<button tooltip="Zurücksetzen" name="reset_btn"/>
<button tool_tip="Zurücksetzen" name="reset_btn"/>
<web_browser name="market_browser" trusted_content="true"/>
<string name="loading_text">Wird geladen...</string>

View File

@@ -1860,8 +1860,6 @@ Ein Grid mit dem gleichen Namen existiert bereits.</notification>
<notification name="GridInfoNoLoginUri">Eine Login URI wird ben&#xF6;tigt um die Grid Informationen ab zu rufen.</notification>
<notification name="GridInfoError">Grid Info kann nicht vom Server abgerufen werden.</notification>
<notification name="HelpRenderCompat">Bauten mit erweiterten Hohlr&#xE4;umen oder erweiterten Lochgr&#xF6;&#xDF;en werden auf anderen Viewern oft nicht korrekt gerendert. Bitte lassen Sie diese Option aktivuert, wenn Sie Ihren Bauten auch auf anderen Viewern korrekt anzeigen lassen wollen.</notification>
<notification name="ExportFailed">Fehlende Berechtigung zum Exportieren vom Objekt. Exportieren abgebrochen.</notification>

View File

@@ -9,6 +9,7 @@
<string name="hippo_label_week">week</string>
<string name="TeleportOfferMaturity">[NAME] is offering a TP to [DESTINATION]</string>
<string name="TeleportLureMaturity">[NAME]'s teleport lure is to [DESTINATION]</string>
<string name="GridInfoError">Grid Info kann nicht vom Server abgerufen werden:</string>
<!-- Default Args - these arguments will be replaced in all strings -->
<string name="SECOND_LIFE">Second Life</string>

View File

@@ -626,7 +626,7 @@ To buy direct, visit the land and click on the place name in the title bar.
<button bottom="-30" follows="top|left" height="25" label="" left="10" name="back_btn" width="25" image_overlay="go-previous.png"/>
<button bottom_delta="0" follows="top|left" height="25" label="" left_delta="27" name="forward_btn" width="25" image_overlay="go-next.png" />
<button bottom_delta="0" follows="top|left" height="25" label="" left_delta="27" name="reload_btn" width="25" image_overlay="view-refresh-5.png"/>
<button bottom_delta="0" follows="top|left" height="25" label="" tooltip="reset" left_delta="27" name="reset_btn" width="25" image_overlay="go-reload.png"/>
<button bottom_delta="0" follows="top|left" height="25" label="" tool_tip="reset" left_delta="27" name="reset_btn" width="25" image_overlay="go-reload.png"/>
<web_browser name="market_browser" trusted_content="true" bottom="25" follows="all" left="10" right="-10" top="-40"/>
<text bottom="5" follows="bottom|left" left="10" height="16" name="status_text"/>
<string name="loading_text">Loading...</string>

View File

@@ -749,7 +749,7 @@ To buy direct, visit the land and click on the place name in the title bar.
<button bottom="-30" follows="top|left" height="25" label="" left="10" name="back_btn" width="25" image_overlay="go-previous.png"/>
<button bottom_delta="0" follows="top|left" height="25" label="" left_delta="27" name="forward_btn" width="25" image_overlay="go-next.png" />
<button bottom_delta="0" follows="top|left" height="25" label="" left_delta="27" name="reload_btn" width="25" image_overlay="go-reload.png"/>
<button bottom_delta="0" follows="top|left" height="25" label="" tooltip="reset" left_delta="27" name="reset_btn" width="25" image_overlay="go-home.png"/>
<button bottom_delta="0" follows="top|left" height="25" label="" tool_tip="reset" left_delta="27" name="reset_btn" width="25" image_overlay="go-home.png"/>
<web_browser name="market_browser" trusted_content="true" bottom="25" follows="all" left="10" right="-10" top="-40"/>
<text bottom="5" follows="bottom|left" left="10" height="16" name="status_text"/>
<string name="loading_text">Loading...</string>

View File

@@ -60,7 +60,7 @@ Try saving image as 24 bit Targa (.tga).
<check_box bottom="37" control_name="TemporaryUpload" enabled="true"
follows="bottom|left" font="SansSerifSmall" height="16"
initial_value="false" label="Temporary (Free)"
left_delta="155" name="temp_check" width="280" tooltip="Sets the asset to be temporary, meaning its free, but in return, only good for a short time before it ceases to exist." />
left_delta="155" name="temp_check" width="280" tool_tip="Sets the asset to be temporary, meaning its free, but in return, only good for a short time before it ceases to exist." />
<button bottom="10" follows="bottom|right" height="20" label="Cancel" left="165"
name="cancel_btn" width="125" />
<button bottom="10" follows="bottom|left" height="20" label="Upload ([UPLOADFEE])"

View File

@@ -5801,13 +5801,6 @@ A grid with the same nickname already exists.
A login URI is required to retrieve the grid info.
</notification>
<notification
icon="alertmodal.tga"
name="GridInfoError"
type="alertmodal">
Cannot retrieve grid info from server.
</notification>
<notification
icon="alertmodal.tga"
name="HelpRenderCompat"

View File

@@ -13,6 +13,15 @@
<string name="TeleportLureMaturity">
[NAME]'s teleport lure is to [DESTINATION]
</string>
<string name="GridInfoError">Cannot retrieve grid info from server:</string>
<!-- The following entry starts and ends with a ", this is to allow the newline at the beginning. It also requires to use \" for quotes within. -->
<string name="GridInfoErrorInstruction">"
Make sure you entered the correct Login URI. An example of a Login URI is: \"http://cool.grid.com:8002/\", this url can usually be found on the website of the grid."
</string>
<string name="GridInfoErrorNoLoginURI">A login URI is required to retrieve the Grid Info.</string>
<string name="GridInfoErrorNotFound">404 Page not found</string>
<string name="GridInfoErrorNotAllowed">This grid does not support retrieving 'Grid Info'</string>
<string name="GridInfoParseError">XML Parse Error: [XML_ERROR]</string>
<!-- Default Args - these arguments will be replaced in all strings -->
<string name="SECOND_LIFE">Second Life</string>
@@ -4368,9 +4377,11 @@ Try enclosing path to the editor with double quotes.
<string name="completed_from">Teleport completed from</string>
<!-- AIAlert messages -->
<!-- These two do not need translation ;) -->
<string name="AIError">"\"[ERROR]\""</string>
<string name="AIPrefix">"[PREFIX]: "</string>
<!-- AIFile exception alerts -->
<!-- AIFile exception alerts -->
<string name="AIFile_mkdir_Failed_to_create_DIRNAME">Failed to create folder [DIRNAME]: [ERROR]</string>
<string name="AIFile_rmdir_Failed_to_remove_DIRNAME">Failed to remove folder [DIRNAME]: [ERROR]</string>
<string name="AIFile_fopen_Failed_to_open_FILENAME">Failed to open file "[FILENAME]": [ERROR]</string>

View File

@@ -488,7 +488,7 @@ subasta. Para comprarlo directamente, visítalo y pulsa en el nombre del terreno
<button label="" name="back_btn"/>
<button label="" name="forward_btn"/>
<button label="" name="reload_btn"/>
<button label="" tooltip="restablecer" name="reset_btn"/>
<button label="" tool_tip="restablecer" name="reset_btn"/>
<web_browser name="market_browser"/>
<text name="status_text"/>
<string name="loading_text">Cargando...</string>

View File

@@ -3262,11 +3262,7 @@ Ya existe un grid con el mismo nombre.
<notification name="GridInfoNoLoginUri">
Se requiere un URI de inicio de sesión para recuperar la información del grid.
</notification>
<notification name="GridInfoError">
No se puede recuperar la información del grid desde el servidor.
</notification>
<notification name="HelpRenderCompat">
Las construcciones con huecos extendidos o tamaños de agujeros extendidos no se renderizarán adecuadamente en otros visores. Por favor, mantén esta opción marcada si quieres que tus construcciones se vean adecuadamente in otros visores.
</notification>

View File

@@ -9,6 +9,7 @@
<string name="hippo_label_week">semana</string>
<string name="TeleportOfferMaturity">[NAME] te ofrece un TP a [DESTINATION]</string>
<string name="TeleportLureMaturity">[NAME] te ofrece una invitación de teleporte a [DESTINATION]</string>
<string name="GridInfoError">No se puede recuperar la información del grid desde el servidor:</string>
<!-- Default Args - these arguments will be replaced in all strings -->
<string name="SECOND_LIFE">Second Life</string>

View File

@@ -49,7 +49,7 @@
Sauvegarder en Targa 24 bits (.tga).
</text>
<check_box label="Compression sans perte" name="lossless_check"/>
<check_box label="Temporaire (Gratuit)" name="temp_check" tooltip="chargement gratuit mais qui disparaitra &#xE0; votre de&#xE9;connection."/>
<check_box label="Temporaire (Gratuit)" name="temp_check" tool_tip="chargement gratuit mais qui disparaitra &#xE0; votre de&#xE9;connection."/>
<button label="Annuler" name="cancel_btn"/>
<button label="Charger ([UPLOADFEE])" name="ok_btn"/>
</floater>

View File

@@ -152,7 +152,7 @@
</flyout_button_item>
</flyout_button>
<button label="Annuler" name="discard_btn" left="133" width="72" />
<check_box label="Image Temporaire (Gratuit)" name="temp_check" tooltip="Comme toute image temporaire elle disparaitra à votre deconnection."/>
<check_box label="Image Temporaire (Gratuit)" name="temp_check" tool_tip="Comme toute image temporaire elle disparaitra à votre deconnection."/>
<string name="unknown">
inconnu
</string>