summaryrefslogtreecommitdiff
path: root/indra/newview/llcompilequeue.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llcompilequeue.cpp')
-rw-r--r--indra/newview/llcompilequeue.cpp533
1 files changed, 265 insertions, 268 deletions
diff --git a/indra/newview/llcompilequeue.cpp b/indra/newview/llcompilequeue.cpp
index 8e5e8c8ea3..268d9958d1 100644
--- a/indra/newview/llcompilequeue.cpp
+++ b/indra/newview/llcompilequeue.cpp
@@ -2,30 +2,25 @@
* @file llcompilequeue.cpp
* @brief LLCompileQueueData class implementation
*
- * $LicenseInfo:firstyear=2002&license=viewergpl$
- *
- * Copyright (c) 2002-2007, Linden Research, Inc.
- *
+ * $LicenseInfo:firstyear=2002&license=viewerlgpl$
* Second Life Viewer Source Code
- * The source code in this file ("Source Code") is provided by Linden Lab
- * to you under the terms of the GNU General Public License, version 2.0
- * ("GPL"), unless you have obtained a separate licensing agreement
- * ("Other License"), formally executed by you and Linden Lab. Terms of
- * the GPL can be found in doc/GPL-license.txt in this distribution, or
- * online at http://secondlife.com/developers/opensource/gplv2
+ * Copyright (C) 2010, Linden Research, Inc.
*
- * There are special exceptions to the terms and conditions of the GPL as
- * it is applied to this Source Code. View the full text of the exception
- * in the file doc/FLOSS-exception.txt in this software distribution, or
- * online at http://secondlife.com/developers/opensource/flossexception
+ * 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.
*
- * By copying, modifying or distributing this software, you acknowledge
- * that you have read and understood your obligations described above,
- * and agree to abide by those obligations.
+ * 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.
*
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
+ * 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$
*/
@@ -42,7 +37,10 @@
#include "llcompilequeue.h"
#include "llagent.h"
+#include "llassetuploadqueue.h"
+#include "llassetuploadresponders.h"
#include "llchat.h"
+#include "llfloaterreg.h"
#include "llviewerwindow.h"
#include "llviewerobject.h"
#include "llviewerobjectlist.h"
@@ -52,101 +50,65 @@
#include "llviewerobject.h"
#include "llviewerregion.h"
#include "llresmgr.h"
+
#include "llbutton.h"
#include "lldir.h"
-#include "llfloaterchat.h"
+#include "llnotificationsutil.h"
#include "llviewerstats.h"
+#include "llvfile.h"
#include "lluictrlfactory.h"
+#include "lltrans.h"
+
+#include "llselectmgr.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
///----------------------------------------------------------------------------
/// Local function declarations, constants, enums, and typedefs
///----------------------------------------------------------------------------
-// *TODO:Translate
-const char* COMPILE_QUEUE_TITLE = "Recompilation Progress";
-const char* COMPILE_START_STRING = "recompile";
-const char* RESET_QUEUE_TITLE = "Reset Progress";
-const char* RESET_START_STRING = "reset";
-const char* RUN_QUEUE_TITLE = "Set Running Progress";
-const char* RUN_START_STRING = "set running";
-const char* NOT_RUN_QUEUE_TITLE = "Set Not Running Progress";
-const char* NOT_RUN_START_STRING = "set not running";
-
-struct LLCompileQueueData
-{
- LLUUID mQueueID;
- LLUUID mOldAssetID;
- LLCompileQueueData(const LLUUID& q_id, const LLUUID& old_asset_id) :
- mQueueID(q_id), mOldAssetID(old_asset_id) {}
-};
-
struct LLScriptQueueData
{
LLUUID mQueueID;
- LLString mScriptName;
- LLScriptQueueData(const LLUUID& q_id, const char* name) :
- mQueueID(q_id), mScriptName(name) {}
+ std::string mScriptName;
+ LLUUID mTaskId;
+ LLUUID mItemId;
+ LLScriptQueueData(const LLUUID& q_id, const std::string& name, const LLUUID& task_id, const LLUUID& item_id) :
+ mQueueID(q_id), mScriptName(name), mTaskId(task_id), mItemId(item_id) {}
+
};
///----------------------------------------------------------------------------
/// Class LLFloaterScriptQueue
///----------------------------------------------------------------------------
-// static
-LLMap<LLUUID, LLFloaterScriptQueue*> LLFloaterScriptQueue::sInstances;
-
-
// Default constructor
-LLFloaterScriptQueue::LLFloaterScriptQueue(const std::string& name,
- const LLRect& rect,
- const char* title,
- const char* start_string) :
- LLFloater(name, rect, title,
- RESIZE_YES, DEFAULT_MIN_WIDTH, DEFAULT_MIN_HEIGHT,
- DRAG_ON_TOP, MINIMIZE_YES, CLOSE_YES)
+LLFloaterScriptQueue::LLFloaterScriptQueue(const LLSD& key) :
+ LLFloater(key),
+ mDone(false),
+ mMono(false)
{
-
- LLUICtrlFactory::getInstance()->buildFloater(this,"floater_script_queue.xml");
-
- childSetAction("close",onCloseBtn,this);
- childSetEnabled("close",FALSE);
-
- setTitle(title);
-
- if (!getHost())
- {
- LLRect curRect = getRect();
- translate(rect.mLeft - curRect.mLeft, rect.mTop - curRect.mTop);
- }
-
- mStartString = start_string;
- mDone = FALSE;
- sInstances.addData(mID, this);
+ //Called from floater reg: LLUICtrlFactory::getInstance()->buildFloater(this,"floater_script_queue.xml", FALSE);
}
// Destroys the object
LLFloaterScriptQueue::~LLFloaterScriptQueue()
{
- sInstances.removeData(mID);
}
-// find an instance by ID. Return NULL if it does not exist.
-// static
-LLFloaterScriptQueue* LLFloaterScriptQueue::findInstance(const LLUUID& id)
+BOOL LLFloaterScriptQueue::postBuild()
{
- if(sInstances.checkData(id))
- {
- return sInstances.getData(id);
- }
- return NULL;
+ childSetAction("close",onCloseBtn,this);
+ getChildView("close")->setEnabled(FALSE);
+ return TRUE;
}
-
// This is the callback method for the viewer object currently being
// worked on.
// NOT static, virtual!
void LLFloaterScriptQueue::inventoryChanged(LLViewerObject* viewer_object,
- InventoryObjectList* inv,
+ LLInventoryObject::object_list_t* inv,
S32,
void* q_id)
{
@@ -187,7 +149,7 @@ void LLFloaterScriptQueue::inventoryChanged(LLViewerObject* viewer_object,
void LLFloaterScriptQueue::onCloseBtn(void* user_data)
{
LLFloaterScriptQueue* self = (LLFloaterScriptQueue*)user_data;
- self->close();
+ self->closeFloater();
}
void LLFloaterScriptQueue::addObject(const LLUUID& id)
@@ -198,11 +160,26 @@ void LLFloaterScriptQueue::addObject(const LLUUID& id)
BOOL LLFloaterScriptQueue::start()
{
//llinfos << "LLFloaterCompileQueue::start()" << llendl;
- char buffer[MAX_STRING]; /*Flawfinder: ignore*/
- snprintf(buffer, sizeof(buffer), "Starting %s of %d items.", mStartString, mObjectIDs.count()); /* Flawfinder: ignore */
+ std::string buffer;
+
+ LLSelectMgr *mgr = LLSelectMgr::getInstance();
+ LLObjectSelectionHandle selectHandle = mgr->getSelection();
+ U32 n_objects = 0;
+ if (gSavedSettings.getBOOL("EditLinkedParts"))
+ {
+ n_objects = selectHandle->getObjectCount();
+ }
+ else
+ {
+ n_objects = selectHandle->getRootObjectCount();
+ }
+
+ LLStringUtil::format_map_t args;
+ args["[START]"] = mStartString;
+ args["[COUNT]"] = llformat ("%d", mObjectIDs.count());
+ buffer = getString ("Starting", args);
- LLScrollListCtrl* list = getChild<LLScrollListCtrl>("queue output");
- list->addCommentText(buffer);
+ getChild<LLScrollListCtrl>("queue output")->setCommentText(buffer);
return nextObject();
}
@@ -234,14 +211,9 @@ BOOL LLFloaterScriptQueue::nextObject()
} while((mObjectIDs.count() > 0) && !successful_start);
if(isDone() && !mDone)
{
-
- LLScrollListCtrl* list = getChild<LLScrollListCtrl>("queue output");
-
- mDone = TRUE;
- char buffer[MAX_STRING]; /*Flawfinder: ignore*/
- snprintf(buffer, sizeof(buffer), "Done."); /* Flawfinder: ignore */
- list->addCommentText(buffer);
- childSetEnabled("close",TRUE);
+ mDone = true;
+ getChild<LLScrollListCtrl>("queue output")->setCommentText(getString("Done"));
+ getChildView("close")->setEnabled(TRUE);
}
return successful_start;
}
@@ -265,7 +237,7 @@ BOOL LLFloaterScriptQueue::popNext()
{
llinfos << "LLFloaterScriptQueue::popNext() requesting inv for "
<< mCurrentObjectID << llendl;
- LLUUID* id = new LLUUID(mID);
+ LLUUID* id = new LLUUID(getKey().asUUID());
registerVOInventoryListener(obj,id);
requestVOInventory();
rv = TRUE;
@@ -279,55 +251,76 @@ BOOL LLFloaterScriptQueue::popNext()
/// Class LLFloaterCompileQueue
///----------------------------------------------------------------------------
-// static
-LLFloaterCompileQueue* LLFloaterCompileQueue::create()
+class LLCompileFloaterUploadQueueSupplier : public LLAssetUploadQueueSupplier
{
- S32 left, top;
- gFloaterView->getNewFloaterPosition(&left, &top);
- LLRect rect = gSavedSettings.getRect("CompileOutputRect");
- rect.translate(left - rect.mLeft, top - rect.mTop);
- LLFloaterCompileQueue* new_queue = new LLFloaterCompileQueue("queue",
- rect);
- new_queue->open(); /*Flawfinder: ignore*/
- return new_queue;
-}
+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")->setCommentText(message);
+ }
+
+private:
+ LLUUID mQueueId;
+};
-LLFloaterCompileQueue::LLFloaterCompileQueue(const std::string& name, const LLRect& rect)
-: LLFloaterScriptQueue(name, rect, COMPILE_QUEUE_TITLE, COMPILE_START_STRING)
-{ }
+LLFloaterCompileQueue::LLFloaterCompileQueue(const LLSD& key)
+ : LLFloaterScriptQueue(key)
+{
+ setTitle(LLTrans::getString("CompileQueueTitle"));
+ setStartString(LLTrans::getString("CompileQueueStart"));
+
+ mUploadQueue = new LLAssetUploadQueue(new LLCompileFloaterUploadQueueSupplier(key.asUUID()));
+}
LLFloaterCompileQueue::~LLFloaterCompileQueue()
{
}
void LLFloaterCompileQueue::handleInventory(LLViewerObject *viewer_object,
- InventoryObjectList* inv)
+ LLInventoryObject::object_list_t* inv)
{
// find all of the lsl, leaving off duplicates. We'll remove
// all matching asset uuids on compilation success.
- typedef std::map<LLUUID, LLPointer<LLInventoryItem> > uuid_item_map;
+ typedef std::multimap<LLUUID, LLPointer<LLInventoryItem> > uuid_item_map;
uuid_item_map asset_item_map;
- InventoryObjectList::const_iterator it = inv->begin();
- InventoryObjectList::const_iterator end = inv->end();
+ LLInventoryObject::object_list_t::const_iterator it = inv->begin();
+ LLInventoryObject::object_list_t::const_iterator end = inv->end();
for ( ; it != end; ++it)
{
if((*it)->getType() == LLAssetType::AT_LSL_TEXT)
{
LLInventoryItem* item = (LLInventoryItem*)((LLInventoryObject*)(*it));
// Check permissions before allowing the user to retrieve data.
- if (item->getPermissions().allowModifyBy(gAgent.getID()) &&
- item->getPermissions().allowCopyBy(gAgent.getID()) )
+ if (item->getPermissions().allowModifyBy(gAgent.getID(), gAgent.getGroupID()) &&
+ item->getPermissions().allowCopyBy(gAgent.getID(), gAgent.getGroupID()) )
{
LLPointer<LLViewerInventoryItem> script = new LLViewerInventoryItem(item);
mCurrentScripts.put(script);
-
- if (!asset_item_map.count(item->getAssetUUID()))
- {
- // No entry, put in an entry for this supposedly permissive script
- asset_item_map[item->getAssetUUID()] = item;
- }
+ asset_item_map.insert(std::make_pair(item->getAssetUUID(), item));
}
}
}
@@ -344,7 +337,10 @@ void LLFloaterCompileQueue::handleInventory(LLViewerObject *viewer_object,
for(iter = asset_item_map.begin(); iter != asset_item_map.end(); iter++)
{
LLInventoryItem *itemp = iter->second;
- LLScriptQueueData* datap = new LLScriptQueueData(getID(), itemp->getName().c_str());
+ LLScriptQueueData* datap = new LLScriptQueueData(getKey().asUUID(),
+ itemp->getName(),
+ viewer_object->getID(),
+ itemp->getUUID());
//llinfos << "ITEM NAME 2: " << names.get(i) << llendl;
gAssetStorage->getInvItemAsset(viewer_object->getRegion()->getHost(),
@@ -361,7 +357,6 @@ void LLFloaterCompileQueue::handleInventory(LLViewerObject *viewer_object,
}
}
-
// This is the callback for when each script arrives
// static
void LLFloaterCompileQueue::scriptArrived(LLVFS *vfs, const LLUUID& asset_id,
@@ -370,45 +365,75 @@ void LLFloaterCompileQueue::scriptArrived(LLVFS *vfs, const LLUUID& asset_id,
{
llinfos << "LLFloaterCompileQueue::scriptArrived()" << llendl;
LLScriptQueueData* data = (LLScriptQueueData*)user_data;
- if(!data) return;
- LLFloaterCompileQueue* queue = static_cast<LLFloaterCompileQueue*>
- (LLFloaterScriptQueue::findInstance(data->mQueueID));
- char buffer[MAX_STRING]; /*Flawfinder: ignore*/
- buffer[0] = '\0';
+ if(!data)
+ {
+ return;
+ }
+ LLFloaterCompileQueue* queue = LLFloaterReg::findTypedInstance<LLFloaterCompileQueue>("compile_queue", data->mQueueID);
+
+ std::string buffer;
if(queue && (0 == status))
{
//llinfos << "ITEM NAME 3: " << data->mScriptName << llendl;
// Dump this into a file on the local disk so we can compile it.
- char filename[LL_MAX_PATH] = ""; /*Flawfinder: ignore*/
+ std::string filename;
LLVFile file(vfs, asset_id, type);
- char uuid_str[UUID_STR_LENGTH]; /*Flawfinder: ignore*/
+ std::string uuid_str;
asset_id.toString(uuid_str);
- snprintf(filename, sizeof(filename), "%s.%s",gDirUtilp->getExpandedFilename(LL_PATH_CACHE,uuid_str).c_str(),LLAssetType::lookup(type)); /* Flawfinder: ignore */
-
- LLFILE *fp = LLFile::fopen(filename, "wb"); /*Flawfinder: ignore*/
- if (fp)
+ 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)
{
- const S32 buf_size = 65536;
- U8 copy_buf[buf_size];
- while (file.read(copy_buf, buf_size)) /*Flawfinder: ignore*/
+ 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->mItemId, is_running, queue->mMono, queue->getKey().asUUID(),
+ script_data, script_size, data->mScriptName);
+ }
+ else
{
- if (fwrite(copy_buf, file.getLastBytesRead(), 1, fp) < 1)
+ // It's now in the file, now compile it.
+ buffer = LLTrans::getString("CompileQueueDownloadedCompiling") + (": ") + data->mScriptName;
+
+ // Write script to local file for compilation.
+ LLFILE *fp = LLFile::fopen(filename, "wb"); /*Flawfinder: ignore*/
+ if (fp)
{
- // return a bad file error if we can't write the whole thing
- status = LL_ERR_CANNOT_OPEN_FILE;
+ const S32 buf_size = 65536;
+ U8 copy_buf[buf_size];
+
+ while (file.read(copy_buf, buf_size)) /*Flawfinder: ignore*/
+ {
+ if (fwrite(copy_buf, file.getLastBytesRead(), 1, fp) < 1)
+ {
+ // return a bad file error if we can't write the whole thing
+ status = LL_ERR_CANNOT_OPEN_FILE;
+ }
+ }
+
+ fclose(fp);
+ }
+ else
+ {
+ llerrs << "Unable to find object to compile" << llendl;
}
- }
- fclose(fp);
+ // TODO: babbage: No compile if no cap.
+ queue->compile(filename, data->mItemId);
+
+ // Delete it after we're done compiling?
+ LLFile::remove(filename);
+ }
}
-
- // It's now in the file, now compile it.
- snprintf(buffer, sizeof(buffer), "Downloaded, now compiling '%s'.", data->mScriptName.c_str()); /* Flawfinder: ignore */
- queue->compile(filename, asset_id);
-
- // Delete it after we're done compiling?
- LLFile::remove(filename);
}
else
{
@@ -416,31 +441,31 @@ void LLFloaterCompileQueue::scriptArrived(LLVFS *vfs, const LLUUID& asset_id,
if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status )
{
- LLChat chat("Script not found on server.");
- LLFloaterChat::addChat(chat);
- snprintf(buffer, sizeof(buffer), "Problem downloading %s.", /* Flawfinder: ignore */
- data->mScriptName.c_str());
+ LLSD args;
+ args["MESSAGE"] = LLTrans::getString("CompileQueueScriptNotFound");
+ LLNotificationsUtil::add("SystemMessage", args);
+
+ buffer = LLTrans::getString("CompileQueueProblemDownloading") + (": ") + data->mScriptName;
}
else if (LL_ERR_INSUFFICIENT_PERMISSIONS == status)
{
- LLChat chat("Insufficient permissions to download a script.");
- LLFloaterChat::addChat(chat);
- snprintf(buffer, sizeof(buffer), "Insufficient permissions for '%s'.", /* Flawfinder: ignore */
- data->mScriptName.c_str());
+ LLSD args;
+ args["MESSAGE"] = LLTrans::getString("CompileQueueInsufficientPermDownload");
+ LLNotificationsUtil::add("SystemMessage", args);
+
+ buffer = LLTrans::getString("CompileQueueInsufficientPermFor") + (": ") + data->mScriptName;
}
else
{
- snprintf(buffer, sizeof(buffer), "Unknown failure to download %s.", /* Flawfinder: ignore */
- data->mScriptName.c_str());
+ buffer = LLTrans::getString("CompileQueueUnknownFailure") + (" ") + data->mScriptName;
}
llwarns << "Problem downloading script asset." << llendl;
- if(queue) queue->removeItemByAssetID(asset_id);
+ if(queue) queue->removeItemByItemID(data->mItemId);
}
- if(queue)
+ if(queue && (buffer.size() > 0))
{
- LLScrollListCtrl* list = queue->getChild<LLScrollListCtrl>("queue output");
- list->addCommentText(buffer);
+ queue->getChild<LLScrollListCtrl>("queue output")->setCommentText(buffer);
}
delete data;
}
@@ -452,9 +477,9 @@ void LLFloaterCompileQueue::onSaveTextComplete(const LLUUID& asset_id, void* use
if (status)
{
llwarns << "Unable to save text for script." << llendl;
- LLString::format_map_t args;
- args["[REASON]"] = std::string(LLAssetStorage::getErrorString(status));
- gViewerWindow->alertXml("CompileQueueSaveText", args);
+ LLSD args;
+ args["REASON"] = std::string(LLAssetStorage::getErrorString(status));
+ LLNotificationsUtil::add("CompileQueueSaveText", args);
}
}
@@ -463,67 +488,70 @@ void LLFloaterCompileQueue::onSaveBytecodeComplete(const LLUUID& asset_id, void*
{
llinfos << "LLFloaterCompileQueue::onSaveBytecodeComplete()" << llendl;
LLCompileQueueData* data = (LLCompileQueueData*)user_data;
- LLFloaterCompileQueue* queue = static_cast<LLFloaterCompileQueue*>
- (LLFloaterScriptQueue::findInstance(data->mQueueID));
+ LLFloaterCompileQueue* queue = LLFloaterReg::findTypedInstance<LLFloaterCompileQueue>("compile_queue", data->mQueueID);
if(queue && (0 == status) && data)
{
- queue->updateAssetID(data->mOldAssetID, asset_id);
- queue->saveItemByAssetID(asset_id);
- queue->removeItemByAssetID(asset_id);
+ queue->saveItemByItemID(data->mItemId);
+ queue->removeItemByItemID(data->mItemId);
}
else
{
llwarns << "Unable to save bytecode for script." << llendl;
- LLStringBase<char>::format_map_t args;
- args["[REASON]"] = std::string(LLAssetStorage::getErrorString(status));
- gViewerWindow->alertXml("CompileQueueSaveBytecode", args);
+ LLSD args;
+ args["REASON"] = std::string(LLAssetStorage::getErrorString(status));
+ LLNotificationsUtil::add("CompileQueueSaveBytecode", args);
}
delete data;
data = NULL;
}
// compile the file given and save it out.
-void LLFloaterCompileQueue::compile(const char* filename,
- const LLUUID& asset_id)
+void LLFloaterCompileQueue::compile(const std::string& filename,
+ const LLUUID& item_id)
{
LLUUID new_asset_id;
LLTransactionID tid;
tid.generate();
new_asset_id = tid.makeAssetID(gAgent.getSecureSessionID());
- char uuid_string[UUID_STR_LENGTH]; /*Flawfinder: ignore*/
+ std::string uuid_string;
new_asset_id.toString(uuid_string);
- char dst_filename[LL_MAX_PATH]; /*Flawfinder: ignore*/
- snprintf(dst_filename, sizeof(dst_filename), "%s.lso", gDirUtilp->getExpandedFilename(LL_PATH_CACHE,uuid_string).c_str()); /* Flawfinder: ignore */
- char err_filename[LL_MAX_PATH]; /*Flawfinder: ignore*/
- snprintf(err_filename, sizeof(err_filename), "%s.out", gDirUtilp->getExpandedFilename(LL_PATH_CACHE,uuid_string).c_str()); /* Flawfinder: ignore */
+ std::string dst_filename;
+ dst_filename = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,uuid_string) + ".lso";
+ std::string err_filename;
+ err_filename = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,uuid_string) + ".out";
gAssetStorage->storeAssetData(filename, tid,
LLAssetType::AT_LSL_TEXT,
&onSaveTextComplete, NULL, FALSE);
- if(!lscript_compile(filename, dst_filename, err_filename, gAgent.isGodlike()))
+
+ const BOOL compile_to_mono = FALSE;
+ if(!lscript_compile(filename.c_str(), dst_filename.c_str(),
+ err_filename.c_str(), compile_to_mono,
+ uuid_string.c_str(), gAgent.isGodlike()))
{
llwarns << "compile failed" << llendl;
- removeItemByAssetID(asset_id);
+ removeItemByItemID(item_id);
}
else
{
llinfos << "compile successful." << llendl;
- // Save the bytecode
- LLCompileQueueData* data = new LLCompileQueueData(mID, asset_id);
- gAssetStorage->storeAssetData(dst_filename, tid,
- LLAssetType::AT_LSL_BYTECODE,
- &onSaveBytecodeComplete,
- (void*)data, FALSE);
+
+ // Save LSL bytecode
+ LLCompileQueueData* data = new LLCompileQueueData(getKey().asUUID(), item_id);
+ gAssetStorage->storeAssetData(dst_filename, new_asset_id,
+ LLAssetType::AT_LSL_BYTECODE,
+ &LLFloaterCompileQueue::onSaveBytecodeComplete,
+ (void*)data, FALSE);
}
}
-void LLFloaterCompileQueue::removeItemByAssetID(const LLUUID& asset_id)
+void LLFloaterCompileQueue::removeItemByItemID(const LLUUID& asset_id)
{
llinfos << "LLFloaterCompileQueue::removeItemByAssetID()" << llendl;
for(S32 i = 0; i < mCurrentScripts.count(); )
{
- if(asset_id == mCurrentScripts.get(i)->getAssetUUID())
+ if(asset_id == mCurrentScripts.get(i)->getUUID())
{
mCurrentScripts.remove(i);
}
@@ -538,7 +566,21 @@ void LLFloaterCompileQueue::removeItemByAssetID(const LLUUID& asset_id)
}
}
-void LLFloaterCompileQueue::saveItemByAssetID(const LLUUID& asset_id)
+const LLInventoryItem* LLFloaterCompileQueue::findItemByItemID(const LLUUID& asset_id) const
+{
+ LLInventoryItem* result = NULL;
+ S32 count = mCurrentScripts.count();
+ for(S32 i = 0; i < count; ++i)
+ {
+ if(asset_id == mCurrentScripts.get(i)->getUUID())
+ {
+ result = mCurrentScripts.get(i);
+ }
+ }
+ return result;
+}
+
+void LLFloaterCompileQueue::saveItemByItemID(const LLUUID& asset_id)
{
llinfos << "LLFloaterCompileQueue::saveItemByAssetID()" << llendl;
LLViewerObject* viewer_object = gObjectList.findObject(mCurrentObjectID);
@@ -547,7 +589,7 @@ void LLFloaterCompileQueue::saveItemByAssetID(const LLUUID& asset_id)
S32 count = mCurrentScripts.count();
for(S32 i = 0; i < count; ++i)
{
- if(asset_id == mCurrentScripts.get(i)->getAssetUUID())
+ if(asset_id == mCurrentScripts.get(i)->getUUID())
{
// *FIX: this auto-resets active to TRUE. That might
// be a bad idea.
@@ -561,54 +603,30 @@ void LLFloaterCompileQueue::saveItemByAssetID(const LLUUID& asset_id)
}
}
-// find old_asst_id, and set the asset id to new_asset_id
-void LLFloaterCompileQueue::updateAssetID(const LLUUID& old_asset_id,
- const LLUUID& new_asset_id)
-{
- S32 count = mCurrentScripts.count();
- for(S32 i = 0; i < count; ++i)
- {
- if(old_asset_id == mCurrentScripts.get(i)->getAssetUUID())
- {
- mCurrentScripts.get(i)->setAssetUUID(new_asset_id);
- }
- }
-}
-
///----------------------------------------------------------------------------
/// Class LLFloaterResetQueue
///----------------------------------------------------------------------------
-// static
-LLFloaterResetQueue* LLFloaterResetQueue::create()
+LLFloaterResetQueue::LLFloaterResetQueue(const LLSD& key)
+ : LLFloaterScriptQueue(key)
{
- S32 left, top;
- gFloaterView->getNewFloaterPosition(&left, &top);
- LLRect rect = gSavedSettings.getRect("CompileOutputRect");
- rect.translate(left - rect.mLeft, top - rect.mTop);
- LLFloaterResetQueue* new_queue = new LLFloaterResetQueue("queue",
- rect);
- new_queue->open(); /*Flawfinder: ignore*/
- return new_queue;
+ setTitle(LLTrans::getString("ResetQueueTitle"));
+ setStartString(LLTrans::getString("ResetQueueStart"));
}
-LLFloaterResetQueue::LLFloaterResetQueue(const std::string& name, const LLRect& rect)
-: LLFloaterScriptQueue(name, rect, RESET_QUEUE_TITLE, RESET_START_STRING)
-{ }
-
LLFloaterResetQueue::~LLFloaterResetQueue()
{
}
void LLFloaterResetQueue::handleInventory(LLViewerObject* viewer_obj,
- InventoryObjectList* inv)
+ LLInventoryObject::object_list_t* inv)
{
// find all of the lsl, leaving off duplicates. We'll remove
// all matching asset uuids on compilation success.
LLDynamicArray<const char*> names;
- InventoryObjectList::const_iterator it = inv->begin();
- InventoryObjectList::const_iterator end = inv->end();
+ LLInventoryObject::object_list_t::const_iterator it = inv->begin();
+ LLInventoryObject::object_list_t::const_iterator end = inv->end();
for ( ; it != end; ++it)
{
if((*it)->getType() == LLAssetType::AT_LSL_TEXT)
@@ -618,10 +636,9 @@ void LLFloaterResetQueue::handleInventory(LLViewerObject* viewer_obj,
if (object)
{
LLInventoryItem* item = (LLInventoryItem*)((LLInventoryObject*)(*it));
- LLScrollListCtrl* list = getChild<LLScrollListCtrl>("queue output");
- char buffer[MAX_STRING]; /*Flawfinder: ignore*/
- snprintf(buffer, sizeof(buffer), "Resetting '%s'.", item->getName().c_str()); /* Flawfinder: ignore */
- list->addCommentText(buffer);
+ std::string buffer;
+ buffer = getString("Resetting") + (": ") + item->getName();
+ getChild<LLScrollListCtrl>("queue output")->setCommentText(buffer);
LLMessageSystem* msg = gMessageSystem;
msg->newMessageFast(_PREHASH_ScriptReset);
msg->nextBlockFast(_PREHASH_AgentData);
@@ -642,36 +659,26 @@ void LLFloaterResetQueue::handleInventory(LLViewerObject* viewer_obj,
/// Class LLFloaterRunQueue
///----------------------------------------------------------------------------
-// static
-LLFloaterRunQueue* LLFloaterRunQueue::create()
+LLFloaterRunQueue::LLFloaterRunQueue(const LLSD& key)
+ : LLFloaterScriptQueue(key)
{
- S32 left, top;
- gFloaterView->getNewFloaterPosition(&left, &top);
- LLRect rect = gSavedSettings.getRect("CompileOutputRect");
- rect.translate(left - rect.mLeft, top - rect.mTop);
- LLFloaterRunQueue* new_queue = new LLFloaterRunQueue("queue",
- rect);
- new_queue->open(); /*Flawfinder: ignore*/
- return new_queue;
+ setTitle(LLTrans::getString("RunQueueTitle"));
+ setStartString(LLTrans::getString("RunQueueStart"));
}
-LLFloaterRunQueue::LLFloaterRunQueue(const std::string& name, const LLRect& rect)
-: LLFloaterScriptQueue(name, rect, RUN_QUEUE_TITLE, RUN_START_STRING)
-{ }
-
LLFloaterRunQueue::~LLFloaterRunQueue()
{
}
void LLFloaterRunQueue::handleInventory(LLViewerObject* viewer_obj,
- InventoryObjectList* inv)
+ LLInventoryObject::object_list_t* inv)
{
// find all of the lsl, leaving off duplicates. We'll remove
// all matching asset uuids on compilation success.
LLDynamicArray<const char*> names;
- InventoryObjectList::const_iterator it = inv->begin();
- InventoryObjectList::const_iterator end = inv->end();
+ LLInventoryObject::object_list_t::const_iterator it = inv->begin();
+ LLInventoryObject::object_list_t::const_iterator end = inv->end();
for ( ; it != end; ++it)
{
if((*it)->getType() == LLAssetType::AT_LSL_TEXT)
@@ -682,9 +689,9 @@ void LLFloaterRunQueue::handleInventory(LLViewerObject* viewer_obj,
{
LLInventoryItem* item = (LLInventoryItem*)((LLInventoryObject*)(*it));
LLScrollListCtrl* list = getChild<LLScrollListCtrl>("queue output");
- char buffer[MAX_STRING]; /*Flawfinder: ignore*/
- snprintf(buffer, sizeof(buffer), "Running '%s'.", item->getName().c_str()); /* Flawfinder: ignore */
- list->addCommentText(buffer);
+ std::string buffer;
+ buffer = getString("Running") + (": ") + item->getName();
+ list->setCommentText(buffer);
LLMessageSystem* msg = gMessageSystem;
msg->newMessageFast(_PREHASH_SetScriptRunning);
@@ -707,36 +714,26 @@ void LLFloaterRunQueue::handleInventory(LLViewerObject* viewer_obj,
/// Class LLFloaterNotRunQueue
///----------------------------------------------------------------------------
-// static
-LLFloaterNotRunQueue* LLFloaterNotRunQueue::create()
+LLFloaterNotRunQueue::LLFloaterNotRunQueue(const LLSD& key)
+ : LLFloaterScriptQueue(key)
{
- S32 left, top;
- gFloaterView->getNewFloaterPosition(&left, &top);
- LLRect rect = gSavedSettings.getRect("CompileOutputRect");
- rect.translate(left - rect.mLeft, top - rect.mTop);
- LLFloaterNotRunQueue* new_queue = new LLFloaterNotRunQueue("queue",
- rect);
- new_queue->open(); /*Flawfinder: ignore*/
- return new_queue;
+ setTitle(LLTrans::getString("NotRunQueueTitle"));
+ setStartString(LLTrans::getString("NotRunQueueStart"));
}
-LLFloaterNotRunQueue::LLFloaterNotRunQueue(const std::string& name, const LLRect& rect)
-: LLFloaterScriptQueue(name, rect, NOT_RUN_QUEUE_TITLE, NOT_RUN_START_STRING)
-{ }
-
LLFloaterNotRunQueue::~LLFloaterNotRunQueue()
{
}
void LLFloaterNotRunQueue::handleInventory(LLViewerObject* viewer_obj,
- InventoryObjectList* inv)
+ LLInventoryObject::object_list_t* inv)
{
// find all of the lsl, leaving off duplicates. We'll remove
// all matching asset uuids on compilation success.
LLDynamicArray<const char*> names;
- InventoryObjectList::const_iterator it = inv->begin();
- InventoryObjectList::const_iterator end = inv->end();
+ LLInventoryObject::object_list_t::const_iterator it = inv->begin();
+ LLInventoryObject::object_list_t::const_iterator end = inv->end();
for ( ; it != end; ++it)
{
if((*it)->getType() == LLAssetType::AT_LSL_TEXT)
@@ -747,9 +744,9 @@ void LLFloaterNotRunQueue::handleInventory(LLViewerObject* viewer_obj,
{
LLInventoryItem* item = (LLInventoryItem*)((LLInventoryObject*)(*it));
LLScrollListCtrl* list = getChild<LLScrollListCtrl>("queue output");
- char buffer[MAX_STRING]; /*Flawfinder: ignore*/
- snprintf(buffer, sizeof(buffer), "Not running '%s'.", item->getName().c_str()); /* Flawfinder: ignore */
- list->addCommentText(buffer);
+ std::string buffer;
+ buffer = getString("NotRunning") + (": ") +item->getName();
+ list->setCommentText(buffer);
LLMessageSystem* msg = gMessageSystem;
msg->newMessageFast(_PREHASH_SetScriptRunning);