From 2c25a43ba27ac921e88b1a662be955a4cd4f0661 Mon Sep 17 00:00:00 2001 From: zontreck Date: Sat, 5 Oct 2024 01:42:13 -0700 Subject: [PATCH] refactor(force_start_update): finish porting force update start script Signed-off-by: zontreck --- src/includes/Functions.lsl | 4 +++ src/includes/Variables.lsl | 19 +++++++++++- src/preproc/Updater/force_start_update.lsl | 12 ++++++++ src/raw/updater/force_update.lsl | 35 +++++++++++----------- 4 files changed, 52 insertions(+), 18 deletions(-) create mode 100644 src/preproc/Updater/force_start_update.lsl diff --git a/src/includes/Functions.lsl b/src/includes/Functions.lsl index a173276..cdc4c65 100644 --- a/src/includes/Functions.lsl +++ b/src/includes/Functions.lsl @@ -13,4 +13,8 @@ Callback(string sTarget, string sTimerID) { CancelCallback(string sTimerID) { LM(LINK_SIGNAL_CALLBACKS, OP_CALLBACK_CANCEL, llList2Json(JSON_OBJECT, ["id", sTimerID])); +} + +string BuildPacket(string sOperation, list lParams) { + return llList2Json(JSON_OBJECT, lParams + ["op", sOperation]); } \ No newline at end of file diff --git a/src/includes/Variables.lsl b/src/includes/Variables.lsl index 2d0a1a1..fa72cad 100644 --- a/src/includes/Variables.lsl +++ b/src/includes/Variables.lsl @@ -19,4 +19,21 @@ string OP_CALLBACK = "5"; -string EMPTY_JSON = "{}"; \ No newline at end of file +string EMPTY_JSON = "{}"; +string VERSION = "0.3.0-dev"; + + + +integer UPDATER_CHANNEL = 0xABCDE0; + + + + +integer g_iUpdaterListener; +integer g_iUpdaterSecureChannel; +integer g_iUpdaterSecureListener; +integer g_iClientPin; +integer g_iUpdateRunning; +integer g_iCurrentBundle; +integer g_iServerListener; +integer g_iUpdateHasStarted; \ No newline at end of file diff --git a/src/preproc/Updater/force_start_update.lsl b/src/preproc/Updater/force_start_update.lsl new file mode 100644 index 0000000..dd8d6cc --- /dev/null +++ b/src/preproc/Updater/force_start_update.lsl @@ -0,0 +1,12 @@ +/* + +This file is a part of NuSystem (https://git.zontreck.com/AriasCreations/NuSystem) + +NuSystem is licensed under the GPL. +Please see the Git Source Tree for structured information on changes to indivudual files + +Initial Author: Aria (aria@zontreck.com) + +*/ + +#include "../raw/updater/force_update.lsl" \ No newline at end of file diff --git a/src/raw/updater/force_update.lsl b/src/raw/updater/force_update.lsl index eab0dcb..17d1b4b 100644 --- a/src/raw/updater/force_update.lsl +++ b/src/raw/updater/force_update.lsl @@ -1,10 +1,8 @@ -/* - - This file is a temporary placeholder for development purposes to help bootstrap the update system. It is a drop in script to immediately start the update - -*/ - -#include "includes/common.lsl" +#include "Variables.lsl" +#include "Functions.lsl" +#include "Version.lsl" +#include "../external/AriasCreations/Common.lsl" +#include "../external/AriasCreations/Helpers.lsl" default { @@ -13,7 +11,7 @@ default // Send the update scan signal VERSION = "0.0.0.0"; g_iUpdaterListener = llListen(UPDATER_CHANNEL, "", "", ""); - llWhisper(UPDATER_CHANNEL, Build("checkupdate", ["myversion", compileVersion()])); + llWhisper(UPDATER_CHANNEL, BuildPacket("checkupdate", ["version", llLinksetDataRead("version")])); llSetTimerEvent(1); } @@ -30,14 +28,17 @@ default { //llSay(0, "DEBUG ["+llDumpList2String([iChan, sName, kID, sMsg], " ~ ")+"]"); integer iStart=0; - if(llJsonGetValue(sMsg,["operation"]) == "available") - { - // Begin stage 2 - iStart=1; - }else if(llJsonGetValue(sMsg,["operation"]) == "same") - { - // Impossible as this is the force start. Tell it to start anyway! - iStart=1; + string sOp = llJsonGetValue(sMsg, ["op"]); + + switch(sOp) { + case "available": { + iStart=1; + break; + } + case "same": { + iStart=1; + break; + } } if(!iStart)return; @@ -46,7 +47,7 @@ default llSetRemoteScriptAccessPin(g_iClientPin); llSleep(1); - llRegionSayTo(kID, UPDATER_CHANNEL, Build("stage2", ["pin", g_iClientPin])); + llRegionSayTo(kID, UPDATER_CHANNEL, BuildPacket("stage2", ["pin", g_iClientPin])); llSay(0, "Updater found, sent pairing code, good bye!"); llRemoveInventory(llGetScriptName()); }