274 lines
11 KiB
Diff
274 lines
11 KiB
Diff
From 37f47683b3416d05c04d68e9898c19a95f3d4e8f Mon Sep 17 00:00:00 2001
|
|
From: Christopher <git@clatza.dev>
|
|
Date: Wed, 27 May 2020 15:28:23 +0200
|
|
Subject: [PATCH] Add os commands similar to experience data storage Add
|
|
similar os commands to llReadKeyValue llCreateKeyValue llDeleteKeyValue ==
|
|
osGetDataValue osSetDataValue osDeleteDataValue and osCheckDataValue
|
|
|
|
---
|
|
.../Shared/Api/Implementation/OSSL_Api.cs | 149 ++++++++++++++++++
|
|
.../Shared/Api/Interface/IOSSL_Api.cs | 10 ++
|
|
.../Shared/Api/Runtime/OSSL_Stub.cs | 40 +++++
|
|
bin/config-include/osslDefaultEnable.ini | 4 +
|
|
4 files changed, 203 insertions(+)
|
|
|
|
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
|
|
index 8289dec2e7..197fde3a01 100644
|
|
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
|
|
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
|
|
@@ -42,8 +42,10 @@ using System;
|
|
using System.Collections;
|
|
using System.Collections.Concurrent;
|
|
using System.Collections.Generic;
|
|
+using System.IO;
|
|
using System.Reflection;
|
|
using System.Runtime.Remoting.Lifetime;
|
|
+using System.Security.Cryptography;
|
|
using System.Text;
|
|
using System.Text.RegularExpressions;
|
|
using System.Threading;
|
|
@@ -948,6 +950,153 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|
return false;
|
|
}
|
|
|
|
+ public string osGetDataValue(string key)
|
|
+ {
|
|
+ return osGetDataValue(key, false);
|
|
+ }
|
|
+
|
|
+ public string osGetDataValue(string key, bool personal)
|
|
+ {
|
|
+ CheckThreatLevel(ThreatLevel.Moderate, "osGetDataValue");
|
|
+
|
|
+ string dataValueDirectory = m_ScriptEngine.ConfigSource.Configs["XEngine"].GetString("DataValueStorageDirectory", "./ScriptDataValue");
|
|
+
|
|
+ String groupFolderName = m_host.GroupID.ToString().Trim().ToUpper().Replace("-", "");
|
|
+
|
|
+ if(personal)
|
|
+ groupFolderName = m_host.OwnerID.ToString().Trim().ToUpper().Replace("-", "");
|
|
+
|
|
+ if (!Directory.Exists(dataValueDirectory))
|
|
+ Directory.CreateDirectory(dataValueDirectory);
|
|
+
|
|
+ if (!Directory.Exists(dataValueDirectory + "/" + groupFolderName))
|
|
+ Directory.CreateDirectory(dataValueDirectory + "/" + groupFolderName);
|
|
+
|
|
+ try
|
|
+ {
|
|
+ string keyMD = BitConverter.ToString(new MD5CryptoServiceProvider().ComputeHash(ASCIIEncoding.ASCII.GetBytes(key.Trim().ToUpper()))).Replace("-", "");
|
|
+ FileInfo file = new FileInfo(dataValueDirectory + "/" + groupFolderName + "/" + keyMD + ".txt");
|
|
+
|
|
+ if (file.Exists)
|
|
+ return File.ReadAllText(file.FullName);
|
|
+ }
|
|
+ catch (Exception _error)
|
|
+ {
|
|
+ Console.WriteLine(_error.Message);
|
|
+ }
|
|
+
|
|
+ return "";
|
|
+ }
|
|
+
|
|
+ public void osSetDataValue(string key, string value)
|
|
+ {
|
|
+ osSetDataValue(key, value, false);
|
|
+ }
|
|
+
|
|
+ public void osSetDataValue(string key, string value, bool personal)
|
|
+ {
|
|
+ CheckThreatLevel(ThreatLevel.Moderate, "osSetDataValue");
|
|
+
|
|
+ string dataValueDirectory = m_ScriptEngine.ConfigSource.Configs["XEngine"].GetString("DataValueStorageDirectory", "./ScriptDataValue");
|
|
+
|
|
+ String groupFolderName = m_host.GroupID.ToString().Trim().ToUpper().Replace("-", "");
|
|
+
|
|
+ if (personal)
|
|
+ groupFolderName = m_host.OwnerID.ToString().Trim().ToUpper().Replace("-", "");
|
|
+
|
|
+ if (!Directory.Exists(dataValueDirectory))
|
|
+ Directory.CreateDirectory(dataValueDirectory);
|
|
+
|
|
+ if (!Directory.Exists(dataValueDirectory + "/" + groupFolderName))
|
|
+ Directory.CreateDirectory(dataValueDirectory + "/" + groupFolderName);
|
|
+
|
|
+ try
|
|
+ {
|
|
+ string keyMD = BitConverter.ToString(new MD5CryptoServiceProvider().ComputeHash(ASCIIEncoding.ASCII.GetBytes(key.Trim().ToUpper()))).Replace("-", "");
|
|
+ FileInfo file = new FileInfo(dataValueDirectory + "/" + groupFolderName + "/" + keyMD + ".txt");
|
|
+
|
|
+ File.WriteAllText(file.FullName, value);
|
|
+ }
|
|
+ catch (Exception _error)
|
|
+ {
|
|
+ Console.WriteLine(_error.Message);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ public void osDeleteDataValue(string key)
|
|
+ {
|
|
+ osDeleteDataValue(key, false);
|
|
+ }
|
|
+
|
|
+ public void osDeleteDataValue(string key, bool personal)
|
|
+ {
|
|
+ CheckThreatLevel(ThreatLevel.Moderate, "osDeleteDataValue");
|
|
+
|
|
+ string dataValueDirectory = m_ScriptEngine.ConfigSource.Configs["XEngine"].GetString("DataValueStorageDirectory", "./ScriptDataValue");
|
|
+
|
|
+ String groupFolderName = m_host.GroupID.ToString().Trim().ToUpper().Replace("-", "");
|
|
+
|
|
+ if (personal)
|
|
+ groupFolderName = m_host.OwnerID.ToString().Trim().ToUpper().Replace("-", "");
|
|
+
|
|
+ if (!Directory.Exists(dataValueDirectory))
|
|
+ Directory.CreateDirectory(dataValueDirectory);
|
|
+
|
|
+ if (!Directory.Exists(dataValueDirectory + "/" + groupFolderName))
|
|
+ Directory.CreateDirectory(dataValueDirectory + "/" + groupFolderName);
|
|
+
|
|
+ try
|
|
+ {
|
|
+ string keyMD = BitConverter.ToString(new MD5CryptoServiceProvider().ComputeHash(ASCIIEncoding.ASCII.GetBytes(key.Trim().ToUpper()))).Replace("-", "");
|
|
+ FileInfo file = new FileInfo(dataValueDirectory + "/" + groupFolderName + "/" + keyMD + ".txt");
|
|
+
|
|
+ if (file.Exists)
|
|
+ file.Delete();
|
|
+ }
|
|
+ catch (Exception _error)
|
|
+ {
|
|
+ Console.WriteLine(_error.Message);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ public bool osCheckDataValue(string key)
|
|
+ {
|
|
+ return osCheckDataValue(key, false);
|
|
+ }
|
|
+
|
|
+ public bool osCheckDataValue(string key, bool personal)
|
|
+ {
|
|
+ CheckThreatLevel(ThreatLevel.Moderate, "osCheckDataValue");
|
|
+
|
|
+ string dataValueDirectory = m_ScriptEngine.ConfigSource.Configs["XEngine"].GetString("DataValueStorageDirectory", "./ScriptDataValue");
|
|
+
|
|
+ String groupFolderName = m_host.GroupID.ToString().Trim().ToUpper().Replace("-", "");
|
|
+
|
|
+ if (personal)
|
|
+ groupFolderName = m_host.OwnerID.ToString().Trim().ToUpper().Replace("-", "");
|
|
+
|
|
+ if (!Directory.Exists(dataValueDirectory))
|
|
+ Directory.CreateDirectory(dataValueDirectory);
|
|
+
|
|
+ if (!Directory.Exists(dataValueDirectory + "/" + groupFolderName))
|
|
+ Directory.CreateDirectory(dataValueDirectory + "/" + groupFolderName);
|
|
+
|
|
+ try
|
|
+ {
|
|
+ string keyMD = BitConverter.ToString(new MD5CryptoServiceProvider().ComputeHash(ASCIIEncoding.ASCII.GetBytes(key.Trim().ToUpper()))).Replace("-", "");
|
|
+ FileInfo file = new FileInfo(dataValueDirectory + "/" + groupFolderName + "/" + keyMD + ".txt");
|
|
+
|
|
+ if (file.Exists)
|
|
+ return true;
|
|
+ }
|
|
+ catch (Exception _error)
|
|
+ {
|
|
+ Console.WriteLine(_error.Message);
|
|
+ }
|
|
+
|
|
+ return false;
|
|
+ }
|
|
+
|
|
public void osSetPrimFloatOnWater(int floatYN)
|
|
{
|
|
CheckThreatLevel(ThreatLevel.VeryLow, "osSetPrimFloatOnWater");
|
|
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
|
|
index e9aeda5f28..93dbc64366 100644
|
|
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
|
|
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
|
|
@@ -142,6 +142,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
|
|
void osRegionNotice(string msg);
|
|
void osRegionNotice(LSL_Key agentID, string msg);
|
|
bool osConsoleCommand(string Command);
|
|
+
|
|
+ string osGetDataValue(string key);
|
|
+ string osGetDataValue(string key, bool persoanl);
|
|
+ void osSetDataValue(string key, string value);
|
|
+ void osSetDataValue(string key, string value, bool personal);
|
|
+ void osDeleteDataValue(string key);
|
|
+ void osDeleteDataValue(string key, bool personal);
|
|
+ bool osCheckDataValue(string key);
|
|
+ bool osCheckDataValue(string key, bool personal);
|
|
+
|
|
void osSetParcelMediaURL(string url);
|
|
void osSetPrimFloatOnWater(int floatYN);
|
|
void osSetParcelSIPAddress(string SIPAddress);
|
|
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
|
|
index 4bae45e392..55e911c6ae 100644
|
|
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
|
|
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
|
|
@@ -235,6 +235,46 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
|
|
return m_OSSL_Functions.osConsoleCommand(Command);
|
|
}
|
|
|
|
+ public string osGetDataValue(string key)
|
|
+ {
|
|
+ return m_OSSL_Functions.osGetDataValue(key);
|
|
+ }
|
|
+
|
|
+ public string osGetDataValue(string key, bool personal)
|
|
+ {
|
|
+ return m_OSSL_Functions.osGetDataValue(key, personal);
|
|
+ }
|
|
+
|
|
+ public void osSetDataValue(string key, string value)
|
|
+ {
|
|
+ m_OSSL_Functions.osSetDataValue(key, value);
|
|
+ }
|
|
+
|
|
+ public void osSetDataValue(string key, string value, bool personal)
|
|
+ {
|
|
+ m_OSSL_Functions.osSetDataValue(key, value, personal);
|
|
+ }
|
|
+
|
|
+ public void osDeleteDataValue(string key)
|
|
+ {
|
|
+ m_OSSL_Functions.osDeleteDataValue(key);
|
|
+ }
|
|
+
|
|
+ public void osDeleteDataValue(string key, bool personal)
|
|
+ {
|
|
+ m_OSSL_Functions.osDeleteDataValue(key, personal);
|
|
+ }
|
|
+
|
|
+ public bool osCheckDataValue(string key)
|
|
+ {
|
|
+ return m_OSSL_Functions.osCheckDataValue(key);
|
|
+ }
|
|
+
|
|
+ public bool osCheckDataValue(string key, bool personal)
|
|
+ {
|
|
+ return m_OSSL_Functions.osCheckDataValue(key, personal);
|
|
+ }
|
|
+
|
|
public void osSetParcelMediaURL(string url)
|
|
{
|
|
m_OSSL_Functions.osSetParcelMediaURL(url);
|
|
diff --git a/bin/config-include/osslDefaultEnable.ini b/bin/config-include/osslDefaultEnable.ini
|
|
index e66577dbcf..72885d9d30 100644
|
|
--- a/bin/config-include/osslDefaultEnable.ini
|
|
+++ b/bin/config-include/osslDefaultEnable.ini
|
|
@@ -146,6 +146,10 @@
|
|
Allow_osSetOwnerSpeed = ${OSSL|osslParcelO}ESTATE_MANAGER,ESTATE_OWNER
|
|
Allow_osRequestURL = ${OSSL|osslParcelO}ESTATE_MANAGER,ESTATE_OWNER
|
|
Allow_osRequestSecureURL = ${OSSL|osslParcelO}ESTATE_MANAGER,ESTATE_OWNER
|
|
+ Allow_osGetDataValue = ${OSSL|osslParcelO}ESTATE_MANAGER,ESTATE_OWNER
|
|
+ Allow_osSetDataValue = ${OSSL|osslParcelO}ESTATE_MANAGER,ESTATE_OWNER
|
|
+ Allow_osDeleteDataValue = ${OSSL|osslParcelO}ESTATE_MANAGER,ESTATE_OWNER
|
|
+ Allow_osCheckDataValue = ${OSSL|osslParcelO}ESTATE_MANAGER,ESTATE_OWNER
|
|
|
|
; ThreatLevel High
|
|
Allow_osCauseDamage = ${OSSL|osslParcelO}ESTATE_MANAGER,ESTATE_OWNER
|
|
--
|
|
2.25.1.windows.1
|
|
|