summaryrefslogtreecommitdiff
path: root/indra/llinventory
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llinventory')
-rw-r--r--indra/llinventory/llinventory.cpp349
-rw-r--r--indra/llinventory/llinventory.h9
-rw-r--r--indra/llinventory/llinventorysettings.cpp26
-rw-r--r--indra/llinventory/llinventorysettings.h13
-rw-r--r--indra/llinventory/llpermissions.cpp142
-rw-r--r--indra/llinventory/llpermissions.h4
-rw-r--r--indra/llinventory/llsaleinfo.cpp73
-rw-r--r--indra/llinventory/llsaleinfo.h5
-rw-r--r--indra/llinventory/llsettingsbase.h1
-rw-r--r--indra/llinventory/tests/inventorymisc_test.cpp72
10 files changed, 112 insertions, 582 deletions
diff --git a/indra/llinventory/llinventory.cpp b/indra/llinventory/llinventory.cpp
index 11647c5518..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");
@@ -228,22 +228,6 @@ BOOL LLInventoryObject::importLegacyStream(std::istream& input_stream)
return TRUE;
}
-// exportFile should be replaced with exportLegacyStream
-// not sure whether exportLegacyStream(llofstream(fp)) would work, fp may need to get icramented...
-BOOL LLInventoryObject::exportFile(LLFILE* fp, BOOL) const
-{
- std::string uuid_str;
- fprintf(fp, "\tinv_object\t0\n\t{\n");
- mUUID.toString(uuid_str);
- fprintf(fp, "\t\tobj_id\t%s\n", uuid_str.c_str());
- mParentUUID.toString(uuid_str);
- fprintf(fp, "\t\tparent_id\t%s\n", uuid_str.c_str());
- fprintf(fp, "\t\ttype\t%s\n", LLAssetType::lookup(mType));
- fprintf(fp, "\t\tname\t%s|\n", mName.c_str());
- fprintf(fp,"\t}\n");
- return TRUE;
-}
-
BOOL LLInventoryObject::exportLegacyStream(std::ostream& output_stream, BOOL) const
{
std::string uuid_str;
@@ -604,215 +588,6 @@ BOOL LLInventoryItem::unpackMessage(LLMessageSystem* msg, const char* block, S32
}
// virtual
-BOOL LLInventoryItem::importFile(LLFILE* fp)
-{
- // *NOTE: Changing the buffer size will require changing the scanf
- // calls below.
- char buffer[MAX_STRING]; /* Flawfinder: ignore */
- char keyword[MAX_STRING]; /* Flawfinder: ignore */
- char valuestr[MAX_STRING]; /* Flawfinder: ignore */
- char junk[MAX_STRING]; /* Flawfinder: ignore */
- BOOL success = TRUE;
-
- keyword[0] = '\0';
- valuestr[0] = '\0';
-
- mInventoryType = LLInventoryType::IT_NONE;
- mAssetUUID.setNull();
- while(success && (!feof(fp)))
- {
- if (fgets(buffer, MAX_STRING, fp) == NULL)
- {
- buffer[0] = '\0';
- }
-
- sscanf(buffer, " %254s %254s", keyword, valuestr); /* Flawfinder: ignore */
- if(0 == strcmp("{",keyword))
- {
- continue;
- }
- if(0 == strcmp("}", keyword))
- {
- break;
- }
- else if(0 == strcmp("item_id", keyword))
- {
- mUUID.set(valuestr);
- }
- else if(0 == strcmp("parent_id", keyword))
- {
- mParentUUID.set(valuestr);
- }
- else if(0 == strcmp("permissions", keyword))
- {
- success = mPermissions.importFile(fp);
- }
- else if(0 == strcmp("sale_info", keyword))
- {
- // 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;
- success = mSaleInfo.importFile(fp, has_perm_mask, perm_mask);
- 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);
- }
- }
- else if(0 == strcmp("shadow_id", keyword))
- {
- mAssetUUID.set(valuestr);
- LLXORCipher cipher(MAGIC_ID.mData, UUID_BYTES);
- cipher.decrypt(mAssetUUID.mData, UUID_BYTES);
- }
- else if(0 == strcmp("asset_id", keyword))
- {
- mAssetUUID.set(valuestr);
- }
- else if(0 == strcmp("type", keyword))
- {
- mType = LLAssetType::lookup(valuestr);
- }
- else if(0 == strcmp("inv_type", keyword))
- {
- mInventoryType = LLInventoryType::lookup(std::string(valuestr));
- }
- else if(0 == strcmp("flags", keyword))
- {
- sscanf(valuestr, "%x", &mFlags);
- }
- else if(0 == strcmp("name", keyword))
- {
- //strcpy(valuestr, buffer + strlen(keyword) + 3);
- // *NOTE: Not ANSI C, but widely supported.
- sscanf( /* Flawfinder: ignore */
- buffer,
- " %254s%254[\t]%254[^|]",
- keyword, junk, valuestr);
-
- // IW: sscanf chokes and puts | in valuestr if there's no name
- if (valuestr[0] == '|')
- {
- valuestr[0] = '\000';
- }
-
- mName.assign(valuestr);
- LLStringUtil::replaceNonstandardASCII(mName, ' ');
- LLStringUtil::replaceChar(mName, '|', ' ');
- }
- else if(0 == strcmp("desc", keyword))
- {
- //strcpy(valuestr, buffer + strlen(keyword) + 3);
- // *NOTE: Not ANSI C, but widely supported.
- sscanf( /* Flawfinder: ignore */
- buffer,
- " %254s%254[\t]%254[^|]",
- keyword, junk, valuestr);
-
- if (valuestr[0] == '|')
- {
- valuestr[0] = '\000';
- }
-
- disclaimMem(mDescription);
- mDescription.assign(valuestr);
- claimMem(mDescription);
- LLStringUtil::replaceNonstandardASCII(mDescription, ' ');
- /* TODO -- ask Ian about this code
- const char *donkey = mDescription.c_str();
- if (donkey[0] == '|')
- {
- LL_ERRS() << "Donkey" << LL_ENDL;
- }
- */
- }
- else if(0 == strcmp("creation_date", keyword))
- {
- S32 date;
- sscanf(valuestr, "%d", &date);
- mCreationDate = date;
- }
- else
- {
- LL_WARNS() << "unknown keyword '" << keyword
- << "' in inventory import of item " << mUUID << LL_ENDL;
- }
- }
-
- // Need to convert 1.0 simstate files to a useful inventory type
- // and potentially deal with bad inventory tyes eg, a landmark
- // marked as a texture.
- if((LLInventoryType::IT_NONE == mInventoryType)
- || !inventory_and_asset_types_match(mInventoryType, mType))
- {
- LL_DEBUGS() << "Resetting inventory type for " << mUUID << LL_ENDL;
- mInventoryType = LLInventoryType::defaultForAssetType(mType);
- }
-
- mPermissions.initMasks(mInventoryType);
-
- return success;
-}
-
-BOOL LLInventoryItem::exportFile(LLFILE* fp, BOOL include_asset_key) const
-{
- std::string uuid_str;
- fprintf(fp, "\tinv_item\t0\n\t{\n");
- mUUID.toString(uuid_str);
- fprintf(fp, "\t\titem_id\t%s\n", uuid_str.c_str());
- mParentUUID.toString(uuid_str);
- fprintf(fp, "\t\tparent_id\t%s\n", uuid_str.c_str());
- mPermissions.exportFile(fp);
-
- // Check for permissions to see the asset id, and if so write it
- // out as an asset id. Otherwise, apply our cheesy encryption.
- if(include_asset_key)
- {
- U32 mask = mPermissions.getMaskBase();
- if(((mask & PERM_ITEM_UNRESTRICTED) == PERM_ITEM_UNRESTRICTED)
- || (mAssetUUID.isNull()))
- {
- mAssetUUID.toString(uuid_str);
- fprintf(fp, "\t\tasset_id\t%s\n", uuid_str.c_str());
- }
- else
- {
- LLUUID shadow_id(mAssetUUID);
- LLXORCipher cipher(MAGIC_ID.mData, UUID_BYTES);
- cipher.encrypt(shadow_id.mData, UUID_BYTES);
- shadow_id.toString(uuid_str);
- fprintf(fp, "\t\tshadow_id\t%s\n", uuid_str.c_str());
- }
- }
- else
- {
- LLUUID::null.toString(uuid_str);
- fprintf(fp, "\t\tasset_id\t%s\n", uuid_str.c_str());
- }
- fprintf(fp, "\t\ttype\t%s\n", LLAssetType::lookup(mType));
- const std::string inv_type_str = LLInventoryType::lookup(mInventoryType);
- if(!inv_type_str.empty()) fprintf(fp, "\t\tinv_type\t%s\n", inv_type_str.c_str());
- fprintf(fp, "\t\tflags\t%08x\n", mFlags);
- mSaleInfo.exportFile(fp);
- fprintf(fp, "\t\tname\t%s|\n", mName.c_str());
- fprintf(fp, "\t\tdesc\t%s|\n", mDescription.c_str());
- fprintf(fp, "\t\tcreation_date\t%d\n", (S32) mCreationDate);
- fprintf(fp,"\t}\n");
- return TRUE;
-}
-
-// virtual
BOOL LLInventoryItem::importLegacyStream(std::istream& input_stream)
{
// *NOTE: Changing the buffer size will require changing the scanf
@@ -1463,90 +1238,7 @@ void LLInventoryCategory::unpackMessage(LLMessageSystem* msg,
msg->getStringFast(block, _PREHASH_Name, mName, block_num);
LLStringUtil::replaceNonstandardASCII(mName, ' ');
}
-
-// virtual
-BOOL LLInventoryCategory::importFile(LLFILE* fp)
-{
- // *NOTE: Changing the buffer size will require changing the scanf
- // calls below.
- char buffer[MAX_STRING]; /* Flawfinder: ignore */
- char keyword[MAX_STRING]; /* Flawfinder: ignore */
- char valuestr[MAX_STRING]; /* Flawfinder: ignore */
- keyword[0] = '\0';
- valuestr[0] = '\0';
- while(!feof(fp))
- {
- if (fgets(buffer, MAX_STRING, fp) == NULL)
- {
- buffer[0] = '\0';
- }
-
- sscanf( /* Flawfinder: ignore */
- buffer,
- " %254s %254s",
- keyword, valuestr);
- if(0 == strcmp("{",keyword))
- {
- continue;
- }
- if(0 == strcmp("}", keyword))
- {
- break;
- }
- else if(0 == strcmp("cat_id", keyword))
- {
- mUUID.set(valuestr);
- }
- else if(0 == strcmp("parent_id", keyword))
- {
- mParentUUID.set(valuestr);
- }
- else if(0 == strcmp("type", keyword))
- {
- mType = LLAssetType::lookup(valuestr);
- }
- else if(0 == strcmp("pref_type", keyword))
- {
- mPreferredType = LLFolderType::lookup(valuestr);
- }
- else if(0 == strcmp("name", keyword))
- {
- //strcpy(valuestr, buffer + strlen(keyword) + 3);
- // *NOTE: Not ANSI C, but widely supported.
- sscanf( /* Flawfinder: ignore */
- buffer,
- " %254s %254[^|]",
- keyword, valuestr);
- mName.assign(valuestr);
- LLStringUtil::replaceNonstandardASCII(mName, ' ');
- LLStringUtil::replaceChar(mName, '|', ' ');
- }
- else
- {
- LL_WARNS() << "unknown keyword '" << keyword
- << "' in inventory import category " << mUUID << LL_ENDL;
- }
- }
- return TRUE;
-}
-
-BOOL LLInventoryCategory::exportFile(LLFILE* fp, BOOL) const
-{
- std::string uuid_str;
- fprintf(fp, "\tinv_category\t0\n\t{\n");
- mUUID.toString(uuid_str);
- fprintf(fp, "\t\tcat_id\t%s\n", uuid_str.c_str());
- mParentUUID.toString(uuid_str);
- fprintf(fp, "\t\tparent_id\t%s\n", uuid_str.c_str());
- fprintf(fp, "\t\ttype\t%s\n", LLAssetType::lookup(mType));
- fprintf(fp, "\t\tpref_type\t%s\n", LLFolderType::lookup(mPreferredType).c_str());
- fprintf(fp, "\t\tname\t%s|\n", mName.c_str());
- fprintf(fp,"\t}\n");
- return TRUE;
-}
-
-
// virtual
BOOL LLInventoryCategory::importLegacyStream(std::istream& input_stream)
{
@@ -1625,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 96659cd602..0f336a072f 100644
--- a/indra/llinventory/llinventory.h
+++ b/indra/llinventory/llinventory.h
@@ -95,8 +95,7 @@ public:
// Implemented here so that a minimal information set can be transmitted
// between simulator and viewer.
//--------------------------------------------------------------------
- // virtual BOOL importFile(LLFILE* fp);
- virtual BOOL exportFile(LLFILE* fp, BOOL include_asset_key = TRUE) const;
+
virtual BOOL importLegacyStream(std::istream& input_stream);
virtual BOOL exportLegacyStream(std::ostream& output_stream, BOOL include_asset_key = TRUE) const;
@@ -197,8 +196,6 @@ public:
// File Support
//--------------------------------------------------------------------
public:
- virtual BOOL importFile(LLFILE* fp);
- virtual BOOL exportFile(LLFILE* fp, BOOL include_asset_key = TRUE) const;
virtual BOOL importLegacyStream(std::istream& input_stream);
virtual BOOL exportLegacyStream(std::ostream& output_stream, BOOL include_asset_key = TRUE) const;
@@ -269,11 +266,11 @@ public:
// File Support
//--------------------------------------------------------------------
public:
- virtual BOOL importFile(LLFILE* fp);
- virtual BOOL exportFile(LLFILE* fp, BOOL include_asset_key = TRUE) const;
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/llinventorysettings.cpp b/indra/llinventory/llinventorysettings.cpp
index fdad50e8d4..81485b3a97 100644
--- a/indra/llinventory/llinventorysettings.cpp
+++ b/indra/llinventory/llinventorysettings.cpp
@@ -33,10 +33,6 @@
#include "llsingleton.h"
#include "llinvtranslationbrdg.h"
-//=========================================================================
-namespace {
- LLTranslationBridge::ptr_t sTranslator;
-}
//=========================================================================
struct SettingsEntry : public LLDictionaryEntry
@@ -49,7 +45,7 @@ struct SettingsEntry : public LLDictionaryEntry
mLabel(name),
mIconName(iconName)
{
- std::string transdname = sTranslator->getString(mLabel);
+ std::string transdname = LLSettingsType::getInstance()->mTranslator->getString(mLabel);
if (!transdname.empty())
{
mLabel = transdname;
@@ -84,6 +80,16 @@ void LLSettingsDictionary::initSingleton()
//=========================================================================
+LLSettingsType::LLSettingsType(LLTranslationBridge::ptr_t &trans)
+{
+ mTranslator = trans;
+}
+
+LLSettingsType::~LLSettingsType()
+{
+ mTranslator.reset();
+}
+
LLSettingsType::type_e LLSettingsType::fromInventoryFlags(U32 flags)
{
return (LLSettingsType::type_e)(flags & LLInventoryItemFlags::II_FLAGS_SUBTYPE_MASK);
@@ -104,13 +110,3 @@ std::string LLSettingsType::getDefaultName(LLSettingsType::type_e type)
return getDefaultName(ST_INVALID);
return entry->mDefaultNewName;
}
-
-void LLSettingsType::initClass(LLTranslationBridge::ptr_t &trans)
-{
- sTranslator = trans;
-}
-
-void LLSettingsType::cleanupClass()
-{
- sTranslator.reset();
-}
diff --git a/indra/llinventory/llinventorysettings.h b/indra/llinventory/llinventorysettings.h
index 906540689c..6b6685d088 100644
--- a/indra/llinventory/llinventorysettings.h
+++ b/indra/llinventory/llinventorysettings.h
@@ -30,9 +30,15 @@
#include "llinventorytype.h"
#include "llinvtranslationbrdg.h"
+#include "llsingleton.h"
-class LLSettingsType
+class LLSettingsType : public LLParamSingleton<LLSettingsType>
{
+ LLSINGLETON(LLSettingsType, LLTranslationBridge::ptr_t &trans);
+ ~LLSettingsType();
+
+ friend struct SettingsEntry;
+
public:
enum type_e
{
@@ -48,8 +54,9 @@ public:
static LLInventoryType::EIconName getIconName(type_e type);
static std::string getDefaultName(type_e type);
- static void initClass(LLTranslationBridge::ptr_t &trans);
- static void cleanupClass();
+protected:
+
+ LLTranslationBridge::ptr_t mTranslator;
};
diff --git a/indra/llinventory/llpermissions.cpp b/indra/llinventory/llpermissions.cpp
index e79b753514..0359d2f554 100644
--- a/indra/llinventory/llpermissions.cpp
+++ b/indra/llinventory/llpermissions.cpp
@@ -565,148 +565,6 @@ void LLPermissions::unpackMessage(LLMessageSystem* msg, const char* block, S32 b
}
-//
-// File support
-//
-
-BOOL LLPermissions::importFile(LLFILE* fp)
-{
- init(LLUUID::null, LLUUID::null, LLUUID::null, LLUUID::null);
- const S32 BUFSIZE = 16384;
-
- // *NOTE: Changing the buffer size will require changing the scanf
- // calls below.
- char buffer[BUFSIZE]; /* Flawfinder: ignore */
- char keyword[256]; /* Flawfinder: ignore */
- char valuestr[256]; /* Flawfinder: ignore */
- char uuid_str[256]; /* Flawfinder: ignore */
- U32 mask;
-
- keyword[0] = '\0';
- valuestr[0] = '\0';
-
- while (!feof(fp))
- {
- if (fgets(buffer, BUFSIZE, fp) == NULL)
- {
- buffer[0] = '\0';
- }
-
- sscanf( /* Flawfinder: ignore */
- buffer,
- " %255s %255s",
- keyword, valuestr);
- if (!strcmp("{", keyword))
- {
- continue;
- }
- if (!strcmp("}",keyword))
- {
- break;
- }
- else if (!strcmp("creator_mask", keyword))
- {
- // legacy support for "creator" masks
- sscanf(valuestr, "%x", &mask);
- mMaskBase = mask;
- fixFairUse();
- }
- else if (!strcmp("base_mask", keyword))
- {
- sscanf(valuestr, "%x", &mask);
- mMaskBase = mask;
- //fixFairUse();
- }
- else if (!strcmp("owner_mask", keyword))
- {
- sscanf(valuestr, "%x", &mask);
- mMaskOwner = mask;
- }
- else if (!strcmp("group_mask", keyword))
- {
- sscanf(valuestr, "%x", &mask);
- mMaskGroup = mask;
- }
- else if (!strcmp("everyone_mask", keyword))
- {
- sscanf(valuestr, "%x", &mask);
- mMaskEveryone = mask;
- }
- else if (!strcmp("next_owner_mask", keyword))
- {
- sscanf(valuestr, "%x", &mask);
- mMaskNextOwner = mask;
- }
- else if (!strcmp("creator_id", keyword))
- {
- sscanf(valuestr, "%255s", uuid_str); /* Flawfinder: ignore */
- mCreator.set(uuid_str);
- }
- else if (!strcmp("owner_id", keyword))
- {
- sscanf(valuestr, "%255s", uuid_str); /* Flawfinder: ignore */
- mOwner.set(uuid_str);
- }
- else if (!strcmp("last_owner_id", keyword))
- {
- sscanf(valuestr, "%255s", uuid_str); /* Flawfinder: ignore */
- mLastOwner.set(uuid_str);
- }
- else if (!strcmp("group_id", keyword))
- {
- sscanf(valuestr, "%255s", uuid_str); /* Flawfinder: ignore */
- mGroup.set(uuid_str);
- }
- else if (!strcmp("group_owned", keyword))
- {
- sscanf(valuestr, "%d", &mask);
- if(mask) mIsGroupOwned = true;
- else mIsGroupOwned = false;
- }
- else
- {
- LL_INFOS() << "unknown keyword " << keyword << " in permissions import" << LL_ENDL;
- }
- }
- fix();
- return TRUE;
-}
-
-
-BOOL LLPermissions::exportFile(LLFILE* fp) const
-{
- std::string uuid_str;
-
- fprintf(fp, "\tpermissions 0\n");
- fprintf(fp, "\t{\n");
-
- fprintf(fp, "\t\tbase_mask\t%08x\n", mMaskBase);
- fprintf(fp, "\t\towner_mask\t%08x\n", mMaskOwner);
- fprintf(fp, "\t\tgroup_mask\t%08x\n", mMaskGroup);
- fprintf(fp, "\t\teveryone_mask\t%08x\n", mMaskEveryone);
- fprintf(fp, "\t\tnext_owner_mask\t%08x\n", mMaskNextOwner);
-
- mCreator.toString(uuid_str);
- fprintf(fp, "\t\tcreator_id\t%s\n", uuid_str.c_str());
-
- mOwner.toString(uuid_str);
- fprintf(fp, "\t\towner_id\t%s\n", uuid_str.c_str());
-
- mLastOwner.toString(uuid_str);
- fprintf(fp, "\t\tlast_owner_id\t%s\n", uuid_str.c_str());
-
- mGroup.toString(uuid_str);
- fprintf(fp, "\t\tgroup_id\t%s\n", uuid_str.c_str());
-
- if(mIsGroupOwned)
- {
- fprintf(fp, "\t\tgroup_owned\t1\n");
- }
- fprintf(fp,"\t}\n");
- return TRUE;
-}
-
-
BOOL LLPermissions::importLegacyStream(std::istream& input_stream)
{
init(LLUUID::null, LLUUID::null, LLUUID::null, LLUUID::null);
diff --git a/indra/llinventory/llpermissions.h b/indra/llinventory/llpermissions.h
index 89c66f6ebd..27252f7b97 100644
--- a/indra/llinventory/llpermissions.h
+++ b/indra/llinventory/llpermissions.h
@@ -311,10 +311,6 @@ public:
void packMessage(LLMessageSystem* msg) const;
void unpackMessage(LLMessageSystem* msg, const char* block, S32 block_num = 0);
- // Load/save support
- BOOL importFile(LLFILE* fp);
- BOOL exportFile(LLFILE* fp) const;
-
BOOL importLegacyStream(std::istream& input_stream);
BOOL exportLegacyStream(std::ostream& output_stream) const;
diff --git a/indra/llinventory/llsaleinfo.cpp b/indra/llinventory/llsaleinfo.cpp
index 63e34d188e..b7231ee239 100644
--- a/indra/llinventory/llsaleinfo.cpp
+++ b/indra/llinventory/llsaleinfo.cpp
@@ -78,16 +78,6 @@ U32 LLSaleInfo::getCRC32() const
return rv;
}
-
-BOOL LLSaleInfo::exportFile(LLFILE* fp) const
-{
- fprintf(fp, "\tsale_info\t0\n\t{\n");
- fprintf(fp, "\t\tsale_type\t%s\n", lookup(mSaleType));
- fprintf(fp, "\t\tsale_price\t%d\n", mSalePrice);
- fprintf(fp,"\t}\n");
- return TRUE;
-}
-
BOOL LLSaleInfo::exportLegacyStream(std::ostream& output_stream) const
{
output_stream << "\tsale_info\t0\n\t{\n";
@@ -129,69 +119,6 @@ bool LLSaleInfo::fromLLSD(const LLSD& sd, BOOL& has_perm_mask, U32& perm_mask)
return true;
}
-// Deleted LLSaleInfo::exportFileXML() and LLSaleInfo::importXML()
-// because I can't find any non-test code references to it. 2009-05-04 JC
-
-BOOL LLSaleInfo::importFile(LLFILE* fp, BOOL& has_perm_mask, U32& perm_mask)
-{
- has_perm_mask = FALSE;
-
- // *NOTE: Changing the buffer size will require changing the scanf
- // calls below.
- char buffer[MAX_STRING]; /* Flawfinder: ignore */
- char keyword[MAX_STRING]; /* Flawfinder: ignore */
- char valuestr[MAX_STRING]; /* Flawfinder: ignore */
- BOOL success = TRUE;
-
- keyword[0] = '\0';
- valuestr[0] = '\0';
- while(success && (!feof(fp)))
- {
- if (fgets(buffer, MAX_STRING, fp) == NULL)
- {
- buffer[0] = '\0';
- }
-
- sscanf( /* Flawfinder: ignore */
- buffer,
- " %254s %254s",
- keyword, valuestr);
- if(!keyword[0])
- {
- continue;
- }
- if(0 == strcmp("{",keyword))
- {
- continue;
- }
- if(0 == strcmp("}", keyword))
- {
- break;
- }
- else if(0 == strcmp("sale_type", keyword))
- {
- mSaleType = lookup(valuestr);
- }
- else if(0 == strcmp("sale_price", keyword))
- {
- sscanf(valuestr, "%d", &mSalePrice);
- mSalePrice = llclamp(mSalePrice, 0, S32_MAX);
- }
- else if (!strcmp("perm_mask", keyword))
- {
- //LL_INFOS() << "found deprecated keyword perm_mask" << LL_ENDL;
- has_perm_mask = TRUE;
- sscanf(valuestr, "%x", &perm_mask);
- }
- else
- {
- LL_WARNS() << "unknown keyword '" << keyword
- << "' in sale info import" << LL_ENDL;
- }
- }
- return success;
-}
-
BOOL LLSaleInfo::importLegacyStream(std::istream& input_stream, BOOL& has_perm_mask, U32& perm_mask)
{
has_perm_mask = FALSE;
diff --git a/indra/llinventory/llsaleinfo.h b/indra/llinventory/llsaleinfo.h
index 4e98ccf6ff..3c8952838b 100644
--- a/indra/llinventory/llsaleinfo.h
+++ b/indra/llinventory/llsaleinfo.h
@@ -84,11 +84,6 @@ public:
void setSalePrice(S32 price);
//void setNextOwnerPermMask(U32 mask) { mNextOwnerPermMask = mask; }
-
- // file serialization
- BOOL exportFile(LLFILE* fp) const;
- BOOL importFile(LLFILE* fp, BOOL& has_perm_mask, U32& perm_mask);
-
BOOL exportLegacyStream(std::ostream& output_stream) const;
LLSD asLLSD() const;
operator LLSD() const { return asLLSD(); }
diff --git a/indra/llinventory/llsettingsbase.h b/indra/llinventory/llsettingsbase.h
index 1d118f0789..f7a9d5b7cd 100644
--- a/indra/llinventory/llsettingsbase.h
+++ b/indra/llinventory/llsettingsbase.h
@@ -359,7 +359,6 @@ protected:
virtual parammapping_t getParameterMap() const { return parammapping_t(); }
LLSD mSettings;
- bool mIsValid;
LLSD cloneSettings() const;
diff --git a/indra/llinventory/tests/inventorymisc_test.cpp b/indra/llinventory/tests/inventorymisc_test.cpp
index 7b15552f24..e8b063bffe 100644
--- a/indra/llinventory/tests/inventorymisc_test.cpp
+++ b/indra/llinventory/tests/inventorymisc_test.cpp
@@ -28,9 +28,9 @@
#include "linden_common.h"
#include "llsd.h"
+#include "llsdserialize.h"
#include "../llinventory.h"
-
#include "../test/lltut.h"
@@ -320,27 +320,39 @@ namespace tut
template<> template<>
void inventory_object::test<7>()
{
- LLFILE* fp = LLFile::fopen("linden_file.dat","w+");
- if(!fp)
+ std::string filename("linden_file.dat");
+ llofstream fileXML(filename.c_str());
+ if (!fileXML.is_open())
{
LL_ERRS() << "file could not be opened\n" << LL_ENDL;
return;
}
LLPointer<LLInventoryItem> src1 = create_random_inventory_item();
- src1->exportFile(fp, TRUE);
- fclose(fp);
+ fileXML << LLSDOStreamer<LLSDNotationFormatter>(src1->asLLSD()) << std::endl;
+ fileXML.close();
- LLPointer<LLInventoryItem> src2 = new LLInventoryItem();
- fp = LLFile::fopen("linden_file.dat","r+");
- if(!fp)
+
+ LLPointer<LLInventoryItem> src2 = new LLInventoryItem();
+ llifstream file(filename.c_str());
+ if (!file.is_open())
{
LL_ERRS() << "file could not be opened\n" << LL_ENDL;
return;
}
-
- src2->importFile(fp);
- fclose(fp);
+ std::string line;
+ LLPointer<LLSDParser> parser = new LLSDNotationParser();
+ std::getline(file, line);
+ LLSD s_item;
+ std::istringstream iss(line);
+ if (parser->parse(iss, s_item, line.length()) == LLSDParser::PARSE_FAILURE)
+ {
+ LL_ERRS()<< "Parsing cache failed" << LL_ENDL;
+ return;
+ }
+ src2->fromLLSD(s_item);
+
+ file.close();
ensure_equals("1.item id::getUUID() failed", src1->getUUID(), src2->getUUID());
ensure_equals("2.parent::getParentUUID() failed", src1->getParentUUID(), src2->getParentUUID());
@@ -457,27 +469,39 @@ namespace tut
template<> template<>
void inventory_object::test<13>()
{
- LLFILE* fp = LLFile::fopen("linden_file.dat","w");
- if(!fp)
+ std::string filename("linden_file.dat");
+ llofstream fileXML(filename.c_str());
+ if (!fileXML.is_open())
{
- LL_ERRS() << "file coudnt be opened\n" << LL_ENDL;
+ LL_ERRS() << "file could not be opened\n" << LL_ENDL;
return;
}
-
+
LLPointer<LLInventoryCategory> src1 = create_random_inventory_cat();
- src1->exportFile(fp, TRUE);
- fclose(fp);
+ fileXML << LLSDOStreamer<LLSDNotationFormatter>(src1->exportLLSD()) << std::endl;
+ fileXML.close();
- LLPointer<LLInventoryCategory> src2 = new LLInventoryCategory();
- fp = LLFile::fopen("linden_file.dat","r");
- if(!fp)
+ llifstream file(filename.c_str());
+ if (!file.is_open())
{
- LL_ERRS() << "file coudnt be opened\n" << LL_ENDL;
+ LL_ERRS() << "file could not be opened\n" << LL_ENDL;
return;
}
-
- src2->importFile(fp);
- fclose(fp);
+ std::string line;
+ LLPointer<LLSDParser> parser = new LLSDNotationParser();
+ std::getline(file, line);
+ LLSD s_item;
+ std::istringstream iss(line);
+ if (parser->parse(iss, s_item, line.length()) == LLSDParser::PARSE_FAILURE)
+ {
+ LL_ERRS()<< "Parsing cache failed" << LL_ENDL;
+ return;
+ }
+
+ file.close();
+
+ 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());