a few changes to encoder and a few more uses
parent
266eabcad4
commit
cdd3ef857c
|
@ -40,7 +40,7 @@ namespace OpenSim.Framework
|
|||
{
|
||||
static readonly DateTime depoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
|
||||
|
||||
public static void AddStartHeader(StringBuilder sb, bool addxmlversion = false)
|
||||
public static void AddStart(StringBuilder sb, bool addxmlversion = false)
|
||||
{
|
||||
if(addxmlversion)
|
||||
sb.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?><llsd>"); // legacy llsd xml name still valid
|
||||
|
@ -48,13 +48,13 @@ namespace OpenSim.Framework
|
|||
sb.Append("<llsd>");
|
||||
}
|
||||
|
||||
public static void AddEndHeader(StringBuilder sb)
|
||||
public static void AddEnd(StringBuilder sb)
|
||||
{
|
||||
sb.Append("</llsd>");
|
||||
}
|
||||
|
||||
// map == a list of key value pairs
|
||||
public static void AddStartMap(StringBuilder sb)
|
||||
public static void AddMap(StringBuilder sb)
|
||||
{
|
||||
sb.Append("<map>");
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ namespace OpenSim.Framework
|
|||
}
|
||||
|
||||
// array == a list values
|
||||
public static void AddStartArray(StringBuilder sb)
|
||||
public static void AddArray(StringBuilder sb)
|
||||
{
|
||||
sb.Append("<array>");
|
||||
}
|
||||
|
@ -99,6 +99,18 @@ namespace OpenSim.Framework
|
|||
sb.Append("<boolean />");
|
||||
}
|
||||
|
||||
public static void AddElem(byte e, StringBuilder sb)
|
||||
{
|
||||
if(e == 0)
|
||||
sb.Append("<integer />");
|
||||
else
|
||||
{
|
||||
sb.Append("<integer>");
|
||||
sb.Append(e.ToString());
|
||||
sb.Append("</integer>");
|
||||
}
|
||||
}
|
||||
|
||||
public static void AddElem(int e, StringBuilder sb)
|
||||
{
|
||||
if(e == 0)
|
||||
|
@ -171,7 +183,7 @@ namespace OpenSim.Framework
|
|||
}
|
||||
}
|
||||
|
||||
public static void AddURIElem(Uri e, StringBuilder sb)
|
||||
public static void AddElem(Uri e, StringBuilder sb)
|
||||
{
|
||||
if(e == null)
|
||||
{
|
||||
|
@ -218,7 +230,7 @@ namespace OpenSim.Framework
|
|||
//************ key value *******************
|
||||
// assumes name is a valid llsd key
|
||||
|
||||
public static void AddStartMap(string name, StringBuilder sb)
|
||||
public static void AddMap(string name, StringBuilder sb)
|
||||
{
|
||||
sb.Append("<key>");
|
||||
sb.Append(name);
|
||||
|
@ -233,7 +245,7 @@ namespace OpenSim.Framework
|
|||
}
|
||||
|
||||
// array == a list values
|
||||
public static void AddStartArray(string name, StringBuilder sb)
|
||||
public static void AddArray(string name, StringBuilder sb)
|
||||
{
|
||||
sb.Append("<key>");
|
||||
sb.Append(name);
|
||||
|
@ -267,6 +279,22 @@ namespace OpenSim.Framework
|
|||
sb.Append("<boolean />");
|
||||
}
|
||||
|
||||
public static void AddElem(string name, byte e, StringBuilder sb)
|
||||
{
|
||||
sb.Append("<key>");
|
||||
sb.Append(name);
|
||||
sb.Append("</key>");
|
||||
|
||||
if(e == 0)
|
||||
sb.Append("<integer />");
|
||||
else
|
||||
{
|
||||
sb.Append("<integer>");
|
||||
sb.Append(e.ToString());
|
||||
sb.Append("</integer>");
|
||||
}
|
||||
}
|
||||
|
||||
public static void AddElem(string name, int e, StringBuilder sb)
|
||||
{
|
||||
sb.Append("<key>");
|
||||
|
@ -363,7 +391,7 @@ namespace OpenSim.Framework
|
|||
}
|
||||
}
|
||||
|
||||
public static void AddURIElem(string name, Uri e, StringBuilder sb)
|
||||
public static void AddElem(string name, Uri e, StringBuilder sb)
|
||||
{
|
||||
sb.Append("<key>");
|
||||
sb.Append(name);
|
||||
|
|
|
@ -1376,9 +1376,15 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
IOSHttpResponse httpResponse)
|
||||
{
|
||||
OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request);
|
||||
OSDMap resp = new OSDMap();
|
||||
OSDArray object_ids = (OSDArray)req["object_ids"];
|
||||
|
||||
StringBuilder lsl = new StringBuilder(256);
|
||||
LLSDxmlEncode.AddStart(lsl);
|
||||
if(object_ids.Count == 0)
|
||||
LLSDxmlEncode.AddEmpyMap(lsl);
|
||||
else
|
||||
{
|
||||
LLSDxmlEncode.AddMap(lsl);
|
||||
for (int i = 0 ; i < object_ids.Count ; i++)
|
||||
{
|
||||
UUID uuid = object_ids[i].AsUUID();
|
||||
|
@ -1386,20 +1392,21 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
SceneObjectPart obj = m_Scene.GetSceneObjectPart(uuid);
|
||||
if (obj != null)
|
||||
{
|
||||
OSDMap object_data = new OSDMap();
|
||||
LLSDxmlEncode.AddMap(uuid.ToString(),lsl);
|
||||
|
||||
object_data["PhysicsShapeType"] = obj.PhysicsShapeType;
|
||||
object_data["Density"] = obj.Density;
|
||||
object_data["Friction"] = obj.Friction;
|
||||
object_data["Restitution"] = obj.Restitution;
|
||||
object_data["GravityMultiplier"] = obj.GravityModifier;
|
||||
LLSDxmlEncode.AddElem("PhysicsShapeType", obj.PhysicsShapeType, lsl);
|
||||
LLSDxmlEncode.AddElem("Density", obj.Density, lsl);
|
||||
LLSDxmlEncode.AddElem("Friction", obj.Friction, lsl);
|
||||
LLSDxmlEncode.AddElem("Restitution", obj.Restitution, lsl);
|
||||
LLSDxmlEncode.AddElem("GravityMultiplier", obj.GravityModifier, lsl);
|
||||
|
||||
resp[uuid.ToString()] = object_data;
|
||||
LLSDxmlEncode.AddEndMap(lsl);
|
||||
}
|
||||
LLSDxmlEncode.AddEndMap(lsl);
|
||||
}
|
||||
}
|
||||
|
||||
string response = OSDParser.SerializeLLSDXmlString(resp);
|
||||
return response;
|
||||
LLSDxmlEncode.AddEnd(lsl);
|
||||
return lsl.ToString();
|
||||
}
|
||||
|
||||
public string GetObjectCost(string request, string path,
|
||||
|
@ -1407,10 +1414,16 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
IOSHttpResponse httpResponse)
|
||||
{
|
||||
OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request);
|
||||
OSDMap resp = new OSDMap();
|
||||
|
||||
OSDArray object_ids = (OSDArray)req["object_ids"];
|
||||
|
||||
StringBuilder lsl = new StringBuilder(512);
|
||||
LLSDxmlEncode.AddStart(lsl);
|
||||
if(object_ids.Count == 0)
|
||||
LLSDxmlEncode.AddEmpyMap(lsl);
|
||||
else
|
||||
{
|
||||
bool haveone = false;
|
||||
LLSDxmlEncode.AddMap(lsl);
|
||||
for (int i = 0; i < object_ids.Count; i++)
|
||||
{
|
||||
UUID uuid = object_ids[i].AsUUID();
|
||||
|
@ -1421,6 +1434,7 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
grp = part.ParentGroup;
|
||||
if (grp != null)
|
||||
{
|
||||
haveone = true;
|
||||
float linksetCost;
|
||||
float linksetPhysCost;
|
||||
float partCost;
|
||||
|
@ -1428,26 +1442,32 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
|
||||
grp.GetResourcesCosts(part,out linksetCost,out linksetPhysCost,out partCost,out partPhysCost);
|
||||
|
||||
OSDMap object_data = new OSDMap();
|
||||
object_data["linked_set_resource_cost"] = linksetCost;
|
||||
object_data["resource_cost"] = partCost;
|
||||
object_data["physics_cost"] = partPhysCost;
|
||||
object_data["linked_set_physics_cost"] = linksetPhysCost;
|
||||
object_data["resource_limiting_type"] = "legacy";
|
||||
resp[uuid.ToString()] = object_data;
|
||||
LLSDxmlEncode.AddMap(uuid.ToString(), lsl);
|
||||
|
||||
LLSDxmlEncode.AddElem("linked_set_resource_cost", linksetCost, lsl);
|
||||
LLSDxmlEncode.AddElem("resource_cost", partCost, lsl);
|
||||
LLSDxmlEncode.AddElem("physics_cost", partPhysCost, lsl);
|
||||
LLSDxmlEncode.AddElem("linked_set_physics_cost", linksetPhysCost, lsl);
|
||||
LLSDxmlEncode.AddElem("resource_limiting_type", "legacy", lsl);
|
||||
|
||||
LLSDxmlEncode.AddEndMap(lsl);
|
||||
}
|
||||
}
|
||||
if(resp.Count == 0)
|
||||
if(!haveone)
|
||||
{
|
||||
OSDMap object_data = new OSDMap();
|
||||
object_data["linked_set_resource_cost"] = 0;
|
||||
object_data["resource_cost"] = 0;
|
||||
object_data["physics_cost"] = 0;
|
||||
object_data["linked_set_physics_cost"] = 0;
|
||||
resp[UUID.Zero.ToString()] = object_data;
|
||||
LLSDxmlEncode.AddMap(UUID.Zero.ToString(), lsl);
|
||||
LLSDxmlEncode.AddElem("linked_set_resource_cost", 0, lsl);
|
||||
LLSDxmlEncode.AddElem("resource_cost", 0, lsl);
|
||||
LLSDxmlEncode.AddElem("physics_cost", 0, lsl);
|
||||
LLSDxmlEncode.AddElem("linked_set_physics_cost", 0, lsl);
|
||||
LLSDxmlEncode.AddElem("resource_limiting_type", "legacy", lsl);
|
||||
LLSDxmlEncode.AddEndMap(lsl);
|
||||
}
|
||||
string response = OSDParser.SerializeLLSDXmlString(resp);
|
||||
return response;
|
||||
LLSDxmlEncode.AddEndMap(lsl);
|
||||
}
|
||||
|
||||
LLSDxmlEncode.AddEnd(lsl);
|
||||
return lsl.ToString();
|
||||
}
|
||||
|
||||
public string ResourceCostSelected(string request, string path,
|
||||
|
@ -1825,13 +1845,13 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
Dictionary<UUID,string> names = m_UserManager.GetUsersNames(ids);
|
||||
|
||||
StringBuilder lsl = new StringBuilder(names.Count * 256 + 256);
|
||||
LLSDxmlEncode.AddStartHeader(lsl);
|
||||
LLSDxmlEncode.AddStartMap(lsl);
|
||||
LLSDxmlEncode.AddStart(lsl);
|
||||
LLSDxmlEncode.AddMap(lsl);
|
||||
if(names.Count == 0)
|
||||
LLSDxmlEncode.AddEmpyArray("agents", lsl);
|
||||
else
|
||||
{
|
||||
LLSDxmlEncode.AddStartArray("agents", lsl);
|
||||
LLSDxmlEncode.AddArray("agents", lsl);
|
||||
|
||||
foreach (KeyValuePair<UUID,string> kvp in names)
|
||||
{
|
||||
|
@ -1846,7 +1866,7 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
if(parts[0] == "Unknown")
|
||||
continue;
|
||||
|
||||
LLSDxmlEncode.AddStartMap(lsl);
|
||||
LLSDxmlEncode.AddMap(lsl);
|
||||
LLSDxmlEncode.AddElem("display_name_next_update", DateTime.UtcNow.AddDays(8), lsl);
|
||||
LLSDxmlEncode.AddElem("display_name_expires", DateTime.UtcNow.AddMonths(1), lsl);
|
||||
LLSDxmlEncode.AddElem("display_name", kvp.Value, lsl);
|
||||
|
@ -1861,7 +1881,7 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
}
|
||||
|
||||
LLSDxmlEncode.AddEndMap(lsl);
|
||||
LLSDxmlEncode.AddEndHeader(lsl);
|
||||
LLSDxmlEncode.AddEnd(lsl);
|
||||
|
||||
// Full content request
|
||||
httpResponse.StatusCode = (int)System.Net.HttpStatusCode.OK;
|
||||
|
|
Loading…
Reference in New Issue