diff options
author | Justin Clarke Casey | 2008-02-11 20:10:44 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2008-02-11 20:10:44 +0000 |
commit | c80c6e977414196fe7b855e885a5872ce5c24821 (patch) | |
tree | ec6ce0b46d57ff610ca311b18574ebb5bcd8251a /OpenSim/Framework/Communications | |
parent | Moved share/sql/mysql-AvatarAppearance.sql to OpenSim/Framework/Data.MySQL/Re... (diff) | |
download | opensim-SC-c80c6e977414196fe7b855e885a5872ce5c24821.zip opensim-SC-c80c6e977414196fe7b855e885a5872ce5c24821.tar.gz opensim-SC-c80c6e977414196fe7b855e885a5872ce5c24821.tar.bz2 opensim-SC-c80c6e977414196fe7b855e885a5872ce5c24821.tar.xz |
Documenting and minor tweaks
Diffstat (limited to 'OpenSim/Framework/Communications')
-rw-r--r-- | OpenSim/Framework/Communications/IInventoryServices.cs | 35 | ||||
-rw-r--r-- | OpenSim/Framework/Communications/InventoryServiceBase.cs | 146 |
2 files changed, 99 insertions, 82 deletions
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 | |||
36 | 36 | ||
37 | public delegate void InventoryItemInfo(LLUUID userID, InventoryItemBase itemInfo); | 37 | public delegate void InventoryItemInfo(LLUUID userID, InventoryItemBase itemInfo); |
38 | 38 | ||
39 | /// <summary> | ||
40 | /// Defines all the operations one can perform on a user's inventory. | ||
41 | /// </summary> | ||
39 | public interface IInventoryServices | 42 | public interface IInventoryServices |
40 | { | 43 | { |
41 | void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, InventoryItemInfo itemCallBack); | 44 | void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, InventoryItemInfo itemCallBack); |
45 | |||
46 | /// <summary> | ||
47 | /// Add a new folder to the given user's inventory | ||
48 | /// </summary> | ||
49 | /// <param name="userID"></param> | ||
50 | /// <param name="folder"></param> | ||
42 | void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder); | 51 | void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder); |
52 | |||
43 | void MoveInventoryFolder(LLUUID userID, InventoryFolderBase folder); | 53 | void MoveInventoryFolder(LLUUID userID, InventoryFolderBase folder); |
54 | |||
55 | /// <summary> | ||
56 | /// Add a new item to the given user's inventory | ||
57 | /// </summary> | ||
58 | /// <param name="userID"></param> | ||
59 | /// <param name="item"></param> | ||
44 | void AddNewInventoryItem(LLUUID userID, InventoryItemBase item); | 60 | void AddNewInventoryItem(LLUUID userID, InventoryItemBase item); |
61 | |||
62 | /// <summary> | ||
63 | /// Delete an item from the given user's inventory | ||
64 | /// </summary> | ||
65 | /// <param name="userID"></param> | ||
66 | /// <param name="item"></param> | ||
45 | void DeleteInventoryItem(LLUUID userID, InventoryItemBase item); | 67 | void DeleteInventoryItem(LLUUID userID, InventoryItemBase item); |
68 | |||
69 | /// <summary> | ||
70 | /// Create a new inventory for the given user | ||
71 | /// </summary> | ||
72 | /// <param name="user"></param> | ||
46 | void CreateNewUserInventory(LLUUID user); | 73 | void CreateNewUserInventory(LLUUID user); |
74 | |||
47 | bool HasInventoryForUser(LLUUID userID); | 75 | bool HasInventoryForUser(LLUUID userID); |
76 | |||
77 | /// <summary> | ||
78 | /// Retrieve the root inventory folder for the given user. | ||
79 | /// </summary> | ||
80 | /// <param name="userID"></param> | ||
81 | /// <returns>null if no root folder was found</returns> | ||
48 | InventoryFolderBase RequestRootFolder(LLUUID userID); | 82 | InventoryFolderBase RequestRootFolder(LLUUID userID); |
49 | 83 | ||
50 | /// <summary> | 84 | /// <summary> |
51 | /// Returns the root folder plus any folders in root (so down one level in the Inventory folders tree) | 85 | /// Returns the root folder plus any folders in root (so down one level in the Inventory folders tree) |
86 | /// for the given user. | ||
52 | /// </summary> | 87 | /// </summary> |
53 | /// <param name="userID"></param> | 88 | /// <param name="userID"></param> |
54 | /// <returns></returns> | 89 | /// <returns></returns> |
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 | |||
36 | { | 36 | { |
37 | public abstract class InventoryServiceBase : IInventoryServices | 37 | public abstract class InventoryServiceBase : IInventoryServices |
38 | { | 38 | { |
39 | private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | 39 | private static readonly log4net.ILog m_log |
40 | = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | ||
40 | 41 | ||
41 | protected Dictionary<string, IInventoryData> m_plugins = new Dictionary<string, IInventoryData>(); | 42 | protected Dictionary<string, IInventoryData> m_plugins = new Dictionary<string, IInventoryData>(); |
42 | //protected IAssetServer m_assetServer; | ||
43 | |||
44 | public InventoryServiceBase() | ||
45 | { | ||
46 | //m_assetServer = assetServer; | ||
47 | } | ||
48 | 43 | ||
44 | #region Plugin methods | ||
45 | |||
49 | /// <summary> | 46 | /// <summary> |
50 | /// Adds a new user server plugin - plugins will be requested in the order they were loaded. | 47 | /// Adds a new user server plugin - plugins will be requested in the order they were loaded. |
51 | /// </summary> | 48 | /// </summary> |
@@ -75,18 +72,19 @@ namespace OpenSim.Framework.Communications | |||
75 | } | 72 | } |
76 | } | 73 | } |
77 | } | 74 | } |
75 | |||
76 | #endregion | ||
77 | |||
78 | #region IInventoryServices methods | ||
78 | 79 | ||
80 | // See IInventoryServices | ||
79 | public List<InventoryFolderBase> RequestFirstLevelFolders(Guid rawUserID) | 81 | public List<InventoryFolderBase> RequestFirstLevelFolders(Guid rawUserID) |
80 | { | 82 | { |
81 | LLUUID userID = new LLUUID(rawUserID); | 83 | LLUUID userID = new LLUUID(rawUserID); |
82 | return RequestFirstLevelFolders(userID); | 84 | return RequestFirstLevelFolders(userID); |
83 | } | 85 | } |
84 | 86 | ||
85 | /// <summary> | 87 | // See IInventoryServices |
86 | /// Returns the root folder plus any folders in root (so down one level in the Inventory folders tree) | ||
87 | /// </summary> | ||
88 | /// <param name="userID"></param> | ||
89 | /// <returns></returns> | ||
90 | public List<InventoryFolderBase> RequestFirstLevelFolders(LLUUID userID) | 88 | public List<InventoryFolderBase> RequestFirstLevelFolders(LLUUID userID) |
91 | { | 89 | { |
92 | List<InventoryFolderBase> inventoryList = new List<InventoryFolderBase>(); | 90 | List<InventoryFolderBase> inventoryList = new List<InventoryFolderBase>(); |
@@ -112,11 +110,7 @@ namespace OpenSim.Framework.Communications | |||
112 | return inventoryList; | 110 | return inventoryList; |
113 | } | 111 | } |
114 | 112 | ||
115 | /// <summary> | 113 | // See IInventoryServices |
116 | /// Get the root folder for a user | ||
117 | /// </summary> | ||
118 | /// <param name="userID"></param> | ||
119 | /// <returns>null if no root folder was found</returns> | ||
120 | public InventoryFolderBase RequestUsersRoot(LLUUID userID) | 114 | public InventoryFolderBase RequestUsersRoot(LLUUID userID) |
121 | { | 115 | { |
122 | foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins) | 116 | foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins) |
@@ -126,9 +120,7 @@ namespace OpenSim.Framework.Communications | |||
126 | return null; | 120 | return null; |
127 | } | 121 | } |
128 | 122 | ||
129 | /// <summary> | 123 | // See IInventoryServices |
130 | /// | ||
131 | /// </summary> | ||
132 | public void MoveInventoryFolder(LLUUID userID, InventoryFolderBase folder) | 124 | public void MoveInventoryFolder(LLUUID userID, InventoryFolderBase folder) |
133 | { | 125 | { |
134 | foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins) | 126 | foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins) |
@@ -136,12 +128,49 @@ namespace OpenSim.Framework.Communications | |||
136 | plugin.Value.moveInventoryFolder(folder); | 128 | plugin.Value.moveInventoryFolder(folder); |
137 | } | 129 | } |
138 | } | 130 | } |
131 | |||
132 | public virtual bool HasInventoryForUser(LLUUID userID) | ||
133 | { | ||
134 | return false; | ||
135 | } | ||
136 | |||
137 | // See IInventoryServices | ||
138 | public InventoryFolderBase RequestRootFolder(LLUUID userID) | ||
139 | { | ||
140 | return RequestUsersRoot(userID); | ||
141 | } | ||
142 | |||
143 | // See IInventoryServices | ||
144 | public void CreateNewUserInventory(LLUUID user) | ||
145 | { | ||
146 | InventoryFolderBase existingRootFolder = RequestUsersRoot(user); | ||
147 | |||
148 | if (null != existingRootFolder) | ||
149 | { | ||
150 | m_log.Error( | ||
151 | String.Format("[AGENTINVENTORY]: " + | ||
152 | "Did not create a new inventory for user {0} since they already have " | ||
153 | + "a root inventory folder with id {1}", user, existingRootFolder)); | ||
154 | } | ||
155 | else | ||
156 | { | ||
157 | UsersInventory inven = new UsersInventory(); | ||
158 | inven.CreateNewInventorySet(user); | ||
159 | AddNewInventorySet(inven); | ||
160 | } | ||
161 | } | ||
162 | |||
163 | public abstract void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, | ||
164 | InventoryItemInfo itemCallBack); | ||
165 | public abstract void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder); | ||
166 | public abstract void MoveExistingInventoryFolder(InventoryFolderBase folder); | ||
167 | public abstract void AddNewInventoryItem(LLUUID userID, InventoryItemBase item); | ||
168 | public abstract void DeleteInventoryItem(LLUUID userID, InventoryItemBase item); | ||
169 | |||
170 | #endregion | ||
171 | |||
172 | #region Methods used by GridInventoryService | ||
139 | 173 | ||
140 | /// <summary> | ||
141 | /// | ||
142 | /// </summary> | ||
143 | /// <param name="parentFolderID"></param> | ||
144 | /// <returns></returns> | ||
145 | public List<InventoryFolderBase> RequestSubFolders(LLUUID parentFolderID) | 174 | public List<InventoryFolderBase> RequestSubFolders(LLUUID parentFolderID) |
146 | { | 175 | { |
147 | List<InventoryFolderBase> inventoryList = new List<InventoryFolderBase>(); | 176 | List<InventoryFolderBase> inventoryList = new List<InventoryFolderBase>(); |
@@ -162,8 +191,10 @@ namespace OpenSim.Framework.Communications | |||
162 | } | 191 | } |
163 | return itemsList; | 192 | return itemsList; |
164 | } | 193 | } |
194 | |||
195 | #endregion | ||
165 | 196 | ||
166 | public void AddFolder(InventoryFolderBase folder) | 197 | protected void AddFolder(InventoryFolderBase folder) |
167 | { | 198 | { |
168 | foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins) | 199 | foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins) |
169 | { | 200 | { |
@@ -171,7 +202,7 @@ namespace OpenSim.Framework.Communications | |||
171 | } | 202 | } |
172 | } | 203 | } |
173 | 204 | ||
174 | public void MoveFolder(InventoryFolderBase folder) | 205 | protected void MoveFolder(InventoryFolderBase folder) |
175 | { | 206 | { |
176 | foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins) | 207 | foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins) |
177 | { | 208 | { |
@@ -179,7 +210,7 @@ namespace OpenSim.Framework.Communications | |||
179 | } | 210 | } |
180 | } | 211 | } |
181 | 212 | ||
182 | public void AddItem(InventoryItemBase item) | 213 | protected void AddItem(InventoryItemBase item) |
183 | { | 214 | { |
184 | foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins) | 215 | foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins) |
185 | { | 216 | { |
@@ -187,68 +218,27 @@ namespace OpenSim.Framework.Communications | |||
187 | } | 218 | } |
188 | } | 219 | } |
189 | 220 | ||
190 | public void DeleteItem(InventoryItemBase item) | 221 | protected void DeleteItem(InventoryItemBase item) |
191 | { | 222 | { |
192 | foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins) | 223 | foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins) |
193 | { | 224 | { |
194 | plugin.Value.deleteInventoryItem(item.inventoryID); | 225 | plugin.Value.deleteInventoryItem(item.inventoryID); |
195 | } | 226 | } |
196 | } | 227 | } |
197 | 228 | ||
198 | public virtual bool HasInventoryForUser(LLUUID userID) | 229 | private void AddNewInventorySet(UsersInventory inventory) |
199 | { | ||
200 | return false; | ||
201 | } | ||
202 | |||
203 | public InventoryFolderBase RequestRootFolder(LLUUID userID) | ||
204 | { | ||
205 | return RequestUsersRoot(userID); | ||
206 | } | ||
207 | |||
208 | /// <summary> | ||
209 | /// | ||
210 | /// </summary> | ||
211 | /// <param name="inventory"></param> | ||
212 | public void AddNewInventorySet(UsersInventory inventory) | ||
213 | { | 230 | { |
214 | foreach (InventoryFolderBase folder in inventory.Folders.Values) | 231 | foreach (InventoryFolderBase folder in inventory.Folders.Values) |
215 | { | 232 | { |
216 | AddFolder(folder); | 233 | AddFolder(folder); |
217 | } | 234 | } |
218 | } | 235 | } |
219 | |||
220 | /// <summary> | ||
221 | /// Create a new set of inventory folders for the given user. | ||
222 | /// </summary> | ||
223 | /// <param name="user"></param> | ||
224 | public void CreateNewUserInventory(LLUUID user) | ||
225 | { | ||
226 | InventoryFolderBase existingRootFolder = RequestUsersRoot(user); | ||
227 | |||
228 | if (null != existingRootFolder) | ||
229 | { | ||
230 | m_log.Error( | ||
231 | String.Format("[AGENTINVENTORY]: " + | ||
232 | "Did not create a new inventory for user {0} since they already have " | ||
233 | + "a root inventory folder with id {1}", user, existingRootFolder)); | ||
234 | } | ||
235 | else | ||
236 | { | ||
237 | UsersInventory inven = new UsersInventory(); | ||
238 | inven.CreateNewInventorySet(user); | ||
239 | AddNewInventorySet(inven); | ||
240 | } | ||
241 | } | ||
242 | 236 | ||
243 | public class UsersInventory | 237 | private class UsersInventory |
244 | { | 238 | { |
245 | public Dictionary<LLUUID, InventoryFolderBase> Folders = new Dictionary<LLUUID, InventoryFolderBase>(); | 239 | public Dictionary<LLUUID, InventoryFolderBase> Folders = new Dictionary<LLUUID, InventoryFolderBase>(); |
246 | public Dictionary<LLUUID, InventoryItemBase> Items = new Dictionary<LLUUID, InventoryItemBase>(); | 240 | public Dictionary<LLUUID, InventoryItemBase> Items = new Dictionary<LLUUID, InventoryItemBase>(); |
247 | 241 | ||
248 | public UsersInventory() | ||
249 | { | ||
250 | } | ||
251 | |||
252 | public virtual void CreateNewInventorySet(LLUUID user) | 242 | public virtual void CreateNewInventorySet(LLUUID user) |
253 | { | 243 | { |
254 | InventoryFolderBase folder = new InventoryFolderBase(); | 244 | InventoryFolderBase folder = new InventoryFolderBase(); |
@@ -390,13 +380,5 @@ namespace OpenSim.Framework.Communications | |||
390 | Folders.Add(folder.folderID, folder); | 380 | Folders.Add(folder.folderID, folder); |
391 | } | 381 | } |
392 | } | 382 | } |
393 | |||
394 | public abstract void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, | ||
395 | InventoryItemInfo itemCallBack); | ||
396 | |||
397 | public abstract void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder); | ||
398 | public abstract void MoveExistingInventoryFolder(InventoryFolderBase folder); | ||
399 | public abstract void AddNewInventoryItem(LLUUID userID, InventoryItemBase item); | ||
400 | public abstract void DeleteInventoryItem(LLUUID userID, InventoryItemBase item); | ||
401 | } | 383 | } |
402 | } \ No newline at end of file | 384 | } \ No newline at end of file |