From 0ec2e5de3fdd112c233eb11691f8e6d3064babf6 Mon Sep 17 00:00:00 2001
From: Rye Mutt <rye@alchemyviewer.org>
Date: Sun, 22 Mar 2020 23:26:07 -0400
Subject: [PATCH] Add RLVa restrictions to profiles

---
 indra/newview/llpanelprofile.cpp            | 10 +++++++++-
 indra/newview/llpanelprofile.h              |  1 +
 indra/newview/llpanelprofileclassifieds.cpp | 10 +++++++++-
 indra/newview/llpanelprofileclassifieds.h   |  2 ++
 indra/newview/llpanelprofilepicks.cpp       | 11 ++++++++++-
 indra/newview/llpanelprofilepicks.h         |  2 ++
 6 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/indra/newview/llpanelprofile.cpp b/indra/newview/llpanelprofile.cpp
index 2cd5aecc2e3..7119bf3f352 100644
--- a/indra/newview/llpanelprofile.cpp
+++ b/indra/newview/llpanelprofile.cpp
@@ -65,6 +65,7 @@
 #include "llviewercontrol.h"
 #include "llvoiceclient.h"
 #include "llweb.h"
+#include "rlvhandler.h"
 
 
 static LLPanelInjector<LLPanelProfileSecondLife> t_panel_profile_secondlife("panel_profile_secondlife");
@@ -249,6 +250,11 @@ LLPanelProfileSecondLife::~LLPanelProfileSecondLife()
     {
         mAvatarNameCacheConnection.disconnect();
     }
+
+    if (mRlvBehaviorConn.connected())
+    {
+        mRlvBehaviorConn.disconnect();
+    }
 }
 
 BOOL LLPanelProfileSecondLife::postBuild()
@@ -299,6 +305,8 @@ BOOL LLPanelProfileSecondLife::postBuild()
     LLVoiceClient::getInstance()->addObserver((LLVoiceClientStatusObserver*)this);
     mCopyMenuButton->setMenu("menu_name_field.xml", LLMenuButton::MP_BOTTOM_RIGHT);
 
+    mRlvBehaviorConn = gRlvHandler.setBehaviourToggleCallback([this](ERlvBehaviour eBhvr, ERlvParamType eParam) { if (eBhvr == RLV_BHVR_SHOWWORLDMAP) updateButtons(); });
+
     return TRUE;
 }
 
@@ -737,7 +745,7 @@ void LLPanelProfileSecondLife::updateButtons()
             mAddFriendButton->setEnabled(true);
         }
 
-        bool enable_map_btn = (is_buddy_online && is_agent_mappable(av_id)) || gAgent.isGodlike();
+        bool enable_map_btn = ((is_buddy_online && is_agent_mappable(av_id)) || gAgent.isGodlike()) && !gRlvHandler.hasBehaviour(RLV_BHVR_SHOWWORLDMAP);
         mShowOnMapButton->setEnabled(enable_map_btn);
 
         bool enable_block_btn = LLAvatarActions::canBlock(av_id) && !LLAvatarActions::isBlocked(av_id);
diff --git a/indra/newview/llpanelprofile.h b/indra/newview/llpanelprofile.h
index de25b924707..49e86c39981 100644
--- a/indra/newview/llpanelprofile.h
+++ b/indra/newview/llpanelprofile.h
@@ -208,6 +208,7 @@ class LLPanelProfileSecondLife
 	bool				mVoiceStatus;
 
 	boost::signals2::connection	mAvatarNameCacheConnection;
+	boost::signals2::connection mRlvBehaviorConn;
 };
 
 
diff --git a/indra/newview/llpanelprofileclassifieds.cpp b/indra/newview/llpanelprofileclassifieds.cpp
index 1937e2db1c3..825fea7981f 100644
--- a/indra/newview/llpanelprofileclassifieds.cpp
+++ b/indra/newview/llpanelprofileclassifieds.cpp
@@ -56,6 +56,8 @@
 #include "llviewerregion.h"
 #include "llviewertexture.h"
 #include "llviewertexture.h"
+#include "rlvactions.h"
+#include "rlvhandler.h"
 
 
 //*TODO: verify this limit
@@ -139,6 +141,10 @@ LLPanelProfileClassifieds::LLPanelProfileClassifieds()
 
 LLPanelProfileClassifieds::~LLPanelProfileClassifieds()
 {
+    if (mRlvBehaviorConn.connected())
+    {
+        mRlvBehaviorConn.disconnect();
+    }
 }
 
 void LLPanelProfileClassifieds::onOpen(const LLSD& key)
@@ -203,6 +209,8 @@ BOOL LLPanelProfileClassifieds::postBuild()
     mNewButton->setCommitCallback(boost::bind(&LLPanelProfileClassifieds::onClickNewBtn, this));
     mDeleteButton->setCommitCallback(boost::bind(&LLPanelProfileClassifieds::onClickDelete, this));
 
+    mRlvBehaviorConn = gRlvHandler.setBehaviourToggleCallback([this](ERlvBehaviour eBhvr, ERlvParamType eParam) { if (eBhvr == RLV_BHVR_SHOWLOC) updateButtons(); });
+
     return TRUE;
 }
 
@@ -356,7 +364,7 @@ void LLPanelProfileClassifieds::updateData()
 
 bool LLPanelProfileClassifieds::canAddNewClassified()
 {
-    return (mTabContainer->getTabCount() < MAX_AVATAR_CLASSIFIEDS);
+    return (mTabContainer->getTabCount() < MAX_AVATAR_CLASSIFIEDS) && RlvActions::canShowLocation();
 }
 
 bool LLPanelProfileClassifieds::canDeleteClassified()
diff --git a/indra/newview/llpanelprofileclassifieds.h b/indra/newview/llpanelprofileclassifieds.h
index 31ef1c65b32..f71fcd5d54c 100644
--- a/indra/newview/llpanelprofileclassifieds.h
+++ b/indra/newview/llpanelprofileclassifieds.h
@@ -105,6 +105,8 @@ class LLPanelProfileClassifieds
 
     LLUUID          mClassifiedToSelectOnLoad;
     bool            mClassifiedEditOnLoad;
+
+    boost::signals2::connection mRlvBehaviorConn;
 };
 
 
diff --git a/indra/newview/llpanelprofilepicks.cpp b/indra/newview/llpanelprofilepicks.cpp
index 43a02e2325b..17132fcd3d9 100644
--- a/indra/newview/llpanelprofilepicks.cpp
+++ b/indra/newview/llpanelprofilepicks.cpp
@@ -50,6 +50,8 @@
 #include "llviewergenericmessage.h" // send_generic_message
 #include "llviewerparcelmgr.h"
 #include "llviewerregion.h"
+#include "rlvactions.h"
+#include "rlvhandler.h"
 
 static LLPanelInjector<LLPanelProfilePicks> t_panel_profile_picks("panel_profile_picks");
 static LLPanelInjector<LLPanelProfilePick> t_panel_profile_pick("panel_profile_pick");
@@ -121,6 +123,10 @@ LLPanelProfilePicks::LLPanelProfilePicks()
 
 LLPanelProfilePicks::~LLPanelProfilePicks()
 {
+    if (mRlvBehaviorConn.connected())
+    {
+        mRlvBehaviorConn.disconnect();
+    }
 }
 
 void LLPanelProfilePicks::onOpen(const LLSD& key)
@@ -172,6 +178,8 @@ BOOL LLPanelProfilePicks::postBuild()
     mNewButton->setCommitCallback(boost::bind(&LLPanelProfilePicks::onClickNewBtn, this));
     mDeleteButton->setCommitCallback(boost::bind(&LLPanelProfilePicks::onClickDelete, this));
 
+    mRlvBehaviorConn = gRlvHandler.setBehaviourToggleCallback([this](ERlvBehaviour eBhvr, ERlvParamType eParam) { if (eBhvr == RLV_BHVR_SHOWLOC) updateButtons(); });
+
     return TRUE;
 }
 
@@ -346,7 +354,8 @@ void LLPanelProfilePicks::updateData()
 bool LLPanelProfilePicks::canAddNewPick()
 {
     return (!LLAgentPicksInfo::getInstance()->isPickLimitReached() &&
-        mTabContainer->getTabCount() < LLAgentPicksInfo::getInstance()->getMaxNumberOfPicks());
+        mTabContainer->getTabCount() < LLAgentPicksInfo::getInstance()->getMaxNumberOfPicks() &&
+        RlvActions::canShowLocation());
 }
 
 bool LLPanelProfilePicks::canDeletePick()
diff --git a/indra/newview/llpanelprofilepicks.h b/indra/newview/llpanelprofilepicks.h
index aeaa25bf8bc..558956e809d 100644
--- a/indra/newview/llpanelprofilepicks.h
+++ b/indra/newview/llpanelprofilepicks.h
@@ -86,6 +86,8 @@ class LLPanelProfilePicks
     LLButton*       mDeleteButton;
 
     LLUUID          mPickToSelectOnLoad;
+
+    boost::signals2::connection mRlvBehaviorConn;
 };
 
 
-- 
GitLab