Skip to content
Snippets Groups Projects
Commit 8eede89c authored by Andrey Kleshchev's avatar Andrey Kleshchev
Browse files

Revert "SL-15168 Changed format"

parent a7fada58
Branches
Tags
No related merge requests found
...@@ -51,12 +51,6 @@ BOOL LLFloaterHowTo::postBuild() ...@@ -51,12 +51,6 @@ BOOL LLFloaterHowTo::postBuild()
void LLFloaterHowTo::onOpen(const LLSD& key) void LLFloaterHowTo::onOpen(const LLSD& key)
{ {
// LLFloaterHowTo is intended to be opened as a location specific guidebook
// with custom titles, reset the title, LLUrlFloaterDispatchHandler will
// set needed one later
// todo: make title into general parameter for LLFloaterWebContent
setTitle(getString("default_tittle"));
LLFloaterWebContent::Params p(key); LLFloaterWebContent::Params p(key);
if (!p.url.isProvided() || p.url.getValue().empty()) if (!p.url.isProvided() || p.url.getValue().empty())
{ {
......
...@@ -36,30 +36,25 @@ ...@@ -36,30 +36,25 @@
#include "llviewergenericmessage.h" #include "llviewergenericmessage.h"
#include "llweb.h" #include "llweb.h"
#include <boost/regex.hpp>
// Example:
// llOpenFloater("My Help Title", "secondlife://guidebook", []);
// values specified by server side's dispatcher // values specified by server side's dispatcher
// for llopenfloater // for llopenfloater
const std::string MESSAGE_URL_FLOATER("URLFloater"); const std::string MESSAGE_URL_FLOATER("URLFloater");
const std::string KEY_ACTION("action"); // "action" will be the string constant "OpenURL" const std::string KEY_ACTION("action"); // "action" will be the string constant "OpenURL"
const std::string VALUE_OPEN_URL("OpenURL"); const std::string VALUE_OPEN_URL("OpenURL");
const std::string KEY_DATA("action_data"); const std::string KEY_DATA("action_data");
const std::string KEY_FLOATER_TITLE("floater_title"); const std::string KEY_FLOATER("floater_title");
const std::string KEY_URI("floater_url"); const std::string KEY_URL("floater_url");
const std::string KEY_PARAMS("floater_params"); const std::string KEY_PARAMS("floater_params");
// Supported floaters, for now it's exact matching, later it might get extended // Supported floaters
const std::string FLOATER_GUIDEBOOK("guidebook"); // translates to "how_to" const std::string FLOATER_GUIDEBOOK("guidebook"); // alias for how_to
const std::string FLOATER_WEB_CONTENT("browser"); // translates to "web_content" const std::string FLOATER_HOW_TO("how_to");
const std::string FLOATER_WEB_CONTENT("web_content");
// Web content universal arguments // Web content universal argument
const std::string KEY_TRUSTED_CONTENT("trusted_content"); const std::string KEY_TRUSTED_CONTENT("trusted_content");
const std::string KEY_URL("url");
// Guidebook ("how_to") specific arguments // Guidebook specific arguments
const std::string KEY_WIDTH("width"); const std::string KEY_WIDTH("width");
const std::string KEY_HEGHT("height"); const std::string KEY_HEGHT("height");
const std::string KEY_CAN_CLOSE("can_close"); const std::string KEY_CAN_CLOSE("can_close");
...@@ -106,26 +101,25 @@ bool LLUrlFloaterDispatchHandler::operator()(const LLDispatcher *, const std::st ...@@ -106,26 +101,25 @@ bool LLUrlFloaterDispatchHandler::operator()(const LLDispatcher *, const std::st
} }
} }
std::string floater_title; std::string floater;
LLSD command_params; LLSD command_params;
std::string raw_uri; std::string url;
std::string floater_identifier;
if (message.has(KEY_ACTION) && message[KEY_ACTION].asString() == VALUE_OPEN_URL) if (message.has(KEY_ACTION) && message[KEY_ACTION].asString() == VALUE_OPEN_URL)
{ {
LLSD &action_data = message[KEY_DATA]; LLSD &action_data = message[KEY_DATA];
if (action_data.isMap()) if (action_data.isMap())
{ {
floater_title = action_data[KEY_FLOATER_TITLE].asString(); floater = action_data[KEY_FLOATER].asString();
command_params = action_data[KEY_PARAMS]; command_params = action_data[KEY_PARAMS];
raw_uri = action_data[KEY_URI].asString(); url = action_data[KEY_URL].asString();
} }
} }
else if (message.has(KEY_FLOATER_TITLE)) else if (message.has(KEY_FLOATER))
{ {
floater_title = message[KEY_FLOATER_TITLE].asString(); floater = message[KEY_FLOATER].asString();
command_params = message[KEY_PARAMS]; command_params = message[KEY_PARAMS];
raw_uri = message[KEY_URI].asString(); url = message[KEY_URL].asString();
} }
else else
{ {
...@@ -133,48 +127,16 @@ bool LLUrlFloaterDispatchHandler::operator()(const LLDispatcher *, const std::st ...@@ -133,48 +127,16 @@ bool LLUrlFloaterDispatchHandler::operator()(const LLDispatcher *, const std::st
return false; return false;
} }
if (raw_uri.find(":///") == std::string::npos) if (url.find("://") == std::string::npos)
{ {
// try unescaping // try unescaping
raw_uri = LLURI::unescape(raw_uri); url = LLURI::unescape(url);
}
LLURI floater_uri(raw_uri);
if (floater_uri.scheme().empty() || floater_uri.scheme() != "secondlife")
{
LL_WARNS("URLFloater") << "Received " << raw_uri << " with unexpected scheme in uri: " << floater_uri << LL_ENDL;
return false;
}
LLSD path_array = floater_uri.pathArray();
S32 path_parts = path_array.size();
if (path_parts == 0)
{
LL_WARNS("URLFloater") << "received an empty uri: " << floater_uri << LL_ENDL;
return false;
}
floater_identifier = path_array[0];
if (floater_identifier.size() < 3)
{
LL_WARNS("URLFloater") << "received invalid flaoter indentifier: " << floater_identifier << LL_ENDL;
return false;
} }
LLFloaterWebContent::Params params; LLFloaterWebContent::Params params;
if (command_params.isMap()) params.url = url;
{
if (command_params.has(KEY_TRUSTED_CONTENT))
{
params.trusted_content = command_params[KEY_TRUSTED_CONTENT].asBoolean();
}
if (command_params.has(KEY_URL))
{
params.url = command_params[KEY_URL].asString();
}
}
if (floater_identifier == FLOATER_GUIDEBOOK) if (floater == FLOATER_GUIDEBOOK || floater == FLOATER_HOW_TO)
{ {
if (command_params.isMap()) // by default is undefines if (command_params.isMap()) // by default is undefines
{ {
...@@ -201,16 +163,13 @@ bool LLUrlFloaterDispatchHandler::operator()(const LLDispatcher *, const std::st ...@@ -201,16 +163,13 @@ bool LLUrlFloaterDispatchHandler::operator()(const LLDispatcher *, const std::st
LLFloaterReg::toggleInstanceOrBringToFront("how_to", params); LLFloaterReg::toggleInstanceOrBringToFront("how_to", params);
instance = LLFloaterReg::findInstance("how_to");
instance->setTitle(floater_title);
if (command_params.isMap() && command_params.has(KEY_CAN_CLOSE)) if (command_params.isMap() && command_params.has(KEY_CAN_CLOSE))
{ {
LLFloater* instance = LLFloaterReg::findInstance("how_to");
instance->setCanClose(command_params[KEY_CAN_CLOSE].asBoolean()); instance->setCanClose(command_params[KEY_CAN_CLOSE].asBoolean());
} }
} }
else if (floater_identifier == FLOATER_WEB_CONTENT) else if (floater == FLOATER_WEB_CONTENT)
{
if (command_params.has(KEY_URL))
{ {
if (command_params.isMap()) // by default is undefines, might be better idea to init params from command_params if (command_params.isMap()) // by default is undefines, might be better idea to init params from command_params
{ {
...@@ -218,21 +177,19 @@ bool LLUrlFloaterDispatchHandler::operator()(const LLDispatcher *, const std::st ...@@ -218,21 +177,19 @@ bool LLUrlFloaterDispatchHandler::operator()(const LLDispatcher *, const std::st
params.show_page_title = command_params.has(KEY_SHOW_PAGE_TITLE) ? command_params[KEY_SHOW_PAGE_TITLE].asBoolean() : true; params.show_page_title = command_params.has(KEY_SHOW_PAGE_TITLE) ? command_params[KEY_SHOW_PAGE_TITLE].asBoolean() : true;
params.allow_address_entry = command_params.has(KEY_ALLOW_ADRESS_ENTRY) ? command_params[KEY_ALLOW_ADRESS_ENTRY].asBoolean() : true; params.allow_address_entry = command_params.has(KEY_ALLOW_ADRESS_ENTRY) ? command_params[KEY_ALLOW_ADRESS_ENTRY].asBoolean() : true;
} }
LLFloater* instance = LLFloaterReg::showInstance("web_content", params); LLFloaterReg::showInstance("web_content", params);
instance->setTitle(floater_title);
}
} }
else else
{ {
if (LLFloaterReg::isRegistered(floater_identifier)) if (LLFloaterReg::isRegistered(floater))
{ {
// A valid floater // A valid floater
LL_INFOS("URLFloater") << "Floater " << floater_identifier << " is not supported by llopenfloater or URLFloater" << LL_ENDL; LL_INFOS("URLFloater") << "Floater " << floater << " is not supported by llopenfloater or URLFloater" << LL_ENDL;
} }
else else
{ {
// A valid message, but no such flaoter // A valid message, but no such flaoter
LL_WARNS("URLFloater") << "Recieved a command to open unknown floater: " << raw_uri << LL_ENDL; LL_WARNS("URLFloater") << "Recieved a command to open unknown floater: " << floater << LL_ENDL;
} }
} }
......
...@@ -14,9 +14,4 @@ ...@@ -14,9 +14,4 @@
width="310" width="310"
rel_x="-0.469309" rel_x="-0.469309"
rel_y="-0.011166" rel_y="-0.011166"
filename="floater_web_content.xml"> filename="floater_web_content.xml"/>
<floater.string \ No newline at end of file
name="default_tittle">
WELCOME ISLAND GUIDEBOOK
</floater.string>
</floater>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment