aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetXferUploader.cs86
1 files changed, 46 insertions, 40 deletions
diff --git a/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetXferUploader.cs b/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetXferUploader.cs
index 5edfe5d..9c0888a 100644
--- a/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetXferUploader.cs
+++ b/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetXferUploader.cs
@@ -37,13 +37,12 @@ using OpenSim.Region.Environment.Scenes;
37 37
38namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction 38namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
39{ 39{
40 public class AssetXferUploader 40 public class AssetXferUploader
41 { 41 {
42 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 42 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
43 43
44 public bool AddToInventory; 44 private AssetBase m_asset;
45 public AssetBase Asset; 45 private UUID InventFolder = UUID.Zero;
46 public UUID InventFolder = UUID.Zero;
47 private sbyte invType = 0; 46 private sbyte invType = 0;
48 private bool m_createItem = false; 47 private bool m_createItem = false;
49 private string m_description = String.Empty; 48 private string m_description = String.Empty;
@@ -54,9 +53,9 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
54 private AgentAssetTransactions m_userTransactions; 53 private AgentAssetTransactions m_userTransactions;
55 private uint nextPerm = 0; 54 private uint nextPerm = 0;
56 private IClientAPI ourClient; 55 private IClientAPI ourClient;
57 public UUID TransactionID = UUID.Zero; 56 private UUID TransactionID = UUID.Zero;
58 private sbyte type = 0; 57 private sbyte type = 0;
59 public bool UploadComplete; 58 private bool UploadComplete;
60 private byte wearableType = 0; 59 private byte wearableType = 0;
61 public ulong XferID; 60 public ulong XferID;
62 61
@@ -77,18 +76,18 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
77 { 76 {
78 if (XferID == xferID) 77 if (XferID == xferID)
79 { 78 {
80 if (Asset.Data.Length > 1) 79 if (m_asset.Data.Length > 1)
81 { 80 {
82 byte[] destinationArray = new byte[Asset.Data.Length + data.Length]; 81 byte[] destinationArray = new byte[m_asset.Data.Length + data.Length];
83 Array.Copy(Asset.Data, 0, destinationArray, 0, Asset.Data.Length); 82 Array.Copy(m_asset.Data, 0, destinationArray, 0, m_asset.Data.Length);
84 Array.Copy(data, 0, destinationArray, Asset.Data.Length, data.Length); 83 Array.Copy(data, 0, destinationArray, m_asset.Data.Length, data.Length);
85 Asset.Data = destinationArray; 84 m_asset.Data = destinationArray;
86 } 85 }
87 else 86 else
88 { 87 {
89 byte[] buffer2 = new byte[data.Length - 4]; 88 byte[] buffer2 = new byte[data.Length - 4];
90 Array.Copy(data, 4, buffer2, 0, data.Length - 4); 89 Array.Copy(data, 4, buffer2, 0, data.Length - 4);
91 Asset.Data = buffer2; 90 m_asset.Data = buffer2;
92 } 91 }
93 92
94 ourClient.SendConfirmXfer(xferID, packetID); 93 ourClient.SendConfirmXfer(xferID, packetID);
@@ -114,19 +113,19 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
114 bool storeLocal, bool tempFile) 113 bool storeLocal, bool tempFile)
115 { 114 {
116 ourClient = remoteClient; 115 ourClient = remoteClient;
117 Asset = new AssetBase(); 116 m_asset = new AssetBase();
118 Asset.FullID = assetID; 117 m_asset.FullID = assetID;
119 Asset.Type = type; 118 m_asset.Type = type;
120 Asset.Data = data; 119 m_asset.Data = data;
121 Asset.Name = "blank"; 120 m_asset.Name = "blank";
122 Asset.Description = "empty"; 121 m_asset.Description = "empty";
123 Asset.Local = storeLocal; 122 m_asset.Local = storeLocal;
124 Asset.Temporary = tempFile; 123 m_asset.Temporary = tempFile;
125 124
126 TransactionID = transaction; 125 TransactionID = transaction;
127 m_storeLocal = storeLocal; 126 m_storeLocal = storeLocal;
128 127
129 if (Asset.Data.Length > 2) 128 if (m_asset.Data.Length > 2)
130 { 129 {
131 SendCompleteMessage(); 130 SendCompleteMessage();
132 return true; 131 return true;
@@ -143,14 +142,14 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
143 { 142 {
144 UploadComplete = false; 143 UploadComplete = false;
145 XferID = Util.GetNextXferID(); 144 XferID = Util.GetNextXferID();
146 ourClient.SendXferRequest(XferID, Asset.Type, Asset.FullID, 0, new byte[0]); 145 ourClient.SendXferRequest(XferID, m_asset.Type, m_asset.FullID, 0, new byte[0]);
147 } 146 }
148 147
149 protected void SendCompleteMessage() 148 protected void SendCompleteMessage()
150 { 149 {
151 UploadComplete = true; 150 UploadComplete = true;
152 151
153 ourClient.SendAssetUploadCompleteMessage(Asset.Type, true, Asset.FullID); 152 ourClient.SendAssetUploadCompleteMessage(m_asset.Type, true, m_asset.FullID);
154 153
155 m_finished = true; 154 m_finished = true;
156 if (m_createItem) 155 if (m_createItem)
@@ -159,7 +158,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
159 } 158 }
160 else if (m_storeLocal) 159 else if (m_storeLocal)
161 { 160 {
162 m_userTransactions.Manager.MyScene.CommsManager.AssetCache.AddAsset(Asset); 161 m_userTransactions.Manager.MyScene.CommsManager.AssetCache.AddAsset(m_asset);
163 } 162 }
164 163
165 m_log.DebugFormat("[ASSET TRANSACTIONS]: Uploaded asset data for transaction {0}", TransactionID); 164 m_log.DebugFormat("[ASSET TRANSACTIONS]: Uploaded asset data for transaction {0}", TransactionID);
@@ -169,8 +168,8 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
169 DateTime now = DateTime.Now; 168 DateTime now = DateTime.Now;
170 string filename = 169 string filename =
171 String.Format("{6}_{7}_{0:d2}{1:d2}{2:d2}_{3:d2}{4:d2}{5:d2}.dat", now.Year, now.Month, now.Day, 170 String.Format("{6}_{7}_{0:d2}{1:d2}{2:d2}_{3:d2}{4:d2}{5:d2}.dat", now.Year, now.Month, now.Day,
172 now.Hour, now.Minute, now.Second, Asset.Name, Asset.Type); 171 now.Hour, now.Minute, now.Second, m_asset.Name, m_asset.Type);
173 SaveAssetToFile(filename, Asset.Data); 172 SaveAssetToFile(filename, m_asset.Data);
174 } 173 }
175 } 174 }
176 175
@@ -201,9 +200,9 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
201 this.invType = invType; 200 this.invType = invType;
202 this.wearableType = wearableType; 201 this.wearableType = wearableType;
203 nextPerm = nextOwnerMask; 202 nextPerm = nextOwnerMask;
204 Asset.Name = name; 203 m_asset.Name = name;
205 Asset.Description = description; 204 m_asset.Description = description;
206 Asset.Type = type; 205 m_asset.Type = type;
207 m_createItem = true; 206 m_createItem = true;
208 207
209 if (m_finished) 208 if (m_finished)
@@ -244,7 +243,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
244 asset.Type = (sbyte) item.AssetType; 243 asset.Type = (sbyte) item.AssetType;
245 item.AssetID = asset.FullID; 244 item.AssetID = asset.FullID;
246 245
247 m_userTransactions.Manager.MyScene.CommsManager.AssetCache.AddAsset(Asset); 246 m_userTransactions.Manager.MyScene.CommsManager.AssetCache.AddAsset(m_asset);
248 } 247 }
249 248
250 userInfo.UpdateItem(item); 249 userInfo.UpdateItem(item);
@@ -259,12 +258,12 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
259 "[ASSET TRANSACTIONS]: Updating task item {0} in {1} with asset in transaction {2}", 258 "[ASSET TRANSACTIONS]: Updating task item {0} in {1} with asset in transaction {2}",
260 item.Name, part.Name, transactionID); 259 item.Name, part.Name, transactionID);
261 260
262 Asset.Name = item.Name; 261 m_asset.Name = item.Name;
263 Asset.Description = item.Description; 262 m_asset.Description = item.Description;
264 Asset.Type = (sbyte) item.Type; 263 m_asset.Type = (sbyte) item.Type;
265 item.AssetID = Asset.FullID; 264 item.AssetID = m_asset.FullID;
266 265
267 m_userTransactions.Manager.MyScene.CommsManager.AssetCache.AddAsset(Asset); 266 m_userTransactions.Manager.MyScene.CommsManager.AssetCache.AddAsset(m_asset);
268 267
269 if (part.UpdateInventoryItem(item)) 268 if (part.UpdateInventoryItem(item))
270 part.GetProperties(remoteClient); 269 part.GetProperties(remoteClient);
@@ -273,16 +272,18 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
273 private void DoCreateItem() 272 private void DoCreateItem()
274 { 273 {
275 //really need to fix this call, if lbsa71 saw this he would die. 274 //really need to fix this call, if lbsa71 saw this he would die.
276 m_userTransactions.Manager.MyScene.CommsManager.AssetCache.AddAsset(Asset); 275 m_userTransactions.Manager.MyScene.CommsManager.AssetCache.AddAsset(m_asset);
277 CachedUserInfo userInfo = 276 CachedUserInfo userInfo =
278 m_userTransactions.Manager.MyScene.CommsManager.UserProfileCacheService.GetUserDetails(ourClient.AgentId); 277 m_userTransactions.Manager.MyScene.CommsManager.UserProfileCacheService.GetUserDetails(
278 ourClient.AgentId);
279
279 if (userInfo != null) 280 if (userInfo != null)
280 { 281 {
281 InventoryItemBase item = new InventoryItemBase(); 282 InventoryItemBase item = new InventoryItemBase();
282 item.Owner = ourClient.AgentId; 283 item.Owner = ourClient.AgentId;
283 item.Creator = ourClient.AgentId; 284 item.Creator = ourClient.AgentId;
284 item.ID = UUID.Random(); 285 item.ID = UUID.Random();
285 item.AssetID = Asset.FullID; 286 item.AssetID = m_asset.FullID;
286 item.Description = m_description; 287 item.Description = m_description;
287 item.Name = m_name; 288 item.Name = m_name;
288 item.AssetType = type; 289 item.AssetType = type;
@@ -299,12 +300,17 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
299 } 300 }
300 } 301 }
301 302
303 /// <summary>
304 /// Get the asset data uploaded in this transfer.
305 /// </summary>
306 /// <returns>null if the asset has not finished uploading</returns>
302 public AssetBase GetAssetData() 307 public AssetBase GetAssetData()
303 { 308 {
304 if (m_finished) 309 if (m_finished)
305 { 310 {
306 return Asset; 311 return m_asset;
307 } 312 }
313
308 return null; 314 return null;
309 } 315 }
310 } 316 }