diff options
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 60bfaa5..f96ae8b 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | |||
@@ -29,9 +29,11 @@ using System; | |||
29 | using System.Timers; | 29 | using System.Timers; |
30 | using System.Collections; | 30 | using System.Collections; |
31 | using System.Collections.Generic; | 31 | using System.Collections.Generic; |
32 | using System.Collections.Specialized; | ||
32 | using System.IO; | 33 | using System.IO; |
33 | using System.Reflection; | 34 | using System.Reflection; |
34 | using System.Text; | 35 | using System.Text; |
36 | using System.Web; | ||
35 | 37 | ||
36 | using OpenMetaverse; | 38 | using OpenMetaverse; |
37 | using OpenMetaverse.StructuredData; | 39 | using OpenMetaverse.StructuredData; |
@@ -125,6 +127,8 @@ namespace OpenSim.Region.ClientStack.Linden | |||
125 | 127 | ||
126 | private bool m_AllowCapHomeLocation = true; | 128 | private bool m_AllowCapHomeLocation = true; |
127 | private bool m_AllowCapGroupMemberData = true; | 129 | private bool m_AllowCapGroupMemberData = true; |
130 | private IUserManagement m_UserManager; | ||
131 | |||
128 | 132 | ||
129 | private enum FileAgentInventoryState : int | 133 | private enum FileAgentInventoryState : int |
130 | { | 134 | { |
@@ -196,6 +200,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
196 | 200 | ||
197 | m_assetService = m_Scene.AssetService; | 201 | m_assetService = m_Scene.AssetService; |
198 | m_regionName = m_Scene.RegionInfo.RegionName; | 202 | m_regionName = m_Scene.RegionInfo.RegionName; |
203 | m_UserManager = m_Scene.RequestModuleInterface<IUserManagement>(); | ||
199 | 204 | ||
200 | RegisterHandlers(); | 205 | RegisterHandlers(); |
201 | 206 | ||
@@ -229,6 +234,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
229 | 234 | ||
230 | RegisterRegionServiceHandlers(); | 235 | RegisterRegionServiceHandlers(); |
231 | RegisterInventoryServiceHandlers(); | 236 | RegisterInventoryServiceHandlers(); |
237 | RegisterOtherHandlers(); | ||
232 | } | 238 | } |
233 | 239 | ||
234 | public void RegisterRegionServiceHandlers() | 240 | public void RegisterRegionServiceHandlers() |
@@ -314,6 +320,19 @@ namespace OpenSim.Region.ClientStack.Linden | |||
314 | } | 320 | } |
315 | } | 321 | } |
316 | 322 | ||
323 | public void RegisterOtherHandlers() | ||
324 | { | ||
325 | try | ||
326 | { | ||
327 | IRequestHandler GetDisplayNamesHandler = new RestStreamHandler( | ||
328 | "GET", GetNewCapPath(), GetDisplayNames, "GetDisplayNames", null); | ||
329 | m_HostCapsObj.RegisterHandler("GetDisplayNames", GetDisplayNamesHandler); | ||
330 | } | ||
331 | catch (Exception e) | ||
332 | { | ||
333 | m_log.Error("[CAPS]: " + e.ToString()); | ||
334 | } | ||
335 | } | ||
317 | /// <summary> | 336 | /// <summary> |
318 | /// Construct a client response detailing all the capabilities this server can provide. | 337 | /// Construct a client response detailing all the capabilities this server can provide. |
319 | /// </summary> | 338 | /// </summary> |
@@ -1794,6 +1813,71 @@ namespace OpenSim.Region.ClientStack.Linden | |||
1794 | response = OSDParser.SerializeLLSDXmlString(resp); | 1813 | response = OSDParser.SerializeLLSDXmlString(resp); |
1795 | return response; | 1814 | return response; |
1796 | } | 1815 | } |
1816 | |||
1817 | public string GetDisplayNames(string request, string path, | ||
1818 | string param, IOSHttpRequest httpRequest, | ||
1819 | IOSHttpResponse httpResponse) | ||
1820 | { | ||
1821 | httpResponse.StatusCode = (int)System.Net.HttpStatusCode.NoContent; | ||
1822 | httpResponse.ContentType = "text/plain"; | ||
1823 | |||
1824 | ScenePresence sp = m_Scene.GetScenePresence(m_AgentID); | ||
1825 | if(sp == null || sp.IsDeleted) | ||
1826 | return ""; | ||
1827 | |||
1828 | NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query); | ||
1829 | string[] ids = query.GetValues("ids"); | ||
1830 | |||
1831 | if (m_UserManager == null) | ||
1832 | { | ||
1833 | m_log.Error("[GET_DISPLAY_NAMES]: Cannot fetch display names without a user management component"); | ||
1834 | httpResponse.StatusCode = (int)System.Net.HttpStatusCode.InternalServerError; | ||
1835 | return ""; | ||
1836 | } | ||
1837 | |||
1838 | Dictionary<UUID,string> names = m_UserManager.GetUsersNames(ids); | ||
1839 | |||
1840 | OSDMap osdReply = new OSDMap(); | ||
1841 | OSDArray agents = new OSDArray(); | ||
1842 | |||
1843 | osdReply["agents"] = agents; | ||
1844 | foreach (KeyValuePair<UUID,string> kvp in names) | ||
1845 | { | ||
1846 | if (string.IsNullOrEmpty(kvp.Value)) | ||
1847 | continue; | ||
1848 | if(kvp.Key == UUID.Zero) | ||
1849 | continue; | ||
1850 | |||
1851 | string[] parts = kvp.Value.Split(new char[] {' '}); | ||
1852 | OSDMap osdname = new OSDMap(); | ||
1853 | if(parts[0] == "Unknown") | ||
1854 | { | ||
1855 | osdname["display_name_next_update"] = OSD.FromDate(DateTime.UtcNow.AddHours(1)); | ||
1856 | osdname["display_name_expires"] = OSD.FromDate(DateTime.UtcNow.AddHours(2)); | ||
1857 | } | ||
1858 | else | ||
1859 | { | ||
1860 | osdname["display_name_next_update"] = OSD.FromDate(DateTime.UtcNow.AddDays(8)); | ||
1861 | osdname["display_name_expires"] = OSD.FromDate(DateTime.UtcNow.AddMonths(1)); | ||
1862 | } | ||
1863 | osdname["display_name"] = OSD.FromString(kvp.Value); | ||
1864 | osdname["legacy_first_name"] = parts[0]; | ||
1865 | osdname["legacy_last_name"] = parts[1]; | ||
1866 | osdname["username"] = OSD.FromString(kvp.Value); | ||
1867 | osdname["id"] = OSD.FromUUID(kvp.Key); | ||
1868 | osdname["is_display_name_default"] = OSD.FromBoolean(true); | ||
1869 | |||
1870 | agents.Add(osdname); | ||
1871 | } | ||
1872 | |||
1873 | // Full content request | ||
1874 | httpResponse.StatusCode = (int)System.Net.HttpStatusCode.OK; | ||
1875 | //httpResponse.ContentLength = ??; | ||
1876 | httpResponse.ContentType = "application/llsd+xml"; | ||
1877 | |||
1878 | string reply = OSDParser.SerializeLLSDXmlString(osdReply); | ||
1879 | return reply; | ||
1880 | } | ||
1797 | } | 1881 | } |
1798 | 1882 | ||
1799 | public class AssetUploader | 1883 | public class AssetUploader |