From 5df851761aa796cba70a3b6d8b36d119502c1de2 Mon Sep 17 00:00:00 2001 From: MW Date: Sat, 1 Dec 2007 18:49:17 +0000 Subject: [PATCH] Initial working Grid Inventory server. Only been tested on a very small grid, so likely to have problems on a larger grid with more people? To use , both the user server and Inventory server need to be running this latest revision. (older regions should be able to still be used, just the user won't have inventory on them). Also and HERE IS THE BIG BREAK ISSUE, currently, so that the initial inventory details for a user are added to the inventory db , you need to recreate the accounts using the user server "create user" feature. It should be quite easy to manual populate the inventory database instead but I someone else will need to look into that) Also I've only tested using SQLite as the database provider, there is a Mysql inventory provider but I don't know if it works (SQLite is set as default, so you will need to change it in the inventory server config.xml) --- .../Communications/IInventoryServices.cs | 2 +- .../Communications/InventoryServiceBase.cs | 4 +- .../Communications/UserManagerBase.cs | 4 +- OpenSim/Framework/IUserService.cs | 2 +- OpenSim/Framework/InventoryConfig.cs | 2 +- OpenSim/Framework/InventoryItemBase.cs | 19 +++ OpenSim/Framework/Servers/RestObjectPoster.cs | 92 +++++++++++++++ OpenSim/Framework/UserConfig.cs | 10 ++ .../InventoryServer/GridInventoryService.cs | 104 +++++++++++++++++ OpenSim/Grid/InventoryServer/Main.cs | 34 +++++- OpenSim/Grid/UserServer/Main.cs | 19 ++- OpenSim/Grid/UserServer/UserLoginService.cs | 50 ++++++++ .../Local/LocalInventoryService.cs | 4 +- .../OGS1/OGS1InventoryService.cs | 108 +++++++++++++++--- .../Communications/OGS1/OGS1UserServices.cs | 3 +- 15 files changed, 430 insertions(+), 27 deletions(-) create mode 100644 OpenSim/Grid/InventoryServer/GridInventoryService.cs diff --git a/OpenSim/Framework/Communications/IInventoryServices.cs b/OpenSim/Framework/Communications/IInventoryServices.cs index fc301c2f6c..96bb7b3b2e 100644 --- a/OpenSim/Framework/Communications/IInventoryServices.cs +++ b/OpenSim/Framework/Communications/IInventoryServices.cs @@ -39,7 +39,7 @@ namespace OpenSim.Framework.Communications public interface IInventoryServices { void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, InventoryItemInfo itemCallBack); - void AddNewInventoryFolder(LLUUID userID, InventoryFolderImpl folder); + void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder); void AddNewInventoryItem(LLUUID userID, InventoryItemBase item); void DeleteInventoryItem(LLUUID userID, InventoryItemBase item); void CreateNewUserInventory(LLUUID user); diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index effe13287a..091d829862 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -150,7 +150,7 @@ namespace OpenSim.Framework.Communications } } - public void deleteItem(InventoryItemBase item) + public void DeleteItem(InventoryItemBase item) { foreach (KeyValuePair plugin in m_plugins) { @@ -231,7 +231,7 @@ namespace OpenSim.Framework.Communications public abstract void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, InventoryItemInfo itemCallBack); - public abstract void AddNewInventoryFolder(LLUUID userID, InventoryFolderImpl folder); + public abstract void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder); public abstract void AddNewInventoryItem(LLUUID userID, InventoryItemBase item); public abstract void DeleteInventoryItem(LLUUID userID, InventoryItemBase item); } diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index f1f2c2b24c..119f8a5b41 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -366,7 +366,7 @@ namespace OpenSim.Framework.UserManagement /// /// /// - public void AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY) + public LLUUID AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY) { UserProfileData user = new UserProfileData(); user.homeLocation = new LLVector3(128, 128, 100); @@ -391,6 +391,8 @@ namespace OpenSim.Framework.UserManagement MainLog.Instance.Verbose("Unable to add user via " + plugin.Key + "(" + e.ToString() + ")"); } } + + return user.UUID; } public abstract UserProfileData SetupMasterUser(string firstName, string lastName); diff --git a/OpenSim/Framework/IUserService.cs b/OpenSim/Framework/IUserService.cs index d7857a41ee..67028a5074 100644 --- a/OpenSim/Framework/IUserService.cs +++ b/OpenSim/Framework/IUserService.cs @@ -46,6 +46,6 @@ namespace OpenSim.Framework /// /// /// - void AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY); + LLUUID AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY); } } \ No newline at end of file diff --git a/OpenSim/Framework/InventoryConfig.cs b/OpenSim/Framework/InventoryConfig.cs index 123319686e..554cd30b74 100644 --- a/OpenSim/Framework/InventoryConfig.cs +++ b/OpenSim/Framework/InventoryConfig.cs @@ -38,7 +38,7 @@ namespace OpenSim.Framework configMember.addConfigurationOption("user_recv_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to expect from user server", "null", false); configMember.addConfigurationOption("database_provider", ConfigurationOption.ConfigurationTypes.TYPE_STRING, - "DLL for database provider", "OpenSim.Framework.Data.MySQL.dll", false); + "DLL for database provider", "OpenSim.Framework.Data.SQLite.dll", false); configMember.addConfigurationOption("http_port", ConfigurationOption.ConfigurationTypes.TYPE_INT32, "Http Listener port", DefaultHttpPort.ToString(), false); } diff --git a/OpenSim/Framework/InventoryItemBase.cs b/OpenSim/Framework/InventoryItemBase.cs index 80f631e2e8..0ee30bb53a 100644 --- a/OpenSim/Framework/InventoryItemBase.cs +++ b/OpenSim/Framework/InventoryItemBase.cs @@ -245,6 +245,25 @@ namespace OpenSim.Framework void deleteInventoryFolder(LLUUID folder); } + public class InventoryCollection + { + public List Folders; + public List AllItems; + public LLUUID UserID; + + public InventoryCollection() + { + Folders = new List(); + AllItems = new List(); + } + + public InventoryCollection(List folders, List allItems) + { + Folders = folders; + AllItems = allItems; + } + } + /* * .Net has some issues, serializing a dictionary, so we cannot reuse the InventoryFolder * class defined in Communications.Framework.Communications.Caches. So we serialize/deserialize diff --git a/OpenSim/Framework/Servers/RestObjectPoster.cs b/OpenSim/Framework/Servers/RestObjectPoster.cs index b77cbcc56a..07095f3793 100644 --- a/OpenSim/Framework/Servers/RestObjectPoster.cs +++ b/OpenSim/Framework/Servers/RestObjectPoster.cs @@ -8,8 +8,11 @@ using System.Xml.Serialization; namespace OpenSim.Framework.Servers { + public delegate void ReturnResponse(T reponse); + public class RestObjectPoster { + public static void BeginPostObject(string requestUrl, TRequest obj) { Type type = typeof(TRequest); @@ -46,4 +49,93 @@ namespace OpenSim.Framework.Servers } } } + + public class RestObjectPosterResponse + { + public ReturnResponse ReturnResponseVal; + + public void BeginPostObject(string requestUrl, TRequest obj) + { + Type type = typeof(TRequest); + + WebRequest request = WebRequest.Create(requestUrl); + request.Method = "POST"; + request.ContentType = "text/xml"; + + MemoryStream buffer = new MemoryStream(); + + XmlWriterSettings settings = new XmlWriterSettings(); + settings.Encoding = Encoding.UTF8; + + using (XmlWriter writer = XmlWriter.Create(buffer, settings)) + { + XmlSerializer serializer = new XmlSerializer(type); + serializer.Serialize(writer, obj); + writer.Flush(); + } + + int length = (int)buffer.Length; + request.ContentLength = length; + + Stream requestStream = request.GetRequestStream(); + requestStream.Write(buffer.ToArray(), 0, length); + IAsyncResult result = request.BeginGetResponse(AsyncCallback, request); + } + + private void AsyncCallback(IAsyncResult result) + { + WebRequest request = (WebRequest)result.AsyncState; + using (WebResponse resp = request.EndGetResponse(result)) + { + TResponse deserial; + XmlSerializer deserializer = new XmlSerializer(typeof(TResponse)); + deserial = (TResponse)deserializer.Deserialize(resp.GetResponseStream()); + + if (deserial != null && ReturnResponseVal != null) + { + ReturnResponseVal(deserial); + } + } + } + } + + public class SyncRestObjectPoster + { + + public static TResponse BeginPostObject(string requestUrl, TRequest obj) + { + Type type = typeof(TRequest); + + WebRequest request = WebRequest.Create(requestUrl); + request.Method = "POST"; + request.ContentType = "text/xml"; + + MemoryStream buffer = new MemoryStream(); + + XmlWriterSettings settings = new XmlWriterSettings(); + settings.Encoding = Encoding.UTF8; + + using (XmlWriter writer = XmlWriter.Create(buffer, settings)) + { + XmlSerializer serializer = new XmlSerializer(type); + serializer.Serialize(writer, obj); + writer.Flush(); + } + + int length = (int)buffer.Length; + request.ContentLength = length; + + Stream requestStream = request.GetRequestStream(); + requestStream.Write(buffer.ToArray(), 0, length); + TResponse deserial = default(TResponse); + using (WebResponse resp = request.GetResponse()) + { + + XmlSerializer deserializer = new XmlSerializer(typeof(TResponse)); + deserial = (TResponse)deserializer.Deserialize(resp.GetResponseStream()); + } + return deserial; + } + + } } \ No newline at end of file diff --git a/OpenSim/Framework/UserConfig.cs b/OpenSim/Framework/UserConfig.cs index d4ee62f292..4c6b3b8ae4 100644 --- a/OpenSim/Framework/UserConfig.cs +++ b/OpenSim/Framework/UserConfig.cs @@ -38,6 +38,8 @@ namespace OpenSim.Framework public string GridSendKey = ""; public string GridRecvKey = ""; + public string InventoryUrl = ""; + public string DatabaseProvider = ""; public static uint DefaultHttpPort = 8002; @@ -68,6 +70,11 @@ namespace OpenSim.Framework "Key to send to grid server", "null", false); configMember.addConfigurationOption("grid_recv_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to expect from grid server", "null", false); + + configMember.addConfigurationOption("default_inventory_server", + ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, + "Default Inventory Server URI", + "http://127.0.0.1:8004/", false); configMember.addConfigurationOption("database_provider", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "DLL for database provider", "OpenSim.Framework.Data.MySQL.dll", false); @@ -95,6 +102,9 @@ namespace OpenSim.Framework case "grid_recv_key": GridRecvKey = (string) configuration_result; break; + case "default_inventory_server": + InventoryUrl = (string)configuration_result; + break; case "database_provider": DatabaseProvider = (string) configuration_result; break; diff --git a/OpenSim/Grid/InventoryServer/GridInventoryService.cs b/OpenSim/Grid/InventoryServer/GridInventoryService.cs new file mode 100644 index 0000000000..dda2f6147f --- /dev/null +++ b/OpenSim/Grid/InventoryServer/GridInventoryService.cs @@ -0,0 +1,104 @@ +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Framework; +using OpenSim.Framework.Communications; +using libsecondlife; + +namespace OpenSim.Grid.InventoryServer +{ + public class GridInventoryService : InventoryServiceBase + { + public override void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, + InventoryItemInfo itemCallBack) + { + + } + + private bool TryGetUsersInventory(LLUUID userID, out List folderList, out List itemsList) + { + List folders = RequestFirstLevelFolders(userID); + List allItems = new List(); + + if (folders != null) + { + foreach (InventoryFolderBase folder in folders) + { + if (folder.parentID != LLUUID.Zero) + { + List items = RequestFolderItems(folder.folderID); + if (items != null) + { + allItems.InsertRange(0, items); + } + } + } + } + + folderList = folders; + itemsList = allItems; + if (folderList != null) + { + return true; + } + else + { + return false; + } + } + + public InventoryCollection GetUserInventory(LLUUID userID) + { + InventoryCollection invCollection = new InventoryCollection(); + List folders; + List allItems; + if (TryGetUsersInventory(userID, out folders, out allItems)) + { + invCollection.AllItems = allItems; + invCollection.Folders = folders; + invCollection.UserID = userID; + } + return invCollection; + } + + public bool CreateUsersInventory(LLUUID user) + { + CreateNewUserInventory(user); + return true; + } + + + public override void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder) + { + AddFolder(folder); + } + + public override void AddNewInventoryItem(LLUUID userID, InventoryItemBase item) + { + AddItem(item); + } + + public bool AddInventoryFolder( InventoryFolderBase folder) + { + AddNewInventoryFolder(folder.agentID, folder); + return true; + } + + public bool AddInventoryItem( InventoryItemBase item) + { + AddNewInventoryItem(item.avatarID, item); + return true; + } + + public override void DeleteInventoryItem(LLUUID userID, InventoryItemBase item) + { + DeleteItem(item); + } + + public bool DeleteInvItem( InventoryItemBase item) + { + DeleteInventoryItem(item.avatarID, item); + return true; + } + } +} diff --git a/OpenSim/Grid/InventoryServer/Main.cs b/OpenSim/Grid/InventoryServer/Main.cs index 1bc396b8c4..8d232c2325 100644 --- a/OpenSim/Grid/InventoryServer/Main.cs +++ b/OpenSim/Grid/InventoryServer/Main.cs @@ -47,6 +47,7 @@ namespace OpenSim.Grid.InventoryServer LogBase m_console; InventoryManager m_inventoryManager; InventoryConfig m_config; + GridInventoryService m_inventoryService; public const string LogName = "INVENTORY"; @@ -69,13 +70,35 @@ namespace OpenSim.Grid.InventoryServer { MainLog.Instance.Notice("Initialising inventory manager..."); m_config = new InventoryConfig(LogName, (Path.Combine(Util.configDir(), "InventoryServer_Config.xml"))); - - m_inventoryManager = new InventoryManager(); - m_inventoryManager.AddDatabasePlugin(m_config.DatabaseProvider); + + m_inventoryService = new GridInventoryService(); + // m_inventoryManager = new InventoryManager(); + m_inventoryService.AddPlugin(m_config.DatabaseProvider); + MainLog.Instance.Notice(LogName, "Starting HTTP server ..."); BaseHttpServer httpServer = new BaseHttpServer(m_config.HttpPort); + httpServer.AddStreamHandler( + new RestDeserialisehandler("POST", "/GetInventory/", + m_inventoryService.GetUserInventory)); + httpServer.AddStreamHandler( + new RestDeserialisehandler("POST", "/CreateInventory/", + m_inventoryService.CreateUsersInventory)); + httpServer.AddStreamHandler( + new RestDeserialisehandler("POST", "/NewFolder/", + m_inventoryService.AddInventoryFolder)); - httpServer.AddStreamHandler(new InventoryManager.GetInventory(m_inventoryManager)); + httpServer.AddStreamHandler( + new RestDeserialisehandler("POST", "/NewItem/", + m_inventoryService.AddInventoryItem)); + httpServer.AddStreamHandler( + new RestDeserialisehandler("POST", "/DeleteItem/", + m_inventoryService.DeleteInvItem)); + + httpServer.AddStreamHandler( + new RestDeserialisehandler>("POST", "/RootFolders/", + m_inventoryService.RequestFirstLevelFolders)); + + // httpServer.AddStreamHandler(new InventoryManager.GetInventory(m_inventoryManager)); httpServer.Start(); MainLog.Instance.Notice(LogName, "Started HTTP server"); @@ -96,6 +119,9 @@ namespace OpenSim.Grid.InventoryServer switch (cmd) { case "quit": + case "add-user": + m_inventoryService.CreateUsersInventory(LLUUID.Random()); + break; case "shutdown": m_console.Close(); Environment.Exit(0); diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs index 779a72be62..b00bb76f76 100644 --- a/OpenSim/Grid/UserServer/Main.cs +++ b/OpenSim/Grid/UserServer/Main.cs @@ -27,7 +27,9 @@ */ using System; +using System.Collections.Generic; using System.IO; +using libsecondlife; using OpenSim.Framework; using OpenSim.Framework.Console; using OpenSim.Framework.Servers; @@ -44,6 +46,7 @@ namespace OpenSim.Grid.UserServer public UserLoginService m_loginService; private LogBase m_console; + private LLUUID m_lastCreatedUser = LLUUID.Random(); [STAThread] public static void Main(string[] args) @@ -123,7 +126,9 @@ namespace OpenSim.Grid.UserServer tempMD5Passwd = Util.Md5Hash(Util.Md5Hash(tempMD5Passwd) + ":" + ""); - m_userManager.AddUserProfile(tempfirstname, templastname, tempMD5Passwd, regX, regY); + LLUUID userID = m_userManager.AddUserProfile(tempfirstname, templastname, tempMD5Passwd, regX, regY); + RestObjectPoster.BeginPostObject(m_userManager._config.InventoryUrl + "CreateInventory/", userID); + m_lastCreatedUser = userID; break; } } @@ -145,9 +150,21 @@ namespace OpenSim.Grid.UserServer m_console.Close(); Environment.Exit(0); break; + + case "test-inventory": + // RestObjectPosterResponse> requester = new RestObjectPosterResponse>(); + // requester.ReturnResponseVal = TestResponse; + // requester.BeginPostObject(m_userManager._config.InventoryUrl + "RootFolders/", m_lastCreatedUser); + List folders = SyncRestObjectPoster.BeginPostObject>(m_userManager._config.InventoryUrl + "RootFolders/", m_lastCreatedUser); + break; } } + public void TestResponse(List resp) + { + System.Console.WriteLine("response got"); + } + /*private void ConfigDB(IGenericConfig configData) { try diff --git a/OpenSim/Grid/UserServer/UserLoginService.cs b/OpenSim/Grid/UserServer/UserLoginService.cs index 0af5790ec9..d3164ade15 100644 --- a/OpenSim/Grid/UserServer/UserLoginService.cs +++ b/OpenSim/Grid/UserServer/UserLoginService.cs @@ -28,12 +28,16 @@ using System; using System.Collections; +using System.Collections.Generic; using System.Net; using Nwc.XmlRpc; +using libsecondlife; using OpenSim.Framework; using OpenSim.Framework.Console; +using OpenSim.Framework.Servers; using OpenSim.Framework.Data; using OpenSim.Framework.UserManagement; +using InventoryFolder = OpenSim.Framework.InventoryFolder; namespace OpenSim.Grid.UserServer { @@ -189,5 +193,51 @@ namespace OpenSim.Grid.UserServer } } + + protected override InventoryData CreateInventoryData(LLUUID userID) + { + List folders = SyncRestObjectPoster.BeginPostObject>(m_config.InventoryUrl + "RootFolders/", userID); + if (folders.Count > 0) + { + LLUUID rootID = LLUUID.Zero; + ArrayList AgentInventoryArray = new ArrayList(); + Hashtable TempHash; + foreach (InventoryFolderBase InvFolder in folders) + { + if (InvFolder.parentID == LLUUID.Zero) + { + rootID = InvFolder.folderID; + } + TempHash = new Hashtable(); + TempHash["name"] = InvFolder.name; + TempHash["parent_id"] = InvFolder.parentID.ToStringHyphenated(); + TempHash["version"] = (Int32)InvFolder.version; + TempHash["type_default"] = (Int32)InvFolder.type; + TempHash["folder_id"] = InvFolder.folderID.ToStringHyphenated(); + AgentInventoryArray.Add(TempHash); + } + return new InventoryData(AgentInventoryArray, rootID); + } + else + { + AgentInventory userInventory = new AgentInventory(); + userInventory.CreateRootFolder(userID, false); + + ArrayList AgentInventoryArray = new ArrayList(); + Hashtable TempHash; + foreach (InventoryFolder InvFolder in userInventory.InventoryFolders.Values) + { + TempHash = new Hashtable(); + TempHash["name"] = InvFolder.FolderName; + TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated(); + TempHash["version"] = (Int32)InvFolder.Version; + TempHash["type_default"] = (Int32)InvFolder.DefaultType; + TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated(); + AgentInventoryArray.Add(TempHash); + } + + return new InventoryData(AgentInventoryArray, userInventory.InventoryRoot.FolderID); + } + } } } \ No newline at end of file diff --git a/OpenSim/Region/Communications/Local/LocalInventoryService.cs b/OpenSim/Region/Communications/Local/LocalInventoryService.cs index c38e92270f..40e6601cc9 100644 --- a/OpenSim/Region/Communications/Local/LocalInventoryService.cs +++ b/OpenSim/Region/Communications/Local/LocalInventoryService.cs @@ -76,7 +76,7 @@ namespace OpenSim.Region.Communications.Local } } - public override void AddNewInventoryFolder(LLUUID userID, InventoryFolderImpl folder) + public override void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder) { AddFolder(folder); } @@ -88,7 +88,7 @@ namespace OpenSim.Region.Communications.Local public override void DeleteInventoryItem(LLUUID userID, InventoryItemBase item) { - deleteItem(item); + DeleteItem(item); } } } \ No newline at end of file diff --git a/OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs b/OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs index 7597e79e2b..934a814aa5 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs @@ -25,9 +25,11 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ +using System; using System.Collections.Generic; using libsecondlife; using OpenSim.Framework; +using OpenSim.Framework.Servers; using OpenSim.Framework.Communications; using OpenSim.Framework.Communications.Cache; @@ -36,6 +38,7 @@ namespace OpenSim.Region.Communications.OGS1 public class OGS1InventoryService : IInventoryServices { private string _inventoryServerUrl; + private Dictionary m_RequestingInventory = new Dictionary(); public OGS1InventoryService(string inventoryServerUrl) { @@ -47,31 +50,96 @@ namespace OpenSim.Region.Communications.OGS1 public void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, InventoryItemInfo itemCallBack) { - //TODO! Uncomment when all is done - //SerializableInventory userInventory = null; - //RestClient inventoryServer = new RestClient(_inventoryServerUrl); - //inventoryServer.AddResourcePath("inventory"); - //inventoryServer.AddResourcePath("user"); - //inventoryServer.AddResourcePath(userID.ToStringHyphenated()); - - //using (Stream userInventoryStream = inventoryServer.Request()) - //{ - // XmlSerializer x = new XmlSerializer(typeof(SerializableInventory)); - // userInventory = (SerializableInventory)x.Deserialize(userInventoryStream); - //} + if (!m_RequestingInventory.ContainsKey(userID)) + { + InventoryRequest request = new InventoryRequest(userID, folderCallBack, itemCallBack); + m_RequestingInventory.Add(userID, request); + RequestInventory(userID); + } } - public void AddNewInventoryFolder(LLUUID userID, InventoryFolderImpl folder) + private void RequestInventory(LLUUID userID) { + try + { + RestObjectPosterResponse requester = new RestObjectPosterResponse(); + requester.ReturnResponseVal = InventoryResponse; + requester.BeginPostObject(_inventoryServerUrl + "/GetInventory/", userID); + } + catch (Exception) + { + } + } + + private void InventoryResponse(InventoryCollection response) + { + LLUUID userID = response.UserID; + if (m_RequestingInventory.ContainsKey(userID)) + { + + InventoryFolderImpl rootFolder = null; + InventoryRequest request = m_RequestingInventory[userID]; + foreach (InventoryFolderBase folder in response.Folders) + { + if (folder.parentID == LLUUID.Zero) + { + InventoryFolderImpl newfolder = new InventoryFolderImpl(folder); + rootFolder = newfolder; + request.FolderCallBack(userID, newfolder); + } + } + + if (rootFolder != null) + { + foreach (InventoryFolderBase folder in response.Folders) + { + if (folder.folderID != rootFolder.folderID) + { + InventoryFolderImpl newfolder = new InventoryFolderImpl(folder); + request.FolderCallBack(userID, newfolder); + } + } + + foreach (InventoryItemBase item in response.AllItems) + { + request.ItemCallBack(userID, item); + } + } + } + } + + public void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder) + { + try + { + RestObjectPoster.BeginPostObject(_inventoryServerUrl + "/NewFolder/", folder); + } + catch (Exception) + { + } } public void AddNewInventoryItem(LLUUID userID, InventoryItemBase item) { + try + { + RestObjectPoster.BeginPostObject(_inventoryServerUrl + "/NewItem/", item); + } + catch (Exception) + { + } } public void DeleteInventoryItem(LLUUID userID, InventoryItemBase item) { + try + { + RestObjectPoster.BeginPostObject(_inventoryServerUrl + "/DeleteItem/", item); + } + catch (Exception) + { + } } public void CreateNewUserInventory(LLUUID user) @@ -84,5 +152,19 @@ namespace OpenSim.Region.Communications.OGS1 } #endregion + + public class InventoryRequest + { + public LLUUID UserID; + public InventoryFolderInfo FolderCallBack; + public InventoryItemInfo ItemCallBack; + + public InventoryRequest(LLUUID userId, InventoryFolderInfo folderCall, InventoryItemInfo itemCall) + { + UserID = userId; + FolderCallBack = folderCall; + ItemCallBack = itemCall; + } + } } } \ No newline at end of file diff --git a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs index 96380f7395..9e1206bde2 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs @@ -162,9 +162,10 @@ namespace OpenSim.Region.Communications.OGS1 return data; } - public void AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY) + public LLUUID AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY) { throw new Exception("The method or operation is not implemented."); + return LLUUID.Zero; } } } \ No newline at end of file