From 8c16ec2b53153a10f40181e0e8108d24331451d4 Mon Sep 17 00:00:00 2001 From: Ansariel Date: Tue, 20 Feb 2024 13:57:07 +0100 Subject: Convert BOOL to bool in LLControlGroup and related classes --- indra/newview/llfloaterbulkpermission.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/llfloaterbulkpermission.cpp') diff --git a/indra/newview/llfloaterbulkpermission.cpp b/indra/newview/llfloaterbulkpermission.cpp index abc9cdbcc2..392866682d 100644 --- a/indra/newview/llfloaterbulkpermission.cpp +++ b/indra/newview/llfloaterbulkpermission.cpp @@ -204,10 +204,10 @@ void LLFloaterBulkPermission::onCloseBtn() void LLFloaterBulkPermission::onCommitCopy() { // Implements fair use - BOOL copyable = gSavedSettings.getBOOL("BulkChangeNextOwnerCopy"); + bool copyable = gSavedSettings.getBOOL("BulkChangeNextOwnerCopy"); if(!copyable) { - gSavedSettings.setBOOL("BulkChangeNextOwnerTransfer", TRUE); + gSavedSettings.setBOOL("BulkChangeNextOwnerTransfer", true); } LLCheckBoxCtrl* xfer =getChild("next_owner_transfer"); xfer->setEnabled(copyable); -- cgit v1.2.3 From a5261a5fa8fad810ecb5c260d92c3e771822bf58 Mon Sep 17 00:00:00 2001 From: Ansariel Date: Tue, 20 Feb 2024 23:46:23 +0100 Subject: Convert BOOL to bool in llui --- indra/newview/llfloaterbulkpermission.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/llfloaterbulkpermission.cpp') diff --git a/indra/newview/llfloaterbulkpermission.cpp b/indra/newview/llfloaterbulkpermission.cpp index 392866682d..d70b7996d3 100644 --- a/indra/newview/llfloaterbulkpermission.cpp +++ b/indra/newview/llfloaterbulkpermission.cpp @@ -64,7 +64,7 @@ LLFloaterBulkPermission::LLFloaterBulkPermission(const LLSD& seed) mCommitCallbackRegistrar.add("BulkPermission.CommitCopy", boost::bind(&LLFloaterBulkPermission::onCommitCopy, this)); } -BOOL LLFloaterBulkPermission::postBuild() +bool LLFloaterBulkPermission::postBuild() { mBulkChangeIncludeAnimations = gSavedSettings.getBOOL("BulkChangeIncludeAnimations"); mBulkChangeIncludeBodyParts = gSavedSettings.getBOOL("BulkChangeIncludeBodyParts"); @@ -89,7 +89,7 @@ BOOL LLFloaterBulkPermission::postBuild() { mBulkChangeNextOwnerTransfer = true; } - return TRUE; + return true; } void LLFloaterBulkPermission::doApply() -- cgit v1.2.3 From 60d3dd98a44230c21803c1606552ee098ed9fa7c Mon Sep 17 00:00:00 2001 From: Ansariel Date: Wed, 21 Feb 2024 21:05:14 +0100 Subject: Convert remaining BOOL to bool --- indra/newview/llfloaterbulkpermission.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'indra/newview/llfloaterbulkpermission.cpp') diff --git a/indra/newview/llfloaterbulkpermission.cpp b/indra/newview/llfloaterbulkpermission.cpp index d70b7996d3..10478d6bcb 100644 --- a/indra/newview/llfloaterbulkpermission.cpp +++ b/indra/newview/llfloaterbulkpermission.cpp @@ -53,7 +53,7 @@ LLFloaterBulkPermission::LLFloaterBulkPermission(const LLSD& seed) : LLFloater(seed), - mDone(FALSE) + mDone(false) { mID.generate(); mCommitCallbackRegistrar.add("BulkPermission.Ok", boost::bind(&LLFloaterBulkPermission::onOkBtn, this)); @@ -120,7 +120,7 @@ void LLFloaterBulkPermission::doApply() } else { - mDone = FALSE; + mDone = false; if (!start()) { LL_WARNS() << "Unexpected bulk permission change failure." << LL_ENDL; @@ -213,7 +213,7 @@ void LLFloaterBulkPermission::onCommitCopy() xfer->setEnabled(copyable); } -BOOL LLFloaterBulkPermission::start() +bool LLFloaterBulkPermission::start() { // note: number of top-level objects to modify is mObjectIDs.size(). getChild("queue output")->setCommentText(getString("start_text")); @@ -221,10 +221,10 @@ BOOL LLFloaterBulkPermission::start() } // Go to the next object and start if found. Returns false if no objects left, true otherwise. -BOOL LLFloaterBulkPermission::nextObject() +bool LLFloaterBulkPermission::nextObject() { S32 count; - BOOL successful_start = FALSE; + bool successful_start = false; do { count = mObjectIDs.size(); @@ -240,17 +240,17 @@ BOOL LLFloaterBulkPermission::nextObject() if(isDone() && !mDone) { getChild("queue output")->setCommentText(getString("done_text")); - mDone = TRUE; + mDone = true; } return successful_start; } // Pop the top object off of the queue. -// Return TRUE if the queue has started, otherwise FALSE. -BOOL LLFloaterBulkPermission::popNext() +// Return true if the queue has started, otherwise false. +bool LLFloaterBulkPermission::popNext() { // get the head element from the container, and attempt to get its inventory. - BOOL rv = FALSE; + bool rv = false; S32 count = mObjectIDs.size(); if(mCurrentObjectID.isNull() && (count > 0)) { @@ -264,7 +264,7 @@ BOOL LLFloaterBulkPermission::popNext() LLUUID* id = new LLUUID(mID); registerVOInventoryListener(obj,id); requestVOInventory(); - rv = TRUE; + rv = true; } else { @@ -276,7 +276,7 @@ BOOL LLFloaterBulkPermission::popNext() } -void LLFloaterBulkPermission::doCheckUncheckAll(BOOL check) +void LLFloaterBulkPermission::doCheckUncheckAll(bool check) { gSavedSettings.setBOOL("BulkChangeIncludeAnimations", check); gSavedSettings.setBOOL("BulkChangeIncludeBodyParts" , check); @@ -352,7 +352,7 @@ void LLFloaterBulkPermission::handleInventory(LLViewerObject* viewer_obj, LLInve perm.setMaskEveryone(LLFloaterPerms::getEveryonePerms("BulkChange")); perm.setMaskGroup(LLFloaterPerms::getGroupPerms("BulkChange")); new_item->setPermissions(perm); // here's the beef - updateInventory(object,new_item,TASK_INVENTORY_ITEM_KEY,FALSE); + updateInventory(object,new_item,TASK_INVENTORY_ITEM_KEY,false); //status_text.setArg("[STATUS]", getString("status_ok_text")); status_text.setArg("[STATUS]", ""); } -- cgit v1.2.3 From e2e37cced861b98de8c1a7c9c0d3a50d2d90e433 Mon Sep 17 00:00:00 2001 From: Ansariel Date: Wed, 22 May 2024 21:25:21 +0200 Subject: Fix line endlings --- indra/newview/llfloaterbulkpermission.cpp | 834 +++++++++++++++--------------- 1 file changed, 417 insertions(+), 417 deletions(-) (limited to 'indra/newview/llfloaterbulkpermission.cpp') diff --git a/indra/newview/llfloaterbulkpermission.cpp b/indra/newview/llfloaterbulkpermission.cpp index c57975194b..497fe3b9ba 100644 --- a/indra/newview/llfloaterbulkpermission.cpp +++ b/indra/newview/llfloaterbulkpermission.cpp @@ -1,417 +1,417 @@ -/** - * @file llfloaterbulkpermissions.cpp - * @author Michelle2 Zenovka - * @brief A floater which allows task inventory item's properties to be changed on mass. - * - * $LicenseInfo:firstyear=2008&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - - -#include "llviewerprecompiledheaders.h" -#include "llfloaterbulkpermission.h" -#include "llfloaterperms.h" // for utilities -#include "llagent.h" -#include "llchat.h" -#include "llinventorydefines.h" -#include "llviewerwindow.h" -#include "llviewerobject.h" -#include "llviewerobjectlist.h" -#include "llviewerregion.h" -#include "llviewercontrol.h" -#include "llviewerinventory.h" -#include "llviewerobject.h" -#include "llviewerregion.h" -#include "llresmgr.h" -#include "llbutton.h" -#include "lldir.h" -#include "llviewerstats.h" -#include "lluictrlfactory.h" -#include "llselectmgr.h" -#include "llcheckboxctrl.h" - -#include "roles_constants.h" // for GP_OBJECT_MANIPULATE - - -LLFloaterBulkPermission::LLFloaterBulkPermission(const LLSD& seed) -: LLFloater(seed), - mDone(false) -{ - mID.generate(); - mCommitCallbackRegistrar.add("BulkPermission.Ok", boost::bind(&LLFloaterBulkPermission::onOkBtn, this)); - mCommitCallbackRegistrar.add("BulkPermission.Apply", boost::bind(&LLFloaterBulkPermission::onApplyBtn, this)); - mCommitCallbackRegistrar.add("BulkPermission.Close", boost::bind(&LLFloaterBulkPermission::onCloseBtn, this)); - mCommitCallbackRegistrar.add("BulkPermission.CheckAll", boost::bind(&LLFloaterBulkPermission::onCheckAll, this)); - mCommitCallbackRegistrar.add("BulkPermission.UncheckAll", boost::bind(&LLFloaterBulkPermission::onUncheckAll, this)); - mCommitCallbackRegistrar.add("BulkPermission.CommitCopy", boost::bind(&LLFloaterBulkPermission::onCommitCopy, this)); -} - -bool LLFloaterBulkPermission::postBuild() -{ - mBulkChangeIncludeAnimations = gSavedSettings.getBOOL("BulkChangeIncludeAnimations"); - mBulkChangeIncludeBodyParts = gSavedSettings.getBOOL("BulkChangeIncludeBodyParts"); - mBulkChangeIncludeClothing = gSavedSettings.getBOOL("BulkChangeIncludeClothing"); - mBulkChangeIncludeGestures = gSavedSettings.getBOOL("BulkChangeIncludeGestures"); - mBulkChangeIncludeNotecards = gSavedSettings.getBOOL("BulkChangeIncludeNotecards"); - mBulkChangeIncludeObjects = gSavedSettings.getBOOL("BulkChangeIncludeObjects"); - mBulkChangeIncludeScripts = gSavedSettings.getBOOL("BulkChangeIncludeScripts"); - mBulkChangeIncludeSounds = gSavedSettings.getBOOL("BulkChangeIncludeSounds"); - mBulkChangeIncludeTextures = gSavedSettings.getBOOL("BulkChangeIncludeTextures"); - mBulkChangeIncludeSettings = gSavedSettings.getBOOL("BulkChangeIncludeSettings"); - mBulkChangeIncludeMaterials = gSavedSettings.getBOOL("BulkChangeIncludeMaterials"); - - mBulkChangeShareWithGroup = gSavedSettings.getBOOL("BulkChangeShareWithGroup"); - mBulkChangeEveryoneCopy = gSavedSettings.getBOOL("BulkChangeEveryoneCopy"); - mBulkChangeNextOwnerModify = gSavedSettings.getBOOL("BulkChangeNextOwnerModify"); - mBulkChangeNextOwnerCopy = gSavedSettings.getBOOL("BulkChangeNextOwnerCopy"); - mBulkChangeNextOwnerTransfer = gSavedSettings.getBOOL("BulkChangeNextOwnerTransfer"); - - // fix invalid permissions case (in case initial settings were generated by a viewer affected by MAINT-3339) - if( !mBulkChangeNextOwnerTransfer && !mBulkChangeEveryoneCopy) - { - mBulkChangeNextOwnerTransfer = true; - } - return true; -} - -void LLFloaterBulkPermission::doApply() -{ - // Inspects a stream of selected object contents and adds modifiable ones to the given array. - class ModifiableGatherer : public LLSelectedNodeFunctor - { - public: - ModifiableGatherer(std::vector& q) : mQueue(q) { mQueue.reserve(32); } - virtual bool apply(LLSelectNode* node) - { - if( node->allowOperationOnNode(PERM_MODIFY, GP_OBJECT_MANIPULATE) ) - { - mQueue.push_back(node->getObject()->getID()); - } - return true; - } - private: - std::vector& mQueue; - }; - LLScrollListCtrl* list = getChild("queue output"); - list->deleteAllItems(); - ModifiableGatherer gatherer(mObjectIDs); - LLSelectMgr::getInstance()->getSelection()->applyToNodes(&gatherer); - if(mObjectIDs.empty()) - { - list->setCommentText(getString("nothing_to_modify_text")); - } - else - { - mDone = false; - if (!start()) - { - LL_WARNS() << "Unexpected bulk permission change failure." << LL_ENDL; - } - } -} - - -// This is the callback method for the viewer object currently being -// worked on. -// NOT static, virtual! -void LLFloaterBulkPermission::inventoryChanged(LLViewerObject* viewer_object, - LLInventoryObject::object_list_t* inv, - S32, - void* q_id) -{ - //LL_INFOS() << "changed object: " << viewer_object->getID() << LL_ENDL; - - //Remove this listener from the object since its - //listener callback is now being executed. - - //We remove the listener here because the function - //removeVOInventoryListener removes the listener from a ViewerObject - //which it internally stores. - - //If we call this further down in the function, calls to handleInventory - //and nextObject may update the interally stored viewer object causing - //the removal of the incorrect listener from an incorrect object. - - //Fixes SL-6119:Recompile scripts fails to complete - removeVOInventoryListener(); - - if (viewer_object && inv && (viewer_object->getID() == mCurrentObjectID) ) - { - handleInventory(viewer_object, inv); - } - else - { - // something went wrong... - // note that we're not working on this one, and move onto the - // next object in the list. - LL_WARNS() << "No inventory for " << mCurrentObjectID << LL_ENDL; - nextObject(); - } -} - -void LLFloaterBulkPermission::onOkBtn() -{ - doApply(); - closeFloater(); -} - -void LLFloaterBulkPermission::onApplyBtn() -{ - doApply(); -} - -void LLFloaterBulkPermission::onCloseBtn() -{ - gSavedSettings.setBOOL("BulkChangeIncludeAnimations", mBulkChangeIncludeAnimations); - gSavedSettings.setBOOL("BulkChangeIncludeBodyParts", mBulkChangeIncludeBodyParts); - gSavedSettings.setBOOL("BulkChangeIncludeClothing", mBulkChangeIncludeClothing); - gSavedSettings.setBOOL("BulkChangeIncludeGestures", mBulkChangeIncludeGestures); - gSavedSettings.setBOOL("BulkChangeIncludeNotecards", mBulkChangeIncludeNotecards); - gSavedSettings.setBOOL("BulkChangeIncludeObjects", mBulkChangeIncludeObjects); - gSavedSettings.setBOOL("BulkChangeIncludeScripts", mBulkChangeIncludeScripts); - gSavedSettings.setBOOL("BulkChangeIncludeSounds", mBulkChangeIncludeSounds); - gSavedSettings.setBOOL("BulkChangeIncludeTextures", mBulkChangeIncludeTextures); - gSavedSettings.setBOOL("BulkChangeIncludeSettings", mBulkChangeIncludeSettings); - gSavedSettings.setBOOL("BulkChangeIncludeMaterials", mBulkChangeIncludeMaterials); - - gSavedSettings.setBOOL("BulkChangeShareWithGroup", mBulkChangeShareWithGroup); - gSavedSettings.setBOOL("BulkChangeEveryoneCopy", mBulkChangeEveryoneCopy); - gSavedSettings.setBOOL("BulkChangeNextOwnerModify", mBulkChangeNextOwnerModify); - gSavedSettings.setBOOL("BulkChangeNextOwnerCopy", mBulkChangeNextOwnerCopy); - gSavedSettings.setBOOL("BulkChangeNextOwnerTransfer", mBulkChangeNextOwnerTransfer); - closeFloater(); -} - -//static -void LLFloaterBulkPermission::onCommitCopy() -{ - // Implements fair use - bool copyable = gSavedSettings.getBOOL("BulkChangeNextOwnerCopy"); - if(!copyable) - { - gSavedSettings.setBOOL("BulkChangeNextOwnerTransfer", true); - } - LLCheckBoxCtrl* xfer =getChild("next_owner_transfer"); - xfer->setEnabled(copyable); -} - -bool LLFloaterBulkPermission::start() -{ - // note: number of top-level objects to modify is mObjectIDs.size(). - getChild("queue output")->setCommentText(getString("start_text")); - return nextObject(); -} - -// Go to the next object and start if found. Returns false if no objects left, true otherwise. -bool LLFloaterBulkPermission::nextObject() -{ - S32 count; - bool successful_start = false; - do - { - count = mObjectIDs.size(); - //LL_INFOS() << "Objects left to process = " << count << LL_ENDL; - mCurrentObjectID.setNull(); - if(count > 0) - { - successful_start = popNext(); - //LL_INFOS() << (successful_start ? "successful" : "unsuccessful") << LL_ENDL; - } - } while((mObjectIDs.size() > 0) && !successful_start); - - if(isDone() && !mDone) - { - getChild("queue output")->setCommentText(getString("done_text")); - mDone = true; - } - return successful_start; -} - -// Pop the top object off of the queue. -// Return true if the queue has started, otherwise false. -bool LLFloaterBulkPermission::popNext() -{ - // get the head element from the container, and attempt to get its inventory. - bool rv = false; - S32 count = mObjectIDs.size(); - if(mCurrentObjectID.isNull() && (count > 0)) - { - mCurrentObjectID = mObjectIDs.at(0); - //LL_INFOS() << "mCurrentID: " << mCurrentObjectID << LL_ENDL; - mObjectIDs.erase(mObjectIDs.begin()); - LLViewerObject* obj = gObjectList.findObject(mCurrentObjectID); - if(obj) - { - //LL_INFOS() << "requesting inv for " << mCurrentObjectID << LL_ENDL; - LLUUID* id = new LLUUID(mID); - registerVOInventoryListener(obj,id); - requestVOInventory(); - rv = true; - } - else - { - LL_INFOS()<<"NULL LLViewerObject" <("queue output"); - - LLInventoryObject::object_list_t::const_iterator it = inv->begin(); - LLInventoryObject::object_list_t::const_iterator end = inv->end(); - for ( ; it != end; ++it) - { - LLAssetType::EType asstype = (*it)->getType(); - if( - ( asstype == LLAssetType::AT_ANIMATION && gSavedSettings.getBOOL("BulkChangeIncludeAnimations")) || - ( asstype == LLAssetType::AT_BODYPART && gSavedSettings.getBOOL("BulkChangeIncludeBodyParts" )) || - ( asstype == LLAssetType::AT_CLOTHING && gSavedSettings.getBOOL("BulkChangeIncludeClothing" )) || - ( asstype == LLAssetType::AT_GESTURE && gSavedSettings.getBOOL("BulkChangeIncludeGestures" )) || - ( asstype == LLAssetType::AT_NOTECARD && gSavedSettings.getBOOL("BulkChangeIncludeNotecards" )) || - ( asstype == LLAssetType::AT_OBJECT && gSavedSettings.getBOOL("BulkChangeIncludeObjects" )) || - ( asstype == LLAssetType::AT_LSL_TEXT && gSavedSettings.getBOOL("BulkChangeIncludeScripts" )) || - ( asstype == LLAssetType::AT_SOUND && gSavedSettings.getBOOL("BulkChangeIncludeSounds" )) || - ( asstype == LLAssetType::AT_SETTINGS && gSavedSettings.getBOOL("BulkChangeIncludeSettings" )) || - ( asstype == LLAssetType::AT_MATERIAL && gSavedSettings.getBOOL("BulkChangeIncludeMaterials")) || - ( asstype == LLAssetType::AT_TEXTURE && gSavedSettings.getBOOL("BulkChangeIncludeTextures" ))) - { - LLViewerObject* object = gObjectList.findObject(viewer_obj->getID()); - - if (object) - { - LLInventoryItem* item = (LLInventoryItem*)((LLInventoryObject*)(*it)); - LLViewerInventoryItem* new_item = (LLViewerInventoryItem*)item; - LLPermissions perm(new_item->getPermissions()); - - // chomp the inventory name so it fits in the scroll window nicely - // and the user can see the [OK] - std::string invname; - invname=item->getName().substr(0,item->getName().size() < 30 ? item->getName().size() : 30 ); - - LLUIString status_text = getString("status_text"); - status_text.setArg("[NAME]", invname.c_str()); - // Check whether we appear to have the appropriate permissions to change permission on this item. - // Although the server will disallow any forbidden changes, it is a good idea to guess correctly - // so that we can warn the user. The risk of getting this check wrong is therefore the possibility - // of incorrectly choosing to not attempt to make a valid change. - // - // Trouble is this is extremely difficult to do and even when we know the results - // it is difficult to design the best messaging. Therefore in this initial implementation - // we'll always try to set the requested permissions and consider all cases successful - // and perhaps later try to implement a smarter, friendlier solution. -MG - if(true - //gAgent.allowOperation(PERM_MODIFY, perm, GP_OBJECT_MANIPULATE) // for group and everyone masks - //|| something else // for next owner perms - ) - { - U32 mask_next = LLFloaterPerms::getNextOwnerPerms("BulkChange"); - if (asstype == LLAssetType::AT_SETTINGS) - { - mask_next |= PERM_COPY; - } - perm.setMaskNext(mask_next); - perm.setMaskEveryone(LLFloaterPerms::getEveryonePerms("BulkChange")); - perm.setMaskGroup(LLFloaterPerms::getGroupPerms("BulkChange")); - new_item->setPermissions(perm); // here's the beef - updateInventory(object,new_item,TASK_INVENTORY_ITEM_KEY,false); - //status_text.setArg("[STATUS]", getString("status_ok_text")); - status_text.setArg("[STATUS]", ""); - } - else - { - //status_text.setArg("[STATUS]", getString("status_bad_text")); - status_text.setArg("[STATUS]", ""); - } - - list->setCommentText(status_text.getString()); - - //TODO if we are an object inside an object we should check a recuse flag and if set - //open the inventory of the object and recurse - Michelle2 Zenovka - - // if(recurse && ( (*it)->getType() == LLAssetType::AT_OBJECT && processObject)) - // { - // I think we need to get the UUID of the object inside the inventory - // call item->fetchFromServer(); - // we need a call back to say item has arrived *sigh* - // we then need to do something like - // LLUUID* id = new LLUUID(mID); - // registerVOInventoryListener(obj,id); - // requestVOInventory(); - // } - } - } - } - - nextObject(); -} - - -// Avoid inventory callbacks etc by just fire and forgetting the message with the permissions update -// we could do this via LLViewerObject::updateInventory but that uses inventory call backs and buggers -// us up and we would have a dodgy item iterator - -void LLFloaterBulkPermission::updateInventory(LLViewerObject* object, LLViewerInventoryItem* item, U8 key, bool is_new) -{ - // This slices the object into what we're concerned about on the viewer. - // The simulator will take the permissions and transfer ownership. - LLPointer task_item = - new LLViewerInventoryItem(item->getUUID(), mID, item->getPermissions(), - item->getAssetUUID(), item->getType(), - item->getInventoryType(), - item->getName(), item->getDescription(), - item->getSaleInfo(), - item->getFlags(), - item->getCreationDate()); - task_item->setTransactionID(item->getTransactionID()); - LLMessageSystem* msg = gMessageSystem; - msg->newMessageFast(_PREHASH_UpdateTaskInventory); - msg->nextBlockFast(_PREHASH_AgentData); - msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); - msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); - msg->nextBlockFast(_PREHASH_UpdateData); - msg->addU32Fast(_PREHASH_LocalID, object->mLocalID); - msg->addU8Fast(_PREHASH_Key, key); - msg->nextBlockFast(_PREHASH_InventoryData); - task_item->packMessage(msg); - msg->sendReliable(object->getRegion()->getHost()); -} - +/** + * @file llfloaterbulkpermissions.cpp + * @author Michelle2 Zenovka + * @brief A floater which allows task inventory item's properties to be changed on mass. + * + * $LicenseInfo:firstyear=2008&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + + +#include "llviewerprecompiledheaders.h" +#include "llfloaterbulkpermission.h" +#include "llfloaterperms.h" // for utilities +#include "llagent.h" +#include "llchat.h" +#include "llinventorydefines.h" +#include "llviewerwindow.h" +#include "llviewerobject.h" +#include "llviewerobjectlist.h" +#include "llviewerregion.h" +#include "llviewercontrol.h" +#include "llviewerinventory.h" +#include "llviewerobject.h" +#include "llviewerregion.h" +#include "llresmgr.h" +#include "llbutton.h" +#include "lldir.h" +#include "llviewerstats.h" +#include "lluictrlfactory.h" +#include "llselectmgr.h" +#include "llcheckboxctrl.h" + +#include "roles_constants.h" // for GP_OBJECT_MANIPULATE + + +LLFloaterBulkPermission::LLFloaterBulkPermission(const LLSD& seed) +: LLFloater(seed), + mDone(false) +{ + mID.generate(); + mCommitCallbackRegistrar.add("BulkPermission.Ok", boost::bind(&LLFloaterBulkPermission::onOkBtn, this)); + mCommitCallbackRegistrar.add("BulkPermission.Apply", boost::bind(&LLFloaterBulkPermission::onApplyBtn, this)); + mCommitCallbackRegistrar.add("BulkPermission.Close", boost::bind(&LLFloaterBulkPermission::onCloseBtn, this)); + mCommitCallbackRegistrar.add("BulkPermission.CheckAll", boost::bind(&LLFloaterBulkPermission::onCheckAll, this)); + mCommitCallbackRegistrar.add("BulkPermission.UncheckAll", boost::bind(&LLFloaterBulkPermission::onUncheckAll, this)); + mCommitCallbackRegistrar.add("BulkPermission.CommitCopy", boost::bind(&LLFloaterBulkPermission::onCommitCopy, this)); +} + +bool LLFloaterBulkPermission::postBuild() +{ + mBulkChangeIncludeAnimations = gSavedSettings.getBOOL("BulkChangeIncludeAnimations"); + mBulkChangeIncludeBodyParts = gSavedSettings.getBOOL("BulkChangeIncludeBodyParts"); + mBulkChangeIncludeClothing = gSavedSettings.getBOOL("BulkChangeIncludeClothing"); + mBulkChangeIncludeGestures = gSavedSettings.getBOOL("BulkChangeIncludeGestures"); + mBulkChangeIncludeNotecards = gSavedSettings.getBOOL("BulkChangeIncludeNotecards"); + mBulkChangeIncludeObjects = gSavedSettings.getBOOL("BulkChangeIncludeObjects"); + mBulkChangeIncludeScripts = gSavedSettings.getBOOL("BulkChangeIncludeScripts"); + mBulkChangeIncludeSounds = gSavedSettings.getBOOL("BulkChangeIncludeSounds"); + mBulkChangeIncludeTextures = gSavedSettings.getBOOL("BulkChangeIncludeTextures"); + mBulkChangeIncludeSettings = gSavedSettings.getBOOL("BulkChangeIncludeSettings"); + mBulkChangeIncludeMaterials = gSavedSettings.getBOOL("BulkChangeIncludeMaterials"); + + mBulkChangeShareWithGroup = gSavedSettings.getBOOL("BulkChangeShareWithGroup"); + mBulkChangeEveryoneCopy = gSavedSettings.getBOOL("BulkChangeEveryoneCopy"); + mBulkChangeNextOwnerModify = gSavedSettings.getBOOL("BulkChangeNextOwnerModify"); + mBulkChangeNextOwnerCopy = gSavedSettings.getBOOL("BulkChangeNextOwnerCopy"); + mBulkChangeNextOwnerTransfer = gSavedSettings.getBOOL("BulkChangeNextOwnerTransfer"); + + // fix invalid permissions case (in case initial settings were generated by a viewer affected by MAINT-3339) + if( !mBulkChangeNextOwnerTransfer && !mBulkChangeEveryoneCopy) + { + mBulkChangeNextOwnerTransfer = true; + } + return true; +} + +void LLFloaterBulkPermission::doApply() +{ + // Inspects a stream of selected object contents and adds modifiable ones to the given array. + class ModifiableGatherer : public LLSelectedNodeFunctor + { + public: + ModifiableGatherer(std::vector& q) : mQueue(q) { mQueue.reserve(32); } + virtual bool apply(LLSelectNode* node) + { + if( node->allowOperationOnNode(PERM_MODIFY, GP_OBJECT_MANIPULATE) ) + { + mQueue.push_back(node->getObject()->getID()); + } + return true; + } + private: + std::vector& mQueue; + }; + LLScrollListCtrl* list = getChild("queue output"); + list->deleteAllItems(); + ModifiableGatherer gatherer(mObjectIDs); + LLSelectMgr::getInstance()->getSelection()->applyToNodes(&gatherer); + if(mObjectIDs.empty()) + { + list->setCommentText(getString("nothing_to_modify_text")); + } + else + { + mDone = false; + if (!start()) + { + LL_WARNS() << "Unexpected bulk permission change failure." << LL_ENDL; + } + } +} + + +// This is the callback method for the viewer object currently being +// worked on. +// NOT static, virtual! +void LLFloaterBulkPermission::inventoryChanged(LLViewerObject* viewer_object, + LLInventoryObject::object_list_t* inv, + S32, + void* q_id) +{ + //LL_INFOS() << "changed object: " << viewer_object->getID() << LL_ENDL; + + //Remove this listener from the object since its + //listener callback is now being executed. + + //We remove the listener here because the function + //removeVOInventoryListener removes the listener from a ViewerObject + //which it internally stores. + + //If we call this further down in the function, calls to handleInventory + //and nextObject may update the interally stored viewer object causing + //the removal of the incorrect listener from an incorrect object. + + //Fixes SL-6119:Recompile scripts fails to complete + removeVOInventoryListener(); + + if (viewer_object && inv && (viewer_object->getID() == mCurrentObjectID) ) + { + handleInventory(viewer_object, inv); + } + else + { + // something went wrong... + // note that we're not working on this one, and move onto the + // next object in the list. + LL_WARNS() << "No inventory for " << mCurrentObjectID << LL_ENDL; + nextObject(); + } +} + +void LLFloaterBulkPermission::onOkBtn() +{ + doApply(); + closeFloater(); +} + +void LLFloaterBulkPermission::onApplyBtn() +{ + doApply(); +} + +void LLFloaterBulkPermission::onCloseBtn() +{ + gSavedSettings.setBOOL("BulkChangeIncludeAnimations", mBulkChangeIncludeAnimations); + gSavedSettings.setBOOL("BulkChangeIncludeBodyParts", mBulkChangeIncludeBodyParts); + gSavedSettings.setBOOL("BulkChangeIncludeClothing", mBulkChangeIncludeClothing); + gSavedSettings.setBOOL("BulkChangeIncludeGestures", mBulkChangeIncludeGestures); + gSavedSettings.setBOOL("BulkChangeIncludeNotecards", mBulkChangeIncludeNotecards); + gSavedSettings.setBOOL("BulkChangeIncludeObjects", mBulkChangeIncludeObjects); + gSavedSettings.setBOOL("BulkChangeIncludeScripts", mBulkChangeIncludeScripts); + gSavedSettings.setBOOL("BulkChangeIncludeSounds", mBulkChangeIncludeSounds); + gSavedSettings.setBOOL("BulkChangeIncludeTextures", mBulkChangeIncludeTextures); + gSavedSettings.setBOOL("BulkChangeIncludeSettings", mBulkChangeIncludeSettings); + gSavedSettings.setBOOL("BulkChangeIncludeMaterials", mBulkChangeIncludeMaterials); + + gSavedSettings.setBOOL("BulkChangeShareWithGroup", mBulkChangeShareWithGroup); + gSavedSettings.setBOOL("BulkChangeEveryoneCopy", mBulkChangeEveryoneCopy); + gSavedSettings.setBOOL("BulkChangeNextOwnerModify", mBulkChangeNextOwnerModify); + gSavedSettings.setBOOL("BulkChangeNextOwnerCopy", mBulkChangeNextOwnerCopy); + gSavedSettings.setBOOL("BulkChangeNextOwnerTransfer", mBulkChangeNextOwnerTransfer); + closeFloater(); +} + +//static +void LLFloaterBulkPermission::onCommitCopy() +{ + // Implements fair use + bool copyable = gSavedSettings.getBOOL("BulkChangeNextOwnerCopy"); + if(!copyable) + { + gSavedSettings.setBOOL("BulkChangeNextOwnerTransfer", true); + } + LLCheckBoxCtrl* xfer =getChild("next_owner_transfer"); + xfer->setEnabled(copyable); +} + +bool LLFloaterBulkPermission::start() +{ + // note: number of top-level objects to modify is mObjectIDs.size(). + getChild("queue output")->setCommentText(getString("start_text")); + return nextObject(); +} + +// Go to the next object and start if found. Returns false if no objects left, true otherwise. +bool LLFloaterBulkPermission::nextObject() +{ + S32 count; + bool successful_start = false; + do + { + count = mObjectIDs.size(); + //LL_INFOS() << "Objects left to process = " << count << LL_ENDL; + mCurrentObjectID.setNull(); + if(count > 0) + { + successful_start = popNext(); + //LL_INFOS() << (successful_start ? "successful" : "unsuccessful") << LL_ENDL; + } + } while((mObjectIDs.size() > 0) && !successful_start); + + if(isDone() && !mDone) + { + getChild("queue output")->setCommentText(getString("done_text")); + mDone = true; + } + return successful_start; +} + +// Pop the top object off of the queue. +// Return true if the queue has started, otherwise false. +bool LLFloaterBulkPermission::popNext() +{ + // get the head element from the container, and attempt to get its inventory. + bool rv = false; + S32 count = mObjectIDs.size(); + if(mCurrentObjectID.isNull() && (count > 0)) + { + mCurrentObjectID = mObjectIDs.at(0); + //LL_INFOS() << "mCurrentID: " << mCurrentObjectID << LL_ENDL; + mObjectIDs.erase(mObjectIDs.begin()); + LLViewerObject* obj = gObjectList.findObject(mCurrentObjectID); + if(obj) + { + //LL_INFOS() << "requesting inv for " << mCurrentObjectID << LL_ENDL; + LLUUID* id = new LLUUID(mID); + registerVOInventoryListener(obj,id); + requestVOInventory(); + rv = true; + } + else + { + LL_INFOS()<<"NULL LLViewerObject" <("queue output"); + + LLInventoryObject::object_list_t::const_iterator it = inv->begin(); + LLInventoryObject::object_list_t::const_iterator end = inv->end(); + for ( ; it != end; ++it) + { + LLAssetType::EType asstype = (*it)->getType(); + if( + ( asstype == LLAssetType::AT_ANIMATION && gSavedSettings.getBOOL("BulkChangeIncludeAnimations")) || + ( asstype == LLAssetType::AT_BODYPART && gSavedSettings.getBOOL("BulkChangeIncludeBodyParts" )) || + ( asstype == LLAssetType::AT_CLOTHING && gSavedSettings.getBOOL("BulkChangeIncludeClothing" )) || + ( asstype == LLAssetType::AT_GESTURE && gSavedSettings.getBOOL("BulkChangeIncludeGestures" )) || + ( asstype == LLAssetType::AT_NOTECARD && gSavedSettings.getBOOL("BulkChangeIncludeNotecards" )) || + ( asstype == LLAssetType::AT_OBJECT && gSavedSettings.getBOOL("BulkChangeIncludeObjects" )) || + ( asstype == LLAssetType::AT_LSL_TEXT && gSavedSettings.getBOOL("BulkChangeIncludeScripts" )) || + ( asstype == LLAssetType::AT_SOUND && gSavedSettings.getBOOL("BulkChangeIncludeSounds" )) || + ( asstype == LLAssetType::AT_SETTINGS && gSavedSettings.getBOOL("BulkChangeIncludeSettings" )) || + ( asstype == LLAssetType::AT_MATERIAL && gSavedSettings.getBOOL("BulkChangeIncludeMaterials")) || + ( asstype == LLAssetType::AT_TEXTURE && gSavedSettings.getBOOL("BulkChangeIncludeTextures" ))) + { + LLViewerObject* object = gObjectList.findObject(viewer_obj->getID()); + + if (object) + { + LLInventoryItem* item = (LLInventoryItem*)((LLInventoryObject*)(*it)); + LLViewerInventoryItem* new_item = (LLViewerInventoryItem*)item; + LLPermissions perm(new_item->getPermissions()); + + // chomp the inventory name so it fits in the scroll window nicely + // and the user can see the [OK] + std::string invname; + invname=item->getName().substr(0,item->getName().size() < 30 ? item->getName().size() : 30 ); + + LLUIString status_text = getString("status_text"); + status_text.setArg("[NAME]", invname.c_str()); + // Check whether we appear to have the appropriate permissions to change permission on this item. + // Although the server will disallow any forbidden changes, it is a good idea to guess correctly + // so that we can warn the user. The risk of getting this check wrong is therefore the possibility + // of incorrectly choosing to not attempt to make a valid change. + // + // Trouble is this is extremely difficult to do and even when we know the results + // it is difficult to design the best messaging. Therefore in this initial implementation + // we'll always try to set the requested permissions and consider all cases successful + // and perhaps later try to implement a smarter, friendlier solution. -MG + if(true + //gAgent.allowOperation(PERM_MODIFY, perm, GP_OBJECT_MANIPULATE) // for group and everyone masks + //|| something else // for next owner perms + ) + { + U32 mask_next = LLFloaterPerms::getNextOwnerPerms("BulkChange"); + if (asstype == LLAssetType::AT_SETTINGS) + { + mask_next |= PERM_COPY; + } + perm.setMaskNext(mask_next); + perm.setMaskEveryone(LLFloaterPerms::getEveryonePerms("BulkChange")); + perm.setMaskGroup(LLFloaterPerms::getGroupPerms("BulkChange")); + new_item->setPermissions(perm); // here's the beef + updateInventory(object,new_item,TASK_INVENTORY_ITEM_KEY,false); + //status_text.setArg("[STATUS]", getString("status_ok_text")); + status_text.setArg("[STATUS]", ""); + } + else + { + //status_text.setArg("[STATUS]", getString("status_bad_text")); + status_text.setArg("[STATUS]", ""); + } + + list->setCommentText(status_text.getString()); + + //TODO if we are an object inside an object we should check a recuse flag and if set + //open the inventory of the object and recurse - Michelle2 Zenovka + + // if(recurse && ( (*it)->getType() == LLAssetType::AT_OBJECT && processObject)) + // { + // I think we need to get the UUID of the object inside the inventory + // call item->fetchFromServer(); + // we need a call back to say item has arrived *sigh* + // we then need to do something like + // LLUUID* id = new LLUUID(mID); + // registerVOInventoryListener(obj,id); + // requestVOInventory(); + // } + } + } + } + + nextObject(); +} + + +// Avoid inventory callbacks etc by just fire and forgetting the message with the permissions update +// we could do this via LLViewerObject::updateInventory but that uses inventory call backs and buggers +// us up and we would have a dodgy item iterator + +void LLFloaterBulkPermission::updateInventory(LLViewerObject* object, LLViewerInventoryItem* item, U8 key, bool is_new) +{ + // This slices the object into what we're concerned about on the viewer. + // The simulator will take the permissions and transfer ownership. + LLPointer task_item = + new LLViewerInventoryItem(item->getUUID(), mID, item->getPermissions(), + item->getAssetUUID(), item->getType(), + item->getInventoryType(), + item->getName(), item->getDescription(), + item->getSaleInfo(), + item->getFlags(), + item->getCreationDate()); + task_item->setTransactionID(item->getTransactionID()); + LLMessageSystem* msg = gMessageSystem; + msg->newMessageFast(_PREHASH_UpdateTaskInventory); + msg->nextBlockFast(_PREHASH_AgentData); + msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); + msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); + msg->nextBlockFast(_PREHASH_UpdateData); + msg->addU32Fast(_PREHASH_LocalID, object->mLocalID); + msg->addU8Fast(_PREHASH_Key, key); + msg->nextBlockFast(_PREHASH_InventoryData); + task_item->packMessage(msg); + msg->sendReliable(object->getRegion()->getHost()); +} + -- cgit v1.2.3 From b42f9d836b4c0f7fbd4bdae1734021e2a09fdbe8 Mon Sep 17 00:00:00 2001 From: Ansariel Date: Sat, 1 Jun 2024 15:49:26 +0200 Subject: Re-enable a lot of compiler warnings for MSVC and address the C4267 "possible loss of precision" warnings --- indra/newview/llfloaterbulkpermission.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/llfloaterbulkpermission.cpp') diff --git a/indra/newview/llfloaterbulkpermission.cpp b/indra/newview/llfloaterbulkpermission.cpp index 497fe3b9ba..c09c02d32b 100644 --- a/indra/newview/llfloaterbulkpermission.cpp +++ b/indra/newview/llfloaterbulkpermission.cpp @@ -223,7 +223,7 @@ bool LLFloaterBulkPermission::start() // Go to the next object and start if found. Returns false if no objects left, true otherwise. bool LLFloaterBulkPermission::nextObject() { - S32 count; + size_t count; bool successful_start = false; do { @@ -251,7 +251,7 @@ bool LLFloaterBulkPermission::popNext() { // get the head element from the container, and attempt to get its inventory. bool rv = false; - S32 count = mObjectIDs.size(); + auto count = mObjectIDs.size(); if(mCurrentObjectID.isNull() && (count > 0)) { mCurrentObjectID = mObjectIDs.at(0); -- cgit v1.2.3