summaryrefslogtreecommitdiff
path: root/indra/llinventory
diff options
context:
space:
mode:
authorMnikolenko Productengine <mnikolenko@productengine.com>2020-08-10 20:50:27 +0300
committerMnikolenko Productengine <mnikolenko@productengine.com>2020-08-10 20:50:27 +0300
commit43941a3d876b854560b06906665d689c3924aed1 (patch)
tree4934b6cb0e778c5ef0dedebb3c9b93878d2508fb /indra/llinventory
parent8213cc896c74ca08ee231aa557eac302445c933e (diff)
SL-13669 tests should cover import/export category from llsd
Diffstat (limited to 'indra/llinventory')
-rw-r--r--indra/llinventory/llinventory.cpp41
-rw-r--r--indra/llinventory/llinventory.h2
-rw-r--r--indra/llinventory/tests/inventorymisc_test.cpp5
3 files changed, 45 insertions, 3 deletions
diff --git a/indra/llinventory/llinventory.cpp b/indra/llinventory/llinventory.cpp
index fcc2e1d173..18bc1b5a91 100644
--- a/indra/llinventory/llinventory.cpp
+++ b/indra/llinventory/llinventory.cpp
@@ -41,7 +41,7 @@
/// Exported functions
///----------------------------------------------------------------------------
static const std::string INV_ITEM_ID_LABEL("item_id");
-static const std::string INV_FOLDER_ID_LABEL("folder_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_ASSET_TYPE_LABEL("type");
static const std::string INV_PREFERRED_TYPE_LABEL("preferred_type");
@@ -1317,6 +1317,45 @@ BOOL LLInventoryCategory::exportLegacyStream(std::ostream& output_stream, BOOL)
return TRUE;
}
+LLSD LLInventoryCategory::exportLLSD() const
+{
+ LLSD cat_data;
+ cat_data[INV_FOLDER_ID_LABEL] = mUUID;
+ cat_data[INV_PARENT_ID_LABEL] = mParentUUID;
+ cat_data[INV_ASSET_TYPE_LABEL] = LLAssetType::lookup(mType);
+ cat_data[INV_PREFERRED_TYPE_LABEL] = LLFolderType::lookup(mPreferredType);
+ cat_data[INV_NAME_LABEL] = mName;
+
+ return cat_data;
+}
+
+bool LLInventoryCategory::importLLSD(const LLSD& cat_data)
+{
+ if (cat_data.has(INV_FOLDER_ID_LABEL))
+ {
+ setUUID(cat_data[INV_FOLDER_ID_LABEL].asUUID());
+ }
+ if (cat_data.has(INV_PARENT_ID_LABEL))
+ {
+ setParent(cat_data[INV_PARENT_ID_LABEL].asUUID());
+ }
+ if (cat_data.has(INV_ASSET_TYPE_LABEL))
+ {
+ setType(LLAssetType::lookup(cat_data[INV_ASSET_TYPE_LABEL].asString()));
+ }
+ if (cat_data.has(INV_PREFERRED_TYPE_LABEL))
+ {
+ setPreferredType(LLFolderType::lookup(cat_data[INV_PREFERRED_TYPE_LABEL].asString()));
+ }
+ if (cat_data.has(INV_NAME_LABEL))
+ {
+ mName = cat_data[INV_NAME_LABEL].asString();
+ LLStringUtil::replaceNonstandardASCII(mName, ' ');
+ LLStringUtil::replaceChar(mName, '|', ' ');
+ }
+
+ return true;
+}
///----------------------------------------------------------------------------
/// Local function definitions
///----------------------------------------------------------------------------
diff --git a/indra/llinventory/llinventory.h b/indra/llinventory/llinventory.h
index d00c4d43ee..024afc109c 100644
--- a/indra/llinventory/llinventory.h
+++ b/indra/llinventory/llinventory.h
@@ -269,6 +269,8 @@ public:
virtual BOOL importLegacyStream(std::istream& input_stream);
virtual BOOL exportLegacyStream(std::ostream& output_stream, BOOL include_asset_key = TRUE) const;
+ LLSD exportLLSD() const;
+ bool importLLSD(const LLSD& cat_data);
//--------------------------------------------------------------------
// Member Variables
//--------------------------------------------------------------------
diff --git a/indra/llinventory/tests/inventorymisc_test.cpp b/indra/llinventory/tests/inventorymisc_test.cpp
index 6eb3f04827..e8b063bffe 100644
--- a/indra/llinventory/tests/inventorymisc_test.cpp
+++ b/indra/llinventory/tests/inventorymisc_test.cpp
@@ -478,7 +478,7 @@ namespace tut
}
LLPointer<LLInventoryCategory> src1 = create_random_inventory_cat();
- fileXML << LLSDOStreamer<LLSDNotationFormatter>(ll_create_sd_from_inventory_category(src1)) << std::endl;
+ fileXML << LLSDOStreamer<LLSDNotationFormatter>(src1->exportLLSD()) << std::endl;
fileXML.close();
llifstream file(filename.c_str());
@@ -500,7 +500,8 @@ namespace tut
file.close();
- LLPointer<LLInventoryCategory> src2 = ll_create_category_from_sd(s_item);
+ LLPointer<LLInventoryCategory> src2 = new LLInventoryCategory();
+ src2->importLLSD(s_item);
ensure_equals("1.item id::getUUID() failed", src1->getUUID(), src2->getUUID());
ensure_equals("2.parent::getParentUUID() failed", src1->getParentUUID(), src2->getParentUUID());