From 70e55205a19ca83aa2f63c2b2c5d2c300e2324f6 Mon Sep 17 00:00:00 2001 From: MW Date: Sat, 15 Mar 2008 11:48:27 +0000 Subject: Part 1 of making inventory work again in the 1.19.1 (RC) client. Implemented the FetchInventoryDescendents CAPS handler. But currently returning empty folder details. So this commit doesn't actually fix inventory in that client, it just stops the "loading" message being displayed forever next to a folder, and instead shows empty folders. Next part will be to fill in the details of the items in the folders. --- .../Framework/Communications/Capabilities/Caps.cs | 36 ++++++++++ .../Communications/Capabilities/LLSDCapsDetails.cs | 1 + .../Communications/Capabilities/LLSDHelpers.cs | 12 +++- .../Capabilities/LLSDInventoryItem.cs | 83 ++++++++++++++++++++++ 4 files changed, 129 insertions(+), 3 deletions(-) create mode 100644 OpenSim/Framework/Communications/Capabilities/LLSDInventoryItem.cs (limited to 'OpenSim/Framework/Communications/Capabilities') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index f9af7ea..53cb955 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -66,6 +66,7 @@ namespace OpenSim.Region.Capabilities //private string m_requestTexture = "0003/"; private string m_notecardUpdatePath = "0004/"; private string m_notecardTaskUpdatePath = "0005/"; + private string m_fetchInventoryPath = "0006/"; //private string eventQueue = "0100/"; private BaseHttpServer m_httpListener; @@ -110,10 +111,17 @@ namespace OpenSim.Region.Capabilities capsBase + m_newInventory, NewAgentInventoryRequest)); + // m_httpListener.AddStreamHandler( + // new LLSDStreamhandler("POST", + // capsBase + m_fetchInventory, + // FetchInventory)); + + AddLegacyCapsHandler(m_httpListener, m_requestPath, CapsRequest); //AddLegacyCapsHandler(m_httpListener, m_requestTexture , RequestTexture); AddLegacyCapsHandler(m_httpListener, m_notecardUpdatePath, NoteCardAgentInventory); AddLegacyCapsHandler(m_httpListener, m_notecardTaskUpdatePath, ScriptTaskInventory); + AddLegacyCapsHandler(m_httpListener, m_fetchInventoryPath, FetchInventoryRequest); } catch (Exception e) { @@ -160,9 +168,37 @@ namespace OpenSim.Region.Capabilities caps.UpdateNotecardAgentInventory = capsBaseUrl + m_notecardUpdatePath; caps.UpdateScriptAgentInventory = capsBaseUrl + m_notecardUpdatePath; caps.UpdateScriptTaskInventory = capsBaseUrl + m_notecardTaskUpdatePath; + caps.FetchInventoryDescendents = capsBaseUrl + m_fetchInventoryPath; return caps; } + public string FetchInventoryRequest(string request, string path, string param) + { + request = request.Replace("folders", ""); + request = request.Replace("", ""); + + //Console.WriteLine("inventory request " + request); + Hashtable hash = (Hashtable)LLSD.LLSDDeserialize(Helpers.StringToField(request)); + LLSDFetchInventoryDescendents llsdRequest = new LLSDFetchInventoryDescendents(); + LLSDHelpers.DeserialiseLLSDMap(hash, llsdRequest); + LLSDInventoryDescendents reply = FetchInventory(llsdRequest); + string response = LLSDHelpers.SerialiseLLSDReply(reply); + return response; + } + + private LLSDInventoryDescendents FetchInventory(LLSDFetchInventoryDescendents invFetch) + { + LLSDInventoryDescendents reply = new LLSDInventoryDescendents(); + LLSDInventoryFolderContents contents = new LLSDInventoryFolderContents(); + contents.agent___id = m_agentID; + contents.owner___id = m_agentID; + contents.folder___id = invFetch.folder_id; + contents.version = 1; + contents.descendents = 0; + reply.folders.Array.Add(contents); + return reply; + } + /// /// /// diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs b/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs index 6bec162..dc866ba 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs @@ -42,6 +42,7 @@ namespace OpenSim.Region.Capabilities public string UpdateScriptAgentInventory = String.Empty; public string UpdateScriptTaskInventory = String.Empty; // public string ParcelVoiceInfoRequest = String.Empty; + public string FetchInventoryDescendents = String.Empty; public LLSDCapsDetails() { diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs b/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs index 28f838d..193927d 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs @@ -66,14 +66,18 @@ namespace OpenSim.Region.Capabilities if (fieldAttributes.Length > 0) { writer.WriteStartElement(String.Empty, "key", String.Empty); - writer.WriteString(fields[i].Name); + string fieldName = fields[i].Name; + fieldName = fieldName.Replace("___", "-"); + writer.WriteString(fieldName); writer.WriteEndElement(); SerializeLLSDType(writer, fieldValue); } else { writer.WriteStartElement(String.Empty, "key", String.Empty); - writer.WriteString(fields[i].Name); + string fieldName = fields[i].Name; + fieldName = fieldName.Replace("___", "-"); + writer.WriteString(fieldName); writer.WriteEndElement(); LLSD.LLSDWriteOne(writer, fieldValue); // libsecondlife.StructuredData.LLSDParser.SerializeXmlElement( @@ -118,7 +122,9 @@ namespace OpenSim.Region.Capabilities IDictionaryEnumerator enumerator = llsd.GetEnumerator(); while (enumerator.MoveNext()) { - FieldInfo field = myType.GetField((string) enumerator.Key); + string keyName = (string)enumerator.Key; + keyName = keyName.Replace("-","_"); + FieldInfo field = myType.GetField(keyName); if (field != null) { // if (enumerator.Value is libsecondlife.StructuredData.LLSDMap) diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDInventoryItem.cs b/OpenSim/Framework/Communications/Capabilities/LLSDInventoryItem.cs new file mode 100644 index 0000000..2d1d441 --- /dev/null +++ b/OpenSim/Framework/Communications/Capabilities/LLSDInventoryItem.cs @@ -0,0 +1,83 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; + +namespace OpenSim.Region.Capabilities +{ + [LLSDMap] + public class LLSDInventoryItem + { + public LLUUID parent_id; + + public LLUUID asset_id; + public LLUUID item_id; + + public string type; + public string inv_type; + public int flags; + + public LLSDSaleInfo sale_info; + public string name; + public string desc; + public int created_at; + + } + + [LLSDMap] + public class LLSDPermissions + { + public LLUUID creator_id; + public LLUUID owner_id; + public LLUUID group_id; + public int base_mask; + public int owner_mask; + public int group_mask; + public int everyone_mask; + public int next_owner_mask; + public bool is_owner_group; + } + + [LLSDMap] + public class LLSDSaleInfo + { + public int sale_price; + public string sale_type; + } + + /* [LLSDMap] + public class LLSDFolderItem + { + public LLUUID folder_id; + public LLUUID parent_id; + public int type; + public string name; + }*/ + + [LLSDMap] + public class LLSDInventoryDescendents + { + public LLSDArray folders= new LLSDArray(); + } + + [LLSDMap] + public class LLSDFetchInventoryDescendents + { + public LLUUID folder_id; + public LLUUID owner_id; + public int sort_order; + public bool fetch_folders; + public bool fetch_items; + } + + [LLSDMap] + public class LLSDInventoryFolderContents + { + public LLUUID agent___id; + public int descendents; + public LLUUID folder___id; // the (three "_") "___" so the serialising knows to change this to a "-" + public LLSDArray items = new LLSDArray(); + public LLUUID owner___id; + public int version; + } +} -- cgit v1.1