[FIXED] Items can be pasted from locked folders into unlocked folders and vice versa

-> rather than blocking the context menu item we'll show a blocked notification toast to help the user identify why their paste is failing

--HG--
branch : RLVa
meow-7.2.2
Kitty Barnett 2016-11-12 00:28:09 +01:00
parent e5beb88409
commit 59500ff77f
5 changed files with 63 additions and 0 deletions

View File

@ -3540,6 +3540,15 @@ void LLFolderBridge::perform_pasteFromClipboard()
LLNotificationsUtil::add("StockPasteFailed", subs);
return;
}
// [RLVa:KB] - Checked: RLVa-2.1.0
if ( ((item) && (!RlvActions::canPaste(item, dest_folder))) || ((cat) && (!RlvActions::canPaste(cat, dest_folder))) )
{
RlvActions::notifyBlocked(RLV_STRING_BLOCKED_INVFOLDER);
return;
}
// [/RLVa:KB]
}
}

View File

@ -23,6 +23,7 @@
#include "rlvactions.h"
#include "rlvhelper.h"
#include "rlvhandler.h"
#include "rlvinventory.h"
// ============================================================================
// Camera
@ -216,6 +217,26 @@ bool RlvActions::canShowNearbyAgents()
return !gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNEARBY);
}
// ============================================================================
// Inventory
//
bool RlvActions::canPaste(const LLInventoryCategory* pSourceCat, const LLInventoryCategory* pDestCat)
{
// The user can paste the specified object into the destination if:
// - the source and destination are subject to the same lock type (or none at all) => NOTE: this happens to be the same logic we use for moving
return (isRlvEnabled()) && (pSourceCat) && (pDestCat) &&
((!RlvFolderLocks::instance().hasLockedFolder(RLV_LOCK_ANY)) || (RlvFolderLocks::instance().canMoveFolder(pSourceCat->getUUID(), pDestCat->getUUID())));
}
bool RlvActions::canPaste(const LLInventoryItem* pSourceItem, const LLInventoryCategory* pDestCat)
{
// The user can paste the specified object into the destination if:
// - the source and destination are subject to the same lock type (or none at all) => NOTE: this happens to be the same logic we use for moving
return (isRlvEnabled()) && (pSourceItem) && (pDestCat) &&
((!RlvFolderLocks::instance().hasLockedFolder(RLV_LOCK_ANY)) || (RlvFolderLocks::instance().canMoveItem(pSourceItem->getUUID(), pDestCat->getUUID())));
}
// ============================================================================
// Movement
//
@ -386,4 +407,9 @@ bool RlvActions::isRlvEnabled()
return RlvHandler::isEnabled();
}
void RlvActions::notifyBlocked(const std::string& strNotifcation, const LLSD& sdArgs)
{
RlvUtil::notifyBlocked(strNotifcation, sdArgs);
}
// ============================================================================

View File

@ -19,6 +19,13 @@
#include "rlvdefines.h"
// ============================================================================
// Forward declarations
//
class LLInventoryCategory;
class LLInventoryItem;
// ============================================================================
// RlvActions class declaration - developer-friendly non-RLVa code facing class, use in lieu of RlvHandler whenever possible
//
@ -122,6 +129,16 @@ protected:
// Backwards logic so that we can initialize to 0 and it won't block when we forget to/don't check if RLVa is disabled
static bool s_BlockNamesContexts[SNC_COUNT];
// =========
// Inventory
// =========
public:
/*
* Returns true if the user is allowed to paste the specified inventory object (item/folder) into the specified destination category (within user inventory)
*/
static bool canPaste(const LLInventoryCategory* pSourceCat, const LLInventoryCategory* pDestCat);
static bool canPaste(const LLInventoryItem* pSourceItem, const LLInventoryCategory* pDestCat);
// ========
// Movement
// ========
@ -232,6 +249,11 @@ public:
* Convenience function to check if RLVa is enabled without having to include rlvhandler.h
*/
static bool isRlvEnabled();
/*
* Shows one of the blocked toast notifications (see rlva_strings.xml)
*/
static void notifyBlocked(const std::string& strNotifcation, const LLSD& sdArgs = LLSD());
};
// ============================================================================

View File

@ -374,6 +374,7 @@ enum ERlvAttachGroupType
#define RLV_STRING_BLOCKED_AUTOPILOT "blocked_autopilot"
#define RLV_STRING_BLOCKED_GENERIC "blocked_generic"
#define RLV_STRING_BLOCKED_GROUPCHANGE "blocked_groupchange"
#define RLV_STRING_BLOCKED_INVFOLDER "blocked_invfolder"
#define RLV_STRING_BLOCKED_PERMATTACH "blocked_permattach"
#define RLV_STRING_BLOCKED_PERMTELEPORT "blocked_permteleport"
#define RLV_STRING_BLOCKED_RECVIM "blocked_recvim"

View File

@ -61,6 +61,11 @@
<key>value</key>
<string>Unable to change your active group due to an RLV restriction; switching back to [GROUP_SLURL]</string>
</map>
<key>blocked_invfolder</key>
<map>
<key>value</key>
<string>Unable to perform the requested inventory action due to an RLV locked folder.</string>
</map>
<key>blocked_nearby</key>
<map>
<key>value</key>