aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llinventory/llinventory.h
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:46 -0500
committerJacek Antonelli2008-08-15 23:44:46 -0500
commit38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch)
treeadca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/llinventory/llinventory.h
parentREADME.txt (diff)
downloadmeta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz
Second Life viewer sources 1.13.2.12
Diffstat (limited to '')
-rw-r--r--linden/indra/llinventory/llinventory.h430
1 files changed, 430 insertions, 0 deletions
diff --git a/linden/indra/llinventory/llinventory.h b/linden/indra/llinventory/llinventory.h
new file mode 100644
index 0000000..1ebcabf
--- /dev/null
+++ b/linden/indra/llinventory/llinventory.h
@@ -0,0 +1,430 @@
1/**
2 * @file llinventory.h
3 * @brief LLInventoryItem and LLInventoryCategory class declaration.
4 *
5 * Copyright (c) 2001-2007, Linden Research, Inc.
6 *
7 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement
10 * ("Other License"), formally executed by you and Linden Lab. Terms of
11 * the GPL can be found in doc/GPL-license.txt in this distribution, or
12 * online at http://secondlife.com/developers/opensource/gplv2
13 *
14 * There are special exceptions to the terms and conditions of the GPL as
15 * it is applied to this Source Code. View the full text of the exception
16 * in the file doc/FLOSS-exception.txt in this software distribution, or
17 * online at http://secondlife.com/developers/opensource/flossexception
18 *
19 * By copying, modifying or distributing this software, you acknowledge
20 * that you have read and understood your obligations described above,
21 * and agree to abide by those obligations.
22 *
23 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
24 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
25 * COMPLETENESS OR PERFORMANCE.
26 */
27
28#ifndef LL_LLINVENTORY_H
29#define LL_LLINVENTORY_H
30
31#include <functional>
32
33#include "llassetstorage.h"
34#include "lldarray.h"
35#include "llpermissions.h"
36#include "llsaleinfo.h"
37#include "llsd.h"
38#include "lluuid.h"
39#include "llxmlnode.h"
40
41// consts for Key field in the task inventory update message
42extern const U8 TASK_INVENTORY_ITEM_KEY;
43extern const U8 TASK_INVENTORY_ASSET_KEY;
44
45// anonymous enumeration to specify a max inventory buffer size for
46// use in packBinaryBucket()
47enum
48{
49 MAX_INVENTORY_BUFFER_SIZE = 1024
50};
51
52//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
53// Class LLInventoryType
54//
55// Class used to encapsulate operations around inventory type.
56//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
57
58class LLInventoryType
59{
60public:
61 enum EType
62 {
63 IT_TEXTURE = 0,
64 IT_SOUND = 1,
65 IT_CALLINGCARD = 2,
66 IT_LANDMARK = 3,
67 //IT_SCRIPT = 4,
68 //IT_CLOTHING = 5,
69 IT_OBJECT = 6,
70 IT_NOTECARD = 7,
71 IT_CATEGORY = 8,
72 IT_ROOT_CATEGORY = 9,
73 IT_LSL = 10,
74 //IT_LSL_BYTECODE = 11,
75 //IT_TEXTURE_TGA = 12,
76 //IT_BODYPART = 13,
77 //IT_TRASH = 14,
78 IT_SNAPSHOT = 15,
79 //IT_LOST_AND_FOUND = 16,
80 IT_ATTACHMENT = 17,
81 IT_WEARABLE = 18,
82 IT_ANIMATION = 19,
83 IT_GESTURE = 20,
84 IT_COUNT = 21,
85
86 IT_NONE = -1
87 };
88
89 // machine transation between type and strings
90 static EType lookup(const char* name);
91 static const char* lookup(EType type);
92
93 // translation from a type to a human readable form.
94 static const char* lookupHumanReadable(EType type);
95
96 // return the default inventory for the given asset type.
97 static EType defaultForAssetType(LLAssetType::EType asset_type);
98
99private:
100 // don't instantiate or derive one of these objects
101 LLInventoryType( void ) {}
102 ~LLInventoryType( void ) {}
103
104//private:
105// static const char* mInventoryTypeNames[];
106// static const char* mInventoryTypeHumanNames[];
107// static LLInventoryType::EType mInventoryAssetType[];
108};
109
110
111//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
112// Class LLInventoryObject
113//
114// This is the base class for inventory objects that handles the
115// common code between items and categories. The 'mParentUUID' member
116// means the parent category since all inventory objects except each
117// user's root category are in some category. Each user's root
118// category will have mParentUUID==LLUUID::null.
119//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
120
121class LLMessageSystem;
122
123class LLInventoryObject : public LLRefCount
124{
125protected:
126 LLUUID mUUID;
127 LLUUID mParentUUID;
128 LLAssetType::EType mType;
129 LLString mName;
130
131protected:
132 virtual ~LLInventoryObject( void );
133
134public:
135 MEM_TYPE_NEW(LLMemType::MTYPE_INVENTORY);
136 LLInventoryObject(const LLUUID& uuid, const LLUUID& parent_uuid,
137 LLAssetType::EType type, const LLString& name);
138 LLInventoryObject();
139 virtual void copy(const LLInventoryObject* other); // LLRefCount requires custom copy
140
141 // accessors
142 const LLUUID& getUUID() const;
143 const LLUUID& getParentUUID() const;
144 const LLString& getName() const;
145 LLAssetType::EType getType() const;
146
147 // mutators - will not call updateServer();
148 void setUUID(const LLUUID& new_uuid);
149 void rename(const LLString& new_name);
150 void setParent(const LLUUID& new_parent);
151 void setType(LLAssetType::EType type);
152
153 // file support - implemented here so that a minimal information
154 // set can be transmitted between simulator and viewer.
155// virtual BOOL importFile(FILE* fp);
156 virtual BOOL exportFile(FILE* fp, BOOL include_asset_key = TRUE) const;
157
158 virtual BOOL importLegacyStream(std::istream& input_stream);
159 virtual BOOL exportLegacyStream(std::ostream& output_stream, BOOL include_asset_key = TRUE) const;
160
161 // virtual methods
162 virtual void removeFromServer();
163 virtual void updateParentOnServer(BOOL) const;
164 virtual void updateServer(BOOL) const;
165};
166
167//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
168// Class LLInventoryItem
169//
170// An inventory item represents something that the current user has in
171// their inventory.
172//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
173
174class LLInventoryItem : public LLInventoryObject
175{
176public:
177 typedef LLDynamicArray<LLPointer<LLInventoryItem> > item_array_t;
178
179protected:
180 LLPermissions mPermissions;
181 LLUUID mAssetUUID;
182 LLString mDescription;
183 LLSaleInfo mSaleInfo;
184 LLInventoryType::EType mInventoryType;
185 U32 mFlags;
186 S32 mCreationDate; // seconds from 1/1/1970, UTC
187
188public:
189 enum
190 {
191 // The meaning of LLInventoryItem::mFlags is distinct for each
192 // inventory type.
193 II_FLAGS_NONE = 0,
194
195 // landmark flags
196 II_FLAGS_LANDMARK_VISITED = 1,
197
198 // flag to indicate that object permissions should have next
199 // owner perm be more restrictive on rez. We bump this into
200 // the second byte of the flags since the low byte is used to
201 // track attachment points.
202 II_FLAGS_OBJECT_SLAM_PERM = 0x100,
203
204 // These flags specify which permissions masks to overwrite
205 // upon rez. Normally, if no permissions slam (above) or
206 // overwrite flags are set, the asset's permissions are
207 // used and the inventory's permissions are ignored. If
208 // any of these flags are set, the inventory's permissions
209 // take precedence.
210 II_FLAGS_OBJECT_PERM_OVERWRITE_BASE = 0x010000,
211 II_FLAGS_OBJECT_PERM_OVERWRITE_OWNER = 0x020000,
212 II_FLAGS_OBJECT_PERM_OVERWRITE_GROUP = 0x040000,
213 II_FLAGS_OBJECT_PERM_OVERWRITE_EVERYONE = 0x080000,
214 II_FLAGS_OBJECT_PERM_OVERWRITE_NEXT_OWNER = 0x100000,
215
216 // wearables use the low order byte of flags to store the
217 // EWearableType enumeration found in newview/llwearable.h
218 };
219
220protected:
221 ~LLInventoryItem(); // ref counted
222
223public:
224 MEM_TYPE_NEW(LLMemType::MTYPE_INVENTORY);
225 LLInventoryItem(const LLUUID& uuid,
226 const LLUUID& parent_uuid,
227 const LLPermissions& permissions,
228 const LLUUID& asset_uuid,
229 LLAssetType::EType type,
230 LLInventoryType::EType inv_type,
231 const LLString& name,
232 const LLString& desc,
233 const LLSaleInfo& sale_info,
234 U32 flags,
235 S32 creation_date_utc);
236 LLInventoryItem();
237 // Create a copy of an inventory item from a pointer to another item
238 // Note: Because InventoryItems are ref counted, reference copy (a = b)
239 // is prohibited
240 LLInventoryItem(const LLInventoryItem* other);
241 virtual void copy(const LLInventoryItem* other); // LLRefCount requires custom copy
242
243 // As a constructor alternative, the clone() method works like a
244 // copy constructor, but gens a new UUID.
245 // It is up to the caller to delete (unref) the item.
246 virtual void clone(LLPointer<LLInventoryItem>& newitem) const;
247
248 // accessors
249 const LLPermissions& getPermissions() const;
250 const LLUUID& getCreatorUUID() const;
251 const LLUUID& getAssetUUID() const;
252 const LLString& getDescription() const;
253 const LLSaleInfo& getSaleInfo() const;
254 LLInventoryType::EType getInventoryType() const;
255 U32 getFlags() const;
256 S32 getCreationDate() const;
257 U32 getCRC32() const; // really more of a checksum.
258
259 // mutators - will not call updateServer(), and will never fail
260 // (though it may correct to sane values)
261 void setAssetUUID(const LLUUID& asset_id);
262 void setDescription(const LLString& new_desc);
263 void setSaleInfo(const LLSaleInfo& sale_info);
264 void setPermissions(const LLPermissions& perm);
265 void setInventoryType(LLInventoryType::EType inv_type);
266 void setFlags(U32 flags);
267 void setCreationDate(S32 creation_date_utc);
268
269 // Put this inventory item onto the current outgoing mesage. It
270 // assumes you have already called nextBlock().
271 virtual void packMessage(LLMessageSystem* msg) const;
272
273 // unpack returns TRUE if the inventory item came through the
274 // network ok. It uses a simple crc check which is defeatable, but
275 // we want to detect network mangling somehow.
276 virtual BOOL unpackMessage(LLMessageSystem* msg, const char* block, S32 block_num = 0);
277
278 // file support
279 virtual BOOL importFile(FILE* fp);
280 virtual BOOL exportFile(FILE* fp, BOOL include_asset_key = TRUE) const;
281
282 virtual BOOL importLegacyStream(std::istream& input_stream);
283 virtual BOOL exportLegacyStream(std::ostream& output_stream, BOOL include_asset_key = TRUE) const;
284
285 virtual LLXMLNode *exportFileXML(BOOL include_asset_key = TRUE) const;
286 BOOL importXML(LLXMLNode* node);
287
288 // helper functions
289
290 // pack all information needed to reconstruct this item into the given binary bucket.
291 // perm_override is optional
292 S32 packBinaryBucket(U8* bin_bucket, LLPermissions* perm_override = NULL) const;
293 void unpackBinaryBucket(U8* bin_bucket, S32 bin_bucket_size);
294 LLSD asLLSD() const;
295 bool fromLLSD(LLSD& sd);
296
297};
298
299BOOL item_dictionary_sort(LLInventoryItem* a,LLInventoryItem* b);
300BOOL item_date_sort(LLInventoryItem* a, LLInventoryItem* b);
301
302
303//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
304// Class LLInventoryCategory
305//
306// An instance of this class represents a category of inventory
307// items. Users come with a set of default categories, and can create
308// new ones as needed.
309//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
310
311class LLInventoryCategory : public LLInventoryObject
312{
313public:
314 typedef LLDynamicArray<LLPointer<LLInventoryCategory> > cat_array_t;
315
316protected:
317 ~LLInventoryCategory();
318
319public:
320 MEM_TYPE_NEW(LLMemType::MTYPE_INVENTORY);
321 LLInventoryCategory(const LLUUID& uuid, const LLUUID& parent_uuid,
322 LLAssetType::EType preferred_type,
323 const LLString& name);
324 LLInventoryCategory();
325 LLInventoryCategory(const LLInventoryCategory* other);
326 virtual void copy(const LLInventoryCategory* other); // LLRefCount requires custom copy
327
328 // accessors and mutators
329 LLAssetType::EType getPreferredType() const;
330 void setPreferredType(LLAssetType::EType type);
331 // For messaging system support
332 virtual void packMessage(LLMessageSystem* msg) const;
333 virtual void unpackMessage(LLMessageSystem* msg, const char* block, S32 block_num = 0);
334
335 // file support
336 virtual BOOL importFile(FILE* fp);
337 virtual BOOL exportFile(FILE* fp, BOOL include_asset_key = TRUE) const;
338
339 virtual BOOL importLegacyStream(std::istream& input_stream);
340 virtual BOOL exportLegacyStream(std::ostream& output_stream, BOOL include_asset_key = TRUE) const;
341
342protected:
343 // The type of asset that this category was "meant" to hold
344 // (although it may in fact hold any type).
345 LLAssetType::EType mPreferredType;
346
347};
348
349
350//-----------------------------------------------------------------------------
351// Useful bits
352//-----------------------------------------------------------------------------
353
354// This functor tests if an item is transferrable and returns true if
355// it is. Derived from unary_function<> so that the object can be used
356// in stl-compliant adaptable predicates (eg, not1<>). You might want
357// to use this in std::partition() or similar logic.
358struct IsItemTransferable : public std::unary_function<LLInventoryItem*, bool>
359{
360 LLUUID mDestID;
361 IsItemTransferable(const LLUUID& dest_id) : mDestID(dest_id) {}
362 bool operator()(const LLInventoryItem* item) const
363 {
364 return (item->getPermissions().allowTransferTo(mDestID)) ? true:false;
365 }
366};
367
368// This functor is used to set the owner and group of inventory items,
369// for example, in a simple std::for_each() loop. Note that the call
370// to setOwnerAndGroup can fail if authority_id != LLUUID::null.
371struct SetItemOwnerAndGroup
372{
373 LLUUID mAuthorityID;
374 LLUUID mOwnerID;
375 LLUUID mGroupID;
376 SetItemOwnerAndGroup(const LLUUID& authority_id,
377 const LLUUID& owner_id,
378 const LLUUID& group_id) :
379 mAuthorityID(authority_id), mOwnerID(owner_id), mGroupID(group_id) {}
380 void operator()(LLInventoryItem* item) const
381 {
382 LLPermissions perm = item->getPermissions();
383 bool is_atomic = (LLAssetType::AT_OBJECT == item->getType()) ? false : true;
384 perm.setOwnerAndGroup(mAuthorityID, mOwnerID, mGroupID, is_atomic);
385 item->setPermissions(perm);
386 }
387};
388
389// This functor is used to unset the share with group, everyone perms, and
390// for sale info for objects being sold through contents.
391struct SetNotForSale
392{
393 LLUUID mAgentID;
394 LLUUID mGroupID;
395 SetNotForSale(const LLUUID& agent_id,
396 const LLUUID& group_id) :
397 mAgentID(agent_id), mGroupID(group_id) {}
398 void operator()(LLInventoryItem* item) const
399 {
400 // Clear group & everyone permissions.
401 LLPermissions perm = item->getPermissions();
402 perm.setGroupBits(mAgentID, mGroupID, FALSE, PERM_MODIFY | PERM_MOVE | PERM_COPY);
403 perm.setEveryoneBits(mAgentID, mGroupID, FALSE, PERM_MOVE | PERM_COPY);
404 item->setPermissions(perm);
405
406 // Mark group & everyone permissions for overwrite on the next
407 // rez if it is an object.
408 if(LLAssetType::AT_OBJECT == item->getType())
409 {
410 U32 flags = item->getFlags();
411 flags |= LLInventoryItem::II_FLAGS_OBJECT_PERM_OVERWRITE_GROUP;
412 flags |= LLInventoryItem::II_FLAGS_OBJECT_PERM_OVERWRITE_EVERYONE;
413 item->setFlags(flags);
414 }
415
416 // Clear for sale info.
417 item->setSaleInfo(LLSaleInfo::DEFAULT);
418 }
419};
420
421typedef std::list<LLPointer<LLInventoryObject> > InventoryObjectList;
422
423// These functions convert between structured data and an inventroy
424// item, appropriate for serialization.
425LLSD ll_create_sd_from_inventory_item(LLPointer<LLInventoryItem> item);
426LLPointer<LLInventoryItem> ll_create_item_from_sd(const LLSD& sd_item);
427LLSD ll_create_sd_from_inventory_category(LLPointer<LLInventoryCategory> cat);
428LLPointer<LLInventoryCategory> ll_create_category_from_sd(const LLSD& sd_cat);
429
430#endif // LL_LLINVENTORY_H