diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/Communications/Cache/CachedUserInfo.cs | 97 | ||||
-rw-r--r-- | OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs | 65 |
2 files changed, 100 insertions, 62 deletions
diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 35c2002..ceca1a4 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs | |||
@@ -35,10 +35,10 @@ using log4net; | |||
35 | 35 | ||
36 | namespace OpenSim.Framework.Communications.Cache | 36 | namespace OpenSim.Framework.Communications.Cache |
37 | { | 37 | { |
38 | internal delegate void CreateInventoryFolderDelegate( | 38 | internal delegate void CreateFolderDelegate(string folderName, LLUUID folderID, ushort folderType, LLUUID parentID); |
39 | string folderName, LLUUID folderID, ushort folderType, LLUUID parentID); | 39 | internal delegate void MoveFolderDelegate(LLUUID folderID, LLUUID parentID); |
40 | internal delegate void UpdateInventoryFolderDelegate( | 40 | internal delegate void PurgeFolderDelegate(LLUUID folderID); |
41 | string name, LLUUID folderID, ushort type, LLUUID parentID); | 41 | internal delegate void UpdateFolderDelegate(string name, LLUUID folderID, ushort type, LLUUID parentID); |
42 | 42 | ||
43 | /// <summary> | 43 | /// <summary> |
44 | /// Stores user profile and inventory data received from backend services for a particular user. | 44 | /// Stores user profile and inventory data received from backend services for a particular user. |
@@ -54,7 +54,7 @@ namespace OpenSim.Framework.Communications.Cache | |||
54 | private readonly CommunicationsManager m_commsManager; | 54 | private readonly CommunicationsManager m_commsManager; |
55 | 55 | ||
56 | public UserProfileData UserProfile { get { return m_userProfile; } } | 56 | public UserProfileData UserProfile { get { return m_userProfile; } } |
57 | private UserProfileData m_userProfile; | 57 | private readonly UserProfileData m_userProfile; |
58 | 58 | ||
59 | /// <summary> | 59 | /// <summary> |
60 | /// Has we received the user's inventory from the inventory service? | 60 | /// Has we received the user's inventory from the inventory service? |
@@ -389,7 +389,7 @@ namespace OpenSim.Framework.Communications.Cache | |||
389 | { | 389 | { |
390 | AddRequest( | 390 | AddRequest( |
391 | new InventoryRequest( | 391 | new InventoryRequest( |
392 | Delegate.CreateDelegate(typeof(CreateInventoryFolderDelegate), this, "CreateFolder"), | 392 | Delegate.CreateDelegate(typeof(CreateFolderDelegate), this, "CreateFolder"), |
393 | new object[] { folderName, folderID, folderType, parentID })); | 393 | new object[] { folderName, folderID, folderType, parentID })); |
394 | 394 | ||
395 | return true; | 395 | return true; |
@@ -428,11 +428,88 @@ namespace OpenSim.Framework.Communications.Cache | |||
428 | { | 428 | { |
429 | AddRequest( | 429 | AddRequest( |
430 | new InventoryRequest( | 430 | new InventoryRequest( |
431 | Delegate.CreateDelegate(typeof(UpdateInventoryFolderDelegate), this, "UpdateFolder"), | 431 | Delegate.CreateDelegate(typeof(UpdateFolderDelegate), this, "UpdateFolder"), |
432 | new object[] { name, folderID, type, parentID })); | 432 | new object[] { name, folderID, type, parentID })); |
433 | } | 433 | } |
434 | 434 | ||
435 | return true; | 435 | return true; |
436 | } | ||
437 | |||
438 | /// <summary> | ||
439 | /// Handle an inventory folder move request from the client. | ||
440 | /// </summary> | ||
441 | /// <param name="folderID"></param> | ||
442 | /// <param name="parentID"></param> | ||
443 | public bool MoveFolder(LLUUID folderID, LLUUID parentID) | ||
444 | { | ||
445 | // m_log.DebugFormat( | ||
446 | // "[AGENT INVENTORY]: Moving inventory folder {0} into folder {1} for {2} {3}", | ||
447 | // parentID, remoteClient.Name, remoteClient.Name, remoteClient.AgentId); | ||
448 | |||
449 | if (HasInventory) | ||
450 | { | ||
451 | InventoryFolderBase baseFolder = new InventoryFolderBase(); | ||
452 | baseFolder.Owner = m_userProfile.ID; | ||
453 | baseFolder.ID = folderID; | ||
454 | baseFolder.ParentID = parentID; | ||
455 | |||
456 | m_commsManager.InventoryService.MoveFolder(baseFolder); | ||
457 | |||
458 | return true; | ||
459 | } | ||
460 | else | ||
461 | { | ||
462 | AddRequest( | ||
463 | new InventoryRequest( | ||
464 | Delegate.CreateDelegate(typeof(MoveFolderDelegate), this, "MoveFolder"), | ||
465 | new object[] { folderID, parentID })); | ||
466 | |||
467 | return true; | ||
468 | } | ||
469 | } | ||
470 | |||
471 | /// <summary> | ||
472 | /// This method will delete all the items and folders in the given folder. | ||
473 | /// </summary> | ||
474 | /// <param name="folderID"></param> | ||
475 | public bool PurgeFolder(LLUUID folderID) | ||
476 | { | ||
477 | // m_log.InfoFormat("[AGENT INVENTORY]: Purging folder {0} for {1} uuid {2}", | ||
478 | // folderID, remoteClient.Name, remoteClient.AgentId); | ||
479 | |||
480 | if (HasInventory) | ||
481 | { | ||
482 | InventoryFolderImpl purgedFolder = RootFolder.GetDescendentFolder(folderID); | ||
483 | |||
484 | if (purgedFolder != null) | ||
485 | { | ||
486 | // XXX Nasty - have to create a new object to hold details we already have | ||
487 | InventoryFolderBase purgedBaseFolder = new InventoryFolderBase(); | ||
488 | purgedBaseFolder.Owner = purgedFolder.Owner; | ||
489 | purgedBaseFolder.ID = purgedFolder.ID; | ||
490 | purgedBaseFolder.Name = purgedFolder.Name; | ||
491 | purgedBaseFolder.ParentID = purgedFolder.ParentID; | ||
492 | purgedBaseFolder.Type = purgedFolder.Type; | ||
493 | purgedBaseFolder.Version = purgedFolder.Version; | ||
494 | |||
495 | m_commsManager.InventoryService.PurgeFolder(purgedBaseFolder); | ||
496 | |||
497 | purgedFolder.Purge(); | ||
498 | |||
499 | return true; | ||
500 | } | ||
501 | } | ||
502 | else | ||
503 | { | ||
504 | AddRequest( | ||
505 | new InventoryRequest( | ||
506 | Delegate.CreateDelegate(typeof(PurgeFolderDelegate), this, "PurgeFolder"), | ||
507 | new object[] { folderID })); | ||
508 | |||
509 | return true; | ||
510 | } | ||
511 | |||
512 | return false; | ||
436 | } | 513 | } |
437 | 514 | ||
438 | /// <summary> | 515 | /// <summary> |
@@ -499,18 +576,18 @@ namespace OpenSim.Framework.Communications.Cache | |||
499 | /// </summary> | 576 | /// </summary> |
500 | class InventoryRequest : IInventoryRequest | 577 | class InventoryRequest : IInventoryRequest |
501 | { | 578 | { |
502 | private Delegate m_delegat; | 579 | private Delegate m_delegate; |
503 | private Object[] m_args; | 580 | private Object[] m_args; |
504 | 581 | ||
505 | internal InventoryRequest(Delegate delegat, Object[] args) | 582 | internal InventoryRequest(Delegate delegat, Object[] args) |
506 | { | 583 | { |
507 | m_delegat = delegat; | 584 | m_delegate = delegat; |
508 | m_args = args; | 585 | m_args = args; |
509 | } | 586 | } |
510 | 587 | ||
511 | public void Execute() | 588 | public void Execute() |
512 | { | 589 | { |
513 | m_delegat.DynamicInvoke(m_args); | 590 | m_delegate.DynamicInvoke(m_args); |
514 | } | 591 | } |
515 | } | 592 | } |
516 | } | 593 | } |
diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index f640fb8..0404477 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs | |||
@@ -33,10 +33,7 @@ using libsecondlife; | |||
33 | using log4net; | 33 | using log4net; |
34 | 34 | ||
35 | namespace OpenSim.Framework.Communications.Cache | 35 | namespace OpenSim.Framework.Communications.Cache |
36 | { | 36 | { |
37 | internal delegate void MoveInventoryFolderDelegate(IClientAPI remoteClient, LLUUID folderID, LLUUID parentID); | ||
38 | internal delegate void PurgeInventoryDescendentsDelegate(IClientAPI remoteClient, LLUUID folderID); | ||
39 | |||
40 | /// <summary> | 37 | /// <summary> |
41 | /// Holds user profile information and retrieves it from backend services. | 38 | /// Holds user profile information and retrieves it from backend services. |
42 | /// </summary> | 39 | /// </summary> |
@@ -199,7 +196,7 @@ namespace OpenSim.Framework.Communications.Cache | |||
199 | if (!userProfile.UpdateFolder(name, folderID, type, parentID)) | 196 | if (!userProfile.UpdateFolder(name, folderID, type, parentID)) |
200 | { | 197 | { |
201 | m_log.ErrorFormat( | 198 | m_log.ErrorFormat( |
202 | "[AGENT INVENTORY]: Failed to create folder for user {0} {1}", | 199 | "[AGENT INVENTORY]: Failed to update folder for user {0} {1}", |
203 | remoteClient.Name, remoteClient.AgentId); | 200 | remoteClient.Name, remoteClient.AgentId); |
204 | } | 201 | } |
205 | } | 202 | } |
@@ -219,29 +216,15 @@ namespace OpenSim.Framework.Communications.Cache | |||
219 | /// <param name="parentID"></param> | 216 | /// <param name="parentID"></param> |
220 | public void HandleMoveInventoryFolder(IClientAPI remoteClient, LLUUID folderID, LLUUID parentID) | 217 | public void HandleMoveInventoryFolder(IClientAPI remoteClient, LLUUID folderID, LLUUID parentID) |
221 | { | 218 | { |
222 | // m_log.DebugFormat( | ||
223 | // "[AGENT INVENTORY]: Moving inventory folder {0} into folder {1} for {2} {3}", | ||
224 | // parentID, remoteClient.Name, remoteClient.Name, remoteClient.AgentId); | ||
225 | |||
226 | CachedUserInfo userProfile; | 219 | CachedUserInfo userProfile; |
227 | 220 | ||
228 | if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile)) | 221 | if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile)) |
229 | { | 222 | { |
230 | if (userProfile.HasInventory) | 223 | if (!userProfile.MoveFolder(folderID, parentID)) |
231 | { | ||
232 | InventoryFolderBase baseFolder = new InventoryFolderBase(); | ||
233 | baseFolder.Owner = remoteClient.AgentId; | ||
234 | baseFolder.ID = folderID; | ||
235 | baseFolder.ParentID = parentID; | ||
236 | |||
237 | m_commsManager.InventoryService.MoveFolder(baseFolder); | ||
238 | } | ||
239 | else | ||
240 | { | 224 | { |
241 | userProfile.AddRequest( | 225 | m_log.ErrorFormat( |
242 | new InventoryRequest( | 226 | "[AGENT INVENTORY]: Failed to move folder for user {0} {1}", |
243 | Delegate.CreateDelegate(typeof(MoveInventoryFolderDelegate), this, "HandleMoveInventoryFolder"), | 227 | remoteClient.Name, remoteClient.AgentId); |
244 | new object[] { remoteClient, folderID, parentID })); | ||
245 | } | 228 | } |
246 | } | 229 | } |
247 | else | 230 | else |
@@ -249,7 +232,7 @@ namespace OpenSim.Framework.Communications.Cache | |||
249 | m_log.ErrorFormat( | 232 | m_log.ErrorFormat( |
250 | "[AGENT INVENTORY]: Could not find user profile for {0} {1}", | 233 | "[AGENT INVENTORY]: Could not find user profile for {0} {1}", |
251 | remoteClient.Name, remoteClient.AgentId); | 234 | remoteClient.Name, remoteClient.AgentId); |
252 | } | 235 | } |
253 | } | 236 | } |
254 | 237 | ||
255 | /// <summary> | 238 | /// <summary> |
@@ -463,37 +446,15 @@ namespace OpenSim.Framework.Communications.Cache | |||
463 | /// <param name="folderID"></param> | 446 | /// <param name="folderID"></param> |
464 | public void HandlePurgeInventoryDescendents(IClientAPI remoteClient, LLUUID folderID) | 447 | public void HandlePurgeInventoryDescendents(IClientAPI remoteClient, LLUUID folderID) |
465 | { | 448 | { |
466 | // m_log.InfoFormat("[AGENT INVENTORY]: Purging folder {0} for {1} uuid {2}", | ||
467 | // folderID, remoteClient.Name, remoteClient.AgentId); | ||
468 | |||
469 | CachedUserInfo userProfile; | 449 | CachedUserInfo userProfile; |
450 | |||
470 | if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile)) | 451 | if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile)) |
471 | { | 452 | { |
472 | if (userProfile.HasInventory) | 453 | if (!userProfile.PurgeFolder(folderID)) |
473 | { | 454 | { |
474 | InventoryFolderImpl purgedFolder = userProfile.RootFolder.GetDescendentFolder(folderID); | 455 | m_log.ErrorFormat( |
475 | if (purgedFolder != null) | 456 | "[AGENT INVENTORY]: Failed to purge folder for user {0} {1}", |
476 | { | 457 | remoteClient.Name, remoteClient.AgentId); |
477 | // XXX Nasty - have to create a new object to hold details we already have | ||
478 | InventoryFolderBase purgedBaseFolder = new InventoryFolderBase(); | ||
479 | purgedBaseFolder.Owner = purgedFolder.Owner; | ||
480 | purgedBaseFolder.ID = purgedFolder.ID; | ||
481 | purgedBaseFolder.Name = purgedFolder.Name; | ||
482 | purgedBaseFolder.ParentID = purgedFolder.ParentID; | ||
483 | purgedBaseFolder.Type = purgedFolder.Type; | ||
484 | purgedBaseFolder.Version = purgedFolder.Version; | ||
485 | |||
486 | m_commsManager.InventoryService.PurgeFolder(purgedBaseFolder); | ||
487 | |||
488 | purgedFolder.Purge(); | ||
489 | } | ||
490 | } | ||
491 | else | ||
492 | { | ||
493 | userProfile.AddRequest( | ||
494 | new InventoryRequest( | ||
495 | Delegate.CreateDelegate(typeof(PurgeInventoryDescendentsDelegate), this, "HandlePurgeInventoryDescendents"), | ||
496 | new object[] { remoteClient, folderID })); | ||
497 | } | 458 | } |
498 | } | 459 | } |
499 | else | 460 | else |
@@ -501,7 +462,7 @@ namespace OpenSim.Framework.Communications.Cache | |||
501 | m_log.ErrorFormat( | 462 | m_log.ErrorFormat( |
502 | "[AGENT INVENTORY]: Could not find user profile for {0} {1}", | 463 | "[AGENT INVENTORY]: Could not find user profile for {0} {1}", |
503 | remoteClient.Name, remoteClient.AgentId); | 464 | remoteClient.Name, remoteClient.AgentId); |
504 | } | 465 | } |
505 | } | 466 | } |
506 | 467 | ||
507 | public void HandleFetchInventory(IClientAPI remoteClient, LLUUID itemID, LLUUID ownerID) | 468 | public void HandleFetchInventory(IClientAPI remoteClient, LLUUID itemID, LLUUID ownerID) |