aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Capabilities/Handlers/GetDisplayNames/GetDisplayNamesHandler.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Capabilities/Handlers/GetDisplayNames/GetDisplayNamesHandler.cs')
-rw-r--r--OpenSim/Capabilities/Handlers/GetDisplayNames/GetDisplayNamesHandler.cs61
1 files changed, 29 insertions, 32 deletions
diff --git a/OpenSim/Capabilities/Handlers/GetDisplayNames/GetDisplayNamesHandler.cs b/OpenSim/Capabilities/Handlers/GetDisplayNames/GetDisplayNamesHandler.cs
index 589602d..41cfdb6 100644
--- a/OpenSim/Capabilities/Handlers/GetDisplayNames/GetDisplayNamesHandler.cs
+++ b/OpenSim/Capabilities/Handlers/GetDisplayNames/GetDisplayNamesHandler.cs
@@ -29,8 +29,6 @@ using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Collections.Specialized; 31using System.Collections.Specialized;
32using System.Drawing;
33using System.Drawing.Imaging;
34using System.Reflection; 32using System.Reflection;
35using System.IO; 33using System.IO;
36using System.Web; 34using System.Web;
@@ -38,12 +36,7 @@ using log4net;
38using Nini.Config; 36using Nini.Config;
39using OpenMetaverse; 37using OpenMetaverse;
40using OpenMetaverse.StructuredData; 38using OpenMetaverse.StructuredData;
41using OpenMetaverse.Imaging;
42using OpenSim.Framework;
43using OpenSim.Framework.Capabilities;
44using OpenSim.Framework.Servers;
45using OpenSim.Framework.Servers.HttpServer; 39using OpenSim.Framework.Servers.HttpServer;
46using OpenSim.Region.Framework.Interfaces;
47using OpenSim.Services.Interfaces; 40using OpenSim.Services.Interfaces;
48using Caps = OpenSim.Framework.Capabilities.Caps; 41using Caps = OpenSim.Framework.Capabilities.Caps;
49using OSDMap = OpenMetaverse.StructuredData.OSDMap; 42using OSDMap = OpenMetaverse.StructuredData.OSDMap;
@@ -55,7 +48,7 @@ namespace OpenSim.Capabilities.Handlers
55 { 48 {
56 private static readonly ILog m_log = 49 private static readonly ILog m_log =
57 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 50 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
58 private IUserManagement m_UserManagement; 51 protected IUserManagement m_UserManagement;
59 52
60 public GetDisplayNamesHandler(string path, IUserManagement umService, string name, string description) 53 public GetDisplayNamesHandler(string path, IUserManagement umService, string name, string description)
61 : base("GET", path, name, description) 54 : base("GET", path, name, description)
@@ -65,12 +58,11 @@ namespace OpenSim.Capabilities.Handlers
65 58
66 protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 59 protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
67 { 60 {
68 m_log.DebugFormat("[GET_DISPLAY_NAMES]: called {0}", httpRequest.Url.Query); 61// m_log.DebugFormat("[GET_DISPLAY_NAMES]: called {0}", httpRequest.Url.Query);
69 62
70 NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query); 63 NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query);
71 string[] ids = query.GetValues("ids"); 64 string[] ids = query.GetValues("ids");
72 65
73
74 if (m_UserManagement == null) 66 if (m_UserManagement == null)
75 { 67 {
76 m_log.Error("[GET_DISPLAY_NAMES]: Cannot fetch display names without a user management component"); 68 m_log.Error("[GET_DISPLAY_NAMES]: Cannot fetch display names without a user management component");
@@ -78,32 +70,39 @@ namespace OpenSim.Capabilities.Handlers
78 return new byte[0]; 70 return new byte[0];
79 } 71 }
80 72
73 Dictionary<UUID,string> names = m_UserManagement.GetUsersNames(ids);
74
81 OSDMap osdReply = new OSDMap(); 75 OSDMap osdReply = new OSDMap();
82 OSDArray agents = new OSDArray(); 76 OSDArray agents = new OSDArray();
83 77
84 osdReply["agents"] = agents; 78 osdReply["agents"] = agents;
85 foreach (string id in ids) 79 foreach (KeyValuePair<UUID,string> kvp in names)
86 { 80 {
87 UUID uuid = UUID.Zero; 81 if (string.IsNullOrEmpty(kvp.Value))
88 if (UUID.TryParse(id, out uuid)) 82 continue;
89 { 83 if(kvp.Key == UUID.Zero)
90 string name = m_UserManagement.GetUserName(uuid); 84 continue;
91 if (!string.IsNullOrEmpty(name))
92 {
93 string[] parts = name.Split(new char[] {' '});
94 OSDMap osdname = new OSDMap();
95 osdname["display_name_next_update"] = OSD.FromDate(DateTime.MinValue);
96 osdname["display_name_expires"] = OSD.FromDate(DateTime.Now.AddMonths(1));
97 osdname["display_name"] = OSD.FromString(name);
98 osdname["legacy_first_name"] = parts[0];
99 osdname["legacy_last_name"] = parts[1];
100 osdname["username"] = OSD.FromString(name);
101 osdname["id"] = OSD.FromUUID(uuid);
102 osdname["is_display_name_default"] = OSD.FromBoolean(true);
103 85
104 agents.Add(osdname); 86 string[] parts = kvp.Value.Split(new char[] {' '});
105 } 87 OSDMap osdname = new OSDMap();
88 if(parts[0] == "Unknown")
89 {
90 osdname["display_name_next_update"] = OSD.FromDate(DateTime.UtcNow.AddHours(1));
91 osdname["display_name_expires"] = OSD.FromDate(DateTime.UtcNow.AddHours(2));
106 } 92 }
93 else
94 {
95 osdname["display_name_next_update"] = OSD.FromDate(DateTime.UtcNow.AddDays(8));
96 osdname["display_name_expires"] = OSD.FromDate(DateTime.UtcNow.AddMonths(1));
97 }
98 osdname["display_name"] = OSD.FromString(kvp.Value);
99 osdname["legacy_first_name"] = parts[0];
100 osdname["legacy_last_name"] = parts[1];
101 osdname["username"] = OSD.FromString(kvp.Value);
102 osdname["id"] = OSD.FromUUID(kvp.Key);
103 osdname["is_display_name_default"] = OSD.FromBoolean(true);
104
105 agents.Add(osdname);
107 } 106 }
108 107
109 // Full content request 108 // Full content request
@@ -113,8 +112,6 @@ namespace OpenSim.Capabilities.Handlers
113 112
114 string reply = OSDParser.SerializeLLSDXmlString(osdReply); 113 string reply = OSDParser.SerializeLLSDXmlString(osdReply);
115 return System.Text.Encoding.UTF8.GetBytes(reply); 114 return System.Text.Encoding.UTF8.GetBytes(reply);
116
117 } 115 }
118
119 } 116 }
120} \ No newline at end of file 117}