From e386aa73b7af5ca326f66fa3fb0482e42b3af33f Mon Sep 17 00:00:00 2001
From: Jonathan Yap <none@none>
Date: Fri, 11 Jan 2013 11:13:44 -0500
Subject: [PATCH] STORM-1838

---
 indra/llmessage/llinstantmessage.h            |  2 +-
 indra/llmessage/message_prehash.cpp           |  1 -
 indra/llmessage/message_prehash.h             |  1 -
 indra/newview/llavataractions.cpp             | 36 ++++++++++++--
 indra/newview/llavataractions.h               |  2 +-
 indra/newview/llpanelpeoplemenus.cpp          |  2 +-
 indra/newview/llviewermessage.cpp             | 48 ++++++++++++++++---
 .../skins/default/xui/en/menu_inventory.xml   |  6 +++
 .../default/xui/en/menu_people_nearby.xml     |  2 +-
 .../skins/default/xui/en/notifications.xml    |  6 +--
 10 files changed, 87 insertions(+), 19 deletions(-)

diff --git a/indra/llmessage/llinstantmessage.h b/indra/llmessage/llinstantmessage.h
index e0dae376b4b..febc59c4bcd 100644
--- a/indra/llmessage/llinstantmessage.h
+++ b/indra/llmessage/llinstantmessage.h
@@ -126,7 +126,7 @@ enum EInstantMessage
 	IM_LURE_ACCEPTED = 23,
 	IM_LURE_DECLINED = 24,
 	IM_GODLIKE_LURE_USER = 25,
-	IM_YET_TO_BE_USED = 26,
+	IM_TELEPORT_REQUEST = 26,
 
 	// IM that notifie of a new group election.
 	// Name is name of person who called vote.
diff --git a/indra/llmessage/message_prehash.cpp b/indra/llmessage/message_prehash.cpp
index 64fb6a78a20..e71fb965407 100644
--- a/indra/llmessage/message_prehash.cpp
+++ b/indra/llmessage/message_prehash.cpp
@@ -1379,4 +1379,3 @@ char const* const _PREHASH_ProductSKU = LLMessageStringTable::getInstance()->get
 char const* const _PREHASH_SeeAVs = LLMessageStringTable::getInstance()->getString("SeeAVs");
 char const* const _PREHASH_AnyAVSounds = LLMessageStringTable::getInstance()->getString("AnyAVSounds");
 char const* const _PREHASH_GroupAVSounds = LLMessageStringTable::getInstance()->getString("GroupAVSounds");
-char const* const _PREHASH_RequestTeleport = LLMessageStringTable::getInstance()->getString("RequestTeleport");
diff --git a/indra/llmessage/message_prehash.h b/indra/llmessage/message_prehash.h
index 4da1fa7a95b..dd2c2dbd64a 100644
--- a/indra/llmessage/message_prehash.h
+++ b/indra/llmessage/message_prehash.h
@@ -1379,5 +1379,4 @@ extern char const* const _PREHASH_ProductSKU;
 extern char const* const _PREHASH_SeeAVs;
 extern char const* const _PREHASH_AnyAVSounds;
 extern char const* const _PREHASH_GroupAVSounds;
-extern char const* const _PREHASH_RequestTeleport;
 #endif
diff --git a/indra/newview/llavataractions.cpp b/indra/newview/llavataractions.cpp
index 8df30da68a3..0d00232c2fc 100755
--- a/indra/newview/llavataractions.cpp
+++ b/indra/newview/llavataractions.cpp
@@ -72,6 +72,7 @@
 #include "llslurl.h"			// IDEVO
 #include "llsidepanelinventory.h"
 #include "llavatarname.h"
+#include "llagentui.h"
 
 // static
 void LLAvatarActions::requestFriendshipDialog(const LLUUID& id, const std::string& name)
@@ -397,15 +398,44 @@ void LLAvatarActions::pay(const LLUUID& id)
 }
 
 // static
-void LLAvatarActions::requestTeleport(const LLUUID& id)
+void LLAvatarActions::teleportRequest(const LLUUID& id)
 {
 	LLMessageSystem* msg = gMessageSystem;
 
-	msg->newMessageFast(_PREHASH_RequestTeleport);
+	msg->newMessageFast(_PREHASH_ImprovedInstantMessage);
 	msg->nextBlockFast(_PREHASH_AgentData);
-	msg->addUUIDFast(_PREHASH_AgentID, id);
+	msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
 	msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
+
+	msg->nextBlockFast(_PREHASH_MessageBlock);
+	msg->addBOOLFast(_PREHASH_FromGroup, FALSE);
+	msg->addUUIDFast(_PREHASH_ToAgentID, id);
+	msg->addU8Fast(_PREHASH_Offline, IM_ONLINE);
+	msg->addU8Fast(_PREHASH_Dialog, IM_TELEPORT_REQUEST);
+	msg->addUUIDFast(_PREHASH_ID, LLUUID::null);
+	msg->addU32Fast(_PREHASH_Timestamp, NO_TIMESTAMP); // no timestamp necessary
+
+	std::string name;
+	LLAgentUI::buildFullname(name);
+
+	msg->addStringFast(_PREHASH_FromAgentName, name);
+	msg->addStringFast(_PREHASH_Message, LLStringUtil::null);
+	msg->addU32Fast(_PREHASH_ParentEstateID, 0);
+	msg->addUUIDFast(_PREHASH_RegionID, LLUUID::null);
+	msg->addVector3Fast(_PREHASH_Position, gAgent.getPositionAgent());
+
+	gMessageSystem->addBinaryDataFast(
+			_PREHASH_BinaryBucket,
+			EMPTY_BINARY_BUCKET,
+			EMPTY_BINARY_BUCKET_SIZE);
+
+/*	msg->newMessageFast(_PREHASH_TeleportRequest);
+	msg->nextBlockFast(_PREHASH_AgentData);
+	msg->addUUIDFast(_PREHASH_AgentID, id);
+	msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); */
+
 	gAgent.sendReliableMessage();
+llwarns << "DBG REQUEST_TELEPORT sent" << llendl;
 }
 
 // static
diff --git a/indra/newview/llavataractions.h b/indra/newview/llavataractions.h
index 1eee9ea81f4..f3df953e982 100644
--- a/indra/newview/llavataractions.h
+++ b/indra/newview/llavataractions.h
@@ -111,7 +111,7 @@ class LLAvatarActions
 	/**
 	 * Request teleport from other avatar
 	 */
-	static void requestTeleport(const LLUUID& id);
+	static void teleportRequest(const LLUUID& id);
 
 	/**
 	 * Share items with the avatar.
diff --git a/indra/newview/llpanelpeoplemenus.cpp b/indra/newview/llpanelpeoplemenus.cpp
index c703ae87684..499dfd36fc4 100644
--- a/indra/newview/llpanelpeoplemenus.cpp
+++ b/indra/newview/llpanelpeoplemenus.cpp
@@ -67,7 +67,7 @@ LLContextMenu* NearbyMenu::createMenu()
 		registrar.add("Avatar.Share",			boost::bind(&LLAvatarActions::share,					id));
 		registrar.add("Avatar.Pay",				boost::bind(&LLAvatarActions::pay,						id));
 		registrar.add("Avatar.BlockUnblock",	boost::bind(&LLAvatarActions::toggleBlock,				id));
-		registrar.add("Avatar.RequestTeleport",	boost::bind(&LLAvatarActions::requestTeleport,			id));
+		registrar.add("Avatar.TeleportRequest",	boost::bind(&LLAvatarActions::teleportRequest,			id));
 
 		enable_registrar.add("Avatar.EnableItem", boost::bind(&NearbyMenu::enableContextMenuItem,	this, _2));
 		enable_registrar.add("Avatar.CheckItem",  boost::bind(&NearbyMenu::checkContextMenuItem,	this, _2));
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index f4f71483404..25b35638076 100755
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -1992,13 +1992,20 @@ bool lure_callback(const LLSD& notification, const LLSD& response)
 }
 static LLNotificationFunctorRegistration lure_callback_reg("TeleportOffered", lure_callback);
 
-bool teleport_requested_callback(const LLSD& notification, const LLSD& response)
+bool teleport_request_callback(const LLSD& notification, const LLSD& response)
 {
 	LLUUID from_id = notification["payload"]["from_id"].asUUID();
+	if(from_id.isNull())
+	{
+		llwarns << "from_id is NULL" << llendl;
+		return false;
+	}
+
 	std::string from_name;
 	gCacheName->getFullName(from_id, from_name);
+llwarns << "DBG " << from_name << " " << from_id << llendl;
 
-	if(from_id.isNull() || (LLMuteList::getInstance()->isMuted(from_id) && !LLMuteList::getInstance()->isLinden(from_name)))
+	if(LLMuteList::getInstance()->isMuted(from_id) && !LLMuteList::getInstance()->isLinden(from_name))
 	{
 		return false;
 	}
@@ -2027,18 +2034,27 @@ bool teleport_requested_callback(const LLSD& notification, const LLSD& response)
 	default:
 		break;
 
-	// Block
+	// IM
 	case 2:
 		{
+llwarns << "DBG start IM" << llendl;
+			LLAvatarActions::startIM(from_id);
+		}
+		break;
+
+/*	// Block
+	case 3:
+		{
 			LLMute mute(from_id, from_name, LLMute::AGENT);
+			LLMuteList::getInstance()->add(mute);
 			LLPanelBlockedList::showPanelAndSelect(mute.mID);
 		}
-		break;
+		break; */
 	}
 	return false;
 }
 
-static LLNotificationFunctorRegistration teleport_requested_callback_reg("TeleportRequested", teleport_requested_callback);
+static LLNotificationFunctorRegistration teleport_request_callback_reg("TeleportRequest", teleport_request_callback);
 
 bool goto_url_callback(const LLSD& notification, const LLSD& response)
 {
@@ -2163,7 +2179,7 @@ static std::string clean_name_from_im(const std::string& name, EInstantMessage t
 	case IM_LURE_ACCEPTED:
 	case IM_LURE_DECLINED:
 	case IM_GODLIKE_LURE_USER:
-	case IM_YET_TO_BE_USED:
+	case IM_TELEPORT_REQUEST:
 	case IM_GROUP_ELECTION_DEPRECATED:
 	//IM_GOTO_URL
 	//IM_FROM_TASK_AS_ALERT
@@ -2914,7 +2930,9 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
 		break;
 		
 	case IM_LURE_USER:
+	case IM_TELEPORT_REQUEST:
 		{
+llwarns << "DBG teleport processing" << llendl;
 			if (is_muted)
 			{ 
 				return;
@@ -2949,7 +2967,23 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
 				payload["lure_id"] = session_id;
 				payload["godlike"] = FALSE;
 
-			    LLNotification::Params params("TeleportOffered");
+				LLNotification::Params params;
+				if (IM_LURE_USER == dialog)
+				{
+llwarns << "DBG LURE_USER received (treating as TELPORT_REQUEST" << llendl;
+//					params.name = "TeleportOffered";
+//					params.functor.name = "TeleportOffered";
+					params.name = "TeleportRequest";
+					params.functor.name = "TeleportRequest";
+				}
+
+				if (IM_TELEPORT_REQUEST == dialog)
+				{
+llwarns << "DBG TELEPORT_REQUEST received" << llendl;
+					params.name = "TeleportRequest";
+					params.functor.name = "TeleportRequest";
+				}
+
 			    params.substitutions = args;
 			    params.payload = payload;
 			    LLPostponedNotification::add<LLPostponedOfferNotification>(	params, from_id, false);
diff --git a/indra/newview/skins/default/xui/en/menu_inventory.xml b/indra/newview/skins/default/xui/en/menu_inventory.xml
index b13bf5b5086..051bb800e76 100644
--- a/indra/newview/skins/default/xui/en/menu_inventory.xml
+++ b/indra/newview/skins/default/xui/en/menu_inventory.xml
@@ -590,6 +590,12 @@
          function="Inventory.BeginIMSession"
          parameter="selected" />
     </menu_item_call>
+    <menu_item_call
+     label="Request Teleport"
+     name="Request Teleport">
+        <menu_item_call.on_click
+        function="Avatar.TeleportRequest" />
+    </menu_item_call>
     <menu_item_separator
      layout="topleft" 
      name="Gesture Separator" />
diff --git a/indra/newview/skins/default/xui/en/menu_people_nearby.xml b/indra/newview/skins/default/xui/en/menu_people_nearby.xml
index cff383cab16..951f43f3256 100644
--- a/indra/newview/skins/default/xui/en/menu_people_nearby.xml
+++ b/indra/newview/skins/default/xui/en/menu_people_nearby.xml
@@ -75,7 +75,7 @@
      layout="topleft"
      name="Request Teleport">
         <menu_item_call.on_click
-         function="Avatar.RequestTeleport" />
+         function="Avatar.TeleportRequest" />
     </menu_item_call>
     <menu_item_check
      label="Block/Unblock"
diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml
index 54ba03ad594..f85b62c9442 100644
--- a/indra/newview/skins/default/xui/en/notifications.xml
+++ b/indra/newview/skins/default/xui/en/notifications.xml
@@ -6153,7 +6153,7 @@ Your object named &lt;nolink&gt;[OBJECTFROMNAME]&lt;/nolink&gt; has given you th
    icon="notify.tga"
    name="TeleportRequest"
    type="notify">
-[NAME] is requesting to be teleported your to your location.
+[NAME_SLURL] is requesting to be teleported your to your location.
 
 Will you permit this?
     <tag>confirm</tag>
@@ -6168,8 +6168,8 @@ Will you permit this?
        text="No"/>
       <button
        index="2"
-       name="Mute"
-       text="Block"/>
+       name="IM"
+       text="IM"/>
     </form>
   </notification>
 
-- 
GitLab