summaryrefslogtreecommitdiff
path: root/indra/newview/llurldispatcher.cpp
diff options
context:
space:
mode:
authorAndreyL ProductEngine <alihatskiy@productengine.com>2019-09-10 23:31:51 +0300
committerAndreyL ProductEngine <alihatskiy@productengine.com>2019-09-10 23:31:51 +0300
commit1b66e4673d9779a1c67cfb074bb15c597d1c5779 (patch)
tree1aa96c63f62c9dddec111eee5bb021ced19ea93d /indra/newview/llurldispatcher.cpp
parent7d9b7e93ed0a157320ccc86d65f16e7fdfc8fbf1 (diff)
parente241670694959833feaa0e667222b337095eb683 (diff)
MergeMerged in lindenlab/viewer-release
Diffstat (limited to 'indra/newview/llurldispatcher.cpp')
-rw-r--r--indra/newview/llurldispatcher.cpp51
1 files changed, 48 insertions, 3 deletions
diff --git a/indra/newview/llurldispatcher.cpp b/indra/newview/llurldispatcher.cpp
index 78268944fc..da31e4f542 100644
--- a/indra/newview/llurldispatcher.cpp
+++ b/indra/newview/llurldispatcher.cpp
@@ -47,6 +47,7 @@
// library includes
#include "llnotificationsutil.h"
#include "llsd.h"
+#include "stringize.h"
static LLURLDispatcherListener sURLDispatcherListener;
@@ -255,14 +256,23 @@ void LLURLDispatcherImpl::regionHandleCallback(U64 region_handle, const LLSLURL&
// Teleportation links are handled here because they are tightly coupled
// to SLURL parsing and sim-fragment parsing
-class LLTeleportHandler : public LLCommandHandler
+class LLTeleportHandler : public LLCommandHandler, public LLEventAPI
{
public:
// Teleport requests *must* come from a trusted browser
// inside the app, otherwise a malicious web page could
// cause a constant teleport loop. JC
- LLTeleportHandler() : LLCommandHandler("teleport", UNTRUSTED_THROTTLE) { }
-
+ LLTeleportHandler() :
+ LLCommandHandler("teleport", UNTRUSTED_THROTTLE),
+ LLEventAPI("LLTeleportHandler", "Low-level teleport API")
+ {
+ LLEventAPI::add("teleport",
+ "Teleport to specified [\"regionname\"] at\n"
+ "specified region-relative [\"x\"], [\"y\"], [\"z\"].\n"
+ "If [\"regionname\"] omitted, teleport to GLOBAL\n"
+ "coordinates [\"x\"], [\"y\"], [\"z\"].",
+ &LLTeleportHandler::from_event);
+ }
bool handle(const LLSD& tokens, const LLSD& query_map,
LLMediaCtrl* web)
@@ -293,6 +303,41 @@ public:
return true;
}
+ void from_event(const LLSD& params) const
+ {
+ Response response(LLSD(), params);
+ if (params.has("regionname"))
+ {
+ // region specified, coordinates (if any) are region-local
+ LLVector3 local_pos(
+ params.has("x")? params["x"].asReal() : 128,
+ params.has("y")? params["y"].asReal() : 128,
+ params.has("z")? params["z"].asReal() : 0);
+ std::string regionname(params["regionname"]);
+ std::string destination(LLSLURL(regionname, local_pos).getSLURLString());
+ // have to resolve region's global coordinates first
+ teleport_via_slapp(regionname, destination);
+ response["message"] = "Teleporting to " + destination;
+ }
+ else // no regionname
+ {
+ // coordinates are global, and at least (x, y) are required
+ if (! (params.has("x") && params.has("y")))
+ {
+ return response.error("Specify either regionname or global (x, y)");
+ }
+ LLVector3d global_pos(params["x"].asReal(), params["y"].asReal(),
+ params["z"].asReal());
+ gAgent.teleportViaLocation(global_pos);
+ LLFloaterWorldMap* instance = LLFloaterWorldMap::getInstance();
+ if (instance)
+ {
+ instance->trackLocation(global_pos);
+ }
+ response["message"] = STRINGIZE("Teleporting to global " << global_pos);
+ }
+ }
+
static void teleport_via_slapp(std::string region_name, std::string callback_url)
{