From a5ceb1a2a06c7975f53603a3eb735e192745211e Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 9 Apr 2009 15:04:02 +0000 Subject: From: Christopher Yeoh The attached patch implements osKey2Name and osName2Key which converts between a UUID key for an avatar and an avatar name and vice-versa. osKey2Name is similar to llKey2Name except that it will work even if the avatar being looked up is not in the same region as the script. --- .../Shared/Api/Implementation/OSSL_Api.cs | 41 ++++++++++++++++++++++ .../ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 2 ++ .../ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 10 ++++++ 3 files changed, 53 insertions(+) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 764f061..36c1639 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -1344,6 +1344,47 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.Inventory.AddInventoryItem(taskItem, false); } + public string osAvatarName2Key(string firstname, string lastname) + { + CheckThreatLevel(ThreatLevel.Low, "osAvatarName2Key"); + + UserProfileData UserProfile = World.CommsManager.UserService + .GetUserProfile(firstname, lastname); + if (UserProfile==null) + { + return UUID.Zero.ToString(); + } + else + { + return UserProfile.ID.ToString(); + } + } + + public string osKey2Name(string id) + { + CheckThreatLevel(ThreatLevel.Low, "osKey2Name"); + UUID key = new UUID(); + + if (UUID.TryParse(id, out key)) + { + UserProfileData UserProfile = World.CommsManager.UserService + .GetUserProfile(key); + if (UserProfile==null) + { + return ""; + } + else + { + return UserProfile.Name; + } + } + else + { + return ""; + } + + } + /// Threat level is Moderate because intentional abuse, for instance /// scripts that are written to be malicious only on one grid, /// for instance in a HG scenario, are a distinct possibility. diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 533ed27..cf4e107 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -117,6 +117,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces void osMessageObject(key objectUUID,string message); void osMakeNotecard(string notecardName, LSL_Types.list contents); + string osAvatarName2Key(string firstname, string lastname); + string osKey2Name(string id); // Grid Info Functions string osGetGridNick(); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index 3ca4095..b42505f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs @@ -300,6 +300,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase m_OSSL_Functions.osMakeNotecard(notecardName, contents); } + public string osAvatarName2Key(string firstname, string lastname) + { + return m_OSSL_Functions.osAvatarName2Key(firstname, lastname); + } + + public string osKey2Name(string id) + { + return m_OSSL_Functions.osKey2Name(id); + } + public string osGetGridNick() { return m_OSSL_Functions.osGetGridNick(); -- cgit v1.1