aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Communications
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/Communications')
-rw-r--r--OpenSim/Framework/Communications/Cache/AssetTransactions.cs4
-rw-r--r--OpenSim/Framework/Communications/Cache/CachedUserInfo.cs8
-rw-r--r--OpenSim/Framework/Communications/Capabilities/Caps.cs102
-rw-r--r--OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs1
-rw-r--r--OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs17
5 files changed, 121 insertions, 11 deletions
diff --git a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs
index e12d234..8909bdf 100644
--- a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs
+++ b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs
@@ -89,7 +89,7 @@ namespace OpenSim.Framework.Communications.Caches
89 private string uploaderPath = ""; 89 private string uploaderPath = "";
90 90
91 // Events 91 // Events
92 public event UpLoadedTexture OnUpLoad; 92 public event UpLoadedAsset OnUpLoad;
93 93
94 // Methods 94 // Methods
95 public void Initialise(string assetName, string assetDescription, LLUUID assetID, LLUUID inventoryItem, LLUUID folderID, string path, BaseHttpServer httpServer) 95 public void Initialise(string assetName, string assetDescription, LLUUID assetID, LLUUID inventoryItem, LLUUID folderID, string path, BaseHttpServer httpServer)
@@ -230,7 +230,7 @@ namespace OpenSim.Framework.Communications.Caches
230 private string uploaderPath = ""; 230 private string uploaderPath = "";
231 231
232 // Events 232 // Events
233 public event UpLoadedTexture OnUpLoad; 233 public event UpLoadedAsset OnUpLoad;
234 234
235 // Methods 235 // Methods
236 public void Initialise(LLUUID inventoryItem, string path, BaseHttpServer httpServer) 236 public void Initialise(LLUUID inventoryItem, string path, BaseHttpServer httpServer)
diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs
index 57c79b4..9970d80 100644
--- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs
+++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs
@@ -104,6 +104,14 @@ namespace OpenSim.Framework.Communications.Caches
104 this.m_parentCommsManager.InventoryServer.AddNewInventoryItem(userID, itemInfo); 104 this.m_parentCommsManager.InventoryServer.AddNewInventoryItem(userID, itemInfo);
105 } 105 }
106 } 106 }
107
108 public void updateItem(LLUUID userID, InventoryItemBase itemInfo)
109 {
110 if ((userID == this.UserProfile.UUID) && (this.RootFolder != null))
111 {
112 this.m_parentCommsManager.InventoryServer.AddNewInventoryItem(userID, itemInfo);
113 }
114 }
107 } 115 }
108 116
109 117
diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs
index eb88aa7..14f9c95 100644
--- a/OpenSim/Framework/Communications/Capabilities/Caps.cs
+++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs
@@ -39,8 +39,10 @@ using OpenSim.Framework.Data;
39 39
40namespace OpenSim.Region.Capabilities 40namespace OpenSim.Region.Capabilities
41{ 41{
42 public delegate void UpLoadedTexture(string assetName, string description, LLUUID assetID, LLUUID inventoryItem, LLUUID parentFolder, byte[] data); 42 public delegate void UpLoadedAsset(string assetName, string description, LLUUID assetID, LLUUID inventoryItem, LLUUID parentFolder, byte[] data);
43 public delegate LLUUID UpdateItem(LLUUID itemID, byte[] data);
43 public delegate void NewInventoryItem(LLUUID userID, InventoryItemBase item); 44 public delegate void NewInventoryItem(LLUUID userID, InventoryItemBase item);
45 public delegate LLUUID ItemUpdatedCallback(LLUUID userID, LLUUID itemID, byte[] data);
44 46
45 public class Caps 47 public class Caps
46 { 48 {
@@ -59,6 +61,7 @@ namespace OpenSim.Region.Capabilities
59 private int eventQueueCount = 1; 61 private int eventQueueCount = 1;
60 private Queue<string> CapsEventQueue = new Queue<string>(); 62 private Queue<string> CapsEventQueue = new Queue<string>();
61 public NewInventoryItem AddNewInventoryItem = null; 63 public NewInventoryItem AddNewInventoryItem = null;
64 public ItemUpdatedCallback ItemUpdatedCall = null;
62 65
63 public Caps(AssetCache assetCach, BaseHttpServer httpServer, string httpListen, int httpPort, string capsPath, LLUUID agent) 66 public Caps(AssetCache assetCach, BaseHttpServer httpServer, string httpListen, int httpPort, string capsPath, LLUUID agent)
64 { 67 {
@@ -125,7 +128,8 @@ namespace OpenSim.Region.Capabilities
125 string capsBaseUrl = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + "/CAPS/" + m_capsObjectPath; 128 string capsBaseUrl = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + "/CAPS/" + m_capsObjectPath;
126 caps.MapLayer = capsBaseUrl + m_mapLayerPath; 129 caps.MapLayer = capsBaseUrl + m_mapLayerPath;
127 caps.NewFileAgentInventory = capsBaseUrl + m_newInventory; 130 caps.NewFileAgentInventory = capsBaseUrl + m_newInventory;
128 // caps.UpdateNotecardAgentInventory = capsBaseUrl + m_notecardUpdatePath; 131 caps.UpdateNotecardAgentInventory = capsBaseUrl + m_notecardUpdatePath;
132 caps.UpdateScriptAgentInventory = capsBaseUrl + m_notecardUpdatePath;
129 return caps; 133 return caps;
130 } 134 }
131 135
@@ -238,21 +242,24 @@ namespace OpenSim.Region.Capabilities
238 /// <returns></returns> 242 /// <returns></returns>
239 public string NoteCardAgentInventory(string request, string path, string param) 243 public string NoteCardAgentInventory(string request, string path, string param)
240 { 244 {
241 Console.WriteLine("notecard update request " + request); 245 Hashtable hash = (Hashtable)LLSD.LLSDDeserialize(Helpers.StringToField(request));
242 string assetName = "notecardupdate"; 246 LLSDItemUpdate llsdRequest = new LLSDItemUpdate();
247 LLSDHelpers.DeserialiseLLSDMap(hash, llsdRequest);
248
243 string capsBase = "/CAPS/" + m_capsObjectPath; 249 string capsBase = "/CAPS/" + m_capsObjectPath;
244 LLUUID newAsset = LLUUID.Random(); 250 LLUUID newInvItem = llsdRequest.item_id;
245 LLUUID newInvItem = LLUUID.Random();
246 string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); 251 string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000");
247 252
248 AssetUploader uploader = new AssetUploader(assetName, "description", newAsset, newInvItem, LLUUID.Zero, "", "", capsBase + uploaderPath, this.httpListener); 253 ItemUpdater uploader = new ItemUpdater(newInvItem, capsBase + uploaderPath, this.httpListener);
254 uploader.OnUpLoad += this.ItemUpdated;
255
249 httpListener.AddStreamHandler(new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps)); 256 httpListener.AddStreamHandler(new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps));
250 string uploaderURL = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + capsBase + uploaderPath; 257 string uploaderURL = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + capsBase + uploaderPath;
251 258
252 LLSDAssetUploadResponse uploadResponse = new LLSDAssetUploadResponse(); 259 LLSDAssetUploadResponse uploadResponse = new LLSDAssetUploadResponse();
253 uploadResponse.uploader = uploaderURL; 260 uploadResponse.uploader = uploaderURL;
254 uploadResponse.state = "upload"; 261 uploadResponse.state = "upload";
255 // uploader.OnUpLoad += this.UploadCompleteHandler; 262
256 return LLSDHelpers.SerialiseLLSDReply(uploadResponse); 263 return LLSDHelpers.SerialiseLLSDReply(uploadResponse);
257 } 264 }
258 265
@@ -321,9 +328,18 @@ namespace OpenSim.Region.Capabilities
321 328
322 } 329 }
323 330
331 public LLUUID ItemUpdated(LLUUID itemID, byte[] data)
332 {
333 if (ItemUpdatedCall != null)
334 {
335 return ItemUpdatedCall(this.agentID, itemID, data);
336 }
337 return LLUUID.Zero;
338 }
339
324 public class AssetUploader 340 public class AssetUploader
325 { 341 {
326 public event UpLoadedTexture OnUpLoad; 342 public event UpLoadedAsset OnUpLoad;
327 343
328 private string uploaderPath = ""; 344 private string uploaderPath = "";
329 private LLUUID newAssetID; 345 private LLUUID newAssetID;
@@ -392,6 +408,74 @@ namespace OpenSim.Region.Capabilities
392 fs.Close(); 408 fs.Close();
393 } 409 }
394 } 410 }
411
412 public class ItemUpdater
413 {
414 public event UpdateItem OnUpLoad;
415
416 private string uploaderPath = "";
417 private LLUUID inventoryItemID;
418 private BaseHttpServer httpListener;
419 private bool SaveAssets = false;
420
421
422 /// <summary>
423 ///
424 /// </summary>
425 /// <param name="assetID"></param>
426 /// <param name="inventoryItem"></param>
427 /// <param name="path"></param>
428 /// <param name="httpServer"></param>
429 public ItemUpdater( LLUUID inventoryItem, string path, BaseHttpServer httpServer)
430 {
431
432 inventoryItemID = inventoryItem;
433 uploaderPath = path;
434 httpListener = httpServer;
435 }
436
437 /// <summary>
438 ///
439 /// </summary>
440 /// <param name="data"></param>
441 /// <param name="path"></param>
442 /// <param name="param"></param>
443 /// <returns></returns>
444 public string uploaderCaps(byte[] data, string path, string param)
445 {
446 LLUUID inv = this.inventoryItemID;
447 string res = "";
448 LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete();
449 LLUUID assetID = LLUUID.Zero;
450
451 if (OnUpLoad != null)
452 {
453 assetID = OnUpLoad(inv, data);
454 }
455
456 uploadComplete.new_asset = assetID.ToStringHyphenated();
457 uploadComplete.new_inventory_item = inv;
458 uploadComplete.state = "complete";
459
460 res = LLSDHelpers.SerialiseLLSDReply(uploadComplete);
461
462 httpListener.RemoveStreamHandler("POST", uploaderPath);
463
464 if (this.SaveAssets)
465 this.SaveAssetToFile("updateditem"+Util.RandomClass.Next(1,1000) + ".dat", data);
466
467 return res;
468 }
469
470 private void SaveAssetToFile(string filename, byte[] data)
471 {
472 FileStream fs = File.Create(filename);
473 BinaryWriter bw = new BinaryWriter(fs);
474 bw.Write(data);
475 bw.Close();
476 fs.Close();
477 }
478 }
395 } 479 }
396} 480}
397 481
diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs b/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs
index 913d7ab..af20468 100644
--- a/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs
+++ b/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs
@@ -9,6 +9,7 @@ namespace OpenSim.Region.Capabilities
9 // public string RequestTextureDownload = ""; 9 // public string RequestTextureDownload = "";
10 // public string ChatSessionRequest = ""; 10 // public string ChatSessionRequest = "";
11 public string UpdateNotecardAgentInventory = ""; 11 public string UpdateNotecardAgentInventory = "";
12 public string UpdateScriptAgentInventory = "";
12 // public string ParcelVoiceInfoRequest = ""; 13 // public string ParcelVoiceInfoRequest = "";
13 14
14 public LLSDCapsDetails() 15 public LLSDCapsDetails()
diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs b/OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs
new file mode 100644
index 0000000..d47bb07
--- /dev/null
+++ b/OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs
@@ -0,0 +1,17 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using libsecondlife;
5
6namespace OpenSim.Region.Capabilities
7{
8 [LLSDMap]
9 public class LLSDItemUpdate
10 {
11 public LLUUID item_id;
12
13 public LLSDItemUpdate()
14 {
15 }
16 }
17}