From 6a9ae9e7cb71d79e9ec06cf25009e8bf45850dd1 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 21 Nov 2010 13:16:52 -0800 Subject: Global creator information working on MySQL DB and on load/save OARs. Creator name properly shown on the viewer as first.last @authority. New option added to save oar -profile=url. Migration on RegionStore making CreatorID be 255 chars. Moved Handling of user UUID -> name requests to a new module UserManagement/UserManagementModule. --- .../Region/Framework/Interfaces/IUserManagement.cs | 13 ++++++ .../Framework/Scenes/Scene.PacketHandlers.cs | 16 ------- OpenSim/Region/Framework/Scenes/Scene.cs | 36 ++------------- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 51 ++++++++++++++++++++++ .../Scenes/Serialization/SceneObjectSerializer.cs | 21 +++++++++ 5 files changed, 89 insertions(+), 48 deletions(-) create mode 100644 OpenSim/Region/Framework/Interfaces/IUserManagement.cs (limited to 'OpenSim/Region/Framework') diff --git a/OpenSim/Region/Framework/Interfaces/IUserManagement.cs b/OpenSim/Region/Framework/Interfaces/IUserManagement.cs new file mode 100644 index 0000000..1a5cb7e --- /dev/null +++ b/OpenSim/Region/Framework/Interfaces/IUserManagement.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; + +using OpenMetaverse; + +namespace OpenSim.Region.Framework.Interfaces +{ + public interface IUserManagement + { + string GetUserName(UUID uuid); + void AddUser(UUID uuid, string userData); + } +} diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs index 21c36d3..ab567fb 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs @@ -462,22 +462,6 @@ namespace OpenSim.Region.Framework.Scenes ); } - public void HandleUUIDNameRequest(UUID uuid, IClientAPI remote_client) - { - if (LibraryService != null && (LibraryService.LibraryRootFolder.Owner == uuid)) - { - remote_client.SendNameReply(uuid, "Mr", "OpenSim"); - } - else - { - string[] names = GetUserNames(uuid); - if (names.Length == 2) - { - remote_client.SendNameReply(uuid, names[0], names[1]); - } - - } - } /// /// Handle a fetch inventory request from the client diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 96a9f99..4fc2cbc 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -185,6 +185,8 @@ namespace OpenSim.Region.Framework.Scenes private Timer m_mapGenerationTimer = new Timer(); private bool m_generateMaptiles; + private Dictionary m_UserNamesCache = new Dictionary(); + #endregion Fields #region Properties @@ -792,36 +794,6 @@ namespace OpenSim.Region.Framework.Scenes return m_simulatorVersion; } - public string[] GetUserNames(UUID uuid) - { - string[] returnstring = new string[0]; - - UserAccount account = UserAccountService.GetUserAccount(RegionInfo.ScopeID, uuid); - - if (account != null) - { - returnstring = new string[2]; - returnstring[0] = account.FirstName; - returnstring[1] = account.LastName; - } - - return returnstring; - } - - public string GetUserName(UUID uuid) - { - string[] names = GetUserNames(uuid); - if (names.Length == 2) - { - string firstname = names[0]; - string lastname = names[1]; - - return firstname + " " + lastname; - - } - return "(hippos)"; - } - /// /// Another region is up. /// @@ -2808,7 +2780,7 @@ namespace OpenSim.Region.Framework.Scenes public virtual void SubscribeToClientGridEvents(IClientAPI client) { - client.OnNameFromUUIDRequest += HandleUUIDNameRequest; + //client.OnNameFromUUIDRequest += HandleUUIDNameRequest; client.OnMoneyTransferRequest += ProcessMoneyTransferRequest; client.OnAvatarPickerRequest += ProcessAvatarPickerRequest; client.OnSetStartLocationRequest += SetHomeRezPoint; @@ -2935,7 +2907,7 @@ namespace OpenSim.Region.Framework.Scenes public virtual void UnSubscribeToClientGridEvents(IClientAPI client) { - client.OnNameFromUUIDRequest -= HandleUUIDNameRequest; + //client.OnNameFromUUIDRequest -= HandleUUIDNameRequest; client.OnMoneyTransferRequest -= ProcessMoneyTransferRequest; client.OnAvatarPickerRequest -= ProcessAvatarPickerRequest; client.OnSetStartLocationRequest -= SetHomeRezPoint; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index f164201..6d5a53a 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -435,6 +435,7 @@ namespace OpenSim.Region.Framework.Scenes private DateTime m_expires; private DateTime m_rezzed; private bool m_createSelected = false; + private string m_creatorData = string.Empty; public UUID CreatorID { @@ -448,6 +449,56 @@ namespace OpenSim.Region.Framework.Scenes } } + public string CreatorData + { + get { return m_creatorData; } + set { m_creatorData = value; } + } + + public string CreatorIdentification + { + get + { + if (m_creatorData != null && m_creatorData != string.Empty) + return _creatorID.ToString() + ';' + m_creatorData; + else + return _creatorID.ToString(); + } + set + { + if ((value == null) || (value != null && value == string.Empty)) + { + m_creatorData = string.Empty; + return; + } + + if (!value.Contains(";")) // plain UUID + { + UUID uuid = UUID.Zero; + UUID.TryParse(value, out uuid); + _creatorID = uuid; + } + else // [;[;name]] + { + string name = "Unknown User"; + string[] parts = value.Split(';'); + if (parts.Length >= 1) + { + UUID uuid = UUID.Zero; + UUID.TryParse(parts[0], out uuid); + _creatorID = uuid; + } + if (parts.Length >= 2) + m_creatorData = parts[1]; + if (parts.Length >= 3) + name = parts[2]; + + m_creatorData += ';' + name; + + } + } + } + /// /// A relic from when we we thought that prims contained folder objects. In /// reality, prim == folder diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index fb4ef28..fceeafa 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -34,6 +34,7 @@ using System.Xml; using log4net; using OpenMetaverse; using OpenSim.Framework; +using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; namespace OpenSim.Region.Framework.Scenes.Serialization @@ -46,6 +47,8 @@ namespace OpenSim.Region.Framework.Scenes.Serialization public class SceneObjectSerializer { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private static IUserManagement m_UserManagement; /// /// Deserialize a scene object from the original xml format @@ -270,6 +273,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization #region SOPXmlProcessors initialization m_SOPXmlProcessors.Add("AllowedDrop", ProcessAllowedDrop); m_SOPXmlProcessors.Add("CreatorID", ProcessCreatorID); + m_SOPXmlProcessors.Add("CreatorData", ProcessCreatorData); m_SOPXmlProcessors.Add("FolderID", ProcessFolderID); m_SOPXmlProcessors.Add("InventorySerial", ProcessInventorySerial); m_SOPXmlProcessors.Add("TaskInventory", ProcessTaskInventory); @@ -412,6 +416,11 @@ namespace OpenSim.Region.Framework.Scenes.Serialization obj.CreatorID = ReadUUID(reader, "CreatorID"); } + private static void ProcessCreatorData(SceneObjectPart obj, XmlTextReader reader) + { + obj.CreatorData = reader.ReadElementContentAsString("CreatorData", String.Empty); + } + private static void ProcessFolderID(SceneObjectPart obj, XmlTextReader reader) { obj.FolderID = ReadUUID(reader, "FolderID"); @@ -1077,7 +1086,19 @@ namespace OpenSim.Region.Framework.Scenes.Serialization writer.WriteAttributeString("xmlns:xsd", "http://www.w3.org/2001/XMLSchema"); writer.WriteElementString("AllowedDrop", sop.AllowedDrop.ToString().ToLower()); + WriteUUID(writer, "CreatorID", sop.CreatorID, options); + + if (sop.CreatorData != null && sop.CreatorData != string.Empty) + writer.WriteElementString("CreatorData", sop.CreatorData); + else if (options.ContainsKey("profile")) + { + if (m_UserManagement == null) + m_UserManagement = sop.ParentGroup.Scene.RequestModuleInterface(); + string name = m_UserManagement.GetUserName(sop.CreatorID); + writer.WriteElementString("CreatorData", (string)options["profile"] + "/" + sop.CreatorID + ";" + name); + } + WriteUUID(writer, "FolderID", sop.FolderID, options); writer.WriteElementString("InventorySerial", sop.InventorySerial.ToString()); -- cgit v1.1