Documenting and minor tweaks
parent
7156d7ae51
commit
c80c6e9774
|
@ -36,19 +36,54 @@ namespace OpenSim.Framework.Communications
|
||||||
|
|
||||||
public delegate void InventoryItemInfo(LLUUID userID, InventoryItemBase itemInfo);
|
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
|
public interface IInventoryServices
|
||||||
{
|
{
|
||||||
void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, InventoryItemInfo itemCallBack);
|
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 AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder);
|
||||||
|
|
||||||
void MoveInventoryFolder(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);
|
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);
|
void DeleteInventoryItem(LLUUID userID, InventoryItemBase item);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Create a new inventory for the given user
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="user"></param>
|
||||||
void CreateNewUserInventory(LLUUID user);
|
void CreateNewUserInventory(LLUUID user);
|
||||||
|
|
||||||
bool HasInventoryForUser(LLUUID userID);
|
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);
|
InventoryFolderBase RequestRootFolder(LLUUID userID);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the root folder plus any folders in root (so down one level in the Inventory folders tree)
|
/// Returns the root folder plus any folders in root (so down one level in the Inventory folders tree)
|
||||||
|
/// for the given user.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="userID"></param>
|
/// <param name="userID"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
|
|
|
@ -36,15 +36,12 @@ namespace OpenSim.Framework.Communications
|
||||||
{
|
{
|
||||||
public abstract class InventoryServiceBase : IInventoryServices
|
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 Dictionary<string, IInventoryData> m_plugins = new Dictionary<string, IInventoryData>();
|
||||||
//protected IAssetServer m_assetServer;
|
|
||||||
|
|
||||||
public InventoryServiceBase()
|
#region Plugin methods
|
||||||
{
|
|
||||||
//m_assetServer = assetServer;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adds a new user server plugin - plugins will be requested in the order they were loaded.
|
/// 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)
|
public List<InventoryFolderBase> RequestFirstLevelFolders(Guid rawUserID)
|
||||||
{
|
{
|
||||||
LLUUID userID = new LLUUID(rawUserID);
|
LLUUID userID = new LLUUID(rawUserID);
|
||||||
return RequestFirstLevelFolders(userID);
|
return RequestFirstLevelFolders(userID);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
// See IInventoryServices
|
||||||
/// 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>
|
|
||||||
public List<InventoryFolderBase> RequestFirstLevelFolders(LLUUID userID)
|
public List<InventoryFolderBase> RequestFirstLevelFolders(LLUUID userID)
|
||||||
{
|
{
|
||||||
List<InventoryFolderBase> inventoryList = new List<InventoryFolderBase>();
|
List<InventoryFolderBase> inventoryList = new List<InventoryFolderBase>();
|
||||||
|
@ -112,11 +110,7 @@ namespace OpenSim.Framework.Communications
|
||||||
return inventoryList;
|
return inventoryList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
// See IInventoryServices
|
||||||
/// Get the root folder for a user
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="userID"></param>
|
|
||||||
/// <returns>null if no root folder was found</returns>
|
|
||||||
public InventoryFolderBase RequestUsersRoot(LLUUID userID)
|
public InventoryFolderBase RequestUsersRoot(LLUUID userID)
|
||||||
{
|
{
|
||||||
foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins)
|
foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins)
|
||||||
|
@ -126,9 +120,7 @@ namespace OpenSim.Framework.Communications
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
// See IInventoryServices
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
public void MoveInventoryFolder(LLUUID userID, InventoryFolderBase folder)
|
public void MoveInventoryFolder(LLUUID userID, InventoryFolderBase folder)
|
||||||
{
|
{
|
||||||
foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins)
|
foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins)
|
||||||
|
@ -137,11 +129,48 @@ namespace OpenSim.Framework.Communications
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
public virtual bool HasInventoryForUser(LLUUID userID)
|
||||||
///
|
{
|
||||||
/// </summary>
|
return false;
|
||||||
/// <param name="parentFolderID"></param>
|
}
|
||||||
/// <returns></returns>
|
|
||||||
|
// 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)
|
public List<InventoryFolderBase> RequestSubFolders(LLUUID parentFolderID)
|
||||||
{
|
{
|
||||||
List<InventoryFolderBase> inventoryList = new List<InventoryFolderBase>();
|
List<InventoryFolderBase> inventoryList = new List<InventoryFolderBase>();
|
||||||
|
@ -163,7 +192,9 @@ namespace OpenSim.Framework.Communications
|
||||||
return itemsList;
|
return itemsList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddFolder(InventoryFolderBase folder)
|
#endregion
|
||||||
|
|
||||||
|
protected void AddFolder(InventoryFolderBase folder)
|
||||||
{
|
{
|
||||||
foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins)
|
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)
|
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)
|
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)
|
foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins)
|
||||||
{
|
{
|
||||||
|
@ -195,21 +226,7 @@ namespace OpenSim.Framework.Communications
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual bool HasInventoryForUser(LLUUID userID)
|
private void AddNewInventorySet(UsersInventory inventory)
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public InventoryFolderBase RequestRootFolder(LLUUID userID)
|
|
||||||
{
|
|
||||||
return RequestUsersRoot(userID);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="inventory"></param>
|
|
||||||
public void AddNewInventorySet(UsersInventory inventory)
|
|
||||||
{
|
{
|
||||||
foreach (InventoryFolderBase folder in inventory.Folders.Values)
|
foreach (InventoryFolderBase folder in inventory.Folders.Values)
|
||||||
{
|
{
|
||||||
|
@ -217,38 +234,11 @@ namespace OpenSim.Framework.Communications
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
private class UsersInventory
|
||||||
/// 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
|
|
||||||
{
|
{
|
||||||
public Dictionary<LLUUID, InventoryFolderBase> Folders = new Dictionary<LLUUID, InventoryFolderBase>();
|
public Dictionary<LLUUID, InventoryFolderBase> Folders = new Dictionary<LLUUID, InventoryFolderBase>();
|
||||||
public Dictionary<LLUUID, InventoryItemBase> Items = new Dictionary<LLUUID, InventoryItemBase>();
|
public Dictionary<LLUUID, InventoryItemBase> Items = new Dictionary<LLUUID, InventoryItemBase>();
|
||||||
|
|
||||||
public UsersInventory()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void CreateNewInventorySet(LLUUID user)
|
public virtual void CreateNewInventorySet(LLUUID user)
|
||||||
{
|
{
|
||||||
InventoryFolderBase folder = new InventoryFolderBase();
|
InventoryFolderBase folder = new InventoryFolderBase();
|
||||||
|
@ -390,13 +380,5 @@ namespace OpenSim.Framework.Communications
|
||||||
Folders.Add(folder.folderID, folder);
|
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -34,6 +34,10 @@ using OpenSim.Framework.Communications.Cache;
|
||||||
|
|
||||||
namespace OpenSim.Region.Communications.Local
|
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 class LocalInventoryService : InventoryServiceBase
|
||||||
{
|
{
|
||||||
public override void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack,
|
public override void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack,
|
||||||
|
|
Loading…
Reference in New Issue