Skip to content

Commit 023fa2d

Browse files
committed
#2924 Add 'Create Landmark' to the place context menu
1 parent 49f03a2 commit 023fa2d

File tree

9 files changed

+137
-89
lines changed

9 files changed

+137
-89
lines changed

indra/llcorehttp/httpcommon.cpp

Lines changed: 42 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
#include "linden_common.h" // Modifies curl/curl.h interfaces
2828
#include "httpcommon.h"
29+
#include "llhttpconstants.h"
2930
#include "llmutex.h"
3031
#include "llthread.h"
3132
#include <curl/curl.h>
@@ -79,47 +80,47 @@ std::string HttpStatus::toString() const
7980

8081
static const std::map<type_enum_t, std::string> http_errors =
8182
{
82-
{ 100, "Continue" },
83-
{ 101, "Switching Protocols" },
84-
{ 200, "OK" },
85-
{ 201, "Created" },
86-
{ 202, "Accepted" },
87-
{ 203, "Non-Authoritative Information" },
88-
{ 204, "No Content" },
89-
{ 205, "Reset Content" },
90-
{ 206, "Partial Content" },
91-
{ 300, "Multiple Choices" },
92-
{ 301, "Moved Permanently" },
93-
{ 302, "Found" },
94-
{ 303, "See Other" },
95-
{ 304, "Not Modified" },
96-
{ 305, "Use Proxy" },
97-
{ 307, "Temporary Redirect" },
98-
{ 400, "Bad Request" },
99-
{ 401, "Unauthorized" },
100-
{ 402, "Payment Required" },
101-
{ 403, "Forbidden" },
102-
{ 404, "Not Found" },
103-
{ 405, "Method Not Allowed" },
104-
{ 406, "Not Acceptable" },
105-
{ 407, "Proxy Authentication Required" },
106-
{ 408, "Request Time-out" },
107-
{ 409, "Conflict" },
108-
{ 410, "Gone" },
109-
{ 411, "Length Required" },
110-
{ 412, "Precondition Failed" },
111-
{ 413, "Request Entity Too Large" },
112-
{ 414, "Request-URI Too Large" },
113-
{ 415, "Unsupported Media Type" },
114-
{ 416, "Requested range not satisfiable" },
115-
{ 417, "Expectation Failed" },
116-
{ 499, "Linden Catch-All" },
117-
{ 500, "Internal Server Error" },
118-
{ 501, "Not Implemented" },
119-
{ 502, "Bad Gateway" },
120-
{ 503, "Service Unavailable" },
121-
{ 504, "Gateway Time-out" },
122-
{ 505, "HTTP Version not supported" }
83+
{ HTTP_CONTINUE, "Continue" },
84+
{ HTTP_SWITCHING_PROTOCOLS, "Switching Protocols" },
85+
{ HTTP_OK, "OK" },
86+
{ HTTP_CREATED, "Created" },
87+
{ HTTP_ACCEPTED, "Accepted" },
88+
{ HTTP_NON_AUTHORITATIVE_INFORMATION, "Non-Authoritative Information" },
89+
{ HTTP_NO_CONTENT, "No Content" },
90+
{ HTTP_RESET_CONTENT, "Reset Content" },
91+
{ HTTP_PARTIAL_CONTENT, "Partial Content" },
92+
{ HTTP_MULTIPLE_CHOICES, "Multiple Choices" },
93+
{ HTTP_MOVED_PERMANENTLY, "Moved Permanently" },
94+
{ HTTP_FOUND, "Found" },
95+
{ HTTP_SEE_OTHER, "See Other" },
96+
{ HTTP_NOT_MODIFIED, "Not Modified" },
97+
{ HTTP_USE_PROXY, "Use Proxy" },
98+
{ HTTP_TEMPORARY_REDIRECT, "Temporary Redirect" },
99+
{ HTTP_BAD_REQUEST, "Bad Request" },
100+
{ HTTP_UNAUTHORIZED, "Unauthorized" },
101+
{ HTTP_PAYMENT_REQUIRED, "Payment Required" },
102+
{ HTTP_FORBIDDEN, "Forbidden" },
103+
{ HTTP_NOT_FOUND, "Not Found" },
104+
{ HTTP_METHOD_NOT_ALLOWED, "Method Not Allowed" },
105+
{ HTTP_NOT_ACCEPTABLE, "Not Acceptable" },
106+
{ HTTP_PROXY_AUTHENTICATION_REQUIRED, "Proxy Authentication Required" },
107+
{ HTTP_REQUEST_TIME_OUT, "Request Time-out" },
108+
{ HTTP_CONFLICT, "Conflict" },
109+
{ HTTP_GONE, "Gone" },
110+
{ HTTP_LENGTH_REQUIRED, "Length Required" },
111+
{ HTTP_PRECONDITION_FAILED, "Precondition Failed" },
112+
{ HTTP_REQUEST_ENTITY_TOO_LARGE, "Request Entity Too Large" },
113+
{ HTTP_REQUEST_URI_TOO_LARGE, "Request-URI Too Large" },
114+
{ HTTP_UNSUPPORTED_MEDIA_TYPE, "Unsupported Media Type" },
115+
{ HTTP_REQUESTED_RANGE_NOT_SATISFIABLE, "Requested range not satisfiable" },
116+
{ HTTP_EXPECTATION_FAILED, "Expectation Failed" },
117+
{ 499, "Linden Catch-All" },
118+
{ HTTP_INTERNAL_SERVER_ERROR, "Internal Server Error" },
119+
{ HTTP_NOT_IMPLEMENTED, "Not Implemented" },
120+
{ HTTP_BAD_GATEWAY, "Bad Gateway" },
121+
{ HTTP_SERVICE_UNAVAILABLE, "Service Unavailable" },
122+
{ HTTP_GATEWAY_TIME_OUT, "Gateway Time-out" },
123+
{ HTTP_VERSION_NOT_SUPPORTED, "HTTP Version not supported" }
123124
};
124125

125126
if (*this)

indra/newview/lllandmarkactions.cpp

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ void LLLandmarkActions::showFloaterCreateLandmarkForUrl(const std::string& url,
274274
(slurl.getType() != LLSLURL::APP || slurl.getAppCmd() != LLSLURL::SLURL_REGION_PATH))
275275
{
276276
LL_INFOS() << "Unsupported URL: '" << url << "'" << LL_ENDL;
277+
LLNotificationsUtil::add("CantCreateLandmark");
277278
return;
278279
}
279280

@@ -284,7 +285,29 @@ void LLLandmarkActions::showFloaterCreateLandmarkForUrl(const std::string& url,
284285
showFloaterCreateLandmarkForCoords(slurl.getRegion(), x, y, z, title == url ? LLStringUtil::null : title);
285286
}
286287

287-
void LLLandmarkActions::showFloaterCreateLandmarkForCoords(const std::string& region_name, S32 x, S32 y, S32 z, const std::string& title)
288+
void LLLandmarkActions::showFloaterCreateLandmarkForPos(const LLVector3d& global_pos, const std::string& title)
289+
{
290+
if (LLSimInfo* info = LLWorldMap::getInstance()->simInfoFromPosGlobal(global_pos))
291+
{
292+
std::string region_name = info->getName();
293+
LLVector3 local_pos = info->getLocalPos(global_pos);
294+
S32 x = ll_round(local_pos.mV[VX]);
295+
S32 y = ll_round(local_pos.mV[VY]);
296+
S32 z = ll_round(local_pos.mV[VZ]);
297+
showFloaterCreateLandmarkForCoords(region_name, x, y, z, title);
298+
return;
299+
}
300+
301+
LL_WARNS() << "No region found for global pos " << global_pos << LL_ENDL;
302+
LLNotificationsUtil::add("CantCreateLandmarkTryAgain");
303+
304+
S32 x = S32(global_pos.mdV[0] / REGION_WIDTH_UNITS);
305+
S32 y = S32(global_pos.mdV[1] / REGION_WIDTH_UNITS);
306+
LLWorldMapMessage::getInstance()->sendMapBlockRequest(x, y, x, y, true);
307+
}
308+
309+
void LLLandmarkActions::showFloaterCreateLandmarkForCoords(const std::string& region_name,
310+
S32 x, S32 y, S32 z, const std::string& title)
288311
{
289312
LLSD data;
290313
data["region"] = region_name;

indra/newview/lllandmarkactions.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,13 @@ class LLLandmarkActions
9191
static void showFloaterCreateLandmarkForUrl(const std::string& url, const std::string& title);
9292

9393
/**
94-
* @brief Shows floater to create landmark for specified coordinates.
94+
* @brief Shows floater to create landmark for specified global position.
95+
*/
96+
static void showFloaterCreateLandmarkForPos(const LLVector3d& global_pos,
97+
const std::string& title = LLStringUtil::null);
98+
99+
/**
100+
* @brief Shows floater to create landmark for specified region coordinates.
95101
*/
96102
static void showFloaterCreateLandmarkForCoords(const std::string& region_name, S32 x, S32 y, S32 z,
97103
const std::string& title = LLStringUtil::null);

indra/newview/llpanelprofilepicks.cpp

Lines changed: 15 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -772,23 +772,8 @@ bool LLPanelProfilePick::isDirty() const
772772

773773
void LLPanelProfilePick::onClickCreateLandmark()
774774
{
775-
if (gAgent.getRegion() &&
776-
!gAgent.getRegion()->getCapability("CreateLandmarkForPosition").empty())
777-
{
778-
U64 handle = to_region_handle(mPosGlobal);
779-
if (LLSimInfo* info = LLWorldMap::getInstance()->simInfoFromHandle(handle))
780-
{
781-
std::string region_name = info->getName();
782-
S32 x = llclamp(ll_round((F32)mPosGlobal.mdV[VX]), 0, REGION_WIDTH_UNITS);
783-
S32 y = llclamp(ll_round((F32)mPosGlobal.mdV[VY]), 0, REGION_WIDTH_UNITS);
784-
S32 z = ll_round(llclamp((F32)mPosGlobal.mdV[VZ], MIN_OBJECT_Z, MAX_OBJECT_Z));
785-
std::string title = getChild<LLUICtrl>("pick_location")->getValue().asString();
786-
LLLandmarkActions::showFloaterCreateLandmarkForCoords(region_name, x, y, z, title);
787-
return;
788-
}
789-
}
790-
791-
LLNotificationsUtil::add("CantCreateLandmark");
775+
std::string title = getChild<LLUICtrl>("pick_location")->getValue().asString();
776+
LLLandmarkActions::showFloaterCreateLandmarkForPos(mPosGlobal, title);
792777
}
793778

794779
void LLPanelProfilePick::onClickSetLocation()
@@ -926,34 +911,27 @@ std::string LLPanelProfilePick::createLocationText(const std::string& owner_name
926911
{
927912
std::string location_text(owner_name);
928913

929-
if (!original_name.empty())
930-
{
931-
if (!location_text.empty())
914+
auto append = [&](const std::string& text, const std::string& delimiter)
932915
{
933-
location_text.append(", ");
934-
}
935-
location_text.append(original_name);
936-
}
916+
if (!text.empty())
917+
{
918+
if (!location_text.empty())
919+
{
920+
location_text.append(delimiter);
921+
}
922+
location_text.append(text);
923+
}
924+
};
937925

938-
if (!sim_name.empty())
939-
{
940-
if (!location_text.empty())
941-
{
942-
location_text.append(", ");
943-
}
944-
location_text.append(sim_name);
945-
}
926+
append(original_name, ", ");
927+
append(sim_name, ", ");
946928

947929
if (!pos_global.isNull())
948930
{
949-
if (!location_text.empty())
950-
{
951-
location_text.append(" ");
952-
}
953931
S32 region_x = ll_round((F32)pos_global.mdV[VX]) % REGION_WIDTH_UNITS;
954932
S32 region_y = ll_round((F32)pos_global.mdV[VY]) % REGION_WIDTH_UNITS;
955933
S32 region_z = ll_round((F32)pos_global.mdV[VZ]);
956-
location_text.append(llformat("(%d, %d, %d)", region_x, region_y, region_z));
934+
append(llformat("(%d, %d, %d)", region_x, region_y, region_z), " ");
957935
}
958936

959937
return location_text;

indra/newview/llpanelteleporthistory.cpp

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "llfloaterreg.h"
3030
#include "llmenubutton.h"
3131

32+
#include "llagent.h"
3233
#include "llfloaterworldmap.h"
3334
#include "llpanelteleporthistory.h"
3435
#include "llworldmap.h"
@@ -413,8 +414,8 @@ LLTeleportHistoryPanel::~LLTeleportHistoryPanel()
413414

414415
bool LLTeleportHistoryPanel::postBuild()
415416
{
416-
mCommitCallbackRegistrar.add("TeleportHistory.GearMenu.Action", { boost::bind(&LLTeleportHistoryPanel::onGearMenuAction, this, _2), cb_info::UNTRUSTED_THROTTLE });
417-
mEnableCallbackRegistrar.add("TeleportHistory.GearMenu.Enable", boost::bind(&LLTeleportHistoryPanel::isActionEnabled, this, _2));
417+
mCommitCallbackRegistrar.add("TeleportHistory.GearMenu.Action", { [&](LLUICtrl* ctrl, const LLSD& param) { onGearMenuAction(param); }, cb_info::UNTRUSTED_THROTTLE });
418+
mEnableCallbackRegistrar.add("TeleportHistory.GearMenu.Enable", [&](LLUICtrl* ctrl, const LLSD& param) { return isActionEnabled(param); });
418419

419420
// init menus before list, since menus are passed to list
420421
mGearItemMenu = LLUICtrlFactory::getInstance()->createFromFile<LLToggleableMenu>("menu_teleport_history_item.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance());
@@ -1063,6 +1064,10 @@ void LLTeleportHistoryPanel::onGearMenuAction(const LLSD& userdata)
10631064
{
10641065
confirmTeleport(index);
10651066
}
1067+
else if ("landmark" == command_name)
1068+
{
1069+
createLandmark(index);
1070+
}
10661071
else if ("view" == command_name)
10671072
{
10681073
LLTeleportHistoryFlatItem::showPlaceInfoPanel(index);
@@ -1135,6 +1140,7 @@ bool LLTeleportHistoryPanel::isActionEnabled(const LLSD& userdata) const
11351140
}
11361141

11371142
if ("teleport" == command_name
1143+
|| "landmark" == command_name
11381144
|| "view" == command_name
11391145
|| "show_on_map" == command_name
11401146
|| "copy_slurl" == command_name
@@ -1188,7 +1194,17 @@ void LLTeleportHistoryPanel::confirmTeleport(S32 hist_idx)
11881194
LLSD args;
11891195
args["HISTORY_ENTRY"] = LLTeleportHistoryStorage::getInstance()->getItems()[hist_idx].mTitle;
11901196
LLNotificationsUtil::add("TeleportToHistoryEntry", args, LLSD(),
1191-
boost::bind(&LLTeleportHistoryPanel::onTeleportConfirmation, _1, _2, hist_idx));
1197+
[&](const LLSD& notification, const LLSD& response)
1198+
{
1199+
onTeleportConfirmation(notification, response, hist_idx);
1200+
});
1201+
}
1202+
1203+
// static
1204+
void LLTeleportHistoryPanel::createLandmark(S32 hist_idx)
1205+
{
1206+
const LLTeleportHistoryPersistentItem& item = LLTeleportHistoryStorage::getInstance()->getItems()[hist_idx];
1207+
LLLandmarkActions::showFloaterCreateLandmarkForPos(item.mGlobalPos, item.mTitle);
11921208
}
11931209

11941210
// Called when user reacts upon teleport confirmation dialog.

indra/newview/llpanelteleporthistory.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ class LLTeleportHistoryPanel : public LLPanelPlacesTab
9292
void onAccordionExpand(LLUICtrl* ctrl, const LLSD& param);
9393

9494
static void confirmTeleport(S32 hist_idx);
95+
static void createLandmark(S32 hist_idx);
9596
static bool onTeleportConfirmation(const LLSD& notification, const LLSD& response, S32 hist_idx);
9697

9798
LLTeleportHistoryStorage* mTeleportHistory;

indra/newview/llviewerinventory.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,14 +1239,16 @@ void create_inventory_landmark(const LLUUID& folder_id, const std::string& name,
12391239
LLViewerRegion* viewer_region = gAgent.getRegion();
12401240
if (!viewer_region)
12411241
{
1242-
LL_WARNS() << "No agent region" << LL_ENDL;
1242+
LL_WARNS("CreateLandmark") << "No agent region" << LL_ENDL;
1243+
LLNotificationsUtil::add("CantCreateLandmark");
12431244
return;
12441245
}
12451246

12461247
std::string cap = viewer_region->getCapability("CreateLandmarkForPosition");
12471248
if (cap.empty())
12481249
{
1249-
LL_WARNS() << "Cap is not supported by the region '" << viewer_region->getName() << "'" << LL_ENDL;
1250+
LL_WARNS("CreateLandmark") << "Cap is not supported by the region '" << viewer_region->getName() << "'" << LL_ENDL;
1251+
LLNotificationsUtil::add("CantCreateLandmark");
12501252
return;
12511253
}
12521254

@@ -1276,12 +1278,12 @@ void create_inventory_landmark(const LLUUID& folder_id, const std::string& name,
12761278

12771279
if (!status)
12781280
{
1279-
LL_WARNS() << "Error " << status.getType() << ": '" << status.toString() << "'" << LL_ENDL;
1280-
LLNotificationsUtil::add("CantCreateLandmark");
1281+
LL_WARNS("CreateLandmark") << "Error " << status.getType() << ": '" << status.toString() << "'" << LL_ENDL;
1282+
LLNotificationsUtil::add(status.getType() == HTTP_PRECONDITION_FAILED ? "CantCreateLandmarkTryAgain" : "CantCreateLandmark");
12811283
}
12821284
else if (result.has("item_id"))
12831285
{
1284-
LL_INFOS() << "Created item id: '" << result["item_id"] << "'" << LL_ENDL;
1286+
LL_INFOS("CreateLandmark") << "Created item id: '" << result["item_id"] << "'" << LL_ENDL;
12851287
}
12861288
});
12871289
}

indra/newview/skins/default/xui/en/menu_teleport_history_item.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,17 @@
1616
function="TeleportHistory.GearMenu.Enable"
1717
parameter="teleport" />
1818
</menu_item_call>
19+
<menu_item_call
20+
label="Create Landmark"
21+
layout="topleft"
22+
name="create_landmark">
23+
<on_click
24+
function="TeleportHistory.GearMenu.Action"
25+
parameter="landmark" />
26+
<on_enable
27+
function="TeleportHistory.GearMenu.Enable"
28+
parameter="landmark" />
29+
</menu_item_call>
1930
<menu_item_call
2031
label="View"
2132
layout="topleft"

indra/newview/skins/default/xui/en/notifications.xml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11984,12 +11984,22 @@ Cannot create that inventory.
1198411984
Cannot create landmark.
1198511985
</notification>
1198611986

11987+
<notification
11988+
icon="alertmodal.tga"
11989+
name="CantCreateLandmarkTryAgain"
11990+
type="notify">
11991+
<tag>fail</tag>
11992+
Cannot create landmark right now.
11993+
Try again in a few seconds.
11994+
</notification>
11995+
1198711996
<notification
1198811997
icon="alertmodal.tga"
1198911998
name="CantCreateOutfit"
1199011999
type="notify">
1199112000
<tag>fail</tag>
11992-
Cannot create outfit right now. Try again in a minute.
12001+
Cannot create outfit right now.
12002+
Try again in a minute.
1199312003
</notification>
1199412004

1199512005
<notification

0 commit comments

Comments
 (0)