diff options
Diffstat (limited to 'linden/indra/llmessage/llassetstorage.h')
-rw-r--r-- | linden/indra/llmessage/llassetstorage.h | 371 |
1 files changed, 371 insertions, 0 deletions
diff --git a/linden/indra/llmessage/llassetstorage.h b/linden/indra/llmessage/llassetstorage.h new file mode 100644 index 0000000..deccad3 --- /dev/null +++ b/linden/indra/llmessage/llassetstorage.h | |||
@@ -0,0 +1,371 @@ | |||
1 | /** | ||
2 | * @file llassetstorage.h | ||
3 | * @brief definition of LLAssetStorage class which allows simple | ||
4 | * up/downloads of uuid,type asets | ||
5 | * | ||
6 | * Copyright (c) 2001-2007, Linden Research, Inc. | ||
7 | * | ||
8 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
9 | * to you under the terms of the GNU General Public License, version 2.0 | ||
10 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
11 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
12 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
13 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
14 | * | ||
15 | * There are special exceptions to the terms and conditions of the GPL as | ||
16 | * it is applied to this Source Code. View the full text of the exception | ||
17 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
18 | * online at http://secondlife.com/developers/opensource/flossexception | ||
19 | * | ||
20 | * By copying, modifying or distributing this software, you acknowledge | ||
21 | * that you have read and understood your obligations described above, | ||
22 | * and agree to abide by those obligations. | ||
23 | * | ||
24 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
25 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
26 | * COMPLETENESS OR PERFORMANCE. | ||
27 | */ | ||
28 | |||
29 | #ifndef LL_LLASSETSTORAGE_H | ||
30 | #define LL_LLASSETSTORAGE_H | ||
31 | |||
32 | #include <string> | ||
33 | |||
34 | #include "lluuid.h" | ||
35 | #include "lltimer.h" | ||
36 | #include "llnamevalue.h" | ||
37 | #include "llhost.h" | ||
38 | #include "stdenums.h" // for EDragAndDropType | ||
39 | #include "lltransfermanager.h" // For LLTSCode enum | ||
40 | #include "llassettype.h" | ||
41 | #include "llstring.h" | ||
42 | |||
43 | // Forward declarations | ||
44 | class LLMessageSystem; | ||
45 | class LLXferManager; | ||
46 | class LLAssetStorage; | ||
47 | class LLVFS; | ||
48 | class LLSD; | ||
49 | |||
50 | class LLAssetInfo | ||
51 | { | ||
52 | protected: | ||
53 | std::string mDescription; | ||
54 | std::string mName; | ||
55 | |||
56 | public: | ||
57 | LLUUID mUuid; | ||
58 | LLTransactionID mTransactionID; | ||
59 | LLUUID mCreatorID; | ||
60 | LLAssetType::EType mType; | ||
61 | |||
62 | LLAssetInfo( void ); | ||
63 | LLAssetInfo( const LLUUID& object_id, const LLUUID& creator_id, | ||
64 | LLAssetType::EType type, const char* name, const char* desc ); | ||
65 | LLAssetInfo( const LLNameValue& nv ); | ||
66 | |||
67 | const std::string& getName( void ) const { return mName; } | ||
68 | const std::string& getDescription( void ) const { return mDescription; } | ||
69 | void setName( const std::string& name ); | ||
70 | void setDescription( const std::string& desc ); | ||
71 | |||
72 | // Assets (aka potential inventory items) can be applied to an | ||
73 | // object in the world. We'll store that as a string name value | ||
74 | // pair where the name encodes part of asset info, and the value | ||
75 | // the rest. LLAssetInfo objects will be responsible for parsing | ||
76 | // the meaning out froman LLNameValue object. See the inventory | ||
77 | // design docs for details. | ||
78 | void setFromNameValue( const LLNameValue& nv ); | ||
79 | }; | ||
80 | |||
81 | |||
82 | class LLAssetRequest | ||
83 | { | ||
84 | public: | ||
85 | LLAssetRequest(const LLUUID &uuid, const LLAssetType::EType at); | ||
86 | virtual ~LLAssetRequest(); | ||
87 | |||
88 | LLUUID getUUID() const { return mUUID; } | ||
89 | LLAssetType::EType getType() const { return mType; } | ||
90 | |||
91 | void setUUID(const LLUUID& id) { mUUID = id; } | ||
92 | void setType(LLAssetType::EType type) { mType = type; } | ||
93 | |||
94 | protected: | ||
95 | LLUUID mUUID; | ||
96 | LLAssetType::EType mType; | ||
97 | |||
98 | public: | ||
99 | void (*mDownCallback)(LLVFS*, const LLUUID&, LLAssetType::EType, void *, S32); | ||
100 | void (*mUpCallback)(const LLUUID&, void *, S32); | ||
101 | void (*mInfoCallback)(LLAssetInfo *, void *, S32); | ||
102 | |||
103 | void *mUserData; | ||
104 | LLHost mHost; | ||
105 | BOOL mIsTemp; | ||
106 | BOOL mIsLocal; | ||
107 | F64 mTime; // Message system time | ||
108 | BOOL mIsPriority; | ||
109 | BOOL mDataSentInFirstPacket; | ||
110 | BOOL mDataIsInVFS; | ||
111 | LLUUID mRequestingAgentID; // Only valid for uploads from an agent | ||
112 | }; | ||
113 | |||
114 | |||
115 | class LLInvItemRequest | ||
116 | { | ||
117 | public: | ||
118 | LLInvItemRequest(const LLUUID &uuid, const LLAssetType::EType at); | ||
119 | virtual ~LLInvItemRequest(); | ||
120 | |||
121 | LLUUID getUUID() const { return mUUID; } | ||
122 | LLAssetType::EType getType() const { return mType; } | ||
123 | |||
124 | void setUUID(const LLUUID& id) { mUUID = id; } | ||
125 | void setType(LLAssetType::EType type) { mType = type; } | ||
126 | |||
127 | protected: | ||
128 | LLUUID mUUID; | ||
129 | LLAssetType::EType mType; | ||
130 | |||
131 | public: | ||
132 | void (*mDownCallback)(LLVFS*, const LLUUID&, LLAssetType::EType, void *, S32); | ||
133 | |||
134 | void *mUserData; | ||
135 | LLHost mHost; | ||
136 | BOOL mIsTemp; | ||
137 | F64 mTime; // Message system time | ||
138 | BOOL mIsPriority; | ||
139 | BOOL mDataSentInFirstPacket; | ||
140 | BOOL mDataIsInVFS; | ||
141 | |||
142 | }; | ||
143 | |||
144 | class LLEstateAssetRequest | ||
145 | { | ||
146 | public: | ||
147 | LLEstateAssetRequest(const LLUUID &uuid, const LLAssetType::EType at, EstateAssetType et); | ||
148 | virtual ~LLEstateAssetRequest(); | ||
149 | |||
150 | LLUUID getUUID() const { return mUUID; } | ||
151 | LLAssetType::EType getAType() const { return mAType; } | ||
152 | |||
153 | void setUUID(const LLUUID& id) { mUUID = id; } | ||
154 | void setType(LLAssetType::EType type) { mAType = type; } | ||
155 | |||
156 | protected: | ||
157 | LLUUID mUUID; | ||
158 | LLAssetType::EType mAType; | ||
159 | EstateAssetType mEstateAssetType; | ||
160 | |||
161 | public: | ||
162 | void (*mDownCallback)(LLVFS*, const LLUUID&, LLAssetType::EType, void *, S32); | ||
163 | |||
164 | void *mUserData; | ||
165 | LLHost mHost; | ||
166 | BOOL mIsTemp; | ||
167 | F64 mTime; // Message system time | ||
168 | BOOL mIsPriority; | ||
169 | BOOL mDataSentInFirstPacket; | ||
170 | BOOL mDataIsInVFS; | ||
171 | |||
172 | }; | ||
173 | |||
174 | |||
175 | |||
176 | |||
177 | typedef void (*LLGetAssetCallback)(LLVFS *vfs, const LLUUID &asset_id, | ||
178 | LLAssetType::EType asset_type, void *user_data, S32 status); | ||
179 | |||
180 | class LLAssetStorage | ||
181 | { | ||
182 | public: | ||
183 | // VFS member is public because static child methods need it :( | ||
184 | LLVFS *mVFS; | ||
185 | typedef void (*LLStoreAssetCallback)(const LLUUID &asset_id, void *user_data, S32 status); | ||
186 | |||
187 | protected: | ||
188 | BOOL mShutDown; | ||
189 | LLHost mUpstreamHost; | ||
190 | |||
191 | LLMessageSystem *mMessageSys; | ||
192 | LLXferManager *mXferManager; | ||
193 | |||
194 | std::list<LLAssetRequest*> mPendingDownloads; | ||
195 | std::list<LLAssetRequest*> mPendingUploads; | ||
196 | std::list<LLAssetRequest*> mPendingLocalUploads; | ||
197 | |||
198 | public: | ||
199 | LLAssetStorage(LLMessageSystem *msg, LLXferManager *xfer, | ||
200 | LLVFS *vfs, const LLHost &upstream_host); | ||
201 | |||
202 | LLAssetStorage(LLMessageSystem *msg, LLXferManager *xfer, | ||
203 | LLVFS *vfs); | ||
204 | virtual ~LLAssetStorage(); | ||
205 | |||
206 | void setUpstream(const LLHost &upstream_host); | ||
207 | |||
208 | virtual BOOL hasLocalAsset(const LLUUID &uuid, LLAssetType::EType type); | ||
209 | |||
210 | // public interface methods | ||
211 | // note that your callback may get called BEFORE the function returns | ||
212 | |||
213 | virtual void getAssetData(const LLUUID uuid, LLAssetType::EType atype, LLGetAssetCallback cb, void *user_data, BOOL is_priority = FALSE); | ||
214 | |||
215 | /* | ||
216 | * TransactionID version | ||
217 | * Viewer needs the store_local | ||
218 | */ | ||
219 | virtual void storeAssetData( | ||
220 | const LLTransactionID& tid, | ||
221 | LLAssetType::EType atype, | ||
222 | LLStoreAssetCallback callback, | ||
223 | void* user_data, | ||
224 | bool temp_file = false, | ||
225 | bool is_priority = false, | ||
226 | bool store_local = false); | ||
227 | |||
228 | /* | ||
229 | * AssetID version | ||
230 | * Sim needs both store_local and requesting_agent_id. | ||
231 | */ | ||
232 | virtual void storeAssetData( | ||
233 | const LLUUID& asset_id, | ||
234 | LLAssetType::EType asset_type, | ||
235 | LLStoreAssetCallback callback, | ||
236 | void* user_data, | ||
237 | bool temp_file = false, | ||
238 | bool is_priority = false, | ||
239 | bool store_local = false, | ||
240 | const LLUUID& requesting_agent_id = LLUUID::null); | ||
241 | |||
242 | // This call will attempt to clear a store asset. This will only | ||
243 | // attempt to cancel an upload that has not yet begun. The | ||
244 | // callback will be called with an error code. | ||
245 | virtual void cancelStoreAsset( | ||
246 | const LLUUID& uuid, | ||
247 | LLAssetType::EType oatype); | ||
248 | |||
249 | virtual void checkForTimeouts(); | ||
250 | |||
251 | void getEstateAsset(const LLHost &object_sim, const LLUUID &agent_id, const LLUUID &session_id, | ||
252 | const LLUUID &asset_id, LLAssetType::EType atype, EstateAssetType etype, | ||
253 | LLGetAssetCallback callback, void *user_data, BOOL is_priority); | ||
254 | |||
255 | void getInvItemAsset(const LLHost &object_sim, | ||
256 | const LLUUID &agent_id, const LLUUID &session_id, | ||
257 | const LLUUID &owner_id, const LLUUID &task_id, const LLUUID &item_id, | ||
258 | const LLUUID &asset_id, LLAssetType::EType atype, | ||
259 | LLGetAssetCallback cb, void *user_data, BOOL is_priority = FALSE); // Get a particular inventory item. | ||
260 | |||
261 | |||
262 | S32 getNumPendingDownloads() const; | ||
263 | S32 getNumPendingUploads() const; | ||
264 | S32 getNumPendingLocalUploads(); | ||
265 | |||
266 | // Returns a map from type to num pending, eg 'texture' => 5, 'object' => 10 | ||
267 | LLSD getPendingDownloadTypes() const; | ||
268 | LLSD getPendingUploadTypes() const; | ||
269 | |||
270 | // download process callbacks | ||
271 | static void downloadCompleteCallback( | ||
272 | S32 result, | ||
273 | const LLUUID& file_id, | ||
274 | LLAssetType::EType file_type, | ||
275 | void* user_data); | ||
276 | static void downloadEstateAssetCompleteCallback( | ||
277 | S32 result, | ||
278 | const LLUUID& file_id, | ||
279 | LLAssetType::EType file_type, | ||
280 | void* user_data); | ||
281 | static void downloadInvItemCompleteCallback( | ||
282 | S32 result, | ||
283 | const LLUUID& file_id, | ||
284 | LLAssetType::EType file_type, | ||
285 | void* user_data); | ||
286 | |||
287 | // upload process callbacks | ||
288 | static void uploadCompleteCallback(const LLUUID&, void *user_data, S32 result); | ||
289 | static void processUploadComplete(LLMessageSystem *msg, void **this_handle); | ||
290 | |||
291 | // debugging | ||
292 | static const char* getErrorString( S32 status ); | ||
293 | |||
294 | // deprecated file-based methods | ||
295 | void getAssetData(const LLUUID uuid, LLAssetType::EType type, void (*callback)(const char*, const LLUUID&, void *, S32), void *user_data, BOOL is_priority = FALSE); | ||
296 | |||
297 | /* | ||
298 | * AssetID version. | ||
299 | */ | ||
300 | virtual void storeAssetData( | ||
301 | const char* filename, | ||
302 | const LLUUID& asset_id, | ||
303 | LLAssetType::EType type, | ||
304 | LLStoreAssetCallback callback, | ||
305 | void* user_data, | ||
306 | bool temp_file = false, | ||
307 | bool is_priority = false); | ||
308 | |||
309 | /* | ||
310 | * TransactionID version | ||
311 | */ | ||
312 | virtual void storeAssetData( | ||
313 | const char * filename, | ||
314 | const LLTransactionID &transaction_id, | ||
315 | LLAssetType::EType type, | ||
316 | LLStoreAssetCallback callback, | ||
317 | void *user_data, | ||
318 | bool temp_file = false, | ||
319 | bool is_priority = false); | ||
320 | |||
321 | static void legacyGetDataCallback(LLVFS *vfs, const LLUUID &uuid, LLAssetType::EType, void *user_data, S32 status); | ||
322 | static void legacyStoreDataCallback(const LLUUID &uuid, void *user_data, S32 status); | ||
323 | |||
324 | // Temp assets are stored on sim nodes, they have agent ID and location data associated with them. | ||
325 | // This is a no-op for non-http asset systems | ||
326 | virtual void addTempAssetData(const LLUUID& asset_id, const LLUUID& agent_id, const std::string& host_name); | ||
327 | virtual BOOL hasTempAssetData(const LLUUID& texture_id) const; | ||
328 | virtual std::string getTempAssetHostName(const LLUUID& texture_id) const; | ||
329 | virtual LLUUID getTempAssetAgentID(const LLUUID& texture_id) const; | ||
330 | virtual void removeTempAssetData(const LLUUID& asset_id); | ||
331 | virtual void removeTempAssetDataByAgentID(const LLUUID& agent_id); | ||
332 | // Pass LLUUID::null for all | ||
333 | virtual void dumpTempAssetData(const LLUUID& avatar_id) const; | ||
334 | virtual void clearTempAssetData(); | ||
335 | |||
336 | // add extra methods to handle metadata | ||
337 | |||
338 | protected: | ||
339 | void _cleanupRequests(BOOL all, S32 error); | ||
340 | void _callUploadCallbacks(const LLUUID &uuid, const LLAssetType::EType asset_type, BOOL success); | ||
341 | |||
342 | virtual void _queueDataRequest(const LLUUID& uuid, LLAssetType::EType type, | ||
343 | void (*callback)(LLVFS *vfs, const LLUUID&, LLAssetType::EType, void *, S32), | ||
344 | void *user_data, BOOL duplicate, | ||
345 | BOOL is_priority); | ||
346 | |||
347 | private: | ||
348 | void _init(LLMessageSystem *msg, | ||
349 | LLXferManager *xfer, | ||
350 | LLVFS *vfs, | ||
351 | const LLHost &upstream_host); | ||
352 | LLSD getPendingTypes(const std::list<LLAssetRequest*>& requests) const; | ||
353 | |||
354 | }; | ||
355 | |||
356 | //////////////////////////////////////////////////////////////////////// | ||
357 | // Wrappers to replicate deprecated API | ||
358 | //////////////////////////////////////////////////////////////////////// | ||
359 | |||
360 | class LLLegacyAssetRequest | ||
361 | { | ||
362 | public: | ||
363 | void (*mDownCallback)(const char *, const LLUUID&, void *, S32); | ||
364 | LLAssetStorage::LLStoreAssetCallback mUpCallback; | ||
365 | |||
366 | void *mUserData; | ||
367 | }; | ||
368 | |||
369 | extern LLAssetStorage *gAssetStorage; | ||
370 | extern const LLUUID CATEGORIZE_LOST_AND_FOUND_ID; | ||
371 | #endif | ||