diff options
| author | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2021-05-06 21:57:46 +0300 | 
|---|---|---|
| committer | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2021-05-06 21:57:46 +0300 | 
| commit | cb42bc2823931b84ce079423a471a332dc332b0c (patch) | |
| tree | 357fa813f6cd435ed85d97b727fd3d0f2266154c /indra | |
| parent | cfb6ca569b2c834520ce50564e857dfc06831675 (diff) | |
SL-15168 Viewer side functionality for guidebook window opening #2
Diffstat (limited to 'indra')
| -rw-r--r-- | indra/llui/llfloaterreg.cpp | 6 | ||||
| -rw-r--r-- | indra/llui/llfloaterreg.h | 1 | ||||
| -rw-r--r-- | indra/newview/llfloaterhowto.cpp | 17 | ||||
| -rw-r--r-- | indra/newview/llfloaterhowto.h | 3 | ||||
| -rw-r--r-- | indra/newview/llurlfloaterdispatchhandler.cpp | 80 | ||||
| -rw-r--r-- | indra/newview/llurlfloaterdispatchhandler.h | 3 | 
6 files changed, 96 insertions, 14 deletions
| diff --git a/indra/llui/llfloaterreg.cpp b/indra/llui/llfloaterreg.cpp index 7c0933f554..36a0cb0fd0 100644 --- a/indra/llui/llfloaterreg.cpp +++ b/indra/llui/llfloaterreg.cpp @@ -58,6 +58,12 @@ void LLFloaterReg::add(const std::string& name, const std::string& filename, con  }  //static +bool LLFloaterReg::isRegistered(const std::string& name) +{ +    return sBuildMap.find(name) != sBuildMap.end(); +} + +//static  LLFloater* LLFloaterReg::getLastFloaterInGroup(const std::string& name)  {  	const std::string& groupname = sGroupMap[name]; diff --git a/indra/llui/llfloaterreg.h b/indra/llui/llfloaterreg.h index e3b17dcb4f..a457a15673 100644 --- a/indra/llui/llfloaterreg.h +++ b/indra/llui/llfloaterreg.h @@ -85,6 +85,7 @@ public:  	static void add(const std::string& name, const std::string& file, const LLFloaterBuildFunc& func,  					const std::string& groupname = LLStringUtil::null); +	static bool isRegistered(const std::string& name);  	// Helpers  	static LLFloater* getLastFloaterInGroup(const std::string& name); diff --git a/indra/newview/llfloaterhowto.cpp b/indra/newview/llfloaterhowto.cpp index 9db733db25..ef40060807 100644 --- a/indra/newview/llfloaterhowto.cpp +++ b/indra/newview/llfloaterhowto.cpp @@ -61,13 +61,16 @@ void LLFloaterHowTo::onOpen(const LLSD& key)      LLFloaterWebContent::onOpen(p); -    // Elements from LLFloaterWebContent did not pick up restored size (save_rect) of LLFloaterHowTo -    // set the stack size and position (alternative to preferred_media_size) -    LLLayoutStack *stack = getChild<LLLayoutStack>("stack1"); -    LLRect stack_rect = stack->getRect(); -    stack->reshape(STACK_WIDTH, STACK_HEIGHT); -    stack->setOrigin(stack_rect.mLeft, stack_rect.mTop - STACK_HEIGHT); -    stack->updateLayout(); +    if (p.preferred_media_size().isEmpty()) +    { +        // Elements from LLFloaterWebContent did not pick up restored size (save_rect) of LLFloaterHowTo +        // set the stack size and position (alternative to preferred_media_size) +        LLLayoutStack *stack = getChild<LLLayoutStack>("stack1"); +        LLRect stack_rect = stack->getRect(); +        stack->reshape(STACK_WIDTH, STACK_HEIGHT); +        stack->setOrigin(stack_rect.mLeft, stack_rect.mTop - STACK_HEIGHT); +        stack->updateLayout(); +    }  }  LLFloaterHowTo* LLFloaterHowTo::getInstance() diff --git a/indra/newview/llfloaterhowto.h b/indra/newview/llfloaterhowto.h index e08d102e2a..15fc43335a 100644 --- a/indra/newview/llfloaterhowto.h +++ b/indra/newview/llfloaterhowto.h @@ -36,6 +36,9 @@ class LLFloaterHowTo :      public LLFloaterWebContent  {  public: +    LOG_CLASS(LLFloaterHowTo); + +    typedef LLFloaterWebContent::Params Params;      LLFloaterHowTo(const Params& key); diff --git a/indra/newview/llurlfloaterdispatchhandler.cpp b/indra/newview/llurlfloaterdispatchhandler.cpp index 7f9929041d..1a5da79a74 100644 --- a/indra/newview/llurlfloaterdispatchhandler.cpp +++ b/indra/newview/llurlfloaterdispatchhandler.cpp @@ -29,6 +29,7 @@  #include "llurlfloaterdispatchhandler.h"  #include "llfloaterreg.h" +#include "llfloaterhowto.h"  #include "llfloaterwebcontent.h"  #include "llsdserialize.h"  #include "llviewercontrol.h" @@ -36,11 +37,14 @@  #include "llweb.h"  // values specified by server side's dispatcher +// for llopenfloater  const std::string MESSAGE_URL_FLOATER("URLFloater"); -const std::string KEY_ACTION("OpenURL"); -const std::string KEY_PARAMS("floater_params"); +const std::string KEY_ACTION("action"); // "action" will be the string constant "OpenURL" +const std::string VALUE_OPEN_URL("OpenURL"); +const std::string KEY_DATA("action_data");  const std::string KEY_FLOATER("floater_title");  const std::string KEY_URL("floater_url"); +const std::string KEY_PARAMS("floater_params");  LLUrlFloaterDispatchHandler LLUrlFloaterDispatchHandler::sUrlDispatchhandler; @@ -75,26 +79,75 @@ bool LLUrlFloaterDispatchHandler::operator()(const LLDispatcher *, const std::st          if (!LLSDSerialize::deserialize(message, llsdData, llsdRaw.length()))          {              LL_WARNS("URLFloater") << "Attempted to read parameter data into LLSD but failed:" << llsdRaw << LL_ENDL; +            return false; +        } +    } + +    std::string floater; +    LLSD command_params; +    std::string url; + +    if (message.has(KEY_ACTION) && message[KEY_ACTION].asString() == VALUE_OPEN_URL) +    { +        LLSD &action_data = message[KEY_DATA]; +        if (action_data.isMap()) +        { +            floater = action_data[KEY_FLOATER]; +            command_params = action_data[KEY_PARAMS]; +            url = action_data[KEY_URL];          }      } +    else if (message.has(KEY_FLOATER)) +    { +        floater = message[KEY_FLOATER]; +        command_params = message[KEY_PARAMS]; +        url = message[KEY_URL]; +    } +    else +    { +        LL_WARNS("URLFloater") << "Received " << MESSAGE_URL_FLOATER << " with unexpected data format: " << message << LL_ENDL; +        return false; +    } -    std::string floater = message[KEY_FLOATER]; -    LLSD &command_params = message[KEY_PARAMS]; +    if (url.find("://") == std::string::npos) +    { +        // try unescaping +        url = LLURI::unescape(url); +    }      LLFloaterWebContent::Params params; -    params.url = message[KEY_URL]; +    params.url = url;      if (floater == "guidebook" || floater == "how_to")      {          if (command_params.isMap()) // by default is undefines          {              params.trusted_content = command_params.has("trusted_content") ? command_params["trusted_content"] : false; + +            // Script's side argument list can't include other lists, neither +            // there is a LLRect type, so expect just width and height +            if (command_params.has("width") && command_params.has("height")) +            { +                LLRect rect(0, command_params["height"].asInteger(), command_params["width"].asInteger(), 0); +                params.preferred_media_size.setValue(rect); +            }          } + +        // Some locations will have customized guidebook, which this function easists for +        // only one instance of guidebook can exist at a time, so if this command arrives, +        // we need to close previous guidebook then reopen it. + +        LLFloater* instance = LLFloaterReg::findInstance("how_to"); +        if (instance) +        { +            instance->closeHostedFloater(); +        } +          LLFloaterReg::toggleInstanceOrBringToFront("how_to", params);      } -    else if (!params.url.getValue().empty()) +    else if (floater == "web_content")      { -        if (command_params.isMap()) // by default is undefines +        if (command_params.isMap()) // by default is undefines, might be better idea to init params from command_params          {              params.trusted_content = command_params.has("trusted_content") ? command_params["trusted_content"] : false;              params.show_page_title = command_params.has("show_page_title") ? command_params["show_page_title"] : true; @@ -102,6 +155,19 @@ bool LLUrlFloaterDispatchHandler::operator()(const LLDispatcher *, const std::st          }          LLFloaterReg::showInstance("web_content", params);      } +    else +    { +        if (LLFloaterReg::isRegistered(floater)) +        { +            // A valid floater +            LL_INFOS("URLFloater") << "Floater " << floater << " is not supported by llopenfloater or URLFloater" << LL_ENDL; +        } +        else +        { +            // A valid message, but no such flaoter +            LL_WARNS("URLFloater") << "Recieved a command to open unknown floater: " << floater << LL_ENDL; +        } +    }      return true;  } diff --git a/indra/newview/llurlfloaterdispatchhandler.h b/indra/newview/llurlfloaterdispatchhandler.h index 469f76b007..1dff52c66f 100644 --- a/indra/newview/llurlfloaterdispatchhandler.h +++ b/indra/newview/llurlfloaterdispatchhandler.h @@ -32,8 +32,11 @@  class LLUrlFloaterDispatchHandler : public LLDispatchHandler  {  public: +    LOG_CLASS(LLUrlFloaterDispatchHandler); +      LLUrlFloaterDispatchHandler();      virtual ~LLUrlFloaterDispatchHandler(); +      virtual bool operator()(const LLDispatcher *, const std::string& key, const LLUUID& invoice, const sparam_t& strings) override;      static void registerInDispatcher(); | 
