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 virtual void copy(const LLViewerInventoryItem* other);
00087 virtual void copy(const LLInventoryItem* other);
00088
00089
00090
00091
00092 virtual void clone(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 importFile(FILE* fp);
00103 virtual BOOL importLegacyStream(std::istream& input_stream);
00104
00105
00106
00107 bool exportFileLocal(FILE* fp) const;
00108 bool importFileLocal(FILE* fp);
00109
00110
00111 BOOL isComplete() const { return mIsComplete; }
00112 void setComplete(BOOL complete) { mIsComplete = complete; }
00113
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
00134
00135
00136
00137
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
00155
00156
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
00164
00165 const LLUUID& getOwnerID() const { return mOwnerID; }
00166
00167
00168 enum { VERSION_UNKNOWN = -1, VERSION_INITIAL = 1 };
00169 S32 getVersion() const { return mVersion; }
00170 void setVersion(S32 version) { mVersion = version; }
00171
00172
00173 bool fetchDescendents();
00174
00175
00176
00177
00178 enum { DESCENDENT_COUNT_UNKNOWN = -1 };
00179 S32 getDescendentCount() const { return mDescendentCount; }
00180 void setDescendentCount(S32 descendents) { mDescendentCount = descendents; }
00181
00182
00183
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
00227
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