From d81226f1707a93b6be52264fc00cae9c60057cc5 Mon Sep 17 00:00:00 2001
From: Mnikolenko ProductEngine <mnikolenko@productengine.com>
Date: Tue, 12 Mar 2013 15:38:10 +0200
Subject: [PATCH] CHUI-809 FIXED Changes in menu items to make them consistent.
 Do not start IM if selected person is self.

---
 indra/llui/lltextbase.cpp                     |  1 +
 indra/llui/llurlaction.cpp                    | 31 ++++++++++++++-----
 indra/llui/llurlaction.h                      |  2 ++
 indra/newview/llavataractions.cpp             |  2 +-
 indra/newview/llchathistory.cpp               | 13 +++++++-
 .../skins/default/xui/en/menu_object_icon.xml | 18 +++++++++++
 .../skins/default/xui/en/menu_url_agent.xml   | 17 +++++++---
 .../default/xui/en/menu_url_objectim.xml      |  2 +-
 8 files changed, 71 insertions(+), 15 deletions(-)

diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp
index a1b6d61cdab..0f6947ca199 100644
--- a/indra/llui/lltextbase.cpp
+++ b/indra/llui/lltextbase.cpp
@@ -1919,6 +1919,7 @@ void LLTextBase::createUrlContextMenu(S32 x, S32 y, const std::string &in_url)
 	registrar.add("Url.Teleport", boost::bind(&LLUrlAction::teleportToLocation, url));
 	registrar.add("Url.ShowProfile", boost::bind(&LLUrlAction::showProfile, url));
 	registrar.add("Url.SendIM", boost::bind(&LLUrlAction::sendIM, url));
+	registrar.add("Url.AddFriend", boost::bind(&LLUrlAction::addFriend, url));
 	registrar.add("Url.ShowOnMap", boost::bind(&LLUrlAction::showLocationOnMap, url));
 	registrar.add("Url.CopyLabel", boost::bind(&LLUrlAction::copyLabelToClipboard, url));
 	registrar.add("Url.CopyUrl", boost::bind(&LLUrlAction::copyURLToClipboard, url));
diff --git a/indra/llui/llurlaction.cpp b/indra/llui/llurlaction.cpp
index fd872eca4bf..f51aeaec131 100644
--- a/indra/llui/llurlaction.cpp
+++ b/indra/llui/llurlaction.cpp
@@ -24,7 +24,6 @@
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
  */
-
 #include "linden_common.h"
 
 #include "llurlaction.h"
@@ -32,6 +31,7 @@
 #include "llwindow.h"
 #include "llurlregistry.h"
 
+
 // global state for the callback functions
 LLUrlAction::url_callback_t 		LLUrlAction::sOpenURLCallback;
 LLUrlAction::url_callback_t 		LLUrlAction::sOpenURLInternalCallback;
@@ -158,16 +158,33 @@ void LLUrlAction::showProfile(std::string url)
 	}
 }
 
-void LLUrlAction::sendIM(std::string url)
+std::string LLUrlAction::getUserID(std::string url)
 {
 	LLURI uri(url);
 	LLSD path_array = uri.pathArray();
+	std::string id_str;
 	if (path_array.size() == 4)
 	{
-		std::string id_str = path_array.get(2).asString();
-		if (LLUUID::validate(id_str))
-		{
-			executeSLURL("secondlife:///app/agent/" + id_str + "/im");
-		}
+		id_str = path_array.get(2).asString();
 	}
+	return id_str;
 }
+
+void LLUrlAction::sendIM(std::string url)
+{
+	std::string id_str = getUserID(url);
+	if (LLUUID::validate(id_str))
+	{
+		executeSLURL("secondlife:///app/agent/" + id_str + "/im");
+	}
+}
+
+void LLUrlAction::addFriend(std::string url)
+{
+	std::string id_str = getUserID(url);
+	if (LLUUID::validate(id_str))
+	{
+		executeSLURL("secondlife:///app/agent/" + id_str + "/requestfriend");
+	}
+}
+
diff --git a/indra/llui/llurlaction.h b/indra/llui/llurlaction.h
index f5f2ceba728..e31cd71a207 100644
--- a/indra/llui/llurlaction.h
+++ b/indra/llui/llurlaction.h
@@ -76,7 +76,9 @@ class LLUrlAction
 
 	/// if the Url specifies an SL command in the form like 'app/{cmd}/{id}/*', show its profile
 	static void showProfile(std::string url);
+	static std::string getUserID(std::string url);
 	static void sendIM(std::string url);
+	static void addFriend(std::string url);
 
 	/// specify the callbacks to enable this class's functionality
 	typedef boost::function<void (const std::string&)> url_callback_t;
diff --git a/indra/newview/llavataractions.cpp b/indra/newview/llavataractions.cpp
index ce063a9887a..b513a52ff7c 100755
--- a/indra/newview/llavataractions.cpp
+++ b/indra/newview/llavataractions.cpp
@@ -193,7 +193,7 @@ static void on_avatar_name_cache_start_im(const LLUUID& agent_id,
 // static
 void LLAvatarActions::startIM(const LLUUID& id)
 {
-	if (id.isNull())
+	if (id.isNull() || gAgent.getID() == id)
 		return;
 
 	LLAvatarNameCache::get(id, boost::bind(&on_avatar_name_cache_start_im, _1, _2));
diff --git a/indra/newview/llchathistory.cpp b/indra/newview/llchathistory.cpp
index 0152571e20f..53926c1fef6 100644
--- a/indra/newview/llchathistory.cpp
+++ b/indra/newview/llchathistory.cpp
@@ -58,7 +58,7 @@
 #include "llworld.h"
 #include "lluiconstants.h"
 #include "llstring.h"
-
+#include "llurlaction.h"
 #include "llviewercontrol.h"
 
 static LLDefaultChildRegistry::Register<LLChatHistory> r("chat_history");
@@ -156,6 +156,17 @@ class LLChatHistoryHeader: public LLPanel
 			LLFloaterSidePanelContainer::showPanel("people", "panel_people",
 				LLSD().with("people_panel_tab_name", "blocked_panel").with("blocked_to_select", getAvatarId()));
 		}
+		else if (level == "map")
+		{
+			std::string url = "secondlife://" + mObjectData["slurl"].asString();
+			LLUrlAction::showLocationOnMap(url);
+		}
+		else if (level == "teleport")
+		{
+			std::string url = "secondlife://" + mObjectData["slurl"].asString();
+			LLUrlAction::teleportToLocation(url);
+		}
+
 	}
 
 	void onAvatarIconContextMenuItemClicked(const LLSD& userdata)
diff --git a/indra/newview/skins/default/xui/en/menu_object_icon.xml b/indra/newview/skins/default/xui/en/menu_object_icon.xml
index 0c8a2af0028..2d4f1792c29 100644
--- a/indra/newview/skins/default/xui/en/menu_object_icon.xml
+++ b/indra/newview/skins/default/xui/en/menu_object_icon.xml
@@ -24,4 +24,22 @@
          function="ObjectIcon.Action"
          parameter="block" />
     </menu_item_call>
+    <menu_item_separator
+     layout="topleft" />
+    <menu_item_call
+     label="Show on Map"
+     layout="topleft"
+     name="show_on_map">
+        <menu_item_call.on_click
+         function="ObjectIcon.Action" 
+         parameter="map" />
+    </menu_item_call>
+    <menu_item_call
+     label="Teleport to Object Location"
+     layout="topleft"
+     name="teleport_to_object">
+        <menu_item_call.on_click
+         function="ObjectIcon.Action"
+         parameter="teleport" />
+    </menu_item_call>
 </menu>
diff --git a/indra/newview/skins/default/xui/en/menu_url_agent.xml b/indra/newview/skins/default/xui/en/menu_url_agent.xml
index 88ae441bd38..7cd56f257a8 100644
--- a/indra/newview/skins/default/xui/en/menu_url_agent.xml
+++ b/indra/newview/skins/default/xui/en/menu_url_agent.xml
@@ -1,20 +1,27 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
 <context_menu
  layout="topleft"
- name="Url Popup">
+ name="Url Popup">  
     <menu_item_call
-     label="Send IM"
+     label="View Profile"
      layout="topleft"
      name="show_agent">
+        <menu_item_call.on_click
+         function="Url.ShowProfile" />         
+    </menu_item_call>
+    <menu_item_call
+     label="Send IM..."
+     layout="topleft"
+     name="send_im">
         <menu_item_call.on_click
          function="Url.SendIM" />        
     </menu_item_call>
     <menu_item_call
-     label="Show Resident Profile"
+     label="Add Friend..."
      layout="topleft"
-     name="show_agent">
+     name="add_friend">
         <menu_item_call.on_click
-         function="Url.ShowProfile" />
+         function="Url.AddFriend" />        
     </menu_item_call>
     <menu_item_separator
      layout="topleft" />
diff --git a/indra/newview/skins/default/xui/en/menu_url_objectim.xml b/indra/newview/skins/default/xui/en/menu_url_objectim.xml
index 35c2269b0d1..87ab58e622e 100644
--- a/indra/newview/skins/default/xui/en/menu_url_objectim.xml
+++ b/indra/newview/skins/default/xui/en/menu_url_objectim.xml
@@ -3,7 +3,7 @@
  layout="topleft"
  name="Url Popup">
     <menu_item_call
-     label="Show Object Information"
+     label="Object Profile..."
      layout="topleft"
      name="show_object">
         <menu_item_call.on_click
-- 
GitLab