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         virtual void copy(const LLViewerInventoryItem* other);
00087         virtual void copy(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         virtual void clone(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 importFile(FILE* fp);
00103         virtual BOOL importLegacyStream(std::istream& input_stream);
00104 
00105         // file handling on the viewer. These are not meant for anything
00106         // other than cacheing.
00107         bool exportFileLocal(FILE* fp) const;
00108         bool importFileLocal(FILE* fp);
00109 
00110         // new methods
00111         BOOL isComplete() const { return mIsComplete; }
00112         void setComplete(BOOL complete) { mIsComplete = complete; }
00113         //void updateAssetOnServer() const;
00114 
00115         virtual void packMessage(LLMessageSystem* msg) const;
00116         virtual void setTransactionID(const LLTransactionID& transaction_id);
00117         struct comparePointers
00118         {
00119                 bool operator()(const LLPointer<LLViewerInventoryItem>& a, const LLPointer<LLViewerInventoryItem>& b)
00120                 {
00121                         return a->getName().compare(b->getName()) < 0;
00122                 }
00123         };
00124         LLTransactionID getTransactionID() const { return mTransactionID; }
00125         
00126 protected:
00127         BOOL mIsComplete;
00128         LLTransactionID mTransactionID;
00129 };
00130 
00131 
00132 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00133 // Class LLViewerInventoryCategory
00134 //
00135 // An instance of this class represents a category of inventory
00136 // items. Users come with a set of default categories, and can create
00137 // new ones as needed.
00138 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00139 
00140 class LLViewerInventoryCategory  : public LLInventoryCategory
00141 {
00142 public:
00143         typedef LLDynamicArray<LLPointer<LLViewerInventoryCategory> > cat_array_t;
00144         
00145 protected:
00146         ~LLViewerInventoryCategory();
00147         
00148 public:
00149         LLViewerInventoryCategory(const LLUUID& uuid, const LLUUID& parent_uuid,
00150                                                           LLAssetType::EType preferred_type,
00151                                                           const LLString& name,
00152                                                           const LLUUID& owner_id);
00153         LLViewerInventoryCategory(const LLUUID& owner_id);
00154         // Create a copy of an inventory category from a pointer to another category
00155         // Note: Because InventoryCategorys are ref counted, reference copy (a = b)
00156         // is prohibited
00157         LLViewerInventoryCategory(const LLViewerInventoryCategory* other);
00158         virtual void copy(const LLViewerInventoryCategory* other);
00159 
00160         virtual void removeFromServer();
00161         virtual void updateParentOnServer(BOOL restamp_children) const;
00162         virtual void updateServer(BOOL is_new) const;
00163         //virtual BOOL unpackMessage(LLMessageSystem* msg, const char* block, S32 block_num = 0);
00164 
00165         const LLUUID& getOwnerID() const { return mOwnerID; }
00166 
00167         // Version handling
00168         enum { VERSION_UNKNOWN = -1, VERSION_INITIAL = 1 };
00169         S32 getVersion() const { return mVersion; }
00170         void setVersion(S32 version) { mVersion = version; }
00171 
00172         // Returns true if a fetch was issued.
00173         bool fetchDescendents();
00174 
00175         // used to help make cacheing more robust - for example, if
00176         // someone is getting 4 packets but logs out after 3. the viewer
00177         // may never know the cache is wrong.
00178         enum { DESCENDENT_COUNT_UNKNOWN = -1 };
00179         S32 getDescendentCount() const { return mDescendentCount; }
00180         void setDescendentCount(S32 descendents) { mDescendentCount = descendents; }
00181 
00182         // file handling on the viewer. These are not meant for anything
00183         // other than cacheing.
00184         bool exportFileLocal(FILE* fp) const;
00185         bool importFileLocal(FILE* fp);
00186 
00187 protected:
00188         LLUUID mOwnerID;
00189         S32 mVersion;
00190         S32 mDescendentCount;
00191         LLFrameTimer mDescendentsRequested;
00192 };
00193 
00194 class LLInventoryCallback : public LLRefCount
00195 {
00196 public:
00197         virtual void fire(const LLUUID& inv_item) = 0;
00198 };
00199 
00200 class WearOnAvatarCallback : public LLInventoryCallback
00201 {
00202         void fire(const LLUUID& inv_item);
00203 };
00204 
00205 class LLViewerJointAttachment;
00206 
00207 class RezAttachmentCallback : public LLInventoryCallback
00208 {
00209 public:
00210         RezAttachmentCallback(LLViewerJointAttachment *attachmentp);
00211         void fire(const LLUUID& inv_item);
00212 
00213 protected:
00214         ~RezAttachmentCallback();
00215 
00216 private:
00217         LLViewerJointAttachment* mAttach;
00218 };
00219 
00220 class ActivateGestureCallback : public LLInventoryCallback
00221 {
00222 public:
00223         void fire(const LLUUID& inv_item);
00224 };
00225 
00226 // misc functions
00227 //void inventory_reliable_callback(void**, S32 status);
00228 
00229 class LLInventoryCallbackManager
00230 {
00231 public:
00232         LLInventoryCallbackManager();
00233         ~LLInventoryCallbackManager();
00234 
00235         void fire(U32 callback_id, const LLUUID& item_id);
00236         U32 registerCB(LLPointer<LLInventoryCallback> cb);
00237 private:
00238         std::map<U32, LLPointer<LLInventoryCallback> > mMap;
00239         U32 mLastCallback;
00240         static LLInventoryCallbackManager *sInstance;
00241 public:
00242         static bool is_instantiated() { return sInstance != NULL; }
00243 };
00244 extern LLInventoryCallbackManager gInventoryCallbacks;
00245 
00246 
00247 #define NOT_WEARABLE (EWearableType)0
00248 
00249 void create_inventory_item(const LLUUID& agent_id, const LLUUID& session_id,
00250                                                    const LLUUID& parent, const LLTransactionID& transaction_id,
00251                                                    const std::string& name,
00252                                                    const std::string& desc, LLAssetType::EType asset_type,
00253                                                    LLInventoryType::EType inv_type, EWearableType wtype,
00254                                                    U32 next_owner_perm,
00255                                                    LLPointer<LLInventoryCallback> cb);
00256 
00260 void copy_inventory_item(
00261         const LLUUID& agent_id,
00262         const LLUUID& current_owner,
00263         const LLUUID& item_id,
00264         const LLUUID& parent_id,
00265         const std::string& new_name,
00266         LLPointer<LLInventoryCallback> cb);
00267 
00268 void move_inventory_item(
00269         const LLUUID& agent_id,
00270         const LLUUID& session_id,
00271         const LLUUID& item_id,
00272         const LLUUID& parent_id,
00273         const std::string& new_name,
00274         LLPointer<LLInventoryCallback> cb);
00275 
00276 void copy_inventory_from_notecard(const LLUUID& object_id,
00277                                                                   const LLUUID& notecard_inv_id,
00278                                                                   const LLInventoryItem *src,
00279                                                                   U32 callback_id = 0);
00280 
00281 
00282 #endif // LL_LLVIEWERINVENTORY_H

Generated on Thu Jul 1 06:09:28 2010 for Second Life Viewer by  doxygen 1.4.7