summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
Diffstat (limited to 'indra')
-rw-r--r--indra/llinventory/llinventory.cpp41
-rw-r--r--indra/llinventory/llinventory.h2
-rw-r--r--indra/llinventory/tests/inventorymisc_test.cpp5
-rw-r--r--indra/newview/llviewerinventory.cpp35
4 files changed, 47 insertions, 36 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());
diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp
index 6c61c34075..bbed741a33 100644
--- a/indra/newview/llviewerinventory.cpp
+++ b/indra/newview/llviewerinventory.cpp
@@ -81,11 +81,6 @@ static const char * const LOG_INV("Inventory");
static const char * const LOG_LOCAL("InventoryLocalize");
static const char * const LOG_NOTECARD("copy_inventory_from_notecard");
-static const std::string INV_CAT_ID("cat_id");
-static const std::string INV_PARENT_ID("parent_id");
-static const std::string INV_ASSET_TYPE("type");
-static const std::string INV_PREFERRED_TYPE("pref_type");
-static const std::string INV_NAME("name");
static const std::string INV_OWNER_ID("owner_id");
static const std::string INV_VERSION("version");
@@ -696,12 +691,7 @@ S32 LLViewerInventoryCategory::getViewerDescendentCount() const
LLSD LLViewerInventoryCategory::exportLLSD() const
{
- LLSD cat_data;
- cat_data[INV_CAT_ID] = mUUID;
- cat_data[INV_PARENT_ID] = mParentUUID;
- cat_data[INV_ASSET_TYPE] = LLAssetType::lookup(mType);
- cat_data[INV_PREFERRED_TYPE] = LLFolderType::lookup(mPreferredType);
- cat_data[INV_NAME] = mName;
+ LLSD cat_data = LLInventoryCategory::exportLLSD();
cat_data[INV_OWNER_ID] = mOwnerID;
cat_data[INV_VERSION] = mVersion;
@@ -710,28 +700,7 @@ LLSD LLViewerInventoryCategory::exportLLSD() const
bool LLViewerInventoryCategory::importLLSD(const LLSD& cat_data)
{
- if (cat_data.has(INV_CAT_ID))
- {
- setUUID(cat_data[INV_CAT_ID].asUUID());
- }
- if (cat_data.has(INV_PARENT_ID))
- {
- setParent(cat_data[INV_PARENT_ID].asUUID());
- }
- if (cat_data.has(INV_ASSET_TYPE))
- {
- setType(LLAssetType::lookup(cat_data[INV_ASSET_TYPE].asString()));
- }
- if (cat_data.has(INV_PREFERRED_TYPE))
- {
- setPreferredType(LLFolderType::lookup(cat_data[INV_PREFERRED_TYPE].asString()));
- }
- if (cat_data.has(INV_NAME))
- {
- mName = cat_data[INV_NAME].asString();
- LLStringUtil::replaceNonstandardASCII(mName, ' ');
- LLStringUtil::replaceChar(mName, '|', ' ');
- }
+ LLInventoryCategory::importLLSD(cat_data);
if (cat_data.has(INV_OWNER_ID))
{
mOwnerID = cat_data[INV_OWNER_ID].asUUID();