diff options
author | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2021-05-06 00:46:14 +0300 |
---|---|---|
committer | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2021-05-06 02:46:42 +0300 |
commit | cfb6ca569b2c834520ce50564e857dfc06831675 (patch) | |
tree | 5f86ac994351c0f1873dba3d663eea1effa958db /indra/newview | |
parent | 9874d65e54c21db38efe65dfbb9c52f7c9971488 (diff) |
SL-15168 Viewer side functionality for guidebook window opening
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/CMakeLists.txt | 2 | ||||
-rw-r--r-- | indra/newview/llappviewer.cpp | 2 | ||||
-rw-r--r-- | indra/newview/llenvironment.cpp | 2 | ||||
-rw-r--r-- | indra/newview/llfloaterhowto.cpp | 7 | ||||
-rw-r--r-- | indra/newview/llstartup.cpp | 2 | ||||
-rw-r--r-- | indra/newview/llurlfloaterdispatchhandler.cpp | 107 | ||||
-rw-r--r-- | indra/newview/llurlfloaterdispatchhandler.h | 46 |
7 files changed, 163 insertions, 5 deletions
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 82dcd402be..e8e5b83957 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -638,6 +638,7 @@ set(viewer_SOURCE_FILES llurl.cpp llurldispatcher.cpp llurldispatcherlistener.cpp + llurlfloaterdispatchhandler.cpp llurlhistory.cpp llurllineeditorctrl.cpp llurlwhitelist.cpp @@ -1269,6 +1270,7 @@ set(viewer_HEADER_FILES llurl.h llurldispatcher.h llurldispatcherlistener.h + llurlfloaterdispatchhandler.h llurlhistory.h llurllineeditorctrl.h llurlwhitelist.h diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 0b2cdff36c..9d03edc060 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -59,6 +59,7 @@ #include "llslurl.h" #include "llstartup.h" #include "llfocusmgr.h" +#include "llurlfloaterdispatchhandler.h" #include "llviewerjoystick.h" #include "llallocator.h" #include "llcalc.h" @@ -917,6 +918,7 @@ bool LLAppViewer::init() // Load translations for tooltips LLFloater::initClass(); + LLUrlFloaterDispatchHandler::registerInDispatcher(); ///////////////////////////////////////////////// diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 90d22c57b0..190051d763 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -327,7 +327,7 @@ namespace std::istringstream llsdData(llsdRaw); if (!LLSDSerialize::deserialize(message, llsdData, llsdRaw.length())) { - LL_WARNS() << "LLExperienceLogDispatchHandler: Attempted to read parameter data into LLSD but failed:" << llsdRaw << LL_ENDL; + LL_WARNS() << "LLEnvironmentPushDispatchHandler: Attempted to read parameter data into LLSD but failed:" << llsdRaw << LL_ENDL; } } diff --git a/indra/newview/llfloaterhowto.cpp b/indra/newview/llfloaterhowto.cpp index 665955c946..9db733db25 100644 --- a/indra/newview/llfloaterhowto.cpp +++ b/indra/newview/llfloaterhowto.cpp @@ -52,8 +52,11 @@ BOOL LLFloaterHowTo::postBuild() void LLFloaterHowTo::onOpen(const LLSD& key) { LLFloaterWebContent::Params p(key); - std::string url = gSavedSettings.getString("GuidebookURL"); - p.url = LLWeb::expandURLSubstitutions(url, LLSD()); + if (!p.url.isProvided() || p.url.getValue().empty()) + { + std::string url = gSavedSettings.getString("GuidebookURL"); + p.url = LLWeb::expandURLSubstitutions(url, LLSD()); + } p.show_chrome = false; LLFloaterWebContent::onOpen(p); diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 0ea5de8d67..55048b03be 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -1905,8 +1905,6 @@ bool idle_startup() // Set the show start location to true, now that the user has logged // on with this install. gSavedSettings.setBOOL("ShowStartLocation", TRUE); - - LLFloaterReg::toggleInstanceOrBringToFront("how_to"); } display_startup(); diff --git a/indra/newview/llurlfloaterdispatchhandler.cpp b/indra/newview/llurlfloaterdispatchhandler.cpp new file mode 100644 index 0000000000..7f9929041d --- /dev/null +++ b/indra/newview/llurlfloaterdispatchhandler.cpp @@ -0,0 +1,107 @@ +/** + * @file llurlfloaterdispatchhandler.cpp + * @brief Handles URLFloater generic message from server + * + * $LicenseInfo:firstyear=2021&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2021, 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 "llurlfloaterdispatchhandler.h" + +#include "llfloaterreg.h" +#include "llfloaterwebcontent.h" +#include "llsdserialize.h" +#include "llviewercontrol.h" +#include "llviewergenericmessage.h" +#include "llweb.h" + +// values specified by server side's dispatcher +const std::string MESSAGE_URL_FLOATER("URLFloater"); +const std::string KEY_ACTION("OpenURL"); +const std::string KEY_PARAMS("floater_params"); +const std::string KEY_FLOATER("floater_title"); +const std::string KEY_URL("floater_url"); + +LLUrlFloaterDispatchHandler LLUrlFloaterDispatchHandler::sUrlDispatchhandler; + +LLUrlFloaterDispatchHandler::LLUrlFloaterDispatchHandler() +{ +} + +LLUrlFloaterDispatchHandler::~LLUrlFloaterDispatchHandler() +{ +} + +void LLUrlFloaterDispatchHandler::registerInDispatcher() +{ + if (!gGenericDispatcher.isHandlerPresent(MESSAGE_URL_FLOATER)) + { + gGenericDispatcher.addHandler(MESSAGE_URL_FLOATER, &sUrlDispatchhandler); + } +} + +//virtual +bool LLUrlFloaterDispatchHandler::operator()(const LLDispatcher *, const std::string& key, const LLUUID& invoice, const sparam_t& strings) +{ + // invoice - transaction id + + LLSD message; + sparam_t::const_iterator it = strings.begin(); + + if (it != strings.end()) + { + const std::string& llsdRaw = *it++; + std::istringstream llsdData(llsdRaw); + if (!LLSDSerialize::deserialize(message, llsdData, llsdRaw.length())) + { + LL_WARNS("URLFloater") << "Attempted to read parameter data into LLSD but failed:" << llsdRaw << LL_ENDL; + } + } + + std::string floater = message[KEY_FLOATER]; + LLSD &command_params = message[KEY_PARAMS]; + + LLFloaterWebContent::Params params; + params.url = message[KEY_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; + } + LLFloaterReg::toggleInstanceOrBringToFront("how_to", params); + } + else if (!params.url.getValue().empty()) + { + if (command_params.isMap()) // by default is undefines + { + 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; + params.allow_address_entry = command_params.has("allow_address_entry") ? command_params["allow_address_entry"] : true; + } + LLFloaterReg::showInstance("web_content", params); + } + + return true; +} diff --git a/indra/newview/llurlfloaterdispatchhandler.h b/indra/newview/llurlfloaterdispatchhandler.h new file mode 100644 index 0000000000..469f76b007 --- /dev/null +++ b/indra/newview/llurlfloaterdispatchhandler.h @@ -0,0 +1,46 @@ +/** + * @file llurlfloaterdispatchhandler.h + * @brief Handles URLFloater generic message from server + * + * $LicenseInfo:firstyear=2021&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2021, 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_LLURLFLOATERDISPATCHHANDLER_H +#define LL_LLURLFLOATERDISPATCHHANDLER_H + +#include "lldispatcher.h" + +class LLUrlFloaterDispatchHandler : public LLDispatchHandler +{ +public: + LLUrlFloaterDispatchHandler(); + virtual ~LLUrlFloaterDispatchHandler(); + virtual bool operator()(const LLDispatcher *, const std::string& key, const LLUUID& invoice, const sparam_t& strings) override; + + static void registerInDispatcher(); + +private: + static LLUrlFloaterDispatchHandler sUrlDispatchhandler; +}; + +#endif // LL_LLURLFLOATERDISPATCHHANDLER_H + |