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. --- OpenSim/Region/Application/OpenSimMain.cs | 6 +-- .../Communications/Local/CommunicationsLocal.cs | 17 +++++++- .../Communications/Local/LocalInventoryService.cs | 51 ++++++++++++++++++++++ .../Communications/Local/LocalLoginService.cs | 49 +++++++++++++++++++++ OpenSim/Region/Environment/Scenes/Scene.cs | 6 +-- .../MonoSqliteDataStore.cs | 2 +- 6 files changed, 121 insertions(+), 10 deletions(-) create mode 100644 OpenSim/Region/Communications/Local/LocalInventoryService.cs (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs index cd53728..4b95e02 100644 --- a/OpenSim/Region/Application/OpenSimMain.cs +++ b/OpenSim/Region/Application/OpenSimMain.cs @@ -155,7 +155,7 @@ namespace OpenSim } // Load all script engines found - OpenSim.Region.Environment.Scenes.Scripting.ScriptEngineLoader ScriptEngineLoader = new OpenSim.Region.Environment.Scenes.Scripting.ScriptEngineLoader(); + //OpenSim.Region.Environment.Scenes.Scripting.ScriptEngineLoader ScriptEngineLoader = new OpenSim.Region.Environment.Scenes.Scripting.ScriptEngineLoader(); for (int i = 0; i < configFiles.Length; i++) { @@ -184,10 +184,6 @@ namespace OpenSim { this.m_udpServers[i].ServerListener(); } - - - - } private static void CreateDefaultRegionInfoXml(string fileName) 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); + } + } } } diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index b423e0a..f24def2 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -1020,7 +1020,8 @@ namespace OpenSim.Region.Environment.Scenes public void AddScriptEngine(OpenSim.Region.Environment.Scenes.Scripting.ScriptEngineInterface ScriptEngine) { ScriptEngines.Add(ScriptEngine); - ScriptEngine.InitializeEngine(this); } + ScriptEngine.InitializeEngine(this); + } #endregion public LLUUID ConvertLocalIDToFullID(uint localID) @@ -1037,8 +1038,7 @@ namespace OpenSim.Region.Environment.Scenes } } } - - return null; + return LLUUID.Zero; } } } diff --git a/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs b/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs index bd6658c..dede5ea 100644 --- a/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs +++ b/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs @@ -467,7 +467,7 @@ namespace OpenSim.DataStore.MonoSqliteStorage addPrim(prim, obj.UUID); } - MainLog.Instance.Verbose("Attempting to do database update...."); + // MainLog.Instance.Verbose("Attempting to do database update...."); primDa.Update(ds, "prims"); shapeDa.Update(ds, "primshapes"); // MainLog.Instance.Verbose("Dump of prims:", ds.GetXml()); -- cgit v1.1