From c80c6e977414196fe7b855e885a5872ce5c24821 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 11 Feb 2008 20:10:44 +0000 Subject: Documenting and minor tweaks --- .../Framework/Communications/IInventoryServices.cs | 35 +++++ .../Communications/InventoryServiceBase.cs | 146 +++++++++------------ 2 files changed, 99 insertions(+), 82 deletions(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/Communications/IInventoryServices.cs b/OpenSim/Framework/Communications/IInventoryServices.cs index 15a2f02..ddb19ba 100644 --- a/OpenSim/Framework/Communications/IInventoryServices.cs +++ b/OpenSim/Framework/Communications/IInventoryServices.cs @@ -36,19 +36,54 @@ namespace OpenSim.Framework.Communications public delegate void InventoryItemInfo(LLUUID userID, InventoryItemBase itemInfo); + /// + /// Defines all the operations one can perform on a user's inventory. + /// public interface IInventoryServices { void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, InventoryItemInfo itemCallBack); + + /// + /// Add a new folder to the given user's inventory + /// + /// + /// void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder); + void MoveInventoryFolder(LLUUID userID, InventoryFolderBase folder); + + /// + /// Add a new item to the given user's inventory + /// + /// + /// void AddNewInventoryItem(LLUUID userID, InventoryItemBase item); + + /// + /// Delete an item from the given user's inventory + /// + /// + /// void DeleteInventoryItem(LLUUID userID, InventoryItemBase item); + + /// + /// Create a new inventory for the given user + /// + /// void CreateNewUserInventory(LLUUID user); + bool HasInventoryForUser(LLUUID userID); + + /// + /// Retrieve the root inventory folder for the given user. + /// + /// + /// null if no root folder was found InventoryFolderBase RequestRootFolder(LLUUID userID); /// /// Returns the root folder plus any folders in root (so down one level in the Inventory folders tree) + /// for the given user. /// /// /// diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index 897aa9a..fd9ab1b 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -36,16 +36,13 @@ namespace OpenSim.Framework.Communications { public abstract class InventoryServiceBase : IInventoryServices { - private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private static readonly log4net.ILog m_log + = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); protected Dictionary m_plugins = new Dictionary(); - //protected IAssetServer m_assetServer; - - public InventoryServiceBase() - { - //m_assetServer = assetServer; - } + #region Plugin methods + /// /// Adds a new user server plugin - plugins will be requested in the order they were loaded. /// @@ -75,18 +72,19 @@ namespace OpenSim.Framework.Communications } } } + + #endregion + + #region IInventoryServices methods + // See IInventoryServices public List RequestFirstLevelFolders(Guid rawUserID) { LLUUID userID = new LLUUID(rawUserID); return RequestFirstLevelFolders(userID); } - /// - /// Returns the root folder plus any folders in root (so down one level in the Inventory folders tree) - /// - /// - /// + // See IInventoryServices public List RequestFirstLevelFolders(LLUUID userID) { List inventoryList = new List(); @@ -112,11 +110,7 @@ namespace OpenSim.Framework.Communications return inventoryList; } - /// - /// Get the root folder for a user - /// - /// - /// null if no root folder was found + // See IInventoryServices public InventoryFolderBase RequestUsersRoot(LLUUID userID) { foreach (KeyValuePair plugin in m_plugins) @@ -126,9 +120,7 @@ namespace OpenSim.Framework.Communications return null; } - /// - /// - /// + // See IInventoryServices public void MoveInventoryFolder(LLUUID userID, InventoryFolderBase folder) { foreach (KeyValuePair plugin in m_plugins) @@ -136,12 +128,49 @@ namespace OpenSim.Framework.Communications plugin.Value.moveInventoryFolder(folder); } } + + public virtual bool HasInventoryForUser(LLUUID userID) + { + return false; + } + + // See IInventoryServices + public InventoryFolderBase RequestRootFolder(LLUUID userID) + { + return RequestUsersRoot(userID); + } + + // See IInventoryServices + public void CreateNewUserInventory(LLUUID user) + { + InventoryFolderBase existingRootFolder = RequestUsersRoot(user); + + if (null != existingRootFolder) + { + m_log.Error( + String.Format("[AGENTINVENTORY]: " + + "Did not create a new inventory for user {0} since they already have " + + "a root inventory folder with id {1}", user, existingRootFolder)); + } + else + { + UsersInventory inven = new UsersInventory(); + inven.CreateNewInventorySet(user); + AddNewInventorySet(inven); + } + } + + public abstract void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, + InventoryItemInfo itemCallBack); + public abstract void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder); + public abstract void MoveExistingInventoryFolder(InventoryFolderBase folder); + public abstract void AddNewInventoryItem(LLUUID userID, InventoryItemBase item); + public abstract void DeleteInventoryItem(LLUUID userID, InventoryItemBase item); + + #endregion + + #region Methods used by GridInventoryService - /// - /// - /// - /// - /// public List RequestSubFolders(LLUUID parentFolderID) { List inventoryList = new List(); @@ -162,8 +191,10 @@ namespace OpenSim.Framework.Communications } return itemsList; } + + #endregion - public void AddFolder(InventoryFolderBase folder) + protected void AddFolder(InventoryFolderBase folder) { foreach (KeyValuePair plugin in m_plugins) { @@ -171,7 +202,7 @@ namespace OpenSim.Framework.Communications } } - public void MoveFolder(InventoryFolderBase folder) + protected void MoveFolder(InventoryFolderBase folder) { foreach (KeyValuePair plugin in m_plugins) { @@ -179,7 +210,7 @@ namespace OpenSim.Framework.Communications } } - public void AddItem(InventoryItemBase item) + protected void AddItem(InventoryItemBase item) { foreach (KeyValuePair plugin in m_plugins) { @@ -187,68 +218,27 @@ namespace OpenSim.Framework.Communications } } - public void DeleteItem(InventoryItemBase item) + protected void DeleteItem(InventoryItemBase item) { foreach (KeyValuePair plugin in m_plugins) { plugin.Value.deleteInventoryItem(item.inventoryID); } } - - public virtual bool HasInventoryForUser(LLUUID userID) - { - return false; - } - - public InventoryFolderBase RequestRootFolder(LLUUID userID) - { - return RequestUsersRoot(userID); - } - - /// - /// - /// - /// - public void AddNewInventorySet(UsersInventory inventory) + + private void AddNewInventorySet(UsersInventory inventory) { foreach (InventoryFolderBase folder in inventory.Folders.Values) { AddFolder(folder); } - } - - /// - /// Create a new set of inventory folders for the given user. - /// - /// - public void CreateNewUserInventory(LLUUID user) - { - InventoryFolderBase existingRootFolder = RequestUsersRoot(user); - - if (null != existingRootFolder) - { - m_log.Error( - String.Format("[AGENTINVENTORY]: " + - "Did not create a new inventory for user {0} since they already have " - + "a root inventory folder with id {1}", user, existingRootFolder)); - } - else - { - UsersInventory inven = new UsersInventory(); - inven.CreateNewInventorySet(user); - AddNewInventorySet(inven); - } - } + } - public class UsersInventory + private class UsersInventory { public Dictionary Folders = new Dictionary(); public Dictionary Items = new Dictionary(); - public UsersInventory() - { - } - public virtual void CreateNewInventorySet(LLUUID user) { InventoryFolderBase folder = new InventoryFolderBase(); @@ -390,13 +380,5 @@ namespace OpenSim.Framework.Communications Folders.Add(folder.folderID, folder); } } - - public abstract void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, - InventoryItemInfo itemCallBack); - - public abstract void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder); - public abstract void MoveExistingInventoryFolder(InventoryFolderBase folder); - public abstract void AddNewInventoryItem(LLUUID userID, InventoryItemBase item); - public abstract void DeleteInventoryItem(LLUUID userID, InventoryItemBase item); } } \ No newline at end of file -- cgit v1.1