Updated llinventory to something closer to V2's implementation. Mostly just restructuring.

Most the changes are due to InventoryObjectList* changing to LLInventoryObject::object_list_t*, LLInventoryItem::II_FLAGS* changing to LLInventoryItemFlags::II_FLAGS* and also const'ing.
Certain perms for certain asset types(callcard&landmarks) have been laxed, as per LL's V2.
LLInventoryType now does lookups mostly though new lldictionary class.
LLLandmark using boost for callbacks, instead of custom class structure.
This commit is contained in:
Shyotl
2011-04-28 01:43:44 -05:00
parent 722a1dda04
commit 332cfdb532
52 changed files with 1178 additions and 786 deletions

View File

@@ -33,180 +33,107 @@
#ifndef LL_LLINVENTORY_H
#define LL_LLINVENTORY_H
#include <functional>
#include "llassetstorage.h"
#include "lldarray.h"
#include "llinventorytype.h"
#include "llinventorydefines.h"
#include "llmemtype.h"
#include "llpermissions.h"
#include "llsaleinfo.h"
#include "llsd.h"
#include "lluuid.h"
#include "llxmlnode.h"
// consts for Key field in the task inventory update message
extern const U8 TASK_INVENTORY_ITEM_KEY;
extern const U8 TASK_INVENTORY_ASSET_KEY;
// anonymous enumeration to specify a max inventory buffer size for
// use in packBinaryBucket()
enum
{
MAX_INVENTORY_BUFFER_SIZE = 1024
};
class LLMessageSystem;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Class LLInventoryObject
//
// This is the base class for inventory objects that handles the
// common code between items and categories. The 'mParentUUID' member
// means the parent category since all inventory objects except each
// user's root category are in some category. Each user's root
// category will have mParentUUID==LLUUID::null.
// Base class for anything in the user's inventory. Handles the common code
// between items and categories.
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class LLMessageSystem;
class LLInventoryObject : public LLRefCount
{
protected:
LLUUID mUUID;
LLUUID mParentUUID;
LLAssetType::EType mType;
std::string mName;
public:
typedef std::list<LLPointer<LLInventoryObject> > object_list_t;
protected:
virtual ~LLInventoryObject( void );
//--------------------------------------------------------------------
// Initialization
//--------------------------------------------------------------------
public:
MEM_TYPE_NEW(LLMemType::MTYPE_INVENTORY);
LLInventoryObject(const LLUUID& uuid, const LLUUID& parent_uuid,
LLAssetType::EType type, const std::string& name);
LLInventoryObject();
LLInventoryObject(const LLUUID& uuid,
const LLUUID& parent_uuid,
LLAssetType::EType type,
const std::string& name);
void copyObject(const LLInventoryObject* other); // LLRefCount requires custom copy
protected:
virtual ~LLInventoryObject();
// accessors
virtual const LLUUID& getUUID() const;
//--------------------------------------------------------------------
// Accessors
//--------------------------------------------------------------------
public:
virtual const LLUUID& getUUID() const; // inventoryID that this item points to
virtual const LLUUID& getLinkedUUID() const; // inventoryID that this item points to, else this item's inventoryID
const LLUUID& getParentUUID() const;
virtual const LLUUID& getLinkedUUID() const; // get the inventoryID that this item points to, else this item's inventoryID
virtual const std::string& getName() const;
virtual LLAssetType::EType getType() const;
LLAssetType::EType getActualType() const; // bypasses indirection for linked items
BOOL getIsLinkType() const;
// mutators - will not call updateServer();
//--------------------------------------------------------------------
// Mutators
// Will not call updateServer
//--------------------------------------------------------------------
public:
void setUUID(const LLUUID& new_uuid);
virtual void rename(const std::string& new_name);
void setParent(const LLUUID& new_parent);
void setType(LLAssetType::EType type);
// file support - 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;
private:
// in place correction for inventory name string
void correctInventoryName(std::string& name);
//--------------------------------------------------------------------
// File Support
// Implemented here so that a minimal information set can be transmitted
// between simulator and viewer.
//--------------------------------------------------------------------
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;
// virtual methods
virtual void removeFromServer();
virtual void updateParentOnServer(BOOL) const;
virtual void updateServer(BOOL) const;
//--------------------------------------------------------------------
// Member Variables
//--------------------------------------------------------------------
protected:
LLUUID mUUID;
LLUUID mParentUUID; // Parent category. Root categories have LLUUID::NULL.
LLAssetType::EType mType;
std::string mName;
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Class LLInventoryItem
//
// An inventory item represents something that the current user has in
// their inventory.
// An item in the current user's inventory.
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class LLInventoryItem : public LLInventoryObject
{
public:
typedef LLDynamicArray<LLPointer<LLInventoryItem> > item_array_t;
protected:
LLPermissions mPermissions;
LLUUID mAssetUUID;
std::string mDescription;
LLSaleInfo mSaleInfo;
LLInventoryType::EType mInventoryType;
U32 mFlags;
time_t mCreationDate; // seconds from 1/1/1970, UTC
public:
/**
* Anonymous enumeration for specifying the inventory item flags.
*/
enum
{
// The shared flags at the top are shared among all inventory
// types. After that section, all values of flags are type
// dependent. The shared flags will start at 2^30 and work
// down while item type specific flags will start at 2^0 and
// work up.
II_FLAGS_NONE = 0,
//
// Shared flags
//
//
// This value means that the asset has only one reference in
// the system. If the inventory item is deleted, or the asset
// id updated, then we can remove the old reference.
II_FLAGS_SHARED_SINGLE_REFERENCE = 0x40000000,
//
// Landmark flags
//
II_FLAGS_LANDMARK_VISITED = 1,
//
// Object flags
//
// flag to indicate that object permissions should have next
// owner perm be more restrictive on rez. We bump this into
// the second byte of the flags since the low byte is used to
// track attachment points.
II_FLAGS_OBJECT_SLAM_PERM = 0x100,
// flag to indicate that the object sale information has been changed.
II_FLAGS_OBJECT_SLAM_SALE = 0x1000,
// These flags specify which permissions masks to overwrite
// upon rez. Normally, if no permissions slam (above) or
// overwrite flags are set, the asset's permissions are
// used and the inventory's permissions are ignored. If
// any of these flags are set, the inventory's permissions
// take precedence.
II_FLAGS_OBJECT_PERM_OVERWRITE_BASE = 0x010000,
II_FLAGS_OBJECT_PERM_OVERWRITE_OWNER = 0x020000,
II_FLAGS_OBJECT_PERM_OVERWRITE_GROUP = 0x040000,
II_FLAGS_OBJECT_PERM_OVERWRITE_EVERYONE = 0x080000,
II_FLAGS_OBJECT_PERM_OVERWRITE_NEXT_OWNER = 0x100000,
// flag to indicate whether an object that is returned is composed
// of muiltiple items or not.
II_FLAGS_OBJECT_HAS_MULTIPLE_ITEMS = 0x200000,
//
// wearables use the low order byte of flags to store the
// EWearableType enumeration found in newview/llwearable.h
//
II_FLAGS_WEARABLES_MASK = 0xff,
};
protected:
~LLInventoryItem(); // ref counted
//--------------------------------------------------------------------
// Initialization
//--------------------------------------------------------------------
public:
MEM_TYPE_NEW(LLMemType::MTYPE_INVENTORY);
LLInventoryItem(const LLUUID& uuid,
@@ -226,13 +153,19 @@ public:
// is prohibited
LLInventoryItem(const LLInventoryItem* other);
virtual void copyItem(const LLInventoryItem* other); // LLRefCount requires custom copy
// As a constructor alternative, the clone() method works like a
void generateUUID() { mUUID.generate(); }
// As a constructor alternative, the clone() method works like a
// copy constructor, but gens a new UUID.
// It is up to the caller to delete (unref) the item.
virtual void cloneItem(LLPointer<LLInventoryItem>& newitem) const;
protected:
~LLInventoryItem(); // ref counted
// accessors
//--------------------------------------------------------------------
// Accessors
//--------------------------------------------------------------------
public:
virtual const LLUUID& getLinkedUUID() const;
virtual const LLPermissions& getPermissions() const;
virtual const LLUUID& getCreatorUUID() const;
@@ -244,8 +177,12 @@ public:
virtual time_t getCreationDate() const;
virtual U32 getCRC32() const; // really more of a checksum.
// mutators - will not call updateServer(), and will never fail
// (though it may correct to sane values)
//--------------------------------------------------------------------
// Mutators
// Will not call updateServer and will never fail
// (though it may correct to sane values)
//--------------------------------------------------------------------
public:
void setAssetUUID(const LLUUID& asset_id);
void setDescription(const std::string& new_desc);
void setSaleInfo(const LLSaleInfo& sale_info);
@@ -253,34 +190,56 @@ public:
void setInventoryType(LLInventoryType::EType inv_type);
void setFlags(U32 flags);
void setCreationDate(time_t creation_date_utc);
void setCreator(const LLUUID& creator); // only used for calling cards
// Put this inventory item onto the current outgoing mesage. It
// assumes you have already called nextBlock().
// Check for changes in permissions masks and sale info
// and set the corresponding bits in mFlags.
void accumulatePermissionSlamBits(const LLInventoryItem& old_item);
// Put this inventory item onto the current outgoing mesage.
// Assumes you have already called nextBlock().
virtual void packMessage(LLMessageSystem* msg) const;
// unpack returns TRUE if the inventory item came through the
// 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
//--------------------------------------------------------------------
// 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;
virtual LLXMLNode *exportFileXML(BOOL include_asset_key = TRUE) const;
BOOL importXML(LLXMLNode* node);
// helper functions
//--------------------------------------------------------------------
// Helper Functions
//--------------------------------------------------------------------
public:
// Pack all information needed to reconstruct this item into the given binary bucket.
// pack all information needed to reconstruct this item into the given binary bucket.
// perm_override is optional
S32 packBinaryBucket(U8* bin_bucket, LLPermissions* perm_override = NULL) const;
void unpackBinaryBucket(U8* bin_bucket, S32 bin_bucket_size);
LLSD asLLSD() const;
bool fromLLSD(LLSD& sd);
void asLLSD( LLSD& sd ) const;
bool fromLLSD(const LLSD& sd);
//--------------------------------------------------------------------
// Member Variables
//--------------------------------------------------------------------
protected:
LLPermissions mPermissions;
LLUUID mAssetUUID;
std::string mDescription;
LLSaleInfo mSaleInfo;
LLInventoryType::EType mInventoryType;
U32 mFlags;
time_t mCreationDate; // seconds from 1/1/1970, UTC
};
BOOL item_dictionary_sort(LLInventoryItem* a,LLInventoryItem* b);
@@ -300,9 +259,9 @@ class LLInventoryCategory : public LLInventoryObject
public:
typedef LLDynamicArray<LLPointer<LLInventoryCategory> > cat_array_t;
protected:
~LLInventoryCategory();
//--------------------------------------------------------------------
// Initialization
//--------------------------------------------------------------------
public:
MEM_TYPE_NEW(LLMemType::MTYPE_INVENTORY);
LLInventoryCategory(const LLUUID& uuid, const LLUUID& parent_uuid,
@@ -311,29 +270,39 @@ public:
LLInventoryCategory();
LLInventoryCategory(const LLInventoryCategory* other);
void copyCategory(const LLInventoryCategory* other); // LLRefCount requires custom copy
protected:
~LLInventoryCategory();
// accessors and mutators
//--------------------------------------------------------------------
// Accessors And Mutators
//--------------------------------------------------------------------
public:
LLAssetType::EType getPreferredType() const;
void setPreferredType(LLAssetType::EType type);
// For messaging system support
LLSD asLLSD() const;
bool fromLLSD(const LLSD& sd);
//--------------------------------------------------------------------
// Messaging
//--------------------------------------------------------------------
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
//--------------------------------------------------------------------
// 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;
//--------------------------------------------------------------------
// Member Variables
//--------------------------------------------------------------------
protected:
// The type of asset that this category was "meant" to hold
// (although it may in fact hold any type).
LLAssetType::EType mPreferredType;
LLAssetType::EType mPreferredType; // Type that this category was "meant" to hold (although it may hold any type).
};
@@ -404,8 +373,8 @@ struct SetNotForSale
if(LLAssetType::AT_OBJECT == item->getType())
{
U32 flags = item->getFlags();
flags |= LLInventoryItem::II_FLAGS_OBJECT_PERM_OVERWRITE_GROUP;
flags |= LLInventoryItem::II_FLAGS_OBJECT_PERM_OVERWRITE_EVERYONE;
flags |= LLInventoryItemFlags::II_FLAGS_OBJECT_PERM_OVERWRITE_GROUP;
flags |= LLInventoryItemFlags::II_FLAGS_OBJECT_PERM_OVERWRITE_EVERYONE;
item->setFlags(flags);
}