diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolder.cs b/OpenSim/Framework/Communications/Cache/InventoryFolder.cs index 300a6e310e..6b0e2b43e2 100644 --- a/OpenSim/Framework/Communications/Cache/InventoryFolder.cs +++ b/OpenSim/Framework/Communications/Cache/InventoryFolder.cs @@ -44,6 +44,21 @@ namespace OpenSim.Framework.Communications.Caches public Dictionary Items = new Dictionary(); public Dictionary SubFolders = new Dictionary(); + public InventoryFolder(InventoryFolderBase folderbase) + { + this.agentID = folderbase.agentID; + this.folderID = folderbase.folderID; + this.name = folderbase.name; + this.parentID = folderbase.parentID; + this.type = folderbase.type; + this.version = folderbase.version; + } + + public InventoryFolder() + { + + } + // Methods public InventoryFolder CreateNewSubFolder(LLUUID folderID, string folderName, ushort type) { diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs index 2f3691cf82..2271550e91 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs @@ -168,18 +168,18 @@ namespace OpenSim.Framework.Communications.Caches /// private void RequestInventoryForUser(LLUUID userID, CachedUserInfo userInfo) { - // this.m_parent.InventoryServer.RequestInventoryForUser(userID, userInfo.FolderReceive, userInfo.ItemReceive); + //this.m_parent.InventoryServer.RequestInventoryForUser(userID, userInfo.FolderReceive, userInfo.ItemReceive); //for now we manually create the root folder, // but should be requesting all inventory from inventory server. - InventoryFolder folderInfo = new InventoryFolder(); + /* InventoryFolder folderInfo = new InventoryFolder(); folderInfo.agentID = userID; folderInfo.folderID = userInfo.UserProfile.rootInventoryFolderID; folderInfo.name = "My Inventory"; folderInfo.parentID = LLUUID.Zero; folderInfo.type = 8; folderInfo.version = 1; - userInfo.FolderReceive(userID, folderInfo); + userInfo.FolderReceive(userID, folderInfo);*/ } /// diff --git a/OpenSim/Framework/Data.SQLite/SQLiteInventoryStore.cs b/OpenSim/Framework/Data.SQLite/SQLiteInventoryStore.cs new file mode 100644 index 0000000000..811a355de1 --- /dev/null +++ b/OpenSim/Framework/Data.SQLite/SQLiteInventoryStore.cs @@ -0,0 +1,401 @@ +using System; +using System.Collections.Generic; +using System.Text; + +using OpenSim.Framework.Console; +using OpenSim.Framework.Types; +using OpenSim.Framework.Utilities; +using libsecondlife; + +using System.Data; +using System.Data.SqlTypes; + +using Mono.Data.SqliteClient; + +namespace OpenSim.Framework.Data.SQLite +{ + + public class SQLiteInventoryStore : IInventoryData + { + private const string invItemsSelect = "select * from inventoryitems"; + private const string invFoldersSelect = "select * from inventoryfolders"; + + private DataSet ds; + private SqliteDataAdapter invItemsDa; + private SqliteDataAdapter invFoldersDa; + + /// + /// Initialises the interface + /// + public void Initialise() + { + Initialise("inventoryStore.db", "inventoryDatabase"); + } + + public void Initialise(string dbfile, string dbname) + { + string connectionString = "URI=file:" + dbfile + ",version=3"; + + MainLog.Instance.Verbose("Inventory", "Sqlite - connecting: " + dbfile); + SqliteConnection conn = new SqliteConnection(connectionString); + + SqliteCommand itemsSelectCmd = new SqliteCommand(invItemsSelect, conn); + invItemsDa = new SqliteDataAdapter(itemsSelectCmd); + // SqliteCommandBuilder primCb = new SqliteCommandBuilder(primDa); + + SqliteCommand foldersSelectCmd = new SqliteCommand(invFoldersSelect, conn); + invFoldersDa = new SqliteDataAdapter(foldersSelectCmd); + + ds = new DataSet(); + + invItemsDa.Fill(ds, "inventoryitems"); + invFoldersDa.Fill(ds, "inventoryfolders"); + ds.AcceptChanges(); + + DataTable itemsTable = ds.Tables["inventoryitems"]; + itemsTable.PrimaryKey = new DataColumn[] { itemsTable.Columns["UUID"] }; + setupItemsCommands(invItemsDa, conn); + + // shapeDa.FillSchema(ds, SchemaType.Source, "ShapeSchema"); + DataTable folderTable = ds.Tables["inventoryfolders"]; + folderTable.PrimaryKey = new DataColumn[] { folderTable.Columns["UUID"] }; + setupFoldersCommands(invFoldersDa, conn); + return; + } + + private SqliteParameter createSqliteParameter(string name, DbType type) + { + SqliteParameter param = new SqliteParameter(); + param.ParameterName = ":" + name; + param.DbType = type; + param.SourceColumn = name; + param.SourceVersion = DataRowVersion.Current; + return param; + } + + private Dictionary createInventoryItemsDataDefs() + { + Dictionary data = new Dictionary(); + data.Add("UUID", DbType.String); //inventoryID + data.Add("assetID", DbType.String); + data.Add("assetType", DbType.Int32); + data.Add("invType", DbType.Int32); + data.Add("parentFolderID", DbType.String); + data.Add("avatarID", DbType.String); + data.Add("creatorsID", DbType.String); + + data.Add("inventoryName", DbType.String); + data.Add("inventoryDescription", DbType.String); + // permissions + data.Add("inventoryNextPermissions", DbType.Int32); + data.Add("inventoryCurrentPermissions", DbType.Int32); + data.Add("inventoryBasePermissions", DbType.Int32); + data.Add("inventoryEveryOnePermissions", DbType.Int32); + + return data; + } + + private Dictionary createShapeDataDefs() + { + Dictionary data = new Dictionary(); + data.Add("UUID", DbType.String); //folderID + // shape is an enum + data.Add("name", DbType.String); + // vectors + data.Add("agentID", DbType.String); + data.Add("parentID", DbType.String); + data.Add("type", DbType.Int32); + data.Add("version", DbType.Int32); + return data; + } + + private SqliteCommand createInsertCommand(string table, Dictionary defs) + { + /** + * This is subtle enough to deserve some commentary. + * Instead of doing *lots* and *lots of hardcoded strings + * for database definitions we'll use the fact that + * realistically all insert statements look like "insert + * into A(b, c) values(:b, :c) on the parameterized query + * front. If we just have a list of b, c, etc... we can + * generate these strings instead of typing them out. + */ + string[] cols = new string[defs.Keys.Count]; + defs.Keys.CopyTo(cols, 0); + + string sql = "insert into " + table + "("; + sql += String.Join(", ", cols); + // important, the first ':' needs to be here, the rest get added in the join + sql += ") values (:"; + sql += String.Join(", :", cols); + sql += ")"; + SqliteCommand cmd = new SqliteCommand(sql); + + // this provides the binding for all our parameters, so + // much less code than it used to be + foreach (KeyValuePair kvp in defs) + { + cmd.Parameters.Add(createSqliteParameter(kvp.Key, kvp.Value)); + } + return cmd; + } + + private SqliteCommand createUpdateCommand(string table, string pk, Dictionary defs) + { + string sql = "update " + table + " set "; + string subsql = ""; + foreach (string key in defs.Keys) + { + if (subsql.Length > 0) + { // a map function would rock so much here + subsql += ", "; + } + subsql += key + "= :" + key; + } + sql += subsql; + sql += " where " + pk; + SqliteCommand cmd = new SqliteCommand(sql); + + // this provides the binding for all our parameters, so + // much less code than it used to be + foreach (KeyValuePair kvp in defs) + { + cmd.Parameters.Add(createSqliteParameter(kvp.Key, kvp.Value)); + } + return cmd; + } + + private void setupItemsCommands(SqliteDataAdapter da, SqliteConnection conn) + { + Dictionary invDataDefs = createInventoryItemsDataDefs(); + + da.InsertCommand = createInsertCommand("inventoryitems", invDataDefs); + da.InsertCommand.Connection = conn; + + da.UpdateCommand = createUpdateCommand("inventoryitems", "UUID=:UUID", invDataDefs); + da.UpdateCommand.Connection = conn; + + SqliteCommand delete = new SqliteCommand("delete from inventoryitems where UUID = :UUID"); + delete.Parameters.Add(createSqliteParameter("UUID", DbType.String)); + delete.Connection = conn; + da.DeleteCommand = delete; + } + + private void setupFoldersCommands(SqliteDataAdapter da, SqliteConnection conn) + { + Dictionary shapeDataDefs = createShapeDataDefs(); + + da.InsertCommand = createInsertCommand("inventoryfolders", shapeDataDefs); + da.InsertCommand.Connection = conn; + + da.UpdateCommand = createUpdateCommand("inventoryfolders", "UUID=:UUID", shapeDataDefs); + da.UpdateCommand.Connection = conn; + + SqliteCommand delete = new SqliteCommand("delete from inventoryfolders where UUID = :UUID"); + delete.Parameters.Add(createSqliteParameter("UUID", DbType.String)); + delete.Connection = conn; + da.DeleteCommand = delete; + } + + private InventoryFolderBase buildFolder(DataRow row) + { + InventoryFolderBase folder = new InventoryFolderBase(); + folder.folderID = new LLUUID((string)row["UUID"]); + folder.name = (string)row["name"]; + folder.agentID = new LLUUID((string)row["agentID"]); + folder.parentID = new LLUUID((string)row["parentID"]); + folder.type = Convert.ToInt16(row["type"]); + folder.version = Convert.ToUInt16(row["version"]); + return folder; + } + + private void fillFolderRow(DataRow row, InventoryFolderBase folder) + { + row["UUID"] = folder.folderID; + row["name"] = folder.name; + row["agentID"] = folder.agentID; + row["parentID"] = folder.parentID; + row["type"] = folder.type; + row["version"] = folder.version; + } + + private void addFolder(InventoryFolderBase folder) + { + DataTable inventoryFolderTable = ds.Tables["inventoryfolders"]; + + DataRow inventoryRow = inventoryFolderTable.Rows.Find(folder.folderID); + if (inventoryRow == null) + { + inventoryRow = inventoryFolderTable.NewRow(); + fillFolderRow(inventoryRow, folder); + inventoryFolderTable.Rows.Add(inventoryRow); + } + else + { + fillFolderRow(inventoryRow, folder); + } + + this.invFoldersDa.Update(ds, "inventoryfolders"); + } + + public void Shutdown() + { + // TODO: DataSet commit + } + + /// + /// Closes the interface + /// + public void Close() + { + } + + /// + /// The plugin being loaded + /// + /// A string containing the plugin name + public string getName() + { + return "SQLite Inventory Data Interface"; + } + + /// + /// The plugins version + /// + /// A string containing the plugin version + public string getVersion() + { + return "0.1"; + } + + /// + /// Returns a list of inventory items contained within the specified folder + /// + /// The UUID of the target folder + /// A List of InventoryItemBase items + public List getInventoryInFolder(LLUUID folderID) + { + return null; + } + + /// + /// Returns a list of the root folders within a users inventory + /// + /// The user whos inventory is to be searched + /// A list of folder objects + public List getUserRootFolders(LLUUID user) + { + return null; + } + + /// + /// Returns the users inventory root folder. + /// + /// The UUID of the user who is having inventory being returned + /// Root inventory folder + public InventoryFolderBase getUserRootFolder(LLUUID user) + { + List folders = new List(); + DataTable inventoryFolderTable = ds.Tables["inventoryfolders"]; + string selectExp = "agentID = '"+ user.ToString()+"' AND parentID = '"+ LLUUID.Zero.ToString()+"'"; + DataRow[] rows = inventoryFolderTable.Select(selectExp); + foreach (DataRow row in rows) + { + folders.Add(this.buildFolder(row)); + } + + if (folders.Count == 1) + { + //we found the root + //System.Console.WriteLine("found root inventory folder"); + return folders[0]; + } + else if (folders.Count > 1) + { + //err shouldn't be more than one root + //System.Console.WriteLine("found more than one root inventory folder"); + } + else if (folders.Count == 0) + { + // no root? + //System.Console.WriteLine("couldn't find root inventory folder"); + } + + return null; + } + + /// + /// Returns a list of inventory folders contained in the folder 'parentID' + /// + /// The folder to get subfolders for + /// A list of inventory folders + public List getInventoryFolders(LLUUID parentID) + { + List folders = new List(); + DataTable inventoryFolderTable = ds.Tables["inventoryfolders"]; + string selectExp = "parentID = '" + parentID.ToString() + "'"; + DataRow[] rows = inventoryFolderTable.Select(selectExp); + foreach (DataRow row in rows) + { + folders.Add(this.buildFolder(row)); + } + // System.Console.WriteLine("found " + folders.Count + " inventory folders"); + return folders; + } + + /// + /// Returns an inventory item by its UUID + /// + /// The UUID of the item to be returned + /// A class containing item information + public InventoryItemBase getInventoryItem(LLUUID item) + { + return null; + } + + /// + /// Returns a specified inventory folder by its UUID + /// + /// The UUID of the folder to be returned + /// A class containing folder information + public InventoryFolderBase getInventoryFolder(LLUUID folder) + { + return null; + } + + /// + /// Creates a new inventory item based on item + /// + /// The item to be created + public void addInventoryItem(InventoryItemBase item) + { + } + + /// + /// Updates an inventory item with item (updates based on ID) + /// + /// The updated item + public void updateInventoryItem(InventoryItemBase item) + { + } + + /// + /// Adds a new folder specified by folder + /// + /// The inventory folder + public void addInventoryFolder(InventoryFolderBase folder) + { + this.addFolder(folder); + } + + /// + /// Updates a folder based on its ID with folder + /// + /// The inventory folder + public void updateInventoryFolder(InventoryFolderBase folder) + { + this.addFolder(folder); + } + } +} + diff --git a/OpenSim/Framework/InventoryServiceBase/InventoryServiceBase.cs b/OpenSim/Framework/InventoryServiceBase/InventoryServiceBase.cs index f2e6128566..10da633000 100644 --- a/OpenSim/Framework/InventoryServiceBase/InventoryServiceBase.cs +++ b/OpenSim/Framework/InventoryServiceBase/InventoryServiceBase.cs @@ -12,11 +12,11 @@ namespace OpenSim.Framework.InventoryServiceBase public class InventoryServiceBase { protected Dictionary m_plugins = new Dictionary(); - protected IAssetServer m_assetServer; + //protected IAssetServer m_assetServer; - public InventoryServiceBase(IAssetServer assetServer) + public InventoryServiceBase() { - m_assetServer = assetServer; + //m_assetServer = assetServer; } /// @@ -25,7 +25,7 @@ namespace OpenSim.Framework.InventoryServiceBase /// The filename to the user server plugin DLL public void AddPlugin(string FileName) { - MainLog.Instance.Verbose("Inventorytorage: Attempting to load " + FileName); + MainLog.Instance.Verbose("Inventory", "Inventorystorage: Attempting to load " + FileName); Assembly pluginAssembly = Assembly.LoadFrom(FileName); foreach (Type pluginType in pluginAssembly.GetTypes()) @@ -108,13 +108,31 @@ namespace OpenSim.Framework.InventoryServiceBase return itemsList; } + public void AddFolder(InventoryFolderBase folder) + { + foreach (KeyValuePair plugin in m_plugins) + { + plugin.Value.addInventoryFolder(folder); + } + } + /// /// /// /// public void AddNewInventorySet(UsersInventory inventory) { + foreach (InventoryFolderBase folder in inventory.Folders.Values) + { + this.AddFolder(folder); + } + } + public void CreateNewUserInventory(LLUUID user) + { + UsersInventory inven = new UsersInventory(); + inven.CreateNewInventorySet(user); + this.AddNewInventorySet(inven); } public class UsersInventory @@ -127,9 +145,45 @@ namespace OpenSim.Framework.InventoryServiceBase } - protected virtual void CreateNewInventorySet() + public virtual void CreateNewInventorySet(LLUUID user) { + InventoryFolderBase folder = new InventoryFolderBase(); + folder.parentID = LLUUID.Zero; + folder.agentID = user; + folder.folderID = LLUUID.Random(); + folder.name = "My Inventory"; + folder.type = 8; + folder.version = 1; + Folders.Add(folder.folderID, folder); + LLUUID rootFolder = folder.folderID; + + folder = new InventoryFolderBase(); + folder.parentID = rootFolder; + folder.agentID = user; + folder.folderID = LLUUID.Random(); + folder.name = "Textures"; + folder.type = 0; + folder.version = 1; + Folders.Add(folder.folderID, folder); + + folder = new InventoryFolderBase(); + folder.parentID = rootFolder; + folder.agentID = user; + folder.folderID = LLUUID.Random(); + folder.name = "Objects"; + folder.type = 6; + folder.version = 1; + Folders.Add(folder.folderID, folder); + + folder = new InventoryFolderBase(); + folder.parentID = rootFolder; + folder.agentID = user; + folder.folderID = LLUUID.Random(); + folder.name = "Clothes"; + folder.type = 5; + folder.version = 1; + Folders.Add(folder.folderID, folder); } } } diff --git a/OpenSim/Framework/UserManager/LoginService.cs b/OpenSim/Framework/UserManager/LoginService.cs index a26a0c4161..b75c4fbf0a 100644 --- a/OpenSim/Framework/UserManager/LoginService.cs +++ b/OpenSim/Framework/UserManager/LoginService.cs @@ -89,14 +89,14 @@ namespace OpenSim.Framework.UserManagement LLUUID agentID = userProfile.UUID; // Inventory Library Section - AgentInventory userInventory = this.GetUsersInventory(agentID); - ArrayList AgentInventoryArray = this.CreateInventoryArray(userInventory); + InventoryData inventData = this.CreateInventoryData(agentID); + ArrayList AgentInventoryArray = inventData.InventoryArray; Hashtable InventoryRootHash = new Hashtable(); - InventoryRootHash["folder_id"] = userInventory.InventoryRoot.FolderID.ToStringHyphenated(); + InventoryRootHash["folder_id"] = inventData.RootFolderID.ToStringHyphenated(); ArrayList InventoryRoot = new ArrayList(); InventoryRoot.Add(InventoryRootHash); - userProfile.rootInventoryFolderID = userInventory.InventoryRoot.FolderID; + userProfile.rootInventoryFolderID = inventData.RootFolderID; // Circuit Code uint circode = (uint)(Util.RandomClass.Next()); @@ -253,16 +253,11 @@ namespace OpenSim.Framework.UserManagement return inventoryLibOwner; } - protected virtual AgentInventory GetUsersInventory(LLUUID agentID) + protected virtual InventoryData CreateInventoryData(LLUUID userID) { AgentInventory userInventory = new AgentInventory(); - userInventory.CreateRootFolder(agentID, false); + userInventory.CreateRootFolder(userID, false); - return userInventory; - } - - protected virtual ArrayList CreateInventoryArray(AgentInventory userInventory) - { ArrayList AgentInventoryArray = new ArrayList(); Hashtable TempHash; foreach (InventoryFolder InvFolder in userInventory.InventoryFolders.Values) @@ -275,7 +270,20 @@ namespace OpenSim.Framework.UserManagement TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated(); AgentInventoryArray.Add(TempHash); } - return AgentInventoryArray; + + return new InventoryData(AgentInventoryArray, userInventory.InventoryRoot.FolderID); + } + + public class InventoryData + { + public ArrayList InventoryArray = null; + public LLUUID RootFolderID = LLUUID.Zero; + + public InventoryData(ArrayList invList, LLUUID rootID) + { + InventoryArray = invList; + RootFolderID = rootID; + } } } } diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs index cd53728420..4b95e022d3 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 3ad33f4fd4..e2a953ca41 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 0000000000..35c2c8cf01 --- /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 19a1e8cf57..661fbbe21d 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 b423e0ac60..f24def2c15 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 bd6658c674..dede5eac9f 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()); diff --git a/bin/inventoryStore.db b/bin/inventoryStore.db new file mode 100644 index 0000000000..070db2b0f9 Binary files /dev/null and b/bin/inventoryStore.db differ diff --git a/prebuild.xml b/prebuild.xml index 4a62fde41c..67c7e8a740 100644 --- a/prebuild.xml +++ b/prebuild.xml @@ -514,6 +514,7 @@ + @@ -810,7 +811,10 @@ + + + diff --git a/share/sql/sqlite3-inventory.sql b/share/sql/sqlite3-inventory.sql new file mode 100644 index 0000000000..0575c28343 --- /dev/null +++ b/share/sql/sqlite3-inventory.sql @@ -0,0 +1,40 @@ +-- +-- Database schema for inventory storage +-- +-- +-- Some type mappings +-- LLUID => char(36) (in ascii hex format) +-- uint => integer +-- string => varchar(256) until such time as we know we need bigger + +create table inventoryitems ( + UUID char(36) primary key, -- inventoryid + assetID char(36), + assetType integer, + invType integer, + parentFolderID char(36), + avatarID char(36), + creatorsID char(36), + inventoryName varchar(256), + inventoryDescription varchar(256), + -- permissions + inventoryNextPermissions integer, + inventoryCurrentPermissions integer, + inventoryBasePermissions integer, + inventoryEveryOnePermissions integer +); + +create index inventoryitems_parent on inventoryitems(parentFolderID); +create index inventoryitems_ownerid on inventoryitems(avatarID); +create index inventoryitems_assetid on inventoryitems(assetID); + +create table inventoryfolders ( + -- The same UUID as prim, just to keep them easily linked + UUID varchar(36) primary key not null, --folderid + name varchar(256), + agentID char(36), + parentID char(36), + type integer, + version integer +); +