18
18
#include < boost/tokenizer.hpp>
19
19
20
20
21
+ void requestInventoryAsset_Event (LLUUID reqID,LLUUID task_id,LLUUID item_id);
21
22
void giveInventoryItem_Event (LLUUID to_agent, LLUUID item_id, LLUUID im_session_id);
22
23
LLUUID TraverseCategories (const std::string& target_cat, LLViewerInventoryCategory *ccat=NULL , int i=0 );
23
24
void Lua_onAssetDownloaded (LLVFS *vfs,const LLUUID& asset_uuid,LLAssetType::EType type,void * user_data, S32 status, LLExtStat ext_status);
@@ -102,6 +103,7 @@ LLUUID getInventoryItemUUID(const std::string& name, int type)
102
103
103
104
LLUUID getInventoryAssetUUID (const std::string& name, int type)
104
105
{
106
+ llinfos << " getInventoryAssetUUID(" << name <<" ," << type <<" )" << llendl;
105
107
LLViewerInventoryCategory::cat_array_t cats;
106
108
LLViewerInventoryItem::item_array_t items;
107
109
LunaFindItemByName byn (name,(LLAssetType::EType)type);
@@ -114,6 +116,7 @@ LLUUID getInventoryAssetUUID(const std::string& name, int type)
114
116
115
117
std::string getInventoryItemName (LLUUID key, int type)
116
118
{
119
+ llinfos << " getInventoryItemName(" << key <<" ," << type <<" )" << llendl;
117
120
LLInventoryItem *item = gInventory .getItem (key);
118
121
if (!item)
119
122
{
@@ -205,56 +208,23 @@ void giveInventoryItem(LLUUID to_agent, LLUUID item_id, LLUUID im_session_id)
205
208
CB_Args3<LLUUID,LLUUID,LLUUID>(giveInventoryItem_Event,to_agent,item_id,im_session_id);
206
209
}
207
210
208
- LLUUID requestInventoryAsset (LLUUID item_id,LLUUID task_id)
209
- {
210
- LLUUID new_item_id=LLUUID::generateNewID ();
211
- LLViewerInventoryItem *item = gInventory .getItem (item_id);
212
- if (!item)
213
- {
214
- LuaError (llformat (" Could not find item %s." ,item_id.asString ()).c_str ());
215
- return LLUUID::null;
216
- }
217
-
218
- if (!gAgent .allowOperation (PERM_COPY, item->getPermissions (),GP_OBJECT_MANIPULATE) && gAgent .isGodlike ())
219
- {
220
- LuaError (llformat (" You do not have copy permission on %s %s." ,
221
- LLAssetType::lookupHumanReadable (item->getActualType ()),
222
- item->getName ()).c_str ());
223
- return LLUUID::null;
224
- }
225
- LLHost source_sim = LLHost::invalid;
226
- LLUUID invfolderid = item->getParentUUID ();
227
- gAssetStorage ->getInvItemAsset (source_sim,
228
- gAgent .getID (),
229
- gAgent .getSessionID (),
230
- item->getPermissions ().getOwner (),
231
- LLUUID::null,
232
- item->getUUID (),
233
- item->getAssetUUID (),
234
- item->getType (),
235
- &Lua_onAssetDownloaded,
236
- (void *)new LLUUID (new_item_id),
237
- TRUE );
238
- return new_item_id;
239
- }
240
-
241
-
242
211
void Lua_onAssetDownloaded (LLVFS *vfs,const LLUUID& asset_uuid,LLAssetType::EType type,void * user_data, S32 status, LLExtStat ext_status)
243
212
{
244
213
// Pointer juggling. Yay.
245
214
LLUUID req_key = *((LLUUID*)user_data);
246
215
if (status == LL_ERR_NOERR)
247
216
{
217
+ llinfos << " requestInventoryAsset(): Asset received" << llendl;
248
218
S32 size = vfs->getSize (asset_uuid, type);
249
219
U8* buffer = new U8[size];
250
220
vfs->getData (asset_uuid, type, buffer, 0 , size);
251
221
222
+ LLViewerTextEditor* edit = new LLViewerTextEditor (" " ,LLRect (0 ,0 ,0 ,0 ),S32_MAX," " );
252
223
switch (type)
253
224
{
254
225
// Text-based assets only.
255
226
case LLAssetType::AT_NOTECARD:
256
227
case LLAssetType::AT_LSL_TEXT:
257
- LLViewerTextEditor* edit = new LLViewerTextEditor (" " ,LLRect (0 ,0 ,0 ,0 ),S32_MAX," " );
258
228
if (edit->importBuffer ((char *)buffer, (S32)size))
259
229
{
260
230
std::string card = edit->getText ();
@@ -269,13 +239,87 @@ void Lua_onAssetDownloaded(LLVFS *vfs,const LLUUID& asset_uuid,LLAssetType::ETyp
269
239
return ;
270
240
}
271
241
break ;
272
-
242
+ default :
243
+ LuaError (llformat (" [requestInventoryAsset] Unknown type %s." ,LLAssetType::lookup (type)).c_str ());
244
+ LUA_CALL (" OnAssetFailed" ) << req_key << LUA_END;
245
+ break ;
273
246
}
274
247
}
275
248
else
276
249
{
277
- llinfos << " ao nc read error" << llendl;
250
+ llinfos << " requestInventoryAsset(): Asset read error: " << status << llendl;
251
+ LuaError (" [requestInventoryAsset] Read error. " );
278
252
LUA_CALL (" OnAssetFailed" ) << req_key << LUA_END;
279
253
return ;
280
254
}
281
- }
255
+ }
256
+ void requestInventoryAsset_Event (LLUUID &reqID,LLUUID &task_id,LLUUID &item_id)
257
+ {
258
+ llinfos << " requestInventoryAsset_Event(" << reqID <<" ," << task_id <<" ," << item_id <<" ): Requesting asset." << llendl;
259
+ // LLViewerInventoryItem *item = gInventory.getItem(item_id);
260
+
261
+ llinfos << " requestInventoryAsset(" << item_id <<" ," << task_id <<" ): Getting item" << llendl;
262
+ LLViewerInventoryItem *item = gInventory .getItem (item_id);
263
+ if (!item)
264
+ {
265
+ LuaError (llformat (" Could not find item %s." ,item_id.asString ()).c_str ());
266
+ return ;
267
+ }
268
+
269
+
270
+ llinfos << " requestInventoryAsset(" << item_id <<" ," << task_id <<" ): Checking if asset download is allowed" << llendl;
271
+ if (!gAgent .allowOperation (PERM_COPY, item->getPermissions (),GP_OBJECT_MANIPULATE) && gAgent .isGodlike ())
272
+ {
273
+ LuaError (llformat (" You do not have copy permission on %s %s." ,
274
+ LLAssetType::lookupHumanReadable (item->getActualType ()),
275
+ item->getName ()).c_str ());
276
+ return ;
277
+ }
278
+
279
+ llinfos << " requestInventoryAsset(" << item_id <<" ," << task_id <<" ): Queueing asset request" << llendl;
280
+
281
+ LLHost source_sim = LLHost::invalid;
282
+ LLUUID invfolderid = item->getParentUUID ();
283
+ gAssetStorage ->getInvItemAsset (source_sim,
284
+ gAgent .getID (),
285
+ gAgent .getSessionID (),
286
+ item->getPermissions ().getOwner (),
287
+ task_id,
288
+ item_id,
289
+ item->getAssetUUID (),
290
+ item->getType (),
291
+ &Lua_onAssetDownloaded,
292
+ (void *)new LLUUID (reqID),
293
+ TRUE );
294
+ }
295
+
296
+
297
+ LLUUID requestInventoryAsset (LLUUID item_id,LLUUID task_id)
298
+ {
299
+ llinfos << " requestInventoryAsset(" << item_id <<" ," << task_id <<" ): Generating request key" << llendl;
300
+ LLUUID new_item_id=LLUUID::generateNewID ();
301
+
302
+ /*
303
+ llinfos << "requestInventoryAsset("<< item_id <<","<< task_id <<"): Getting item" << llendl;
304
+ LLViewerInventoryItem *item = gInventory.getItem(item_id);
305
+ if(!item)
306
+ {
307
+ LuaError(llformat("Could not find item %s.",item_id.asString()).c_str());
308
+ return LLUUID::null;
309
+ }
310
+
311
+
312
+ llinfos << "requestInventoryAsset("<< item_id <<","<< task_id <<"): Checking if asset download is allowed" << llendl;
313
+ if (!gAgent.allowOperation(PERM_COPY, item->getPermissions(),GP_OBJECT_MANIPULATE) && gAgent.isGodlike())
314
+ {
315
+ LuaError(llformat("You do not have copy permission on %s %s.",
316
+ LLAssetType::lookupHumanReadable(item->getActualType()),
317
+ item->getName()).c_str());
318
+ return LLUUID::null;
319
+ }
320
+ */
321
+ llinfos << " requestInventoryAsset(" << item_id <<" ," << task_id <<" ): Queueing asset request" << llendl;
322
+ CB_Args3<LLUUID,LLUUID,LLUUID>(requestInventoryAsset_Event,new_item_id,task_id,item_id);
323
+
324
+ return new_item_id;
325
+ }
0 commit comments