From c7d61737fb5223d9673e4330c5a25ce328b0d583 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 10 Oct 2020 19:11:37 +0100 Subject: [PATCH] make use of some of those on inventory caps; fix some set of sp osutf8 fields --- .../FetchInventory/FetchInvDescHandler.cs | 97 +++++++++---------- .../FetchInventory/FetchInventory2Handler.cs | 34 +++---- OpenSim/Framework/InventoryItemBase.cs | 55 +++++------ OpenSim/Framework/ViewerEnvironment.cs | 1 + .../Framework/Scenes/SceneObjectPart.cs | 42 ++++++-- 5 files changed, 126 insertions(+), 103 deletions(-) diff --git a/OpenSim/Capabilities/Handlers/FetchInventory/FetchInvDescHandler.cs b/OpenSim/Capabilities/Handlers/FetchInventory/FetchInvDescHandler.cs index 544414910a..9bf4f2e373 100644 --- a/OpenSim/Capabilities/Handlers/FetchInventory/FetchInvDescHandler.cs +++ b/OpenSim/Capabilities/Handlers/FetchInventory/FetchInvDescHandler.cs @@ -131,18 +131,18 @@ namespace OpenSim.Capabilities.Handlers return; } - StringBuilder sb = osStringBuilderCache.Acquire(); - sb.Append("[WEB FETCH INV DESC HANDLER]: Unable to fetch folders owned by "); - sb.Append("Unknown"); - sb.Append(" :"); + osUTF8 sb = OSUTF8Cached.Acquire(); + sb.AppendASCII("[WEB FETCH INV DESC HANDLER]: Unable to fetch folders owned by "); + sb.AppendASCII("Unknown"); + sb.AppendASCII(" :"); int limit = 5; int count = 0; foreach (UUID bad in bad_folders) { if (BadRequests.ContainsKey(bad)) continue; - sb.Append(" "); - sb.Append(bad.ToString()); + sb.Append((byte)' '); + sb.AppendASCII(bad.ToString()); ++count; if (--limit < 0) break; @@ -151,22 +151,21 @@ namespace OpenSim.Capabilities.Handlers if(count > 0) { if (limit < 0) - sb.Append(" ..."); - m_log.Warn(osStringBuilderCache.GetStringAndRelease(sb)); + sb.AppendASCII(" ..."); + m_log.Warn(sb.ToString()); } - else - osStringBuilderCache.Release(sb); - sb = osStringBuilderCache.Acquire(); - sb.Append("foldersbad_folders"); + sb.Clear(); + + sb.AppendASCII("foldersbad_folders"); foreach (UUID bad in bad_folders) { - sb.Append("folder_id"); - sb.Append(bad.ToString()); - sb.Append("errorUnknown"); + sb.AppendASCII("folder_id"); + sb.AppendASCII(bad.ToString()); + sb.AppendASCII("errorUnknown"); } - sb.Append(""); - httpResponse.RawBuffer = Util.UTF8NBGetbytes(osStringBuilderCache.GetStringAndRelease(sb)); + sb.AppendASCII(""); + httpResponse.RawBuffer = OSUTF8Cached.GetArrayAndRelease(sb); return; } @@ -187,12 +186,11 @@ namespace OpenSim.Capabilities.Handlers 1024 * total_items + 128 * bad_folders.Count) & 0x7ffff000); - StringBuilder lastresponse = new StringBuilder(mem); - lastresponse.Append(""); + osUTF8 lastresponse = LLSDxmlEncode2.Start(mem); if (invcollSetCount > 0) { - lastresponse.Append("folders"); + lastresponse.AppendASCII("folders"); int i = 0; InventoryCollection thiscoll; for (i = 0; i < invcollSetCount; i++) @@ -200,70 +198,70 @@ namespace OpenSim.Capabilities.Handlers thiscoll = invcollSet[i]; invcollSet[i] = null; - LLSDxmlEncode.AddMap(lastresponse); - LLSDxmlEncode.AddElem("agent_id", thiscoll.OwnerID, lastresponse); - LLSDxmlEncode.AddElem("descendents", thiscoll.Descendents, lastresponse); - LLSDxmlEncode.AddElem("folder_id", thiscoll.FolderID, lastresponse); + LLSDxmlEncode2.AddMap(lastresponse); + LLSDxmlEncode2.AddElem_agent_id(thiscoll.OwnerID, lastresponse); + LLSDxmlEncode2.AddElem("descendents", thiscoll.Descendents, lastresponse); + LLSDxmlEncode2.AddElem_folder_id(thiscoll.FolderID, lastresponse); if (thiscoll.Folders == null || thiscoll.Folders.Count == 0) - LLSDxmlEncode.AddEmptyArray("categories", lastresponse); + LLSDxmlEncode2.AddEmptyArray("categories", lastresponse); else { - LLSDxmlEncode.AddArray("categories", lastresponse); + LLSDxmlEncode2.AddArray("categories", lastresponse); foreach (InventoryFolderBase invFolder in thiscoll.Folders) { - LLSDxmlEncode.AddMap(lastresponse); + LLSDxmlEncode2.AddMap(lastresponse); - LLSDxmlEncode.AddElem("folder_id", invFolder.ID, lastresponse); - LLSDxmlEncode.AddElem("parent_id", invFolder.ParentID, lastresponse); - LLSDxmlEncode.AddElem("name", invFolder.Name, lastresponse); - LLSDxmlEncode.AddElem("type", invFolder.Type, lastresponse); - LLSDxmlEncode.AddElem("preferred_type", (int)-1, lastresponse); - LLSDxmlEncode.AddElem("version", invFolder.Version, lastresponse); + LLSDxmlEncode2.AddElem_folder_id(invFolder.ID, lastresponse); + LLSDxmlEncode2.AddElem_parent_id(invFolder.ParentID, lastresponse); + LLSDxmlEncode2.AddElem_name(invFolder.Name, lastresponse); + LLSDxmlEncode2.AddElem("type", invFolder.Type, lastresponse); + LLSDxmlEncode2.AddElem("preferred_type", (int)-1, lastresponse); + LLSDxmlEncode2.AddElem("version", invFolder.Version, lastresponse); - LLSDxmlEncode.AddEndMap(lastresponse); + LLSDxmlEncode2.AddEndMap(lastresponse); } - LLSDxmlEncode.AddEndArray(lastresponse); + LLSDxmlEncode2.AddEndArray(lastresponse); } if (thiscoll.Items == null || thiscoll.Items.Count == 0) - LLSDxmlEncode.AddEmptyArray("items", lastresponse); + LLSDxmlEncode2.AddEmptyArray("items", lastresponse); else { - LLSDxmlEncode.AddArray("items", lastresponse); + LLSDxmlEncode2.AddArray("items", lastresponse); foreach (InventoryItemBase invItem in thiscoll.Items) { invItem.ToLLSDxml(lastresponse); } - LLSDxmlEncode.AddEndArray(lastresponse); + LLSDxmlEncode2.AddEndArray(lastresponse); } - LLSDxmlEncode.AddElem("owner_id", thiscoll.OwnerID, lastresponse); - LLSDxmlEncode.AddElem("version", thiscoll.Version, lastresponse); + LLSDxmlEncode2.AddElem_owner_id(thiscoll.OwnerID, lastresponse); + LLSDxmlEncode2.AddElem("version", thiscoll.Version, lastresponse); - LLSDxmlEncode.AddEndMap(lastresponse); + LLSDxmlEncode2.AddEndMap(lastresponse); invcollSet[i] = null; } - lastresponse.Append(""); + LLSDxmlEncode2.AddEndArrayAndMap(lastresponse); thiscoll = null; } else { - lastresponse.Append("folders"); + lastresponse.AppendASCII("folders"); } if (bad_folders.Count > 0) { - lastresponse.Append("bad_folders"); + lastresponse.AppendASCII("bad_folders"); foreach (UUID bad in bad_folders) { BadRequests.Add(bad); - lastresponse.Append("folder_id"); - lastresponse.Append(bad.ToString()); - lastresponse.Append("errorUnknown"); + lastresponse.AppendASCII("folder_id"); + lastresponse.AppendASCII(bad.ToString()); + lastresponse.AppendASCII("errorUnknown"); } - lastresponse.Append(""); + lastresponse.AppendASCII(""); StringBuilder sb = osStringBuilderCache.Acquire(); sb.Append("[WEB FETCH INV DESC HANDLER]: Unable to fetch folders owned by "); @@ -281,9 +279,8 @@ namespace OpenSim.Capabilities.Handlers sb.Append(" ..."); m_log.Warn(osStringBuilderCache.GetStringAndRelease(sb)); } - lastresponse.Append(""); - httpResponse.RawBuffer = Util.UTF8NBGetbytes(lastresponse.ToString()); + httpResponse.RawBuffer = LLSDxmlEncode2.EndToBytes(lastresponse); } private void AddLibraryFolders(List libFolders, List result, ref int total_folders, ref int total_items) diff --git a/OpenSim/Capabilities/Handlers/FetchInventory/FetchInventory2Handler.cs b/OpenSim/Capabilities/Handlers/FetchInventory/FetchInventory2Handler.cs index 7d5a59ff93..e93a077963 100644 --- a/OpenSim/Capabilities/Handlers/FetchInventory/FetchInventory2Handler.cs +++ b/OpenSim/Capabilities/Handlers/FetchInventory/FetchInventory2Handler.cs @@ -81,31 +81,31 @@ namespace OpenSim.Capabilities.Handlers items[i++] = m_inventoryService.GetItem(UUID.Zero, id); } - StringBuilder lsl = LLSDxmlEncode.Start(4096); - LLSDxmlEncode.AddMap(lsl); + osUTF8 lsl = LLSDxmlEncode2.Start(4096); + LLSDxmlEncode2.AddMap(lsl); if(m_agentID == UUID.Zero && items.Length > 0) - LLSDxmlEncode.AddElem("agent_id", items[0].Owner, lsl); + LLSDxmlEncode2.AddElem("agent_id", items[0].Owner, lsl); else - LLSDxmlEncode.AddElem("agent_id", m_agentID, lsl); + LLSDxmlEncode2.AddElem("agent_id", m_agentID, lsl); if(items == null || items.Length == 0) { - LLSDxmlEncode.AddEmptyArray("items", lsl); + LLSDxmlEncode2.AddEmptyArray("items", lsl); } else { - LLSDxmlEncode.AddArray("items", lsl); + LLSDxmlEncode2.AddArray("items", lsl); foreach (InventoryItemBase item in items) { if (item != null) item.ToLLSDxml(lsl, 0xff); } - LLSDxmlEncode.AddEndArray(lsl); + LLSDxmlEncode2.AddEndArray(lsl); } - LLSDxmlEncode.AddEndMap(lsl); - return LLSDxmlEncode.End(lsl); + LLSDxmlEncode2.AddEndMap(lsl); + return LLSDxmlEncode2.End(lsl); } public void FetchInventorySimpleRequest(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse, OSDMap requestmap, ExpiringKey BadRequests) @@ -137,28 +137,28 @@ namespace OpenSim.Capabilities.Handlers } catch{ } - StringBuilder lsl = LLSDxmlEncode.Start(4096); - LLSDxmlEncode.AddMap(lsl); + osUTF8 lsl = LLSDxmlEncode2.Start(4096); + LLSDxmlEncode2.AddMap(lsl); - LLSDxmlEncode.AddElem("agent_id", m_agentID, lsl); + LLSDxmlEncode2.AddElem("agent_id", m_agentID, lsl); if (items == null || items.Length == 0) { - LLSDxmlEncode.AddEmptyArray("items", lsl); + LLSDxmlEncode2.AddEmptyArray("items", lsl); } else { - LLSDxmlEncode.AddArray("items", lsl); + LLSDxmlEncode2.AddArray("items", lsl); foreach (InventoryItemBase item in items) { if (item != null) item.ToLLSDxml(lsl, 0xff); } - LLSDxmlEncode.AddEndArray(lsl); + LLSDxmlEncode2.AddEndArray(lsl); } - LLSDxmlEncode.AddEndMap(lsl); - httpResponse.RawBuffer = Util.UTF8.GetBytes(LLSDxmlEncode.End(lsl)); + LLSDxmlEncode2.AddEndMap(lsl); + httpResponse.RawBuffer = LLSDxmlEncode2.EndToBytes(lsl); httpResponse.StatusCode = (int)HttpStatusCode.OK; } } diff --git a/OpenSim/Framework/InventoryItemBase.cs b/OpenSim/Framework/InventoryItemBase.cs index 407c6acf21..13d66ce9b5 100644 --- a/OpenSim/Framework/InventoryItemBase.cs +++ b/OpenSim/Framework/InventoryItemBase.cs @@ -28,6 +28,7 @@ using System; using System.Text; using OpenMetaverse; +using OpenMetaverse.StructuredData; namespace OpenSim.Framework { @@ -411,39 +412,39 @@ namespace OpenSim.Framework return MemberwiseClone(); } - public void ToLLSDxml(StringBuilder lsl, uint flagsMask = 0xffffffff) + public void ToLLSDxml(osUTF8 lsl, uint flagsMask = 0xffffffff) { - LLSDxmlEncode.AddMap(lsl); - LLSDxmlEncode.AddElem("parent_id", Folder, lsl); - LLSDxmlEncode.AddElem("asset_id", AssetID, lsl); - LLSDxmlEncode.AddElem("item_id", ID, lsl); + LLSDxmlEncode2.AddMap(lsl); + LLSDxmlEncode2.AddElem_parent_id(Folder, lsl); + LLSDxmlEncode2.AddElem("asset_id", AssetID, lsl); + LLSDxmlEncode2.AddElem("item_id", ID, lsl); - LLSDxmlEncode.AddMap("permissions",lsl); - LLSDxmlEncode.AddElem("creator_id", CreatorIdAsUuid, lsl); - LLSDxmlEncode.AddElem("owner_id", Owner, lsl); - LLSDxmlEncode.AddElem("group_id", GroupID, lsl); - LLSDxmlEncode.AddElem("base_mask", (int)CurrentPermissions, lsl); - LLSDxmlEncode.AddElem("owner_mask", (int)CurrentPermissions, lsl); - LLSDxmlEncode.AddElem("group_mask", (int)GroupPermissions, lsl); - LLSDxmlEncode.AddElem("everyone_mask", (int)EveryOnePermissions, lsl); - LLSDxmlEncode.AddElem("next_owner_mask", (int)NextPermissions, lsl); - LLSDxmlEncode.AddElem("is_owner_group", GroupOwned, lsl); - LLSDxmlEncode.AddEndMap(lsl); + LLSDxmlEncode2.AddMap("permissions",lsl); + LLSDxmlEncode2.AddElem("creator_id", CreatorIdAsUuid, lsl); + LLSDxmlEncode2.AddElem_owner_id( Owner, lsl); + LLSDxmlEncode2.AddElem("group_id", GroupID, lsl); + LLSDxmlEncode2.AddElem("base_mask", (int)CurrentPermissions, lsl); + LLSDxmlEncode2.AddElem("owner_mask", (int)CurrentPermissions, lsl); + LLSDxmlEncode2.AddElem("group_mask", (int)GroupPermissions, lsl); + LLSDxmlEncode2.AddElem("everyone_mask", (int)EveryOnePermissions, lsl); + LLSDxmlEncode2.AddElem("next_owner_mask", (int)NextPermissions, lsl); + LLSDxmlEncode2.AddElem("is_owner_group", GroupOwned, lsl); + LLSDxmlEncode2.AddEndMap(lsl); - LLSDxmlEncode.AddElem("type", AssetType, lsl); - LLSDxmlEncode.AddElem("inv_type", InvType, lsl); - LLSDxmlEncode.AddElem("flags", (int)(Flags & flagsMask), lsl); + LLSDxmlEncode2.AddElem("type", AssetType, lsl); + LLSDxmlEncode2.AddElem("inv_type", InvType, lsl); + LLSDxmlEncode2.AddElem("flags", (int)(Flags & flagsMask), lsl); - LLSDxmlEncode.AddMap("sale_info",lsl); - LLSDxmlEncode.AddElem("sale_price", SalePrice, lsl); - LLSDxmlEncode.AddElem("sale_type", SaleType, lsl); - LLSDxmlEncode.AddEndMap(lsl); + LLSDxmlEncode2.AddMap("sale_info",lsl); + LLSDxmlEncode2.AddElem("sale_price", SalePrice, lsl); + LLSDxmlEncode2.AddElem("sale_type", SaleType, lsl); + LLSDxmlEncode2.AddEndMap(lsl); - LLSDxmlEncode.AddElem("name", Name, lsl); - LLSDxmlEncode.AddElem("desc", Description, lsl); - LLSDxmlEncode.AddElem("created_at", CreationDate, lsl); + LLSDxmlEncode2.AddElem_name(Name, lsl); + LLSDxmlEncode2.AddElem("desc", Description, lsl); + LLSDxmlEncode2.AddElem("created_at", CreationDate, lsl); - LLSDxmlEncode.AddEndMap(lsl); + LLSDxmlEncode2.AddEndMap(lsl); } } } diff --git a/OpenSim/Framework/ViewerEnvironment.cs b/OpenSim/Framework/ViewerEnvironment.cs index f617742ecd..7042c7ee77 100644 --- a/OpenSim/Framework/ViewerEnvironment.cs +++ b/OpenSim/Framework/ViewerEnvironment.cs @@ -480,6 +480,7 @@ namespace OpenSim.Framework ret = OSDParser.SerializeLLSDXmlToBytes(map); m_cachedbytes = ret; } + return ret; } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index e69ff4b0bb..c9d8874f46 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -4075,12 +4075,24 @@ namespace OpenSim.Region.Framework.Scenes public void SetText(string text) { osUTF8 old = osUTF8Text; - osUTF8Text = new osUTF8(text, 254); - - if (ParentGroup != null && !osUTF8Text.Equals(old)) + if(string.IsNullOrEmpty(text)) { - ParentGroup.HasGroupChanged = true; - ScheduleFullUpdate(); + osUTF8Text = null; + if (old != null && ParentGroup != null) + { + ParentGroup.HasGroupChanged = true; + ScheduleFullUpdate(); + } + } + else + { + osUTF8Text = new osUTF8(text, 254); + + if (ParentGroup != null && !osUTF8Text.Equals(old)) + { + ParentGroup.HasGroupChanged = true; + ScheduleFullUpdate(); + } } } @@ -4099,11 +4111,23 @@ namespace OpenSim.Region.Framework.Scenes (int) (color.Y*0xff), (int) (color.Z*0xff)); osUTF8 old = osUTF8Text; - osUTF8Text = new osUTF8(text, 254); - if (ParentGroup != null && (oldcolor != Color || !osUTF8Text.Equals(old))) + if(string.IsNullOrEmpty(text)) { - ParentGroup.HasGroupChanged = true; - ScheduleFullUpdate(); + osUTF8Text = new osUTF8(text, 254); + if (ParentGroup != null && (oldcolor != Color || !osUTF8Text.Equals(old))) + { + ParentGroup.HasGroupChanged = true; + ScheduleFullUpdate(); + } + } + else + { + osUTF8Text = null; + if (ParentGroup != null && (oldcolor != Color || old != null)) + { + ParentGroup.HasGroupChanged = true; + ScheduleFullUpdate(); + } } }