diff options
Diffstat (limited to 'indra/llui/llurlentry.cpp')
-rw-r--r-- | indra/llui/llurlentry.cpp | 81 |
1 files changed, 51 insertions, 30 deletions
diff --git a/indra/llui/llurlentry.cpp b/indra/llui/llurlentry.cpp index 85f9064115..c20212c375 100644 --- a/indra/llui/llurlentry.cpp +++ b/indra/llui/llurlentry.cpp @@ -339,54 +339,75 @@ std::string LLUrlEntryGroup::getLabel(const std::string &url, const LLUrlLabelCa } /// -/// LLUrlEntryEvent Describes a Second Life event Url, e.g., -/// secondlife:///app/event/700727/about +/// LLUrlEntryParcel Describes a Second Life parcel Url, e.g., +/// secondlife:///app/parcel/0000060e-4b39-e00b-d0c3-d98b1934e3a8/about /// -LLUrlEntryEvent::LLUrlEntryEvent() +LLUrlEntryParcel::LLUrlEntryParcel() { - mPattern = boost::regex("secondlife:///app/event/[\\da-f-]+/about", + mPattern = boost::regex("secondlife:///app/parcel/[\\da-f-]+/about", boost::regex::perl|boost::regex::icase); - mMenuName = "menu_url_event.xml"; - mTooltip = LLTrans::getString("TooltipEventUrl"); + mMenuName = "menu_url_parcel.xml"; + mTooltip = LLTrans::getString("TooltipParcelUrl"); } -std::string LLUrlEntryEvent::getLabel(const std::string &url, const LLUrlLabelCallback &cb) +std::string LLUrlEntryParcel::getLabel(const std::string &url, const LLUrlLabelCallback &cb) { return unescapeUrl(url); } -/// -/// LLUrlEntryClassified Describes a Second Life classified Url, e.g., -/// secondlife:///app/classified/00128854-c36a-5649-7ca6-5dfaa7514ab2/about -/// -LLUrlEntryClassified::LLUrlEntryClassified() +// +// LLUrlEntryPlace Describes secondlife:///<location> URLs +// +LLUrlEntryPlace::LLUrlEntryPlace() { - mPattern = boost::regex("secondlife:///app/classified/[\\da-f-]+/about", + mPattern = boost::regex("secondlife://\\S+/?(\\d+/\\d+/\\d+|\\d+/\\d+)/?", boost::regex::perl|boost::regex::icase); - mMenuName = "menu_url_classified.xml"; - mTooltip = LLTrans::getString("TooltipClassifiedUrl"); + mMenuName = "menu_url_slurl.xml"; + mTooltip = LLTrans::getString("TooltipSLURL"); } -std::string LLUrlEntryClassified::getLabel(const std::string &url, const LLUrlLabelCallback &cb) +std::string LLUrlEntryPlace::getLabel(const std::string &url, const LLUrlLabelCallback &cb) { - return unescapeUrl(url); -} + // + // we handle SLURLs in the following formats: + // - secondlife://Place/X/Y/Z + // - secondlife://Place/X/Y + // + LLURI uri(url); + std::string location = unescapeUrl(uri.hostName()); + LLSD path_array = uri.pathArray(); + S32 path_parts = path_array.size(); + if (path_parts == 3) + { + // handle slurl with (X,Y,Z) coordinates + std::string x = path_array[0]; + std::string y = path_array[1]; + std::string z = path_array[2]; + return location + " (" + x + "," + y + "," + z + ")"; + } + else if (path_parts == 2) + { + // handle slurl with (X,Y) coordinates + std::string x = path_array[0]; + std::string y = path_array[1]; + return location + " (" + x + "," + y + ")"; + } -/// -/// LLUrlEntryParcel Describes a Second Life parcel Url, e.g., -/// secondlife:///app/parcel/0000060e-4b39-e00b-d0c3-d98b1934e3a8/about -/// -LLUrlEntryParcel::LLUrlEntryParcel() -{ - mPattern = boost::regex("secondlife:///app/parcel/[\\da-f-]+/about", - boost::regex::perl|boost::regex::icase); - mMenuName = "menu_url_parcel.xml"; - mTooltip = LLTrans::getString("TooltipParcelUrl"); + return url; } -std::string LLUrlEntryParcel::getLabel(const std::string &url, const LLUrlLabelCallback &cb) +std::string LLUrlEntryPlace::getLocation(const std::string &url) const { - return unescapeUrl(url); + // return the part of the Url after secondlife:// part + const std::string search_string = "://"; + size_t pos = url.find(search_string); + if (pos == std::string::npos) + { + return ""; + } + + pos += search_string.size(); + return url.substr(pos, url.size() - pos); } // |