aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs')
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs179
1 files changed, 179 insertions, 0 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs
new file mode 100644
index 0000000..f2b736c
--- /dev/null
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs
@@ -0,0 +1,179 @@
1using System;
2using System.Collections.Generic;
3
4using OpenMetaverse;
5using Nini.Config;
6using log4net;
7
8using OpenSim.Framework;
9using OpenSim.Services.Interfaces;
10
11
12namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
13{
14 public abstract class BaseInventoryConnector : IInventoryService
15 {
16 protected InventoryCache m_cache;
17
18 protected virtual void Init(IConfigSource source)
19 {
20 m_cache = new InventoryCache();
21 m_cache.Init(source, this);
22 }
23
24 /// <summary>
25 /// Create the entire inventory for a given user
26 /// </summary>
27 /// <param name="user"></param>
28 /// <returns></returns>
29 public abstract bool CreateUserInventory(UUID user);
30
31 /// <summary>
32 /// Gets the skeleton of the inventory -- folders only
33 /// </summary>
34 /// <param name="userId"></param>
35 /// <returns></returns>
36 public abstract List<InventoryFolderBase> GetInventorySkeleton(UUID userId);
37
38 /// <summary>
39 /// Synchronous inventory fetch.
40 /// </summary>
41 /// <param name="userID"></param>
42 /// <returns></returns>
43 public abstract InventoryCollection GetUserInventory(UUID userID);
44
45 /// <summary>
46 /// Request the inventory for a user. This is an asynchronous operation that will call the callback when the
47 /// inventory has been received
48 /// </summary>
49 /// <param name="userID"></param>
50 /// <param name="callback"></param>
51 public abstract void GetUserInventory(UUID userID, InventoryReceiptCallback callback);
52
53 /// <summary>
54 /// Retrieve the root inventory folder for the given user.
55 /// </summary>
56 /// <param name="userID"></param>
57 /// <returns>null if no root folder was found</returns>
58 public abstract InventoryFolderBase GetRootFolder(UUID userID);
59
60 public abstract Dictionary<AssetType, InventoryFolderBase> GetSystemFolders(UUID userID);
61
62 /// <summary>
63 /// Gets the user folder for the given folder-type
64 /// </summary>
65 /// <param name="userID"></param>
66 /// <param name="type"></param>
67 /// <returns></returns>
68 public InventoryFolderBase GetFolderForType(UUID userID, AssetType type)
69 {
70 return m_cache.GetFolderForType(userID, type);
71 }
72
73 /// <summary>
74 /// Gets everything (folders and items) inside a folder
75 /// </summary>
76 /// <param name="userId"></param>
77 /// <param name="folderID"></param>
78 /// <returns></returns>
79 public abstract InventoryCollection GetFolderContent(UUID userID, UUID folderID);
80
81 /// <summary>
82 /// Gets the items inside a folder
83 /// </summary>
84 /// <param name="userID"></param>
85 /// <param name="folderID"></param>
86 /// <returns></returns>
87 public abstract List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID);
88
89 /// <summary>
90 /// Add a new folder to the user's inventory
91 /// </summary>
92 /// <param name="folder"></param>
93 /// <returns>true if the folder was successfully added</returns>
94 public abstract bool AddFolder(InventoryFolderBase folder);
95
96 /// <summary>
97 /// Update a folder in the user's inventory
98 /// </summary>
99 /// <param name="folder"></param>
100 /// <returns>true if the folder was successfully updated</returns>
101 public abstract bool UpdateFolder(InventoryFolderBase folder);
102
103 /// <summary>
104 /// Move an inventory folder to a new location
105 /// </summary>
106 /// <param name="folder">A folder containing the details of the new location</param>
107 /// <returns>true if the folder was successfully moved</returns>
108 public abstract bool MoveFolder(InventoryFolderBase folder);
109
110 /// <summary>
111 /// Purge an inventory folder of all its items and subfolders.
112 /// </summary>
113 /// <param name="folder"></param>
114 /// <returns>true if the folder was successfully purged</returns>
115 public abstract bool PurgeFolder(InventoryFolderBase folder);
116
117 /// <summary>
118 /// Add a new item to the user's inventory.
119 /// If the given item has to parent folder, it tries to find the most
120 /// suitable folder for it.
121 /// </summary>
122 /// <param name="item"></param>
123 /// <returns>true if the item was successfully added</returns>
124 public bool AddItem(InventoryItemBase item)
125 {
126 if (item.Folder == UUID.Zero)
127 {
128 InventoryFolderBase f = GetFolderForType(item.Owner, (AssetType)item.AssetType);
129 if (f != null)
130 item.Folder = f.ID;
131 else
132 {
133 f = GetRootFolder(item.Owner);
134 if (f != null)
135 item.Folder = f.ID;
136 else
137 return false;
138 }
139 }
140
141 return AddItemPlain(item);
142 }
143
144 protected abstract bool AddItemPlain(InventoryItemBase item);
145
146 /// <summary>
147 /// Update an item in the user's inventory
148 /// </summary>
149 /// <param name="item"></param>
150 /// <returns>true if the item was successfully updated</returns>
151 public abstract bool UpdateItem(InventoryItemBase item);
152
153 /// <summary>
154 /// Delete an item from the user's inventory
155 /// </summary>
156 /// <param name="item"></param>
157 /// <returns>true if the item was successfully deleted</returns>
158 public abstract bool DeleteItem(InventoryItemBase item);
159
160 public abstract InventoryItemBase QueryItem(InventoryItemBase item);
161
162 public abstract InventoryFolderBase QueryFolder(InventoryFolderBase folder);
163
164 /// <summary>
165 /// Does the given user have an inventory structure?
166 /// </summary>
167 /// <param name="userID"></param>
168 /// <returns></returns>
169 public abstract bool HasInventoryForUser(UUID userID);
170
171 /// <summary>
172 /// Get the active gestures of the agent.
173 /// </summary>
174 /// <param name="userId"></param>
175 /// <returns></returns>
176 public abstract List<InventoryItemBase> GetActiveGestures(UUID userId);
177
178 }
179}