aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Communications/Cache/AssetTransactions.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/Communications/Cache/AssetTransactions.cs')
-rw-r--r--OpenSim/Framework/Communications/Cache/AssetTransactions.cs28
1 files changed, 19 insertions, 9 deletions
diff --git a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs
index 51fc462..581e300 100644
--- a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs
+++ b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs
@@ -39,7 +39,7 @@ using OpenSim.Framework.Utilities;
39using OpenSim.Region.Capabilities; 39using OpenSim.Region.Capabilities;
40using OpenSim.Framework.Servers; 40using OpenSim.Framework.Servers;
41 41
42namespace OpenSim.Framework.Communications.Caches 42namespace OpenSim.Framework.Communications.Cache
43{ 43{
44 public class AgentAssetTransactions 44 public class AgentAssetTransactions
45 { 45 {
@@ -49,12 +49,14 @@ namespace OpenSim.Framework.Communications.Caches
49 public LLUUID UserID; 49 public LLUUID UserID;
50 public Dictionary<LLUUID, AssetXferUploader> XferUploaders = new Dictionary<LLUUID, AssetXferUploader>(); 50 public Dictionary<LLUUID, AssetXferUploader> XferUploaders = new Dictionary<LLUUID, AssetXferUploader>();
51 public AssetTransactionManager Manager; 51 public AssetTransactionManager Manager;
52 private bool m_dumpAssetsToFile;
52 53
53 // Methods 54 // Methods
54 public AgentAssetTransactions(LLUUID agentID, AssetTransactionManager manager) 55 public AgentAssetTransactions(LLUUID agentID, AssetTransactionManager manager, bool dumpAssetsToFile)
55 { 56 {
56 this.UserID = agentID; 57 this.UserID = agentID;
57 Manager = manager; 58 Manager = manager;
59 m_dumpAssetsToFile = dumpAssetsToFile;
58 } 60 }
59 61
60 public AssetCapsUploader RequestCapsUploader() 62 public AssetCapsUploader RequestCapsUploader()
@@ -75,7 +77,7 @@ namespace OpenSim.Framework.Communications.Caches
75 { 77 {
76 if (!this.XferUploaders.ContainsKey(transactionID)) 78 if (!this.XferUploaders.ContainsKey(transactionID))
77 { 79 {
78 AssetXferUploader uploader = new AssetXferUploader(this); 80 AssetXferUploader uploader = new AssetXferUploader(this, m_dumpAssetsToFile);
79 81
80 this.XferUploaders.Add(transactionID, uploader); 82 this.XferUploaders.Add(transactionID, uploader);
81 return uploader; 83 return uploader;
@@ -122,14 +124,14 @@ namespace OpenSim.Framework.Communications.Caches
122 private string m_assetName = ""; 124 private string m_assetName = "";
123 private LLUUID m_folderID; 125 private LLUUID m_folderID;
124 private LLUUID newAssetID; 126 private LLUUID newAssetID;
125 private bool SaveImages = false; 127 private bool m_dumpImageToFile;
126 private string uploaderPath = ""; 128 private string uploaderPath = "";
127 129
128 // Events 130 // Events
129 public event UpLoadedAsset OnUpLoad; 131 public event UpLoadedAsset OnUpLoad;
130 132
131 // Methods 133 // Methods
132 public void Initialise(string assetName, string assetDescription, LLUUID assetID, LLUUID inventoryItem, LLUUID folderID, string path, BaseHttpServer httpServer) 134 public void Initialise(string assetName, string assetDescription, LLUUID assetID, LLUUID inventoryItem, LLUUID folderID, string path, BaseHttpServer httpServer, bool dumpImageToFile)
133 { 135 {
134 this.m_assetName = assetName; 136 this.m_assetName = assetName;
135 this.m_assetDescription = assetDescription; 137 this.m_assetDescription = assetDescription;
@@ -138,6 +140,7 @@ namespace OpenSim.Framework.Communications.Caches
138 this.inventoryItemID = inventoryItem; 140 this.inventoryItemID = inventoryItem;
139 this.uploaderPath = path; 141 this.uploaderPath = path;
140 this.httpListener = httpServer; 142 this.httpListener = httpServer;
143 m_dumpImageToFile = dumpImageToFile;
141 } 144 }
142 145
143 private void SaveImageToFile(string filename, byte[] data) 146 private void SaveImageToFile(string filename, byte[] data)
@@ -159,7 +162,7 @@ namespace OpenSim.Framework.Communications.Caches
159 complete.state = "complete"; 162 complete.state = "complete";
160 text = LLSDHelpers.SerialiseLLSDReply(complete); 163 text = LLSDHelpers.SerialiseLLSDReply(complete);
161 this.httpListener.RemoveStreamHandler("POST", this.uploaderPath); 164 this.httpListener.RemoveStreamHandler("POST", this.uploaderPath);
162 if (this.SaveImages) 165 if (this.m_dumpImageToFile)
163 { 166 {
164 this.SaveImageToFile(this.m_assetName + ".jp2", data); 167 this.SaveImageToFile(this.m_assetName + ".jp2", data);
165 } 168 }
@@ -190,10 +193,12 @@ namespace OpenSim.Framework.Communications.Caches
190 private bool m_createItem = false; 193 private bool m_createItem = false;
191 private AgentAssetTransactions m_userTransactions; 194 private AgentAssetTransactions m_userTransactions;
192 private bool m_storeLocal; 195 private bool m_storeLocal;
196 private bool m_dumpAssetToFile;
193 197
194 public AssetXferUploader(AgentAssetTransactions transactions) 198 public AssetXferUploader(AgentAssetTransactions transactions, bool dumpAssetToFile)
195 { 199 {
196 this.m_userTransactions = transactions; 200 this.m_userTransactions = transactions;
201 m_dumpAssetToFile = dumpAssetToFile;
197 } 202 }
198 203
199 // Methods 204 // Methods
@@ -278,9 +283,14 @@ namespace OpenSim.Framework.Communications.Caches
278 this.m_userTransactions.Manager.CommsManager.AssetCache.AddAsset(this.Asset); 283 this.m_userTransactions.Manager.CommsManager.AssetCache.AddAsset(this.Asset);
279 } 284 }
280 285
281 // Console.WriteLine("upload complete "+ this.TransactionID); 286 // Console.WriteLine("upload complete "+ this.TransactionID);
282 //SaveAssetToFile("testudpupload" + Util.RandomClass.Next(1, 1000) + ".dat", this.Asset.Data); 287
288 if (m_dumpAssetToFile)
289 {
290 SaveAssetToFile("testudpupload" + Util.RandomClass.Next(1, 1000) + ".dat", this.Asset.Data);
291 }
283 } 292 }
293
284 private void SaveAssetToFile(string filename, byte[] data) 294 private void SaveAssetToFile(string filename, byte[] data)
285 { 295 {
286 FileStream fs = File.Create(filename); 296 FileStream fs = File.Create(filename);