summaryrefslogtreecommitdiff
path: root/indra/newview/llpreviewscript.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llpreviewscript.cpp')
-rw-r--r--[-rwxr-xr-x]indra/newview/llpreviewscript.cpp408
1 files changed, 2 insertions, 406 deletions
diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp
index 98e0272300..5b1b356597 100755..100644
--- a/indra/newview/llpreviewscript.cpp
+++ b/indra/newview/llpreviewscript.cpp
@@ -52,7 +52,6 @@
#include "llscrolllistcell.h"
#include "llsdserialize.h"
#include "llslider.h"
-#include "lscript_rt_interface.h"
#include "lltooldraganddrop.h"
#include "llvfile.h"
@@ -1688,194 +1687,9 @@ void LLPreviewLSL::saveIfNeeded(bool sync /*= true*/)
LLViewerAssetUpload::EnqueueInventoryUpload(url, uploadInfo);
}
- else if (gAssetStorage)
- {
- // save off asset into file
- LLTransactionID tid;
- tid.generate();
- LLAssetID asset_id = tid.makeAssetID(gAgent.getSecureSessionID());
- std::string filepath = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, asset_id.asString());
- std::string filename = filepath + ".lsl";
-
- mScriptEd->writeToFile(filename);
-
- uploadAssetLegacy(filename, mItemUUID, tid);
- }
}
}
-void LLPreviewLSL::uploadAssetLegacy(const std::string& filename,
- const LLUUID& item_id,
- const LLTransactionID& tid)
-{
- LLLineEditor* descEditor = getChild<LLLineEditor>("desc");
- LLScriptSaveInfo* info = new LLScriptSaveInfo(item_id,
- descEditor->getText(),
- tid);
- gAssetStorage->storeAssetData(filename, tid,
- LLAssetType::AT_LSL_TEXT,
- &LLPreviewLSL::onSaveComplete,
- info);
-
- LLAssetID asset_id = tid.makeAssetID(gAgent.getSecureSessionID());
- std::string filepath = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,asset_id.asString());
- std::string dst_filename = llformat("%s.lso", filepath.c_str());
- std::string err_filename = llformat("%s.out", filepath.c_str());
-
- const BOOL compile_to_mono = FALSE;
- if(!lscript_compile(filename.c_str(),
- dst_filename.c_str(),
- err_filename.c_str(),
- compile_to_mono,
- asset_id.asString().c_str(),
- gAgent.isGodlike()))
- {
- LL_INFOS() << "Compile failed!" << LL_ENDL;
- //char command[256];
- //sprintf(command, "type %s\n", err_filename.c_str());
- //system(command);
-
- // load the error file into the error scrolllist
- LLFILE* fp = LLFile::fopen(err_filename, "r");
- if(fp)
- {
- char buffer[MAX_STRING]; /*Flawfinder: ignore*/
- std::string line;
- while(!feof(fp))
- {
- if (fgets(buffer, MAX_STRING, fp) == NULL)
- {
- buffer[0] = '\0';
- }
- if(feof(fp))
- {
- break;
- }
- else
- {
- line.assign(buffer);
- LLStringUtil::stripNonprintable(line);
-
- LLSD row;
- row["columns"][0]["value"] = line;
- row["columns"][0]["font"] = "OCRA";
- mScriptEd->mErrorList->addElement(row);
- }
- }
- fclose(fp);
- mScriptEd->selectFirstError();
- }
- }
- else
- {
- LL_INFOS() << "Compile worked!" << LL_ENDL;
- if(gAssetStorage)
- {
- getWindow()->incBusyCount();
- mPendingUploads++;
- LLUUID* this_uuid = new LLUUID(mItemUUID);
- gAssetStorage->storeAssetData(dst_filename,
- tid,
- LLAssetType::AT_LSL_BYTECODE,
- &LLPreviewLSL::onSaveBytecodeComplete,
- (void**)this_uuid);
- }
- }
-
- // get rid of any temp files left lying around
- LLFile::remove(filename);
- LLFile::remove(err_filename);
- LLFile::remove(dst_filename);
-}
-
-
-// static
-void LLPreviewLSL::onSaveComplete(const LLUUID& asset_uuid, void* user_data, S32 status, LLExtStat ext_status) // StoreAssetData callback (fixed)
-{
- LLScriptSaveInfo* info = reinterpret_cast<LLScriptSaveInfo*>(user_data);
- if(0 == status)
- {
- if (info)
- {
- const LLViewerInventoryItem* item;
- item = (const LLViewerInventoryItem*)gInventory.getItem(info->mItemUUID);
- if(item)
- {
- LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem(item);
- new_item->setAssetUUID(asset_uuid);
- new_item->setTransactionID(info->mTransactionID);
- new_item->updateServer(FALSE);
- gInventory.updateItem(new_item);
- gInventory.notifyObservers();
- }
- else
- {
- LL_WARNS() << "Inventory item for script " << info->mItemUUID
- << " is no longer in agent inventory." << LL_ENDL;
- }
-
- // Find our window and close it if requested.
- LLPreviewLSL* self = LLFloaterReg::findTypedInstance<LLPreviewLSL>("preview_script", info->mItemUUID);
- if (self)
- {
- getWindow()->decBusyCount();
- self->mPendingUploads--;
- if (self->mPendingUploads <= 0
- && self->mCloseAfterSave)
- {
- self->closeFloater();
- }
- }
- }
- }
- else
- {
- LL_WARNS() << "Problem saving script: " << status << LL_ENDL;
- LLSD args;
- args["REASON"] = std::string(LLAssetStorage::getErrorString(status));
- LLNotificationsUtil::add("SaveScriptFailReason", args);
- }
- delete info;
-}
-
-// static
-void LLPreviewLSL::onSaveBytecodeComplete(const LLUUID& asset_uuid, void* user_data, S32 status, LLExtStat ext_status) // StoreAssetData callback (fixed)
-{
- LLUUID* instance_uuid = (LLUUID*)user_data;
- LLPreviewLSL* self = NULL;
- if(instance_uuid)
- {
- self = LLFloaterReg::findTypedInstance<LLPreviewLSL>("preview_script", *instance_uuid);
- }
- if (0 == status)
- {
- if (self)
- {
- LLSD row;
- row["columns"][0]["value"] = "Compile successful!";
- row["columns"][0]["font"] = "SANSSERIF_SMALL";
- self->mScriptEd->mErrorList->addElement(row);
-
- // Find our window and close it if requested.
- self->getWindow()->decBusyCount();
- self->mPendingUploads--;
- if (self->mPendingUploads <= 0
- && self->mCloseAfterSave)
- {
- self->closeFloater();
- }
- }
- }
- else
- {
- LL_WARNS() << "Problem saving LSL Bytecode (Preview)" << LL_ENDL;
- LLSD args;
- args["REASON"] = std::string(LLAssetStorage::getErrorString(status));
- LLNotificationsUtil::add("SaveBytecodeFailReason", args);
- }
- delete instance_uuid;
-}
-
// static
void LLPreviewLSL::onLoadComplete( LLVFS *vfs, const LLUUID& asset_uuid, LLAssetType::EType type,
void* user_data, S32 status, LLExtStat ext_status)
@@ -2258,23 +2072,6 @@ void LLLiveLSLEditor::draw()
{
runningCheckbox->setLabel(getString("script_running"));
runningCheckbox->setEnabled(!mIsSaving);
-
- if(object->permAnyOwner())
- {
- runningCheckbox->setLabel(getString("script_running"));
- runningCheckbox->setEnabled(!mIsSaving);
- }
- else
- {
- runningCheckbox->setLabel(getString("public_objects_can_not_run"));
- runningCheckbox->setEnabled(FALSE);
- // *FIX: Set it to false so that the ui is correct for
- // a box that is released to public. It could be
- // incorrect after a release/claim cycle, but will be
- // correct after clicking on it.
- runningCheckbox->set(FALSE);
- mMonoCheckbox->set(FALSE);
- }
}
else
{
@@ -2286,9 +2083,7 @@ void LLLiveLSLEditor::draw()
// incorrect after a release/claim cycle, but will be
// correct after clicking on it.
runningCheckbox->set(FALSE);
- mMonoCheckbox->setEnabled(FALSE);
- // object may have fallen out of range.
- mHaveRunningInfo = FALSE;
+ mMonoCheckbox->set(FALSE);
}
}
else if(!object)
@@ -2297,6 +2092,7 @@ void LLLiveLSLEditor::draw()
// Really ought to put in main window.
setTitle(LLTrans::getString("ObjectOutOfRange"));
runningCheckbox->setEnabled(FALSE);
+ mMonoCheckbox->setEnabled(FALSE);
// object may have fallen out of range.
mHaveRunningInfo = FALSE;
}
@@ -2421,206 +2217,6 @@ void LLLiveLSLEditor::saveIfNeeded(bool sync /*= true*/)
LLViewerAssetUpload::EnqueueInventoryUpload(url, uploadInfo);
}
- else if (gAssetStorage)
- {
- // set up the save on the local machine.
- LLTransactionID tid;
- tid.generate();
- LLAssetID asset_id = tid.makeAssetID(gAgent.getSecureSessionID());
- std::string filepath = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, asset_id.asString());
- std::string filename = llformat("%s.lsl", filepath.c_str());
-
- mItem->setAssetUUID(asset_id);
- mItem->setTransactionID(tid);
-
- mScriptEd->writeToFile(filename);
-
- mIsSaving = TRUE;
- uploadAssetLegacy(filename, object, tid, isRunning);
- }
-
-}
-
-void LLLiveLSLEditor::uploadAssetLegacy(const std::string& filename,
- LLViewerObject* object,
- const LLTransactionID& tid,
- BOOL is_running)
-{
- LLLiveLSLSaveData* data = new LLLiveLSLSaveData(mObjectUUID,
- mItem,
- is_running);
- gAssetStorage->storeAssetData(filename, tid,
- LLAssetType::AT_LSL_TEXT,
- &onSaveTextComplete,
- (void*)data,
- FALSE);
-
- LLAssetID asset_id = tid.makeAssetID(gAgent.getSecureSessionID());
- std::string filepath = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,asset_id.asString());
- std::string dst_filename = llformat("%s.lso", filepath.c_str());
- std::string err_filename = llformat("%s.out", filepath.c_str());
-
- LLFILE *fp;
- const BOOL compile_to_mono = FALSE;
- if(!lscript_compile(filename.c_str(),
- dst_filename.c_str(),
- err_filename.c_str(),
- compile_to_mono,
- asset_id.asString().c_str(),
- gAgent.isGodlike()))
- {
- // load the error file into the error scrolllist
- LL_INFOS() << "Compile failed!" << LL_ENDL;
- if(NULL != (fp = LLFile::fopen(err_filename, "r")))
- {
- char buffer[MAX_STRING]; /*Flawfinder: ignore*/
- std::string line;
- while(!feof(fp))
- {
-
- if (fgets(buffer, MAX_STRING, fp) == NULL)
- {
- buffer[0] = '\0';
- }
- if(feof(fp))
- {
- break;
- }
- else
- {
- line.assign(buffer);
- LLStringUtil::stripNonprintable(line);
-
- LLSD row;
- row["columns"][0]["value"] = line;
- row["columns"][0]["font"] = "OCRA";
- mScriptEd->mErrorList->addElement(row);
- }
- }
- fclose(fp);
- mScriptEd->selectFirstError();
- // don't set the asset id, because we want to save the
- // script, even though the compile failed.
- //mItem->setAssetUUID(LLUUID::null);
- object->saveScript(mItem, FALSE, false);
- dialog_refresh_all();
- }
- }
- else
- {
- LL_INFOS() << "Compile worked!" << LL_ENDL;
- mScriptEd->mErrorList->setCommentText(LLTrans::getString("CompileSuccessfulSaving"));
- if(gAssetStorage)
- {
- LL_INFOS() << "LLLiveLSLEditor::saveAsset "
- << mItem->getAssetUUID() << LL_ENDL;
- getWindow()->incBusyCount();
- mPendingUploads++;
- LLLiveLSLSaveData* data = NULL;
- data = new LLLiveLSLSaveData(mObjectUUID,
- mItem,
- is_running);
- gAssetStorage->storeAssetData(dst_filename,
- tid,
- LLAssetType::AT_LSL_BYTECODE,
- &LLLiveLSLEditor::onSaveBytecodeComplete,
- (void*)data);
- dialog_refresh_all();
- }
- }
-
- // get rid of any temp files left lying around
- LLFile::remove(filename);
- LLFile::remove(err_filename);
- LLFile::remove(dst_filename);
-
- // If we successfully saved it, then we should be able to check/uncheck the running box!
- LLCheckBoxCtrl* runningCheckbox = getChild<LLCheckBoxCtrl>( "running");
- runningCheckbox->setLabel(getString("script_running"));
- runningCheckbox->setEnabled(TRUE);
-}
-
-void LLLiveLSLEditor::onSaveTextComplete(const LLUUID& asset_uuid, void* user_data, S32 status, LLExtStat ext_status) // StoreAssetData callback (fixed)
-{
- LLLiveLSLSaveData* data = (LLLiveLSLSaveData*)user_data;
-
- if (status)
- {
- LL_WARNS() << "Unable to save text for a script." << LL_ENDL;
- LLSD args;
- args["REASON"] = std::string(LLAssetStorage::getErrorString(status));
- LLNotificationsUtil::add("CompileQueueSaveText", args);
- }
- else
- {
- LLSD floater_key;
- floater_key["taskid"] = data->mSaveObjectID;
- floater_key["itemid"] = data->mItem->getUUID();
- LLLiveLSLEditor* self = LLFloaterReg::findTypedInstance<LLLiveLSLEditor>("preview_scriptedit", floater_key);
- if (self)
- {
- self->getWindow()->decBusyCount();
- self->mPendingUploads--;
- if (self->mPendingUploads <= 0
- && self->mCloseAfterSave)
- {
- self->closeFloater();
- }
- }
- }
- delete data;
- data = NULL;
-}
-
-
-void LLLiveLSLEditor::onSaveBytecodeComplete(const LLUUID& asset_uuid, void* user_data, S32 status, LLExtStat ext_status) // StoreAssetData callback (fixed)
-{
- LLLiveLSLSaveData* data = (LLLiveLSLSaveData*)user_data;
- if(!data)
- return;
- if(0 ==status)
- {
- LL_INFOS() << "LSL Bytecode saved" << LL_ENDL;
- LLSD floater_key;
- floater_key["taskid"] = data->mSaveObjectID;
- floater_key["itemid"] = data->mItem->getUUID();
- LLLiveLSLEditor* self = LLFloaterReg::findTypedInstance<LLLiveLSLEditor>("preview_scriptedit", floater_key);
- if (self)
- {
- // Tell the user that the compile worked.
- self->mScriptEd->mErrorList->setCommentText(LLTrans::getString("SaveComplete"));
- // close the window if this completes both uploads
- self->getWindow()->decBusyCount();
- self->mPendingUploads--;
- if (self->mPendingUploads <= 0
- && self->mCloseAfterSave)
- {
- self->closeFloater();
- }
- }
- LLViewerObject* object = gObjectList.findObject(data->mSaveObjectID);
- if(object)
- {
- object->saveScript(data->mItem, data->mActive, false);
- dialog_refresh_all();
- //LLToolDragAndDrop::dropScript(object, ids->first,
- // LLAssetType::AT_LSL_TEXT, FALSE);
- }
- }
- else
- {
- LL_INFOS() << "Problem saving LSL Bytecode (Live Editor)" << LL_ENDL;
- LL_WARNS() << "Unable to save a compiled script." << LL_ENDL;
-
- LLSD args;
- args["REASON"] = std::string(LLAssetStorage::getErrorString(status));
- LLNotificationsUtil::add("CompileQueueSaveBytecode", args);
- }
-
- std::string filepath = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,asset_uuid.asString());
- std::string dst_filename = llformat("%s.lso", filepath.c_str());
- LLFile::remove(dst_filename);
- delete data;
}
BOOL LLLiveLSLEditor::canClose()