diff --git a/OpenSim/Framework/Communications/Cache/AgentAssetTransactions.cs b/OpenSim/Framework/Communications/Cache/AgentAssetTransactions.cs index e74a06b6c7..92390b55df 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 c9c35d2573..48b25637ee 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); } } - } - - /// - /// Get the collection of asset transactions for the given user. - /// - /// - /// null if this agent does not have an asset transactions collection - public AgentAssetTransactions GetUserTransactions(LLUUID userID) - { - if (AgentTransactions.ContainsKey(userID)) - { - return AgentTransactions[userID]; - } - return null; + return AgentTransactions[userID]; + } + + /// + /// 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. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public void HandleItemCreationFromTransaction(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID, + uint callbackID, string description, string name, sbyte invType, + sbyte type, byte wearableType, uint nextOwnerMask) + { + m_log.InfoFormat( + "[TRANSACTIONS MANAGER] Called HandleItemCreationFromTransaction with item {0}", name); + + AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); + + 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); } } } diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs index 0dc3139628..6800d5f993 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs @@ -253,6 +253,7 @@ namespace OpenSim.Region.Environment.Scenes if (userInfo != null && userInfo.RootFolder != null) { InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); + if (item != null) { if (LLUUID.Zero == transactionID) @@ -265,34 +266,8 @@ namespace OpenSim.Region.Environment.Scenes } else { - AgentAssetTransactions transactions - = CommsManager.TransactionsManager.GetUserTransactions(remoteClient.AgentId); - - if (transactions != null) - { - LLUUID assetID = LLUUID.Combine(transactionID, remoteClient.SecureSessionId); - AssetBase asset - = AssetCache.GetAsset( - assetID, (item.assetType == (int) AssetType.Texture ? true : false)); - - if (asset == null) - { - asset = transactions.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; - - AssetCache.AddAsset(asset); - } - - userInfo.UpdateItem(remoteClient.AgentId, item); - } + CommsManager.TransactionsManager.HandleItemUpdateFromTransaction( + remoteClient, transactionID, item); } } else @@ -484,21 +459,9 @@ namespace OpenSim.Region.Environment.Scenes } else { - AgentAssetTransactions transactions - = CommsManager.TransactionsManager.GetUserTransactions(remoteClient.AgentId); - - if (transactions != null) - { - transactions.RequestCreateInventoryItem( - remoteClient, transactionID, folderID, callbackID, description, - name, invType, assetType, wearableType, nextOwnerMask); - } - else - { - m_log.ErrorFormat( - "Agent asset transactions for agent {0} uuid {1} in transaction uuid {2} unexpectedly null!", - remoteClient.Name, remoteClient.AgentId, transactionID); - } + CommsManager.TransactionsManager.HandleItemCreationFromTransaction( + remoteClient, transactionID, folderID, callbackID, description, + name, invType, assetType, wearableType, nextOwnerMask); } } diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index ba2a2cffda..62437cf54b 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -1311,7 +1311,6 @@ namespace OpenSim.Region.Environment.Scenes m_LandManager.sendParcelOverlay(client); CommsManager.UserProfileCacheService.AddNewUser(client.AgentId); - CommsManager.TransactionsManager.AddUser(client.AgentId); } protected virtual void SubscribeToClientEvents(IClientAPI client)