diff --git a/LibreMetaverse.Types/Enums.cs b/LibreMetaverse.Types/Enums.cs index 04e3e9e1..69e79cda 100644 --- a/LibreMetaverse.Types/Enums.cs +++ b/LibreMetaverse.Types/Enums.cs @@ -222,11 +222,11 @@ public enum InventoryType : sbyte Landmark = 3, /* /// Script - //[Obsolete("See LSL")] Script = 4, + [Obsolete("See LSL")] Script = 4, /// Clothing - //[Obsolete("See Wearable")] Clothing = 5, + [Obsolete("See Wearable")] Clothing = 5, + */ /// Object, both single and coalesced - */ Object = 6, /// Notecard Notecard = 7, @@ -265,6 +265,8 @@ public enum InventoryType : sbyte /// Mesh = 22, + /// + Settings = 23, } /// diff --git a/LibreMetaverse/AssetManager.cs b/LibreMetaverse/AssetManager.cs index de3eeab5..5e7f7662 100644 --- a/LibreMetaverse/AssetManager.cs +++ b/LibreMetaverse/AssetManager.cs @@ -1587,6 +1587,9 @@ public Asset CreateAssetWrapper(AssetType type) case AssetType.CallingCard: asset = new AssetCallingCard(); break; + case AssetType.Settings: + asset = new AssetSettings(); + break; default: asset = new AssetMutable(type); Logger.Log("Unimplemented asset type: " + type, Helpers.LogLevel.Error); diff --git a/LibreMetaverse/Assets/AssetTypes/AssetSettings.cs b/LibreMetaverse/Assets/AssetTypes/AssetSettings.cs new file mode 100644 index 00000000..bec0f946 --- /dev/null +++ b/LibreMetaverse/Assets/AssetTypes/AssetSettings.cs @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2024, Sjofn LLC + * All rights reserved. + * + * - Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * - Neither the name of the openmetaverse.co nor the names + * of its contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +using OpenMetaverse.StructuredData; + +namespace OpenMetaverse.Assets +{ + public class AssetSettings : Asset + { + public override AssetType AssetType => AssetType.Settings; + + public OSD Settings; + + /// Initializes a new instance of an AssetSettings object + public AssetSettings() { } + + /// + /// Construct an Asset object of type Settings + /// + /// A unique specific to this asset + /// A byte array containing the raw asset data + public AssetSettings(UUID assetId, byte[] assetData) + : base(assetId, assetData) + { + Decode(); + } + + public override void Encode() + { + AssetData = Utils.StringToBytes(Settings.AsString()); + } + + public sealed override bool Decode() + { + if (AssetData != null && AssetData.Length > 0) + { + try + { + var raw = Utils.BytesToString(AssetData); + Settings = OSD.FromString(raw); + return true; + } + catch + { + return false; + } + } + + return false; + } + } +} \ No newline at end of file diff --git a/LibreMetaverse/InventoryBase.cs b/LibreMetaverse/InventoryBase.cs index 5fd4d94b..df930f8c 100644 --- a/LibreMetaverse/InventoryBase.cs +++ b/LibreMetaverse/InventoryBase.cs @@ -779,6 +779,29 @@ public InventoryGesture(SerializationInfo info, StreamingContext ctxt) } } + /// + /// + /// InventorySettings, LLSD settings blob as an asset + /// + [Serializable] + public class InventorySettings : InventoryItem + { + /// + /// Construct an InventorySettings object + /// + /// A which becomes the + /// objects AssetUUID + public InventorySettings(UUID itemID) : base(itemID) + { + InventoryType = InventoryType.Settings; + } + + public InventorySettings(SerializationInfo info, StreamingContext ctxt) : base(info, ctxt) + { + InventoryType = InventoryType.Settings; + } + } + /// /// /// A folder contains s and has certain attributes specific diff --git a/LibreMetaverse/InventoryManager.cs b/LibreMetaverse/InventoryManager.cs index aaf82a84..57df1602 100644 --- a/LibreMetaverse/InventoryManager.cs +++ b/LibreMetaverse/InventoryManager.cs @@ -3168,6 +3168,7 @@ public static InventoryItem CreateInventoryItem(InventoryType type, UUID id) case InventoryType.Wearable: return new InventoryWearable(id); case InventoryType.Animation: return new InventoryAnimation(id); case InventoryType.Gesture: return new InventoryGesture(id); + case InventoryType.Settings: return new InventorySettings(id); default: return new InventoryItem(type, id); } }