aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Communications/Cache/AssetTransactions.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Communications/Cache/AssetTransactions.cs199
1 files changed, 102 insertions, 97 deletions
diff --git a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs
index e78f4f7..6b08fc9 100644
--- a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs
+++ b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs
@@ -26,17 +26,12 @@
26* 26*
27*/ 27*/
28using System; 28using System;
29using System.Collections;
30using System.Collections.Generic; 29using System.Collections.Generic;
31using System.Text;
32using System.IO; 30using System.IO;
33using libsecondlife; 31using libsecondlife;
34using libsecondlife.Packets; 32using libsecondlife.Packets;
35using OpenSim.Framework.Communications.Cache;
36using OpenSim.Framework.Interfaces;
37using OpenSim.Framework;
38using OpenSim.Region.Capabilities;
39using OpenSim.Framework.Servers; 33using OpenSim.Framework.Servers;
34using OpenSim.Region.Capabilities;
40 35
41namespace OpenSim.Framework.Communications.Cache 36namespace OpenSim.Framework.Communications.Cache
42{ 37{
@@ -53,7 +48,7 @@ namespace OpenSim.Framework.Communications.Cache
53 // Methods 48 // Methods
54 public AgentAssetTransactions(LLUUID agentID, AssetTransactionManager manager, bool dumpAssetsToFile) 49 public AgentAssetTransactions(LLUUID agentID, AssetTransactionManager manager, bool dumpAssetsToFile)
55 { 50 {
56 this.UserID = agentID; 51 UserID = agentID;
57 Manager = manager; 52 Manager = manager;
58 m_dumpAssetsToFile = dumpAssetsToFile; 53 m_dumpAssetsToFile = dumpAssetsToFile;
59 } 54 }
@@ -61,24 +56,24 @@ namespace OpenSim.Framework.Communications.Cache
61 public AssetCapsUploader RequestCapsUploader() 56 public AssetCapsUploader RequestCapsUploader()
62 { 57 {
63 AssetCapsUploader uploader = new AssetCapsUploader(); 58 AssetCapsUploader uploader = new AssetCapsUploader();
64 this.CapsUploaders.Add(uploader); 59 CapsUploaders.Add(uploader);
65 return uploader; 60 return uploader;
66 } 61 }
67 62
68 public NoteCardCapsUpdate RequestNoteCardUpdater() 63 public NoteCardCapsUpdate RequestNoteCardUpdater()
69 { 64 {
70 NoteCardCapsUpdate update = new NoteCardCapsUpdate(); 65 NoteCardCapsUpdate update = new NoteCardCapsUpdate();
71 this.NotecardUpdaters.Add(update); 66 NotecardUpdaters.Add(update);
72 return update; 67 return update;
73 } 68 }
74 69
75 public AssetXferUploader RequestXferUploader(LLUUID transactionID) 70 public AssetXferUploader RequestXferUploader(LLUUID transactionID)
76 { 71 {
77 if (!this.XferUploaders.ContainsKey(transactionID)) 72 if (!XferUploaders.ContainsKey(transactionID))
78 { 73 {
79 AssetXferUploader uploader = new AssetXferUploader(this, m_dumpAssetsToFile); 74 AssetXferUploader uploader = new AssetXferUploader(this, m_dumpAssetsToFile);
80 75
81 this.XferUploaders.Add(transactionID, uploader); 76 XferUploaders.Add(transactionID, uploader);
82 return uploader; 77 return uploader;
83 } 78 }
84 return null; 79 return null;
@@ -86,7 +81,7 @@ namespace OpenSim.Framework.Communications.Cache
86 81
87 public void HandleXfer(ulong xferID, uint packetID, byte[] data) 82 public void HandleXfer(ulong xferID, uint packetID, byte[] data)
88 { 83 {
89 foreach (AssetXferUploader uploader in this.XferUploaders.Values) 84 foreach (AssetXferUploader uploader in XferUploaders.Values)
90 { 85 {
91 if (uploader.XferID == xferID) 86 if (uploader.XferID == xferID)
92 { 87 {
@@ -96,17 +91,21 @@ namespace OpenSim.Framework.Communications.Cache
96 } 91 }
97 } 92 }
98 93
99 public void RequestCreateInventoryItem(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID, uint callbackID, string description, string name, sbyte invType, sbyte type, byte wearableType, uint nextOwnerMask) 94 public void RequestCreateInventoryItem(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID,
95 uint callbackID, string description, string name, sbyte invType,
96 sbyte type, byte wearableType, uint nextOwnerMask)
100 { 97 {
101 if (this.XferUploaders.ContainsKey(transactionID)) 98 if (XferUploaders.ContainsKey(transactionID))
102 { 99 {
103 this.XferUploaders[transactionID].RequestCreateInventoryItem(remoteClient, transactionID, folderID, callbackID, description, name, invType, type, wearableType, nextOwnerMask); 100 XferUploaders[transactionID].RequestCreateInventoryItem(remoteClient, transactionID, folderID,
101 callbackID, description, name, invType, type,
102 wearableType, nextOwnerMask);
104 } 103 }
105 } 104 }
106 105
107 public AssetBase GetTransactionAsset(LLUUID transactionID) 106 public AssetBase GetTransactionAsset(LLUUID transactionID)
108 { 107 {
109 if (this.XferUploaders.ContainsKey(transactionID)) 108 if (XferUploaders.ContainsKey(transactionID))
110 { 109 {
111 return XferUploaders[transactionID].GetAssetData(); 110 return XferUploaders[transactionID].GetAssetData();
112 } 111 }
@@ -130,15 +129,16 @@ namespace OpenSim.Framework.Communications.Cache
130 public event UpLoadedAsset OnUpLoad; 129 public event UpLoadedAsset OnUpLoad;
131 130
132 // Methods 131 // Methods
133 public void Initialise(string assetName, string assetDescription, LLUUID assetID, LLUUID inventoryItem, LLUUID folderID, string path, BaseHttpServer httpServer, bool dumpImageToFile) 132 public void Initialise(string assetName, string assetDescription, LLUUID assetID, LLUUID inventoryItem,
133 LLUUID folderID, string path, BaseHttpServer httpServer, bool dumpImageToFile)
134 { 134 {
135 this.m_assetName = assetName; 135 m_assetName = assetName;
136 this.m_assetDescription = assetDescription; 136 m_assetDescription = assetDescription;
137 this.m_folderID = folderID; 137 m_folderID = folderID;
138 this.newAssetID = assetID; 138 newAssetID = assetID;
139 this.inventoryItemID = inventoryItem; 139 inventoryItemID = inventoryItem;
140 this.uploaderPath = path; 140 uploaderPath = path;
141 this.httpListener = httpServer; 141 httpListener = httpServer;
142 m_dumpImageToFile = dumpImageToFile; 142 m_dumpImageToFile = dumpImageToFile;
143 } 143 }
144 144
@@ -156,18 +156,18 @@ namespace OpenSim.Framework.Communications.Cache
156 LLUUID inventoryItemID = this.inventoryItemID; 156 LLUUID inventoryItemID = this.inventoryItemID;
157 string text = ""; 157 string text = "";
158 LLSDAssetUploadComplete complete = new LLSDAssetUploadComplete(); 158 LLSDAssetUploadComplete complete = new LLSDAssetUploadComplete();
159 complete.new_asset = this.newAssetID.ToStringHyphenated(); 159 complete.new_asset = newAssetID.ToStringHyphenated();
160 complete.new_inventory_item = inventoryItemID; 160 complete.new_inventory_item = inventoryItemID;
161 complete.state = "complete"; 161 complete.state = "complete";
162 text = LLSDHelpers.SerialiseLLSDReply(complete); 162 text = LLSDHelpers.SerialiseLLSDReply(complete);
163 this.httpListener.RemoveStreamHandler("POST", this.uploaderPath); 163 httpListener.RemoveStreamHandler("POST", uploaderPath);
164 if (this.m_dumpImageToFile) 164 if (m_dumpImageToFile)
165 { 165 {
166 this.SaveImageToFile(this.m_assetName + ".jp2", data); 166 SaveImageToFile(m_assetName + ".jp2", data);
167 } 167 }
168 if (this.OnUpLoad != null) 168 if (OnUpLoad != null)
169 { 169 {
170 this.OnUpLoad(this.m_assetName, "description", this.newAssetID, inventoryItemID, LLUUID.Zero, data, "" , ""); 170 OnUpLoad(m_assetName, "description", newAssetID, inventoryItemID, LLUUID.Zero, data, "", "");
171 } 171 }
172 return text; 172 return text;
173 } 173 }
@@ -196,90 +196,91 @@ namespace OpenSim.Framework.Communications.Cache
196 196
197 public AssetXferUploader(AgentAssetTransactions transactions, bool dumpAssetToFile) 197 public AssetXferUploader(AgentAssetTransactions transactions, bool dumpAssetToFile)
198 { 198 {
199 this.m_userTransactions = transactions; 199 m_userTransactions = transactions;
200 m_dumpAssetToFile = dumpAssetToFile; 200 m_dumpAssetToFile = dumpAssetToFile;
201 } 201 }
202 202
203 // Methods 203 // Methods
204 public void HandleXferPacket(ulong xferID, uint packetID, byte[] data) 204 public void HandleXferPacket(ulong xferID, uint packetID, byte[] data)
205 { 205 {
206 if (this.XferID == xferID) 206 if (XferID == xferID)
207 { 207 {
208 if (this.Asset.Data.Length > 1) 208 if (Asset.Data.Length > 1)
209 { 209 {
210 byte[] destinationArray = new byte[this.Asset.Data.Length + data.Length]; 210 byte[] destinationArray = new byte[Asset.Data.Length + data.Length];
211 Array.Copy(this.Asset.Data, 0, destinationArray, 0, this.Asset.Data.Length); 211 Array.Copy(Asset.Data, 0, destinationArray, 0, Asset.Data.Length);
212 Array.Copy(data, 0, destinationArray, this.Asset.Data.Length, data.Length); 212 Array.Copy(data, 0, destinationArray, Asset.Data.Length, data.Length);
213 this.Asset.Data = destinationArray; 213 Asset.Data = destinationArray;
214 } 214 }
215 else 215 else
216 { 216 {
217 byte[] buffer2 = new byte[data.Length - 4]; 217 byte[] buffer2 = new byte[data.Length - 4];
218 Array.Copy(data, 4, buffer2, 0, data.Length - 4); 218 Array.Copy(data, 4, buffer2, 0, data.Length - 4);
219 this.Asset.Data = buffer2; 219 Asset.Data = buffer2;
220 } 220 }
221 ConfirmXferPacketPacket newPack = new ConfirmXferPacketPacket(); 221 ConfirmXferPacketPacket newPack = new ConfirmXferPacketPacket();
222 newPack.XferID.ID = xferID; 222 newPack.XferID.ID = xferID;
223 newPack.XferID.Packet = packetID; 223 newPack.XferID.Packet = packetID;
224 this.ourClient.OutPacket(newPack); 224 ourClient.OutPacket(newPack);
225 if ((packetID & 0x80000000) != 0) 225 if ((packetID & 0x80000000) != 0)
226 { 226 {
227 this.SendCompleteMessage(); 227 SendCompleteMessage();
228 } 228 }
229 } 229 }
230 } 230 }
231 231
232 public void Initialise(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, byte[] data, bool storeLocal) 232 public void Initialise(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, byte[] data,
233 bool storeLocal)
233 { 234 {
234 this.ourClient = remoteClient; 235 ourClient = remoteClient;
235 this.Asset = new AssetBase(); 236 Asset = new AssetBase();
236 this.Asset.FullID = assetID; 237 Asset.FullID = assetID;
237 this.Asset.InvType = type; 238 Asset.InvType = type;
238 this.Asset.Type = type; 239 Asset.Type = type;
239 this.Asset.Data = data; 240 Asset.Data = data;
240 this.Asset.Name = "blank"; 241 Asset.Name = "blank";
241 this.Asset.Description = "empty"; 242 Asset.Description = "empty";
242 this.TransactionID = transaction; 243 TransactionID = transaction;
243 this.m_storeLocal = storeLocal; 244 m_storeLocal = storeLocal;
244 if (this.Asset.Data.Length > 2) 245 if (Asset.Data.Length > 2)
245 { 246 {
246 this.SendCompleteMessage(); 247 SendCompleteMessage();
247 } 248 }
248 else 249 else
249 { 250 {
250 this.ReqestStartXfer(); 251 ReqestStartXfer();
251 } 252 }
252 } 253 }
253 254
254 protected void ReqestStartXfer() 255 protected void ReqestStartXfer()
255 { 256 {
256 this.UploadComplete = false; 257 UploadComplete = false;
257 this.XferID = Util.GetNextXferID(); 258 XferID = Util.GetNextXferID();
258 RequestXferPacket newPack = new RequestXferPacket(); 259 RequestXferPacket newPack = new RequestXferPacket();
259 newPack.XferID.ID = this.XferID; 260 newPack.XferID.ID = XferID;
260 newPack.XferID.VFileType = this.Asset.Type; 261 newPack.XferID.VFileType = Asset.Type;
261 newPack.XferID.VFileID = this.Asset.FullID; 262 newPack.XferID.VFileID = Asset.FullID;
262 newPack.XferID.FilePath = 0; 263 newPack.XferID.FilePath = 0;
263 newPack.XferID.Filename = new byte[0]; 264 newPack.XferID.Filename = new byte[0];
264 this.ourClient.OutPacket(newPack); 265 ourClient.OutPacket(newPack);
265 } 266 }
266 267
267 protected void SendCompleteMessage() 268 protected void SendCompleteMessage()
268 { 269 {
269 this.UploadComplete = true; 270 UploadComplete = true;
270 AssetUploadCompletePacket newPack = new AssetUploadCompletePacket(); 271 AssetUploadCompletePacket newPack = new AssetUploadCompletePacket();
271 newPack.AssetBlock.Type = this.Asset.Type; 272 newPack.AssetBlock.Type = Asset.Type;
272 newPack.AssetBlock.Success = true; 273 newPack.AssetBlock.Success = true;
273 newPack.AssetBlock.UUID = this.Asset.FullID; 274 newPack.AssetBlock.UUID = Asset.FullID;
274 this.ourClient.OutPacket(newPack); 275 ourClient.OutPacket(newPack);
275 this.m_finished = true; 276 m_finished = true;
276 if (m_createItem) 277 if (m_createItem)
277 { 278 {
278 DoCreateItem(); 279 DoCreateItem();
279 } 280 }
280 else if (m_storeLocal) 281 else if (m_storeLocal)
281 { 282 {
282 this.m_userTransactions.Manager.CommsManager.AssetCache.AddAsset(this.Asset); 283 m_userTransactions.Manager.CommsManager.AssetCache.AddAsset(Asset);
283 } 284 }
284 285
285 // Console.WriteLine("upload complete "+ this.TransactionID); 286 // Console.WriteLine("upload complete "+ this.TransactionID);
@@ -287,8 +288,10 @@ namespace OpenSim.Framework.Communications.Cache
287 if (m_dumpAssetToFile) 288 if (m_dumpAssetToFile)
288 { 289 {
289 DateTime now = DateTime.Now; 290 DateTime now = DateTime.Now;
290 string filename = String.Format("{6}_{7}_{0:d2}{1:d2}{2:d2}_{3:d2}{4:d2}{5:d2}", now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second, Asset.Name, Asset.Type ); 291 string filename =
291 SaveAssetToFile(filename, this.Asset.Data); 292 String.Format("{6}_{7}_{0:d2}{1:d2}{2:d2}_{3:d2}{4:d2}{5:d2}", now.Year, now.Month, now.Day,
293 now.Hour, now.Minute, now.Second, Asset.Name, Asset.Type);
294 SaveAssetToFile(filename, Asset.Data);
292 } 295 }
293 } 296 }
294 297
@@ -301,20 +304,22 @@ namespace OpenSim.Framework.Communications.Cache
301 fs.Close(); 304 fs.Close();
302 } 305 }
303 306
304 public void RequestCreateInventoryItem(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID, uint callbackID, string description, string name, sbyte invType, sbyte type, byte wearableType, uint nextOwnerMask) 307 public void RequestCreateInventoryItem(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID,
308 uint callbackID, string description, string name, sbyte invType,
309 sbyte type, byte wearableType, uint nextOwnerMask)
305 { 310 {
306 if (this.TransactionID == transactionID) 311 if (TransactionID == transactionID)
307 { 312 {
308 this.InventFolder = folderID; 313 InventFolder = folderID;
309 this.m_name = name; 314 m_name = name;
310 this.m_description = description; 315 m_description = description;
311 this.type = type; 316 this.type = type;
312 this.invType = invType; 317 this.invType = invType;
313 this.nextPerm = nextOwnerMask; 318 nextPerm = nextOwnerMask;
314 this.Asset.Name = name; 319 Asset.Name = name;
315 this.Asset.Description = description; 320 Asset.Description = description;
316 this.Asset.Type = type; 321 Asset.Type = type;
317 this.Asset.InvType = invType; 322 Asset.InvType = invType;
318 m_createItem = true; 323 m_createItem = true;
319 if (m_finished) 324 if (m_finished)
320 { 325 {
@@ -326,22 +331,23 @@ namespace OpenSim.Framework.Communications.Cache
326 private void DoCreateItem() 331 private void DoCreateItem()
327 { 332 {
328 //really need to fix this call, if lbsa71 saw this he would die. 333 //really need to fix this call, if lbsa71 saw this he would die.
329 this.m_userTransactions.Manager.CommsManager.AssetCache.AddAsset(this.Asset); 334 m_userTransactions.Manager.CommsManager.AssetCache.AddAsset(Asset);
330 CachedUserInfo userInfo = m_userTransactions.Manager.CommsManager.UserProfileCache.GetUserDetails(ourClient.AgentId); 335 CachedUserInfo userInfo =
336 m_userTransactions.Manager.CommsManager.UserProfileCache.GetUserDetails(ourClient.AgentId);
331 if (userInfo != null) 337 if (userInfo != null)
332 { 338 {
333 InventoryItemBase item = new InventoryItemBase(); 339 InventoryItemBase item = new InventoryItemBase();
334 item.avatarID = this.ourClient.AgentId; 340 item.avatarID = ourClient.AgentId;
335 item.creatorsID = ourClient.AgentId; 341 item.creatorsID = ourClient.AgentId;
336 item.inventoryID = LLUUID.Random(); 342 item.inventoryID = LLUUID.Random();
337 item.assetID = Asset.FullID; 343 item.assetID = Asset.FullID;
338 item.inventoryDescription = this.m_description; 344 item.inventoryDescription = m_description;
339 item.inventoryName = m_name; 345 item.inventoryName = m_name;
340 item.assetType = type; 346 item.assetType = type;
341 item.invType = this.invType; 347 item.invType = invType;
342 item.parentFolderID = this.InventFolder; 348 item.parentFolderID = InventFolder;
343 item.inventoryCurrentPermissions = 2147483647; 349 item.inventoryCurrentPermissions = 2147483647;
344 item.inventoryNextPermissions = this.nextPerm; 350 item.inventoryNextPermissions = nextPerm;
345 351
346 userInfo.AddItem(ourClient.AgentId, item); 352 userInfo.AddItem(ourClient.AgentId, item);
347 ourClient.SendInventoryItemUpdate(item); 353 ourClient.SendInventoryItemUpdate(item);
@@ -350,14 +356,13 @@ namespace OpenSim.Framework.Communications.Cache
350 356
351 public void UpdateInventoryItem(LLUUID itemID) 357 public void UpdateInventoryItem(LLUUID itemID)
352 { 358 {
353
354 } 359 }
355 360
356 public AssetBase GetAssetData() 361 public AssetBase GetAssetData()
357 { 362 {
358 if (m_finished) 363 if (m_finished)
359 { 364 {
360 return this.Asset; 365 return Asset;
361 } 366 }
362 return null; 367 return null;
363 } 368 }
@@ -379,10 +384,10 @@ namespace OpenSim.Framework.Communications.Cache
379 // Methods 384 // Methods
380 public void Initialise(LLUUID inventoryItem, string path, BaseHttpServer httpServer) 385 public void Initialise(LLUUID inventoryItem, string path, BaseHttpServer httpServer)
381 { 386 {
382 this.inventoryItemID = inventoryItem; 387 inventoryItemID = inventoryItem;
383 this.uploaderPath = path; 388 uploaderPath = path;
384 this.httpListener = httpServer; 389 httpListener = httpServer;
385 this.newAssetID = LLUUID.Random(); 390 newAssetID = LLUUID.Random();
386 } 391 }
387 392
388 private void SaveImageToFile(string filename, byte[] data) 393 private void SaveImageToFile(string filename, byte[] data)
@@ -399,18 +404,18 @@ namespace OpenSim.Framework.Communications.Cache
399 LLUUID inventoryItemID = this.inventoryItemID; 404 LLUUID inventoryItemID = this.inventoryItemID;
400 string text = ""; 405 string text = "";
401 LLSDAssetUploadComplete complete = new LLSDAssetUploadComplete(); 406 LLSDAssetUploadComplete complete = new LLSDAssetUploadComplete();
402 complete.new_asset = this.newAssetID.ToStringHyphenated(); 407 complete.new_asset = newAssetID.ToStringHyphenated();
403 complete.new_inventory_item = inventoryItemID; 408 complete.new_inventory_item = inventoryItemID;
404 complete.state = "complete"; 409 complete.state = "complete";
405 text = LLSDHelpers.SerialiseLLSDReply(complete); 410 text = LLSDHelpers.SerialiseLLSDReply(complete);
406 this.httpListener.RemoveStreamHandler("POST", this.uploaderPath); 411 httpListener.RemoveStreamHandler("POST", uploaderPath);
407 if (this.SaveImages) 412 if (SaveImages)
408 { 413 {
409 this.SaveImageToFile(this.m_assetName + "notecard.txt", data); 414 SaveImageToFile(m_assetName + "notecard.txt", data);
410 } 415 }
411 if (this.OnUpLoad != null) 416 if (OnUpLoad != null)
412 { 417 {
413 this.OnUpLoad(this.m_assetName, "description", this.newAssetID, inventoryItemID, LLUUID.Zero, data, "" , "" ); 418 OnUpLoad(m_assetName, "description", newAssetID, inventoryItemID, LLUUID.Zero, data, "", "");
414 } 419 }
415 return text; 420 return text;
416 } 421 }