From a228b5984e6523456871f2f8e51aa086050acbf2 Mon Sep 17 00:00:00 2001 From: MW Date: Tue, 14 Aug 2007 13:54:46 +0000 Subject: Start of Inventory service, currently only (partially) functional in standalone mode and using sqlite). In standalone mode, if you have account authenticate turned on (setting in opensim.ini) then when you create a new account, a set of inventory is created for that account and stored in database (currently only a set of empty folders). Then during login the database is search for that set and sent to the client in the login response. More functions will be added soon, like creating new folders (and a bit later items) from the client inventory window. --- .../Communications/Local/CommunicationsLocal.cs | 17 +++++++- .../Communications/Local/LocalInventoryService.cs | 51 ++++++++++++++++++++++ .../Communications/Local/LocalLoginService.cs | 49 +++++++++++++++++++++ 3 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 OpenSim/Region/Communications/Local/LocalInventoryService.cs (limited to 'OpenSim/Region/Communications') diff --git a/OpenSim/Region/Communications/Local/CommunicationsLocal.cs b/OpenSim/Region/Communications/Local/CommunicationsLocal.cs index 3ad33f4..e2a953c 100644 --- a/OpenSim/Region/Communications/Local/CommunicationsLocal.cs +++ b/OpenSim/Region/Communications/Local/CommunicationsLocal.cs @@ -32,23 +32,32 @@ using OpenSim.Framework.Servers; using OpenSim.Framework.Communications.Caches; using OpenSim.Framework.Console; using OpenSim.Framework.Utilities; +using OpenSim.Framework.Data; namespace OpenSim.Region.Communications.Local { public class CommunicationsLocal : CommunicationsManager { - public LocalBackEndServices InstanceServices = new LocalBackEndServices(); + public LocalBackEndServices InstanceServices; public LocalUserServices UserServices; public LocalLoginService LoginServices; + public LocalInventoryService InvenServices; public CommunicationsLocal(NetworkServersInfo serversInfo, BaseHttpServer httpServer, AssetCache assetCache, bool accountsAuthenticate, string welcomeMessage ) : base(serversInfo, httpServer, assetCache) { + InvenServices = new LocalInventoryService(); + InvenServices.AddPlugin("OpenSim.Framework.Data.SQLite.dll"); + InventoryServer = InvenServices; + UserServices = new LocalUserServices(this, serversInfo); UserServices.AddPlugin("OpenSim.Framework.Data.DB4o.dll"); UserServer = UserServices; + + InstanceServices = new LocalBackEndServices(); GridServer = InstanceServices; InterRegion = InstanceServices; + LoginServices = new LocalLoginService(UserServices, welcomeMessage, this, serversInfo, accountsAuthenticate); httpServer.AddXmlRPCHandler("login_to_simulator", LoginServices.XmlRpcLoginMethod); } @@ -78,6 +87,12 @@ namespace OpenSim.Region.Communications.Local tempMD5Passwd = Util.Md5Hash(Util.Md5Hash(tempMD5Passwd) + ":" + ""); this.UserServices.AddUserProfile(tempfirstname, templastname, tempMD5Passwd, regX, regY); + UserProfileData userProf = this.UserServer.GetUserProfile(tempfirstname, templastname); + if (userProf != null) + { + this.InvenServices.CreateNewUserInventory(userProf.UUID); + Console.WriteLine("created new inventory set for " + tempfirstname + " " + templastname); + } break; } } diff --git a/OpenSim/Region/Communications/Local/LocalInventoryService.cs b/OpenSim/Region/Communications/Local/LocalInventoryService.cs new file mode 100644 index 0000000..35c2c8c --- /dev/null +++ b/OpenSim/Region/Communications/Local/LocalInventoryService.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using libsecondlife; +using OpenSim.Framework.Communications; +using OpenSim.Framework.Data; +using OpenSim.Framework.Types; +using OpenSim.Framework.UserManagement; +using OpenSim.Framework.Utilities; +using OpenSim.Framework.InventoryServiceBase; +using InventoryFolder = OpenSim.Framework.Communications.Caches.InventoryFolder; + +namespace OpenSim.Region.Communications.Local +{ + public class LocalInventoryService : InventoryServiceBase , IInventoryServices + { + + public LocalInventoryService() + { + + } + + public void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, InventoryItemInfo itemCallBack) + { + List folders = this.RequestFirstLevelFolders(userID); + InventoryFolder rootFolder = null; + + //need to make sure we send root folder first + foreach (InventoryFolderBase folder in folders) + { + if (folder.parentID == libsecondlife.LLUUID.Zero) + { + InventoryFolder newfolder = new InventoryFolder(folder); + rootFolder = newfolder; + folderCallBack(userID, newfolder); + } + } + + if (rootFolder != null) + { + foreach (InventoryFolderBase folder in folders) + { + if (folder.folderID != rootFolder.folderID) + { + InventoryFolder newfolder = new InventoryFolder(folder); + folderCallBack(userID, newfolder); + } + } + } + } + } +} diff --git a/OpenSim/Region/Communications/Local/LocalLoginService.cs b/OpenSim/Region/Communications/Local/LocalLoginService.cs index 19a1e8c..661fbbe 100644 --- a/OpenSim/Region/Communications/Local/LocalLoginService.cs +++ b/OpenSim/Region/Communications/Local/LocalLoginService.cs @@ -1,10 +1,13 @@ using System; +using System.Collections; +using System.Collections.Generic; using libsecondlife; using OpenSim.Framework.Communications; using OpenSim.Framework.Data; using OpenSim.Framework.Types; using OpenSim.Framework.UserManagement; using OpenSim.Framework.Utilities; +using OpenSim.Framework.Inventory; namespace OpenSim.Region.Communications.Local { @@ -109,5 +112,51 @@ namespace OpenSim.Region.Communications.Local } } + + protected override InventoryData CreateInventoryData(LLUUID userID) + { + List folders = this.m_Parent.InvenServices.RequestFirstLevelFolders(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 (OpenSim.Framework.Inventory.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); + } + } } } -- cgit v1.1