Documenting and minor tweaks

ThreadPoolClientBranch
Justin Clarke Casey 2008-02-11 20:10:44 +00:00
parent 7156d7ae51
commit c80c6e9774
3 changed files with 103 additions and 82 deletions

View File

@ -36,19 +36,54 @@ namespace OpenSim.Framework.Communications
public delegate void InventoryItemInfo(LLUUID userID, InventoryItemBase itemInfo);
/// <summary>
/// Defines all the operations one can perform on a user's inventory.
/// </summary>
public interface IInventoryServices
{
void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, InventoryItemInfo itemCallBack);
/// <summary>
/// Add a new folder to the given user's inventory
/// </summary>
/// <param name="userID"></param>
/// <param name="folder"></param>
void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder);
void MoveInventoryFolder(LLUUID userID, InventoryFolderBase folder);
/// <summary>
/// Add a new item to the given user's inventory
/// </summary>
/// <param name="userID"></param>
/// <param name="item"></param>
void AddNewInventoryItem(LLUUID userID, InventoryItemBase item);
/// <summary>
/// Delete an item from the given user's inventory
/// </summary>
/// <param name="userID"></param>
/// <param name="item"></param>
void DeleteInventoryItem(LLUUID userID, InventoryItemBase item);
/// <summary>
/// Create a new inventory for the given user
/// </summary>
/// <param name="user"></param>
void CreateNewUserInventory(LLUUID user);
bool HasInventoryForUser(LLUUID userID);
/// <summary>
/// Retrieve the root inventory folder for the given user.
/// </summary>
/// <param name="userID"></param>
/// <returns>null if no root folder was found</returns>
InventoryFolderBase RequestRootFolder(LLUUID userID);
/// <summary>
/// Returns the root folder plus any folders in root (so down one level in the Inventory folders tree)
/// for the given user.
/// </summary>
/// <param name="userID"></param>
/// <returns></returns>

View File

@ -36,15 +36,12 @@ 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<string, IInventoryData> m_plugins = new Dictionary<string, IInventoryData>();
//protected IAssetServer m_assetServer;
public InventoryServiceBase()
{
//m_assetServer = assetServer;
}
#region Plugin methods
/// <summary>
/// Adds a new user server plugin - plugins will be requested in the order they were loaded.
@ -76,17 +73,18 @@ namespace OpenSim.Framework.Communications
}
}
#endregion
#region IInventoryServices methods
// See IInventoryServices
public List<InventoryFolderBase> RequestFirstLevelFolders(Guid rawUserID)
{
LLUUID userID = new LLUUID(rawUserID);
return RequestFirstLevelFolders(userID);
}
/// <summary>
/// Returns the root folder plus any folders in root (so down one level in the Inventory folders tree)
/// </summary>
/// <param name="userID"></param>
/// <returns></returns>
// See IInventoryServices
public List<InventoryFolderBase> RequestFirstLevelFolders(LLUUID userID)
{
List<InventoryFolderBase> inventoryList = new List<InventoryFolderBase>();
@ -112,11 +110,7 @@ namespace OpenSim.Framework.Communications
return inventoryList;
}
/// <summary>
/// Get the root folder for a user
/// </summary>
/// <param name="userID"></param>
/// <returns>null if no root folder was found</returns>
// See IInventoryServices
public InventoryFolderBase RequestUsersRoot(LLUUID userID)
{
foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins)
@ -126,9 +120,7 @@ namespace OpenSim.Framework.Communications
return null;
}
/// <summary>
///
/// </summary>
// See IInventoryServices
public void MoveInventoryFolder(LLUUID userID, InventoryFolderBase folder)
{
foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins)
@ -137,11 +129,48 @@ namespace OpenSim.Framework.Communications
}
}
/// <summary>
///
/// </summary>
/// <param name="parentFolderID"></param>
/// <returns></returns>
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<InventoryFolderBase> RequestSubFolders(LLUUID parentFolderID)
{
List<InventoryFolderBase> inventoryList = new List<InventoryFolderBase>();
@ -163,7 +192,9 @@ namespace OpenSim.Framework.Communications
return itemsList;
}
public void AddFolder(InventoryFolderBase folder)
#endregion
protected void AddFolder(InventoryFolderBase folder)
{
foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins)
{
@ -171,7 +202,7 @@ namespace OpenSim.Framework.Communications
}
}
public void MoveFolder(InventoryFolderBase folder)
protected void MoveFolder(InventoryFolderBase folder)
{
foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins)
{
@ -179,7 +210,7 @@ namespace OpenSim.Framework.Communications
}
}
public void AddItem(InventoryItemBase item)
protected void AddItem(InventoryItemBase item)
{
foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins)
{
@ -187,7 +218,7 @@ namespace OpenSim.Framework.Communications
}
}
public void DeleteItem(InventoryItemBase item)
protected void DeleteItem(InventoryItemBase item)
{
foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins)
{
@ -195,21 +226,7 @@ namespace OpenSim.Framework.Communications
}
}
public virtual bool HasInventoryForUser(LLUUID userID)
{
return false;
}
public InventoryFolderBase RequestRootFolder(LLUUID userID)
{
return RequestUsersRoot(userID);
}
/// <summary>
///
/// </summary>
/// <param name="inventory"></param>
public void AddNewInventorySet(UsersInventory inventory)
private void AddNewInventorySet(UsersInventory inventory)
{
foreach (InventoryFolderBase folder in inventory.Folders.Values)
{
@ -217,38 +234,11 @@ namespace OpenSim.Framework.Communications
}
}
/// <summary>
/// Create a new set of inventory folders for the given user.
/// </summary>
/// <param name="user"></param>
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<LLUUID, InventoryFolderBase> Folders = new Dictionary<LLUUID, InventoryFolderBase>();
public Dictionary<LLUUID, InventoryItemBase> Items = new Dictionary<LLUUID, InventoryItemBase>();
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);
}
}

View File

@ -34,6 +34,10 @@ using OpenSim.Framework.Communications.Cache;
namespace OpenSim.Region.Communications.Local
{
/// <summary>
/// An implementation of user inventory where the inventory is held locally (e.g. when OpenSim is
/// operating in standalone mode.
/// </summary>
public class LocalInventoryService : InventoryServiceBase
{
public override void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack,