diff options
author | UbitUmarov | 2018-01-25 09:06:39 +0000 |
---|---|---|
committer | UbitUmarov | 2018-01-25 09:06:39 +0000 |
commit | 98019031dfc8934be2feb92c99c514307b1ca159 (patch) | |
tree | 52db021c534ecd48f5a295c29b8debf79bb4ae6b /OpenSim | |
parent | a few changes to encoder and a few more uses (diff) | |
download | opensim-SC-98019031dfc8934be2feb92c99c514307b1ca159.zip opensim-SC-98019031dfc8934be2feb92c99c514307b1ca159.tar.gz opensim-SC-98019031dfc8934be2feb92c99c514307b1ca159.tar.bz2 opensim-SC-98019031dfc8934be2feb92c99c514307b1ca159.tar.xz |
got tired of creating stringbuilders
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Framework/LLSDxmlEncode.cs | 18 | ||||
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 53 |
2 files changed, 43 insertions, 28 deletions
diff --git a/OpenSim/Framework/LLSDxmlEncode.cs b/OpenSim/Framework/LLSDxmlEncode.cs index e095363..5447963 100644 --- a/OpenSim/Framework/LLSDxmlEncode.cs +++ b/OpenSim/Framework/LLSDxmlEncode.cs | |||
@@ -48,11 +48,28 @@ namespace OpenSim.Framework | |||
48 | sb.Append("<llsd>"); | 48 | sb.Append("<llsd>"); |
49 | } | 49 | } |
50 | 50 | ||
51 | // got tired of creating a stringbuilder all the time; | ||
52 | public static StringBuilder Start(int size = 256, bool addxmlversion = false) | ||
53 | { | ||
54 | StringBuilder sb = new StringBuilder(size); | ||
55 | if(addxmlversion) | ||
56 | sb.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?><llsd>"); // legacy llsd xml name still valid | ||
57 | else | ||
58 | sb.Append("<llsd>"); | ||
59 | return sb; | ||
60 | } | ||
61 | |||
51 | public static void AddEnd(StringBuilder sb) | 62 | public static void AddEnd(StringBuilder sb) |
52 | { | 63 | { |
53 | sb.Append("</llsd>"); | 64 | sb.Append("</llsd>"); |
54 | } | 65 | } |
55 | 66 | ||
67 | public static string End(StringBuilder sb) | ||
68 | { | ||
69 | sb.Append("</llsd>"); | ||
70 | return sb.ToString(); | ||
71 | } | ||
72 | |||
56 | // map == a list of key value pairs | 73 | // map == a list of key value pairs |
57 | public static void AddMap(StringBuilder sb) | 74 | public static void AddMap(StringBuilder sb) |
58 | { | 75 | { |
@@ -452,7 +469,6 @@ namespace OpenSim.Framework | |||
452 | { | 469 | { |
453 | int i; | 470 | int i; |
454 | char c; | 471 | char c; |
455 | String t; | ||
456 | int len = s.Length; | 472 | int len = s.Length; |
457 | 473 | ||
458 | for (i = 0; i < len; i++) | 474 | for (i = 0; i < len; i++) |
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 5c5d2b9..bbfe68c 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | |||
@@ -1378,8 +1378,8 @@ namespace OpenSim.Region.ClientStack.Linden | |||
1378 | OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request); | 1378 | OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request); |
1379 | OSDArray object_ids = (OSDArray)req["object_ids"]; | 1379 | OSDArray object_ids = (OSDArray)req["object_ids"]; |
1380 | 1380 | ||
1381 | StringBuilder lsl = new StringBuilder(256); | 1381 | StringBuilder lsl = LLSDxmlEncode.Start(); |
1382 | LLSDxmlEncode.AddStart(lsl); | 1382 | |
1383 | if(object_ids.Count == 0) | 1383 | if(object_ids.Count == 0) |
1384 | LLSDxmlEncode.AddEmpyMap(lsl); | 1384 | LLSDxmlEncode.AddEmpyMap(lsl); |
1385 | else | 1385 | else |
@@ -1405,8 +1405,8 @@ namespace OpenSim.Region.ClientStack.Linden | |||
1405 | LLSDxmlEncode.AddEndMap(lsl); | 1405 | LLSDxmlEncode.AddEndMap(lsl); |
1406 | } | 1406 | } |
1407 | } | 1407 | } |
1408 | LLSDxmlEncode.AddEnd(lsl); | 1408 | |
1409 | return lsl.ToString(); | 1409 | return LLSDxmlEncode.End(lsl); |
1410 | } | 1410 | } |
1411 | 1411 | ||
1412 | public string GetObjectCost(string request, string path, | 1412 | public string GetObjectCost(string request, string path, |
@@ -1416,8 +1416,8 @@ namespace OpenSim.Region.ClientStack.Linden | |||
1416 | OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request); | 1416 | OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request); |
1417 | OSDArray object_ids = (OSDArray)req["object_ids"]; | 1417 | OSDArray object_ids = (OSDArray)req["object_ids"]; |
1418 | 1418 | ||
1419 | StringBuilder lsl = new StringBuilder(512); | 1419 | StringBuilder lsl = LLSDxmlEncode.Start(512); |
1420 | LLSDxmlEncode.AddStart(lsl); | 1420 | |
1421 | if(object_ids.Count == 0) | 1421 | if(object_ids.Count == 0) |
1422 | LLSDxmlEncode.AddEmpyMap(lsl); | 1422 | LLSDxmlEncode.AddEmpyMap(lsl); |
1423 | else | 1423 | else |
@@ -1466,8 +1466,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
1466 | LLSDxmlEncode.AddEndMap(lsl); | 1466 | LLSDxmlEncode.AddEndMap(lsl); |
1467 | } | 1467 | } |
1468 | 1468 | ||
1469 | LLSDxmlEncode.AddEnd(lsl); | 1469 | return LLSDxmlEncode.End(lsl); |
1470 | return lsl.ToString(); | ||
1471 | } | 1470 | } |
1472 | 1471 | ||
1473 | public string ResourceCostSelected(string request, string path, | 1472 | public string ResourceCostSelected(string request, string path, |
@@ -1475,8 +1474,6 @@ namespace OpenSim.Region.ClientStack.Linden | |||
1475 | IOSHttpResponse httpResponse) | 1474 | IOSHttpResponse httpResponse) |
1476 | { | 1475 | { |
1477 | OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request); | 1476 | OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request); |
1478 | OSDMap resp = new OSDMap(); | ||
1479 | |||
1480 | 1477 | ||
1481 | float phys=0; | 1478 | float phys=0; |
1482 | float stream=0; | 1479 | float stream=0; |
@@ -1527,16 +1524,21 @@ namespace OpenSim.Region.ClientStack.Linden | |||
1527 | } | 1524 | } |
1528 | } | 1525 | } |
1529 | 1526 | ||
1530 | OSDMap object_data = new OSDMap(); | 1527 | StringBuilder lsl = LLSDxmlEncode.Start(); |
1528 | LLSDxmlEncode.AddMap(lsl); | ||
1531 | 1529 | ||
1532 | object_data["physics"] = phys; | 1530 | LLSDxmlEncode.AddMap("selected", lsl); |
1533 | object_data["streaming"] = stream; | ||
1534 | object_data["simulation"] = simul; | ||
1535 | 1531 | ||
1536 | resp["selected"] = object_data; | 1532 | LLSDxmlEncode.AddElem("physics", phys, lsl); |
1533 | LLSDxmlEncode.AddElem("streaming", stream, lsl); | ||
1534 | LLSDxmlEncode.AddElem("simulation", simul, lsl); | ||
1535 | |||
1536 | LLSDxmlEncode.AddEndMap(lsl); | ||
1537 | LLSDxmlEncode.AddEndMap(lsl); | ||
1538 | |||
1537 | // resp["transaction_id"] = "undef"; | 1539 | // resp["transaction_id"] = "undef"; |
1538 | string response = OSDParser.SerializeLLSDXmlString(resp); | 1540 | return LLSDxmlEncode.End(lsl); |
1539 | return response; | 1541 | |
1540 | } | 1542 | } |
1541 | 1543 | ||
1542 | public string UpdateAgentInformation(string request, string path, | 1544 | public string UpdateAgentInformation(string request, string path, |
@@ -1839,13 +1841,17 @@ namespace OpenSim.Region.ClientStack.Linden | |||
1839 | return ""; | 1841 | return ""; |
1840 | } | 1842 | } |
1841 | 1843 | ||
1844 | // Full content request | ||
1845 | httpResponse.StatusCode = (int)System.Net.HttpStatusCode.OK; | ||
1846 | //httpResponse.ContentLength = ??; | ||
1847 | httpResponse.ContentType = "application/llsd+xml"; | ||
1848 | |||
1842 | NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query); | 1849 | NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query); |
1843 | string[] ids = query.GetValues("ids"); | 1850 | string[] ids = query.GetValues("ids"); |
1844 | 1851 | ||
1845 | Dictionary<UUID,string> names = m_UserManager.GetUsersNames(ids); | 1852 | Dictionary<UUID,string> names = m_UserManager.GetUsersNames(ids); |
1846 | 1853 | ||
1847 | StringBuilder lsl = new StringBuilder(names.Count * 256 + 256); | 1854 | StringBuilder lsl = LLSDxmlEncode.Start(names.Count * 256 + 256); |
1848 | LLSDxmlEncode.AddStart(lsl); | ||
1849 | LLSDxmlEncode.AddMap(lsl); | 1855 | LLSDxmlEncode.AddMap(lsl); |
1850 | if(names.Count == 0) | 1856 | if(names.Count == 0) |
1851 | LLSDxmlEncode.AddEmpyArray("agents", lsl); | 1857 | LLSDxmlEncode.AddEmpyArray("agents", lsl); |
@@ -1881,14 +1887,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
1881 | } | 1887 | } |
1882 | 1888 | ||
1883 | LLSDxmlEncode.AddEndMap(lsl); | 1889 | LLSDxmlEncode.AddEndMap(lsl); |
1884 | LLSDxmlEncode.AddEnd(lsl); | 1890 | return LLSDxmlEncode.End(lsl);; |
1885 | |||
1886 | // Full content request | ||
1887 | httpResponse.StatusCode = (int)System.Net.HttpStatusCode.OK; | ||
1888 | //httpResponse.ContentLength = ??; | ||
1889 | httpResponse.ContentType = "application/llsd+xml"; | ||
1890 | |||
1891 | return lsl.ToString(); | ||
1892 | } | 1891 | } |
1893 | } | 1892 | } |
1894 | 1893 | ||