aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Communications
diff options
context:
space:
mode:
authorSean Dague2009-05-08 18:09:41 +0000
committerSean Dague2009-05-08 18:09:41 +0000
commitb333690969a600bd2d3e298bee98ea38c5dd66e9 (patch)
tree52b722e0160ce6308d71e168d82382a4200e3d73 /OpenSim/Framework/Communications
parent* refactor: break out sog original xml serialization to a separate class (diff)
downloadopensim-SC-b333690969a600bd2d3e298bee98ea38c5dd66e9.zip
opensim-SC-b333690969a600bd2d3e298bee98ea38c5dd66e9.tar.gz
opensim-SC-b333690969a600bd2d3e298bee98ea38c5dd66e9.tar.bz2
opensim-SC-b333690969a600bd2d3e298bee98ea38c5dd66e9.tar.xz
added WebFetchInventoryDescendents CAP
From: Robert Smart <smartrob@uk.ibm.com>
Diffstat (limited to 'OpenSim/Framework/Communications')
-rw-r--r--OpenSim/Framework/Communications/Capabilities/Caps.cs86
-rw-r--r--OpenSim/Framework/Communications/Capabilities/LLSDInventoryItem.cs6
2 files changed, 84 insertions, 8 deletions
diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs
index 73aa819..858ff1d 100644
--- a/OpenSim/Framework/Communications/Capabilities/Caps.cs
+++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs
@@ -88,7 +88,7 @@ namespace OpenSim.Framework.Communications.Capabilities
88 //private static readonly string m_requestTexture = "0003/"; 88 //private static readonly string m_requestTexture = "0003/";
89 private static readonly string m_notecardUpdatePath = "0004/"; 89 private static readonly string m_notecardUpdatePath = "0004/";
90 private static readonly string m_notecardTaskUpdatePath = "0005/"; 90 private static readonly string m_notecardTaskUpdatePath = "0005/";
91 // private static readonly string m_fetchInventoryPath = "0006/"; 91 private static readonly string m_fetchInventoryPath = "0006/";
92 92
93 // The following entries are in a module, however, they are also here so that we don't re-assign 93 // The following entries are in a module, however, they are also here so that we don't re-assign
94 // the path to another cap by mistake. 94 // the path to another cap by mistake.
@@ -202,6 +202,10 @@ namespace OpenSim.Framework.Communications.Capabilities
202 new RestStreamHandler("POST", capsBase + m_notecardUpdatePath, NoteCardAgentInventory); 202 new RestStreamHandler("POST", capsBase + m_notecardUpdatePath, NoteCardAgentInventory);
203 m_capsHandlers["UpdateScriptAgentInventory"] = m_capsHandlers["UpdateNotecardAgentInventory"]; 203 m_capsHandlers["UpdateScriptAgentInventory"] = m_capsHandlers["UpdateNotecardAgentInventory"];
204 m_capsHandlers["UpdateScriptAgent"] = m_capsHandlers["UpdateScriptAgentInventory"]; 204 m_capsHandlers["UpdateScriptAgent"] = m_capsHandlers["UpdateScriptAgentInventory"];
205
206 // rob smart
207 // adding handling for WebFetchInventoryDescendents which appears in RC 1.22.9
208 m_capsHandlers["WebFetchInventoryDescendents"] =new RestStreamHandler("POST", capsBase + m_fetchInventoryPath, FetchInventoryDescendentsRequest);
205 209
206 // justincc: I've disabled the CAPS service for now to fix problems with selecting textures, and 210 // justincc: I've disabled the CAPS service for now to fix problems with selecting textures, and
207 // subsequent inventory breakage, in the edit object pane (such as mantis 1085). This requires 211 // subsequent inventory breakage, in the edit object pane (such as mantis 1085). This requires
@@ -360,6 +364,76 @@ namespace OpenSim.Framework.Communications.Capabilities
360 return response; 364 return response;
361 } 365 }
362 366
367 public string FetchInventoryDescendentsRequest(string request, string path, string param,OSHttpRequest httpRequest, OSHttpResponse httpResponse)
368 {
369 m_log.Debug("[CAPS]: FetchInventoryDescendentsRequest in region: " + m_regionName + "request is "+request);
370
371 // nasty temporary hack here, the linden client falsely identifies the uuid 00000000-0000-0000-0000-000000000000 as a string which breaks us
372 // correctly mark it as a uuid
373 request = request.Replace("<string>00000000-0000-0000-0000-000000000000</string>", "<uuid>00000000-0000-0000-0000-000000000000</uuid>");
374
375 // another hack <integer>1</integer> results in a System.ArgumentException: Object type System.Int32 cannot be converted to target type: System.Boolean
376 request = request.Replace("<key>fetch_folders</key><integer>0</integer>", "<key>fetch_folders</key><boolean>0</boolean>");
377 request = request.Replace("<key>fetch_folders</key><integer>1</integer>", "<key>fetch_folders</key><boolean>1</boolean>");
378 Hashtable hash = new Hashtable();
379 try
380 {
381 hash = (Hashtable)LLSD.LLSDDeserialize(Utils.StringToBytes(request));
382 }
383 catch (LLSD.LLSDParseException pe)
384 {
385 m_log.Error("[AGENT INVENTORY]: Fetch error: " + pe.Message);
386 m_log.Error("Request: " + request.ToString());
387 }
388
389 ArrayList foldersrequested = (ArrayList)hash["folders"];
390
391 string response = "";
392 for (int i = 0; i < foldersrequested.Count; i++)
393 {
394 string inventoryitemstr = "";
395 Hashtable inventoryhash = (Hashtable)foldersrequested[i];
396
397 LLSDFetchInventoryDescendents llsdRequest = new LLSDFetchInventoryDescendents();
398
399 try{
400 LLSDHelpers.DeserialiseOSDMap(inventoryhash, llsdRequest);
401 }
402 catch(Exception e)
403 {
404 m_log.Debug("[CAPS]: caught exception doing OSD deserialize" + e);
405 }
406 LLSDInventoryDescendents reply = FetchInventoryReply(llsdRequest);
407
408 inventoryitemstr = LLSDHelpers.SerialiseLLSDReply(reply);
409 inventoryitemstr = inventoryitemstr.Replace("<llsd><map><key>folders</key><array>", "");
410 inventoryitemstr = inventoryitemstr.Replace("</array></map></llsd>", "");
411
412 response += inventoryitemstr;
413 }
414
415
416 if (response.Length == 0)
417 {
418 // Ter-guess: If requests fail a lot, the client seems to stop requesting descendants.
419 // Therefore, I'm concluding that the client only has so many threads available to do requests
420 // and when a thread stalls.. is stays stalled.
421 // Therefore we need to return something valid
422 response = "<llsd><map><key>folders</key><array /></map></llsd>";
423 }
424 else
425 {
426 response = "<llsd><map><key>folders</key><array>" + response + "</array></map></llsd>";
427 }
428
429 m_log.DebugFormat("[CAPS]: Replying to CAPS fetch inventory request with following xml");
430 m_log.Debug("[CAPS] "+response);
431
432 return response;
433 }
434
435
436
363 /// <summary> 437 /// <summary>
364 /// Construct an LLSD reply packet to a CAPS inventory request 438 /// Construct an LLSD reply packet to a CAPS inventory request
365 /// </summary> 439 /// </summary>
@@ -369,9 +443,9 @@ namespace OpenSim.Framework.Communications.Capabilities
369 { 443 {
370 LLSDInventoryDescendents reply = new LLSDInventoryDescendents(); 444 LLSDInventoryDescendents reply = new LLSDInventoryDescendents();
371 LLSDInventoryFolderContents contents = new LLSDInventoryFolderContents(); 445 LLSDInventoryFolderContents contents = new LLSDInventoryFolderContents();
372 contents.agent___id = m_agentID; 446 contents.agent_id = m_agentID;
373 contents.owner___id = invFetch.owner_id; 447 contents.owner_id = invFetch.owner_id;
374 contents.folder___id = invFetch.folder_id; 448 contents.folder_id = invFetch.folder_id;
375 449
376 // The version number being sent back was originally 1. 450 // The version number being sent back was originally 1.
377 // Unfortunately, on 1.19.1.4, this means that we see a problem where on subsequent logins 451 // Unfortunately, on 1.19.1.4, this means that we see a problem where on subsequent logins
@@ -397,6 +471,8 @@ namespace OpenSim.Framework.Communications.Capabilities
397 contents.items.Array.Add(ConvertInventoryItem(invItem)); 471 contents.items.Array.Add(ConvertInventoryItem(invItem));
398 } 472 }
399 } 473 }
474 /* Rob Smart The following block i removed as it ALWAYS sends the error to the client because the RC 1.22.9 client tries to
475 find items that have become dissasociated with a paret folder and have parent of 00000000-0000-00000....
400 else 476 else
401 { 477 {
402 IClientAPI client = GetClient(m_agentID); 478 IClientAPI client = GetClient(m_agentID);
@@ -416,7 +492,7 @@ namespace OpenSim.Framework.Communications.Capabilities
416 "[AGENT INVENTORY]: Could not lookup controlling client for {0} in order to notify them of the inventory service failure", 492 "[AGENT INVENTORY]: Could not lookup controlling client for {0} in order to notify them of the inventory service failure",
417 m_agentID); 493 m_agentID);
418 } 494 }
419 } 495 }*/
420 496
421 contents.descendents = contents.items.Array.Count; 497 contents.descendents = contents.items.Array.Count;
422 return reply; 498 return reply;
diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDInventoryItem.cs b/OpenSim/Framework/Communications/Capabilities/LLSDInventoryItem.cs
index 3651513..7cc1e38 100644
--- a/OpenSim/Framework/Communications/Capabilities/LLSDInventoryItem.cs
+++ b/OpenSim/Framework/Communications/Capabilities/LLSDInventoryItem.cs
@@ -87,11 +87,11 @@ namespace OpenSim.Framework.Communications.Capabilities
87 [OSDMap] 87 [OSDMap]
88 public class LLSDInventoryFolderContents 88 public class LLSDInventoryFolderContents
89 { 89 {
90 public UUID agent___id; // the (three "_") "___" so the serialising knows to change this to a "-" 90 public UUID agent_id;
91 public int descendents; 91 public int descendents;
92 public UUID folder___id; //as LL can't decide if they are going to use "_" or "-" to separate words in the field names 92 public UUID folder_id;
93 public OSDArray items = new OSDArray(); 93 public OSDArray items = new OSDArray();
94 public UUID owner___id; // and of course we can't have field names with "-" in 94 public UUID owner_id;
95 public int version; 95 public int version;
96 } 96 }
97} 97}