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
00041
00042
00043
00044
00045
00046 class LLViewerInventoryItem : public LLInventoryItem
00047 {
00048 public:
00049 typedef LLDynamicArray<LLPointer<LLViewerInventoryItem> > item_array_t;
00050
00051 protected:
00052 ~LLViewerInventoryItem( void );
00053
00054 public:
00055
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
00068
00069 LLViewerInventoryItem(
00070 const LLUUID& item_id,
00071 const LLUUID& parent_id,
00072 const char* name,
00073 LLInventoryType::EType inv_type);
00074
00075
00076
00077
00078
00079 LLViewerInventoryItem();
00080
00081
00082
00083 LLViewerInventoryItem(const LLViewerInventoryItem* other);
00084 LLViewerInventoryItem(const LLInventoryItem* other);
00085
00086 void copyViewerItem(const LLViewerInventoryItem* other);
00087 void copyItem(const LLInventoryItem* other);
00088
00089
00090
00091
00092 void cloneViewerItem(LLPointer<LLViewerInventoryItem>& newitem) const;
00093
00094
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
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
00107
00108 bool exportFileLocal(LLFILE* fp) const;
00109 bool importFileLocal(LLFILE* fp);
00110
00111
00112 BOOL isComplete() const { return mIsComplete; }
00113 void setComplete(BOOL complete) { mIsComplete = complete; }
00114
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
00135
00136
00137
00138
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
00156
00157
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
00165
00166 const LLUUID& getOwnerID() const { return mOwnerID; }
00167
00168
00169 enum { VERSION_UNKNOWN = -1, VERSION_INITIAL = 1 };
00170 S32 getVersion() const { return mVersion; }
00171 void setVersion(S32 version) { mVersion = version; }
00172
00173
00174 bool fetchDescendents();
00175
00176
00177
00178
00179 enum { DESCENDENT_COUNT_UNKNOWN = -1 };
00180 S32 getDescendentCount() const { return mDescendentCount; }
00181 void setDescendentCount(S32 descendents) { mDescendentCount = descendents; }
00182
00183
00184
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
00234
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