diff options
Diffstat (limited to 'indra/newview')
-rwxr-xr-x | indra/newview/CMakeLists.txt | 5 | ||||
-rwxr-xr-x | indra/newview/llagent.cpp | 2 | ||||
-rwxr-xr-x | indra/newview/llpreviewscript.cpp | 193 | ||||
-rwxr-xr-x | indra/newview/llpreviewscript.h | 7 | ||||
-rw-r--r-- | indra/newview/llscriptruntimeperms.h | 60 | ||||
-rwxr-xr-x | indra/newview/llviewermessage.cpp | 69 |
6 files changed, 77 insertions, 259 deletions
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index d3ac1612ad..422a75f3f1 100755 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -36,7 +36,6 @@ include(LLUI) include(LLVFS) include(LLWindow) include(LLXML) -include(LScript) include(Linking) include(NDOF) include(NVAPI) @@ -85,8 +84,6 @@ include_directories( ${LLVFS_INCLUDE_DIRS} ${LLWINDOW_INCLUDE_DIRS} ${LLXML_INCLUDE_DIRS} - ${LSCRIPT_INCLUDE_DIRS} - ${LSCRIPT_INCLUDE_DIRS}/lscript_compile ${LLLOGIN_INCLUDE_DIRS} ${UPDATER_INCLUDE_DIRS} ${LIBS_PREBUILT_DIR}/include/collada @@ -1111,6 +1108,7 @@ set(viewer_HEADER_FILES llscreenchannel.h llscripteditor.h llscriptfloater.h + llscriptruntimeperms.h llscrollingpanelparam.h llscrollingpanelparambase.h llsearchcombobox.h @@ -1949,7 +1947,6 @@ target_link_libraries(${VIEWER_BINARY_NAME} ${LLVFS_LIBRARIES} ${LLWINDOW_LIBRARIES} ${LLXML_LIBRARIES} - ${LSCRIPT_LIBRARIES} ${LLMATH_LIBRARIES} ${LLCOREHTTP_LIBRARIES} ${LLCOMMON_LIBRARIES} diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index f151b15e29..64b3df21fd 100755 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -63,6 +63,7 @@ #include "llpaneltopinfobar.h" #include "llparcel.h" #include "llrendersphere.h" +#include "llscriptruntimeperms.h" #include "llsdmessage.h" #include "llsdutil.h" #include "llsky.h" @@ -92,7 +93,6 @@ #include "llwindow.h" #include "llworld.h" #include "llworldmap.h" -#include "lscript_byteformat.h" #include "stringize.h" #include "boost/foreach.hpp" diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index 5415c273e2..9184159321 100755 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -53,7 +53,6 @@ #include "llscrolllistcell.h" #include "llsdserialize.h" #include "llslider.h" -#include "lscript_rt_interface.h" #include "lltooldraganddrop.h" #include "llvfile.h" @@ -1474,10 +1473,6 @@ void LLPreviewLSL::saveIfNeeded(bool sync /*= true*/) { uploadAssetViaCaps(url, filename, mItemUUID); } - else if (gAssetStorage) - { - uploadAssetLegacy(filename, mItemUUID, tid); - } } } @@ -1492,91 +1487,6 @@ void LLPreviewLSL::uploadAssetViaCaps(const std::string& url, LLHTTPClient::post(url, body, new LLUpdateAgentInventoryResponder(body, filename, LLAssetType::AT_LSL_TEXT)); } -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) { @@ -2170,10 +2080,6 @@ void LLLiveLSLEditor::saveIfNeeded(bool sync /*= true*/) { uploadAssetViaCaps(url, filename, mObjectUUID, mItemUUID, is_running); } - else if (gAssetStorage) - { - uploadAssetLegacy(filename, object, tid, is_running); - } } void LLLiveLSLEditor::uploadAssetViaCaps(const std::string& url, @@ -2192,105 +2098,6 @@ void LLLiveLSLEditor::uploadAssetViaCaps(const std::string& url, new LLUpdateTaskInventoryResponder(body, filename, LLAssetType::AT_LSL_TEXT)); } -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; diff --git a/indra/newview/llpreviewscript.h b/indra/newview/llpreviewscript.h index 66727bceee..fab997bc22 100755 --- a/indra/newview/llpreviewscript.h +++ b/indra/newview/llpreviewscript.h @@ -202,9 +202,6 @@ protected: void uploadAssetViaCaps(const std::string& url, const std::string& filename, const LLUUID& item_id); - void uploadAssetLegacy(const std::string& filename, - const LLUUID& item_id, - const LLTransactionID& tid); static void onSearchReplace(void* userdata); static void onLoad(void* userdata); @@ -260,10 +257,6 @@ private: const LLUUID& task_id, const LLUUID& item_id, BOOL is_running); - void uploadAssetLegacy(const std::string& filename, - LLViewerObject* object, - const LLTransactionID& tid, - BOOL is_running); BOOL monoChecked() const; diff --git a/indra/newview/llscriptruntimeperms.h b/indra/newview/llscriptruntimeperms.h new file mode 100644 index 0000000000..4a8e4288d2 --- /dev/null +++ b/indra/newview/llscriptruntimeperms.h @@ -0,0 +1,60 @@ +/** + * @file llscriptruntimeperms.h + * @brief Script runtime permission definitions + * + * $LicenseInfo:firstyear=2002&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2015, 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$ + */ + +#ifndef LL_LLSCRIPTRUNTIME_PERMS_H +#define LL_LLSCRIPTRUNTIME_PERMS_H + +typedef struct _script_perm { + std::string question; + U32 permbit; + bool caution; + _script_perm(const std::string& q, const U32 b, const bool c) : + question(q), permbit(b), caution(c) {} +} script_perm_t; + +const U32 NUM_SCRIPT_PERMISSIONS = 16; +const S32 SCRIPT_PERMISSION_DEBIT = 0; + +static const boost::array<script_perm_t, NUM_SCRIPT_PERMISSIONS> SCRIPT_PERMISSIONS = {{ + _script_perm("ScriptTakeMoney", (0x1 << 1), true), + _script_perm("ActOnControlInputs", (0x1 << 2), false), + _script_perm("RemapControlInputs", (0x1 << 3), false), + _script_perm("AnimateYourAvatar", (0x1 << 4), false), + _script_perm("AttachToYourAvatar", (0x1 << 5), false), + _script_perm("ReleaseOwnership", (0x1 << 6), false), + _script_perm("LinkAndDelink", (0x1 << 7), false), + _script_perm("AddAndRemoveJoints", (0x1 << 8), false), + _script_perm("ChangePermissions", (0x1 << 9), false), + _script_perm("TrackYourCamera", (0x1 << 10), false), + _script_perm("ControlYourCamera", (0x1 << 11), false), + _script_perm("TeleportYourAgent", (0x1 << 12), false), + _script_perm("JoinAnExperience", (0x1 << 13), false), + _script_perm("SilentlyManageEstateAccess", (0x1 << 14), false), + _script_perm("OverrideYourAnimations", (0x1 << 15), false), + _script_perm("ScriptReturnObjects", (0x1 << 16), false) +}}; + +#endif // LL_LLSCRIPTRUNTIME_PERMS_H diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index 762f75edd4..edefdff3c9 100755 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -33,7 +33,6 @@ #include "llaudioengine.h" #include "llavataractions.h" #include "llavatarnamecache.h" // IDEVO HACK -#include "lscript_byteformat.h" #include "lleconomy.h" #include "lleventtimer.h" #include "llfloaterreg.h" @@ -76,6 +75,7 @@ #include "llpanelgrouplandmoney.h" #include "llrecentpeople.h" #include "llscriptfloater.h" +#include "llscriptruntimeperms.h" #include "llselectmgr.h" #include "llstartup.h" #include "llsky.h" @@ -115,6 +115,7 @@ #include <boost/algorithm/string/split.hpp> // #include <boost/regex.hpp> +#include <boost/foreach.hpp> #include "llnotificationmanager.h" // @@ -153,47 +154,6 @@ const U8 AU_FLAGS_NONE = 0x00; const U8 AU_FLAGS_HIDETITLE = 0x01; const U8 AU_FLAGS_CLIENT_AUTOPILOT = 0x02; -//script permissions -const std::string SCRIPT_QUESTIONS[SCRIPT_PERMISSION_EOF] = - { - "ScriptTakeMoney", - "ActOnControlInputs", - "RemapControlInputs", - "AnimateYourAvatar", - "AttachToYourAvatar", - "ReleaseOwnership", - "LinkAndDelink", - "AddAndRemoveJoints", - "ChangePermissions", - "TrackYourCamera", - "ControlYourCamera", - "TeleportYourAgent", - "JoinAnExperience", - "SilentlyManageEstateAccess", - "OverrideYourAnimations", - "ScriptReturnObjects" - }; - -const BOOL SCRIPT_QUESTION_IS_CAUTION[SCRIPT_PERMISSION_EOF] = -{ - TRUE, // ScriptTakeMoney, - FALSE, // ActOnControlInputs - FALSE, // RemapControlInputs - FALSE, // AnimateYourAvatar - FALSE, // AttachToYourAvatar - FALSE, // ReleaseOwnership, - FALSE, // LinkAndDelink, - FALSE, // AddAndRemoveJoints - FALSE, // ChangePermissions - FALSE, // TrackYourCamera, - FALSE, // ControlYourCamera - FALSE, // TeleportYourAgent - FALSE, // JoinAnExperience - FALSE, // SilentlyManageEstateAccess - FALSE, // OverrideYourAnimations - FALSE, // ScriptReturnObjects -}; - bool friendship_offer_callback(const LLSD& notification, const LLSD& response) { S32 option = LLNotificationsUtil::getSelectedOption(notification, response); @@ -6284,21 +6244,22 @@ void notify_cautioned_script_question(const LLSD& notification, const LLSD& resp BOOL caution = FALSE; S32 count = 0; std::string perms; - for (S32 i = 0; i < SCRIPT_PERMISSION_EOF; i++) + BOOST_FOREACH(script_perm_t script_perm, SCRIPT_PERMISSIONS) { - if ((orig_questions & LSCRIPTRunTimePermissionBits[i]) && SCRIPT_QUESTION_IS_CAUTION[i]) + if ((orig_questions & script_perm.permbit) + && script_perm.caution) { count++; caution = TRUE; // add a comma before the permission description if it is not the first permission // added to the list or the last permission to check - if ((count > 1) && (i < SCRIPT_PERMISSION_EOF)) + if (count > 1) { perms.append(", "); } - perms.append(LLTrans::getString(SCRIPT_QUESTIONS[i])); + perms.append(LLTrans::getString(script_perm.question)); } } @@ -6472,27 +6433,27 @@ void process_script_question(LLMessageSystem *msg, void **user_data) std::string script_question; if (questions) { - BOOL caution = FALSE; + bool caution = false; S32 count = 0; LLSD args; args["OBJECTNAME"] = object_name; args["NAME"] = LLCacheName::cleanFullName(owner_name); S32 known_questions = 0; - BOOL has_not_only_debit = questions ^ LSCRIPTRunTimePermissionBits[SCRIPT_PERMISSION_DEBIT]; + bool has_not_only_debit = questions ^ SCRIPT_PERMISSIONS[SCRIPT_PERMISSION_DEBIT].permbit; // check the received permission flags against each permission - for (S32 i = 0; i < SCRIPT_PERMISSION_EOF; i++) + BOOST_FOREACH(script_perm_t script_perm, SCRIPT_PERMISSIONS) { - if (questions & LSCRIPTRunTimePermissionBits[i]) + if (questions & script_perm.permbit) { count++; - known_questions |= LSCRIPTRunTimePermissionBits[i]; + known_questions |= script_perm.permbit; // check whether permission question should cause special caution dialog - caution |= (SCRIPT_QUESTION_IS_CAUTION[i]); + caution |= (script_perm.caution); - if (("ScriptTakeMoney" == SCRIPT_QUESTIONS[i]) && has_not_only_debit) + if (("ScriptTakeMoney" == script_perm.question) && has_not_only_debit) continue; - script_question += " " + LLTrans::getString(SCRIPT_QUESTIONS[i]) + "\n"; + script_question += " " + LLTrans::getString(script_perm.question) + "\n"; } } |