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);
|
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)
|
if(addxmlversion)
|
||||||
sb.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?><llsd>"); // legacy llsd xml name still valid
|
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>");
|
sb.Append("<llsd>");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void AddEndHeader(StringBuilder sb)
|
public static void AddEnd(StringBuilder sb)
|
||||||
{
|
{
|
||||||
sb.Append("</llsd>");
|
sb.Append("</llsd>");
|
||||||
}
|
}
|
||||||
|
|
||||||
// map == a list of key value pairs
|
// map == a list of key value pairs
|
||||||
public static void AddStartMap(StringBuilder sb)
|
public static void AddMap(StringBuilder sb)
|
||||||
{
|
{
|
||||||
sb.Append("<map>");
|
sb.Append("<map>");
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ namespace OpenSim.Framework
|
||||||
}
|
}
|
||||||
|
|
||||||
// array == a list values
|
// array == a list values
|
||||||
public static void AddStartArray(StringBuilder sb)
|
public static void AddArray(StringBuilder sb)
|
||||||
{
|
{
|
||||||
sb.Append("<array>");
|
sb.Append("<array>");
|
||||||
}
|
}
|
||||||
|
@ -99,6 +99,18 @@ namespace OpenSim.Framework
|
||||||
sb.Append("<boolean />");
|
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)
|
public static void AddElem(int e, StringBuilder sb)
|
||||||
{
|
{
|
||||||
if(e == 0)
|
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)
|
if(e == null)
|
||||||
{
|
{
|
||||||
|
@ -218,7 +230,7 @@ namespace OpenSim.Framework
|
||||||
//************ key value *******************
|
//************ key value *******************
|
||||||
// assumes name is a valid llsd key
|
// 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("<key>");
|
||||||
sb.Append(name);
|
sb.Append(name);
|
||||||
|
@ -233,7 +245,7 @@ namespace OpenSim.Framework
|
||||||
}
|
}
|
||||||
|
|
||||||
// array == a list values
|
// 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("<key>");
|
||||||
sb.Append(name);
|
sb.Append(name);
|
||||||
|
@ -267,6 +279,22 @@ namespace OpenSim.Framework
|
||||||
sb.Append("<boolean />");
|
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)
|
public static void AddElem(string name, int e, StringBuilder sb)
|
||||||
{
|
{
|
||||||
sb.Append("<key>");
|
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("<key>");
|
||||||
sb.Append(name);
|
sb.Append(name);
|
||||||
|
|
|
@ -1376,30 +1376,37 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
IOSHttpResponse httpResponse)
|
IOSHttpResponse httpResponse)
|
||||||
{
|
{
|
||||||
OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request);
|
OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request);
|
||||||
OSDMap resp = new OSDMap();
|
|
||||||
OSDArray object_ids = (OSDArray)req["object_ids"];
|
OSDArray object_ids = (OSDArray)req["object_ids"];
|
||||||
|
|
||||||
for (int i = 0 ; i < object_ids.Count ; i++)
|
StringBuilder lsl = new StringBuilder(256);
|
||||||
|
LLSDxmlEncode.AddStart(lsl);
|
||||||
|
if(object_ids.Count == 0)
|
||||||
|
LLSDxmlEncode.AddEmpyMap(lsl);
|
||||||
|
else
|
||||||
{
|
{
|
||||||
UUID uuid = object_ids[i].AsUUID();
|
LLSDxmlEncode.AddMap(lsl);
|
||||||
|
for (int i = 0 ; i < object_ids.Count ; i++)
|
||||||
SceneObjectPart obj = m_Scene.GetSceneObjectPart(uuid);
|
|
||||||
if (obj != null)
|
|
||||||
{
|
{
|
||||||
OSDMap object_data = new OSDMap();
|
UUID uuid = object_ids[i].AsUUID();
|
||||||
|
|
||||||
object_data["PhysicsShapeType"] = obj.PhysicsShapeType;
|
SceneObjectPart obj = m_Scene.GetSceneObjectPart(uuid);
|
||||||
object_data["Density"] = obj.Density;
|
if (obj != null)
|
||||||
object_data["Friction"] = obj.Friction;
|
{
|
||||||
object_data["Restitution"] = obj.Restitution;
|
LLSDxmlEncode.AddMap(uuid.ToString(),lsl);
|
||||||
object_data["GravityMultiplier"] = obj.GravityModifier;
|
|
||||||
|
|
||||||
resp[uuid.ToString()] = object_data;
|
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);
|
||||||
|
|
||||||
|
LLSDxmlEncode.AddEndMap(lsl);
|
||||||
|
}
|
||||||
|
LLSDxmlEncode.AddEndMap(lsl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
LLSDxmlEncode.AddEnd(lsl);
|
||||||
string response = OSDParser.SerializeLLSDXmlString(resp);
|
return lsl.ToString();
|
||||||
return response;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetObjectCost(string request, string path,
|
public string GetObjectCost(string request, string path,
|
||||||
|
@ -1407,47 +1414,60 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
IOSHttpResponse httpResponse)
|
IOSHttpResponse httpResponse)
|
||||||
{
|
{
|
||||||
OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request);
|
OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request);
|
||||||
OSDMap resp = new OSDMap();
|
|
||||||
|
|
||||||
OSDArray object_ids = (OSDArray)req["object_ids"];
|
OSDArray object_ids = (OSDArray)req["object_ids"];
|
||||||
|
|
||||||
for (int i = 0; i < object_ids.Count; i++)
|
StringBuilder lsl = new StringBuilder(512);
|
||||||
|
LLSDxmlEncode.AddStart(lsl);
|
||||||
|
if(object_ids.Count == 0)
|
||||||
|
LLSDxmlEncode.AddEmpyMap(lsl);
|
||||||
|
else
|
||||||
{
|
{
|
||||||
UUID uuid = object_ids[i].AsUUID();
|
bool haveone = false;
|
||||||
|
LLSDxmlEncode.AddMap(lsl);
|
||||||
SceneObjectPart part = m_Scene.GetSceneObjectPart(uuid);
|
for (int i = 0; i < object_ids.Count; i++)
|
||||||
SceneObjectGroup grp = null;
|
|
||||||
if (part != null)
|
|
||||||
grp = part.ParentGroup;
|
|
||||||
if (grp != null)
|
|
||||||
{
|
{
|
||||||
float linksetCost;
|
UUID uuid = object_ids[i].AsUUID();
|
||||||
float linksetPhysCost;
|
|
||||||
float partCost;
|
|
||||||
float partPhysCost;
|
|
||||||
|
|
||||||
grp.GetResourcesCosts(part,out linksetCost,out linksetPhysCost,out partCost,out partPhysCost);
|
SceneObjectPart part = m_Scene.GetSceneObjectPart(uuid);
|
||||||
|
SceneObjectGroup grp = null;
|
||||||
|
if (part != null)
|
||||||
|
grp = part.ParentGroup;
|
||||||
|
if (grp != null)
|
||||||
|
{
|
||||||
|
haveone = true;
|
||||||
|
float linksetCost;
|
||||||
|
float linksetPhysCost;
|
||||||
|
float partCost;
|
||||||
|
float partPhysCost;
|
||||||
|
|
||||||
OSDMap object_data = new OSDMap();
|
grp.GetResourcesCosts(part,out linksetCost,out linksetPhysCost,out partCost,out partPhysCost);
|
||||||
object_data["linked_set_resource_cost"] = linksetCost;
|
|
||||||
object_data["resource_cost"] = partCost;
|
LLSDxmlEncode.AddMap(uuid.ToString(), lsl);
|
||||||
object_data["physics_cost"] = partPhysCost;
|
|
||||||
object_data["linked_set_physics_cost"] = linksetPhysCost;
|
LLSDxmlEncode.AddElem("linked_set_resource_cost", linksetCost, lsl);
|
||||||
object_data["resource_limiting_type"] = "legacy";
|
LLSDxmlEncode.AddElem("resource_cost", partCost, lsl);
|
||||||
resp[uuid.ToString()] = object_data;
|
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(!haveone)
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
LLSDxmlEncode.AddEndMap(lsl);
|
||||||
}
|
}
|
||||||
if(resp.Count == 0)
|
|
||||||
{
|
LLSDxmlEncode.AddEnd(lsl);
|
||||||
OSDMap object_data = new OSDMap();
|
return lsl.ToString();
|
||||||
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;
|
|
||||||
}
|
|
||||||
string response = OSDParser.SerializeLLSDXmlString(resp);
|
|
||||||
return response;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string ResourceCostSelected(string request, string path,
|
public string ResourceCostSelected(string request, string path,
|
||||||
|
@ -1825,13 +1845,13 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
Dictionary<UUID,string> names = m_UserManager.GetUsersNames(ids);
|
Dictionary<UUID,string> names = m_UserManager.GetUsersNames(ids);
|
||||||
|
|
||||||
StringBuilder lsl = new StringBuilder(names.Count * 256 + 256);
|
StringBuilder lsl = new StringBuilder(names.Count * 256 + 256);
|
||||||
LLSDxmlEncode.AddStartHeader(lsl);
|
LLSDxmlEncode.AddStart(lsl);
|
||||||
LLSDxmlEncode.AddStartMap(lsl);
|
LLSDxmlEncode.AddMap(lsl);
|
||||||
if(names.Count == 0)
|
if(names.Count == 0)
|
||||||
LLSDxmlEncode.AddEmpyArray("agents", lsl);
|
LLSDxmlEncode.AddEmpyArray("agents", lsl);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LLSDxmlEncode.AddStartArray("agents", lsl);
|
LLSDxmlEncode.AddArray("agents", lsl);
|
||||||
|
|
||||||
foreach (KeyValuePair<UUID,string> kvp in names)
|
foreach (KeyValuePair<UUID,string> kvp in names)
|
||||||
{
|
{
|
||||||
|
@ -1846,7 +1866,7 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
if(parts[0] == "Unknown")
|
if(parts[0] == "Unknown")
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
LLSDxmlEncode.AddStartMap(lsl);
|
LLSDxmlEncode.AddMap(lsl);
|
||||||
LLSDxmlEncode.AddElem("display_name_next_update", DateTime.UtcNow.AddDays(8), 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_expires", DateTime.UtcNow.AddMonths(1), lsl);
|
||||||
LLSDxmlEncode.AddElem("display_name", kvp.Value, lsl);
|
LLSDxmlEncode.AddElem("display_name", kvp.Value, lsl);
|
||||||
|
@ -1861,7 +1881,7 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
}
|
}
|
||||||
|
|
||||||
LLSDxmlEncode.AddEndMap(lsl);
|
LLSDxmlEncode.AddEndMap(lsl);
|
||||||
LLSDxmlEncode.AddEndHeader(lsl);
|
LLSDxmlEncode.AddEnd(lsl);
|
||||||
|
|
||||||
// Full content request
|
// Full content request
|
||||||
httpResponse.StatusCode = (int)System.Net.HttpStatusCode.OK;
|
httpResponse.StatusCode = (int)System.Net.HttpStatusCode.OK;
|
||||||
|
|
Loading…
Reference in New Issue