00001
00032 #ifndef LL_LLINVENTORY_H
00033 #define LL_LLINVENTORY_H
00034
00035 #include <functional>
00036
00037 #include "llassetstorage.h"
00038 #include "lldarray.h"
00039 #include "llinventorytype.h"
00040 #include "llmemtype.h"
00041 #include "llpermissions.h"
00042 #include "llsaleinfo.h"
00043 #include "llsd.h"
00044 #include "lluuid.h"
00045 #include "llxmlnode.h"
00046
00047
00048 extern const U8 TASK_INVENTORY_ITEM_KEY;
00049 extern const U8 TASK_INVENTORY_ASSET_KEY;
00050
00051
00052
00053 enum
00054 {
00055 MAX_INVENTORY_BUFFER_SIZE = 1024
00056 };
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070 class LLMessageSystem;
00071
00072 class LLInventoryObject : public LLRefCount
00073 {
00074 protected:
00075 LLUUID mUUID;
00076 LLUUID mParentUUID;
00077 LLAssetType::EType mType;
00078 LLString mName;
00079
00080 protected:
00081 virtual ~LLInventoryObject( void );
00082
00083 public:
00084 MEM_TYPE_NEW(LLMemType::MTYPE_INVENTORY);
00085 LLInventoryObject(const LLUUID& uuid, const LLUUID& parent_uuid,
00086 LLAssetType::EType type, const LLString& name);
00087 LLInventoryObject();
00088 void copyObject(const LLInventoryObject* other);
00089
00090
00091 const LLUUID& getUUID() const;
00092 const LLUUID& getParentUUID() const;
00093 const LLString& getName() const;
00094 LLAssetType::EType getType() const;
00095
00096
00097 void setUUID(const LLUUID& new_uuid);
00098 void rename(const LLString& new_name);
00099 void setParent(const LLUUID& new_parent);
00100 void setType(LLAssetType::EType type);
00101
00102
00103
00104
00105 virtual BOOL exportFile(LLFILE* fp, BOOL include_asset_key = TRUE) const;
00106
00107 virtual BOOL importLegacyStream(std::istream& input_stream);
00108 virtual BOOL exportLegacyStream(std::ostream& output_stream, BOOL include_asset_key = TRUE) const;
00109
00110
00111 virtual void removeFromServer();
00112 virtual void updateParentOnServer(BOOL) const;
00113 virtual void updateServer(BOOL) const;
00114 };
00115
00116
00117
00118
00119
00120
00121
00122
00123 class LLInventoryItem : public LLInventoryObject
00124 {
00125 public:
00126 typedef LLDynamicArray<LLPointer<LLInventoryItem> > item_array_t;
00127
00128 protected:
00129 LLPermissions mPermissions;
00130 LLUUID mAssetUUID;
00131 LLString mDescription;
00132 LLSaleInfo mSaleInfo;
00133 LLInventoryType::EType mInventoryType;
00134 U32 mFlags;
00135 S32 mCreationDate;
00136
00137 public:
00138
00142 enum
00143 {
00144
00145
00146
00147
00148
00149 II_FLAGS_NONE = 0,
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160 II_FLAGS_SHARED_SINGLE_REFERENCE = 0x40000000,
00161
00162
00163
00164
00165
00166 II_FLAGS_LANDMARK_VISITED = 1,
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176 II_FLAGS_OBJECT_SLAM_PERM = 0x100,
00177
00178
00179 II_FLAGS_OBJECT_SLAM_SALE = 0x1000,
00180
00181
00182
00183
00184
00185
00186
00187 II_FLAGS_OBJECT_PERM_OVERWRITE_BASE = 0x010000,
00188 II_FLAGS_OBJECT_PERM_OVERWRITE_OWNER = 0x020000,
00189 II_FLAGS_OBJECT_PERM_OVERWRITE_GROUP = 0x040000,
00190 II_FLAGS_OBJECT_PERM_OVERWRITE_EVERYONE = 0x080000,
00191 II_FLAGS_OBJECT_PERM_OVERWRITE_NEXT_OWNER = 0x100000,
00192
00193
00194
00195 II_FLAGS_OBJECT_HAS_MULTIPLE_ITEMS = 0x200000,
00196
00197
00198
00199
00200
00201 II_FLAGS_WEARABLES_MASK = 0xff,
00202 };
00203
00204 protected:
00205 ~LLInventoryItem();
00206
00207 public:
00208 MEM_TYPE_NEW(LLMemType::MTYPE_INVENTORY);
00209 LLInventoryItem(const LLUUID& uuid,
00210 const LLUUID& parent_uuid,
00211 const LLPermissions& permissions,
00212 const LLUUID& asset_uuid,
00213 LLAssetType::EType type,
00214 LLInventoryType::EType inv_type,
00215 const LLString& name,
00216 const LLString& desc,
00217 const LLSaleInfo& sale_info,
00218 U32 flags,
00219 S32 creation_date_utc);
00220 LLInventoryItem();
00221
00222
00223
00224 LLInventoryItem(const LLInventoryItem* other);
00225 virtual void copyItem(const LLInventoryItem* other);
00226
00227
00228
00229
00230 virtual void cloneItem(LLPointer<LLInventoryItem>& newitem) const;
00231
00232
00233 const LLPermissions& getPermissions() const;
00234 const LLUUID& getCreatorUUID() const;
00235 const LLUUID& getAssetUUID() const;
00236 const LLString& getDescription() const;
00237 const LLSaleInfo& getSaleInfo() const;
00238 LLInventoryType::EType getInventoryType() const;
00239 U32 getFlags() const;
00240 S32 getCreationDate() const;
00241 U32 getCRC32() const;
00242
00243
00244
00245 void setAssetUUID(const LLUUID& asset_id);
00246 void setDescription(const LLString& new_desc);
00247 void setSaleInfo(const LLSaleInfo& sale_info);
00248 void setPermissions(const LLPermissions& perm);
00249 void setInventoryType(LLInventoryType::EType inv_type);
00250 void setFlags(U32 flags);
00251 void setCreationDate(S32 creation_date_utc);
00252
00253
00254
00255 virtual void packMessage(LLMessageSystem* msg) const;
00256
00257
00258
00259
00260 virtual BOOL unpackMessage(LLMessageSystem* msg, const char* block, S32 block_num = 0);
00261
00262 virtual BOOL importFile(LLFILE* fp);
00263 virtual BOOL exportFile(LLFILE* fp, BOOL include_asset_key = TRUE) const;
00264
00265 virtual BOOL importLegacyStream(std::istream& input_stream);
00266 virtual BOOL exportLegacyStream(std::ostream& output_stream, BOOL include_asset_key = TRUE) const;
00267
00268 virtual LLXMLNode *exportFileXML(BOOL include_asset_key = TRUE) const;
00269 BOOL importXML(LLXMLNode* node);
00270
00271
00272
00273
00274
00275 S32 packBinaryBucket(U8* bin_bucket, LLPermissions* perm_override = NULL) const;
00276 void unpackBinaryBucket(U8* bin_bucket, S32 bin_bucket_size);
00277 LLSD asLLSD() const;
00278 bool fromLLSD(LLSD& sd);
00279
00280 };
00281
00282 BOOL item_dictionary_sort(LLInventoryItem* a,LLInventoryItem* b);
00283 BOOL item_date_sort(LLInventoryItem* a, LLInventoryItem* b);
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294 class LLInventoryCategory : public LLInventoryObject
00295 {
00296 public:
00297 typedef LLDynamicArray<LLPointer<LLInventoryCategory> > cat_array_t;
00298
00299 protected:
00300 ~LLInventoryCategory();
00301
00302 public:
00303 MEM_TYPE_NEW(LLMemType::MTYPE_INVENTORY);
00304 LLInventoryCategory(const LLUUID& uuid, const LLUUID& parent_uuid,
00305 LLAssetType::EType preferred_type,
00306 const LLString& name);
00307 LLInventoryCategory();
00308 LLInventoryCategory(const LLInventoryCategory* other);
00309 void copyCategory(const LLInventoryCategory* other);
00310
00311
00312 LLAssetType::EType getPreferredType() const;
00313 void setPreferredType(LLAssetType::EType type);
00314
00315 virtual void packMessage(LLMessageSystem* msg) const;
00316 virtual void unpackMessage(LLMessageSystem* msg, const char* block, S32 block_num = 0);
00317
00318 LLSD asLLSD() const;
00319 bool fromLLSD(LLSD& sd);
00320
00321
00322 virtual BOOL importFile(LLFILE* fp);
00323 virtual BOOL exportFile(LLFILE* fp, BOOL include_asset_key = TRUE) const;
00324
00325 virtual BOOL importLegacyStream(std::istream& input_stream);
00326 virtual BOOL exportLegacyStream(std::ostream& output_stream, BOOL include_asset_key = TRUE) const;
00327
00328 protected:
00329
00330
00331 LLAssetType::EType mPreferredType;
00332
00333 };
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344 struct IsItemTransferable : public std::unary_function<LLInventoryItem*, bool>
00345 {
00346 LLUUID mDestID;
00347 IsItemTransferable(const LLUUID& dest_id) : mDestID(dest_id) {}
00348 bool operator()(const LLInventoryItem* item) const
00349 {
00350 return (item->getPermissions().allowTransferTo(mDestID)) ? true:false;
00351 }
00352 };
00353
00354
00355
00356
00357 struct SetItemOwnerAndGroup
00358 {
00359 LLUUID mAuthorityID;
00360 LLUUID mOwnerID;
00361 LLUUID mGroupID;
00362 SetItemOwnerAndGroup(const LLUUID& authority_id,
00363 const LLUUID& owner_id,
00364 const LLUUID& group_id) :
00365 mAuthorityID(authority_id), mOwnerID(owner_id), mGroupID(group_id) {}
00366 void operator()(LLInventoryItem* item) const
00367 {
00368 LLPermissions perm = item->getPermissions();
00369 bool is_atomic = (LLAssetType::AT_OBJECT == item->getType()) ? false : true;
00370 perm.setOwnerAndGroup(mAuthorityID, mOwnerID, mGroupID, is_atomic);
00371
00372
00373 if (mOwnerID.isNull())
00374 {
00375 perm.setMaskGroup(PERM_NONE);
00376 }
00377 item->setPermissions(perm);
00378 }
00379 };
00380
00381
00382
00383 struct SetNotForSale
00384 {
00385 LLUUID mAgentID;
00386 LLUUID mGroupID;
00387 SetNotForSale(const LLUUID& agent_id,
00388 const LLUUID& group_id) :
00389 mAgentID(agent_id), mGroupID(group_id) {}
00390 void operator()(LLInventoryItem* item) const
00391 {
00392
00393 LLPermissions perm = item->getPermissions();
00394 perm.setGroupBits(mAgentID, mGroupID, FALSE, PERM_MODIFY | PERM_MOVE | PERM_COPY);
00395 perm.setEveryoneBits(mAgentID, mGroupID, FALSE, PERM_MOVE | PERM_COPY);
00396 item->setPermissions(perm);
00397
00398
00399
00400 if(LLAssetType::AT_OBJECT == item->getType())
00401 {
00402 U32 flags = item->getFlags();
00403 flags |= LLInventoryItem::II_FLAGS_OBJECT_PERM_OVERWRITE_GROUP;
00404 flags |= LLInventoryItem::II_FLAGS_OBJECT_PERM_OVERWRITE_EVERYONE;
00405 item->setFlags(flags);
00406 }
00407
00408
00409 item->setSaleInfo(LLSaleInfo::DEFAULT);
00410 }
00411 };
00412
00413 typedef std::list<LLPointer<LLInventoryObject> > InventoryObjectList;
00414
00415
00416
00417 LLSD ll_create_sd_from_inventory_item(LLPointer<LLInventoryItem> item);
00418 LLPointer<LLInventoryItem> ll_create_item_from_sd(const LLSD& sd_item);
00419 LLSD ll_create_sd_from_inventory_category(LLPointer<LLInventoryCategory> cat);
00420 LLPointer<LLInventoryCategory> ll_create_category_from_sd(const LLSD& sd_cat);
00421
00422 #endif // LL_LLINVENTORY_H