aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r--OpenSim/Framework/Communications/Cache/CachedUserInfo.cs100
-rw-r--r--OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs76
-rw-r--r--OpenSim/Framework/Communications/InventoryServiceBase.cs12
3 files changed, 115 insertions, 73 deletions
diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs
index 86c24bc..f55b492 100644
--- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs
+++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs
@@ -28,11 +28,16 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Reflection; 30using System.Reflection;
31using System.Threading;
32
31using libsecondlife; 33using libsecondlife;
32using log4net; 34using log4net;
33 35
34namespace OpenSim.Framework.Communications.Cache 36namespace OpenSim.Framework.Communications.Cache
35{ 37{
38 internal delegate void CreateInventoryFolderDelegate(
39 string folderName, LLUUID folderID, ushort folderType, LLUUID parentID);
40
36 /// <summary> 41 /// <summary>
37 /// Stores user profile and inventory data received from backend services for a particular user. 42 /// Stores user profile and inventory data received from backend services for a particular user.
38 /// </summary> 43 /// </summary>
@@ -297,6 +302,99 @@ namespace OpenSim.Framework.Communications.Cache
297 } 302 }
298 } 303 }
299 } 304 }
305
306 /// <summary>
307 /// Create a folder in this agent's inventory
308 /// </summary>
309 /// <param name="parentID"></param>
310 /// <returns></returns>
311 public bool CreateFolder(string folderName, LLUUID folderID, ushort folderType, LLUUID parentID)
312 {
313// m_log.DebugFormat(
314// "[AGENT INVENTORY]: Creating inventory folder {0} {1} for {2} {3}", folderID, folderName, remoteClient.Name, remoteClient.AgentId);
315
316 if (HasInventory)
317 {
318 if (RootFolder.ID == parentID)
319 {
320 InventoryFolderImpl createdFolder = RootFolder.CreateNewSubFolder(folderID, folderName, folderType);
321
322 if (createdFolder != null)
323 {
324 InventoryFolderBase createdBaseFolder = new InventoryFolderBase();
325 createdBaseFolder.Owner = createdFolder.Owner;
326 createdBaseFolder.ID = createdFolder.ID;
327 createdBaseFolder.Name = createdFolder.Name;
328 createdBaseFolder.ParentID = createdFolder.ParentID;
329 createdBaseFolder.Type = createdFolder.Type;
330 createdBaseFolder.Version = createdFolder.Version;
331
332 m_commsManager.InventoryService.AddFolder(createdBaseFolder);
333
334 return true;
335 }
336 else
337 {
338 m_log.WarnFormat(
339 "[INVENTORY CACHE]: Tried to create folder {0} {1} but the folder already exists",
340 folderName, folderID);
341
342 return false;
343 }
344 }
345 else
346 {
347 InventoryFolderImpl folder = RootFolder.GetDescendentFolder(parentID);
348
349 if (folder != null)
350 {
351 InventoryFolderImpl createdFolder = folder.CreateNewSubFolder(folderID, folderName, folderType);
352
353 if (createdFolder != null)
354 {
355 InventoryFolderBase createdBaseFolder = new InventoryFolderBase();
356 createdBaseFolder.Owner = createdFolder.Owner;
357 createdBaseFolder.ID = createdFolder.ID;
358 createdBaseFolder.Name = createdFolder.Name;
359 createdBaseFolder.ParentID = createdFolder.ParentID;
360 createdBaseFolder.Type = createdFolder.Type;
361 createdBaseFolder.Version = createdFolder.Version;
362
363 m_commsManager.InventoryService.AddFolder(createdBaseFolder);
364
365 return true;
366 }
367 else
368 {
369 m_log.WarnFormat(
370 "[INVENTORY CACHE]: Tried to create folder {0} {1} but the folder already exists",
371 folderName, folderID);
372
373 return false;
374 }
375 }
376 else
377 {
378 m_log.WarnFormat(
379 "[INVENTORY CACHE]: Could not find parent folder with id {0} in order to create folder {1} {2}",
380 parentID, folderName, folderID);
381
382 return false;
383 }
384 }
385 }
386 else
387 {
388 AddRequest(
389 new InventoryRequest(
390 Delegate.CreateDelegate(typeof(CreateInventoryFolderDelegate), this, "CreateFolder"),
391 new object[] { folderName, folderID, folderType, parentID }));
392
393 return true;
394 }
395
396 return false;
397 }
300 398
301 /// <summary> 399 /// <summary>
302 /// Add an item to the user's inventory 400 /// Add an item to the user's inventory
@@ -360,7 +458,7 @@ namespace OpenSim.Framework.Communications.Cache
360 /// <summary> 458 /// <summary>
361 /// Generic inventory request 459 /// Generic inventory request
362 /// </summary> 460 /// </summary>
363 public class InventoryRequest : IInventoryRequest 461 class InventoryRequest : IInventoryRequest
364 { 462 {
365 private Delegate m_delegat; 463 private Delegate m_delegat;
366 private Object[] m_args; 464 private Object[] m_args;
diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs
index befb6c7..f1929c8 100644
--- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs
+++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs
@@ -34,8 +34,6 @@ using log4net;
34 34
35namespace OpenSim.Framework.Communications.Cache 35namespace OpenSim.Framework.Communications.Cache
36{ 36{
37 internal delegate void CreateInventoryFolderDelegate(
38 IClientAPI remoteClient, LLUUID folderID, ushort folderType, string folderName, LLUUID parentID);
39 internal delegate void MoveInventoryFolderDelegate(IClientAPI remoteClient, LLUUID folderID, LLUUID parentID); 37 internal delegate void MoveInventoryFolderDelegate(IClientAPI remoteClient, LLUUID folderID, LLUUID parentID);
40 internal delegate void PurgeInventoryDescendentsDelegate(IClientAPI remoteClient, LLUUID folderID); 38 internal delegate void PurgeInventoryDescendentsDelegate(IClientAPI remoteClient, LLUUID folderID);
41 internal delegate void UpdateInventoryFolderDelegate( 39 internal delegate void UpdateInventoryFolderDelegate(
@@ -157,80 +155,16 @@ namespace OpenSim.Framework.Communications.Cache
157 /// <param name="parentID"></param> 155 /// <param name="parentID"></param>
158 public void HandleCreateInventoryFolder(IClientAPI remoteClient, LLUUID folderID, ushort folderType, 156 public void HandleCreateInventoryFolder(IClientAPI remoteClient, LLUUID folderID, ushort folderType,
159 string folderName, LLUUID parentID) 157 string folderName, LLUUID parentID)
160 { 158 {
161// m_log.DebugFormat(
162// "[AGENT INVENTORY]: Creating inventory folder {0} {1} for {2} {3}", folderID, folderName, remoteClient.Name, remoteClient.AgentId);
163
164 CachedUserInfo userProfile; 159 CachedUserInfo userProfile;
165 160
166 if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile)) 161 if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile))
167 { 162 {
168 if (userProfile.HasInventory) 163 if (!userProfile.CreateFolder(folderName, folderID, folderType, parentID))
169 { 164 {
170 if (userProfile.RootFolder.ID == parentID) 165 m_log.WarnFormat(
171 { 166 "[AGENT INVENTORY]: Failed to create folder for user {0} {1}",
172 InventoryFolderImpl createdFolder = 167 remoteClient.Name, remoteClient.AgentId);
173 userProfile.RootFolder.CreateNewSubFolder(folderID, folderName, folderType);
174
175 if (createdFolder != null)
176 {
177 InventoryFolderBase createdBaseFolder = new InventoryFolderBase();
178 createdBaseFolder.Owner = createdFolder.Owner;
179 createdBaseFolder.ID = createdFolder.ID;
180 createdBaseFolder.Name = createdFolder.Name;
181 createdBaseFolder.ParentID = createdFolder.ParentID;
182 createdBaseFolder.Type = createdFolder.Type;
183 createdBaseFolder.Version = createdFolder.Version;
184
185 m_commsManager.InventoryService.AddFolder(createdBaseFolder);
186 }
187 else
188 {
189 m_log.WarnFormat(
190 "[INVENTORY CACHE]: Tried to create folder {0} {1} for user {2} {3} but the folder already exists",
191 folderName, folderID, remoteClient.Name, remoteClient.AgentId);
192 }
193 }
194 else
195 {
196 InventoryFolderImpl folder = userProfile.RootFolder.GetDescendentFolder(parentID);
197 if (folder != null)
198 {
199 InventoryFolderImpl createdFolder = folder.CreateNewSubFolder(folderID, folderName, folderType);
200
201 if (createdFolder != null)
202 {
203 InventoryFolderBase createdBaseFolder = new InventoryFolderBase();
204 createdBaseFolder.Owner = createdFolder.Owner;
205 createdBaseFolder.ID = createdFolder.ID;
206 createdBaseFolder.Name = createdFolder.Name;
207 createdBaseFolder.ParentID = createdFolder.ParentID;
208 createdBaseFolder.Type = createdFolder.Type;
209 createdBaseFolder.Version = createdFolder.Version;
210
211 m_commsManager.InventoryService.AddFolder(createdBaseFolder);
212 }
213 else
214 {
215 m_log.WarnFormat(
216 "[INVENTORY CACHE]: Tried to create folder {0} {1} for user {2} {3} but the folder already exists",
217 folderName, folderID, remoteClient.Name, remoteClient.AgentId);
218 }
219 }
220 else
221 {
222 m_log.WarnFormat(
223 "[INVENTORY CACHE]: Could not find parent folder with id {0} in order to create folder {1} {2} for user {3} {4}",
224 parentID, folderName, folderID, remoteClient.Name, remoteClient.AgentId);
225 }
226 }
227 }
228 else
229 {
230 userProfile.AddRequest(
231 new InventoryRequest(
232 Delegate.CreateDelegate(typeof(CreateInventoryFolderDelegate), this, "HandleCreateInventoryFolder"),
233 new object[] { remoteClient, folderID, folderType, folderName, parentID }));
234 } 168 }
235 } 169 }
236 } 170 }
diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs
index 1601963..e81d8c4 100644
--- a/OpenSim/Framework/Communications/InventoryServiceBase.cs
+++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs
@@ -28,11 +28,16 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Reflection; 30using System.Reflection;
31using System.Threading;
32
31using libsecondlife; 33using libsecondlife;
32using log4net; 34using log4net;
33 35
34namespace OpenSim.Framework.Communications 36namespace OpenSim.Framework.Communications
35{ 37{
38 /// <summary>
39 /// Abstract base class used by local and grid implementations of an inventory service.
40 /// </summary>
36 public abstract class InventoryServiceBase : IInventoryServices 41 public abstract class InventoryServiceBase : IInventoryServices
37 { 42 {
38 private static readonly ILog m_log 43 private static readonly ILog m_log
@@ -178,10 +183,11 @@ namespace OpenSim.Framework.Communications
178 183
179 #endregion 184 #endregion
180 185
186 // See IInventoryServices
181 public bool AddFolder(InventoryFolderBase folder) 187 public bool AddFolder(InventoryFolderBase folder)
182 { 188 {
183 m_log.DebugFormat( 189 m_log.DebugFormat(
184 "[AGENT INVENTORY]: Adding folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID); 190 "[AGENT INVENTORY]: Adding folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID);
185 191
186 foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins) 192 foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins)
187 { 193 {
@@ -192,6 +198,7 @@ namespace OpenSim.Framework.Communications
192 return true; 198 return true;
193 } 199 }
194 200
201 // See IInventoryServices
195 public bool MoveFolder(InventoryFolderBase folder) 202 public bool MoveFolder(InventoryFolderBase folder)
196 { 203 {
197 m_log.DebugFormat( 204 m_log.DebugFormat(
@@ -206,6 +213,7 @@ namespace OpenSim.Framework.Communications
206 return true; 213 return true;
207 } 214 }
208 215
216 // See IInventoryServices
209 public bool AddItem(InventoryItemBase item) 217 public bool AddItem(InventoryItemBase item)
210 { 218 {
211 m_log.DebugFormat( 219 m_log.DebugFormat(
@@ -220,6 +228,7 @@ namespace OpenSim.Framework.Communications
220 return true; 228 return true;
221 } 229 }
222 230
231 // See IInventoryServices
223 public bool UpdateItem(InventoryItemBase item) 232 public bool UpdateItem(InventoryItemBase item)
224 { 233 {
225 m_log.InfoFormat( 234 m_log.InfoFormat(
@@ -234,6 +243,7 @@ namespace OpenSim.Framework.Communications
234 return true; 243 return true;
235 } 244 }
236 245
246 // See IInventoryServices
237 public bool DeleteItem(InventoryItemBase item) 247 public bool DeleteItem(InventoryItemBase item)
238 { 248 {
239 m_log.InfoFormat( 249 m_log.InfoFormat(