diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index f9af7eacfb..53cb955029 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 6bec162d23..dc866ba75c 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 28f838de65..193927daec 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 0000000000..2d1d441d60 --- /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; + } +}