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.cs127
1 files changed, 66 insertions, 61 deletions
diff --git a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs
index f972368..51b80e5 100644
--- a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs
+++ b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs
@@ -113,66 +113,6 @@ namespace OpenSim.Framework.Communications.Cache
113 } 113 }
114 114
115 // Nested Types 115 // Nested Types
116 public class AssetCapsUploader
117 {
118 // Fields
119 private BaseHttpServer httpListener;
120 private LLUUID inventoryItemID;
121 private string m_assetDescription = "";
122 private string m_assetName = "";
123 private LLUUID m_folderID;
124 private LLUUID newAssetID;
125 private bool m_dumpImageToFile;
126 private string uploaderPath = "";
127
128 // Events
129 public event UpLoadedAsset OnUpLoad;
130
131 // Methods
132 public void Initialise(string assetName, string assetDescription, LLUUID assetID, LLUUID inventoryItem,
133 LLUUID folderID, string path, BaseHttpServer httpServer, bool dumpImageToFile)
134 {
135 m_assetName = assetName;
136 m_assetDescription = assetDescription;
137 m_folderID = folderID;
138 newAssetID = assetID;
139 inventoryItemID = inventoryItem;
140 uploaderPath = path;
141 httpListener = httpServer;
142 m_dumpImageToFile = dumpImageToFile;
143 }
144
145 private void SaveImageToFile(string filename, byte[] data)
146 {
147 FileStream output = File.Create(filename);
148 BinaryWriter writer = new BinaryWriter(output);
149 writer.Write(data);
150 writer.Close();
151 output.Close();
152 }
153
154 public string uploaderCaps(byte[] data, string path, string param)
155 {
156 LLUUID inventoryItemID = this.inventoryItemID;
157 string text = "";
158 LLSDAssetUploadComplete complete = new LLSDAssetUploadComplete();
159 complete.new_asset = newAssetID.ToStringHyphenated();
160 complete.new_inventory_item = inventoryItemID;
161 complete.state = "complete";
162 text = LLSDHelpers.SerialiseLLSDReply(complete);
163 httpListener.RemoveStreamHandler("POST", uploaderPath);
164 if (m_dumpImageToFile)
165 {
166 SaveImageToFile(m_assetName + ".jp2", data);
167 }
168 if (OnUpLoad != null)
169 {
170 OnUpLoad(m_assetName, "description", newAssetID, inventoryItemID, LLUUID.Zero, data, "", "");
171 }
172 return text;
173 }
174 }
175
176 public class AssetXferUploader 116 public class AssetXferUploader
177 { 117 {
178 // Fields 118 // Fields
@@ -230,7 +170,7 @@ namespace OpenSim.Framework.Communications.Cache
230 } 170 }
231 171
232 public void Initialise(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, byte[] data, 172 public void Initialise(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, byte[] data,
233 bool storeLocal) 173 bool storeLocal, bool tempFile)
234 { 174 {
235 ourClient = remoteClient; 175 ourClient = remoteClient;
236 Asset = new AssetBase(); 176 Asset = new AssetBase();
@@ -240,6 +180,9 @@ namespace OpenSim.Framework.Communications.Cache
240 Asset.Data = data; 180 Asset.Data = data;
241 Asset.Name = "blank"; 181 Asset.Name = "blank";
242 Asset.Description = "empty"; 182 Asset.Description = "empty";
183 Asset.Local = storeLocal;
184 Asset.Temporary = tempFile;
185
243 TransactionID = transaction; 186 TransactionID = transaction;
244 m_storeLocal = storeLocal; 187 m_storeLocal = storeLocal;
245 if (Asset.Data.Length > 2) 188 if (Asset.Data.Length > 2)
@@ -368,6 +311,67 @@ namespace OpenSim.Framework.Communications.Cache
368 } 311 }
369 } 312 }
370 313
314 #region Nested Classes currently not in use (waiting for them to be enabled)
315 public class AssetCapsUploader
316 {
317 // Fields
318 private BaseHttpServer httpListener;
319 private LLUUID inventoryItemID;
320 private string m_assetDescription = "";
321 private string m_assetName = "";
322 private LLUUID m_folderID;
323 private LLUUID newAssetID;
324 private bool m_dumpImageToFile;
325 private string uploaderPath = "";
326
327 // Events
328 public event UpLoadedAsset OnUpLoad;
329
330 // Methods
331 public void Initialise(string assetName, string assetDescription, LLUUID assetID, LLUUID inventoryItem,
332 LLUUID folderID, string path, BaseHttpServer httpServer, bool dumpImageToFile)
333 {
334 m_assetName = assetName;
335 m_assetDescription = assetDescription;
336 m_folderID = folderID;
337 newAssetID = assetID;
338 inventoryItemID = inventoryItem;
339 uploaderPath = path;
340 httpListener = httpServer;
341 m_dumpImageToFile = dumpImageToFile;
342 }
343
344 private void SaveImageToFile(string filename, byte[] data)
345 {
346 FileStream output = File.Create(filename);
347 BinaryWriter writer = new BinaryWriter(output);
348 writer.Write(data);
349 writer.Close();
350 output.Close();
351 }
352
353 public string uploaderCaps(byte[] data, string path, string param)
354 {
355 LLUUID inventoryItemID = this.inventoryItemID;
356 string text = "";
357 LLSDAssetUploadComplete complete = new LLSDAssetUploadComplete();
358 complete.new_asset = newAssetID.ToStringHyphenated();
359 complete.new_inventory_item = inventoryItemID;
360 complete.state = "complete";
361 text = LLSDHelpers.SerialiseLLSDReply(complete);
362 httpListener.RemoveStreamHandler("POST", uploaderPath);
363 if (m_dumpImageToFile)
364 {
365 SaveImageToFile(m_assetName + ".jp2", data);
366 }
367 if (OnUpLoad != null)
368 {
369 OnUpLoad(m_assetName, "description", newAssetID, inventoryItemID, LLUUID.Zero, data, "", "");
370 }
371 return text;
372 }
373 }
374
371 public class NoteCardCapsUpdate 375 public class NoteCardCapsUpdate
372 { 376 {
373 // Fields 377 // Fields
@@ -420,5 +424,6 @@ namespace OpenSim.Framework.Communications.Cache
420 return text; 424 return text;
421 } 425 }
422 } 426 }
427 #endregion
423 } 428 }
424} 429}