summaryrefslogtreecommitdiff
path: root/indra/llinventory
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llinventory')
-rw-r--r--indra/llinventory/llinventory.cpp70
-rw-r--r--indra/llinventory/llinventory.h4
-rw-r--r--indra/llinventory/llpermissions.cpp33
-rw-r--r--indra/llinventory/llpermissions.h3
-rw-r--r--indra/llinventory/llsaleinfo.cpp21
-rw-r--r--indra/llinventory/llsaleinfo.h3
6 files changed, 120 insertions, 14 deletions
diff --git a/indra/llinventory/llinventory.cpp b/indra/llinventory/llinventory.cpp
index 4d411e6b8d..272e8ffba2 100644
--- a/indra/llinventory/llinventory.cpp
+++ b/indra/llinventory/llinventory.cpp
@@ -54,6 +54,7 @@ static const std::string INV_INVENTORY_TYPE_LABEL("inv_type");
static const std::string INV_NAME_LABEL("name");
static const std::string INV_DESC_LABEL("desc");
static const std::string INV_PERMISSIONS_LABEL("permissions");
+static const std::string INV_SHADOW_ID_LABEL("shadow_id");
static const std::string INV_ASSET_ID_LABEL("asset_id");
static const std::string INV_SALE_INFO_LABEL("sale_info");
static const std::string INV_FLAGS_LABEL("flags");
@@ -927,34 +928,34 @@ BOOL LLInventoryItem::exportLegacyStream(std::ostream& output_stream, BOOL inclu
LLSD LLInventoryItem::asLLSD() const
{
LLSD sd = LLSD();
- sd["item_id"] = mUUID;
- sd["parent_id"] = mParentUUID;
- sd["permissions"] = ll_create_sd_from_permissions(mPermissions);
+ sd[INV_ITEM_ID_LABEL] = mUUID;
+ sd[INV_PARENT_ID_LABEL] = mParentUUID;
+ sd[INV_PERMISSIONS_LABEL] = ll_create_sd_from_permissions(mPermissions);
U32 mask = mPermissions.getMaskBase();
if(((mask & PERM_ITEM_UNRESTRICTED) == PERM_ITEM_UNRESTRICTED)
|| (mAssetUUID.isNull()))
{
- sd["asset_id"] = mAssetUUID;
+ sd[INV_ASSET_ID_LABEL] = mAssetUUID;
}
else
{
LLUUID shadow_id(mAssetUUID);
LLXORCipher cipher(MAGIC_ID.mData, UUID_BYTES);
cipher.encrypt(shadow_id.mData, UUID_BYTES);
- sd["shadow_id"] = shadow_id;
+ sd[INV_SHADOW_ID_LABEL] = shadow_id;
}
- sd["type"] = LLAssetType::lookup(mType);
+ sd[INV_ASSET_TYPE_LABEL] = LLAssetType::lookup(mType);
const char* inv_type_str = LLInventoryType::lookup(mInventoryType);
if(inv_type_str)
{
- sd["inv_type"] = inv_type_str;
+ sd[INV_INVENTORY_TYPE_LABEL] = inv_type_str;
}
- sd["flags"] = ll_sd_from_U32(mFlags);
- sd["sale_info"] = mSaleInfo;
- sd["name"] = mName;
- sd["desc"] = mDescription;
- sd["creation_date"] = mCreationDate;
+ sd[INV_FLAGS_LABEL] = ll_sd_from_U32(mFlags);
+ sd[INV_SALE_INFO_LABEL] = mSaleInfo;
+ sd[INV_NAME_LABEL] = mName;
+ sd[INV_DESC_LABEL] = mDescription;
+ sd[INV_CREATION_DATE_LABEL] = mCreationDate;
return sd;
}
@@ -1007,7 +1008,7 @@ bool LLInventoryItem::fromLLSD(LLSD& sd)
mPermissions.setMaskNext(perm_mask);
}
}
- w = "shadow_id";
+ w = INV_SHADOW_ID_LABEL;
if (sd.has(w))
{
mAssetUUID = sd[w];
@@ -1357,6 +1358,19 @@ void LLInventoryCategory::setPreferredType(LLAssetType::EType type)
mPreferredType = type;
}
+LLSD LLInventoryCategory::asLLSD() const
+{
+ LLSD sd = LLSD();
+ sd["item_id"] = mUUID;
+ sd["parent_id"] = mParentUUID;
+ S8 type = static_cast<S8>(mPreferredType);
+ sd["type"] = type;
+ sd["name"] = mName;
+
+ return sd;
+}
+
+
// virtual
void LLInventoryCategory::packMessage(LLMessageSystem* msg) const
{
@@ -1367,6 +1381,36 @@ void LLInventoryCategory::packMessage(LLMessageSystem* msg) const
msg->addStringFast(_PREHASH_Name, mName);
}
+bool LLInventoryCategory::fromLLSD(LLSD& sd)
+{
+ std::string w;
+
+ w = INV_ITEM_ID_LABEL;
+ if (sd.has(w))
+ {
+ mUUID = sd[w];
+ }
+ w = INV_PARENT_ID_LABEL;
+ if (sd.has(w))
+ {
+ mParentUUID = sd[w];
+ }
+ w = INV_ASSET_TYPE_LABEL;
+ if (sd.has(w))
+ {
+ S8 type = (U8)sd[w].asInteger();
+ mPreferredType = static_cast<LLAssetType::EType>(type);
+ }
+ w = INV_NAME_LABEL;
+ if (sd.has(w))
+ {
+ mName = sd[w].asString();
+ LLString::replaceNonstandardASCII(mName, ' ');
+ LLString::replaceChar(mName, '|', ' ');
+ }
+ return true;
+}
+
// virtual
void LLInventoryCategory::unpackMessage(LLMessageSystem* msg,
const char* block,
diff --git a/indra/llinventory/llinventory.h b/indra/llinventory/llinventory.h
index 5ff7a1e72b..db4843d8b5 100644
--- a/indra/llinventory/llinventory.h
+++ b/indra/llinventory/llinventory.h
@@ -230,7 +230,6 @@ public:
// network ok. It uses a simple crc check which is defeatable, but
// we want to detect network mangling somehow.
virtual BOOL unpackMessage(LLMessageSystem* msg, const char* block, S32 block_num = 0);
-
// file support
virtual BOOL importFile(FILE* fp);
virtual BOOL exportFile(FILE* fp, BOOL include_asset_key = TRUE) const;
@@ -288,6 +287,9 @@ public:
virtual void packMessage(LLMessageSystem* msg) const;
virtual void unpackMessage(LLMessageSystem* msg, const char* block, S32 block_num = 0);
+ LLSD asLLSD() const;
+ bool fromLLSD(LLSD& sd);
+
// file support
virtual BOOL importFile(FILE* fp);
virtual BOOL exportFile(FILE* fp, BOOL include_asset_key = TRUE) const;
diff --git a/indra/llinventory/llpermissions.cpp b/indra/llinventory/llpermissions.cpp
index 8f9f73d0bd..f816d54181 100644
--- a/indra/llinventory/llpermissions.cpp
+++ b/indra/llinventory/llpermissions.cpp
@@ -37,6 +37,7 @@
// library includes
#include "message.h"
#include "metapropertyt.h"
+#include "llsd.h"
///----------------------------------------------------------------------------
/// Class LLPermissions
@@ -473,6 +474,25 @@ BOOL LLPermissions::allowOperationBy(PermissionBit op, const LLUUID& requester,
}
//
+// LLSD support for HTTP messages.
+//
+LLSD LLPermissions::packMessage() const
+{
+ LLSD result;
+ result["creator-id"] = mCreator;
+ result["owner-id"] = mOwner;
+ result["group-id"] = mGroup;
+
+ result["base-mask"] = (S32)mMaskBase;
+ result["owner-mask"] = (S32)mMaskOwner;
+ result["group-mask"] = (S32)mMaskGroup;
+ result["everyone-mask"] = (S32)mMaskEveryone;
+ result["next-owner-mask"]= (S32)mMaskNextOwner;
+ result["group-owned"] = (BOOL)mIsGroupOwned;
+ return result;
+}
+
+//
// Messaging support
//
void LLPermissions::packMessage(LLMessageSystem* msg) const
@@ -489,6 +509,19 @@ void LLPermissions::packMessage(LLMessageSystem* msg) const
msg->addBOOLFast(_PREHASH_GroupOwned, (BOOL)mIsGroupOwned);
}
+void LLPermissions::unpackMessage(LLSD perms)
+{
+ mCreator = perms["creator-id"];
+ mOwner = perms["owner-id"];
+ mGroup = perms["group-id"];
+
+ mMaskBase = (U32)perms["base-mask"].asInteger();
+ mMaskOwner = (U32)perms["owner-mask"].asInteger();
+ mMaskGroup = (U32)perms["group-mask"].asInteger();
+ mMaskEveryone = (U32)perms["everyone-mask"].asInteger();
+ mMaskNextOwner = (U32)perms["next-owner-mask"].asInteger();
+ mIsGroupOwned = perms["group-owned"].asBoolean();
+}
void LLPermissions::unpackMessage(LLMessageSystem* msg, const char* block, S32 block_num)
{
diff --git a/indra/llinventory/llpermissions.h b/indra/llinventory/llpermissions.h
index 9370d6480b..36acc438be 100644
--- a/indra/llinventory/llpermissions.h
+++ b/indra/llinventory/llpermissions.h
@@ -294,6 +294,9 @@ public:
// MISC METHODS and OPERATORS
//
+ LLSD packMessage() const;
+ void unpackMessage(LLSD perms);
+
// For messaging system support
void packMessage(LLMessageSystem* msg) const;
void unpackMessage(LLMessageSystem* msg, const char* block, S32 block_num = 0);
diff --git a/indra/llinventory/llsaleinfo.cpp b/indra/llinventory/llsaleinfo.cpp
index d0c7c728f3..c268544955 100644
--- a/indra/llinventory/llsaleinfo.cpp
+++ b/indra/llinventory/llsaleinfo.cpp
@@ -280,6 +280,17 @@ void LLSaleInfo::setSalePrice(S32 price)
mSalePrice = llclamp(mSalePrice, 0, S32_MAX);
}
+LLSD LLSaleInfo::packMessage() const
+{
+ LLSD result;
+
+ U8 sale_type = static_cast<U8>(mSaleType);
+ result["sale-type"] = (U8)sale_type;
+ result["sale-price"] = (S32)mSalePrice;
+ //result[_PREHASH_NextOwnerMask] = mNextOwnerPermMask;
+ return result;
+}
+
void LLSaleInfo::packMessage(LLMessageSystem* msg) const
{
U8 sale_type = static_cast<U8>(mSaleType);
@@ -288,6 +299,16 @@ void LLSaleInfo::packMessage(LLMessageSystem* msg) const
//msg->addU32Fast(_PREHASH_NextOwnerMask, mNextOwnerPermMask);
}
+void LLSaleInfo::unpackMessage(LLSD sales)
+{
+ U8 sale_type = (U8)sales["sale-type"].asInteger();
+ mSaleType = static_cast<EForSale>(sale_type);
+
+ mSalePrice = (S32)sales["sale-price"].asInteger();
+ mSalePrice = llclamp(mSalePrice, 0, S32_MAX);
+ //msg->getU32Fast(block, _PREHASH_NextOwnerMask, mNextOwnerPermMask);
+}
+
void LLSaleInfo::unpackMessage(LLMessageSystem* msg, const char* block)
{
U8 sale_type;
diff --git a/indra/llinventory/llsaleinfo.h b/indra/llinventory/llsaleinfo.h
index e22466bfa8..1c9db6e346 100644
--- a/indra/llinventory/llsaleinfo.h
+++ b/indra/llinventory/llsaleinfo.h
@@ -103,6 +103,9 @@ public:
LLXMLNode *exportFileXML() const;
BOOL importXML(LLXMLNode* node);
+ LLSD packMessage() const;
+ void unpackMessage(LLSD sales);
+
// message serialization
void packMessage(LLMessageSystem* msg) const;
void unpackMessage(LLMessageSystem* msg, const char* block);