Sync LLCompileQueue, fix compile (...queue)

This commit is contained in:
Lirusaito
2016-03-31 05:05:13 -04:00
parent 2653567d82
commit 3e4f099ef2
2 changed files with 100 additions and 159 deletions

View File

@@ -50,13 +50,13 @@
#include "llviewerobject.h"
#include "llviewerobjectlist.h"
#include "llviewerregion.h"
//#include "lscript_rt_interface.h"
#include "llviewercontrol.h"
#include "llviewerobject.h"
#include "llviewerregion.h"
#include "llresmgr.h"
#include "llbutton.h"
#include "llscrolllistctrl.h"
#include "lldir.h"
#include "llnotificationsutil.h"
#include "llfloaterchat.h"
@@ -66,6 +66,9 @@
#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
///----------------------------------------------------------------------------
@@ -105,15 +108,10 @@ LLFloaterScriptQueue::LLFloaterScriptQueue(const std::string& name,
mID.generate();
LLUICtrlFactory::getInstance()->buildFloater(this,"floater_script_queue.xml");
childSetAction("close",onCloseBtn,this);
childSetEnabled("close",FALSE);
setTitle(title);
LLRect curRect = getRect();
translate(rect.mLeft - curRect.mLeft, rect.mTop - curRect.mTop);
mStartString = start_string;
sInstances.addData(mID, this);
}
@@ -124,18 +122,20 @@ LLFloaterScriptQueue::~LLFloaterScriptQueue()
sInstances.removeData(mID);
}
BOOL LLFloaterScriptQueue::postBuild()
{
childSetAction("close",onCloseBtn,this);
getChildView("close")->setEnabled(FALSE);
return TRUE;
}
// find an instance by ID. Return NULL if it does not exist.
// static
LLFloaterScriptQueue* LLFloaterScriptQueue::findInstance(const LLUUID& id)
{
if(sInstances.checkData(id))
{
return sInstances.getData(id);
}
return NULL;
return sInstances.checkData(id)? sInstances.getData(id) : NULL
}
// This is the callback method for the viewer object currently being
// worked on.
// NOT static, virtual!
@@ -191,7 +191,6 @@ void LLFloaterScriptQueue::addObject(const LLUUID& id)
BOOL LLFloaterScriptQueue::start()
{
//LL_INFOS() << "LLFloaterCompileQueue::start()" << LL_ENDL;
std::string buffer;
LLStringUtil::format_map_t args;
@@ -201,7 +200,7 @@ BOOL LLFloaterScriptQueue::start()
getChild<LLScrollListCtrl>("queue output")->addSimpleElement(buffer, ADD_BOTTOM);
return nextObject();
return startQueue();
}
BOOL LLFloaterScriptQueue::isDone() const
@@ -266,6 +265,42 @@ BOOL LLFloaterScriptQueue::popNext()
return rv;
}
BOOL LLFloaterScriptQueue::startQueue()
{
return nextObject();
}
/* Singu TODO: Experiences
class CompileQueueExperienceResponder : public LLHTTPClient::ResponderWithResult
{
public:
CompileQueueExperienceResponder(const LLUUID& parent):mParent(parent)
{
}
LLUUID mParent;
/*virtual*/ void httpSuccess()
{
sendResult(getContent());
}
/*virtual*/ void httpFailure()
{
sendResult(LLSD());
}
void sendResult(const LLSD& content)
{
LLFloaterCompileQueue* queue = (LLFloaterCompileQueue*) LLFloaterScriptQueue::findInstance(mParent);
if(!queue)
return;
queue->experienceIdsReceived(content["experience_ids"]);
}
/*virtual*/ char const* getName() const { return "RequiredRubbish"; }
};
*/
///----------------------------------------------------------------------------
/// Class LLFloaterCompileQueue
@@ -306,7 +341,7 @@ private:
};
// static
LLFloaterCompileQueue* LLFloaterCompileQueue::create(BOOL mono)
LLFloaterCompileQueue* LLFloaterCompileQueue::create(bool mono)
{
S32 left, top;
gFloaterView->getNewFloaterPosition(&left, &top);
@@ -315,7 +350,7 @@ LLFloaterCompileQueue* LLFloaterCompileQueue::create(BOOL mono)
LLFloaterCompileQueue* new_queue = new LLFloaterCompileQueue("queue", rect);
new_queue->mUploadQueue = new LLAssetUploadQueue(new LLCompileFloaterUploadQueueSupplier(new_queue->getID()));
new_queue->mMono = mono;
new_queue->setMono(mono);
new_queue->open();
return new_queue;
}
@@ -387,6 +422,7 @@ 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,
@@ -395,7 +431,10 @@ void LLFloaterCompileQueue::scriptArrived(LLVFS *vfs, const LLUUID& asset_id,
{
LL_INFOS() << "LLFloaterCompileQueue::scriptArrived()" << LL_ENDL;
LLScriptQueueData* data = (LLScriptQueueData*)user_data;
if(!data) return;
if(!data)
{
return;
}
LLFloaterCompileQueue* queue = static_cast<LLFloaterCompileQueue*> (LLFloaterScriptQueue::findInstance(data->mQueueID));
std::string buffer;
@@ -423,8 +462,8 @@ void LLFloaterCompileQueue::scriptArrived(LLVFS *vfs, const LLUUID& asset_id,
file.read(script_data, script_size);
queue->mUploadQueue->queue(filename, data->mTaskId,
data->mItemId, is_running, queue->mMono, queue->getID(),
script_data, script_size, data->mScriptName);
data->mItemId, is_running, queue->mMono, queue->getID(),
script_data, script_size, data->mScriptName);
}
else
{
@@ -435,42 +474,6 @@ void LLFloaterCompileQueue::scriptArrived(LLVFS *vfs, const LLUUID& asset_id,
LL_WARNS() << "Problem uploading script asset." << LL_ENDL;
if(queue) queue->removeItemByItemID(data->mItemId);
}
#if 0 //Client side compiling disabled.
else
{
// 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)
{
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
{
LL_ERRS() << "Unable to find object to compile" << LL_ENDL;
}
// TODO: babbage: No compile if no cap.
queue->compile(filename, data->mItemId);
// Delete it after we're done compiling?
LLFile::remove(filename);
}
#endif
}
}
else
@@ -506,83 +509,6 @@ void LLFloaterCompileQueue::scriptArrived(LLVFS *vfs, const LLUUID& asset_id,
delete data;
}
#if 0 //Client side compiling disabled.
// static
void LLFloaterCompileQueue::onSaveTextComplete(const LLUUID& asset_id, void* user_data, S32 status, LLExtStat ext_status) // StoreAssetData callback (fixed)
{
LL_INFOS() << "LLFloaterCompileQueue::onSaveTextComplete()" << LL_ENDL;
if (status)
{
LL_WARNS() << "Unable to save text for script." << LL_ENDL;
LLSD args;
args["REASON"] = std::string(LLAssetStorage::getErrorString(status));
LLNotificationsUtil::add("CompileQueueSaveText", args);
}
}
// static
void LLFloaterCompileQueue::onSaveBytecodeComplete(const LLUUID& asset_id, void* user_data, S32 status, LLExtStat ext_status) // StoreAssetData callback (fixed)
{
LL_INFOS() << "LLFloaterCompileQueue::onSaveBytecodeComplete()" << LL_ENDL;
LLCompileQueueData* data = (LLCompileQueueData*)user_data;
LLFloaterCompileQueue* queue = static_cast<LLFloaterCompileQueue*> (LLFloaterScriptQueue::findInstance(data->mQueueID));
if(queue && (0 == status) && data)
{
queue->saveItemByItemID(data->mItemId);
queue->removeItemByItemID(data->mItemId);
}
else
{
LL_WARNS() << "Unable to save bytecode for script." << LL_ENDL;
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 std::string& filename,
const LLUUID& item_id)
{
LLUUID new_asset_id;
LLTransactionID tid;
tid.generate();
new_asset_id = tid.makeAssetID(gAgent.getSecureSessionID());
std::string uuid_string;
new_asset_id.toString(uuid_string);
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);
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()))
{
LL_WARNS() << "compile failed" << LL_ENDL;
removeItemByItemID(item_id);
}
else
{
LL_INFOS() << "compile successful." << LL_ENDL;
// Save LSL bytecode
LLCompileQueueData* data = new LLCompileQueueData(mID, item_id);
gAssetStorage->storeAssetData(dst_filename, new_asset_id,
LLAssetType::AT_LSL_BYTECODE,
&LLFloaterCompileQueue::onSaveBytecodeComplete,
(void*)data, FALSE);
}
}
#endif
const LLInventoryItem* LLFloaterCompileQueue::findItemByItemID(const LLUUID& asset_id) const
{
@@ -651,7 +577,6 @@ void LLFloaterResetQueue::handleInventory(LLViewerObject* viewer_obj,
{
// find all of the lsl, leaving off duplicates. We'll remove
// all matching asset uuids on compilation success.
std::vector<const char*> names;
LLInventoryObject::object_list_t::const_iterator it = inv->begin();
LLInventoryObject::object_list_t::const_iterator end = inv->end();
@@ -712,8 +637,6 @@ void LLFloaterRunQueue::handleInventory(LLViewerObject* viewer_obj,
{
// find all of the lsl, leaving off duplicates. We'll remove
// all matching asset uuids on compilation success.
std::vector<const char*> names;
LLInventoryObject::object_list_t::const_iterator it = inv->begin();
LLInventoryObject::object_list_t::const_iterator end = inv->end();
for ( ; it != end; ++it)
@@ -791,13 +714,29 @@ void LLFloaterCompileQueue::removeItemByItemID(const LLUUID& asset_id)
}
}
BOOL LLFloaterCompileQueue::startQueue()
{
/* Singu TODO: Experiences
LLViewerRegion* region = gAgent.getRegion();
if (region)
{
std::string lookup_url=region->getCapability("GetCreatorExperiences");
if(!lookup_url.empty())
{
LLHTTPClient::get(lookup_url, new CompileQueueExperienceResponder(getKey().asUUID()));
return TRUE;
}
}*/
return nextObject();
}
void LLFloaterNotRunQueue::handleInventory(LLViewerObject* viewer_obj,
LLInventoryObject::object_list_t* inv)
{
// find all of the lsl, leaving off duplicates. We'll remove
// all matching asset uuids on compilation success.
std::vector<const char*> names;
LLInventoryObject::object_list_t::const_iterator it = inv->begin();
LLInventoryObject::object_list_t::const_iterator end = inv->end();
for ( ; it != end; ++it)

View File

@@ -40,10 +40,11 @@
#include "lluuid.h"
#include "llfloater.h"
#include "llscrolllistctrl.h"
#include "llviewerinventory.h"
class LLScrollListCtrl;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Class LLFloaterScriptQueue
//
@@ -58,20 +59,23 @@
class LLFloaterScriptQueue : public LLFloater, public LLVOInventoryListener
{
public:
// find an instance by ID. Return NULL if it does not exist.
static LLFloaterScriptQueue* findInstance(const LLUUID& id);
LLFloaterScriptQueue(const std::string& name, const LLRect& rect,
const std::string& title, const std::string& start_string);
virtual ~LLFloaterScriptQueue();
/*virtual*/ BOOL postBuild();
void setMono(bool mono) { mMono = mono; }
// addObject() accepts an object id.
void addObject(const LLUUID& id);
// start() returns TRUE if the queue has started, otherwise FALSE.
BOOL start();
// find an instance by ID. Return NULL if it does not exist.
static LLFloaterScriptQueue* findInstance(const LLUUID& id);
protected:
LLFloaterScriptQueue(const std::string& name, const LLRect& rect,
const std::string& title, const std::string& start_string);
virtual ~LLFloaterScriptQueue();
// This is the callback method for the viewer object currently
// being worked on.
/*virtual*/ void inventoryChanged(LLViewerObject* obj,
@@ -88,12 +92,16 @@ protected:
// returns true if this is done
BOOL isDone() const;
virtual BOOL startQueue();
// go to the next object. If no objects left, it falls out
// silently and waits to be killed by the deleteIfDone() callback.
BOOL nextObject();
BOOL popNext();
// Get this instances ID.
void setStartString(const std::string& s) { mStartString = s; }
// Get this instance's ID.
const LLUUID& getID() const { return mID; }
protected:
@@ -110,6 +118,7 @@ protected:
static LLMap<LLUUID, LLFloaterScriptQueue*> sInstances;
std::string mStartString;
bool mMono;
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -133,13 +142,16 @@ class LLFloaterCompileQueue : public LLFloaterScriptQueue
public:
// Use this method to create a compile queue. Once created, it
// will be responsible for it's own destruction.
static LLFloaterCompileQueue* create(BOOL mono);
static LLFloaterCompileQueue* create(bool mono);
// remove any object in mScriptScripts with the matching uuid.
void removeItemByItemID(const LLUUID& item_id);
LLAssetUploadQueue* getUploadQueue() { return mUploadQueue; }
void experienceIdsReceived( const LLSD& content );
BOOL hasExperience(const LLUUID& id)const;
protected:
LLFloaterCompileQueue(const std::string& name, const LLRect& rect);
virtual ~LLFloaterCompileQueue();
@@ -152,17 +164,6 @@ protected:
static void scriptArrived(LLVFS *vfs, const LLUUID& asset_id,
LLAssetType::EType type,
void* user_data, S32 status, LLExtStat ext_status);
#if 0 //Client side compiling disabled.
static void onSaveTextComplete(const LLUUID& asset_id, void* user_data, S32 status, LLExtStat ext_status);
static void onSaveBytecodeComplete(const LLUUID& asset_id,
void* user_data,
S32 status, LLExtStat ext_status);
// compile the file given and save it out.
void compile(const std::string& filename, const LLUUID& asset_id);
#endif
// remove any object in mScriptScripts with the matching uuid.
void removeItemByAssetID(const LLUUID& asset_id);
@@ -173,12 +174,13 @@ protected:
// find InventoryItem given item id.
const LLInventoryItem* findItemByItemID(const LLUUID& item_id) const;
virtual BOOL startQueue();
protected:
LLViewerInventoryItem::item_array_t mCurrentScripts;
private:
BOOL mMono; // Compile to mono.
LLAssetUploadQueue* mUploadQueue;
uuid_list_t mExperienceIds;
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~