using System; using System.Collections.Generic; using OpenMetaverse; using Nini.Config; using log4net; using OpenSim.Framework; using OpenSim.Services.Interfaces; namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory { public abstract class BaseInventoryConnector : IInventoryService { protected InventoryCache m_cache; protected virtual void Init(IConfigSource source) { m_cache = new InventoryCache(); m_cache.Init(source, this); } /// /// Create the entire inventory for a given user /// /// /// public abstract bool CreateUserInventory(UUID user); /// /// Gets the skeleton of the inventory -- folders only /// /// /// public abstract List GetInventorySkeleton(UUID userId); /// /// Synchronous inventory fetch. /// /// /// public abstract InventoryCollection GetUserInventory(UUID userID); /// /// Request the inventory for a user. This is an asynchronous operation that will call the callback when the /// inventory has been received /// /// /// public abstract void GetUserInventory(UUID userID, InventoryReceiptCallback callback); /// /// Retrieve the root inventory folder for the given user. /// /// /// null if no root folder was found public abstract InventoryFolderBase GetRootFolder(UUID userID); public abstract Dictionary GetSystemFolders(UUID userID); /// /// Gets the user folder for the given folder-type /// /// /// /// public InventoryFolderBase GetFolderForType(UUID userID, AssetType type) { return m_cache.GetFolderForType(userID, type); } /// /// Gets everything (folders and items) inside a folder /// /// /// /// public abstract InventoryCollection GetFolderContent(UUID userID, UUID folderID); /// /// Gets the items inside a folder /// /// /// /// public abstract List GetFolderItems(UUID userID, UUID folderID); /// /// Add a new folder to the user's inventory /// /// /// true if the folder was successfully added public abstract bool AddFolder(InventoryFolderBase folder); /// /// Update a folder in the user's inventory /// /// /// true if the folder was successfully updated public abstract bool UpdateFolder(InventoryFolderBase folder); /// /// Move an inventory folder to a new location /// /// A folder containing the details of the new location /// true if the folder was successfully moved public abstract bool MoveFolder(InventoryFolderBase folder); /// /// Purge an inventory folder of all its items and subfolders. /// /// /// true if the folder was successfully purged public abstract bool PurgeFolder(InventoryFolderBase folder); /// /// Add a new item to the user's inventory. /// If the given item has to parent folder, it tries to find the most /// suitable folder for it. /// /// /// true if the item was successfully added public bool AddItem(InventoryItemBase item) { if (item.Folder == UUID.Zero) { InventoryFolderBase f = GetFolderForType(item.Owner, (AssetType)item.AssetType); if (f != null) item.Folder = f.ID; else { f = GetRootFolder(item.Owner); if (f != null) item.Folder = f.ID; else return false; } } return AddItemPlain(item); } protected abstract bool AddItemPlain(InventoryItemBase item); /// /// Update an item in the user's inventory /// /// /// true if the item was successfully updated public abstract bool UpdateItem(InventoryItemBase item); /// /// Delete an item from the user's inventory /// /// /// true if the item was successfully deleted public abstract bool DeleteItem(InventoryItemBase item); public abstract InventoryItemBase QueryItem(InventoryItemBase item); public abstract InventoryFolderBase QueryFolder(InventoryFolderBase folder); /// /// Does the given user have an inventory structure? /// /// /// public abstract bool HasInventoryForUser(UUID userID); /// /// Get the active gestures of the agent. /// /// /// public abstract List GetActiveGestures(UUID userId); } }