diff options
Diffstat (limited to 'linden/indra/newview/llcompilequeue.cpp')
-rw-r--r-- | linden/indra/newview/llcompilequeue.cpp | 321 |
1 files changed, 190 insertions, 131 deletions
diff --git a/linden/indra/newview/llcompilequeue.cpp b/linden/indra/newview/llcompilequeue.cpp index 45d8e1c..fc2742f 100644 --- a/linden/indra/newview/llcompilequeue.cpp +++ b/linden/indra/newview/llcompilequeue.cpp | |||
@@ -42,6 +42,8 @@ | |||
42 | #include "llcompilequeue.h" | 42 | #include "llcompilequeue.h" |
43 | 43 | ||
44 | #include "llagent.h" | 44 | #include "llagent.h" |
45 | #include "llassetuploadqueue.h" | ||
46 | #include "llassetuploadresponders.h" | ||
45 | #include "llchat.h" | 47 | #include "llchat.h" |
46 | #include "llviewerwindow.h" | 48 | #include "llviewerwindow.h" |
47 | #include "llviewerobject.h" | 49 | #include "llviewerobject.h" |
@@ -63,29 +65,24 @@ | |||
63 | ///---------------------------------------------------------------------------- | 65 | ///---------------------------------------------------------------------------- |
64 | 66 | ||
65 | // *TODO:Translate | 67 | // *TODO:Translate |
66 | const char* COMPILE_QUEUE_TITLE = "Recompilation Progress"; | 68 | const std::string COMPILE_QUEUE_TITLE("Recompilation Progress"); |
67 | const char* COMPILE_START_STRING = "recompile"; | 69 | const std::string COMPILE_START_STRING("recompile"); |
68 | const char* RESET_QUEUE_TITLE = "Reset Progress"; | 70 | const std::string RESET_QUEUE_TITLE("Reset Progress"); |
69 | const char* RESET_START_STRING = "reset"; | 71 | const std::string RESET_START_STRING("reset"); |
70 | const char* RUN_QUEUE_TITLE = "Set Running Progress"; | 72 | const std::string RUN_QUEUE_TITLE("Set Running Progress"); |
71 | const char* RUN_START_STRING = "set running"; | 73 | const std::string RUN_START_STRING("set running"); |
72 | const char* NOT_RUN_QUEUE_TITLE = "Set Not Running Progress"; | 74 | const std::string NOT_RUN_QUEUE_TITLE("Set Not Running Progress"); |
73 | const char* NOT_RUN_START_STRING = "set not running"; | 75 | const std::string NOT_RUN_START_STRING("set not running"); |
74 | |||
75 | struct LLCompileQueueData | ||
76 | { | ||
77 | LLUUID mQueueID; | ||
78 | LLUUID mOldAssetID; | ||
79 | LLCompileQueueData(const LLUUID& q_id, const LLUUID& old_asset_id) : | ||
80 | mQueueID(q_id), mOldAssetID(old_asset_id) {} | ||
81 | }; | ||
82 | 76 | ||
83 | struct LLScriptQueueData | 77 | struct LLScriptQueueData |
84 | { | 78 | { |
85 | LLUUID mQueueID; | 79 | LLUUID mQueueID; |
86 | LLString mScriptName; | 80 | std::string mScriptName; |
87 | LLScriptQueueData(const LLUUID& q_id, const char* name) : | 81 | LLUUID mTaskId; |
88 | mQueueID(q_id), mScriptName(name) {} | 82 | LLUUID mItemId; |
83 | LLScriptQueueData(const LLUUID& q_id, const std::string& name, const LLUUID& task_id, const LLUUID& item_id) : | ||
84 | mQueueID(q_id), mScriptName(name), mTaskId(task_id), mItemId(item_id) {} | ||
85 | |||
89 | }; | 86 | }; |
90 | 87 | ||
91 | ///---------------------------------------------------------------------------- | 88 | ///---------------------------------------------------------------------------- |
@@ -98,14 +95,15 @@ LLMap<LLUUID, LLFloaterScriptQueue*> LLFloaterScriptQueue::sInstances; | |||
98 | 95 | ||
99 | // Default constructor | 96 | // Default constructor |
100 | LLFloaterScriptQueue::LLFloaterScriptQueue(const std::string& name, | 97 | LLFloaterScriptQueue::LLFloaterScriptQueue(const std::string& name, |
101 | const LLRect& rect, | 98 | const LLRect& rect, |
102 | const char* title, | 99 | const std::string& title, |
103 | const char* start_string) : | 100 | const std::string& start_string) : |
104 | LLFloater(name, rect, title, | 101 | LLFloater(name, rect, title, |
105 | RESIZE_YES, DEFAULT_MIN_WIDTH, DEFAULT_MIN_HEIGHT, | 102 | RESIZE_YES, DEFAULT_MIN_WIDTH, DEFAULT_MIN_HEIGHT, |
106 | DRAG_ON_TOP, MINIMIZE_YES, CLOSE_YES) | 103 | DRAG_ON_TOP, MINIMIZE_YES, CLOSE_YES) |
107 | { | 104 | { |
108 | 105 | mID.generate(); | |
106 | |||
109 | LLUICtrlFactory::getInstance()->buildFloater(this,"floater_script_queue.xml"); | 107 | LLUICtrlFactory::getInstance()->buildFloater(this,"floater_script_queue.xml"); |
110 | 108 | ||
111 | childSetAction("close",onCloseBtn,this); | 109 | childSetAction("close",onCloseBtn,this); |
@@ -113,11 +111,8 @@ LLFloaterScriptQueue::LLFloaterScriptQueue(const std::string& name, | |||
113 | 111 | ||
114 | setTitle(title); | 112 | setTitle(title); |
115 | 113 | ||
116 | if (!getHost()) | 114 | LLRect curRect = getRect(); |
117 | { | 115 | translate(rect.mLeft - curRect.mLeft, rect.mTop - curRect.mTop); |
118 | LLRect curRect = getRect(); | ||
119 | translate(rect.mLeft - curRect.mLeft, rect.mTop - curRect.mTop); | ||
120 | } | ||
121 | 116 | ||
122 | mStartString = start_string; | 117 | mStartString = start_string; |
123 | mDone = FALSE; | 118 | mDone = FALSE; |
@@ -198,8 +193,8 @@ void LLFloaterScriptQueue::addObject(const LLUUID& id) | |||
198 | BOOL LLFloaterScriptQueue::start() | 193 | BOOL LLFloaterScriptQueue::start() |
199 | { | 194 | { |
200 | //llinfos << "LLFloaterCompileQueue::start()" << llendl; | 195 | //llinfos << "LLFloaterCompileQueue::start()" << llendl; |
201 | char buffer[MAX_STRING]; /*Flawfinder: ignore*/ | 196 | std::string buffer; |
202 | snprintf(buffer, sizeof(buffer), "Starting %s of %d items.", mStartString, mObjectIDs.count()); /* Flawfinder: ignore */ | 197 | buffer = llformat("Starting %s of %d items.", mStartString.c_str(), mObjectIDs.count()); // *TODO: Translate |
203 | 198 | ||
204 | LLScrollListCtrl* list = getChild<LLScrollListCtrl>("queue output"); | 199 | LLScrollListCtrl* list = getChild<LLScrollListCtrl>("queue output"); |
205 | list->addCommentText(buffer); | 200 | list->addCommentText(buffer); |
@@ -238,8 +233,7 @@ BOOL LLFloaterScriptQueue::nextObject() | |||
238 | LLScrollListCtrl* list = getChild<LLScrollListCtrl>("queue output"); | 233 | LLScrollListCtrl* list = getChild<LLScrollListCtrl>("queue output"); |
239 | 234 | ||
240 | mDone = TRUE; | 235 | mDone = TRUE; |
241 | char buffer[MAX_STRING]; /*Flawfinder: ignore*/ | 236 | std::string buffer = "Done."; // *TODO: Translate |
242 | snprintf(buffer, sizeof(buffer), "Done."); /* Flawfinder: ignore */ | ||
243 | list->addCommentText(buffer); | 237 | list->addCommentText(buffer); |
244 | childSetEnabled("close",TRUE); | 238 | childSetEnabled("close",TRUE); |
245 | } | 239 | } |
@@ -280,15 +274,57 @@ BOOL LLFloaterScriptQueue::popNext() | |||
280 | ///---------------------------------------------------------------------------- | 274 | ///---------------------------------------------------------------------------- |
281 | 275 | ||
282 | // static | 276 | // static |
283 | LLFloaterCompileQueue* LLFloaterCompileQueue::create() | 277 | LLFloaterCompileQueue* LLFloaterCompileQueue::create(BOOL mono) |
284 | { | 278 | { |
285 | S32 left, top; | 279 | S32 left, top; |
286 | gFloaterView->getNewFloaterPosition(&left, &top); | 280 | gFloaterView->getNewFloaterPosition(&left, &top); |
287 | LLRect rect = gSavedSettings.getRect("CompileOutputRect"); | 281 | LLRect rect = gSavedSettings.getRect("CompileOutputRect"); |
288 | rect.translate(left - rect.mLeft, top - rect.mTop); | 282 | rect.translate(left - rect.mLeft, top - rect.mTop); |
289 | LLFloaterCompileQueue* new_queue = new LLFloaterCompileQueue("queue", | 283 | LLFloaterCompileQueue* new_queue = new LLFloaterCompileQueue("queue", rect); |
290 | rect); | 284 | |
291 | new_queue->open(); /*Flawfinder: ignore*/ | 285 | class LLCompileFloaterUploadQueueSupplier : public LLAssetUploadQueueSupplier |
286 | { | ||
287 | public: | ||
288 | |||
289 | LLCompileFloaterUploadQueueSupplier(const LLUUID& queue_id) : | ||
290 | mQueueId(queue_id) | ||
291 | { | ||
292 | } | ||
293 | |||
294 | virtual LLAssetUploadQueue* get() const | ||
295 | { | ||
296 | LLFloaterCompileQueue* queue = | ||
297 | (LLFloaterCompileQueue*) LLFloaterScriptQueue::findInstance(mQueueId); | ||
298 | |||
299 | if(NULL == queue) | ||
300 | { | ||
301 | return NULL; | ||
302 | } | ||
303 | |||
304 | return queue->mUploadQueue; | ||
305 | } | ||
306 | |||
307 | virtual void log(std::string message) const | ||
308 | { | ||
309 | LLFloaterCompileQueue* queue = | ||
310 | (LLFloaterCompileQueue*) LLFloaterScriptQueue::findInstance(mQueueId); | ||
311 | |||
312 | if(NULL == queue) | ||
313 | { | ||
314 | return; | ||
315 | } | ||
316 | |||
317 | LLScrollListCtrl* list = queue->getChild<LLScrollListCtrl>("queue output"); | ||
318 | list->addCommentText(message.c_str()); | ||
319 | } | ||
320 | |||
321 | private: | ||
322 | LLUUID mQueueId; | ||
323 | }; | ||
324 | |||
325 | new_queue->mUploadQueue = new LLAssetUploadQueue(new LLCompileFloaterUploadQueueSupplier(new_queue->getID())); | ||
326 | new_queue->mMono = mono; | ||
327 | new_queue->open(); | ||
292 | return new_queue; | 328 | return new_queue; |
293 | } | 329 | } |
294 | 330 | ||
@@ -306,7 +342,7 @@ void LLFloaterCompileQueue::handleInventory(LLViewerObject *viewer_object, | |||
306 | // find all of the lsl, leaving off duplicates. We'll remove | 342 | // find all of the lsl, leaving off duplicates. We'll remove |
307 | // all matching asset uuids on compilation success. | 343 | // all matching asset uuids on compilation success. |
308 | 344 | ||
309 | typedef std::map<LLUUID, LLPointer<LLInventoryItem> > uuid_item_map; | 345 | typedef std::multimap<LLUUID, LLPointer<LLInventoryItem> > uuid_item_map; |
310 | uuid_item_map asset_item_map; | 346 | uuid_item_map asset_item_map; |
311 | 347 | ||
312 | InventoryObjectList::const_iterator it = inv->begin(); | 348 | InventoryObjectList::const_iterator it = inv->begin(); |
@@ -317,17 +353,12 @@ void LLFloaterCompileQueue::handleInventory(LLViewerObject *viewer_object, | |||
317 | { | 353 | { |
318 | LLInventoryItem* item = (LLInventoryItem*)((LLInventoryObject*)(*it)); | 354 | LLInventoryItem* item = (LLInventoryItem*)((LLInventoryObject*)(*it)); |
319 | // Check permissions before allowing the user to retrieve data. | 355 | // Check permissions before allowing the user to retrieve data. |
320 | if (item->getPermissions().allowModifyBy(gAgent.getID()) && | 356 | if (item->getPermissions().allowModifyBy(gAgent.getID(), gAgent.getGroupID()) && |
321 | item->getPermissions().allowCopyBy(gAgent.getID()) ) | 357 | item->getPermissions().allowCopyBy(gAgent.getID(), gAgent.getGroupID()) ) |
322 | { | 358 | { |
323 | LLPointer<LLViewerInventoryItem> script = new LLViewerInventoryItem(item); | 359 | LLPointer<LLViewerInventoryItem> script = new LLViewerInventoryItem(item); |
324 | mCurrentScripts.put(script); | 360 | mCurrentScripts.put(script); |
325 | 361 | asset_item_map.insert(std::make_pair(item->getAssetUUID(), item)); | |
326 | if (!asset_item_map.count(item->getAssetUUID())) | ||
327 | { | ||
328 | // No entry, put in an entry for this supposedly permissive script | ||
329 | asset_item_map[item->getAssetUUID()] = item; | ||
330 | } | ||
331 | } | 362 | } |
332 | } | 363 | } |
333 | } | 364 | } |
@@ -344,7 +375,10 @@ void LLFloaterCompileQueue::handleInventory(LLViewerObject *viewer_object, | |||
344 | for(iter = asset_item_map.begin(); iter != asset_item_map.end(); iter++) | 375 | for(iter = asset_item_map.begin(); iter != asset_item_map.end(); iter++) |
345 | { | 376 | { |
346 | LLInventoryItem *itemp = iter->second; | 377 | LLInventoryItem *itemp = iter->second; |
347 | LLScriptQueueData* datap = new LLScriptQueueData(getID(), itemp->getName().c_str()); | 378 | LLScriptQueueData* datap = new LLScriptQueueData(getID(), |
379 | itemp->getName(), | ||
380 | viewer_object->getID(), | ||
381 | itemp->getUUID()); | ||
348 | 382 | ||
349 | //llinfos << "ITEM NAME 2: " << names.get(i) << llendl; | 383 | //llinfos << "ITEM NAME 2: " << names.get(i) << llendl; |
350 | gAssetStorage->getInvItemAsset(viewer_object->getRegion()->getHost(), | 384 | gAssetStorage->getInvItemAsset(viewer_object->getRegion()->getHost(), |
@@ -361,7 +395,6 @@ void LLFloaterCompileQueue::handleInventory(LLViewerObject *viewer_object, | |||
361 | } | 395 | } |
362 | } | 396 | } |
363 | 397 | ||
364 | |||
365 | // This is the callback for when each script arrives | 398 | // This is the callback for when each script arrives |
366 | // static | 399 | // static |
367 | void LLFloaterCompileQueue::scriptArrived(LLVFS *vfs, const LLUUID& asset_id, | 400 | void LLFloaterCompileQueue::scriptArrived(LLVFS *vfs, const LLUUID& asset_id, |
@@ -373,42 +406,69 @@ void LLFloaterCompileQueue::scriptArrived(LLVFS *vfs, const LLUUID& asset_id, | |||
373 | if(!data) return; | 406 | if(!data) return; |
374 | LLFloaterCompileQueue* queue = static_cast<LLFloaterCompileQueue*> | 407 | LLFloaterCompileQueue* queue = static_cast<LLFloaterCompileQueue*> |
375 | (LLFloaterScriptQueue::findInstance(data->mQueueID)); | 408 | (LLFloaterScriptQueue::findInstance(data->mQueueID)); |
376 | char buffer[MAX_STRING]; /*Flawfinder: ignore*/ | 409 | std::string buffer; |
377 | buffer[0] = '\0'; | ||
378 | if(queue && (0 == status)) | 410 | if(queue && (0 == status)) |
379 | { | 411 | { |
380 | //llinfos << "ITEM NAME 3: " << data->mScriptName << llendl; | 412 | //llinfos << "ITEM NAME 3: " << data->mScriptName << llendl; |
381 | 413 | ||
382 | // Dump this into a file on the local disk so we can compile it. | 414 | // Dump this into a file on the local disk so we can compile it. |
383 | char filename[LL_MAX_PATH] = ""; /*Flawfinder: ignore*/ | 415 | std::string filename; |
384 | LLVFile file(vfs, asset_id, type); | 416 | LLVFile file(vfs, asset_id, type); |
385 | char uuid_str[UUID_STR_LENGTH]; /*Flawfinder: ignore*/ | 417 | std::string uuid_str; |
386 | asset_id.toString(uuid_str); | 418 | asset_id.toString(uuid_str); |
387 | snprintf(filename, sizeof(filename), "%s.%s",gDirUtilp->getExpandedFilename(LL_PATH_CACHE,uuid_str).c_str(),LLAssetType::lookup(type)); /* Flawfinder: ignore */ | 419 | filename = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,uuid_str) + llformat(".%s",LLAssetType::lookup(type)); |
388 | 420 | ||
389 | LLFILE *fp = LLFile::fopen(filename, "wb"); /*Flawfinder: ignore*/ | 421 | const bool is_running = true; |
390 | if (fp) | 422 | LLViewerObject* object = gObjectList.findObject(data->mTaskId); |
423 | if (object) | ||
391 | { | 424 | { |
392 | const S32 buf_size = 65536; | 425 | std::string url = object->getRegion()->getCapability("UpdateScriptTask"); |
393 | U8 copy_buf[buf_size]; | 426 | if(!url.empty()) |
394 | while (file.read(copy_buf, buf_size)) /*Flawfinder: ignore*/ | 427 | { |
428 | // Read script source in to buffer. | ||
429 | U32 script_size = file.getSize(); | ||
430 | U8* script_data = new U8[script_size]; | ||
431 | file.read(script_data, script_size); | ||
432 | |||
433 | queue->mUploadQueue->queue(filename, data->mTaskId, | ||
434 | data->mItemId, is_running, queue->mMono, queue->getID(), | ||
435 | script_data, script_size, data->mScriptName); | ||
436 | } | ||
437 | else | ||
395 | { | 438 | { |
396 | if (fwrite(copy_buf, file.getLastBytesRead(), 1, fp) < 1) | 439 | // It's now in the file, now compile it. |
440 | buffer = std::string("Downloaded, now compiling: ") + data->mScriptName; // *TODO: Translate | ||
441 | |||
442 | // Write script to local file for compilation. | ||
443 | LLFILE *fp = LLFile::fopen(filename, "wb"); /*Flawfinder: ignore*/ | ||
444 | if (fp) | ||
397 | { | 445 | { |
398 | // return a bad file error if we can't write the whole thing | 446 | const S32 buf_size = 65536; |
399 | status = LL_ERR_CANNOT_OPEN_FILE; | 447 | U8 copy_buf[buf_size]; |
448 | |||
449 | while (file.read(copy_buf, buf_size)) /*Flawfinder: ignore*/ | ||
450 | { | ||
451 | if (fwrite(copy_buf, file.getLastBytesRead(), 1, fp) < 1) | ||
452 | { | ||
453 | // return a bad file error if we can't write the whole thing | ||
454 | status = LL_ERR_CANNOT_OPEN_FILE; | ||
455 | } | ||
456 | } | ||
457 | |||
458 | fclose(fp); | ||
459 | } | ||
460 | else | ||
461 | { | ||
462 | llerrs << "Unable to find object to compile" << llendl; | ||
400 | } | 463 | } |
401 | } | ||
402 | 464 | ||
403 | fclose(fp); | 465 | // TODO: babbage: No compile if no cap. |
466 | queue->compile(filename, data->mItemId); | ||
467 | |||
468 | // Delete it after we're done compiling? | ||
469 | LLFile::remove(filename); | ||
470 | } | ||
404 | } | 471 | } |
405 | |||
406 | // It's now in the file, now compile it. | ||
407 | snprintf(buffer, sizeof(buffer), "Downloaded, now compiling '%s'.", data->mScriptName.c_str()); /* Flawfinder: ignore */ | ||
408 | queue->compile(filename, asset_id); | ||
409 | |||
410 | // Delete it after we're done compiling? | ||
411 | LLFile::remove(filename); | ||
412 | } | 472 | } |
413 | else | 473 | else |
414 | { | 474 | { |
@@ -416,28 +476,25 @@ void LLFloaterCompileQueue::scriptArrived(LLVFS *vfs, const LLUUID& asset_id, | |||
416 | 476 | ||
417 | if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status ) | 477 | if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status ) |
418 | { | 478 | { |
419 | LLChat chat("Script not found on server."); | 479 | LLChat chat(std::string("Script not found on server.")); // *TODO: Translate |
420 | LLFloaterChat::addChat(chat); | 480 | LLFloaterChat::addChat(chat); |
421 | snprintf(buffer, sizeof(buffer), "Problem downloading %s.", /* Flawfinder: ignore */ | 481 | buffer = std::string("Problem downloading: ") + data->mScriptName; // *TODO: Translate |
422 | data->mScriptName.c_str()); | ||
423 | } | 482 | } |
424 | else if (LL_ERR_INSUFFICIENT_PERMISSIONS == status) | 483 | else if (LL_ERR_INSUFFICIENT_PERMISSIONS == status) |
425 | { | 484 | { |
426 | LLChat chat("Insufficient permissions to download a script."); | 485 | LLChat chat(std::string("Insufficient permissions to download a script.")); // *TODO: Translate |
427 | LLFloaterChat::addChat(chat); | 486 | LLFloaterChat::addChat(chat); |
428 | snprintf(buffer, sizeof(buffer), "Insufficient permissions for '%s'.", /* Flawfinder: ignore */ | 487 | buffer = std::string("Insufficient permissions for: ") + data->mScriptName; // *TODO: Translate |
429 | data->mScriptName.c_str()); | ||
430 | } | 488 | } |
431 | else | 489 | else |
432 | { | 490 | { |
433 | snprintf(buffer, sizeof(buffer), "Unknown failure to download %s.", /* Flawfinder: ignore */ | 491 | buffer = std::string("Unknown failure to download ") + data->mScriptName; // *TODO: Translate |
434 | data->mScriptName.c_str()); | ||
435 | } | 492 | } |
436 | 493 | ||
437 | llwarns << "Problem downloading script asset." << llendl; | 494 | llwarns << "Problem downloading script asset." << llendl; |
438 | if(queue) queue->removeItemByAssetID(asset_id); | 495 | if(queue) queue->removeItemByItemID(data->mItemId); |
439 | } | 496 | } |
440 | if(queue) | 497 | if(queue && (buffer.size() > 0)) |
441 | { | 498 | { |
442 | LLScrollListCtrl* list = queue->getChild<LLScrollListCtrl>("queue output"); | 499 | LLScrollListCtrl* list = queue->getChild<LLScrollListCtrl>("queue output"); |
443 | list->addCommentText(buffer); | 500 | list->addCommentText(buffer); |
@@ -452,7 +509,7 @@ void LLFloaterCompileQueue::onSaveTextComplete(const LLUUID& asset_id, void* use | |||
452 | if (status) | 509 | if (status) |
453 | { | 510 | { |
454 | llwarns << "Unable to save text for script." << llendl; | 511 | llwarns << "Unable to save text for script." << llendl; |
455 | LLString::format_map_t args; | 512 | LLStringUtil::format_map_t args; |
456 | args["[REASON]"] = std::string(LLAssetStorage::getErrorString(status)); | 513 | args["[REASON]"] = std::string(LLAssetStorage::getErrorString(status)); |
457 | gViewerWindow->alertXml("CompileQueueSaveText", args); | 514 | gViewerWindow->alertXml("CompileQueueSaveText", args); |
458 | } | 515 | } |
@@ -467,14 +524,13 @@ void LLFloaterCompileQueue::onSaveBytecodeComplete(const LLUUID& asset_id, void* | |||
467 | (LLFloaterScriptQueue::findInstance(data->mQueueID)); | 524 | (LLFloaterScriptQueue::findInstance(data->mQueueID)); |
468 | if(queue && (0 == status) && data) | 525 | if(queue && (0 == status) && data) |
469 | { | 526 | { |
470 | queue->updateAssetID(data->mOldAssetID, asset_id); | 527 | queue->saveItemByItemID(data->mItemId); |
471 | queue->saveItemByAssetID(asset_id); | 528 | queue->removeItemByItemID(data->mItemId); |
472 | queue->removeItemByAssetID(asset_id); | ||
473 | } | 529 | } |
474 | else | 530 | else |
475 | { | 531 | { |
476 | llwarns << "Unable to save bytecode for script." << llendl; | 532 | llwarns << "Unable to save bytecode for script." << llendl; |
477 | LLStringBase<char>::format_map_t args; | 533 | LLStringUtil::format_map_t args; |
478 | args["[REASON]"] = std::string(LLAssetStorage::getErrorString(status)); | 534 | args["[REASON]"] = std::string(LLAssetStorage::getErrorString(status)); |
479 | gViewerWindow->alertXml("CompileQueueSaveBytecode", args); | 535 | gViewerWindow->alertXml("CompileQueueSaveBytecode", args); |
480 | } | 536 | } |
@@ -483,47 +539,52 @@ void LLFloaterCompileQueue::onSaveBytecodeComplete(const LLUUID& asset_id, void* | |||
483 | } | 539 | } |
484 | 540 | ||
485 | // compile the file given and save it out. | 541 | // compile the file given and save it out. |
486 | void LLFloaterCompileQueue::compile(const char* filename, | 542 | void LLFloaterCompileQueue::compile(const std::string& filename, |
487 | const LLUUID& asset_id) | 543 | const LLUUID& item_id) |
488 | { | 544 | { |
489 | LLUUID new_asset_id; | 545 | LLUUID new_asset_id; |
490 | LLTransactionID tid; | 546 | LLTransactionID tid; |
491 | tid.generate(); | 547 | tid.generate(); |
492 | new_asset_id = tid.makeAssetID(gAgent.getSecureSessionID()); | 548 | new_asset_id = tid.makeAssetID(gAgent.getSecureSessionID()); |
493 | 549 | ||
494 | char uuid_string[UUID_STR_LENGTH]; /*Flawfinder: ignore*/ | 550 | std::string uuid_string; |
495 | new_asset_id.toString(uuid_string); | 551 | new_asset_id.toString(uuid_string); |
496 | char dst_filename[LL_MAX_PATH]; /*Flawfinder: ignore*/ | 552 | std::string dst_filename; |
497 | snprintf(dst_filename, sizeof(dst_filename), "%s.lso", gDirUtilp->getExpandedFilename(LL_PATH_CACHE,uuid_string).c_str()); /* Flawfinder: ignore */ | 553 | dst_filename = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,uuid_string) + ".lso"; |
498 | char err_filename[LL_MAX_PATH]; /*Flawfinder: ignore*/ | 554 | std::string err_filename; |
499 | snprintf(err_filename, sizeof(err_filename), "%s.out", gDirUtilp->getExpandedFilename(LL_PATH_CACHE,uuid_string).c_str()); /* Flawfinder: ignore */ | 555 | err_filename = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,uuid_string) + ".out"; |
500 | 556 | ||
501 | gAssetStorage->storeAssetData(filename, tid, | 557 | gAssetStorage->storeAssetData(filename, tid, |
502 | LLAssetType::AT_LSL_TEXT, | 558 | LLAssetType::AT_LSL_TEXT, |
503 | &onSaveTextComplete, NULL, FALSE); | 559 | &onSaveTextComplete, NULL, FALSE); |
504 | if(!lscript_compile(filename, dst_filename, err_filename, gAgent.isGodlike())) | 560 | |
561 | const BOOL compile_to_mono = FALSE; | ||
562 | if(!lscript_compile(filename.c_str(), dst_filename.c_str(), | ||
563 | err_filename.c_str(), compile_to_mono, | ||
564 | uuid_string.c_str(), gAgent.isGodlike())) | ||
505 | { | 565 | { |
506 | llwarns << "compile failed" << llendl; | 566 | llwarns << "compile failed" << llendl; |
507 | removeItemByAssetID(asset_id); | 567 | removeItemByItemID(item_id); |
508 | } | 568 | } |
509 | else | 569 | else |
510 | { | 570 | { |
511 | llinfos << "compile successful." << llendl; | 571 | llinfos << "compile successful." << llendl; |
512 | // Save the bytecode | 572 | |
513 | LLCompileQueueData* data = new LLCompileQueueData(mID, asset_id); | 573 | // Save LSL bytecode |
514 | gAssetStorage->storeAssetData(dst_filename, tid, | 574 | LLCompileQueueData* data = new LLCompileQueueData(mID, item_id); |
515 | LLAssetType::AT_LSL_BYTECODE, | 575 | gAssetStorage->storeAssetData(dst_filename, new_asset_id, |
516 | &onSaveBytecodeComplete, | 576 | LLAssetType::AT_LSL_BYTECODE, |
517 | (void*)data, FALSE); | 577 | &LLFloaterCompileQueue::onSaveBytecodeComplete, |
578 | (void*)data, FALSE); | ||
518 | } | 579 | } |
519 | } | 580 | } |
520 | 581 | ||
521 | void LLFloaterCompileQueue::removeItemByAssetID(const LLUUID& asset_id) | 582 | void LLFloaterCompileQueue::removeItemByItemID(const LLUUID& asset_id) |
522 | { | 583 | { |
523 | llinfos << "LLFloaterCompileQueue::removeItemByAssetID()" << llendl; | 584 | llinfos << "LLFloaterCompileQueue::removeItemByAssetID()" << llendl; |
524 | for(S32 i = 0; i < mCurrentScripts.count(); ) | 585 | for(S32 i = 0; i < mCurrentScripts.count(); ) |
525 | { | 586 | { |
526 | if(asset_id == mCurrentScripts.get(i)->getAssetUUID()) | 587 | if(asset_id == mCurrentScripts.get(i)->getUUID()) |
527 | { | 588 | { |
528 | mCurrentScripts.remove(i); | 589 | mCurrentScripts.remove(i); |
529 | } | 590 | } |
@@ -538,7 +599,21 @@ void LLFloaterCompileQueue::removeItemByAssetID(const LLUUID& asset_id) | |||
538 | } | 599 | } |
539 | } | 600 | } |
540 | 601 | ||
541 | void LLFloaterCompileQueue::saveItemByAssetID(const LLUUID& asset_id) | 602 | const LLInventoryItem* LLFloaterCompileQueue::findItemByItemID(const LLUUID& asset_id) const |
603 | { | ||
604 | LLInventoryItem* result = NULL; | ||
605 | S32 count = mCurrentScripts.count(); | ||
606 | for(S32 i = 0; i < count; ++i) | ||
607 | { | ||
608 | if(asset_id == mCurrentScripts.get(i)->getUUID()) | ||
609 | { | ||
610 | result = mCurrentScripts.get(i); | ||
611 | } | ||
612 | } | ||
613 | return result; | ||
614 | } | ||
615 | |||
616 | void LLFloaterCompileQueue::saveItemByItemID(const LLUUID& asset_id) | ||
542 | { | 617 | { |
543 | llinfos << "LLFloaterCompileQueue::saveItemByAssetID()" << llendl; | 618 | llinfos << "LLFloaterCompileQueue::saveItemByAssetID()" << llendl; |
544 | LLViewerObject* viewer_object = gObjectList.findObject(mCurrentObjectID); | 619 | LLViewerObject* viewer_object = gObjectList.findObject(mCurrentObjectID); |
@@ -547,7 +622,7 @@ void LLFloaterCompileQueue::saveItemByAssetID(const LLUUID& asset_id) | |||
547 | S32 count = mCurrentScripts.count(); | 622 | S32 count = mCurrentScripts.count(); |
548 | for(S32 i = 0; i < count; ++i) | 623 | for(S32 i = 0; i < count; ++i) |
549 | { | 624 | { |
550 | if(asset_id == mCurrentScripts.get(i)->getAssetUUID()) | 625 | if(asset_id == mCurrentScripts.get(i)->getUUID()) |
551 | { | 626 | { |
552 | // *FIX: this auto-resets active to TRUE. That might | 627 | // *FIX: this auto-resets active to TRUE. That might |
553 | // be a bad idea. | 628 | // be a bad idea. |
@@ -561,20 +636,6 @@ void LLFloaterCompileQueue::saveItemByAssetID(const LLUUID& asset_id) | |||
561 | } | 636 | } |
562 | } | 637 | } |
563 | 638 | ||
564 | // find old_asst_id, and set the asset id to new_asset_id | ||
565 | void LLFloaterCompileQueue::updateAssetID(const LLUUID& old_asset_id, | ||
566 | const LLUUID& new_asset_id) | ||
567 | { | ||
568 | S32 count = mCurrentScripts.count(); | ||
569 | for(S32 i = 0; i < count; ++i) | ||
570 | { | ||
571 | if(old_asset_id == mCurrentScripts.get(i)->getAssetUUID()) | ||
572 | { | ||
573 | mCurrentScripts.get(i)->setAssetUUID(new_asset_id); | ||
574 | } | ||
575 | } | ||
576 | } | ||
577 | |||
578 | ///---------------------------------------------------------------------------- | 639 | ///---------------------------------------------------------------------------- |
579 | /// Class LLFloaterResetQueue | 640 | /// Class LLFloaterResetQueue |
580 | ///---------------------------------------------------------------------------- | 641 | ///---------------------------------------------------------------------------- |
@@ -586,9 +647,9 @@ LLFloaterResetQueue* LLFloaterResetQueue::create() | |||
586 | gFloaterView->getNewFloaterPosition(&left, &top); | 647 | gFloaterView->getNewFloaterPosition(&left, &top); |
587 | LLRect rect = gSavedSettings.getRect("CompileOutputRect"); | 648 | LLRect rect = gSavedSettings.getRect("CompileOutputRect"); |
588 | rect.translate(left - rect.mLeft, top - rect.mTop); | 649 | rect.translate(left - rect.mLeft, top - rect.mTop); |
589 | LLFloaterResetQueue* new_queue = new LLFloaterResetQueue("queue", | 650 | LLFloaterResetQueue* new_queue = new LLFloaterResetQueue("queue", rect); |
590 | rect); | 651 | gFloaterView->addChild(new_queue); |
591 | new_queue->open(); /*Flawfinder: ignore*/ | 652 | new_queue->open(); |
592 | return new_queue; | 653 | return new_queue; |
593 | } | 654 | } |
594 | 655 | ||
@@ -619,8 +680,8 @@ void LLFloaterResetQueue::handleInventory(LLViewerObject* viewer_obj, | |||
619 | { | 680 | { |
620 | LLInventoryItem* item = (LLInventoryItem*)((LLInventoryObject*)(*it)); | 681 | LLInventoryItem* item = (LLInventoryItem*)((LLInventoryObject*)(*it)); |
621 | LLScrollListCtrl* list = getChild<LLScrollListCtrl>("queue output"); | 682 | LLScrollListCtrl* list = getChild<LLScrollListCtrl>("queue output"); |
622 | char buffer[MAX_STRING]; /*Flawfinder: ignore*/ | 683 | std::string buffer; |
623 | snprintf(buffer, sizeof(buffer), "Resetting '%s'.", item->getName().c_str()); /* Flawfinder: ignore */ | 684 | buffer = std::string("Resetting: ") + item->getName(); // *TODO: Translate |
624 | list->addCommentText(buffer); | 685 | list->addCommentText(buffer); |
625 | LLMessageSystem* msg = gMessageSystem; | 686 | LLMessageSystem* msg = gMessageSystem; |
626 | msg->newMessageFast(_PREHASH_ScriptReset); | 687 | msg->newMessageFast(_PREHASH_ScriptReset); |
@@ -649,8 +710,7 @@ LLFloaterRunQueue* LLFloaterRunQueue::create() | |||
649 | gFloaterView->getNewFloaterPosition(&left, &top); | 710 | gFloaterView->getNewFloaterPosition(&left, &top); |
650 | LLRect rect = gSavedSettings.getRect("CompileOutputRect"); | 711 | LLRect rect = gSavedSettings.getRect("CompileOutputRect"); |
651 | rect.translate(left - rect.mLeft, top - rect.mTop); | 712 | rect.translate(left - rect.mLeft, top - rect.mTop); |
652 | LLFloaterRunQueue* new_queue = new LLFloaterRunQueue("queue", | 713 | LLFloaterRunQueue* new_queue = new LLFloaterRunQueue("queue", rect); |
653 | rect); | ||
654 | new_queue->open(); /*Flawfinder: ignore*/ | 714 | new_queue->open(); /*Flawfinder: ignore*/ |
655 | return new_queue; | 715 | return new_queue; |
656 | } | 716 | } |
@@ -682,8 +742,8 @@ void LLFloaterRunQueue::handleInventory(LLViewerObject* viewer_obj, | |||
682 | { | 742 | { |
683 | LLInventoryItem* item = (LLInventoryItem*)((LLInventoryObject*)(*it)); | 743 | LLInventoryItem* item = (LLInventoryItem*)((LLInventoryObject*)(*it)); |
684 | LLScrollListCtrl* list = getChild<LLScrollListCtrl>("queue output"); | 744 | LLScrollListCtrl* list = getChild<LLScrollListCtrl>("queue output"); |
685 | char buffer[MAX_STRING]; /*Flawfinder: ignore*/ | 745 | std::string buffer; |
686 | snprintf(buffer, sizeof(buffer), "Running '%s'.", item->getName().c_str()); /* Flawfinder: ignore */ | 746 | buffer = std::string("Running: ") + item->getName(); // *TODO: Translate |
687 | list->addCommentText(buffer); | 747 | list->addCommentText(buffer); |
688 | 748 | ||
689 | LLMessageSystem* msg = gMessageSystem; | 749 | LLMessageSystem* msg = gMessageSystem; |
@@ -714,8 +774,7 @@ LLFloaterNotRunQueue* LLFloaterNotRunQueue::create() | |||
714 | gFloaterView->getNewFloaterPosition(&left, &top); | 774 | gFloaterView->getNewFloaterPosition(&left, &top); |
715 | LLRect rect = gSavedSettings.getRect("CompileOutputRect"); | 775 | LLRect rect = gSavedSettings.getRect("CompileOutputRect"); |
716 | rect.translate(left - rect.mLeft, top - rect.mTop); | 776 | rect.translate(left - rect.mLeft, top - rect.mTop); |
717 | LLFloaterNotRunQueue* new_queue = new LLFloaterNotRunQueue("queue", | 777 | LLFloaterNotRunQueue* new_queue = new LLFloaterNotRunQueue("queue", rect); |
718 | rect); | ||
719 | new_queue->open(); /*Flawfinder: ignore*/ | 778 | new_queue->open(); /*Flawfinder: ignore*/ |
720 | return new_queue; | 779 | return new_queue; |
721 | } | 780 | } |
@@ -747,8 +806,8 @@ void LLFloaterNotRunQueue::handleInventory(LLViewerObject* viewer_obj, | |||
747 | { | 806 | { |
748 | LLInventoryItem* item = (LLInventoryItem*)((LLInventoryObject*)(*it)); | 807 | LLInventoryItem* item = (LLInventoryItem*)((LLInventoryObject*)(*it)); |
749 | LLScrollListCtrl* list = getChild<LLScrollListCtrl>("queue output"); | 808 | LLScrollListCtrl* list = getChild<LLScrollListCtrl>("queue output"); |
750 | char buffer[MAX_STRING]; /*Flawfinder: ignore*/ | 809 | std::string buffer; |
751 | snprintf(buffer, sizeof(buffer), "Not running '%s'.", item->getName().c_str()); /* Flawfinder: ignore */ | 810 | buffer = std::string("Not running: ") +item->getName(); // *TODO: Translate |
752 | list->addCommentText(buffer); | 811 | list->addCommentText(buffer); |
753 | 812 | ||
754 | LLMessageSystem* msg = gMessageSystem; | 813 | LLMessageSystem* msg = gMessageSystem; |