#1638 Add permissions checks to GLTF Save As and Upload buttons (#1653)

master
Dave Parks 2024-06-07 09:51:32 -05:00 committed by GitHub
parent 40197e8949
commit 33ddedd6b5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 47 additions and 23 deletions

View File

@ -270,6 +270,7 @@ public:
inline bool allowModifyBy(const LLUUID &agent_id) const; inline bool allowModifyBy(const LLUUID &agent_id) const;
inline bool allowCopyBy(const LLUUID& agent_id) const; inline bool allowCopyBy(const LLUUID& agent_id) const;
inline bool allowMoveBy(const LLUUID& agent_id) const; inline bool allowMoveBy(const LLUUID& agent_id) const;
inline bool allowModifyBy(const LLUUID &agent_id, const LLUUID& group) const; inline bool allowModifyBy(const LLUUID &agent_id, const LLUUID& group) const;
inline bool allowCopyBy(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 allowMoveBy(const LLUUID &agent_id, const LLUUID &group) const;
@ -278,27 +279,11 @@ public:
// current owner is allowed to transfer to the specified agent id. // current owner is allowed to transfer to the specified agent id.
inline bool allowTransferTo(const LLUUID &agent_id) const; inline bool allowTransferTo(const LLUUID &agent_id) const;
// // Returns true if the object can exported by the given agent
// DEPRECATED. // (e.g. saved as a local .gltf file)
// // The current test should return true if the agent is the owner
// These return true if the given agent can perform the function. // AND the creator of the object.
// They also return true if the object isn't owned, or the inline bool allowExportBy(const LLUUID& agent_id) const;
// requesting agent is a system agent. See llpermissionsflags.h
// for bits.
//bool allowDeleteBy(const LLUUID& agent_id) const { return allowModifyBy(agent_id); }
//bool allowEditBy(const LLUUID& agent_id) const { return allowModifyBy(agent_id); }
// saves last owner and sets current owner
//bool setOwner(const LLUUID& agent, const LLUUID& owner);
// This method saves the last owner, sets the current owner to the
// one provided, and sets the base mask as indicated.
//bool setOwner(const LLUUID& agent, const LLUUID& owner, U32 new_base_mask);
// Attempt to set or clear the given bitmask. Returns true if you
// are allowed to modify the permissions. If you attempt to turn
// on bits not allowed by the base bits, the function will return
// true, but those bits will not be set.
//bool setGroupBits( const LLUUID& agent, bool set, PermissionMask bits);
//bool setEveryoneBits(const LLUUID& agent, bool set, PermissionMask bits);
// //
// MISC METHODS and OPERATORS // MISC METHODS and OPERATORS
@ -353,6 +338,11 @@ bool LLPermissions::allowMoveBy(const LLUUID& agent) const
return allowOperationBy(PERM_MOVE, agent, LLUUID::null); return allowOperationBy(PERM_MOVE, agent, LLUUID::null);
} }
bool LLPermissions::allowExportBy(const LLUUID& agent) const
{
return agent == mOwner && agent == mCreator;
}
bool LLPermissions::allowTransferTo(const LLUUID &agent_id) const bool LLPermissions::allowTransferTo(const LLUUID &agent_id) const
{ {
if (mIsGroupOwned) if (mIsGroupOwned)

View File

@ -368,6 +368,10 @@ namespace LL
// remove the bufferview at the given index // remove the bufferview at the given index
// updates all bufferview indices in this Asset as needed // updates all bufferview indices in this Asset as needed
void eraseBufferView(S32 bufferView); void eraseBufferView(S32 bufferView);
// return true if this Asset has been loaded as a local preview
// Local previews may be uploaded or exported to disk
bool isLocalPreview() { return !mFilename.empty(); }
}; };
Material::AlphaMode gltf_alpha_mode_to_enum(const std::string& alpha_mode); Material::AlphaMode gltf_alpha_mode_to_enum(const std::string& alpha_mode);

View File

@ -143,6 +143,7 @@
#include "llcleanup.h" #include "llcleanup.h"
#include "llviewershadermgr.h" #include "llviewershadermgr.h"
#include "gltfscenemanager.h" #include "gltfscenemanager.h"
#include "gltf/asset.h"
using namespace LLAvatarAppearanceDefines; using namespace LLAvatarAppearanceDefines;
@ -3325,6 +3326,33 @@ bool enable_gltf()
return enablegltf; return enablegltf;
} }
bool enable_gltf_save_as()
{
if (enable_gltf())
{
LLViewerObject* obj = LLSelectMgr::getInstance()->getSelection()->getFirstRootObject();
if (obj)
{
if (obj->mGLTFAsset && obj->mGLTFAsset->isLocalPreview())
{
return true;
}
LLPermissions* permissions = LLSelectMgr::getInstance()->findObjectPermissions(obj);
if (permissions)
{
return permissions->allowExportBy(gAgent.getID());
}
}
}
return false;
}
bool enable_gltf_upload()
{
return enable_gltf_save_as();
}
class LLSelfRemoveAllAttachments : public view_listener_t class LLSelfRemoveAllAttachments : public view_listener_t
{ {
bool handleEvent(const LLSD& userdata) bool handleEvent(const LLSD& userdata)
@ -10091,6 +10119,8 @@ void initialize_menus()
enable.add("EnableSelectInPathfindingCharacters", boost::bind(&enable_object_select_in_pathfinding_characters)); enable.add("EnableSelectInPathfindingCharacters", boost::bind(&enable_object_select_in_pathfinding_characters));
enable.add("Advanced.EnableErrorOSException", boost::bind(&enable_os_exception)); enable.add("Advanced.EnableErrorOSException", boost::bind(&enable_os_exception));
enable.add("EnableGLTF", boost::bind(&enable_gltf)); enable.add("EnableGLTF", boost::bind(&enable_gltf));
enable.add("EnableGLTFSaveAs", boost::bind(&enable_gltf_save_as));
enable.add("EnableGLTFUpload", boost::bind(&enable_gltf_upload));
view_listener_t::addMenu(new LLFloaterVisible(), "FloaterVisible"); view_listener_t::addMenu(new LLFloaterVisible(), "FloaterVisible");
view_listener_t::addMenu(new LLShowSidetrayPanel(), "ShowSidetrayPanel"); view_listener_t::addMenu(new LLShowSidetrayPanel(), "ShowSidetrayPanel");

View File

@ -2875,7 +2875,7 @@ function="World.EnvPreset"
label="Save As..." label="Save As..."
name="Save As..."> name="Save As...">
<menu_item_call.on_enable <menu_item_call.on_enable
function="EnableGLTF"/> function="EnableGLTFSaveAs"/>
<menu_item_call.on_click <menu_item_call.on_click
function="Advanced.ClickGLTFSaveAs" /> function="Advanced.ClickGLTFSaveAs" />
</menu_item_call> </menu_item_call>
@ -2883,7 +2883,7 @@ function="World.EnvPreset"
label="Upload..." label="Upload..."
name="Upload..."> name="Upload...">
<menu_item_call.on_enable <menu_item_call.on_enable
function="EnableGLTF"/> function="EnableGLTFUpload"/>
<menu_item_call.on_click <menu_item_call.on_click
function="Advanced.ClickGLTFUpload" /> function="Advanced.ClickGLTFUpload" />
</menu_item_call> </menu_item_call>