aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs
diff options
context:
space:
mode:
authorJustin Clarke Casey2008-05-03 19:50:49 +0000
committerJustin Clarke Casey2008-05-03 19:50:49 +0000
commit068163b14bae4f411bb3cf2b34981eb212b7639b (patch)
treef00d55a71821893e3738ac5ba1fef7fd5402bc27 /OpenSim/Framework/Communications/Cache/CachedUserInfo.cs
parent* Made 3Di LoadBalancerPlugin compatible with recent IClientNetworkServer cha... (diff)
downloadopensim-SC-068163b14bae4f411bb3cf2b34981eb212b7639b.zip
opensim-SC-068163b14bae4f411bb3cf2b34981eb212b7639b.tar.gz
opensim-SC-068163b14bae4f411bb3cf2b34981eb212b7639b.tar.bz2
opensim-SC-068163b14bae4f411bb3cf2b34981eb212b7639b.tar.xz
* Refactor: Move MoveFolder() and PurgeFolder() into CachedUserInfo (which arguably should be split)
Diffstat (limited to 'OpenSim/Framework/Communications/Cache/CachedUserInfo.cs')
-rw-r--r--OpenSim/Framework/Communications/Cache/CachedUserInfo.cs97
1 files changed, 87 insertions, 10 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
36namespace OpenSim.Framework.Communications.Cache 36namespace 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}