diff options
Diffstat (limited to 'indra/newview/llcompilequeue.cpp')
-rw-r--r-- | indra/newview/llcompilequeue.cpp | 169 |
1 files changed, 83 insertions, 86 deletions
diff --git a/indra/newview/llcompilequeue.cpp b/indra/newview/llcompilequeue.cpp index b11786a451..0006a48de5 100644 --- a/indra/newview/llcompilequeue.cpp +++ b/indra/newview/llcompilequeue.cpp @@ -1,25 +1,25 @@ -/** +/** * @file llcompilequeue.cpp * @brief LLCompileQueueData class implementation * * $LicenseInfo:firstyear=2002&license=viewerlgpl$ * Second Life Viewer Source Code * Copyright (C) 2010, Linden Research, Inc. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; * version 2.1 of the License only. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * + * * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ @@ -27,7 +27,7 @@ /** * * Implementation of the script queue which keeps an array of object - * UUIDs and manipulates all of the scripts on each of them. + * UUIDs and manipulates all of the scripts on each of them. * */ @@ -66,9 +66,10 @@ namespace { const std::string QUEUE_EVENTPUMP_NAME("ScriptActionQueue"); + const F32 QUEUE_INVENTORY_FETCH_TIMEOUT = 300.f; - // ObjectIventoryFetcher is an adapter between the LLVOInventoryListener::inventoryChanged - // callback mechanism and the LLEventPump coroutine architecture allowing the + // ObjectIventoryFetcher is an adapter between the LLVOInventoryListener::inventoryChanged + // callback mechanism and the LLEventPump coroutine architecture allowing the // coroutine to wait for the inventory event. class ObjectInventoryFetcher: public LLVOInventoryListener { @@ -87,7 +88,7 @@ namespace S32 serial_num, void* user_data); - void fetchInventory() + void fetchInventory() { requestVOInventory(); } @@ -115,15 +116,15 @@ namespace } -// *NOTE$: A minor specialization of LLScriptAssetUpload, it does not require a buffer -// (and does not save a buffer to the cache) and it finds the compile queue window and +// *NOTE$: A minor specialization of LLScriptAssetUpload, it does not require a buffer +// (and does not save a buffer to the cache) 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, + LLScriptAssetUpload(taskId, itemId, targetType, isRunning, exerienceId, std::string(), finish, nullptr), mScriptName(scriptName), mQueueId(queueId) @@ -133,8 +134,8 @@ public: virtual LLSD prepareUpload() { - /* *NOTE$: The parent class (LLScriptAssetUpload will attempt to save - * the script buffer into to the cache. Since the resource is already in + /* *NOTE$: The parent class (LLScriptAssetUpload will attempt to save + * the script buffer into to the cache. Since the resource is already in * the cache we don't want to do that. Just put a compiling message in * the window and move on */ @@ -165,14 +166,14 @@ private: struct LLScriptQueueData { - LLUUID mQueueID; - LLUUID mTaskId; - LLPointer<LLInventoryItem> mItem; - LLHost mHost; - LLUUID mExperienceId; - std::string mExperiencename; - LLScriptQueueData(const LLUUID& q_id, const LLUUID& task_id, LLInventoryItem* item) : - mQueueID(q_id), mTaskId(task_id), mItem(new LLInventoryItem(item)) {} + LLUUID mQueueID; + LLUUID mTaskId; + LLPointer<LLInventoryItem> mItem; + LLHost mHost; + LLUUID mExperienceId; + std::string mExperiencename; + LLScriptQueueData(const LLUUID& q_id, const LLUUID& task_id, LLInventoryItem* item) : + mQueueID(q_id), mTaskId(task_id), mItem(new LLInventoryItem(item)) {} }; @@ -182,11 +183,11 @@ struct LLScriptQueueData // Default constructor LLFloaterScriptQueue::LLFloaterScriptQueue(const LLSD& key) : - LLFloater(key), - mDone(false), - mMono(false) + LLFloater(key), + mDone(false), + mMono(false) { - + } // Destroys the object @@ -196,17 +197,17 @@ LLFloaterScriptQueue::~LLFloaterScriptQueue() BOOL LLFloaterScriptQueue::postBuild() { - childSetAction("close",onCloseBtn,this); - getChildView("close")->setEnabled(FALSE); - setVisible(true); - return TRUE; + childSetAction("close",onCloseBtn,this); + getChildView("close")->setEnabled(FALSE); + setVisible(true); + return TRUE; } // static void LLFloaterScriptQueue::onCloseBtn(void* user_data) { - LLFloaterScriptQueue* self = (LLFloaterScriptQueue*)user_data; - self->closeFloater(); + LLFloaterScriptQueue* self = (LLFloaterScriptQueue*)user_data; + self->closeFloater(); } void LLFloaterScriptQueue::addObject(const LLUUID& id, std::string name) @@ -217,16 +218,16 @@ void LLFloaterScriptQueue::addObject(const LLUUID& id, std::string name) BOOL LLFloaterScriptQueue::start() { - std::string buffer; + std::string buffer; + + LLStringUtil::format_map_t args; + args["[START]"] = mStartString; + args["[COUNT]"] = llformat ("%d", mObjectList.size()); + buffer = getString ("Starting", args); - LLStringUtil::format_map_t args; - args["[START]"] = mStartString; - args["[COUNT]"] = llformat ("%d", mObjectList.size()); - buffer = getString ("Starting", args); - - getChild<LLScrollListCtrl>("queue output")->addSimpleElement(buffer, ADD_BOTTOM); + getChild<LLScrollListCtrl>("queue output")->addSimpleElement(buffer, ADD_BOTTOM); - return startQueue(); + return startQueue(); } void LLFloaterScriptQueue::addProcessingMessage(const std::string &message, const LLSD &args) @@ -244,7 +245,7 @@ void LLFloaterScriptQueue::addStringMessage(const std::string &message) BOOL LLFloaterScriptQueue::isDone() const { - return (mCurrentObjectID.isNull() && (mObjectList.size() == 0)); + return (mCurrentObjectID.isNull() && (mObjectList.size() == 0)); } ///---------------------------------------------------------------------------- @@ -253,29 +254,29 @@ BOOL LLFloaterScriptQueue::isDone() const LLFloaterCompileQueue::LLFloaterCompileQueue(const LLSD& key) : LLFloaterScriptQueue(key) { - setTitle(LLTrans::getString("CompileQueueTitle")); - setStartString(LLTrans::getString("CompileQueueStart")); - + setTitle(LLTrans::getString("CompileQueueTitle")); + setStartString(LLTrans::getString("CompileQueueStart")); + } LLFloaterCompileQueue::~LLFloaterCompileQueue() -{ +{ } void LLFloaterCompileQueue::experienceIdsReceived( const LLSD& content ) { - for(LLSD::array_const_iterator it = content.beginArray(); it != content.endArray(); ++it) - { - mExperienceIds.insert(it->asUUID()); - } + for(LLSD::array_const_iterator it = content.beginArray(); it != content.endArray(); ++it) + { + mExperienceIds.insert(it->asUUID()); + } } BOOL LLFloaterCompileQueue::hasExperience( const LLUUID& id ) const { - return mExperienceIds.find(id) != mExperienceIds.end(); + return mExperienceIds.find(id) != mExperienceIds.end(); } -// //Attempt to record this asset ID. If it can not be inserted into the set +// //Attempt to record this asset ID. If it can not be inserted into the set // //then it has already been processed so return false. void LLFloaterCompileQueue::handleHTTPResponse(std::string pumpName, const LLSD &expresult) @@ -284,10 +285,10 @@ void LLFloaterCompileQueue::handleHTTPResponse(std::string pumpName, const LLSD } // *TODO: handleSCriptRetrieval is passed into the cache via a legacy C function pointer -// future project would be to convert these to C++ callables (std::function<>) so that +// future project would be to convert these to C++ callables (std::function<>) so that // we can use bind and remove the userData parameter. -// -void LLFloaterCompileQueue::handleScriptRetrieval(const LLUUID& assetId, +// +void LLFloaterCompileQueue::handleScriptRetrieval(const LLUUID& assetId, LLAssetType::EType type, void* userData, S32 status, LLExtStat extStatus) { LLSD result(LLSD::emptyMap()); @@ -296,7 +297,7 @@ void LLFloaterCompileQueue::handleScriptRetrieval(const LLUUID& assetId, if (status) { result["error"] = status; - + if (status == LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE) { result["message"] = LLTrans::getString("CompileQueueProblemDownloading") + (":"); @@ -359,8 +360,6 @@ bool LLFloaterCompileQueue::processScript(LLHandle<LLFloaterCompileQueue> hfloat // Dereferencing floater may fail. If they do they throw LLExeceptionStaleHandle. // which is caught in objectScriptProcessingQueueCoro bool monocompile = floater->mMono; - F32 fetch_timeout = gSavedSettings.getF32("QueueInventoryFetchTimeout"); - // Initial test to see if we can (or should) attempt to compile the script. LLInventoryItem *item = dynamic_cast<LLInventoryItem *>(inventory); @@ -385,7 +384,7 @@ bool LLFloaterCompileQueue::processScript(LLHandle<LLFloaterCompileQueue> hfloat LLExperienceCache::instance().fetchAssociatedExperience(inventory->getParentUUID(), inventory->getUUID(), boost::bind(&LLFloaterCompileQueue::handleHTTPResponse, pump.getName(), _1)); - result = llcoro::suspendUntilEventOnWithTimeout(pump, fetch_timeout, + result = llcoro::suspendUntilEventOnWithTimeout(pump, QUEUE_INVENTORY_FETCH_TIMEOUT, LLSDMap("timeout", LLSD::Boolean(true))); floater.check(); @@ -404,7 +403,7 @@ bool LLFloaterCompileQueue::processScript(LLHandle<LLFloaterCompileQueue> hfloat experienceId = result[LLExperienceCache::EXPERIENCE_ID].asUUID(); if (!floater->hasExperience(experienceId)) { - floater->addProcessingMessage("CompileNoExperiencePerm", + floater->addProcessingMessage("CompileNoExperiencePerm", LLSDMap("SCRIPT", inventory->getName()) ("EXPERIENCE", result[LLExperienceCache::NAME].asString())); return true; @@ -435,7 +434,7 @@ bool LLFloaterCompileQueue::processScript(LLHandle<LLFloaterCompileQueue> hfloat &LLFloaterCompileQueue::handleScriptRetrieval, &userData); - result = llcoro::suspendUntilEventOnWithTimeout(pump, fetch_timeout, + result = llcoro::suspendUntilEventOnWithTimeout(pump, QUEUE_INVENTORY_FETCH_TIMEOUT, LLSDMap("timeout", LLSD::Boolean(true))); } @@ -468,20 +467,20 @@ bool LLFloaterCompileQueue::processScript(LLHandle<LLFloaterCompileQueue> hfloat std::string url = object->getRegion()->getCapability("UpdateScriptTask"); { - LLResourceUploadInfo::ptr_t uploadInfo(new LLQueuedScriptAssetUpload(object->getID(), - inventory->getUUID(), - assetId, + LLResourceUploadInfo::ptr_t uploadInfo(new LLQueuedScriptAssetUpload(object->getID(), + inventory->getUUID(), + assetId, monocompile ? LLScriptAssetUpload::MONO : LLScriptAssetUpload::LSL2, - true, - inventory->getName(), - LLUUID(), - experienceId, + true, + inventory->getName(), + LLUUID(), + experienceId, boost::bind(&LLFloaterCompileQueue::handleHTTPResponse, pump.getName(), _4))); LLViewerAssetUpload::EnqueueInventoryUpload(url, uploadInfo); } - result = llcoro::suspendUntilEventOnWithTimeout(pump, fetch_timeout, LLSDMap("timeout", LLSD::Boolean(true))); + result = llcoro::suspendUntilEventOnWithTimeout(pump, QUEUE_INVENTORY_FETCH_TIMEOUT, LLSDMap("timeout", LLSD::Boolean(true))); floater.check(); @@ -552,12 +551,12 @@ bool LLFloaterCompileQueue::startQueue() LLFloaterResetQueue::LLFloaterResetQueue(const LLSD& key) : LLFloaterScriptQueue(key) { - setTitle(LLTrans::getString("ResetQueueTitle")); - setStartString(LLTrans::getString("ResetQueueStart")); + setTitle(LLTrans::getString("ResetQueueTitle")); + setStartString(LLTrans::getString("ResetQueueStart")); } LLFloaterResetQueue::~LLFloaterResetQueue() -{ +{ } /// This is a utility function to be bound and called from objectScriptProcessingQueueCoro. @@ -572,7 +571,7 @@ bool LLFloaterResetQueue::resetObjectScripts(LLHandle<LLFloaterScriptQueue> hflo std::string buffer; buffer = floater->getString("Resetting") + (": ") + inventory->getName(); floater->addStringMessage(buffer); - + LLMessageSystem* msg = gMessageSystem; msg->newMessageFast(_PREHASH_ScriptReset); msg->nextBlockFast(_PREHASH_AgentData); @@ -609,12 +608,12 @@ bool LLFloaterResetQueue::startQueue() LLFloaterRunQueue::LLFloaterRunQueue(const LLSD& key) : LLFloaterScriptQueue(key) { - setTitle(LLTrans::getString("RunQueueTitle")); - setStartString(LLTrans::getString("RunQueueStart")); + setTitle(LLTrans::getString("RunQueueTitle")); + setStartString(LLTrans::getString("RunQueueStart")); } LLFloaterRunQueue::~LLFloaterRunQueue() -{ +{ } /// This is a utility function to be bound and called from objectScriptProcessingQueueCoro. @@ -666,17 +665,17 @@ bool LLFloaterRunQueue::startQueue() LLFloaterNotRunQueue::LLFloaterNotRunQueue(const LLSD& key) : LLFloaterScriptQueue(key) { - setTitle(LLTrans::getString("NotRunQueueTitle")); - setStartString(LLTrans::getString("NotRunQueueStart")); + setTitle(LLTrans::getString("NotRunQueueTitle")); + setStartString(LLTrans::getString("NotRunQueueStart")); } LLFloaterNotRunQueue::~LLFloaterNotRunQueue() -{ +{ } /// This is a utility function to be bound and called from objectScriptProcessingQueueCoro. /// Do not call directly. It may throw a LLCheckedHandle<>::Stale exception. -bool LLFloaterNotRunQueue::stopObjectScripts(LLHandle<LLFloaterScriptQueue> hfloater, +bool LLFloaterNotRunQueue::stopObjectScripts(LLHandle<LLFloaterScriptQueue> hfloater, const LLPointer<LLViewerObject> &object, LLInventoryObject* inventory, LLEventPump &pump) { LLCheckedHandle<LLFloaterScriptQueue> floater(hfloater); @@ -732,12 +731,10 @@ void LLFloaterScriptQueue::objectScriptProcessingQueueCoro(std::string action, L object_data_list_t objectList, fnQueueAction_t func) { LLCoros::set_consuming(true); - LLCheckedHandle<LLFloaterScriptQueue> floater(hfloater); - // Dereferencing floater may fail. If they do they throw LLExeceptionStaleHandle. + LLCheckedHandle<LLFloaterScriptQueue> floater(hfloater); + // Dereferencing floater may fail. If they do they throw LLExeceptionStaleHandle. // This is expected if the dialog closes. LLEventMailDrop maildrop(QUEUE_EVENTPUMP_NAME, true); - F32 fetch_timeout = gSavedSettings.getF32("QueueInventoryFetchTimeout"); - try { @@ -759,7 +756,7 @@ void LLFloaterScriptQueue::objectScriptProcessingQueueCoro(std::string action, L args["[OBJECT_NAME]"] = (*itObj).mObjectName; floater->addStringMessage(floater->getString("LoadingObjInv", args)); - LLSD result = llcoro::suspendUntilEventOnWithTimeout(maildrop, fetch_timeout, + LLSD result = llcoro::suspendUntilEventOnWithTimeout(maildrop, QUEUE_INVENTORY_FETCH_TIMEOUT, LLSDMap("timeout", LLSD::Boolean(true))); if (result.has("timeout")) @@ -792,7 +789,7 @@ void LLFloaterScriptQueue::objectScriptProcessingQueueCoro(std::string action, L { floater.check(); - // note, we have a smart pointer to the obj above... but if we didn't we'd check that + // note, we have a smart pointer to the obj above... but if we didn't we'd check that // it still exists here. if (((*itInv)->getType() == LLAssetType::AT_LSL_TEXT)) @@ -822,7 +819,7 @@ void LLFloaterScriptQueue::objectScriptProcessingQueueCoro(std::string action, L } catch (LLCheckedHandleBase::Stale &) { - // This is expected. It means that floater has been closed before + // This is expected. It means that floater has been closed before // processing was completed. LL_DEBUGS("SCRIPTQ") << "LLExeceptionStaleHandle caught! Floater has most likely been closed." << LL_ENDL; } |