aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Communications/Capabilities/Caps.cs
diff options
context:
space:
mode:
authorMW2007-08-14 19:19:09 +0000
committerMW2007-08-14 19:19:09 +0000
commita979808493b20362ab3fe06ac68e5370622ceafa (patch)
treeb3e2b6bd5b6bd30e7331b15630fd50b8765e0d5f /OpenSim/Framework/Communications/Capabilities/Caps.cs
parentkrinkec's updates to ll* interface and functions (diff)
downloadopensim-SC_OLD-a979808493b20362ab3fe06ac68e5370622ceafa.zip
opensim-SC_OLD-a979808493b20362ab3fe06ac68e5370622ceafa.tar.gz
opensim-SC_OLD-a979808493b20362ab3fe06ac68e5370622ceafa.tar.bz2
opensim-SC_OLD-a979808493b20362ab3fe06ac68e5370622ceafa.tar.xz
preliminary support for editing notecards and scripts.
Although there seems to sometimes be a problem of when you login again, old notecards and scripts will have their permissions messed up and you won't be able to even view their text. This seems to be related to the client's cache, and if you clear your client's cache, on the next login they should be fine again. [I have a couple of ideas about what might be causing this so hopefully will have it fixed soon.]
Diffstat (limited to 'OpenSim/Framework/Communications/Capabilities/Caps.cs')
-rw-r--r--OpenSim/Framework/Communications/Capabilities/Caps.cs102
1 files changed, 93 insertions, 9 deletions
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