From 4515e0e8e2808e9f072435b9d5dd316909002ddd Mon Sep 17 00:00:00 2001
From: Rye Mutt <rye@alchemyviewer.org>
Date: Mon, 2 May 2022 18:38:40 -0400
Subject: [PATCH] Start to introduce export perm support for opensim

---
 indra/llinventory/llpermissions.cpp    | 12 +++++++++++-
 indra/llinventory/llpermissions.h      |  6 ++++++
 indra/llinventory/llpermissionsflags.h |  2 ++
 indra/newview/llviewerregion.cpp       | 10 ++++++++++
 indra/newview/llviewerregion.h         |  2 ++
 5 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/indra/llinventory/llpermissions.cpp b/indra/llinventory/llpermissions.cpp
index 0359d2f554c..0cd02d4ed43 100644
--- a/indra/llinventory/llpermissions.cpp
+++ b/indra/llinventory/llpermissions.cpp
@@ -986,7 +986,17 @@ void mask_to_string(U32 mask, char* str)
 	else
 	{
 		*str = ' ';
-	}	
+	}
+	str++;
+	
+	if (mask & PERM_EXPORT)
+	{
+		*str = 'X';
+	}
+	else
+	{
+		*str = ' ';
+	}
 	str++;	
 	*str = '\0';
 }
diff --git a/indra/llinventory/llpermissions.h b/indra/llinventory/llpermissions.h
index 27252f7b97d..2d8d6549dec 100644
--- a/indra/llinventory/llpermissions.h
+++ b/indra/llinventory/llpermissions.h
@@ -273,6 +273,7 @@ class LLPermissions
 	inline bool allowModifyBy(const LLUUID &agent_id, const LLUUID& group) const;
 	inline bool allowCopyBy(const LLUUID& agent_id, const LLUUID& group) const;
 	inline bool allowMoveBy(const LLUUID &agent_id, const LLUUID &group) const;
+	inline bool allowExportBy(const LLUUID& agent_id) const;
 
 	// This somewhat specialized function is meant for testing if the
 	// current owner is allowed to transfer to the specified agent id.
@@ -353,6 +354,11 @@ bool LLPermissions::allowMoveBy(const LLUUID& agent) const
 	return allowOperationBy(PERM_MOVE, agent, LLUUID::null);
 }
 
+bool LLPermissions::allowExportBy(const LLUUID& agent) const
+{
+	return ((mCreator == agent) ? true : (allowOperationBy(PERM_EXPORT, agent, LLUUID::null)));
+}
+
 bool LLPermissions::allowTransferTo(const LLUUID &agent_id) const
 {
 	if (mIsGroupOwned)
diff --git a/indra/llinventory/llpermissionsflags.h b/indra/llinventory/llpermissionsflags.h
index 9ecf465c8c0..ca7d63259d4 100644
--- a/indra/llinventory/llpermissionsflags.h
+++ b/indra/llinventory/llpermissionsflags.h
@@ -48,6 +48,8 @@ const PermissionBit PERM_COPY				= (1 << 15); // 0x00008000
 
 // parcels, allow entry, deprecated
 //const PermissionBit PERM_ENTER			= (1 << 16); // 0x00010000
+// objects, allow export (opensim)
+const PermissionBit PERM_EXPORT				= (1 << 16); // 0x00010000
 
 // parcels, allow terraform, deprecated
 //const PermissionBit PERM_TERRAFORM		= (1 << 17); // 0x00020000
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 37e89472abd..9cf7eeb1cda 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -3701,6 +3701,16 @@ std::string LLViewerRegion::getSimHostName()
 	return std::string("...");
 }
 
+bool LLViewerRegion::getRegionAllowsExport() const
+{
+	if (mSimulatorFeatures.has("OpenSimExtras")
+		&& mSimulatorFeatures["OpenSimExtras"].has("ExportSupported"))
+	{
+		return mSimulatorFeatures["OpenSimExtras"]["ExportSupported"].asBoolean();
+	}
+	return false;
+}
+
 std::string LLViewerRegion::getAvatarPickerURL() const
 {
 	std::string url;
diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h
index 5a5ce305a5f..151071a478e 100644
--- a/indra/newview/llviewerregion.h
+++ b/indra/newview/llviewerregion.h
@@ -412,6 +412,8 @@ class LLViewerRegion final : public LLCapabilityProvider // implements this inte
 	 * @name OpenSimExtras Simulator Features capability
 	 * @{
 	 */
+	/// Get region allows export
+	bool getRegionAllowsExport() const;
 	/// Avatar picker url
 	std::string getAvatarPickerURL() const;
 	/// Destination guide url
-- 
GitLab