summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorMerov Linden <merov@lindenlab.com>2014-04-14 22:58:14 -0700
committerMerov Linden <merov@lindenlab.com>2014-04-14 22:58:14 -0700
commit545b408618388c0484b16d7dff22b9aeb6421530 (patch)
treef9c60c78842c1f584dfe19d93334a60a7d24ecd3 /indra/newview
parent65e53b70f276ff765fdd38b511563508459d0768 (diff)
DD-20 : Prevent pasting incompatible items in stock folders
Diffstat (limited to 'indra/newview')
-rwxr-xr-xindra/newview/llinventorybridge.cpp18
-rwxr-xr-xindra/newview/llinventoryfunctions.cpp15
-rwxr-xr-xindra/newview/llviewerinventory.cpp23
-rwxr-xr-xindra/newview/llviewerinventory.h3
4 files changed, 41 insertions, 18 deletions
diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp
index e740a16d49..520a840f74 100755
--- a/indra/newview/llinventorybridge.cpp
+++ b/indra/newview/llinventorybridge.cpp
@@ -4350,23 +4350,7 @@ BOOL LLFolderBridge::dragItemIntoFolder(LLInventoryItem* inv_item,
}
else if (move_is_into_marketplacelistings)
{
- // If destination folder type is stock, check perm and type of item, if not compatible -> FALSE
- if (getPreferredType() == LLFolderType::FT_MARKETPLACE_STOCK)
- {
- // If the item is copyable (i.e. non stock) do not accept the drop in a stock folder
- if (inv_item->getPermissions().allowOperationBy(PERM_COPY, gAgent.getID(), gAgent.getGroupID()))
- {
- accept = FALSE;
- }
- else
- {
- LLInventoryModel::cat_array_t* cat_array;
- LLInventoryModel::item_array_t* item_array;
- gInventory.getDirectDescendentsOf(mUUID,cat_array,item_array);
- // Destination stock folder must be empty OR types must be identical
- accept = (!item_array->count() || (item_array->get(0)->getInventoryType() == inv_item->getInventoryType()));
- }
- }
+ accept = (getCategory() && getCategory()->acceptItem(inv_item));
}
LLInventoryPanel* active_panel = LLInventoryPanel::getActiveInventoryPanel(FALSE);
diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp
index c7cd38b20e..7a16cf5e74 100755
--- a/indra/newview/llinventoryfunctions.cpp
+++ b/indra/newview/llinventoryfunctions.cpp
@@ -913,6 +913,13 @@ void move_item_to_marketplacelistings(LLInventoryItem* inv_item, LLUUID dest_fol
}
LLViewerInventoryCategory* dest_cat = gInventory.getCategory(dest_folder);
+ // Verify we can have this item in that destination category
+ if (!dest_cat->acceptItem(viewer_inv_item))
+ {
+ llinfos << "Merov : Marketplace error : Cannot move item in that stock folder -> move aborted!" << llendl;
+ return;
+ }
+
// When moving a no copy item into a first level listing folder, we create a stock folder for it
if (!viewer_inv_item->getPermissions().allowOperationBy(PERM_COPY, gAgent.getID(), gAgent.getGroupID()) && (dest_cat->getParentUUID() == marketplace_listings_uuid))
{
@@ -961,9 +968,15 @@ void move_folder_to_marketplacelistings(LLInventoryCategory* inv_cat, const LLUU
if (has_correct_permissions_for_sale(inv_cat))
{
// Get the destination folder
- // *TODO : check that this folder is not full of no-copy items under its root...
LLViewerInventoryCategory* dest_cat = gInventory.getCategory(dest_folder);
+ // Check it's not a stock folder
+ if (dest_cat->getPreferredType() == LLFolderType::FT_MARKETPLACE_STOCK)
+ {
+ llinfos << "Merov : Marketplace error : Cannot move folder in stock folder -> move aborted!" << llendl;
+ return;
+ }
+
// Get the parent folder of the moved item : we may have to update it
LLUUID src_folder = inv_cat->getParentUUID();
diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp
index fff9821e86..4ca569e78c 100755
--- a/indra/newview/llviewerinventory.cpp
+++ b/indra/newview/llviewerinventory.cpp
@@ -816,6 +816,29 @@ bool LLViewerInventoryCategory::exportFileLocal(LLFILE* fp) const
return true;
}
+bool LLViewerInventoryCategory::acceptItem(LLInventoryItem* inv_item)
+{
+ bool accept = true;
+ // Only stock folders have limitation on which item they will accept
+ if (getPreferredType() == LLFolderType::FT_MARKETPLACE_STOCK)
+ {
+ // If the item is copyable (i.e. non stock) do not accept the drop in a stock folder
+ if (inv_item->getPermissions().allowOperationBy(PERM_COPY, gAgent.getID(), gAgent.getGroupID()))
+ {
+ accept = false;
+ }
+ else
+ {
+ LLInventoryModel::cat_array_t* cat_array;
+ LLInventoryModel::item_array_t* item_array;
+ gInventory.getDirectDescendentsOf(getUUID(),cat_array,item_array);
+ // Destination stock folder must be empty OR types of incoming and existing items must be identical
+ accept = (!item_array->count() || (item_array->get(0)->getInventoryType() == inv_item->getInventoryType()));
+ }
+ }
+ return accept;
+}
+
void LLViewerInventoryCategory::determineFolderType()
{
/* Do NOT uncomment this code. This is for future 2.1 support of ensembles.
diff --git a/indra/newview/llviewerinventory.h b/indra/newview/llviewerinventory.h
index ab19a12014..6b33ef0672 100755
--- a/indra/newview/llviewerinventory.h
+++ b/indra/newview/llviewerinventory.h
@@ -225,6 +225,9 @@ public:
bool importFileLocal(LLFILE* fp);
void determineFolderType();
void changeType(LLFolderType::EType new_folder_type);
+
+ // returns true if the category object will accept the incoming item
+ bool acceptItem(LLInventoryItem* inv_item);
private:
friend class LLInventoryModel;