summaryrefslogtreecommitdiff
path: root/indra/llinventory/llinventory.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llinventory/llinventory.cpp')
-rw-r--r--indra/llinventory/llinventory.cpp300
1 files changed, 159 insertions, 141 deletions
diff --git a/indra/llinventory/llinventory.cpp b/indra/llinventory/llinventory.cpp
index 5adf1fa0e6..55bcc7c5b2 100644
--- a/indra/llinventory/llinventory.cpp
+++ b/indra/llinventory/llinventory.cpp
@@ -904,152 +904,173 @@ bool LLInventoryItem::fromLLSD(const LLSD& sd, bool is_new)
mInventoryType = LLInventoryType::IT_NONE;
mAssetUUID.setNull();
}
- 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];
- }
+ // TODO - figure out if this should be moved into the noclobber fields above
mThumbnailUUID.setNull();
- w = INV_THUMBNAIL_LABEL;
- if (sd.has(w))
+
+ // iterate as map to avoid making unnecessary temp copies of everything
+ LLSD::map_const_iterator i, end;
+ end = sd.endMap();
+ for (i = sd.beginMap(); i != end; ++i)
{
- const LLSD &thumbnail_map = sd[w];
- w = INV_ASSET_ID_LABEL;
- if (thumbnail_map.has(w))
+ if (i->first == INV_ITEM_ID_LABEL)
{
- mThumbnailUUID = thumbnail_map[w];
+ mUUID = i->second;
+ continue;
}
- /* 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>
- */
- }
- else
- {
- w = INV_THUMBNAIL_ID_LABEL;
- if (sd.has(w))
+
+ if (i->first == INV_PARENT_ID_LABEL)
+ {
+ mParentUUID = i->second;
+ continue;
+ }
+
+ if (i->first == INV_THUMBNAIL_LABEL)
+ {
+ const LLSD &thumbnail_map = i->second;
+ const std::string w = INV_ASSET_ID_LABEL;
+ if (thumbnail_map.has(w))
+ {
+ mThumbnailUUID = thumbnail_map[w];
+ }
+ /* 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_PERMISSIONS_LABEL)
+ {
+ mPermissions = ll_permissions_from_sd(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)
+ {
+ perm_mask = mPermissions.getMaskOwner();
+ }
+ // fair use fix.
+ if (!(perm_mask & PERM_COPY))
+ {
+ perm_mask |= PERM_TRANSFER;
+ }
+ 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 (i->first == INV_ASSET_ID_LABEL)
+ {
+ mAssetUUID = i->second;
+ continue;
+ }
+
+ if (i->first == INV_LINKED_ID_LABEL)
+ {
+ mAssetUUID = i->second;
+ continue;
+ }
+
+ if (i->first == INV_ASSET_TYPE_LABEL)
{
- mThumbnailUUID = sd[w].asUUID();
+ LLSD const &label = i->second;
+ if (label.isString())
+ {
+ mType = LLAssetType::lookup(label.asString().c_str());
+ }
+ else if (label.isInteger())
+ {
+ S8 type = (U8) label.asInteger();
+ mType = static_cast<LLAssetType::EType>(type);
+ }
+ continue;
+ }
+
+ if (i->first == INV_INVENTORY_TYPE_LABEL)
+ {
+ LLSD const &label = i->second;
+ if (label.isString())
+ {
+ mInventoryType = LLInventoryType::lookup(label.asString().c_str());
+ }
+ else if (label.isInteger())
+ {
+ S8 type = (U8) label.asInteger();
+ mInventoryType = static_cast<LLInventoryType::EType>(type);
+ }
+ continue;
+ }
+
+ 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;
+ }
+
+ if (i->first == INV_NAME_LABEL)
+ {
+ mName = i->second.asString();
+ LLStringUtil::replaceNonstandardASCII(mName, ' ');
+ LLStringUtil::replaceChar(mName, '|', ' ');
+ continue;
+ }
+
+ if (i->first == INV_DESC_LABEL)
+ {
+ mDescription = i->second.asString();
+ LLStringUtil::replaceNonstandardASCII(mDescription, ' ');
+ continue;
+ }
+
+ if (i->first == INV_CREATION_DATE_LABEL)
+ {
+ mCreationDate = i->second.asInteger();
+ continue;
}
}
- w = INV_PERMISSIONS_LABEL;
- if (sd.has(w))
- {
- mPermissions = ll_permissions_from_sd(sd[w]);
- }
- w = INV_SALE_INFO_LABEL;
- if (sd.has(w))
- {
- // 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(sd[w], has_perm_mask, perm_mask))
- {
- goto fail;
- }
- 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);
- }
- }
- w = INV_SHADOW_ID_LABEL;
- if (sd.has(w))
- {
- mAssetUUID = sd[w];
- LLXORCipher cipher(MAGIC_ID.mData, UUID_BYTES);
- cipher.decrypt(mAssetUUID.mData, UUID_BYTES);
- }
- w = INV_ASSET_ID_LABEL;
- if (sd.has(w))
- {
- mAssetUUID = sd[w];
- }
- w = INV_LINKED_ID_LABEL;
- if (sd.has(w))
- {
- mAssetUUID = sd[w];
- }
- w = INV_ASSET_TYPE_LABEL;
- if (sd.has(w))
- {
- if (sd[w].isString())
- {
- mType = LLAssetType::lookup(sd[w].asString().c_str());
- }
- else if (sd[w].isInteger())
- {
- S8 type = (U8)sd[w].asInteger();
- mType = static_cast<LLAssetType::EType>(type);
- }
- }
- w = INV_INVENTORY_TYPE_LABEL;
- if (sd.has(w))
- {
- if (sd[w].isString())
- {
- mInventoryType = LLInventoryType::lookup(sd[w].asString().c_str());
- }
- else if (sd[w].isInteger())
- {
- S8 type = (U8)sd[w].asInteger();
- mInventoryType = static_cast<LLInventoryType::EType>(type);
- }
- }
- w = INV_FLAGS_LABEL;
- if (sd.has(w))
- {
- if (sd[w].isBinary())
- {
- mFlags = ll_U32_from_sd(sd[w]);
- }
- else if(sd[w].isInteger())
- {
- mFlags = sd[w].asInteger();
- }
- }
- w = INV_NAME_LABEL;
- if (sd.has(w))
- {
- mName = sd[w].asString();
- LLStringUtil::replaceNonstandardASCII(mName, ' ');
- LLStringUtil::replaceChar(mName, '|', ' ');
- }
- w = INV_DESC_LABEL;
- if (sd.has(w))
- {
- mDescription = sd[w].asString();
- LLStringUtil::replaceNonstandardASCII(mDescription, ' ');
- }
- w = INV_CREATION_DATE_LABEL;
- if (sd.has(w))
- {
- mCreationDate = sd[w].asInteger();
- }
// Need to convert 1.0 simstate files to a useful inventory type
// and potentially deal with bad inventory tyes eg, a landmark
@@ -1064,9 +1085,6 @@ bool LLInventoryItem::fromLLSD(const LLSD& sd, bool is_new)
mPermissions.initMasks(mInventoryType);
return true;
-fail:
- return false;
-
}
///----------------------------------------------------------------------------