added WebFetchInventoryDescendents CAP

From: Robert Smart <smartrob@uk.ibm.com>
0.6.5-rc1
Sean Dague 2009-05-08 18:09:41 +00:00
parent 9f39a490b5
commit b333690969
2 changed files with 84 additions and 8 deletions

View File

@ -88,7 +88,7 @@ namespace OpenSim.Framework.Communications.Capabilities
//private static readonly string m_requestTexture = "0003/";
private static readonly string m_notecardUpdatePath = "0004/";
private static readonly string m_notecardTaskUpdatePath = "0005/";
// private static readonly string m_fetchInventoryPath = "0006/";
private static readonly string m_fetchInventoryPath = "0006/";
// The following entries are in a module, however, they are also here so that we don't re-assign
// the path to another cap by mistake.
@ -203,6 +203,10 @@ namespace OpenSim.Framework.Communications.Capabilities
m_capsHandlers["UpdateScriptAgentInventory"] = m_capsHandlers["UpdateNotecardAgentInventory"];
m_capsHandlers["UpdateScriptAgent"] = m_capsHandlers["UpdateScriptAgentInventory"];
// rob smart
// adding handling for WebFetchInventoryDescendents which appears in RC 1.22.9
m_capsHandlers["WebFetchInventoryDescendents"] =new RestStreamHandler("POST", capsBase + m_fetchInventoryPath, FetchInventoryDescendentsRequest);
// justincc: I've disabled the CAPS service for now to fix problems with selecting textures, and
// subsequent inventory breakage, in the edit object pane (such as mantis 1085). This requires
// enhancements (probably filling out the folder part of the LLSD reply) to our CAPS service,
@ -360,6 +364,76 @@ namespace OpenSim.Framework.Communications.Capabilities
return response;
}
public string FetchInventoryDescendentsRequest(string request, string path, string param,OSHttpRequest httpRequest, OSHttpResponse httpResponse)
{
m_log.Debug("[CAPS]: FetchInventoryDescendentsRequest in region: " + m_regionName + "request is "+request);
// nasty temporary hack here, the linden client falsely identifies the uuid 00000000-0000-0000-0000-000000000000 as a string which breaks us
// correctly mark it as a uuid
request = request.Replace("<string>00000000-0000-0000-0000-000000000000</string>", "<uuid>00000000-0000-0000-0000-000000000000</uuid>");
// another hack <integer>1</integer> results in a System.ArgumentException: Object type System.Int32 cannot be converted to target type: System.Boolean
request = request.Replace("<key>fetch_folders</key><integer>0</integer>", "<key>fetch_folders</key><boolean>0</boolean>");
request = request.Replace("<key>fetch_folders</key><integer>1</integer>", "<key>fetch_folders</key><boolean>1</boolean>");
Hashtable hash = new Hashtable();
try
{
hash = (Hashtable)LLSD.LLSDDeserialize(Utils.StringToBytes(request));
}
catch (LLSD.LLSDParseException pe)
{
m_log.Error("[AGENT INVENTORY]: Fetch error: " + pe.Message);
m_log.Error("Request: " + request.ToString());
}
ArrayList foldersrequested = (ArrayList)hash["folders"];
string response = "";
for (int i = 0; i < foldersrequested.Count; i++)
{
string inventoryitemstr = "";
Hashtable inventoryhash = (Hashtable)foldersrequested[i];
LLSDFetchInventoryDescendents llsdRequest = new LLSDFetchInventoryDescendents();
try{
LLSDHelpers.DeserialiseOSDMap(inventoryhash, llsdRequest);
}
catch(Exception e)
{
m_log.Debug("[CAPS]: caught exception doing OSD deserialize" + e);
}
LLSDInventoryDescendents reply = FetchInventoryReply(llsdRequest);
inventoryitemstr = LLSDHelpers.SerialiseLLSDReply(reply);
inventoryitemstr = inventoryitemstr.Replace("<llsd><map><key>folders</key><array>", "");
inventoryitemstr = inventoryitemstr.Replace("</array></map></llsd>", "");
response += inventoryitemstr;
}
if (response.Length == 0)
{
// Ter-guess: If requests fail a lot, the client seems to stop requesting descendants.
// Therefore, I'm concluding that the client only has so many threads available to do requests
// and when a thread stalls.. is stays stalled.
// Therefore we need to return something valid
response = "<llsd><map><key>folders</key><array /></map></llsd>";
}
else
{
response = "<llsd><map><key>folders</key><array>" + response + "</array></map></llsd>";
}
m_log.DebugFormat("[CAPS]: Replying to CAPS fetch inventory request with following xml");
m_log.Debug("[CAPS] "+response);
return response;
}
/// <summary>
/// Construct an LLSD reply packet to a CAPS inventory request
/// </summary>
@ -369,9 +443,9 @@ namespace OpenSim.Framework.Communications.Capabilities
{
LLSDInventoryDescendents reply = new LLSDInventoryDescendents();
LLSDInventoryFolderContents contents = new LLSDInventoryFolderContents();
contents.agent___id = m_agentID;
contents.owner___id = invFetch.owner_id;
contents.folder___id = invFetch.folder_id;
contents.agent_id = m_agentID;
contents.owner_id = invFetch.owner_id;
contents.folder_id = invFetch.folder_id;
// The version number being sent back was originally 1.
// 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
contents.items.Array.Add(ConvertInventoryItem(invItem));
}
}
/* 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
find items that have become dissasociated with a paret folder and have parent of 00000000-0000-00000....
else
{
IClientAPI client = GetClient(m_agentID);
@ -416,7 +492,7 @@ namespace OpenSim.Framework.Communications.Capabilities
"[AGENT INVENTORY]: Could not lookup controlling client for {0} in order to notify them of the inventory service failure",
m_agentID);
}
}
}*/
contents.descendents = contents.items.Array.Count;
return reply;

View File

@ -87,11 +87,11 @@ namespace OpenSim.Framework.Communications.Capabilities
[OSDMap]
public class LLSDInventoryFolderContents
{
public UUID agent___id; // the (three "_") "___" so the serialising knows to change this to a "-"
public UUID agent_id;
public int descendents;
public UUID folder___id; //as LL can't decide if they are going to use "_" or "-" to separate words in the field names
public UUID folder_id;
public OSDArray items = new OSDArray();
public UUID owner___id; // and of course we can't have field names with "-" in
public UUID owner_id;
public int version;
}
}