From 3f27ba891ac4d032753b219b4b96d1ffbc9fb488 Mon Sep 17 00:00:00 2001 From: Jacek Antonelli Date: Fri, 15 Aug 2008 23:45:16 -0500 Subject: Second Life viewer sources 1.18.5.0-RC --- linden/indra/newview/llurldispatcher.cpp | 128 ++++++++++++++++++++----------- 1 file changed, 82 insertions(+), 46 deletions(-) (limited to 'linden/indra/newview/llurldispatcher.cpp') diff --git a/linden/indra/newview/llurldispatcher.cpp b/linden/indra/newview/llurldispatcher.cpp index e49e9e5..880822a 100644 --- a/linden/indra/newview/llurldispatcher.cpp +++ b/linden/indra/newview/llurldispatcher.cpp @@ -35,11 +35,10 @@ // viewer includes #include "llagent.h" // teleportViaLocation() #include "llcommandhandler.h" -// *FIX: code in merge sl-search-8 -//#include "llfloaterurldisplay.h" +#include "llfloaterurldisplay.h" #include "llfloaterdirectory.h" #include "llfloaterhtmlhelp.h" -#include "llfloaterworldmap.h" +//#include "llfloaterworldmap.h" #include "llpanellogin.h" #include "llstartup.h" // gStartupState #include "llurlsimstring.h" @@ -88,11 +87,10 @@ private: // handles secondlife://Ahern/123/45/67/ // Returns true if handled. -// *FIX: code in merge sl-search-8 -// static void regionHandleCallback(U64 handle, const std::string& url, -// const LLUUID& snapshot_id, bool teleport); -// // Called by LLWorldMap when a region name has been resolved to a -// // location in-world, used by places-panel display. + static void regionHandleCallback(U64 handle, const std::string& url, + const LLUUID& snapshot_id, bool teleport); + // Called by LLWorldMap when a region name has been resolved to a + // location in-world, used by places-panel display. static bool matchPrefix(const std::string& url, const std::string& prefix); @@ -151,7 +149,9 @@ bool LLURLDispatcherImpl::dispatchHelp(const std::string& url, BOOL right_mouse) { if (matchPrefix(url, SLURL_SL_HELP_PREFIX)) { +#if LL_LIBXUL_ENABLED gViewerHtmlHelp.show(); +#endif // LL_LIBXUL_ENABLED return true; } return false; @@ -228,13 +228,52 @@ bool LLURLDispatcherImpl::dispatchRegion(const std::string& url, BOOL right_mous S32 y = 128; S32 z = 0; LLURLSimString::parse(sim_string, ®ion_name, &x, &y, &z); - if (gFloaterWorldMap) + + LLFloaterURLDisplay* url_displayp = LLFloaterURLDisplay::getInstance(LLSD()); + url_displayp->setName(region_name); + + // Request a region handle by name + gWorldMap->sendNamedRegionRequest(region_name, + LLURLDispatcherImpl::regionHandleCallback, + url, + false); // don't teleport + return true; +} + +/*static*/ +void LLURLDispatcherImpl::regionHandleCallback(U64 region_handle, const std::string& url, const LLUUID& snapshot_id, bool teleport) +{ + std::string sim_string = stripProtocol(url); + std::string region_name; + S32 x = 128; + S32 y = 128; + S32 z = 0; + LLURLSimString::parse(sim_string, ®ion_name, &x, &y, &z); + + LLVector3 local_pos; + local_pos.mV[VX] = (F32)x; + local_pos.mV[VY] = (F32)y; + local_pos.mV[VZ] = (F32)z; + + if (teleport) { - llinfos << "Opening map to " << region_name << llendl; - gFloaterWorldMap->trackURL( region_name.c_str(), x, y, z ); - LLFloaterWorldMap::show(NULL, TRUE); + LLVector3d global_pos = from_region_handle(region_handle); + global_pos += LLVector3d(local_pos); + gAgent.teleportViaLocation(global_pos); + } + else + { + // display informational floater, allow user to click teleport btn + LLFloaterURLDisplay* url_displayp = LLFloaterURLDisplay::getInstance(LLSD()); + + url_displayp->displayParcelInfo(region_handle, local_pos); + if(snapshot_id.notNull()) + { + url_displayp->setSnapshotDisplay(snapshot_id); + } + std::string locationString = llformat("%s %d, %d, %d", region_name.c_str(), x, y, z); + url_displayp->setLocationString(locationString); } - return true; } // static @@ -268,38 +307,36 @@ std::string LLURLDispatcherImpl::stripProtocol(const std::string& url) return stripped; } -// *FIX: code in merge sl-search-8 -// -////--------------------------------------------------------------------------- -//// Teleportation links are handled here because they are tightly coupled -//// to URL parsing and sim-fragment parsing -//class LLTeleportHandler : public LLCommandHandler -//{ -//public: -// LLTeleportHandler() : LLCommandHandler("teleport") { } -// bool handle(const std::vector& tokens) -// { -// // construct a "normal" SLURL, resolve the region to -// // a global position, and teleport to it -// if (tokens.size() < 1) return false; -// -// // Region names may be %20 escaped. -// std::string region_name = LLURLSimString::unescapeRegionName(tokens[0]); -// -// // build secondlife://De%20Haro/123/45/67 for use in callback -// std::string url = SLURL_SECONDLIFE_PREFIX; -// for (size_t i = 0; i < tokens.size(); ++i) -// { -// url += tokens[i] + "/"; -// } -// gWorldMap->sendNamedRegionRequest(region_name, -// LLURLDispatcherImpl::regionHandleCallback, -// url, -// true); // teleport -// return true; -// } -//}; -//LLTeleportHandler gTeleportHandler; +//--------------------------------------------------------------------------- +// Teleportation links are handled here because they are tightly coupled +// to URL parsing and sim-fragment parsing +class LLTeleportHandler : public LLCommandHandler +{ +public: + LLTeleportHandler() : LLCommandHandler("teleport") { } + bool handle(const std::vector& tokens) + { + // construct a "normal" SLURL, resolve the region to + // a global position, and teleport to it + if (tokens.size() < 1) return false; + + // Region names may be %20 escaped. + std::string region_name = LLURLSimString::unescapeRegionName(tokens[0]); + + // build secondlife://De%20Haro/123/45/67 for use in callback + std::string url = SLURL_SECONDLIFE_PREFIX; + for (size_t i = 0; i < tokens.size(); ++i) + { + url += tokens[i] + "/"; + } + gWorldMap->sendNamedRegionRequest(region_name, + LLURLDispatcherImpl::regionHandleCallback, + url, + true); // teleport + return true; + } +}; +LLTeleportHandler gTeleportHandler; //--------------------------------------------------------------------------- @@ -325,4 +362,3 @@ bool LLURLDispatcher::dispatchRightClick(const std::string& url) { return LLURLDispatcherImpl::dispatchRightClick(url); } - -- cgit v1.1