aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/LLSDxmlEncode.cs44
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs130
2 files changed, 111 insertions, 63 deletions
diff --git a/OpenSim/Framework/LLSDxmlEncode.cs b/OpenSim/Framework/LLSDxmlEncode.cs
index afa0214..e095363 100644
--- a/OpenSim/Framework/LLSDxmlEncode.cs
+++ b/OpenSim/Framework/LLSDxmlEncode.cs
@@ -40,7 +40,7 @@ namespace OpenSim.Framework
40 { 40 {
41 static readonly DateTime depoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); 41 static readonly DateTime depoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
42 42
43 public static void AddStartHeader(StringBuilder sb, bool addxmlversion = false) 43 public static void AddStart(StringBuilder sb, bool addxmlversion = false)
44 { 44 {
45 if(addxmlversion) 45 if(addxmlversion)
46 sb.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?><llsd>"); // legacy llsd xml name still valid 46 sb.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?><llsd>"); // legacy llsd xml name still valid
@@ -48,13 +48,13 @@ namespace OpenSim.Framework
48 sb.Append("<llsd>"); 48 sb.Append("<llsd>");
49 } 49 }
50 50
51 public static void AddEndHeader(StringBuilder sb) 51 public static void AddEnd(StringBuilder sb)
52 { 52 {
53 sb.Append("</llsd>"); 53 sb.Append("</llsd>");
54 } 54 }
55 55
56 // map == a list of key value pairs 56 // map == a list of key value pairs
57 public static void AddStartMap(StringBuilder sb) 57 public static void AddMap(StringBuilder sb)
58 { 58 {
59 sb.Append("<map>"); 59 sb.Append("<map>");
60 } 60 }
@@ -70,7 +70,7 @@ namespace OpenSim.Framework
70 } 70 }
71 71
72 // array == a list values 72 // array == a list values
73 public static void AddStartArray(StringBuilder sb) 73 public static void AddArray(StringBuilder sb)
74 { 74 {
75 sb.Append("<array>"); 75 sb.Append("<array>");
76 } 76 }
@@ -99,6 +99,18 @@ namespace OpenSim.Framework
99 sb.Append("<boolean />"); 99 sb.Append("<boolean />");
100 } 100 }
101 101
102 public static void AddElem(byte e, StringBuilder sb)
103 {
104 if(e == 0)
105 sb.Append("<integer />");
106 else
107 {
108 sb.Append("<integer>");
109 sb.Append(e.ToString());
110 sb.Append("</integer>");
111 }
112 }
113
102 public static void AddElem(int e, StringBuilder sb) 114 public static void AddElem(int e, StringBuilder sb)
103 { 115 {
104 if(e == 0) 116 if(e == 0)
@@ -171,7 +183,7 @@ namespace OpenSim.Framework
171 } 183 }
172 } 184 }
173 185
174 public static void AddURIElem(Uri e, StringBuilder sb) 186 public static void AddElem(Uri e, StringBuilder sb)
175 { 187 {
176 if(e == null) 188 if(e == null)
177 { 189 {
@@ -218,7 +230,7 @@ namespace OpenSim.Framework
218//************ key value ******************* 230//************ key value *******************
219// assumes name is a valid llsd key 231// assumes name is a valid llsd key
220 232
221 public static void AddStartMap(string name, StringBuilder sb) 233 public static void AddMap(string name, StringBuilder sb)
222 { 234 {
223 sb.Append("<key>"); 235 sb.Append("<key>");
224 sb.Append(name); 236 sb.Append(name);
@@ -233,7 +245,7 @@ namespace OpenSim.Framework
233 } 245 }
234 246
235 // array == a list values 247 // array == a list values
236 public static void AddStartArray(string name, StringBuilder sb) 248 public static void AddArray(string name, StringBuilder sb)
237 { 249 {
238 sb.Append("<key>"); 250 sb.Append("<key>");
239 sb.Append(name); 251 sb.Append(name);
@@ -267,6 +279,22 @@ namespace OpenSim.Framework
267 sb.Append("<boolean />"); 279 sb.Append("<boolean />");
268 } 280 }
269 281
282 public static void AddElem(string name, byte e, StringBuilder sb)
283 {
284 sb.Append("<key>");
285 sb.Append(name);
286 sb.Append("</key>");
287
288 if(e == 0)
289 sb.Append("<integer />");
290 else
291 {
292 sb.Append("<integer>");
293 sb.Append(e.ToString());
294 sb.Append("</integer>");
295 }
296 }
297
270 public static void AddElem(string name, int e, StringBuilder sb) 298 public static void AddElem(string name, int e, StringBuilder sb)
271 { 299 {
272 sb.Append("<key>"); 300 sb.Append("<key>");
@@ -363,7 +391,7 @@ namespace OpenSim.Framework
363 } 391 }
364 } 392 }
365 393
366 public static void AddURIElem(string name, Uri e, StringBuilder sb) 394 public static void AddElem(string name, Uri e, StringBuilder sb)
367 { 395 {
368 sb.Append("<key>"); 396 sb.Append("<key>");
369 sb.Append(name); 397 sb.Append(name);
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
index 85e5ec3..5c5d2b9 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
@@ -1376,30 +1376,37 @@ namespace OpenSim.Region.ClientStack.Linden
1376 IOSHttpResponse httpResponse) 1376 IOSHttpResponse httpResponse)
1377 { 1377 {
1378 OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request); 1378 OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request);
1379 OSDMap resp = new OSDMap();
1380 OSDArray object_ids = (OSDArray)req["object_ids"]; 1379 OSDArray object_ids = (OSDArray)req["object_ids"];
1381 1380
1382 for (int i = 0 ; i < object_ids.Count ; i++) 1381 StringBuilder lsl = new StringBuilder(256);
1382 LLSDxmlEncode.AddStart(lsl);
1383 if(object_ids.Count == 0)
1384 LLSDxmlEncode.AddEmpyMap(lsl);
1385 else
1383 { 1386 {
1384 UUID uuid = object_ids[i].AsUUID(); 1387 LLSDxmlEncode.AddMap(lsl);
1385 1388 for (int i = 0 ; i < object_ids.Count ; i++)
1386 SceneObjectPart obj = m_Scene.GetSceneObjectPart(uuid);
1387 if (obj != null)
1388 { 1389 {
1389 OSDMap object_data = new OSDMap(); 1390 UUID uuid = object_ids[i].AsUUID();
1391
1392 SceneObjectPart obj = m_Scene.GetSceneObjectPart(uuid);
1393 if (obj != null)
1394 {
1395 LLSDxmlEncode.AddMap(uuid.ToString(),lsl);
1390 1396
1391 object_data["PhysicsShapeType"] = obj.PhysicsShapeType; 1397 LLSDxmlEncode.AddElem("PhysicsShapeType", obj.PhysicsShapeType, lsl);
1392 object_data["Density"] = obj.Density; 1398 LLSDxmlEncode.AddElem("Density", obj.Density, lsl);
1393 object_data["Friction"] = obj.Friction; 1399 LLSDxmlEncode.AddElem("Friction", obj.Friction, lsl);
1394 object_data["Restitution"] = obj.Restitution; 1400 LLSDxmlEncode.AddElem("Restitution", obj.Restitution, lsl);
1395 object_data["GravityMultiplier"] = obj.GravityModifier; 1401 LLSDxmlEncode.AddElem("GravityMultiplier", obj.GravityModifier, lsl);
1396 1402
1397 resp[uuid.ToString()] = object_data; 1403 LLSDxmlEncode.AddEndMap(lsl);
1404 }
1405 LLSDxmlEncode.AddEndMap(lsl);
1398 } 1406 }
1399 } 1407 }
1400 1408 LLSDxmlEncode.AddEnd(lsl);
1401 string response = OSDParser.SerializeLLSDXmlString(resp); 1409 return lsl.ToString();
1402 return response;
1403 } 1410 }
1404 1411
1405 public string GetObjectCost(string request, string path, 1412 public string GetObjectCost(string request, string path,
@@ -1407,47 +1414,60 @@ namespace OpenSim.Region.ClientStack.Linden
1407 IOSHttpResponse httpResponse) 1414 IOSHttpResponse httpResponse)
1408 { 1415 {
1409 OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request); 1416 OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request);
1410 OSDMap resp = new OSDMap();
1411
1412 OSDArray object_ids = (OSDArray)req["object_ids"]; 1417 OSDArray object_ids = (OSDArray)req["object_ids"];
1413 1418
1414 for (int i = 0; i < object_ids.Count; i++) 1419 StringBuilder lsl = new StringBuilder(512);
1420 LLSDxmlEncode.AddStart(lsl);
1421 if(object_ids.Count == 0)
1422 LLSDxmlEncode.AddEmpyMap(lsl);
1423 else
1415 { 1424 {
1416 UUID uuid = object_ids[i].AsUUID(); 1425 bool haveone = false;
1426 LLSDxmlEncode.AddMap(lsl);
1427 for (int i = 0; i < object_ids.Count; i++)
1428 {
1429 UUID uuid = object_ids[i].AsUUID();
1430
1431 SceneObjectPart part = m_Scene.GetSceneObjectPart(uuid);
1432 SceneObjectGroup grp = null;
1433 if (part != null)
1434 grp = part.ParentGroup;
1435 if (grp != null)
1436 {
1437 haveone = true;
1438 float linksetCost;
1439 float linksetPhysCost;
1440 float partCost;
1441 float partPhysCost;
1417 1442
1418 SceneObjectPart part = m_Scene.GetSceneObjectPart(uuid); 1443 grp.GetResourcesCosts(part,out linksetCost,out linksetPhysCost,out partCost,out partPhysCost);
1419 SceneObjectGroup grp = null; 1444
1420 if (part != null) 1445 LLSDxmlEncode.AddMap(uuid.ToString(), lsl);
1421 grp = part.ParentGroup; 1446
1422 if (grp != null) 1447 LLSDxmlEncode.AddElem("linked_set_resource_cost", linksetCost, lsl);
1448 LLSDxmlEncode.AddElem("resource_cost", partCost, lsl);
1449 LLSDxmlEncode.AddElem("physics_cost", partPhysCost, lsl);
1450 LLSDxmlEncode.AddElem("linked_set_physics_cost", linksetPhysCost, lsl);
1451 LLSDxmlEncode.AddElem("resource_limiting_type", "legacy", lsl);
1452
1453 LLSDxmlEncode.AddEndMap(lsl);
1454 }
1455 }
1456 if(!haveone)
1423 { 1457 {
1424 float linksetCost; 1458 LLSDxmlEncode.AddMap(UUID.Zero.ToString(), lsl);
1425 float linksetPhysCost; 1459 LLSDxmlEncode.AddElem("linked_set_resource_cost", 0, lsl);
1426 float partCost; 1460 LLSDxmlEncode.AddElem("resource_cost", 0, lsl);
1427 float partPhysCost; 1461 LLSDxmlEncode.AddElem("physics_cost", 0, lsl);
1428 1462 LLSDxmlEncode.AddElem("linked_set_physics_cost", 0, lsl);
1429 grp.GetResourcesCosts(part,out linksetCost,out linksetPhysCost,out partCost,out partPhysCost); 1463 LLSDxmlEncode.AddElem("resource_limiting_type", "legacy", lsl);
1430 1464 LLSDxmlEncode.AddEndMap(lsl);
1431 OSDMap object_data = new OSDMap();
1432 object_data["linked_set_resource_cost"] = linksetCost;
1433 object_data["resource_cost"] = partCost;
1434 object_data["physics_cost"] = partPhysCost;
1435 object_data["linked_set_physics_cost"] = linksetPhysCost;
1436 object_data["resource_limiting_type"] = "legacy";
1437 resp[uuid.ToString()] = object_data;
1438 } 1465 }
1466 LLSDxmlEncode.AddEndMap(lsl);
1439 } 1467 }
1440 if(resp.Count == 0) 1468
1441 { 1469 LLSDxmlEncode.AddEnd(lsl);
1442 OSDMap object_data = new OSDMap(); 1470 return lsl.ToString();
1443 object_data["linked_set_resource_cost"] = 0;
1444 object_data["resource_cost"] = 0;
1445 object_data["physics_cost"] = 0;
1446 object_data["linked_set_physics_cost"] = 0;
1447 resp[UUID.Zero.ToString()] = object_data;
1448 }
1449 string response = OSDParser.SerializeLLSDXmlString(resp);
1450 return response;
1451 } 1471 }
1452 1472
1453 public string ResourceCostSelected(string request, string path, 1473 public string ResourceCostSelected(string request, string path,
@@ -1825,13 +1845,13 @@ namespace OpenSim.Region.ClientStack.Linden
1825 Dictionary<UUID,string> names = m_UserManager.GetUsersNames(ids); 1845 Dictionary<UUID,string> names = m_UserManager.GetUsersNames(ids);
1826 1846
1827 StringBuilder lsl = new StringBuilder(names.Count * 256 + 256); 1847 StringBuilder lsl = new StringBuilder(names.Count * 256 + 256);
1828 LLSDxmlEncode.AddStartHeader(lsl); 1848 LLSDxmlEncode.AddStart(lsl);
1829 LLSDxmlEncode.AddStartMap(lsl); 1849 LLSDxmlEncode.AddMap(lsl);
1830 if(names.Count == 0) 1850 if(names.Count == 0)
1831 LLSDxmlEncode.AddEmpyArray("agents", lsl); 1851 LLSDxmlEncode.AddEmpyArray("agents", lsl);
1832 else 1852 else
1833 { 1853 {
1834 LLSDxmlEncode.AddStartArray("agents", lsl); 1854 LLSDxmlEncode.AddArray("agents", lsl);
1835 1855
1836 foreach (KeyValuePair<UUID,string> kvp in names) 1856 foreach (KeyValuePair<UUID,string> kvp in names)
1837 { 1857 {
@@ -1846,7 +1866,7 @@ namespace OpenSim.Region.ClientStack.Linden
1846 if(parts[0] == "Unknown") 1866 if(parts[0] == "Unknown")
1847 continue; 1867 continue;
1848 1868
1849 LLSDxmlEncode.AddStartMap(lsl); 1869 LLSDxmlEncode.AddMap(lsl);
1850 LLSDxmlEncode.AddElem("display_name_next_update", DateTime.UtcNow.AddDays(8), lsl); 1870 LLSDxmlEncode.AddElem("display_name_next_update", DateTime.UtcNow.AddDays(8), lsl);
1851 LLSDxmlEncode.AddElem("display_name_expires", DateTime.UtcNow.AddMonths(1), lsl); 1871 LLSDxmlEncode.AddElem("display_name_expires", DateTime.UtcNow.AddMonths(1), lsl);
1852 LLSDxmlEncode.AddElem("display_name", kvp.Value, lsl); 1872 LLSDxmlEncode.AddElem("display_name", kvp.Value, lsl);
@@ -1861,7 +1881,7 @@ namespace OpenSim.Region.ClientStack.Linden
1861 } 1881 }
1862 1882
1863 LLSDxmlEncode.AddEndMap(lsl); 1883 LLSDxmlEncode.AddEndMap(lsl);
1864 LLSDxmlEncode.AddEndHeader(lsl); 1884 LLSDxmlEncode.AddEnd(lsl);
1865 1885
1866 // Full content request 1886 // Full content request
1867 httpResponse.StatusCode = (int)System.Net.HttpStatusCode.OK; 1887 httpResponse.StatusCode = (int)System.Net.HttpStatusCode.OK;