From 365cf8e4555e5105d669f3ebf11d3fb5b563f9a8 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Wed, 13 Feb 2008 00:30:51 +0000 Subject: * Refactor: Move last commit's refactor back to AgentAssetTransactionsManager * Push asset update (invoked when clothing is altered) down into AgentAssetTransactions from Scene.Inventory.cs to join others * I've tested that clothing creation and update still works, but please let me know if it suddently breaks for you. * Add/correct comments --- .../Communications/Cache/AgentAssetTransactions.cs | 47 +++++++++ .../Cache/AgentAssetTransactionsManager.cs | 116 ++++++++++++++------- 2 files changed, 128 insertions(+), 35 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AgentAssetTransactions.cs b/OpenSim/Framework/Communications/Cache/AgentAssetTransactions.cs index e74a06b..92390b5 100644 --- a/OpenSim/Framework/Communications/Cache/AgentAssetTransactions.cs +++ b/OpenSim/Framework/Communications/Cache/AgentAssetTransactions.cs @@ -136,6 +136,15 @@ namespace OpenSim.Framework.Communications.Cache wearableType, nextOwnerMask); } } + + public void RequestUpdateInventoryItem(IClientAPI remoteClient, LLUUID transactionID, + InventoryItemBase item) + { + if (XferUploaders.ContainsKey(transactionID)) + { + XferUploaders[transactionID].RequestUpdateInventoryItem(remoteClient, transactionID, item); + } + } /// /// Get an uploaded asset. If the data is successfully retrieved, the transaction will be removed. @@ -351,6 +360,44 @@ namespace OpenSim.Framework.Communications.Cache } } } + + public void RequestUpdateInventoryItem(IClientAPI remoteClient, LLUUID transactionID, + InventoryItemBase item) + { + if (TransactionID == transactionID) + { + CachedUserInfo userInfo = + m_userTransactions.Manager.CommsManager.UserProfileCacheService.GetUserDetails( + remoteClient.AgentId); + + if (userInfo != null) + { + LLUUID assetID = LLUUID.Combine(transactionID, remoteClient.SecureSessionId); + + AssetBase asset + = m_userTransactions.Manager.CommsManager.AssetCache.GetAsset( + assetID, (item.assetType == (int) AssetType.Texture ? true : false)); + + if (asset == null) + { + asset = m_userTransactions.GetTransactionAsset(transactionID); + } + + if (asset != null && asset.FullID == assetID) + { + asset.Name = item.inventoryName; + asset.Description = item.inventoryDescription; + asset.InvType = (sbyte) item.invType; + asset.Type = (sbyte) item.assetType; + item.assetID = asset.FullID; + + m_userTransactions.Manager.CommsManager.AssetCache.AddAsset(Asset); + } + + userInfo.UpdateItem(remoteClient.AgentId, item); + } + } + } private void DoCreateItem() { diff --git a/OpenSim/Framework/Communications/Cache/AgentAssetTransactionsManager.cs b/OpenSim/Framework/Communications/Cache/AgentAssetTransactionsManager.cs index c9c35d2..48b2563 100644 --- a/OpenSim/Framework/Communications/Cache/AgentAssetTransactionsManager.cs +++ b/OpenSim/Framework/Communications/Cache/AgentAssetTransactionsManager.cs @@ -34,7 +34,8 @@ using libsecondlife; namespace OpenSim.Framework.Communications.Cache { /// - /// Manage the collection of agent asset transaction collections. Each agent has its own transaction collection + /// Provider handlers for processing asset transactions originating from the agent. This encompasses + /// clothing creation and update as well as asset uploads. /// public class AgentAssetTransactionsManager { @@ -62,34 +63,76 @@ namespace OpenSim.Framework.Communications.Cache } /// - /// Add a collection of asset transactions for the given user + /// Get the collection of asset transactions for the given user. If one does not already exist, it + /// is created. /// /// - public void AddUser(LLUUID userID) + /// + private AgentAssetTransactions GetUserTransactions(LLUUID userID) { lock (AgentTransactions) { if (!AgentTransactions.ContainsKey(userID)) { - AgentAssetTransactions transactions = new AgentAssetTransactions(userID, this, m_dumpAssetsToFile); - AgentTransactions.Add(userID, transactions); + AgentAssetTransactions transactions + = new AgentAssetTransactions(userID, this, m_dumpAssetsToFile); + AgentTransactions.Add(userID, transactions); } } + + return AgentTransactions[userID]; } - + /// - /// Get the collection of asset transactions for the given user. + /// Create an inventory item from data that has been received through a transaction. + /// + /// This is called when new clothing or body parts are created. It may also be called in other + /// situations. /// - /// - /// null if this agent does not have an asset transactions collection - public AgentAssetTransactions GetUserTransactions(LLUUID userID) + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public void HandleItemCreationFromTransaction(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID, + uint callbackID, string description, string name, sbyte invType, + sbyte type, byte wearableType, uint nextOwnerMask) { - if (AgentTransactions.ContainsKey(userID)) - { - return AgentTransactions[userID]; - } + m_log.InfoFormat( + "[TRANSACTIONS MANAGER] Called HandleItemCreationFromTransaction with item {0}", name); + + AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); - return null; + transactions.RequestCreateInventoryItem( + remoteClient, transactionID, folderID, callbackID, description, + name, invType, type, wearableType, nextOwnerMask); + } + + /// + /// Update an inventory item with data that has been received through a transaction. + /// + /// This is called when clothing or body parts are updated (for instance, with new textures or + /// colours). It may also be called in other situations. + /// + /// + /// + /// + public void HandleItemUpdateFromTransaction(IClientAPI remoteClient, LLUUID transactionID, + InventoryItemBase item) + { + m_log.InfoFormat( + "[TRANSACTIONS MANAGER] Called HandleItemUpdateFromTransaction with item {0}", + item.inventoryName); + + AgentAssetTransactions transactions + = CommsManager.TransactionsManager.GetUserTransactions(remoteClient.AgentId); + + transactions.RequestUpdateInventoryItem(remoteClient, transactionID, item); } public void HandleUDPUploadRequest(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, @@ -97,36 +140,39 @@ namespace OpenSim.Framework.Communications.Cache { // Console.WriteLine("asset upload of " + assetID); AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); - if (transactions != null) + + AgentAssetTransactions.AssetXferUploader uploader = transactions.RequestXferUploader(transaction); + if (uploader != null) { - AgentAssetTransactions.AssetXferUploader uploader = transactions.RequestXferUploader(transaction); - if (uploader != null) + // Upload has already compelted uploading... + + if (uploader.Initialise(remoteClient, assetID, transaction, type, data, storeLocal, tempFile)) { - // Upload has already compelted uploading... - - if (uploader.Initialise(remoteClient, assetID, transaction, type, data, storeLocal, tempFile)) + //[commenting out as this removal breaks uploads] + /*lock (transactions.XferUploaders) { - //[commenting out as this removal breaks uploads] - /*lock (transactions.XferUploaders) - { - - // XXX Weak ass way of doing this by directly manipulating this public dictionary, purely temporary - transactions.XferUploaders.Remove(uploader.TransactionID); - - //m_log.InfoFormat("[ASSET TRANSACTIONS] Current uploaders: {0}", transactions.XferUploaders.Count); - }*/ - } + + // XXX Weak ass way of doing this by directly manipulating this public dictionary, purely temporary + transactions.XferUploaders.Remove(uploader.TransactionID); + + //m_log.InfoFormat("[ASSET TRANSACTIONS] Current uploaders: {0}", transactions.XferUploaders.Count); + }*/ } } } + /// + /// Conduct an asset transfer from the client. + /// + /// + /// + /// + /// public void HandleXfer(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data) { AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); - if (transactions != null) - { - transactions.HandleXfer(xferID, packetID, data); - } + + transactions.HandleXfer(xferID, packetID, data); } } } -- cgit v1.1