llviewerinventory.h

Go to the documentation of this file.
00001 
00032 #ifndef LL_LLVIEWERINVENTORY_H
00033 #define LL_LLVIEWERINVENTORY_H
00034 
00035 #include "llinventory.h"
00036 #include "llframetimer.h"
00037 #include "llwearable.h"
00038 
00039 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00040 // Class LLViewerInventoryItem
00041 //
00042 // An inventory item represents something that the current user has in
00043 // their inventory.
00044 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00045 
00046 class LLViewerInventoryItem : public LLInventoryItem
00047 {
00048 public:
00049         typedef LLDynamicArray<LLPointer<LLViewerInventoryItem> > item_array_t;
00050         
00051 protected:
00052         ~LLViewerInventoryItem( void ); // ref counted
00053         
00054 public:
00055         // construct a complete viewer inventory item
00056         LLViewerInventoryItem(const LLUUID& uuid, const LLUUID& parent_uuid,
00057                                                   const LLPermissions& permissions,
00058                                                   const LLUUID& asset_uuid,
00059                                                   LLAssetType::EType type,
00060                                                   LLInventoryType::EType inv_type,
00061                                                   const LLString& name, 
00062                                                   const LLString& desc,
00063                                                   const LLSaleInfo& sale_info,
00064                                                   U32 flags,
00065                                                   S32 creation_date_utc);
00066 
00067         // construct a viewer inventory item which has the minimal amount
00068         // of information to use in the UI.
00069         LLViewerInventoryItem(
00070                 const LLUUID& item_id,
00071                 const LLUUID& parent_id,
00072                 const char* name,
00073                 LLInventoryType::EType inv_type);
00074 
00075         // construct an invalid and incomplete viewer inventory item.
00076         // usually useful for unpacking or importing or what have you.
00077         // *NOTE: it is important to call setComplete() if you expect the
00078         // operations to provide all necessary information.
00079         LLViewerInventoryItem();
00080         // Create a copy of an inventory item from a pointer to another item
00081         // Note: Because InventoryItems are ref counted,
00082         //       reference copy (a = b) is prohibited
00083         LLViewerInventoryItem(const LLViewerInventoryItem* other);
00084         LLViewerInventoryItem(const LLInventoryItem* other);
00085 
00086         void copyViewerItem(const LLViewerInventoryItem* other);
00087         /*virtual*/ void copyItem(const LLInventoryItem* other);
00088 
00089         // construct a new clone of this item - it creates a new viewer
00090         // inventory item using the copy constructor, and returns it.
00091         // It is up to the caller to delete (unref) the item.
00092         void cloneViewerItem(LLPointer<LLViewerInventoryItem>& newitem) const;
00093 
00094         // virtual methods
00095         virtual void removeFromServer( void );
00096         virtual void updateParentOnServer(BOOL restamp) const;
00097         virtual void updateServer(BOOL is_new) const;
00098         void fetchFromServer(void) const;
00099 
00100         //virtual void packMessage(LLMessageSystem* msg) const;
00101         virtual BOOL unpackMessage(LLMessageSystem* msg, const char* block, S32 block_num = 0);
00102         virtual BOOL unpackMessage(LLSD item);
00103         virtual BOOL importFile(LLFILE* fp);
00104         virtual BOOL importLegacyStream(std::istream& input_stream);
00105 
00106         // file handling on the viewer. These are not meant for anything
00107         // other than cacheing.
00108         bool exportFileLocal(LLFILE* fp) const;
00109         bool importFileLocal(LLFILE* fp);
00110 
00111         // new methods
00112         BOOL isComplete() const { return mIsComplete; }
00113         void setComplete(BOOL complete) { mIsComplete = complete; }
00114         //void updateAssetOnServer() const;
00115 
00116         virtual void packMessage(LLMessageSystem* msg) const;
00117         virtual void setTransactionID(const LLTransactionID& transaction_id);
00118         struct comparePointers
00119         {
00120                 bool operator()(const LLPointer<LLViewerInventoryItem>& a, const LLPointer<LLViewerInventoryItem>& b)
00121                 {
00122                         return a->getName().compare(b->getName()) < 0;
00123                 }
00124         };
00125         LLTransactionID getTransactionID() const { return mTransactionID; }
00126         
00127 protected:
00128         BOOL mIsComplete;
00129         LLTransactionID mTransactionID;
00130 };
00131 
00132 
00133 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00134 // Class LLViewerInventoryCategory
00135 //
00136 // An instance of this class represents a category of inventory
00137 // items. Users come with a set of default categories, and can create
00138 // new ones as needed.
00139 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00140 
00141 class LLViewerInventoryCategory  : public LLInventoryCategory
00142 {
00143 public:
00144         typedef LLDynamicArray<LLPointer<LLViewerInventoryCategory> > cat_array_t;
00145         
00146 protected:
00147         ~LLViewerInventoryCategory();
00148         
00149 public:
00150         LLViewerInventoryCategory(const LLUUID& uuid, const LLUUID& parent_uuid,
00151                                                           LLAssetType::EType preferred_type,
00152                                                           const LLString& name,
00153                                                           const LLUUID& owner_id);
00154         LLViewerInventoryCategory(const LLUUID& owner_id);
00155         // Create a copy of an inventory category from a pointer to another category
00156         // Note: Because InventoryCategorys are ref counted, reference copy (a = b)
00157         // is prohibited
00158         LLViewerInventoryCategory(const LLViewerInventoryCategory* other);
00159         void copyViewerCategory(const LLViewerInventoryCategory* other);
00160 
00161         virtual void removeFromServer();
00162         virtual void updateParentOnServer(BOOL restamp_children) const;
00163         virtual void updateServer(BOOL is_new) const;
00164         //virtual BOOL unpackMessage(LLMessageSystem* msg, const char* block, S32 block_num = 0);
00165 
00166         const LLUUID& getOwnerID() const { return mOwnerID; }
00167 
00168         // Version handling
00169         enum { VERSION_UNKNOWN = -1, VERSION_INITIAL = 1 };
00170         S32 getVersion() const { return mVersion; }
00171         void setVersion(S32 version) { mVersion = version; }
00172 
00173         // Returns true if a fetch was issued.
00174         bool fetchDescendents();
00175 
00176         // used to help make cacheing more robust - for example, if
00177         // someone is getting 4 packets but logs out after 3. the viewer
00178         // may never know the cache is wrong.
00179         enum { DESCENDENT_COUNT_UNKNOWN = -1 };
00180         S32 getDescendentCount() const { return mDescendentCount; }
00181         void setDescendentCount(S32 descendents) { mDescendentCount = descendents; }
00182 
00183         // file handling on the viewer. These are not meant for anything
00184         // other than cacheing.
00185         bool exportFileLocal(LLFILE* fp) const;
00186         bool importFileLocal(LLFILE* fp);
00187 
00188 protected:
00189         LLUUID mOwnerID;
00190         S32 mVersion;
00191         S32 mDescendentCount;
00192         LLFrameTimer mDescendentsRequested;
00193 };
00194 
00195 class LLInventoryCallback : public LLRefCount
00196 {
00197 public:
00198         virtual void fire(const LLUUID& inv_item) = 0;
00199 };
00200 
00201 class WearOnAvatarCallback : public LLInventoryCallback
00202 {
00203         void fire(const LLUUID& inv_item);
00204 };
00205 
00206 class LLViewerJointAttachment;
00207 
00208 class RezAttachmentCallback : public LLInventoryCallback
00209 {
00210 public:
00211         RezAttachmentCallback(LLViewerJointAttachment *attachmentp);
00212         void fire(const LLUUID& inv_item);
00213 
00214 protected:
00215         ~RezAttachmentCallback();
00216 
00217 private:
00218         LLViewerJointAttachment* mAttach;
00219 };
00220 
00221 class ActivateGestureCallback : public LLInventoryCallback
00222 {
00223 public:
00224         void fire(const LLUUID& inv_item);
00225 };
00226 
00227 class CreateGestureCallback : public LLInventoryCallback
00228 {
00229 public:
00230         void fire(const LLUUID& inv_item);
00231 };
00232 
00233 // misc functions
00234 //void inventory_reliable_callback(void**, S32 status);
00235 
00236 class LLInventoryCallbackManager
00237 {
00238 public:
00239         LLInventoryCallbackManager();
00240         ~LLInventoryCallbackManager();
00241 
00242         void fire(U32 callback_id, const LLUUID& item_id);
00243         U32 registerCB(LLPointer<LLInventoryCallback> cb);
00244 private:
00245         std::map<U32, LLPointer<LLInventoryCallback> > mMap;
00246         U32 mLastCallback;
00247         static LLInventoryCallbackManager *sInstance;
00248 public:
00249         static bool is_instantiated() { return sInstance != NULL; }
00250 };
00251 extern LLInventoryCallbackManager gInventoryCallbacks;
00252 
00253 
00254 #define NOT_WEARABLE (EWearableType)0
00255 
00256 void create_inventory_item(const LLUUID& agent_id, const LLUUID& session_id,
00257                                                    const LLUUID& parent, const LLTransactionID& transaction_id,
00258                                                    const std::string& name,
00259                                                    const std::string& desc, LLAssetType::EType asset_type,
00260                                                    LLInventoryType::EType inv_type, EWearableType wtype,
00261                                                    U32 next_owner_perm,
00262                                                    LLPointer<LLInventoryCallback> cb);
00263 
00267 void copy_inventory_item(
00268         const LLUUID& agent_id,
00269         const LLUUID& current_owner,
00270         const LLUUID& item_id,
00271         const LLUUID& parent_id,
00272         const std::string& new_name,
00273         LLPointer<LLInventoryCallback> cb);
00274 
00275 void move_inventory_item(
00276         const LLUUID& agent_id,
00277         const LLUUID& session_id,
00278         const LLUUID& item_id,
00279         const LLUUID& parent_id,
00280         const std::string& new_name,
00281         LLPointer<LLInventoryCallback> cb);
00282 
00283 void copy_inventory_from_notecard(const LLUUID& object_id,
00284                                                                   const LLUUID& notecard_inv_id,
00285                                                                   const LLInventoryItem *src,
00286                                                                   U32 callback_id = 0);
00287 
00288 
00289 #endif // LL_LLVIEWERINVENTORY_H

Generated on Fri May 16 08:34:10 2008 for SecondLife by  doxygen 1.5.5