From fbb4e5fb0f7bba935ec9d0d466be12a346a6b149 Mon Sep 17 00:00:00 2001 From: Jonathan Yap Date: Fri, 8 Jun 2012 13:49:02 -0400 Subject: STORM-68 As a Builder, I want that ability to set default permissions on creation of objects, clothing, scripts, notecards, etc. First pass at implementation, debuggins lines still need to be removed and there is one known bug to be resolved. --- indra/newview/llviewerinventory.cpp | 98 ++++++++++++++++++++++++++++++------- 1 file changed, 81 insertions(+), 17 deletions(-) (limited to 'indra/newview/llviewerinventory.cpp') diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp index 45ca23cdfe..0d56233db1 100644 --- a/indra/newview/llviewerinventory.cpp +++ b/indra/newview/llviewerinventory.cpp @@ -64,6 +64,7 @@ #include "llavatarnamecache.h" #include "llavataractions.h" #include "lllogininstance.h" +#include "llfloaterperms.h" ///---------------------------------------------------------------------------- /// Helper class to store special inventory item names and their localized values. @@ -1013,6 +1014,24 @@ void ActivateGestureCallback::fire(const LLUUID& inv_item) LLGestureMgr::instance().activateGesture(inv_item); } +void CreateScriptCallback::fire(const LLUUID& inv_item) +{ + if (inv_item.isNull()) + return; + + LLViewerInventoryItem* item = gInventory.getItem(inv_item); + if (!item) return; + + LLPermissions perm = item->getPermissions(); + perm.setMaskEveryone(LLFloaterPerms::getEveryonePerms("Scripts")); + perm.setMaskGroup(LLFloaterPerms::getGroupPerms("Scripts")); + + item->setPermissions(perm); + + gInventory.updateItem(item); + gInventory.notifyObservers(); +} + void CreateGestureCallback::fire(const LLUUID& inv_item) { if (inv_item.isNull()) @@ -1022,6 +1041,12 @@ void CreateGestureCallback::fire(const LLUUID& inv_item) LLViewerInventoryItem* item = gInventory.getItem(inv_item); if (!item) return; + + LLPermissions perm = item->getPermissions(); + perm.setMaskEveryone(LLFloaterPerms::getEveryonePerms("Gestures")); + perm.setMaskGroup(LLFloaterPerms::getGroupPerms("Gestures")); + item->setPermissions(perm); + gInventory.updateItem(item); gInventory.notifyObservers(); @@ -1030,6 +1055,23 @@ void CreateGestureCallback::fire(const LLUUID& inv_item) gFloaterView->adjustToFitScreen(preview, FALSE); } +void CreateNotecardCallback::fire(const LLUUID& inv_item) +{ + if (inv_item.isNull()) + return; + + LLViewerInventoryItem* item = gInventory.getItem(inv_item); + if (!item) return; + + LLPermissions perm = item->getPermissions(); + perm.setMaskEveryone(LLFloaterPerms::getEveryonePerms("Notecards")); + perm.setMaskGroup(LLFloaterPerms::getGroupPerms("Notecards")); + item->setPermissions(perm); + + gInventory.updateItem(item); + gInventory.notifyObservers(); +} + void AddFavoriteLandmarkCallback::fire(const LLUUID& inv_item_id) { if (mTargetLandmarkId.isNull()) return; @@ -1285,22 +1327,44 @@ void create_new_item(const std::string& name, LLViewerAssetType::generateDescriptionFor(asset_type, desc); next_owner_perm = (next_owner_perm) ? next_owner_perm : PERM_MOVE | PERM_TRANSFER; - - if (inv_type == LLInventoryType::IT_GESTURE) - { - LLPointer cb = new CreateGestureCallback(); - create_inventory_item(gAgent.getID(), gAgent.getSessionID(), - parent_id, LLTransactionID::tnull, name, desc, asset_type, inv_type, - NOT_WEARABLE, next_owner_perm, cb); - } - else + LLPointer cb = NULL; + + switch (inv_type) { - LLPointer cb = NULL; - create_inventory_item(gAgent.getID(), gAgent.getSessionID(), - parent_id, LLTransactionID::tnull, name, desc, asset_type, inv_type, - NOT_WEARABLE, next_owner_perm, cb); - } + case LLInventoryType::IT_LSL: + { + cb = new CreateScriptCallback(); + next_owner_perm = LLFloaterPerms::getNextOwnerPerms("Scripts"); + break; + } + + case LLInventoryType::IT_GESTURE: + { + cb = new CreateGestureCallback(); + next_owner_perm = LLFloaterPerms::getNextOwnerPerms("Gestures"); + break; + } + + case LLInventoryType::IT_NOTECARD: + { + cb = new CreateNotecardCallback(); + next_owner_perm = LLFloaterPerms::getNextOwnerPerms("Notecards"); + break; + } + } + + create_inventory_item(gAgent.getID(), + gAgent.getSessionID(), + parent_id, + LLTransactionID::tnull, + name, + desc, + asset_type, + inv_type, + NOT_WEARABLE, + next_owner_perm, + cb); } const std::string NEW_LSL_NAME = "New Script"; // *TODO:Translate? (probably not) @@ -1341,7 +1405,7 @@ void menu_create_inventory_item(LLFolderView* root, LLFolderBridge *bridge, cons parent_id, LLAssetType::AT_LSL_TEXT, LLInventoryType::IT_LSL, - PERM_MOVE | PERM_TRANSFER); + PERM_MOVE | PERM_TRANSFER); // overridden in create_new_item } else if ("notecard" == type_name) { @@ -1350,7 +1414,7 @@ void menu_create_inventory_item(LLFolderView* root, LLFolderBridge *bridge, cons parent_id, LLAssetType::AT_NOTECARD, LLInventoryType::IT_NOTECARD, - PERM_ALL); + PERM_ALL); // overridden in create_new_item } else if ("gesture" == type_name) { @@ -1359,7 +1423,7 @@ void menu_create_inventory_item(LLFolderView* root, LLFolderBridge *bridge, cons parent_id, LLAssetType::AT_GESTURE, LLInventoryType::IT_GESTURE, - PERM_ALL); + PERM_ALL); // overridden in create_new_item } else { -- cgit v1.2.3 From dce0a9be48808d084f3c98615d5747544fe59ad5 Mon Sep 17 00:00:00 2001 From: Jonathan Yap Date: Fri, 8 Jun 2012 17:09:37 -0400 Subject: STORM-68 Add default: to switch statement to fix compiling issue on mac/linux --- indra/newview/llviewerinventory.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indra/newview/llviewerinventory.cpp') diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp index 0d56233db1..83a195738a 100644 --- a/indra/newview/llviewerinventory.cpp +++ b/indra/newview/llviewerinventory.cpp @@ -1352,6 +1352,8 @@ void create_new_item(const std::string& name, next_owner_perm = LLFloaterPerms::getNextOwnerPerms("Notecards"); break; } + default: + break; } create_inventory_item(gAgent.getID(), -- cgit v1.2.3 From 052dc3982056d822a523394954c277d9eb7c7ab9 Mon Sep 17 00:00:00 2001 From: Jonathan Yap Date: Tue, 12 Jun 2012 14:26:53 -0400 Subject: STORM-68 Fix for group perms not being defined correctly and fix for group and everyone perms failing to copy and paste --- indra/newview/llviewerinventory.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'indra/newview/llviewerinventory.cpp') diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp index 83a195738a..a7ba150294 100644 --- a/indra/newview/llviewerinventory.cpp +++ b/indra/newview/llviewerinventory.cpp @@ -1025,9 +1025,9 @@ void CreateScriptCallback::fire(const LLUUID& inv_item) LLPermissions perm = item->getPermissions(); perm.setMaskEveryone(LLFloaterPerms::getEveryonePerms("Scripts")); perm.setMaskGroup(LLFloaterPerms::getGroupPerms("Scripts")); - item->setPermissions(perm); + item->updateServer(FALSE); gInventory.updateItem(item); gInventory.notifyObservers(); } @@ -1047,8 +1047,9 @@ void CreateGestureCallback::fire(const LLUUID& inv_item) perm.setMaskGroup(LLFloaterPerms::getGroupPerms("Gestures")); item->setPermissions(perm); - gInventory.updateItem(item); - gInventory.notifyObservers(); + item->updateServer(FALSE); + gInventory.updateItem(item); + gInventory.notifyObservers(); LLPreviewGesture* preview = LLPreviewGesture::show(inv_item, LLUUID::null); // Force to be entirely onscreen. @@ -1068,6 +1069,7 @@ void CreateNotecardCallback::fire(const LLUUID& inv_item) perm.setMaskGroup(LLFloaterPerms::getGroupPerms("Notecards")); item->setPermissions(perm); + item->updateServer(FALSE); gInventory.updateItem(item); gInventory.notifyObservers(); } -- cgit v1.2.3 From 176901422f0122dad8d1e4e423d0bc19e9e4ad8a Mon Sep 17 00:00:00 2001 From: Jonathan Yap Date: Wed, 20 Nov 2013 10:21:41 -0500 Subject: STORM-68 Reapply changes to inventory processing lost in the merge. Move call to updateCap back to where it was. The place it was moved to was too early in the login sequence and was causing a crash. --- indra/newview/llviewerinventory.cpp | 99 ++++++++++++++++++++++++++++++------- 1 file changed, 82 insertions(+), 17 deletions(-) (limited to 'indra/newview/llviewerinventory.cpp') diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp index fff9821e86..5e3df16c38 100755 --- a/indra/newview/llviewerinventory.cpp +++ b/indra/newview/llviewerinventory.cpp @@ -65,6 +65,7 @@ #include "llavataractions.h" #include "lllogininstance.h" #include "llfavoritesbar.h" +#include "llfloaterperms.h" // Two do-nothing ops for use in callbacks. void no_op_inventory_func(const LLUUID&) {} @@ -989,6 +990,24 @@ void activate_gesture_cb(const LLUUID& inv_item) LLGestureMgr::instance().activateGesture(inv_item); } +void create_script_cb(const LLUUID& inv_item) +{ + if (inv_item.isNull()) + return; + + LLViewerInventoryItem* item = gInventory.getItem(inv_item); + if (!item) return; + + LLPermissions perm = item->getPermissions(); + perm.setMaskEveryone(LLFloaterPerms::getEveryonePerms("Scripts")); + perm.setMaskGroup(LLFloaterPerms::getGroupPerms("Scripts")); + + item->setPermissions(perm); + + gInventory.updateItem(item); + gInventory.notifyObservers(); +} + void create_gesture_cb(const LLUUID& inv_item) { if (inv_item.isNull()) @@ -998,6 +1017,13 @@ void create_gesture_cb(const LLUUID& inv_item) LLViewerInventoryItem* item = gInventory.getItem(inv_item); if (!item) return; + + LLPermissions perm = item->getPermissions(); + perm.setMaskEveryone(LLFloaterPerms::getEveryonePerms("Gestures")); + perm.setMaskGroup(LLFloaterPerms::getGroupPerms("Gestures")); + + item->setPermissions(perm); + gInventory.updateItem(item); gInventory.notifyObservers(); @@ -1007,6 +1033,24 @@ void create_gesture_cb(const LLUUID& inv_item) } +void create_notecard_cb(const LLUUID& inv_item) +{ + if (inv_item.isNull()) + return; + + LLViewerInventoryItem* item = gInventory.getItem(inv_item); + if (!item) return; + + LLPermissions perm = item->getPermissions(); + perm.setMaskEveryone(LLFloaterPerms::getEveryonePerms("Notecards")); + perm.setMaskGroup(LLFloaterPerms::getGroupPerms("Notecards")); + + item->setPermissions(perm); + + gInventory.updateItem(item); + gInventory.notifyObservers(); +} + LLInventoryCallbackManager gInventoryCallbacks; void create_inventory_item(const LLUUID& agent_id, const LLUUID& session_id, @@ -1260,22 +1304,43 @@ void create_new_item(const std::string& name, LLViewerAssetType::generateDescriptionFor(asset_type, desc); next_owner_perm = (next_owner_perm) ? next_owner_perm : PERM_MOVE | PERM_TRANSFER; - - if (inv_type == LLInventoryType::IT_GESTURE) - { - LLPointer cb = new LLBoostFuncInventoryCallback(create_gesture_cb); - create_inventory_item(gAgent.getID(), gAgent.getSessionID(), - parent_id, LLTransactionID::tnull, name, desc, asset_type, inv_type, - NOT_WEARABLE, next_owner_perm, cb); - } - else + LLPointer cb = NULL; + + switch (inv_type) { - LLPointer cb = NULL; - create_inventory_item(gAgent.getID(), gAgent.getSessionID(), - parent_id, LLTransactionID::tnull, name, desc, asset_type, inv_type, - NOT_WEARABLE, next_owner_perm, cb); + case LLInventoryType::IT_LSL: + { + cb = new LLBoostFuncInventoryCallback(create_script_cb); + next_owner_perm = LLFloaterPerms::getNextOwnerPerms("Scripts"); + break; + } + + case LLInventoryType::IT_GESTURE: + { + cb = new LLBoostFuncInventoryCallback(create_gesture_cb); + next_owner_perm = LLFloaterPerms::getNextOwnerPerms("Gestures"); + break; + } + + case LLInventoryType::IT_NOTECARD: + { + cb = new LLBoostFuncInventoryCallback(create_notecard_cb); + next_owner_perm = LLFloaterPerms::getNextOwnerPerms("Notecards"); + break; + } } - + + create_inventory_item(gAgent.getID(), + gAgent.getSessionID(), + parent_id, + LLTransactionID::tnull, + name, + desc, + asset_type, + inv_type, + NOT_WEARABLE, + next_owner_perm, + cb); } const std::string NEW_LSL_NAME = "New Script"; // *TODO:Translate? (probably not) @@ -1316,7 +1381,7 @@ void menu_create_inventory_item(LLInventoryPanel* panel, LLFolderBridge *bridge, parent_id, LLAssetType::AT_LSL_TEXT, LLInventoryType::IT_LSL, - PERM_MOVE | PERM_TRANSFER); + PERM_MOVE | PERM_TRANSFER); // overridden in create_new_item } else if ("notecard" == type_name) { @@ -1325,7 +1390,7 @@ void menu_create_inventory_item(LLInventoryPanel* panel, LLFolderBridge *bridge, parent_id, LLAssetType::AT_NOTECARD, LLInventoryType::IT_NOTECARD, - PERM_ALL); + PERM_ALL); // overridden in create_new_item } else if ("gesture" == type_name) { @@ -1334,7 +1399,7 @@ void menu_create_inventory_item(LLInventoryPanel* panel, LLFolderBridge *bridge, parent_id, LLAssetType::AT_GESTURE, LLInventoryType::IT_GESTURE, - PERM_ALL); + PERM_ALL); // overridden in create_new_item } else { -- cgit v1.2.3 From aec2fde7a4c3114b9081fa3c90f891f8337595ad Mon Sep 17 00:00:00 2001 From: Jonathan Yap Date: Wed, 20 Nov 2013 14:47:00 -0500 Subject: STORM-68 Added default clause to switch statement to try to fix linux compile error. --- indra/newview/llviewerinventory.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indra/newview/llviewerinventory.cpp') diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp index 5e3df16c38..c52505e4b3 100755 --- a/indra/newview/llviewerinventory.cpp +++ b/indra/newview/llviewerinventory.cpp @@ -1328,6 +1328,8 @@ void create_new_item(const std::string& name, next_owner_perm = LLFloaterPerms::getNextOwnerPerms("Notecards"); break; } + default: + break; } create_inventory_item(gAgent.getID(), -- cgit v1.2.3 From 2d701456a07d37a520f436f9e83b1008e492f232 Mon Sep 17 00:00:00 2001 From: Jonathan Yap Date: Thu, 12 Dec 2013 08:51:15 -0500 Subject: STORM-68 Fix bug for new gestures, notecards, and scripts where a copied item did not preserve its default permissions. Add apply button. --- indra/newview/llviewerinventory.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'indra/newview/llviewerinventory.cpp') diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp index c52505e4b3..5c41ef52b6 100755 --- a/indra/newview/llviewerinventory.cpp +++ b/indra/newview/llviewerinventory.cpp @@ -1004,6 +1004,7 @@ void create_script_cb(const LLUUID& inv_item) item->setPermissions(perm); + item->updateServer(FALSE); gInventory.updateItem(item); gInventory.notifyObservers(); } @@ -1024,6 +1025,7 @@ void create_gesture_cb(const LLUUID& inv_item) item->setPermissions(perm); + item->updateServer(FALSE); gInventory.updateItem(item); gInventory.notifyObservers(); @@ -1047,6 +1049,7 @@ void create_notecard_cb(const LLUUID& inv_item) item->setPermissions(perm); + item->updateServer(FALSE); gInventory.updateItem(item); gInventory.notifyObservers(); } -- cgit v1.2.3 From a4173dc81a21dfac6a8b57e8e1c354b9a37fe5ba Mon Sep 17 00:00:00 2001 From: Jonathan Yap Date: Wed, 8 Jan 2014 09:30:30 -0500 Subject: STORM-68 Remove obsolete note. Refactor a few blocks of code to not have early returns --- indra/newview/llviewerinventory.cpp | 89 +++++++++++++++++++------------------ 1 file changed, 46 insertions(+), 43 deletions(-) (limited to 'indra/newview/llviewerinventory.cpp') diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp index 5c41ef52b6..e8ae621e41 100755 --- a/indra/newview/llviewerinventory.cpp +++ b/indra/newview/llviewerinventory.cpp @@ -992,66 +992,69 @@ void activate_gesture_cb(const LLUUID& inv_item) void create_script_cb(const LLUUID& inv_item) { - if (inv_item.isNull()) - return; - - LLViewerInventoryItem* item = gInventory.getItem(inv_item); - if (!item) return; - - LLPermissions perm = item->getPermissions(); - perm.setMaskEveryone(LLFloaterPerms::getEveryonePerms("Scripts")); - perm.setMaskGroup(LLFloaterPerms::getGroupPerms("Scripts")); + if (!inv_item.isNull()) + { + LLViewerInventoryItem* item = gInventory.getItem(inv_item); + if (item) + { + LLPermissions perm = item->getPermissions(); + perm.setMaskEveryone(LLFloaterPerms::getEveryonePerms("Scripts")); + perm.setMaskGroup(LLFloaterPerms::getGroupPerms("Scripts")); - item->setPermissions(perm); + item->setPermissions(perm); - item->updateServer(FALSE); - gInventory.updateItem(item); - gInventory.notifyObservers(); + item->updateServer(FALSE); + gInventory.updateItem(item); + gInventory.notifyObservers(); + } + } } void create_gesture_cb(const LLUUID& inv_item) { - if (inv_item.isNull()) - return; - - LLGestureMgr::instance().activateGesture(inv_item); + if (!inv_item.isNull()) + { + LLGestureMgr::instance().activateGesture(inv_item); - LLViewerInventoryItem* item = gInventory.getItem(inv_item); - if (!item) return; - - LLPermissions perm = item->getPermissions(); - perm.setMaskEveryone(LLFloaterPerms::getEveryonePerms("Gestures")); - perm.setMaskGroup(LLFloaterPerms::getGroupPerms("Gestures")); + LLViewerInventoryItem* item = gInventory.getItem(inv_item); + if (item) + { + LLPermissions perm = item->getPermissions(); + perm.setMaskEveryone(LLFloaterPerms::getEveryonePerms("Gestures")); + perm.setMaskGroup(LLFloaterPerms::getGroupPerms("Gestures")); - item->setPermissions(perm); + item->setPermissions(perm); - item->updateServer(FALSE); - gInventory.updateItem(item); - gInventory.notifyObservers(); + item->updateServer(FALSE); + gInventory.updateItem(item); + gInventory.notifyObservers(); - LLPreviewGesture* preview = LLPreviewGesture::show(inv_item, LLUUID::null); - // Force to be entirely onscreen. - gFloaterView->adjustToFitScreen(preview, FALSE); + LLPreviewGesture* preview = LLPreviewGesture::show(inv_item, LLUUID::null); + // Force to be entirely onscreen. + gFloaterView->adjustToFitScreen(preview, FALSE); + } + } } void create_notecard_cb(const LLUUID& inv_item) { - if (inv_item.isNull()) - return; - - LLViewerInventoryItem* item = gInventory.getItem(inv_item); - if (!item) return; - - LLPermissions perm = item->getPermissions(); - perm.setMaskEveryone(LLFloaterPerms::getEveryonePerms("Notecards")); - perm.setMaskGroup(LLFloaterPerms::getGroupPerms("Notecards")); + if (!inv_item.isNull()) + { + LLViewerInventoryItem* item = gInventory.getItem(inv_item); + if (item) + { + LLPermissions perm = item->getPermissions(); + perm.setMaskEveryone(LLFloaterPerms::getEveryonePerms("Notecards")); + perm.setMaskGroup(LLFloaterPerms::getGroupPerms("Notecards")); - item->setPermissions(perm); + item->setPermissions(perm); - item->updateServer(FALSE); - gInventory.updateItem(item); - gInventory.notifyObservers(); + item->updateServer(FALSE); + gInventory.updateItem(item); + gInventory.notifyObservers(); + } + } } LLInventoryCallbackManager gInventoryCallbacks; -- cgit v1.2.3