diff --git a/indra/llinventory/llpermissions.cpp b/indra/llinventory/llpermissions.cpp index 9568cd001..07aa44db3 100644 --- a/indra/llinventory/llpermissions.cpp +++ b/indra/llinventory/llpermissions.cpp @@ -34,13 +34,6 @@ #include "metapropertyt.h" #include "llsd.h" -///---------------------------------------------------------------------------- -/// Class LFSimFeatureHandlerInterface -///---------------------------------------------------------------------------- - -//static -LFSimFeatureHandlerInterface* LFSimFeatureHandlerInterface::sInstance; - ///---------------------------------------------------------------------------- /// Class LLPermissions ///---------------------------------------------------------------------------- @@ -482,14 +475,6 @@ BOOL LLPermissions::setNextOwnerBits(const LLUUID& agent, const LLUUID& group, B bool LLPermissions::allowOperationBy(PermissionBit op, const LLUUID& requester, const LLUUID& group) const { - // Singu extension: Make this function work for PERM_EXPORT operation (also on grids not supporting it). - if (op == PERM_EXPORT) - { - // Requester must always be the owner; on grids supporting PERM_EXPORT, that bit - // must be set in the mMaskEveryone mask, otherwise the requester must be the creator. - return (!mIsGroupOwned && (mOwner == requester) && - (mCreator == requester || (LFSimFeatureHandlerInterface::ifInstance()->simSupportsExport() && (mMaskEveryone & PERM_EXPORT)))); - } if(requester.isNull()) { // ...system making request @@ -1113,3 +1098,9 @@ LLPermissions ll_permissions_from_sd(const LLSD& sd_perm) rv.fix(); return rv; } + +bool LLPermissions::allowExportBy(LLUUID const& requester, bool supports_export) const +{ + return !mIsGroupOwned && requester == mOwner && (requester == mCreator || (supports_export && (mMaskEveryone & PERM_EXPORT))); +} + diff --git a/indra/llinventory/llpermissions.h b/indra/llinventory/llpermissions.h index 5986e0dd9..d4f736dc3 100644 --- a/indra/llinventory/llpermissions.h +++ b/indra/llinventory/llpermissions.h @@ -40,23 +40,6 @@ extern void mask_to_string(U32 mask, char* str); extern std::string mask_to_string(U32 mask); template class LLMetaClassT; -// Interface of LFSimFeatureHandler. -class LFSimFeatureHandlerInterface -{ -private: - // LFSimFeatureHandler is a singleton. - static LFSimFeatureHandlerInterface* sInstance; - -protected: - LFSimFeatureHandlerInterface(void) { sInstance = this; } - virtual ~LFSimFeatureHandlerInterface() { } - -public: - virtual bool simSupportsExport() const = 0; - - static LFSimFeatureHandlerInterface* ifInstance(void) { return sInstance; } -}; - //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Class LLPermissions // @@ -291,7 +274,13 @@ public: 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; // Singu extension. + + // Returns true if export is allowed. + // If a grid supports PERM_EXPORT then they should also check if (any) element + // has that bit set and allow exporting even when this function returns false, + // or pass supports_export as true, which causes to perform that check using + // these permissions. + bool allowExportBy(LLUUID const& requester, bool supports_export = false) const; // This somewhat specialized function is meant for testing if the // current owner is allowed to transfer to the specified agent id. @@ -391,11 +380,6 @@ bool LLPermissions::allowTransferTo(const LLUUID &agent_id) const } } -bool LLPermissions::allowExportBy(const LLUUID& agent) const -{ - return allowOperationBy(PERM_EXPORT, agent); -} - //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Class LLAggregatePermissions // diff --git a/indra/newview/awavefront.cpp b/indra/newview/awavefront.cpp index 816895e91..635d9b9a9 100644 --- a/indra/newview/awavefront.cpp +++ b/indra/newview/awavefront.cpp @@ -30,6 +30,7 @@ #include "llnotificationsutil.h" // newview includes +#include "lfsimfeaturehandler.h" #include "llavatarappearancedefines.h" #include "llface.h" #include "llvoavatar.h" @@ -219,6 +220,14 @@ void WavefrontSaver::Add(const LLViewerObject* some_vo) } namespace { + // Identical to the one in daeexport.cpp. + bool can_export_node(const LLSelectNode* node) + { + LLPermissions* perms = node->mPermissions; // Is perms ever NULL? + // This tests the PERM_EXPORT bit too, which is not really necessary (just checking if it's set + // on the root prim would suffice), but also isn't hurting. + return perms && perms->allowExportBy(gAgentID, LFSimFeatureHandler::instance().simSupportsExport()); + } class LFSaveSelectedObjects : public view_listener_t { bool handleEvent(LLPointer event, const LLSD& userdata) @@ -233,7 +242,7 @@ namespace { total++; LLSelectNode* node = *iter; - if (!node->mPermissions->allowExportBy(gAgentID)) continue; + if (!can_export_node(node)) continue; included++; wfsaver->Add(node->getObject()); } @@ -316,7 +325,7 @@ void WavefrontSaver::Add(const LLVOAvatar* av_vo) //adds attachments, too! if (!c) continue; if (const LLSelectNode* n = LLSelectMgr::getInstance()->getSelection()->findNode(const_cast(c))) { - if (!n->mPermissions->allowExportBy(gAgentID)) continue; + if (!can_export_node(n)) continue; } else continue; const LLVolume* vol = c->getVolume(); diff --git a/indra/newview/daeexport.cpp b/indra/newview/daeexport.cpp index 145261d19..f37a6e5a5 100644 --- a/indra/newview/daeexport.cpp +++ b/indra/newview/daeexport.cpp @@ -65,6 +65,7 @@ #include "boost/date_time/posix_time/posix_time.hpp" // newview includes +#include "lfsimfeaturehandler.h" #include "llface.h" #include "llvovolume.h" @@ -116,6 +117,15 @@ namespace DAEExportUtil } } + // Identical to the one in awavefront.cpp + bool can_export_node(const LLSelectNode* node) + { + LLPermissions* perms = node->mPermissions; // Is perms ever NULL? + // This tests the PERM_EXPORT bit too, which is not really necessary (just checking if it's set + // on the root prim would suffice), but also isn't hurting. + return perms && perms->allowExportBy(gAgentID, LFSimFeatureHandler::instance().simSupportsExport()); + } + void saveSelectedObject() { static const std::string file_ext = ".dae"; @@ -131,7 +141,7 @@ namespace DAEExportUtil { total++; LLSelectNode* node = *iter; - if (!node->mPermissions->allowExportBy(gAgentID) || !node->getObject()->getVolume()) continue; + if (!can_export_node(node) || !node->getObject()->getVolume()) continue; included++; daesaver->Add(node->getObject(), node->mName); } diff --git a/indra/newview/lfsimfeaturehandler.h b/indra/newview/lfsimfeaturehandler.h index 062a55898..070d6ba1e 100644 --- a/indra/newview/lfsimfeaturehandler.h +++ b/indra/newview/lfsimfeaturehandler.h @@ -19,7 +19,6 @@ #define LFSIMFEATUREHANDLER_H #include "llsingleton.h" -#include "llpermissions.h" template class SignaledType @@ -46,7 +45,7 @@ private: Type mValue; }; -class LFSimFeatureHandler : public LFSimFeatureHandlerInterface, public LLSingleton +class LFSimFeatureHandler : public LLSingleton { protected: friend class LLSingleton; @@ -60,7 +59,7 @@ public: boost::signals2::connection setSupportsExportCallback(const boost::signals2::signal::slot_type& slot); // Accessors - /*virtual*/ bool simSupportsExport() const { return mSupportsExport; } + bool simSupportsExport() const { return mSupportsExport; } private: // SignaledTypes diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index 924164a26..50c8bc5cc 100644 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -3165,8 +3165,7 @@ BOOL LLAgent::allowOperation(PermissionBit op, U8 god_minimum) { // Check god level. - // Singu note: We should never get here for PERM_EXPORT really, but if we do - then Gods are not above the law. - if (getGodLevel() >= god_minimum && PERM_EXPORT != op) return TRUE; + if (getGodLevel() >= god_minimum) return TRUE; if (!perm.isOwned()) return FALSE; @@ -3188,8 +3187,7 @@ BOOL LLAgent::allowOperation(PermissionBit op, else { // Check for granted mod permissions. - // Singu note: do not allow proxy powers for exporting. - if ((PERM_OWNER != op && PERM_EXPORT != op) && isGrantedProxy(perm)) + if ((PERM_OWNER != op) && isGrantedProxy(perm)) { agent_proxy = owner_id; } diff --git a/indra/newview/llpaneleditwearable.cpp b/indra/newview/llpaneleditwearable.cpp index aef365e7b..81d807259 100644 --- a/indra/newview/llpaneleditwearable.cpp +++ b/indra/newview/llpaneleditwearable.cpp @@ -26,6 +26,7 @@ #include "llviewerprecompiledheaders.h" +#include "lfsimfeaturehandler.h" #include "llpaneleditwearable.h" #include "llpanel.h" #include "llviewerwearable.h" @@ -1422,7 +1423,8 @@ bool LLPanelEditWearable::updatePermissions() // Exporting (of slider values) is allowed when the wearable is full perm, and owned by and created by the user. // Of course, only modifiable is enough for the user to write down the values and enter them else where... but why make it easy for them to break the ToS. - if (is_complete && item->getPermissions().allowExportBy(gAgent.getID())) + if (is_complete && + (item->getPermissions().allowExportBy(gAgent.getID(), LFSimFeatureHandler::instance().simSupportsExport()))) { can_export = true; } diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 7d84af13a..7bd68ad4a 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -5926,12 +5926,6 @@ BOOL LLSelectNode::allowOperationOnNode(PermissionBit op, U64 group_proxy_power) } } - if (PERM_EXPORT == op) - { - // No proxy or god powers allowed. - return mPermissions->allowExportBy(gAgent.getID()); - } - // Calculate proxy_agent_id and group_id to use for permissions checks. // proxy_agent_id may be set to the object owner through group powers. // group_id can only be set to the object's group, if the agent is in that group. diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index e384b8bdb..0031f2a87 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -54,6 +54,7 @@ #include "llappearancemgr.h" #include "llagentwearables.h" #include "jcfloaterareasearch.h" +#include "lfsimfeaturehandler.h" #include "llagentpilot.h" #include "llcompilequeue.h" @@ -2884,22 +2885,22 @@ class LLObjectEnableExport : public view_listener_t { bool handleEvent(LLPointer event, const LLSD& userdata) { - bool new_value = !!LLSelectMgr::getInstance()->getSelection()->getPrimaryObject(); - if (new_value) + LLPermissions perms; + bool new_value = LLSelectMgr::getInstance()->selectGetPermissions(perms) && perms.isOwned(); // At least one object, accumulated permissions of all objects. + bool supports_export = LFSimFeatureHandler::instance().simSupportsExport(); + if (new_value && !(supports_export && (perms.getMaskEveryone() & PERM_EXPORT))) // No need to call allowExportBy if PERM_EXPORT is set on (all) root objects. { struct ff : public LLSelectedNodeFunctor { - ff(const LLSD& data) : LLSelectedNodeFunctor(), userdata(data) - { - } - const LLSD& userdata; + bool mSupportsExport; + ff(bool supports_export) : mSupportsExport(supports_export) { } virtual bool apply(LLSelectNode* node) { - return node->mPermissions->allowExportBy(gAgent.getID()); + return node->mPermissions->allowExportBy(gAgent.getID(), mSupportsExport); } }; - ff * the_ff = new ff(userdata); - new_value = LLSelectMgr::getInstance()->getSelection()->applyToNodes(the_ff, false); + ff the_ff(supports_export); + new_value = LLSelectMgr::getInstance()->getSelection()->applyToNodes(&the_ff, false); } gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value); return true; diff --git a/indra/newview/llviewerobjectbackup.cpp b/indra/newview/llviewerobjectbackup.cpp index 932dde3a6..795426a2d 100644 --- a/indra/newview/llviewerobjectbackup.cpp +++ b/indra/newview/llviewerobjectbackup.cpp @@ -79,6 +79,7 @@ #include "llviewerwindow.h" #include "hippogridmanager.h" +#include "lfsimfeaturehandler.h" #include "llviewerobjectbackup.h" @@ -398,7 +399,7 @@ void LLObjectBackup::exportObject_continued(AIFilePicker* filepicker) bool LLObjectBackup::validatePerms(const LLPermissions *item_permissions) { - return item_permissions->allowExportBy(gAgent.getID()); + return item_permissions->allowExportBy(gAgent.getID(), LFSimFeatureHandler::instance().simSupportsExport()); } // So far, only Second Life forces TPVs to verify the creator for textures...