diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/HGUserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/HGUserManagementModule.cs index 8077a7a53b..66de8e4f5a 100644 --- a/OpenSim/Region/CoreModules/Framework/UserManagement/HGUserManagementModule.cs +++ b/OpenSim/Region/CoreModules/Framework/UserManagement/HGUserManagementModule.cs @@ -92,19 +92,47 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement foreach (UserData d in m_UserCache.Values) { if (d.LastName.StartsWith("@") && - (d.FirstName.ToLower().Equals(words[0].ToLower()) || - d.LastName.ToLower().Equals(words[1].ToLower()))) + d.FirstName.ToLower().Equals(words[0].ToLower()) && + d.LastName.ToLower().Equals(words[1].ToLower())) { users.Add(d); found = true; break; } } - if (!found) // This is it! Let's ask the other world + + if (!found && words[1].StartsWith("@") && words[0].Contains(".")) // This is it! Let's ask the other world { - // TODO - //UserAgentServiceConnector uasConn = new UserAgentServiceConnector(words[0]); - //uasConn.GetUserInfo(...); + string[] names = words[0].Split(new char[] { '.' }); + if (names.Length >= 2) + { + + string uriStr = "http://" + words[1].Substring(1); // remove the @ + // Let's check that the last name is a valid address + try + { + new Uri(uriStr); + } + catch (UriFormatException) + { + return; + } + + UserAgentServiceConnector uasConn = new UserAgentServiceConnector(uriStr); + UUID userID = uasConn.GetUUID(names[0], names[1]); + if (!userID.Equals(UUID.Zero)) + { + UserData ud = new UserData(); + ud.Id = userID; + ud.FirstName = words[0]; + ud.LastName = words[1]; + users.Add(ud); + AddUser(userID, ud.FirstName, ud.LastName, uriStr); + m_log.DebugFormat("[USER MANAGEMENT MODULE]: User {0} {1} found", words[0], words[1]); + } + else + m_log.DebugFormat("[USER MANAGEMENT MODULE]: User {0} {1} not found", words[0], words[1]); + } } } else diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs index 23ef0fc98d..cb562a2703 100644 --- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs +++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs @@ -183,7 +183,6 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement List users = new List(); if (accs != null) { - m_log.DebugFormat("[USER MANAGEMENT MODULE]: Found {0} users", accs.Count); foreach (UserAccount acc in accs) { UserData ud = new UserData(); diff --git a/OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs b/OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs index 1bd37062db..734836855f 100644 --- a/OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs +++ b/OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs @@ -96,6 +96,7 @@ namespace OpenSim.Server.Handlers.Hypergrid server.AddXmlRPCHandler("locate_user", LocateUser, false); server.AddXmlRPCHandler("get_uui", GetUUI, false); + server.AddXmlRPCHandler("get_uuid", GetUUID, false); server.AddHTTPHandler("/homeagent/", new HomeAgentHandler(m_HomeUsersService, loginServerIP, proxy).Handler); } @@ -410,8 +411,7 @@ namespace OpenSim.Server.Handlers.Hypergrid } /// - /// Locates the user. - /// This is a sensitive operation, only authorized IP addresses can perform it. + /// Returns the UUI of a user given a UUID. /// /// /// @@ -445,5 +445,33 @@ namespace OpenSim.Server.Handlers.Hypergrid } + /// + /// Gets the UUID of a user given First name, Last name. + /// + /// + /// + /// + public XmlRpcResponse GetUUID(XmlRpcRequest request, IPEndPoint remoteClient) + { + Hashtable hash = new Hashtable(); + + Hashtable requestData = (Hashtable)request.Params[0]; + //string host = (string)requestData["host"]; + //string portstr = (string)requestData["port"]; + if (requestData.ContainsKey("first") && requestData.ContainsKey("last")) + { + UUID userID = UUID.Zero; + string first = (string)requestData["first"]; + + string last = (string)requestData["last"]; + UUID uuid = m_HomeUsersService.GetUUID(first, last); + hash["UUID"] = uuid.ToString(); + } + + XmlRpcResponse response = new XmlRpcResponse(); + response.Value = hash; + return response; + + } } } diff --git a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs index 5b27cf6427..bf86035f6a 100644 --- a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs +++ b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs @@ -789,13 +789,72 @@ namespace OpenSim.Services.Connectors.Hypergrid } catch { - m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on LocateUser response."); + m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on GetUUI response."); // reason = "Exception: " + e.Message; } return uui; } + public UUID GetUUID(String first, String last) + { + Hashtable hash = new Hashtable(); + hash["first"] = first; + hash["last"] = last; + + IList paramList = new ArrayList(); + paramList.Add(hash); + + XmlRpcRequest request = new XmlRpcRequest("get_uuid", paramList); + // string reason = string.Empty; + + // Send and get reply + UUID uuid = UUID.Zero; + XmlRpcResponse response = null; + try + { + response = request.Send(m_ServerURL, 10000); + } + catch + { + m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetUUID", m_ServerURL); + // reason = "Exception: " + e.Message; + return uuid; + } + + if (response.IsFault) + { + m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for GetUUID returned an error: {1}", m_ServerURL, response.FaultString); + // reason = "XMLRPC Fault"; + return uuid; + } + + hash = (Hashtable)response.Value; + //foreach (Object o in hash) + // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); + try + { + if (hash == null) + { + m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetUUDI Got null response from {0}! THIS IS BAAAAD", m_ServerURL); + // reason = "Internal error 1"; + return uuid; + } + + // Here's the actual response + if (hash.ContainsKey("UUID")) + UUID.TryParse(hash["UUID"].ToString(), out uuid); + + } + catch + { + m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on UUID response."); + // reason = "Exception: " + e.Message; + } + + return uuid; + } + private bool GetBoolResponse(XmlRpcRequest request, out string reason) { //m_log.Debug("[USER AGENT CONNECTOR]: GetBoolResponse from/to " + m_ServerURL); diff --git a/OpenSim/Services/HypergridService/UserAgentService.cs b/OpenSim/Services/HypergridService/UserAgentService.cs index f681df4243..5eca801deb 100644 --- a/OpenSim/Services/HypergridService/UserAgentService.cs +++ b/OpenSim/Services/HypergridService/UserAgentService.cs @@ -566,6 +566,16 @@ namespace OpenSim.Services.HypergridService return string.Empty; } + + public UUID GetUUID(String first, String last) + { + // Let's see if it's a local user + UserAccount account = m_UserAccountService.GetUserAccount(UUID.Zero, first, last); + if (account != null) + return account.PrincipalID; + else + return UUID.Zero; + } } class TravelingAgentInfo diff --git a/OpenSim/Services/Interfaces/IHypergridServices.cs b/OpenSim/Services/Interfaces/IHypergridServices.cs index 5b293acbee..0cd44f721f 100644 --- a/OpenSim/Services/Interfaces/IHypergridServices.cs +++ b/OpenSim/Services/Interfaces/IHypergridServices.cs @@ -62,6 +62,8 @@ namespace OpenSim.Services.Interfaces // on behalf of the userID string GetUUI(UUID userID, UUID targetUserID); + UUID GetUUID(String first, String last); + // Returns the local friends online List StatusNotification(List friends, UUID userID, bool online); //List GetOnlineFriends(UUID userID, List friends);