diff options
Diffstat (limited to 'OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AgentAssetsTransactions.cs')
-rw-r--r-- | OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AgentAssetsTransactions.cs | 52 |
1 files changed, 37 insertions, 15 deletions
diff --git a/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AgentAssetsTransactions.cs b/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AgentAssetsTransactions.cs index c46c4a4..b32d199 100644 --- a/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AgentAssetsTransactions.cs +++ b/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AgentAssetsTransactions.cs | |||
@@ -28,10 +28,13 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.IO; | 30 | using System.IO; |
31 | using System.Reflection; | ||
32 | using log4net; | ||
31 | using OpenMetaverse; | 33 | using OpenMetaverse; |
32 | using OpenMetaverse.Packets; | 34 | using OpenMetaverse.Packets; |
33 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
34 | using OpenSim.Framework.Communications.Cache; | 36 | using OpenSim.Framework.Communications.Cache; |
37 | using OpenSim.Region.Environment.Scenes; | ||
35 | 38 | ||
36 | namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction | 39 | namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction |
37 | { | 40 | { |
@@ -74,9 +77,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction | |||
74 | } | 77 | } |
75 | 78 | ||
76 | public void HandleXfer(ulong xferID, uint packetID, byte[] data) | 79 | public void HandleXfer(ulong xferID, uint packetID, byte[] data) |
77 | { | 80 | { |
78 | // AssetXferUploader uploaderFound = null; | ||
79 | |||
80 | lock (XferUploaders) | 81 | lock (XferUploaders) |
81 | { | 82 | { |
82 | foreach (AssetXferUploader uploader in XferUploaders.Values) | 83 | foreach (AssetXferUploader uploader in XferUploaders.Values) |
@@ -110,6 +111,15 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction | |||
110 | XferUploaders[transactionID].RequestUpdateInventoryItem(remoteClient, transactionID, item); | 111 | XferUploaders[transactionID].RequestUpdateInventoryItem(remoteClient, transactionID, item); |
111 | } | 112 | } |
112 | } | 113 | } |
114 | |||
115 | public void RequestUpdateTaskInventoryItem( | ||
116 | IClientAPI remoteClient, SceneObjectPart part, UUID transactionID, TaskInventoryItem item) | ||
117 | { | ||
118 | if (XferUploaders.ContainsKey(transactionID)) | ||
119 | { | ||
120 | XferUploaders[transactionID].RequestUpdateTaskInventoryItem(remoteClient, part, transactionID, item); | ||
121 | } | ||
122 | } | ||
113 | 123 | ||
114 | /// <summary> | 124 | /// <summary> |
115 | /// Get an uploaded asset. If the data is successfully retrieved, the transaction will be removed. | 125 | /// Get an uploaded asset. If the data is successfully retrieved, the transaction will be removed. |
@@ -140,6 +150,8 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction | |||
140 | 150 | ||
141 | public class AssetXferUploader | 151 | public class AssetXferUploader |
142 | { | 152 | { |
153 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
154 | |||
143 | // Fields | 155 | // Fields |
144 | public bool AddToInventory; | 156 | public bool AddToInventory; |
145 | public AssetBase Asset; | 157 | public AssetBase Asset; |
@@ -225,6 +237,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction | |||
225 | 237 | ||
226 | TransactionID = transaction; | 238 | TransactionID = transaction; |
227 | m_storeLocal = storeLocal; | 239 | m_storeLocal = storeLocal; |
240 | |||
228 | if (Asset.Data.Length > 2) | 241 | if (Asset.Data.Length > 2) |
229 | { | 242 | { |
230 | SendCompleteMessage(); | 243 | SendCompleteMessage(); |
@@ -251,7 +264,6 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction | |||
251 | 264 | ||
252 | ourClient.SendAssetUploadCompleteMessage(Asset.Type, true, Asset.FullID); | 265 | ourClient.SendAssetUploadCompleteMessage(Asset.Type, true, Asset.FullID); |
253 | 266 | ||
254 | |||
255 | m_finished = true; | 267 | m_finished = true; |
256 | if (m_createItem) | 268 | if (m_createItem) |
257 | { | 269 | { |
@@ -262,7 +274,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction | |||
262 | m_userTransactions.Manager.MyScene.CommsManager.AssetCache.AddAsset(Asset); | 274 | m_userTransactions.Manager.MyScene.CommsManager.AssetCache.AddAsset(Asset); |
263 | } | 275 | } |
264 | 276 | ||
265 | // Console.WriteLine("upload complete "+ this.TransactionID); | 277 | m_log.DebugFormat("[ASSET TRANSACTIONS]: Uploaded asset data for transaction {0}", TransactionID); |
266 | 278 | ||
267 | if (m_dumpAssetToFile) | 279 | if (m_dumpAssetToFile) |
268 | { | 280 | { |
@@ -274,15 +286,6 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction | |||
274 | } | 286 | } |
275 | } | 287 | } |
276 | 288 | ||
277 | ///Left this in and commented in case there are unforseen issues | ||
278 | //private void SaveAssetToFile(string filename, byte[] data) | ||
279 | //{ | ||
280 | // FileStream fs = File.Create(filename); | ||
281 | // BinaryWriter bw = new BinaryWriter(fs); | ||
282 | // bw.Write(data); | ||
283 | // bw.Close(); | ||
284 | // fs.Close(); | ||
285 | //} | ||
286 | private void SaveAssetToFile(string filename, byte[] data) | 289 | private void SaveAssetToFile(string filename, byte[] data) |
287 | { | 290 | { |
288 | string assetPath = "UserAssets"; | 291 | string assetPath = "UserAssets"; |
@@ -314,6 +317,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction | |||
314 | Asset.Description = description; | 317 | Asset.Description = description; |
315 | Asset.Type = type; | 318 | Asset.Type = type; |
316 | m_createItem = true; | 319 | m_createItem = true; |
320 | |||
317 | if (m_finished) | 321 | if (m_finished) |
318 | { | 322 | { |
319 | DoCreateItem(); | 323 | DoCreateItem(); |
@@ -359,7 +363,25 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction | |||
359 | } | 363 | } |
360 | } | 364 | } |
361 | } | 365 | } |
362 | 366 | ||
367 | public void RequestUpdateTaskInventoryItem( | ||
368 | IClientAPI remoteClient, SceneObjectPart part, UUID transactionID, TaskInventoryItem item) | ||
369 | { | ||
370 | m_log.DebugFormat( | ||
371 | "[ASSET TRANSACTIONS]: Updating task item {0} in {1} with asset in transaction {2}", | ||
372 | item.Name, part.Name, transactionID); | ||
373 | |||
374 | Asset.Name = item.Name; | ||
375 | Asset.Description = item.Description; | ||
376 | Asset.Type = (sbyte) item.Type; | ||
377 | item.AssetID = Asset.FullID; | ||
378 | |||
379 | m_userTransactions.Manager.MyScene.CommsManager.AssetCache.AddAsset(Asset); | ||
380 | |||
381 | if (part.UpdateInventoryItem(item)) | ||
382 | part.GetProperties(remoteClient); | ||
383 | } | ||
384 | |||
363 | private void DoCreateItem() | 385 | private void DoCreateItem() |
364 | { | 386 | { |
365 | //really need to fix this call, if lbsa71 saw this he would die. | 387 | //really need to fix this call, if lbsa71 saw this he would die. |