From 68c6b6ece3f1f20a81806b08ffd5c73296324d6c Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 22 Apr 2008 18:58:09 +0000 Subject: * Replace previous specific inventory callback code with generic alternative --- .../Communications/Cache/CachedUserInfo.cs | 23 +++++++++++ .../Cache/UserProfileCacheService.cs | 47 ++++++++-------------- 2 files changed, 40 insertions(+), 30 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 3d7ada3..9a7ce42 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -332,6 +332,29 @@ namespace OpenSim.Framework.Communications.Cache /// public interface IInventoryRequest { + /// + /// This is the method executed once we have received the user's inventory by which the request can be fulfilled. + /// void Execute(); } + + /// + /// Generic inventory request + /// + public class InventoryRequest : IInventoryRequest + { + private Delegate m_delegat; + private Object[] m_args; + + internal InventoryRequest(Delegate delegat, Object[] args) + { + m_delegat = delegat; + m_args = args; + } + + public void Execute() + { + m_delegat.DynamicInvoke(m_args); + } + } } diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index cbf2ded..eb85ec8 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -25,14 +25,19 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +using System; using System.Collections.Generic; using System.Reflection; using System.Threading; + using libsecondlife; using log4net; namespace OpenSim.Framework.Communications.Cache { + internal delegate void UpdateInventoryFolderDelegate( + IClientAPI remoteClient, LLUUID folderID, ushort type, string name, LLUUID parentID); + /// /// Holds user profile information and retrieves it from backend services. /// @@ -221,7 +226,10 @@ namespace OpenSim.Framework.Communications.Cache } else { - userProfile.AddRequest(new UpdateFolderRequest(this, remoteClient, folderID, type, name, parentID)); + userProfile.AddRequest( + new InventoryRequest( + Delegate.CreateDelegate(typeof(UpdateInventoryFolderDelegate), this, "HandleUpdateInventoryFolder"), + new object[] { remoteClient, folderID, type, name, parentID })); } } } @@ -234,6 +242,10 @@ namespace OpenSim.Framework.Communications.Cache /// public void HandleMoveInventoryFolder(IClientAPI remoteClient, LLUUID folderID, LLUUID parentID) { + m_log.DebugFormat( + "[AGENT INVENTORY] Moving inventory folder {0} into folder {1} for {2} {3}", + parentID, remoteClient.Name, remoteClient.AgentId); + CachedUserInfo userProfile; if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile)) @@ -246,6 +258,10 @@ namespace OpenSim.Framework.Communications.Cache baseFolder.ParentID = parentID; m_commsManager.InventoryService.MoveInventoryFolder(remoteClient.AgentId, baseFolder); } +// else +// { +// userProfile.AddRequest(new MoveFolderRequest(remoteClient, folderID, parentID)); +// } } } @@ -499,33 +515,4 @@ namespace OpenSim.Framework.Communications.Cache } } } - - /// - /// Used to create an update folder request if we haven't yet received the user's inventory - /// - internal class UpdateFolderRequest : IInventoryRequest - { - private UserProfileCacheService m_userProfileCacheService; - private IClientAPI m_client; - private LLUUID m_folderID; - private ushort m_type; - private string m_name; - private LLUUID m_parentID; - - internal UpdateFolderRequest( - UserProfileCacheService cacheService, IClientAPI client, LLUUID folderID, ushort type, string name, LLUUID parentID) - { - m_userProfileCacheService = cacheService; - m_client = client; - m_folderID = folderID; - m_type = type; - m_name = name; - m_parentID = parentID; - } - - public void Execute() - { - m_userProfileCacheService.HandleUpdateInventoryFolder(m_client, m_folderID, m_type, m_name, m_parentID); - } - } } -- cgit v1.1