diff options
author | Rider Linden <rider@lindenlab.com> | 2015-07-20 15:57:10 -0700 |
---|---|---|
committer | Rider Linden <rider@lindenlab.com> | 2015-07-20 15:57:10 -0700 |
commit | 37d17eaebd05325f0ddb3334cbabf7a8710d5843 (patch) | |
tree | b706c56898eeb6489f70d3bc04d72f7c8f4d40cb /indra/newview/llcompilequeue.cpp | |
parent | 2fc4ddb92bfb7b05851372adcfda7e0ab4886718 (diff) |
Remove old "compile queue" and replace with the coroutine based upload queue.
Diffstat (limited to 'indra/newview/llcompilequeue.cpp')
-rwxr-xr-x | indra/newview/llcompilequeue.cpp | 163 |
1 files changed, 93 insertions, 70 deletions
diff --git a/indra/newview/llcompilequeue.cpp b/indra/newview/llcompilequeue.cpp index d9fd4509a5..c4b0b96d4c 100755 --- a/indra/newview/llcompilequeue.cpp +++ b/indra/newview/llcompilequeue.cpp @@ -37,7 +37,6 @@ #include "llcompilequeue.h" #include "llagent.h" -#include "llassetuploadqueue.h" #include "llassetuploadresponders.h" #include "llchat.h" #include "llfloaterreg.h" @@ -62,8 +61,51 @@ #include "llexperienceassociationresponder.h" #include "llexperiencecache.h" -// *TODO: This should be separated into the script queue, and the floater views of that queue. -// There should only be one floater class that can view any queue type +#include "llviewerassetupload.h" + +// *NOTE$: A minor specialization of LLScriptAssetUpload, it does not require a buffer +// (and does not save a buffer to the vFS) and it finds the compile queue window and +// displays a compiling message. +class LLQueuedScriptAssetUpload : public LLScriptAssetUpload +{ +public: + LLQueuedScriptAssetUpload(LLUUID taskId, LLUUID itemId, LLUUID assetId, TargetType_t targetType, + bool isRunning, std::string scriptName, LLUUID queueId, LLUUID exerienceId, taskUploadFinish_f finish) : + LLScriptAssetUpload(taskId, itemId, targetType, isRunning, + exerienceId, std::string(), finish), + mScriptName(scriptName), + mQueueId(queueId) + { + setAssetId(assetId); + } + + virtual LLSD prepareUpload() + { + /* *NOTE$: The parent class (LLScriptAssetUpload will attempt to save + * the script buffer into to the VFS. Since the resource is already in + * the VFS we don't want to do that. Just put a compiling message in + * the window and move on + */ + LLFloaterCompileQueue* queue = LLFloaterReg::findTypedInstance<LLFloaterCompileQueue>("compile_queue", LLSD(mQueueId)); + if (queue) + { + std::string message = std::string("Compiling \"") + getScriptName() + std::string("\"..."); + + queue->getChild<LLScrollListCtrl>("queue output")->addSimpleElement(message, ADD_BOTTOM); + } + + return LLSD().with("success", LLSD::Boolean(true)); + } + + + std::string getScriptName() const { return mScriptName; } + +private: + void setScriptName(const std::string &scriptName) { mScriptName = scriptName; } + + LLUUID mQueueId; + std::string mScriptName; +}; ///---------------------------------------------------------------------------- /// Local function declarations, constants, enums, and typedefs @@ -127,7 +169,7 @@ void LLFloaterScriptQueue::inventoryChanged(LLViewerObject* viewer_object, //which it internally stores. //If we call this further down in the function, calls to handleInventory - //and nextObject may update the interally stored viewer object causing + //and nextObject may update the internally stored viewer object causing //the removal of the incorrect listener from an incorrect object. //Fixes SL-6119:Recompile scripts fails to complete @@ -275,48 +317,13 @@ public: ///---------------------------------------------------------------------------- /// Class LLFloaterCompileQueue ///---------------------------------------------------------------------------- - -class LLCompileFloaterUploadQueueSupplier : public LLAssetUploadQueueSupplier -{ -public: - - LLCompileFloaterUploadQueueSupplier(const LLUUID& queue_id) : - mQueueId(queue_id) - { - } - - virtual LLAssetUploadQueue* get() const - { - LLFloaterCompileQueue* queue = LLFloaterReg::findTypedInstance<LLFloaterCompileQueue>("compile_queue", LLSD(mQueueId)); - if(NULL == queue) - { - return NULL; - } - return queue->getUploadQueue(); - } - - virtual void log(std::string message) const - { - LLFloaterCompileQueue* queue = LLFloaterReg::findTypedInstance<LLFloaterCompileQueue>("compile_queue", LLSD(mQueueId)); - if(NULL == queue) - { - return; - } - - queue->getChild<LLScrollListCtrl>("queue output")->addSimpleElement(message, ADD_BOTTOM); - } - -private: - LLUUID mQueueId; -}; - LLFloaterCompileQueue::LLFloaterCompileQueue(const LLSD& key) : LLFloaterScriptQueue(key) { setTitle(LLTrans::getString("CompileQueueTitle")); setStartString(LLTrans::getString("CompileQueueStart")); - mUploadQueue = new LLAssetUploadQueue(new LLCompileFloaterUploadQueueSupplier(key.asUUID())); +// mUploadQueue = new LLAssetUploadQueue(new LLCompileFloaterUploadQueueSupplier(key.asUUID())); } LLFloaterCompileQueue::~LLFloaterCompileQueue() @@ -423,6 +430,37 @@ void LLFloaterCompileQueue::requestAsset( LLScriptQueueData* datap, const LLSD& (void*)datap); } +/*static*/ +void LLFloaterCompileQueue::finishLSLUpload(LLUUID itemId, LLUUID taskId, LLUUID newAssetId, LLSD response, std::string scriptName, LLUUID queueId) +{ + + LLFloaterCompileQueue* queue = LLFloaterReg::findTypedInstance<LLFloaterCompileQueue>("compile_queue", LLSD(queueId)); + if (queue) + { + // Bytecode save completed + if (response["compiled"]) + { + std::string message = std::string("Compilation of \"") + scriptName + std::string("\" succeeded"); + + queue->getChild<LLScrollListCtrl>("queue output")->addSimpleElement(message, ADD_BOTTOM); + LL_INFOS() << message << LL_ENDL; + } + else + { + LLSD compile_errors = response["errors"]; + for (LLSD::array_const_iterator line = compile_errors.beginArray(); + line < compile_errors.endArray(); line++) + { + std::string str = line->asString(); + str.erase(std::remove(str.begin(), str.end(), '\n'), str.end()); + + queue->getChild<LLScrollListCtrl>("queue output")->addSimpleElement(str, ADD_BOTTOM); + } + LL_INFOS() << response["errors"] << LL_ENDL; + } + + } +} // This is the callback for when each script arrives // static @@ -441,36 +479,21 @@ void LLFloaterCompileQueue::scriptArrived(LLVFS *vfs, const LLUUID& asset_id, std::string buffer; if(queue && (0 == status)) { - //LL_INFOS() << "ITEM NAME 3: " << data->mScriptName << LL_ENDL; - - // Dump this into a file on the local disk so we can compile it. - std::string filename; - LLVFile file(vfs, asset_id, type); - std::string uuid_str; - asset_id.toString(uuid_str); - filename = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,uuid_str) + llformat(".%s",LLAssetType::lookup(type)); - - const bool is_running = true; - LLViewerObject* object = gObjectList.findObject(data->mTaskId); - if (object) - { - std::string url = object->getRegion()->getCapability("UpdateScriptTask"); - if(!url.empty()) - { - // Read script source in to buffer. - U32 script_size = file.getSize(); - U8* script_data = new U8[script_size]; - file.read(script_data, script_size); - - queue->mUploadQueue->queue(filename, data->mTaskId, - data->mItem->getUUID(), is_running, queue->mMono, queue->getKey().asUUID(), - script_data, script_size, data->mItem->getName(), data->mExperienceId); - } - else - { - buffer = LLTrans::getString("CompileQueueServiceUnavailable") + (": ") + data->mItem->getName(); - } - } + LLViewerObject* object = gObjectList.findObject(data->mTaskId); + if (object) + { + std::string url = object->getRegion()->getCapability("UpdateScriptTask"); + std::string scriptName = data->mItem->getName(); + + LLBufferedAssetUploadInfo::taskUploadFinish_f proc = boost::bind(&LLFloaterCompileQueue::finishLSLUpload, _1, _2, _3, _4, + scriptName, data->mQueueID); + + LLResourceUploadInfo::ptr_t uploadInfo(new LLQueuedScriptAssetUpload(data->mTaskId, data->mItem->getUUID(), asset_id, + (queue->mMono) ? LLScriptAssetUpload::MONO : LLScriptAssetUpload::LSL2, + true, scriptName, data->mQueueID, data->mExperienceId, proc)); + + LLViewerAssetUpload::EnqueueInventoryUpload(url, uploadInfo); + } } else { |