aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Capabilities/Handlers/GetDisplayNames/GetDisplayNamesHandler.cs58
-rw-r--r--OpenSim/Capabilities/Handlers/GetDisplayNames/GetDisplayNamesServerConnector.cs2
-rw-r--r--OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs116
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs2
-rw-r--r--OpenSim/Services/Interfaces/IUserManagement.cs1
5 files changed, 143 insertions, 36 deletions
diff --git a/OpenSim/Capabilities/Handlers/GetDisplayNames/GetDisplayNamesHandler.cs b/OpenSim/Capabilities/Handlers/GetDisplayNames/GetDisplayNamesHandler.cs
index 155196c..3e01bbb 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;
@@ -70,7 +63,6 @@ namespace OpenSim.Capabilities.Handlers
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,35 +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 // a date that is valid
96// osdname["display_name_next_update"] = OSD.FromDate(new DateTime(1970,1,1));
97 // but send one that blocks edition, since we actually don't suport this
98 osdname["display_name_next_update"] = OSD.FromDate(DateTime.UtcNow.AddDays(8));
99 osdname["display_name_expires"] = OSD.FromDate(DateTime.UtcNow.AddMonths(1));
100 osdname["display_name"] = OSD.FromString(name);
101 osdname["legacy_first_name"] = parts[0];
102 osdname["legacy_last_name"] = parts[1];
103 osdname["username"] = OSD.FromString(name);
104 osdname["id"] = OSD.FromUUID(uuid);
105 osdname["is_display_name_default"] = OSD.FromBoolean(true);
106 85
107 agents.Add(osdname); 86 string[] parts = kvp.Value.Split(new char[] {' '});
108 } 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));
109 } 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);
110 } 106 }
111 107
112 // Full content request 108 // Full content request
@@ -116,8 +112,6 @@ namespace OpenSim.Capabilities.Handlers
116 112
117 string reply = OSDParser.SerializeLLSDXmlString(osdReply); 113 string reply = OSDParser.SerializeLLSDXmlString(osdReply);
118 return System.Text.Encoding.UTF8.GetBytes(reply); 114 return System.Text.Encoding.UTF8.GetBytes(reply);
119
120 } 115 }
121
122 } 116 }
123} 117}
diff --git a/OpenSim/Capabilities/Handlers/GetDisplayNames/GetDisplayNamesServerConnector.cs b/OpenSim/Capabilities/Handlers/GetDisplayNames/GetDisplayNamesServerConnector.cs
index d42de56..8f70c97 100644
--- a/OpenSim/Capabilities/Handlers/GetDisplayNames/GetDisplayNamesServerConnector.cs
+++ b/OpenSim/Capabilities/Handlers/GetDisplayNames/GetDisplayNamesServerConnector.cs
@@ -61,8 +61,6 @@ namespace OpenSim.Capabilities.Handlers
61 61
62 if (m_UserManagement == null) 62 if (m_UserManagement == null)
63 throw new Exception(String.Format("Failed to load UserManagement from {0}; config is {1}", umService, m_ConfigName)); 63 throw new Exception(String.Format("Failed to load UserManagement from {0}; config is {1}", umService, m_ConfigName));
64
65 string rurl = serverConfig.GetString("GetTextureRedirectURL");
66 64
67 server.AddStreamHandler( 65 server.AddStreamHandler(
68 new GetDisplayNamesHandler("/CAPS/agents/", m_UserManagement, "GetDisplayNames", null)); 66 new GetDisplayNamesHandler("/CAPS/agents/", m_UserManagement, "GetDisplayNames", null));
diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs
index b72593c..2fd9183 100644
--- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs
@@ -481,6 +481,121 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
481 return user.FirstName + " " + user.LastName; 481 return user.FirstName + " " + user.LastName;
482 } 482 }
483 483
484 public virtual Dictionary<UUID,string> GetUsersNames(string[] ids)
485 {
486 Dictionary<UUID,string> ret = new Dictionary<UUID,string>();
487 if(m_Scenes.Count <= 0)
488 return ret;
489
490 List<string> missing = new List<string>();
491
492 // look in cache
493 UserData userdata = new UserData();
494 UUID uuid = UUID.Zero;
495 foreach(string id in ids)
496 {
497 if(UUID.TryParse(id, out uuid))
498 {
499 lock (m_UserCache)
500 {
501 if (m_UserCache.TryGetValue(uuid, out userdata) &&
502 userdata.HasGridUserTried &&
503 userdata.FirstName != "Unknown")
504 {
505 string name = userdata.FirstName + " " + userdata.LastName;
506 ret[uuid] = name;
507 }
508 else
509 missing.Add(id);
510 }
511 }
512 }
513
514 if(missing.Count == 0)
515 return ret;
516
517 // try user account service
518 List<UserAccount> accounts = m_Scenes[0].UserAccountService.GetUserAccounts(
519 m_Scenes[0].RegionInfo.ScopeID, missing);
520
521 if(accounts.Count != 0)
522 {
523 foreach(UserAccount uac in accounts)
524 {
525 if(uac != null)
526 {
527 string name = uac.FirstName + " " + uac.LastName;
528 ret[uac.PrincipalID] = name;
529 missing.Remove(uac.PrincipalID.ToString()); // slowww
530
531 userdata = new UserData();
532 userdata.Id = uac.PrincipalID;
533 userdata.FirstName = uac.FirstName;
534 userdata.LastName = uac.LastName;
535 userdata.HomeURL = string.Empty;
536 userdata.IsUnknownUser = false;
537 userdata.HasGridUserTried = true;
538 lock (m_UserCache)
539 m_UserCache[uac.PrincipalID] = userdata;
540 }
541 }
542 }
543
544 if (missing.Count == 0 || m_Scenes[0].GridUserService == null)
545 return ret;
546
547 // try grid user service
548
549 GridUserInfo[] pinfos = m_Scenes[0].GridUserService.GetGridUserInfo(missing.ToArray());
550 if(pinfos.Length > 0)
551 {
552 foreach(GridUserInfo uInfo in pinfos)
553 {
554 if (uInfo != null)
555 {
556 string url, first, last, tmp;
557 UUID u;
558 if(uInfo.UserID.Length <= 36)
559 continue;
560
561 if (Util.ParseUniversalUserIdentifier(uInfo.UserID, out u, out url, out first, out last, out tmp))
562 {
563 if (url != string.Empty)
564 {
565 try
566 {
567 string name = first.Replace(" ", ".") + "." + last.Replace(" ", ".") + " @" + new Uri(url).Authority;
568 ret[u] = name;
569 missing.Remove(u.ToString());
570 }
571 catch
572 {
573 }
574 }
575 }
576 }
577 }
578 }
579
580 // add the UMMthings ( not sure we should)
581 if(missing.Count > 0)
582 {
583 foreach(string id in missing)
584 {
585 if(UUID.TryParse(id, out uuid) && uuid != UUID.Zero)
586 {
587 if (m_Scenes[0].LibraryService != null &&
588 (m_Scenes[0].LibraryService.LibraryRootFolder.Owner == uuid))
589 ret[uuid] = "Mr OpenSim";
590 else
591 ret[uuid] = "Unknown UserUMMAU43";
592 }
593 }
594 }
595
596 return ret;
597 }
598
484 public virtual string GetUserHomeURL(UUID userID) 599 public virtual string GetUserHomeURL(UUID userID)
485 { 600 {
486 UserData user; 601 UserData user;
@@ -584,7 +699,6 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
584 else 699 else
585 { 700 {
586 userdata = new UserData(); 701 userdata = new UserData();
587 userdata.HasGridUserTried = false;
588 userdata.Id = uuid; 702 userdata.Id = uuid;
589 userdata.FirstName = "Unknown"; 703 userdata.FirstName = "Unknown";
590 userdata.LastName = "UserUMMAU42"; 704 userdata.LastName = "UserUMMAU42";
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs
index ce1754f..90c90d6 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs
@@ -165,7 +165,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts
165 List<UserAccount> accs = new List<UserAccount>(); 165 List<UserAccount> accs = new List<UserAccount>();
166 List<string> missing = new List<string>(); 166 List<string> missing = new List<string>();
167 167
168 UUID uuid = UUID.Zero;; 168 UUID uuid = UUID.Zero;
169 UserAccount account; 169 UserAccount account;
170 bool inCache = false; 170 bool inCache = false;
171 171
diff --git a/OpenSim/Services/Interfaces/IUserManagement.cs b/OpenSim/Services/Interfaces/IUserManagement.cs
index 9e560d5..225560e 100644
--- a/OpenSim/Services/Interfaces/IUserManagement.cs
+++ b/OpenSim/Services/Interfaces/IUserManagement.cs
@@ -42,6 +42,7 @@ namespace OpenSim.Services.Interfaces
42 string GetUserUUI(UUID uuid); 42 string GetUserUUI(UUID uuid);
43 bool GetUserUUI(UUID userID, out string uui); 43 bool GetUserUUI(UUID userID, out string uui);
44 string GetUserServerURL(UUID uuid, string serverType); 44 string GetUserServerURL(UUID uuid, string serverType);
45 Dictionary<UUID,string> GetUsersNames(string[] ids);
45 46
46 /// <summary> 47 /// <summary>
47 /// Get user ID by the given name. 48 /// Get user ID by the given name.