From 5df851761aa796cba70a3b6d8b36d119502c1de2 Mon Sep 17 00:00:00 2001 From: MW Date: Sat, 1 Dec 2007 18:49:17 +0000 Subject: 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/Local/LocalInventoryService.cs | 4 +- .../Communications/OGS1/OGS1InventoryService.cs | 110 ++++++++++++++++++--- .../Region/Communications/OGS1/OGS1UserServices.cs | 3 +- 3 files changed, 100 insertions(+), 17 deletions(-) (limited to 'OpenSim/Region/Communications') diff --git a/OpenSim/Region/Communications/Local/LocalInventoryService.cs b/OpenSim/Region/Communications/Local/LocalInventoryService.cs index c38e922..40e6601 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 7597e79..934a814 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 96380f7..9e1206b 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 -- cgit v1.1