summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorBrad Payne (Vir Linden) <vir@lindenlab.com>2023-01-09 21:14:16 +0000
committerBrad Payne (Vir Linden) <vir@lindenlab.com>2023-01-09 21:14:16 +0000
commit819eec6f8c3abbf71ec3bdaaf4891068574fdc46 (patch)
tree8a0f6dd41d19620b8afc779d859ad494199b76dd /indra
parent11bd72661c86fd2cea016c9f2894efd7c98fc5d4 (diff)
SL-18924 - basic get/set functions for thumbnail UUID, removed obsolete binary pack/unpack functions for inventory
Diffstat (limited to 'indra')
-rw-r--r--indra/llinventory/llinventory.cpp148
-rw-r--r--indra/llinventory/llinventory.h6
-rw-r--r--indra/llinventory/tests/inventorymisc_test.cpp20
3 files changed, 22 insertions, 152 deletions
diff --git a/indra/llinventory/llinventory.cpp b/indra/llinventory/llinventory.cpp
index 81261f0767..b897198d10 100644
--- a/indra/llinventory/llinventory.cpp
+++ b/indra/llinventory/llinventory.cpp
@@ -40,9 +40,11 @@
///----------------------------------------------------------------------------
/// Exported functions
///----------------------------------------------------------------------------
+// FIXME D567 - what's the point of these, especially if we don't even use them consistently?
static const std::string INV_ITEM_ID_LABEL("item_id");
static const std::string INV_FOLDER_ID_LABEL("cat_id");
static const std::string INV_PARENT_ID_LABEL("parent_id");
+static const std::string INV_THUMBNAIL_ID_LABEL("thumbnail_id");
static const std::string INV_ASSET_TYPE_LABEL("type");
static const std::string INV_PREFERRED_TYPE_LABEL("preferred_type");
static const std::string INV_INVENTORY_TYPE_LABEL("inv_type");
@@ -99,6 +101,7 @@ void LLInventoryObject::copyObject(const LLInventoryObject* other)
mParentUUID = other->mParentUUID;
mType = other->mType;
mName = other->mName;
+ mThumbnailUUID = other->mThumbnailUUID;
}
const LLUUID& LLInventoryObject::getUUID() const
@@ -111,6 +114,11 @@ const LLUUID& LLInventoryObject::getParentUUID() const
return mParentUUID;
}
+const LLUUID& LLInventoryObject::getThumbnailUUID() const
+{
+ return mThumbnailUUID;
+}
+
const std::string& LLInventoryObject::getName() const
{
return mName;
@@ -160,6 +168,11 @@ void LLInventoryObject::setParent(const LLUUID& new_parent)
mParentUUID = new_parent;
}
+void LLInventoryObject::setThumbnailUUID(const LLUUID& thumbnail_uuid)
+{
+ mThumbnailUUID = thumbnail_uuid;
+}
+
void LLInventoryObject::setType(LLAssetType::EType type)
{
mType = type;
@@ -972,135 +985,6 @@ fail:
}
-// Deleted LLInventoryItem::exportFileXML() and LLInventoryItem::importXML()
-// because I can't find any non-test code references to it. 2009-05-04 JC
-
-S32 LLInventoryItem::packBinaryBucket(U8* bin_bucket, LLPermissions* perm_override) const
-{
- // Figure out which permissions to use.
- LLPermissions perm;
- if (perm_override)
- {
- // Use the permissions override.
- perm = *perm_override;
- }
- else
- {
- // Use the current permissions.
- perm = getPermissions();
- }
-
- // describe the inventory item
- char* buffer = (char*) bin_bucket;
- std::string creator_id_str;
-
- perm.getCreator().toString(creator_id_str);
- std::string owner_id_str;
- perm.getOwner().toString(owner_id_str);
- std::string last_owner_id_str;
- perm.getLastOwner().toString(last_owner_id_str);
- std::string group_id_str;
- perm.getGroup().toString(group_id_str);
- std::string asset_id_str;
- getAssetUUID().toString(asset_id_str);
- S32 size = sprintf(buffer, /* Flawfinder: ignore */
- "%d|%d|%s|%s|%s|%s|%s|%x|%x|%x|%x|%x|%s|%s|%d|%d|%x",
- getType(),
- getInventoryType(),
- getName().c_str(),
- creator_id_str.c_str(),
- owner_id_str.c_str(),
- last_owner_id_str.c_str(),
- group_id_str.c_str(),
- perm.getMaskBase(),
- perm.getMaskOwner(),
- perm.getMaskGroup(),
- perm.getMaskEveryone(),
- perm.getMaskNextOwner(),
- asset_id_str.c_str(),
- getDescription().c_str(),
- getSaleInfo().getSaleType(),
- getSaleInfo().getSalePrice(),
- getFlags()) + 1;
-
- return size;
-}
-
-void LLInventoryItem::unpackBinaryBucket(U8* bin_bucket, S32 bin_bucket_size)
-{
- // Early exit on an empty binary bucket.
- if (bin_bucket_size <= 1) return;
-
- if (NULL == bin_bucket)
- {
- LL_ERRS() << "unpackBinaryBucket failed. bin_bucket is NULL." << LL_ENDL;
- return;
- }
-
- // Convert the bin_bucket into a string.
- std::vector<char> item_buffer(bin_bucket_size+1);
- memcpy(&item_buffer[0], bin_bucket, bin_bucket_size); /* Flawfinder: ignore */
- item_buffer[bin_bucket_size] = '\0';
- std::string str(&item_buffer[0]);
-
- LL_DEBUGS() << "item buffer: " << str << LL_ENDL;
-
- // Tokenize the string.
- typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
- boost::char_separator<char> sep("|", "", boost::keep_empty_tokens);
- tokenizer tokens(str, sep);
- tokenizer::iterator iter = tokens.begin();
-
- // Extract all values.
- LLUUID item_id;
- item_id.generate();
- setUUID(item_id);
-
- LLAssetType::EType type;
- type = (LLAssetType::EType)(atoi((*(iter++)).c_str()));
- setType( type );
-
- LLInventoryType::EType inv_type;
- inv_type = (LLInventoryType::EType)(atoi((*(iter++)).c_str()));
- setInventoryType( inv_type );
-
- std::string name((*(iter++)).c_str());
- rename( name );
-
- LLUUID creator_id((*(iter++)).c_str());
- LLUUID owner_id((*(iter++)).c_str());
- LLUUID last_owner_id((*(iter++)).c_str());
- LLUUID group_id((*(iter++)).c_str());
- PermissionMask mask_base = strtoul((*(iter++)).c_str(), NULL, 16);
- PermissionMask mask_owner = strtoul((*(iter++)).c_str(), NULL, 16);
- PermissionMask mask_group = strtoul((*(iter++)).c_str(), NULL, 16);
- PermissionMask mask_every = strtoul((*(iter++)).c_str(), NULL, 16);
- PermissionMask mask_next = strtoul((*(iter++)).c_str(), NULL, 16);
- LLPermissions perm;
- perm.init(creator_id, owner_id, last_owner_id, group_id);
- perm.initMasks(mask_base, mask_owner, mask_group, mask_every, mask_next);
- setPermissions(perm);
- //LL_DEBUGS() << "perm: " << perm << LL_ENDL;
-
- LLUUID asset_id((*(iter++)).c_str());
- setAssetUUID(asset_id);
-
- std::string desc((*(iter++)).c_str());
- setDescription(desc);
-
- LLSaleInfo::EForSale sale_type;
- sale_type = (LLSaleInfo::EForSale)(atoi((*(iter++)).c_str()));
- S32 price = atoi((*(iter++)).c_str());
- LLSaleInfo sale_info(sale_type, price);
- setSaleInfo(sale_info);
-
- U32 flags = strtoul((*(iter++)).c_str(), NULL, 16);
- setFlags(flags);
-
- time_t now = time(NULL);
- setCreationDate(now);
-}
-
///----------------------------------------------------------------------------
/// Class LLInventoryCategory
///----------------------------------------------------------------------------
@@ -1152,6 +1036,7 @@ LLSD LLInventoryCategory::asLLSD() const
LLSD sd = LLSD();
sd["item_id"] = mUUID;
sd["parent_id"] = mParentUUID;
+ sd["thumbnail_id"] = mThumbnailUUID;
S8 type = static_cast<S8>(mPreferredType);
sd["type"] = type;
sd["name"] = mName;
@@ -1184,6 +1069,11 @@ bool LLInventoryCategory::fromLLSD(const LLSD& sd)
{
mParentUUID = sd[w];
}
+ w = INV_THUMBNAIL_ID_LABEL;
+ if (sd.has(w))
+ {
+ mThumbnailUUID = sd[w];
+ }
w = INV_ASSET_TYPE_LABEL;
if (sd.has(w))
{
diff --git a/indra/llinventory/llinventory.h b/indra/llinventory/llinventory.h
index 7d9f9704f1..dfe8b7659b 100644
--- a/indra/llinventory/llinventory.h
+++ b/indra/llinventory/llinventory.h
@@ -70,6 +70,7 @@ public:
virtual const LLUUID& getUUID() const; // inventoryID that this item points to
virtual const LLUUID& getLinkedUUID() const; // inventoryID that this item points to, else this item's inventoryID
const LLUUID& getParentUUID() const;
+ virtual const LLUUID& getThumbnailUUID() const;
virtual const std::string& getName() const;
virtual LLAssetType::EType getType() const;
LLAssetType::EType getActualType() const; // bypasses indirection for linked items
@@ -84,6 +85,7 @@ public:
void setUUID(const LLUUID& new_uuid);
virtual void rename(const std::string& new_name);
void setParent(const LLUUID& new_parent);
+ virtual void setThumbnailUUID(const LLUUID& thumbnail_uuid);
void setType(LLAssetType::EType type);
virtual void setCreationDate(time_t creation_date_utc); // only stored for items
@@ -108,6 +110,7 @@ public:
protected:
LLUUID mUUID;
LLUUID mParentUUID; // Parent category. Root categories have LLUUID::NULL.
+ LLUUID mThumbnailUUID;
LLAssetType::EType mType;
std::string mName;
time_t mCreationDate; // seconds from 1/1/1970, UTC
@@ -203,9 +206,6 @@ public:
// Helper Functions
//--------------------------------------------------------------------
public:
- // Pack all information needed to reconstruct this item into the given binary bucket.
- S32 packBinaryBucket(U8* bin_bucket, LLPermissions* perm_override = NULL) const;
- void unpackBinaryBucket(U8* bin_bucket, S32 bin_bucket_size);
LLSD asLLSD() const;
void asLLSD( LLSD& sd ) const;
bool fromLLSD(const LLSD& sd, bool is_new = true);
diff --git a/indra/llinventory/tests/inventorymisc_test.cpp b/indra/llinventory/tests/inventorymisc_test.cpp
index e8b063bffe..039fa938dd 100644
--- a/indra/llinventory/tests/inventorymisc_test.cpp
+++ b/indra/llinventory/tests/inventorymisc_test.cpp
@@ -400,27 +400,7 @@ namespace tut
// Deleted LLInventoryItem::exportFileXML() and LLInventoryItem::importXML()
// because I can't find any non-test code references to it. 2009-05-04 JC
}
-
- template<> template<>
- void inventory_object::test<10>()
- {
- LLPointer<LLInventoryItem> src1 = create_random_inventory_item();
- U8* bin_bucket = new U8[300];
- S32 bin_bucket_size = src1->packBinaryBucket(bin_bucket, NULL);
-
- LLPointer<LLInventoryItem> src2 = new LLInventoryItem();
- src2->unpackBinaryBucket(bin_bucket, bin_bucket_size);
- ensure_equals("1.sale price::getSalePrice() failed price", src1->getSaleInfo().getSalePrice(), src2->getSaleInfo().getSalePrice());
- ensure_equals("2.sale type::getSaleType() failed type", src1->getSaleInfo().getSaleType(), src2->getSaleInfo().getSaleType());
- ensure_equals("3.type::getType() failed", src1->getType(), src2->getType());
- ensure_equals("4.inventory type::getInventoryType() failed type", src1->getInventoryType(), src2->getInventoryType());
- ensure_equals("5.name::getName() failed", src1->getName(), src2->getName());
- ensure_equals("6.description::getDescription() failed", src1->getDescription(), src2->getDescription());
- ensure_equals("7.flags::getFlags() failed", src1->getFlags(), src2->getFlags());
-
- }
-
template<> template<>
void inventory_object::test<11>()
{