summaryrefslogtreecommitdiff
path: root/indra/llinventory
diff options
context:
space:
mode:
authorErik Kundiman <erik@megapahit.org>2026-09-01 18:35:23 +0800
committerErik Kundiman <erik@megapahit.org>2026-09-04 21:58:53 +0800
commit00bb3bb6f07660bd914d29a1389342bb3060d254 (patch)
tree431f574922494d2201718f13085f17bc6bd7fb42 /indra/llinventory
parenta8636720129952c10cf49ab80da21bf8b340b96c (diff)
parent4ef9f8f14b35ed388c294d53767a0dca0e890924 (diff)
Merge remote-tracking branch 'secondlife/release/26.4' into 26.4
Diffstat (limited to 'indra/llinventory')
-rw-r--r--indra/llinventory/CMakeLists.txt7
-rw-r--r--indra/llinventory/llinventory.cpp478
-rw-r--r--indra/llinventory/llinventory.h11
-rw-r--r--indra/llinventory/llinventorydefines.h5
-rw-r--r--indra/llinventory/llinventorytype.h9
-rw-r--r--indra/llinventory/llsettingsbase.cpp4
-rw-r--r--indra/llinventory/llsettingsdaycycle.cpp2
-rw-r--r--indra/llinventory/llsettingssky.cpp2
-rw-r--r--indra/llinventory/llsettingswater.cpp1
-rw-r--r--indra/llinventory/tests/llpermissions_test.cpp491
-rw-r--r--indra/llinventory/tests/llsaleinfo_test.cpp194
-rw-r--r--indra/llinventory/tests/lluserrelations_test.cpp156
12 files changed, 1191 insertions, 169 deletions
diff --git a/indra/llinventory/CMakeLists.txt b/indra/llinventory/CMakeLists.txt
index 88a2c33ae0..1630d32200 100644
--- a/indra/llinventory/CMakeLists.txt
+++ b/indra/llinventory/CMakeLists.txt
@@ -61,6 +61,10 @@ target_include_directories( llinventory INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}
include(LibraryInstall)
+if (USE_PRECOMPILED_HEADERS)
+ target_precompile_headers(llinventory REUSE_FROM llprecompiled)
+endif ()
+
#add unit tests
if (LL_TESTS)
INCLUDE(LLAddBuildTest)
@@ -73,4 +77,7 @@ if (LL_TESTS)
set(test_libs llinventory llmath llcorehttp llfilesystem )
LL_ADD_INTEGRATION_TEST(inventorymisc "" "${test_libs}")
LL_ADD_INTEGRATION_TEST(llparcel "" "${test_libs}")
+ LL_ADD_INTEGRATION_TEST(llpermissions "" "${test_libs}")
+ LL_ADD_INTEGRATION_TEST(llsaleinfo "" "${test_libs}")
+ LL_ADD_INTEGRATION_TEST(lluserrelations "" "${test_libs}")
endif (LL_TESTS)
diff --git a/indra/llinventory/llinventory.cpp b/indra/llinventory/llinventory.cpp
index f126accfb8..19ad49c6cc 100644
--- a/indra/llinventory/llinventory.cpp
+++ b/indra/llinventory/llinventory.cpp
@@ -33,6 +33,7 @@
#include "llxorcipher.h"
#include "llsd.h"
#include "llsdserialize.h"
+#include "llstreamtools.h"
#include "message.h"
#include <boost/tokenizer.hpp>
@@ -61,6 +62,9 @@ static const std::string INV_SALE_INFO_LABEL("sale_info");
static const std::string INV_FLAGS_LABEL("flags");
static const std::string INV_CREATION_DATE_LABEL("created_at");
static const std::string INV_TOGGLED_LABEL("toggled");
+static const std::string INV_SCRIPT_LABEL("script");
+static const std::string INV_RUNTIME_LABEL("runtime");
+static const std::string INV_METADATA_LABEL("metadata");
// key used by agent-inventory-service
static const std::string INV_ASSET_TYPE_LABEL_WS("type_default");
@@ -109,6 +113,7 @@ void LLInventoryObject::copyObject(const LLInventoryObject* other)
mName = other->mName;
mThumbnailUUID = other->mThumbnailUUID;
mFavorite = other->mFavorite;
+ mRuntime = other->mRuntime;
}
const LLUUID& LLInventoryObject::getUUID() const
@@ -131,6 +136,11 @@ bool LLInventoryObject::getIsFavorite() const
return mFavorite;
}
+const std::string& LLInventoryObject::getRuntime() const
+{
+ return mRuntime;
+}
+
const std::string& LLInventoryObject::getName() const
{
return mName;
@@ -190,9 +200,23 @@ void LLInventoryObject::setFavorite(bool favorite)
mFavorite = favorite;
}
+void LLInventoryObject::setRuntime(std::string_view runtime)
+{
+ // Store the runtime unconditionally; it will be validated/cleared
+ // when the final asset type is known (see setType()).
+ mRuntime = runtime;
+}
+
void LLInventoryObject::setType(LLAssetType::EType type)
{
mType = type;
+
+ // Only LSL text assets are expected to have a runtime; clear any
+ // previously stored runtime for other asset types.
+ if (mType != LLAssetType::AT_LSL_TEXT)
+ {
+ mRuntime.clear();
+ }
}
@@ -279,6 +303,15 @@ bool LLInventoryObject::importLegacyStream(std::istream& input_stream)
{
setFavorite(false);
}
+
+ if (metadata.has("script") && metadata["script"].has("runtime"))
+ {
+ setRuntime(metadata["script"]["runtime"].asString());
+ }
+ else
+ {
+ setRuntime(std::string());
+ }
}
else if(0 == strcmp("name", keyword))
{
@@ -421,6 +454,7 @@ void LLInventoryItem::copyItem(const LLInventoryItem* other)
mInventoryType = other->mInventoryType;
mFlags = other->mFlags;
mCreationDate = other->mCreationDate;
+ mRuntime = other->mRuntime;
}
// If this is a linked item, then the UUID of the base object is
@@ -784,6 +818,16 @@ bool LLInventoryItem::importLegacyStream(std::istream& input_stream)
{
setFavorite(false);
}
+
+ if (metadata.has("script") && metadata["script"].has("runtime"))
+ {
+ setRuntime(metadata["script"]["runtime"].asString());
+ }
+ else
+ {
+ setRuntime(std::string());
+ }
+
}
else if(0 == strcmp("inv_type", keyword))
{
@@ -827,6 +871,42 @@ bool LLInventoryItem::importLegacyStream(std::istream& input_stream)
}
mDescription.assign(valuestr);
+
+ // Currently server side doesn't handle escaped newline right
+ // and they end up unescaped.
+ // And even if we do copy the data correctly, moving the item
+ // from notecard using CopyInventoryFromNotecard drops the
+ // content after first the new line.
+ //
+ // Check if the description ends with | on this line
+ if (strchr(buffer, '|') == nullptr)
+ {
+ // No | found, continue reading lines until we find one
+ char next_buffer[MAX_STRING];
+ while (input_stream.good())
+ {
+ input_stream.getline(next_buffer, MAX_STRING);
+
+ // Look for | delimiter
+ char* pipe_pos = strchr(next_buffer, '|');
+ if (pipe_pos != nullptr)
+ {
+ // Found the delimiter, add text up to it
+ *pipe_pos = '\0'; // Terminate at the pipe
+ mDescription += '\n';
+ mDescription += next_buffer;
+ break;
+ }
+ else
+ {
+ // No delimiter yet, add the whole line
+ mDescription += '\n';
+ mDescription += next_buffer;
+ }
+ }
+ }
+
+ unescape_string(mDescription);
LLStringUtil::replaceNonstandardASCII(mDescription, ' ');
/* TODO -- ask Ian about this code
const char *donkey = mDescription.c_str();
@@ -920,7 +1000,12 @@ bool LLInventoryItem::exportLegacyStream(std::ostream& output_stream, bool inclu
output_stream << buffer;
mSaleInfo.exportLegacyStream(output_stream);
output_stream << "\t\tname\t" << mName.c_str() << "|\n";
- output_stream << "\t\tdesc\t" << mDescription.c_str() << "|\n";
+ // Note: Currently server side doesn't handle newline right for notecards.
+ // Even if we escape or replace all newlines with spaces, notecard's
+ // import buffer still ends up with newlines.
+ std::string desc = mDescription;
+ escape_string(desc);
+ output_stream << "\t\tdesc\t" << desc.c_str() << "|\n";
output_stream << "\t\tcreation_date\t" << mCreationDate << "\n";
output_stream << "\t}\n";
return true;
@@ -941,12 +1026,19 @@ void LLInventoryItem::asLLSD( LLSD& sd ) const
if (mThumbnailUUID.notNull())
{
- sd[INV_THUMBNAIL_LABEL] = LLSD().with(INV_ASSET_ID_LABEL, mThumbnailUUID);
+ LLSD& thumbnail = sd[INV_THUMBNAIL_LABEL];
+ thumbnail[INV_ASSET_ID_LABEL] = mThumbnailUUID;
}
if (mFavorite)
{
- sd[INV_FAVORITE_LABEL] = LLSD().with(INV_TOGGLED_LABEL, mFavorite);
+ LLSD& favorite = sd[INV_FAVORITE_LABEL];
+ favorite[INV_TOGGLED_LABEL] = mFavorite;
+ }
+
+ if (!mRuntime.empty())
+ {
+ sd[INV_SCRIPT_LABEL] = LLSD().with(INV_RUNTIME_LABEL, mRuntime);
}
U32 mask = mPermissions.getMaskBase();
@@ -963,7 +1055,7 @@ void LLInventoryItem::asLLSD( LLSD& sd ) const
cipher.encrypt(shadow_id.mData, UUID_BYTES);
sd[INV_SHADOW_ID_LABEL] = shadow_id;
}
- sd[INV_ASSET_TYPE_LABEL] = std::string(LLAssetType::lookup(mType));
+ sd[INV_ASSET_TYPE_LABEL] = LLAssetType::lookup(mType);
const std::string inv_type_str = LLInventoryType::lookup(mInventoryType);
if(!inv_type_str.empty())
{
@@ -1002,171 +1094,231 @@ bool LLInventoryItem::fromLLSD(const LLSD& sd, bool is_new)
end = sd.endMap();
for (i = sd.beginMap(); i != end; ++i)
{
- if (i->first == INV_ITEM_ID_LABEL)
- {
- mUUID = i->second;
- continue;
- }
-
- if (i->first == INV_PARENT_ID_LABEL)
- {
- mParentUUID = i->second;
- continue;
- }
-
- if (i->first == INV_THUMBNAIL_LABEL)
- {
- const LLSD &thumbnail_map = i->second;
- if (thumbnail_map.has(INV_ASSET_ID_LABEL))
- {
- mThumbnailUUID = thumbnail_map[INV_ASSET_ID_LABEL];
- }
- /* Example:
- <key> asset_id </key>
- <uuid> acc0ec86 - 17f2 - 4b92 - ab41 - 6718b1f755f7 </uuid>
- <key> perms </key>
- <integer> 8 </integer>
- <key>service</key>
- <integer> 3 </integer>
- <key>version</key>
- <integer> 1 </key>
- */
- continue;
- }
-
- if (i->first == INV_THUMBNAIL_ID_LABEL)
- {
- mThumbnailUUID = i->second.asUUID();
- continue;
- }
-
- if (i->first == INV_FAVORITE_LABEL)
- {
- const LLSD& favorite_map = i->second;
- if (favorite_map.has(INV_TOGGLED_LABEL))
- {
- mFavorite = favorite_map[INV_TOGGLED_LABEL].asBoolean();
- }
- continue;
- }
+ // Use string length as a fast pre-filter before string comparison
+ const std::string& key = i->first;
+ const LLSD& value = i->second;
+ const size_t key_len = key.length();
- if (i->first == INV_PERMISSIONS_LABEL)
+ switch (key_len)
{
- mPermissions.importLLSD(i->second);
- continue;
- }
-
- if (i->first == INV_SALE_INFO_LABEL)
- {
- // Sale info used to contain next owner perm. It is now in
- // the permissions. Thus, we read that out, and fix legacy
- // objects. It's possible this op would fail, but it
- // should pick up the vast majority of the tasks.
- bool has_perm_mask = false;
- U32 perm_mask = 0;
- if (!mSaleInfo.fromLLSD(i->second, has_perm_mask, perm_mask))
- {
- return false;
- }
- if (has_perm_mask)
- {
- if (perm_mask == PERM_NONE)
+ case 4: // "name", "desc", "type"
+ if (key == INV_NAME_LABEL) // "name"
{
- perm_mask = mPermissions.getMaskOwner();
+ mName = value.asString();
+ LLStringUtil::replaceNonstandardASCII(mName, ' ');
+ LLStringUtil::replaceChar(mName, '|', ' ');
+ continue;
}
- // fair use fix.
- if (!(perm_mask & PERM_COPY))
+ if (key == INV_DESC_LABEL) // "desc"
{
- perm_mask |= PERM_TRANSFER;
+ mDescription = value.asString();
+ LLStringUtil::replaceNonstandardASCII(mDescription, ' ');
+ continue;
}
- mPermissions.setMaskNext(perm_mask);
- }
- continue;
- }
-
- if (i->first == INV_SHADOW_ID_LABEL)
- {
- mAssetUUID = i->second;
- LLXORCipher cipher(MAGIC_ID.mData, UUID_BYTES);
- cipher.decrypt(mAssetUUID.mData, UUID_BYTES);
- continue;
- }
+ if (key == INV_ASSET_TYPE_LABEL) // "type"
+ {
+ if (value.isString())
+ {
+ mType = LLAssetType::lookup(value.asStringRef().c_str());
+ }
+ else if (value.isInteger())
+ {
+ S8 type = (U8)value.asInteger();
+ mType = static_cast<LLAssetType::EType>(type);
+ }
+ continue;
+ }
+ break;
- if (i->first == INV_ASSET_ID_LABEL)
- {
- mAssetUUID = i->second;
- continue;
- }
+ case 5: // "flags"
+ if (key == INV_FLAGS_LABEL)
+ {
+ if (value.isBinary())
+ {
+ mFlags = ll_U32_from_sd(value);
+ }
+ else if (value.isInteger())
+ {
+ mFlags = value.asInteger();
+ }
+ continue;
+ }
+ break;
- if (i->first == INV_LINKED_ID_LABEL)
- {
- mAssetUUID = i->second;
- continue;
- }
+ case 6: // "script"
+ if (key == INV_SCRIPT_LABEL)
+ {
+ const LLSD& script_map = value;
+ if (script_map.has(INV_RUNTIME_LABEL))
+ {
+ mRuntime = script_map[INV_RUNTIME_LABEL].asString();
+ }
+ else
+ {
+ // Clear stale runtime data when a script block is
+ // present without an explicit runtime value.
+ mRuntime.clear();
+ }
+ continue;
+ }
+ break;
- if (i->first == INV_ASSET_TYPE_LABEL)
- {
- LLSD const &label = i->second;
- if (label.isString())
- {
- mType = LLAssetType::lookup(label.asStringRef().c_str());
- }
- else if (label.isInteger())
- {
- S8 type = (U8) label.asInteger();
- mType = static_cast<LLAssetType::EType>(type);
- }
- continue;
- }
+ case 7: // "item_id"
+ if (key == INV_ITEM_ID_LABEL)
+ {
+ mUUID = value;
+ continue;
+ }
+ break;
- if (i->first == INV_INVENTORY_TYPE_LABEL)
- {
- LLSD const &label = i->second;
- if (label.isString())
- {
- mInventoryType = LLInventoryType::lookup(label.asStringRef().c_str());
- }
- else if (label.isInteger())
- {
- S8 type = (U8) label.asInteger();
- mInventoryType = static_cast<LLInventoryType::EType>(type);
- }
- continue;
- }
+ case 8: // "asset_id", "inv_type"
+ if (key == INV_ASSET_ID_LABEL)
+ {
+ mAssetUUID = value;
+ continue;
+ }
+ if (key == INV_INVENTORY_TYPE_LABEL) // "inv_type"
+ {
+ if (value.isString())
+ {
+ mInventoryType = LLInventoryType::lookup(value.asStringRef().c_str());
+ }
+ else if (value.isInteger())
+ {
+ S8 type = (U8)value.asInteger();
+ mInventoryType = static_cast<LLInventoryType::EType>(type);
+ }
+ continue;
+ }
+ if (key == INV_FAVORITE_LABEL) // "favorite"
+ {
+ if (value.has(INV_TOGGLED_LABEL))
+ {
+ mFavorite = value[INV_TOGGLED_LABEL].asBoolean();
+ }
+ continue;
+ }
+ if (key == INV_METADATA_LABEL)
+ {
+ // Server (non-AIS) exports thumbnail, favorite, and
+ // script metadata under a "metadata" wrapper.
+ const LLSD& metadata = value;
+ if (metadata.has(INV_THUMBNAIL_LABEL))
+ {
+ const LLSD& thumbnail = metadata[INV_THUMBNAIL_LABEL];
+ if (thumbnail.has(INV_ASSET_ID_LABEL))
+ {
+ mThumbnailUUID = thumbnail[INV_ASSET_ID_LABEL].asUUID();
+ }
+ }
+ if (metadata.has(INV_FAVORITE_LABEL))
+ {
+ const LLSD& favorite = metadata[INV_FAVORITE_LABEL];
+ if (favorite.has(INV_TOGGLED_LABEL))
+ {
+ mFavorite = favorite[INV_TOGGLED_LABEL].asBoolean();
+ }
+ }
+ if (metadata.has(INV_SCRIPT_LABEL)
+ && metadata[INV_SCRIPT_LABEL].has(INV_RUNTIME_LABEL))
+ {
+ mRuntime = metadata[INV_SCRIPT_LABEL][INV_RUNTIME_LABEL].asString();
+ }
+ continue;
+ }
+ break;
- if (i->first == INV_FLAGS_LABEL)
- {
- LLSD const &label = i->second;
- if (label.isBinary())
- {
- mFlags = ll_U32_from_sd(label);
- }
- else if (label.isInteger())
- {
- mFlags = label.asInteger();
- }
- continue;
- }
+ case 9: // "parent_id", "shadow_id", "linked_id", "sale_info", "thumbnail"
+ if (key == INV_PARENT_ID_LABEL)
+ {
+ mParentUUID = value;
+ continue;
+ }
+ if (key == INV_SHADOW_ID_LABEL)
+ {
+ mAssetUUID = value;
+ LLXORCipher cipher(MAGIC_ID.mData, UUID_BYTES);
+ cipher.decrypt(mAssetUUID.mData, UUID_BYTES);
+ continue;
+ }
+ if (key == INV_LINKED_ID_LABEL)
+ {
+ mAssetUUID = value;
+ continue;
+ }
+ if (key == INV_SALE_INFO_LABEL)
+ {
+ // Sale info used to contain next owner perm. It is now in
+ // the permissions. Thus, we read that out, and fix legacy
+ // objects. It's possible this op would fail, but it
+ // should pick up the vast majority of the tasks.
+ bool has_perm_mask = false;
+ U32 perm_mask = 0;
+ if (!mSaleInfo.fromLLSD(value, has_perm_mask, perm_mask))
+ {
+ return false;
+ }
+ if (has_perm_mask)
+ {
+ if (perm_mask == PERM_NONE)
+ {
+ perm_mask = mPermissions.getMaskOwner();
+ }
+ // fair use fix.
+ if (!(perm_mask & PERM_COPY))
+ {
+ perm_mask |= PERM_TRANSFER;
+ }
+ mPermissions.setMaskNext(perm_mask);
+ }
+ continue;
+ }
+ if (key == INV_THUMBNAIL_LABEL)
+ {
+ if (value.has(INV_ASSET_ID_LABEL))
+ {
+ mThumbnailUUID = value[INV_ASSET_ID_LABEL];
+ }
+ /* Example:
+ <key> asset_id </key>
+ <uuid> acc0ec86 - 17f2 - 4b92 - ab41 - 6718b1f755f7 </uuid>
+ <key> perms </key>
+ <integer> 8 </integer>
+ <key>service</key>
+ <integer> 3 </integer>
+ <key>version</key>
+ <integer> 1 </key>
+ */
+ continue;
+ }
+ break;
+ case 10: // "created_at"
+ if (key == INV_CREATION_DATE_LABEL)
+ {
+ mCreationDate = value.asInteger();
+ continue;
+ }
+ break;
- if (i->first == INV_NAME_LABEL)
- {
- mName = i->second.asString();
- LLStringUtil::replaceNonstandardASCII(mName, ' ');
- LLStringUtil::replaceChar(mName, '|', ' ');
- continue;
- }
+ case 11: // "permissions"
+ if (key == INV_PERMISSIONS_LABEL)
+ {
+ mPermissions.importLLSD(value);
+ continue;
+ }
+ break;
- if (i->first == INV_DESC_LABEL)
- {
- mDescription = i->second.asString();
- LLStringUtil::replaceNonstandardASCII(mDescription, ' ');
- continue;
- }
+ case 12: // "thumbnail_id"
+ if (key == INV_THUMBNAIL_ID_LABEL)
+ {
+ mThumbnailUUID = value.asUUID();
+ continue;
+ }
+ break;
- if (i->first == INV_CREATION_DATE_LABEL)
- {
- mCreationDate = i->second.asInteger();
- continue;
+ default:
+ // Unknown field - skip
+ break;
}
}
@@ -1242,12 +1394,14 @@ LLSD LLInventoryCategory::asLLSD() const
if (mThumbnailUUID.notNull())
{
- sd[INV_THUMBNAIL_LABEL] = LLSD().with(INV_ASSET_ID_LABEL, mThumbnailUUID);
+ LLSD& thumbnail = sd[INV_THUMBNAIL_LABEL];
+ thumbnail[INV_ASSET_ID_LABEL] = mThumbnailUUID;
}
if (mFavorite)
{
- sd[INV_FAVORITE_LABEL] = LLSD().with(INV_TOGGLED_LABEL, mFavorite);
+ LLSD& favorite = sd[INV_FAVORITE_LABEL];
+ favorite[INV_TOGGLED_LABEL] = mFavorite;
}
return sd;
@@ -1469,6 +1623,8 @@ bool LLInventoryCategory::importLegacyStream(std::istream& input_stream)
{
setFavorite(false);
}
+ setRuntime(std::string());
+
}
else
{
@@ -1507,17 +1663,19 @@ void LLInventoryCategory::exportLLSD(LLSD& cat_data) const
{
cat_data[INV_FOLDER_ID_LABEL] = mUUID;
cat_data[INV_PARENT_ID_LABEL] = mParentUUID;
- cat_data[INV_ASSET_TYPE_LABEL] = std::string(LLAssetType::lookup(mType));
+ cat_data[INV_ASSET_TYPE_LABEL] = LLAssetType::lookup(mType);
cat_data[INV_PREFERRED_TYPE_LABEL] = LLFolderType::lookup(mPreferredType);
cat_data[INV_NAME_LABEL] = mName;
if (mThumbnailUUID.notNull())
{
- cat_data[INV_THUMBNAIL_LABEL] = LLSD().with(INV_ASSET_ID_LABEL, mThumbnailUUID);
+ LLSD& thumbnail = cat_data[INV_THUMBNAIL_LABEL];
+ thumbnail[INV_ASSET_ID_LABEL] = mThumbnailUUID;
}
if (mFavorite)
{
- cat_data[INV_FAVORITE_LABEL] = LLSD().with(INV_TOGGLED_LABEL, mFavorite);
+ LLSD& favorite = cat_data[INV_FAVORITE_LABEL];
+ favorite[INV_TOGGLED_LABEL] = mFavorite;
}
}
diff --git a/indra/llinventory/llinventory.h b/indra/llinventory/llinventory.h
index 181c46226c..c22b17ab66 100644
--- a/indra/llinventory/llinventory.h
+++ b/indra/llinventory/llinventory.h
@@ -24,11 +24,11 @@
* $/LicenseInfo$
*/
-#ifndef LL_LLINVENTORY_H
-#define LL_LLINVENTORY_H
+#pragma once
#include "llfoldertype.h"
#include "llinventorytype.h"
+#include "llinventorydefines.h"
#include "llpermissions.h"
#include "llrefcount.h"
#include "llsaleinfo.h"
@@ -72,6 +72,7 @@ public:
const LLUUID& getParentUUID() const;
virtual const LLUUID& getThumbnailUUID() const;
virtual bool getIsFavorite() const;
+ virtual const std::string& getRuntime() const;
virtual const std::string& getName() const;
virtual LLAssetType::EType getType() const;
LLAssetType::EType getActualType() const; // bypasses indirection for linked items
@@ -88,6 +89,7 @@ public:
void setParent(const LLUUID& new_parent);
virtual void setThumbnailUUID(const LLUUID& thumbnail_uuid);
virtual void setFavorite(bool favorite);
+ virtual void setRuntime(std::string_view runtime);
void setType(LLAssetType::EType type);
virtual void setCreationDate(time_t creation_date_utc); // only stored for items
@@ -114,6 +116,7 @@ protected:
LLUUID mParentUUID; // Parent category. Root categories have LLUUID::NULL.
LLUUID mThumbnailUUID;
bool mFavorite;
+ std::string mRuntime;
LLAssetType::EType mType;
std::string mName;
time_t mCreationDate; // seconds from 1/1/1970, UTC
@@ -166,6 +169,7 @@ public:
virtual const std::string& getActualDescription() const; // Does not follow links
virtual const LLSaleInfo& getSaleInfo() const;
virtual LLInventoryType::EType getInventoryType() const;
+ virtual U8 getInventorySubType() const { return getFlags() & LLInventoryItemFlags::II_FLAGS_SUBTYPE_MASK; }
virtual U32 getFlags() const;
virtual time_t getCreationDate() const;
virtual U32 getCRC32() const; // really more of a checksum.
@@ -182,6 +186,7 @@ public:
void setSaleInfo(const LLSaleInfo& sale_info);
void setPermissions(const LLPermissions& perm);
void setInventoryType(LLInventoryType::EType inv_type);
+ void setInventorySubType(U8 sub_type) { setFlags((getFlags() & ~LLInventoryItemFlags::II_FLAGS_SUBTYPE_MASK) | (sub_type & LLInventoryItemFlags::II_FLAGS_SUBTYPE_MASK)); }
void setFlags(U32 flags);
void setCreator(const LLUUID& creator); // only used for calling cards
@@ -294,5 +299,3 @@ protected:
LLSD ll_create_sd_from_inventory_item(LLPointer<LLInventoryItem> item);
LLSD ll_create_sd_from_inventory_category(LLPointer<LLInventoryCategory> cat);
LLPointer<LLInventoryCategory> ll_create_category_from_sd(const LLSD& sd_cat);
-
-#endif // LL_LLINVENTORY_H
diff --git a/indra/llinventory/llinventorydefines.h b/indra/llinventory/llinventorydefines.h
index 8e7bd87ac4..9088d172d9 100644
--- a/indra/llinventory/llinventorydefines.h
+++ b/indra/llinventory/llinventorydefines.h
@@ -24,8 +24,7 @@
* $/LicenseInfo$
*/
-#ifndef LL_LLINVENTORYDEFINES_H
-#define LL_LLINVENTORYDEFINES_H
+#pragma once
// Consts for "key" field in the task inventory update message
extern const U8 TASK_INVENTORY_ITEM_KEY;
@@ -97,5 +96,3 @@ public:
// on a pre-existing inventory item (DEV-28098 and DEV-30997)
};
};
-
-#endif // LL_LLINVENTORYDEFINES_H
diff --git a/indra/llinventory/llinventorytype.h b/indra/llinventory/llinventorytype.h
index c90f8aa107..ce8bedb68d 100644
--- a/indra/llinventory/llinventorytype.h
+++ b/indra/llinventory/llinventorytype.h
@@ -123,6 +123,8 @@ public:
ICONNAME_MATERIAL,
+ ICONNAME_SCRIPT_LUAU,
+
ICONNAME_INVALID,
ICONNAME_UNKNOWN,
ICONNAME_COUNT,
@@ -150,6 +152,13 @@ private:
~LLInventoryType( void );
};
+// Subtypes for scripts, (inventory type IT_LSL).
+enum ScriptSubtype_t
+{
+ SST_LSL = 0,
+ SST_LUA = 1
+};
+
// helper function that returns true if inventory type and asset type
// are potentially compatible. For example, an attachment must be an
// object, but a wearable can be a bodypart or clothing asset.
diff --git a/indra/llinventory/llsettingsbase.cpp b/indra/llinventory/llsettingsbase.cpp
index 6c07c3309a..0a20f521ce 100644
--- a/indra/llinventory/llsettingsbase.cpp
+++ b/indra/llinventory/llsettingsbase.cpp
@@ -25,6 +25,8 @@
* $/LicenseInfo$
*/
+#include "linden_common.h"
+
#include "llsettingsbase.h"
#include "llmath.h"
@@ -758,7 +760,7 @@ void LLSettingsBlender::update(const LLSettingsBase::BlendFactor& blendf)
F64 LLSettingsBlender::setBlendFactor(const LLSettingsBase::BlendFactor& blendf_in)
{
LLSettingsBase::TrackPosition blendf = (F32)blendf_in;
- llassert(!isnan(blendf));
+ llassert(!std::isnan(blendf));
if (blendf >= 1.0)
{
triggerComplete();
diff --git a/indra/llinventory/llsettingsdaycycle.cpp b/indra/llinventory/llsettingsdaycycle.cpp
index 2baf140e6a..ebd8602c8d 100644
--- a/indra/llinventory/llsettingsdaycycle.cpp
+++ b/indra/llinventory/llsettingsdaycycle.cpp
@@ -25,6 +25,8 @@
* $/LicenseInfo$
*/
+#include "linden_common.h"
+
#include "llsettingsdaycycle.h"
#include "llerror.h"
#include <algorithm>
diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp
index 1e5a2280e3..342bd6255d 100644
--- a/indra/llinventory/llsettingssky.cpp
+++ b/indra/llinventory/llsettingssky.cpp
@@ -25,6 +25,8 @@
* $/LicenseInfo$
*/
+#include "linden_common.h"
+
#include "llsettingssky.h"
#include "indra_constants.h"
#include <algorithm>
diff --git a/indra/llinventory/llsettingswater.cpp b/indra/llinventory/llsettingswater.cpp
index b8946dbdba..c245ef2528 100644
--- a/indra/llinventory/llsettingswater.cpp
+++ b/indra/llinventory/llsettingswater.cpp
@@ -24,6 +24,7 @@
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
+#include "linden_common.h"
#include "llsettingswater.h"
#include <algorithm>
diff --git a/indra/llinventory/tests/llpermissions_test.cpp b/indra/llinventory/tests/llpermissions_test.cpp
new file mode 100644
index 0000000000..1328939004
--- /dev/null
+++ b/indra/llinventory/tests/llpermissions_test.cpp
@@ -0,0 +1,491 @@
+/**
+ * @file llpermissions_tut.cpp
+ * @author Adroit
+ * @date March 2007
+ * @brief llpermissions test cases.
+ *
+ * $LicenseInfo:firstyear=2007&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 <tut/tut.hpp>
+#include "linden_common.h"
+
+#include "lltut.h"
+
+#include "message.h"
+#include "llpermissions.h"
+
+
+namespace tut
+{
+ struct permission
+ {
+ };
+ typedef test_group<permission> permission_t;
+ typedef permission_t::object permission_object_t;
+ tut::permission_t tut_permission("permission");
+
+ template<> template<>
+ void permission_object_t::test<1>()
+ {
+ LLPermissions permissions;
+ LLUUID uuid = permissions.getCreator();
+ LLUUID uuid1 = permissions.getOwner();
+ LLUUID uuid2 = permissions.getGroup();
+ LLUUID uuid3 = permissions.getLastOwner();
+
+ ensure("LLPermission Get Functions failed", (uuid == LLUUID::null && uuid1 == LLUUID::null &&
+ uuid2 == LLUUID::null && uuid3 == LLUUID::null));
+ ensure("LLPermission Get Functions failed", (permissions.getMaskBase() == PERM_ALL && permissions.getMaskOwner() == PERM_ALL &&
+ permissions.getMaskGroup() == PERM_ALL && permissions.getMaskEveryone() == PERM_ALL && permissions.getMaskNextOwner() == PERM_ALL));
+ ensure("Ownership functions failed", ((! permissions.isGroupOwned()) && (! permissions.isOwned())));
+ }
+
+ template<> template<>
+ void permission_object_t::test<2>()
+ {
+ LLPermissions permissions;
+ LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
+ LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806");
+ LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
+ LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
+ permissions.init(creator, owner, lastOwner, group);
+
+ ensure_equals("init/getCreator():failed to return the creator ", creator, permissions.getCreator());
+ ensure_equals("init/getOwner():failed to return the owner ", owner, permissions.getOwner());
+ ensure_equals("init/getLastOwner():failed to return the group ", lastOwner, permissions.getLastOwner());
+ ensure_equals("init/getGroup():failed to return the group ", group, permissions.getGroup());
+ }
+
+ template<> template<>
+ void permission_object_t::test<3>()
+ {
+ LLPermissions permissions;
+ U32 base = PERM_ALL;
+ U32 owner = PERM_ITEM_UNRESTRICTED; //PERM_ITEM_UNRESTRICTED = PERM_MODIFY | PERM_COPY | PERM_TRANSFER;
+ U32 group = PERM_TRANSFER | PERM_MOVE | PERM_COPY|PERM_MODIFY;
+ U32 everyone = PERM_TRANSFER | PERM_MOVE | PERM_MODIFY;
+ U32 next = PERM_NONE;
+
+ U32 fixedbase = base;
+ U32 fixedowner = PERM_ITEM_UNRESTRICTED; //owner & fixedbase
+ U32 fixedgroup = PERM_ITEM_UNRESTRICTED; // no PERM_MOVE as owner does not have that perm either
+ U32 fixedeveryone = PERM_TRANSFER; // no PERM_MOVE. Everyone can never modify.
+ U32 fixednext = PERM_NONE;
+
+ permissions.initMasks(base, owner, everyone, group, next); // will fix perms if not allowed.
+ ensure_equals("initMasks/getMaskBase():failed to return the MaskBase ", fixedbase, permissions.getMaskBase());
+ ensure_equals("initMasks/getMaskOwner():failed to return the MaskOwner ", fixedowner, permissions.getMaskOwner());
+ ensure_equals("initMasks/getMaskEveryone():failed to return the MaskGroup ", fixedgroup, permissions.getMaskGroup());
+ ensure_equals("initMasks/getMaskEveryone():failed to return the MaskEveryone ", fixedeveryone, permissions.getMaskEveryone());
+ ensure_equals("initMasks/getMaskNextOwner():failed to return the MaskNext ", fixednext, permissions.getMaskNextOwner());
+
+ // explictly set should maintain the values
+ permissions.setMaskBase(base); //no fixing
+ ensure_equals("setMaskBase/getMaskBase():failed to return the MaskBase ", base, permissions.getMaskBase());
+
+ permissions.setMaskOwner(owner);
+ ensure_equals("setMaskOwner/getMaskOwner():failed to return the MaskOwner ", owner, permissions.getMaskOwner());
+
+ permissions.setMaskEveryone(everyone);
+ ensure_equals("setMaskEveryone/getMaskEveryone():failed to return the MaskEveryone ", everyone, permissions.getMaskEveryone());
+
+ permissions.setMaskGroup(group);
+ ensure_equals("setMaskGroup/getMaskEveryone():failed to return the MaskGroup ", group, permissions.getMaskGroup());
+
+ permissions.setMaskNext(next);
+ ensure_equals("setMaskNext/getMaskNextOwner():failed to return the MaskNext ", next, permissions.getMaskNextOwner());
+
+ // further tests can be added to ensure perms for owner/group/everyone etc. get properly fixed.
+ // code however suggests that there is no explict check if the perms are correct and the user of this
+ // class is expected to know how to use them correctly. skipping further test cases for now for various
+ // perm combinations.
+ }
+
+ template<> template<>
+ void permission_object_t::test<4>()
+ {
+ LLPermissions perm,perm1;
+ LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
+ LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806");
+ LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
+ LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
+ perm1.init(creator,owner,lastOwner,group);
+ perm.set(perm1);
+ ensure("set():failed to set ", (creator == perm.getCreator()) && (owner == perm.getOwner())&&
+ (lastOwner == perm.getLastOwner())&& (group == perm.getGroup()));
+ }
+
+ template<> template<>
+ void permission_object_t::test<5>()
+ {
+ LLPermissions perm,perm1;
+ LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
+ LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806");
+ LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
+ LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
+ perm1.init(creator,owner,lastOwner,group);
+
+ U32 base = PERM_TRANSFER;
+ U32 ownerp = PERM_TRANSFER;
+ U32 groupp = PERM_TRANSFER;
+ U32 everyone = PERM_TRANSFER;
+ U32 next = PERM_NONE;
+
+ perm1.initMasks(base, ownerp, everyone, groupp, next);
+
+ base = PERM_ALL;
+ ownerp = PERM_ITEM_UNRESTRICTED; //PERM_ITEM_UNRESTRICTED = PERM_MODIFY | PERM_COPY | PERM_TRANSFER;
+ groupp = PERM_TRANSFER | PERM_COPY|PERM_MODIFY;
+ everyone = PERM_TRANSFER;
+ next = PERM_NONE;
+
+ perm.init(creator,owner,lastOwner,group);
+ perm.initMasks(base, ownerp, everyone, groupp, next);
+
+ // restrict permissions by accumulation
+ perm.accumulate(perm1);
+
+ U32 fixedbase = PERM_TRANSFER | PERM_MOVE;
+ U32 fixedowner = PERM_TRANSFER;
+ U32 fixedgroup = PERM_TRANSFER;
+ U32 fixedeveryone = PERM_TRANSFER;
+ U32 fixednext = PERM_NONE;
+
+ ensure_equals("accumulate failed ", fixedbase, perm.getMaskBase());
+ ensure_equals("accumulate failed ", fixedowner, perm.getMaskOwner());
+ ensure_equals("accumulate failed ", fixedgroup, perm.getMaskGroup());
+ ensure_equals("accumulate failed ", fixedeveryone, perm.getMaskEveryone());
+ ensure_equals("accumulate failed ", fixednext, perm.getMaskNextOwner());
+ }
+
+ template<> template<>
+ void permission_object_t::test<6>()
+ {
+ LLPermissions perm;
+ LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
+ LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806");
+ LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
+ LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
+ perm.init(creator,owner,lastOwner,group);
+ ensure_equals("getSafeOwner:failed ", owner,perm.getSafeOwner());
+
+ ///NULL Owner
+ perm.init(creator,LLUUID::null,lastOwner,group);
+ ensure_equals("getSafeOwner:failed ", group, perm.getSafeOwner());
+ }
+
+ template<> template<>
+ void permission_object_t::test<7>()
+ {
+ LLPermissions perm1;
+ LLUUID uuid;
+ bool is_group_owned = false;
+ ensure("1:getOwnership:failed ", ! perm1.getOwnership(uuid,is_group_owned));
+
+ LLPermissions perm;
+ LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
+ LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806");
+ LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
+ LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
+ perm.init(creator,owner,lastOwner,group);
+ perm.getOwnership(uuid,is_group_owned);
+ ensure("2:getOwnership:failed ", ((uuid == owner) && (! is_group_owned)));
+
+ perm.init(creator,LLUUID::null,lastOwner,group);
+ perm.getOwnership(uuid,is_group_owned);
+ ensure("3:getOwnership:failed ", ((uuid == group) && is_group_owned));
+ }
+
+ template<> template<>
+ void permission_object_t::test<8>()
+ {
+ LLPermissions perm,perm1;
+ LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
+ LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806");
+ LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
+ LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
+ perm.init(creator,owner,lastOwner,group);
+ perm1.init(creator,owner,lastOwner,group);
+ ensure_equals("getCRC32:failed ", perm.getCRC32(),perm1.getCRC32());
+ }
+
+ template<> template<>
+ void permission_object_t::test<9>()
+ {
+ LLPermissions perm;
+ LLUUID agent("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
+ LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806");
+ LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
+ bool is_atomic = true;
+ ensure("setOwnerAndGroup():failed ", perm.setOwnerAndGroup(agent,owner,group,is_atomic));
+
+ LLUUID owner2("68edcf47-ccd7-45b8-9f90-1649d7f12807");
+ LLUUID group2("9c8eca51-53d5-42a7-bb58-cef070395db9");
+
+ // cant change - agent need to be current owner
+ ensure("setOwnerAndGroup():failed ", ! perm.setOwnerAndGroup(agent,owner2,group2,is_atomic));
+
+ // should be able to change - agent and owner same as current owner
+ ensure("setOwnerAndGroup():failed ", perm.setOwnerAndGroup(owner,owner,group2,is_atomic));
+ }
+
+ template<> template<>
+ void permission_object_t::test<10>()
+ {
+ LLPermissions perm;
+ LLUUID agent;
+ LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
+ ensure("deedToGroup():failed ", perm.deedToGroup(agent,group));
+ }
+ template<> template<>
+ void permission_object_t::test<11>()
+ {
+ LLPermissions perm;
+ LLUUID agent;
+ bool set = true;
+ U32 bits = PERM_TRANSFER | PERM_MODIFY;
+ ensure("setBaseBits():failed ", perm.setBaseBits(agent, set, bits));
+ ensure("setOwnerBits():failed ", perm.setOwnerBits(agent, set, bits));
+
+ LLUUID agent1("9c8eca51-53d5-42a7-bb58-cef070395db8");
+ ensure("setBaseBits():failed ", ! perm.setBaseBits(agent1, set, bits));
+ ensure("setOwnerBits():failed ", ! perm.setOwnerBits(agent1, set, bits));
+ }
+
+ template<> template<>
+ void permission_object_t::test<12>()
+ {
+ LLPermissions perm;
+ LLUUID agent;
+ LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
+ bool set = true;
+ U32 bits = 10;
+ ensure("setGroupBits():failed ", perm.setGroupBits(agent,group, set, bits));
+ ensure("setEveryoneBits():failed ", perm.setEveryoneBits(agent,group, set, bits));
+ ensure("setNextOwnerBits():failed ", perm.setNextOwnerBits(agent,group, set, bits));
+
+ LLUUID agent1("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
+ ensure("setGroupBits():failed ", ! perm.setGroupBits(agent1,group, set, bits));
+ ensure("setEveryoneBits():failed ", ! perm.setEveryoneBits(agent1,group, set, bits));
+ ensure("setNextOwnerBits():failed ", ! perm.setNextOwnerBits(agent1,group, set, bits));
+ }
+
+ template<> template<>
+ void permission_object_t::test<13>()
+ {
+ LLPermissions perm;
+ LLUUID agent;
+ LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
+ U32 bits = 10;
+ ensure("allowOperationBy():failed ", perm.allowOperationBy(bits,agent,group));
+
+ LLUUID agent1("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
+ LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
+ LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806");
+ LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
+ perm.init(creator,owner,lastOwner,group);
+ ensure("allowOperationBy():failed ", perm.allowOperationBy(bits,agent1,group));
+ }
+
+ template<> template<>
+ void permission_object_t::test<14>()
+ {
+ LLPermissions perm;
+ LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
+ LLUUID owner;
+ LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
+ LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
+ perm.init(creator,owner,lastOwner,group);
+ LLUUID agent;
+ ensure("1:allowModifyBy():failed ", perm.allowModifyBy(agent));
+ ensure("2:allowModifyBy():failed ", perm.allowModifyBy(agent,group));
+
+ LLUUID agent1("9c8eca51-53d5-42a7-bb58-cef070395db8");
+ ensure("3:allowModifyBy():failed ", perm.allowModifyBy(agent1));
+ ensure("4:allowModifyBy():failed ", perm.allowModifyBy(agent1,group));
+ }
+
+ template<> template<>
+ void permission_object_t::test<15>()
+ {
+ LLPermissions perm;
+ LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
+ LLUUID owner;
+ LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
+ LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
+ perm.init(creator,owner,lastOwner,group);
+ LLUUID agent;
+ ensure("1:allowCopyBy():failed ", perm.allowModifyBy(agent));
+ ensure("2:allowCopyBy():failed ", perm.allowModifyBy(agent,group));
+
+ LLUUID agent1("9c8eca51-53d5-42a7-bb58-cef070395db8");
+ ensure("3:allowCopyBy():failed ", perm.allowCopyBy(agent1));
+ ensure("4:allowCopyBy():failed ", perm.allowCopyBy(agent1,group));
+ }
+
+ template<> template<>
+ void permission_object_t::test<16>()
+ {
+ LLPermissions perm;
+ LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
+ LLUUID owner;
+ LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
+ LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
+ perm.init(creator,owner,lastOwner,group);
+ LLUUID agent;
+ ensure("1:allowMoveBy():failed ", perm.allowMoveBy(agent));
+ ensure("2:allowMoveBy():failed ", perm.allowMoveBy(agent,group));
+
+ LLUUID agent1("9c8eca51-53d5-42a7-bb58-cef070395db8");
+ ensure("3:allowMoveBy():failed ", perm.allowMoveBy(agent1));
+ ensure("4:allowMoveBy():failed ", perm.allowMoveBy(agent1,group));
+ }
+
+ template<> template<>
+ void permission_object_t::test<17>()
+ {
+ LLPermissions perm;
+ LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
+ LLUUID owner;
+ LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
+ LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
+ LLUUID agent;
+ ensure("1:allowMoveBy():failed ", perm.allowTransferTo(agent));
+
+ perm.init(creator,owner,lastOwner,group);
+ ensure("2:allowMoveBy():failed ", perm.allowTransferTo(agent));
+ }
+
+ template<> template<>
+ void permission_object_t::test<18>()
+ {
+ LLPermissions perm,perm1;
+ ensure_equals("1:Operator==:failed ", perm, perm1);
+
+ LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
+ LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806");
+ LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
+ LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
+ perm.init(creator,owner,lastOwner,group);
+ perm = perm1;
+ ensure_equals("2:Operator==:failed ", perm, perm1);
+ }
+
+ template<> template<>
+ void permission_object_t::test<19>()
+ {
+ LLPermissions perm,perm1;
+ LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
+ LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806");
+ LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
+ LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
+ perm.init(creator,owner,lastOwner,group);
+ ensure_not_equals("2:Operator==:failed ", perm, perm1);
+ }
+
+ template<> template<>
+ void permission_object_t::test<20>()
+ {
+ LLPermissions perm,perm1;
+ LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
+ LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806");
+ LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
+ LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
+ perm.init(creator,owner,lastOwner,group);
+
+ U32 base = PERM_TRANSFER | PERM_COPY;
+ U32 ownerp = PERM_TRANSFER;
+ U32 groupp = PERM_TRANSFER;
+ U32 everyone = PERM_TRANSFER;
+ U32 next = PERM_NONE;
+
+ perm.initMasks(base, ownerp, everyone, groupp, next);
+
+ std::ostringstream ostream;
+ perm.exportLegacyStream(ostream);
+ std::istringstream istream(ostream.str());
+ perm1.importLegacyStream(istream);
+
+ ensure_equals("exportStream()/importStream():failed to export and import the data ", perm1, perm);
+ }
+
+ template<> template<>
+ void permission_object_t::test<21>()
+ {
+ LLPermissions perm,perm1;
+ LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
+ LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806");
+ LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
+ LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
+ perm.init(creator,owner,lastOwner,group);
+ std::ostringstream stream1, stream2;
+ stream1 << perm;
+ perm1.init(creator,owner,lastOwner,group);
+ stream2 << perm1;
+ ensure_equals("1:operator << failed", stream1.str(), stream2.str());
+ }
+
+ template<> template<>
+ void permission_object_t::test<22>()
+ {
+ LLPermissions perm,perm1;
+ LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
+ LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806");
+ LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
+ LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
+ perm.init(creator,owner,lastOwner,group);
+
+ U32 base = PERM_TRANSFER | PERM_COPY;
+ U32 ownerp = PERM_TRANSFER;
+ U32 groupp = PERM_TRANSFER;
+ U32 everyone = PERM_TRANSFER;
+ U32 next = PERM_NONE;
+
+ perm.initMasks(base, ownerp, everyone, groupp, next);
+
+ LLSD sd = ll_create_sd_from_permissions(perm);
+ perm1 = ll_permissions_from_sd(sd);
+ ensure_equals("ll_permissions_from_sd() and ll_create_sd_from_permissions()functions failed", perm, perm1);
+ }
+
+ template<> template<>
+ void permission_object_t::test<23>()
+ {
+ LLAggregatePermissions AggrPermission;
+ LLAggregatePermissions AggrPermission1;
+ ensure_equals("getU8() function failed", AggrPermission.getU8(), 0);
+ ensure("isEmpty() function failed", AggrPermission.isEmpty());
+ AggrPermission.getValue(PERM_TRANSFER);
+ ensure_equals("getValue() function failed", AggrPermission.getValue(PERM_TRANSFER), 0x00);
+
+ AggrPermission.aggregate(PERM_ITEM_UNRESTRICTED);
+ ensure("aggregate() function failed", ! AggrPermission.isEmpty());
+
+ AggrPermission1.aggregate(AggrPermission);
+ ensure("aggregate() function failed", ! AggrPermission1.isEmpty());
+
+ std::ostringstream stream1;
+ stream1 << AggrPermission;
+ ensure_equals("operator<< failed", stream1.str(), "{PI_COPY=All, PI_MODIFY=All, PI_TRANSFER=All}");
+ }
+}
diff --git a/indra/llinventory/tests/llsaleinfo_test.cpp b/indra/llinventory/tests/llsaleinfo_test.cpp
new file mode 100644
index 0000000000..1da7101aa3
--- /dev/null
+++ b/indra/llinventory/tests/llsaleinfo_test.cpp
@@ -0,0 +1,194 @@
+/**
+ * @file LLSaleInfo_tut.cpp
+ * @author Adroit
+ * @date 2007-03
+ * @brief Test cases of llsaleinfo.h
+ *
+ * $LicenseInfo:firstyear=2007&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 <tut/tut.hpp>
+#include "linden_common.h"
+#include "lltut.h"
+#include "llsaleinfo.h"
+
+namespace tut
+{
+ struct llsaleinfo_tut
+ {
+ };
+ typedef test_group<llsaleinfo_tut> llsaleinfo_tut_t;
+ typedef llsaleinfo_tut_t::object llsaleinfo_test_t;
+ tut::llsaleinfo_tut_t tut_llsaleinfo_test("llsaleinfo");
+
+ template<> template<>
+ void llsaleinfo_test_t::test<1>()
+ {
+ //test case for getSaleType(), getSalePrice(), getCRC32() fn.
+ //test case for setSaleType(), setSalePrice() fn.
+
+ S32 sale_price = 10000;
+ LLSaleInfo llsaleinfo(LLSaleInfo::FS_COPY, sale_price);
+ const char* sale= "copy";
+
+ LLSD llsd_obj1 = ll_create_sd_from_sale_info(llsaleinfo);
+ LLSaleInfo saleinfo1 = ll_sale_info_from_sd(llsd_obj1);
+
+ ensure("1. The getSaleType() fn failed", LLSaleInfo::FS_COPY == llsaleinfo.getSaleType());
+ ensure("2. LLSaleInfo::isForSale() fn failed", true == llsaleinfo.isForSale());
+ ensure("3. The getSalePrice() fn failed", sale_price == llsaleinfo.getSalePrice());
+ ensure("4. The getCRC32() fn failed", 235833404 == llsaleinfo.getCRC32());
+ ensure("5. LLSaleInfo::lookup(const char* name) fn failed", LLSaleInfo::FS_COPY == llsaleinfo.lookup(sale));
+ ensure_equals("6. ll_create_sd_from_sale_info() fn failed", llsaleinfo.getSalePrice(), saleinfo1.getSalePrice());
+ ensure_equals("7. ll_create_sd_from_sale_info() fn failed", llsaleinfo.getSaleType(), saleinfo1.getSaleType());
+
+ llsaleinfo.setSalePrice(10000000);
+ llsaleinfo.setSaleType(LLSaleInfo::FS_ORIGINAL);
+ sale = "cntn";
+ llsd_obj1 = ll_create_sd_from_sale_info(llsaleinfo);
+ saleinfo1 = ll_sale_info_from_sd(llsd_obj1);
+
+ ensure("8. The getSaleType() and setSaleType() fn failed", LLSaleInfo::FS_ORIGINAL == llsaleinfo.getSaleType());
+ ensure("9. LLSaleInfo::isForSale() fn failed", true == llsaleinfo.isForSale());
+ ensure("10. The getSalePrice() fn failed", 10000000 == llsaleinfo.getSalePrice());
+ ensure("11. The getCRC32() fn failed", 127911702 == llsaleinfo.getCRC32());
+ ensure("12. LLSaleInfo::lookup(const char* name) fn failed", LLSaleInfo::FS_CONTENTS == llsaleinfo.lookup(sale));
+ ensure_equals("13. ll_create_sd_from_sale_info() fn failed", llsaleinfo.getSalePrice(), saleinfo1.getSalePrice());
+ ensure_equals("14. ll_create_sd_from_sale_info() fn failed", llsaleinfo.getSaleType(), saleinfo1.getSaleType());
+
+ llsaleinfo.setSalePrice(55000550);
+ llsaleinfo.setSaleType(LLSaleInfo::FS_CONTENTS);
+ sale = "orig";
+ llsd_obj1 = ll_create_sd_from_sale_info(llsaleinfo);
+ saleinfo1 = ll_sale_info_from_sd(llsd_obj1);
+
+ ensure("15. The getSaleType() and setSaleType() fn failed", LLSaleInfo::FS_CONTENTS == llsaleinfo.getSaleType());
+ ensure("16. LLSaleInfo::isForSale() fn failed", true == llsaleinfo.isForSale());
+ ensure("17. The getSalePrice() fn failed", 55000550 == llsaleinfo.getSalePrice());
+ ensure("18. The getCRC32() fn failed", 408735656 == llsaleinfo.getCRC32());
+ ensure("19. LLSaleInfo::lookup(const char* name) fn failed", LLSaleInfo::FS_ORIGINAL == llsaleinfo.lookup(sale));
+ ensure_equals("20. ll_create_sd_from_sale_info() fn failed", llsaleinfo.getSalePrice(), saleinfo1.getSalePrice());
+ ensure_equals("21. ll_create_sd_from_sale_info() fn failed", llsaleinfo.getSaleType(), saleinfo1.getSaleType());
+
+ llsaleinfo.setSalePrice(-6432);
+ llsaleinfo.setSaleType(LLSaleInfo::FS_NOT);
+ sale = "not";
+ llsd_obj1 = ll_create_sd_from_sale_info(llsaleinfo);
+ saleinfo1 = ll_sale_info_from_sd(llsd_obj1);
+
+ ensure("22. The getSaleType() and setSaleType() fn failed", LLSaleInfo::FS_NOT == llsaleinfo.getSaleType());
+ ensure("23. LLSaleInfo::isForSale() fn failed", false == llsaleinfo.isForSale());
+ ensure("24. The getSalePrice() fn failed", 0 == llsaleinfo.getSalePrice());
+ ensure("25. The getCRC32() fn failed", 0 == llsaleinfo.getCRC32());
+ ensure("26. LLSaleInfo::lookup(const char* name) fn failed", LLSaleInfo::FS_NOT == llsaleinfo.lookup(sale));
+ ensure_equals("27. ll_create_sd_from_sale_info() fn failed", llsaleinfo.getSalePrice(), saleinfo1.getSalePrice());
+ ensure_equals("28. ll_create_sd_from_sale_info() fn failed", llsaleinfo.getSaleType(), saleinfo1.getSaleType());
+ }
+
+ template<> template<>
+ void llsaleinfo_test_t::test<2>()
+ {
+ S32 sale_price = 525452;
+ LLSaleInfo llsaleinfo(LLSaleInfo::FS_ORIGINAL, sale_price);
+
+ std::ostringstream ostream;
+ llsaleinfo.exportLegacyStream(ostream);
+
+ std::istringstream istream(ostream.str());
+ LLSaleInfo llsaleinfo1;
+ U32 perm_mask = 0;
+ bool has_perm_mask = false;
+ llsaleinfo1.importLegacyStream(istream, has_perm_mask, perm_mask);
+
+ ensure("importStream() fn failed ",
+ llsaleinfo.getSalePrice() == llsaleinfo1.getSalePrice() &&
+ llsaleinfo.getSaleType() == llsaleinfo1.getSaleType());
+ }
+
+ template<> template<>
+ void llsaleinfo_test_t::test<3>()
+ {
+ S32 sale_price = 99000;
+ LLSaleInfo saleinfo(LLSaleInfo::FS_ORIGINAL, sale_price);
+
+ LLSD sd_result = saleinfo.asLLSD();
+
+ U32 perm_mask = 0 ;
+ bool has_perm_mask = false;
+
+ LLSaleInfo saleinfo1;
+ saleinfo1.fromLLSD( sd_result, has_perm_mask, perm_mask);
+
+ ensure_equals("asLLSD and fromLLSD failed", saleinfo.getSalePrice(), saleinfo1.getSalePrice());
+ ensure_equals("asLLSD and fromLLSD failed", saleinfo.getSaleType(), saleinfo1.getSaleType());
+ }
+
+ //static EForSale lookup(const char* name) fn test
+ template<> template<>
+ void llsaleinfo_test_t::test<4>()
+ {
+ S32 sale_price = 233223;
+ LLSaleInfo::EForSale ret_type = LLSaleInfo::lookup("orig");
+
+ ensure_equals("lookup(const char* name) fn failed", ret_type, LLSaleInfo::FS_ORIGINAL);
+
+ LLSaleInfo saleinfo(LLSaleInfo::FS_COPY, sale_price);
+ const char* result = LLSaleInfo::lookup(LLSaleInfo::FS_COPY);
+ ensure("char* lookup(EForSale type) fn failed", 0 == strcmp("copy", result));
+ }
+
+ //void LLSaleInfo::accumulate(const LLSaleInfo& sale_info) fn test
+ template<> template<>
+ void llsaleinfo_test_t::test<5>()
+ {
+ S32 sale_price = 20;
+ LLSaleInfo saleinfo(LLSaleInfo::FS_COPY, sale_price);
+ LLSaleInfo saleinfo1(LLSaleInfo::FS_COPY, sale_price);
+ saleinfo1.accumulate(saleinfo);
+ ensure_equals("LLSaleInfo::accumulate(const LLSaleInfo& sale_info) fn failed", saleinfo1.getSalePrice(), 40);
+
+ }
+
+ // test cases of bool operator==(const LLSaleInfo &rhs) fn
+ // test case of bool operator!=(const LLSaleInfo &rhs) fn
+ template<> template<>
+ void llsaleinfo_test_t::test<6>()
+ {
+ S32 sale_price = 55000;
+ LLSaleInfo saleinfo(LLSaleInfo::FS_ORIGINAL, sale_price);
+ LLSaleInfo saleinfoequal(LLSaleInfo::FS_ORIGINAL, sale_price);
+ LLSaleInfo saleinfonotequal(LLSaleInfo::FS_ORIGINAL, sale_price*2);
+
+ ensure("operator == fn. failed", true == (saleinfo == saleinfoequal));
+ ensure("operator != fn. failed", true == (saleinfo != saleinfonotequal));
+ }
+
+ template<> template<>
+ void llsaleinfo_test_t::test<7>()
+ {
+
+ //TBD: void LLSaleInfo::packMessage(LLMessageSystem* msg) const
+ //TBD: void LLSaleInfo::unpackMessage(LLMessageSystem* msg, const char* block)
+ //TBD: void LLSaleInfo::unpackMultiMessage(LLMessageSystem* msg, const char* block, S32 block_num)
+ }
+
+}
diff --git a/indra/llinventory/tests/lluserrelations_test.cpp b/indra/llinventory/tests/lluserrelations_test.cpp
new file mode 100644
index 0000000000..80a659da65
--- /dev/null
+++ b/indra/llinventory/tests/lluserrelations_test.cpp
@@ -0,0 +1,156 @@
+/**
+ * @file lluserrelations_tut.cpp
+ * @author Phoenix
+ * @date 2006-10-12
+ * @brief Unit tests for the LLRelationship class.
+ *
+ * $LicenseInfo:firstyear=2006&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 <tut/tut.hpp>
+
+#include "linden_common.h"
+#include "lluserrelations.h"
+
+namespace tut
+{
+ struct user_relationship
+ {
+ LLRelationship mRelationship;
+ };
+ typedef test_group<user_relationship> user_relationship_t;
+ typedef user_relationship_t::object user_relationship_object_t;
+ tut::user_relationship_t tut_user_relationship("relationships");
+
+ template<> template<>
+ void user_relationship_object_t::test<1>()
+ {
+ // Test the default construction
+ ensure(
+ "No granted rights to",
+ !mRelationship.isRightGrantedTo(
+ LLRelationship::GRANT_ONLINE_STATUS));
+ ensure(
+ "No granted rights from",
+ !mRelationship.isRightGrantedFrom(
+ LLRelationship::GRANT_ONLINE_STATUS));
+ ensure("No online status",!mRelationship.isOnline());
+ }
+
+ template<> template<>
+ void user_relationship_object_t::test<2>()
+ {
+ // Test some granting
+ mRelationship.grantRights(
+ LLRelationship::GRANT_ONLINE_STATUS,
+ LLRelationship::GRANT_MODIFY_OBJECTS);
+ ensure(
+ "Granted rights to has online",
+ mRelationship.isRightGrantedTo(
+ LLRelationship::GRANT_ONLINE_STATUS));
+ ensure(
+ "Granted rights from does not have online",
+ !mRelationship.isRightGrantedFrom(
+ LLRelationship::GRANT_ONLINE_STATUS));
+ ensure(
+ "Granted rights to does not have modify",
+ !mRelationship.isRightGrantedTo(
+ LLRelationship::GRANT_MODIFY_OBJECTS));
+ ensure(
+ "Granted rights from has modify",
+ mRelationship.isRightGrantedFrom(
+ LLRelationship::GRANT_MODIFY_OBJECTS));
+ }
+
+ template<> template<>
+ void user_relationship_object_t::test<3>()
+ {
+ // Test revoking
+ mRelationship.grantRights(
+ LLRelationship::GRANT_ONLINE_STATUS
+ | LLRelationship::GRANT_MAP_LOCATION,
+ LLRelationship::GRANT_ONLINE_STATUS);
+ ensure(
+ "Granted rights to has online and map",
+ mRelationship.isRightGrantedTo(
+ LLRelationship::GRANT_ONLINE_STATUS
+ | LLRelationship::GRANT_MAP_LOCATION));
+ ensure(
+ "Granted rights from has online",
+ mRelationship.isRightGrantedFrom(
+ LLRelationship::GRANT_ONLINE_STATUS));
+
+ mRelationship.revokeRights(
+ LLRelationship::GRANT_MAP_LOCATION,
+ LLRelationship::GRANT_NONE);
+ ensure(
+ "Granted rights revoked map",
+ !mRelationship.isRightGrantedTo(
+ LLRelationship::GRANT_ONLINE_STATUS
+ | LLRelationship::GRANT_MAP_LOCATION));
+ ensure(
+ "Granted rights revoked still has online",
+ mRelationship.isRightGrantedTo(
+ LLRelationship::GRANT_ONLINE_STATUS));
+
+ mRelationship.grantRights(
+ LLRelationship::GRANT_NONE,
+ LLRelationship::GRANT_MODIFY_OBJECTS);
+ ensure(
+ "Granted rights from still has online",
+ mRelationship.isRightGrantedFrom(
+ LLRelationship::GRANT_ONLINE_STATUS));
+ ensure(
+ "Granted rights from has full grant",
+ mRelationship.isRightGrantedFrom(
+ LLRelationship::GRANT_ONLINE_STATUS
+ | LLRelationship::GRANT_MODIFY_OBJECTS));
+ mRelationship.revokeRights(
+ LLRelationship::GRANT_NONE,
+ LLRelationship::GRANT_MODIFY_OBJECTS);
+ ensure(
+ "Granted rights from still has online",
+ mRelationship.isRightGrantedFrom(
+ LLRelationship::GRANT_ONLINE_STATUS));
+ ensure(
+ "Granted rights from no longer modify",
+ !mRelationship.isRightGrantedFrom(
+ LLRelationship::GRANT_MODIFY_OBJECTS));
+ }
+
+ template<> template<>
+ void user_relationship_object_t::test<4>()
+ {
+ ensure("No online status", !mRelationship.isOnline());
+ mRelationship.online(true);
+ ensure("Online status", mRelationship.isOnline());
+ mRelationship.online(false);
+ ensure("No online status", !mRelationship.isOnline());
+ }
+
+/*
+ template<> template<>
+ void user_relationship_object_t::test<>()
+ {
+ }
+*/
+}