From bc68390b14ec582093dc322c2f45c32491924406 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 8 Jan 2010 22:51:37 +0000 Subject: [PATCH] The first 2 handlers for the XInventory system. --- .../Inventory/XInventoryInConnector.cs | 74 +++++++++++++++++++ .../Inventory/XInventoryConnector.cs | 4 +- 2 files changed, 76 insertions(+), 2 deletions(-) diff --git a/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs b/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs index b48e30e342..c7d5ff1d3a 100644 --- a/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs +++ b/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs @@ -38,6 +38,7 @@ using OpenSim.Services.Interfaces; using OpenSim.Framework.Servers.HttpServer; using OpenSim.Server.Handlers.Base; using log4net; +using OpenMetaverse; namespace OpenSim.Server.Handlers.Asset { @@ -193,6 +194,14 @@ namespace OpenSim.Server.Handlers.Asset { Dictionary result = new Dictionary(); + if (!request.ContainsKey("PRINCIPAL")) + return FailureResult(); + + if(m_InventoryService.CreateUserInventory(new UUID(request["PRINCIPAL"].ToString()))) + result["RESULT"] = "True"; + else + result["RESULT"] = "False"; + string xmlString = ServerUtils.BuildXmlResponse(result); m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); UTF8Encoding encoding = new UTF8Encoding(); @@ -203,6 +212,15 @@ namespace OpenSim.Server.Handlers.Asset { Dictionary result = new Dictionary(); + if (!request.ContainsKey("PRINCIPAL")) + return FailureResult(); + + + List folders = m_InventoryService.GetInventorySkeleton(new UUID(request["PRINCIPAL"].ToString())); + + foreach (InventoryFolderBase f in folders) + result[f.ID.ToString()] = EncodeFolder(f); + string xmlString = ServerUtils.BuildXmlResponse(result); m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); UTF8Encoding encoding = new UTF8Encoding(); @@ -378,5 +396,61 @@ namespace OpenSim.Server.Handlers.Asset UTF8Encoding encoding = new UTF8Encoding(); return encoding.GetBytes(xmlString); } + + private Dictionary EncodeFolder(InventoryFolderBase f) + { + Dictionary ret = new Dictionary(); + + ret["ParentID"] = f.ParentID.ToString(); + ret["Type"] = f.Type.ToString(); + ret["Version"] = f.Version.ToString(); + ret["Name"] = f.Name; + ret["Owner"] = f.Owner.ToString(); + ret["ID"] = f.ID.ToString(); + + return ret; + } + + private InventoryFolderBase BuildFolder(Dictionary data) + { + InventoryFolderBase folder = new InventoryFolderBase(); + + folder.ParentID = new UUID(data["ParentID"].ToString()); + folder.Type = short.Parse(data["Type"].ToString()); + folder.Version = ushort.Parse(data["Version"].ToString()); + folder.Name = data["Name"].ToString(); + folder.Owner = new UUID(data["Owner"].ToString()); + folder.ID = new UUID(data["ID"].ToString()); + + return folder; + } + + private InventoryItemBase BuildItem(Dictionary data) + { + InventoryItemBase item = new InventoryItemBase(); + + item.AssetID = new UUID(data["AssetID"].ToString()); + item.AssetType = int.Parse(data["AssetType"].ToString()); + item.Name = data["Name"].ToString(); + item.Owner = new UUID(data["Owner"].ToString()); + item.ID = new UUID(data["ID"].ToString()); + item.InvType = int.Parse(data["InvType"].ToString()); + item.Folder = new UUID(data["Folder"].ToString()); + item.CreatorId = data["CreatorId"].ToString(); + item.Description = data["Description"].ToString(); + item.NextPermissions = uint.Parse(data["NextPermissions"].ToString()); + item.CurrentPermissions = uint.Parse(data["CurrentPermissions"].ToString()); + item.BasePermissions = uint.Parse(data["BasePermissions"].ToString()); + item.EveryOnePermissions = uint.Parse(data["EveryOnePermissions"].ToString()); + item.GroupPermissions = uint.Parse(data["GroupPermissions"].ToString()); + item.GroupID = new UUID(data["GroupID"].ToString()); + item.GroupOwned = bool.Parse(data["GroupOwned"].ToString()); + item.SalePrice = int.Parse(data["SalePrice"].ToString()); + item.SaleType = byte.Parse(data["SaleType"].ToString()); + item.Flags = uint.Parse(data["Flags"].ToString()); + item.CreationDate = int.Parse(data["CreationDate"].ToString()); + + return item; + } } } diff --git a/OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs b/OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs index 40acd6d20f..b9ccd7ea12 100644 --- a/OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs +++ b/OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs @@ -490,7 +490,7 @@ namespace OpenSim.Services.Connectors return replyData; } - InventoryFolderBase BuildFolder(Dictionary data) + private InventoryFolderBase BuildFolder(Dictionary data) { InventoryFolderBase folder = new InventoryFolderBase(); @@ -504,7 +504,7 @@ namespace OpenSim.Services.Connectors return folder; } - InventoryItemBase BuildItem(Dictionary data) + private InventoryItemBase BuildItem(Dictionary data) { InventoryItemBase item = new InventoryItemBase();