From 6a9ae9e7cb71d79e9ec06cf25009e8bf45850dd1 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 21 Nov 2010 13:16:52 -0800 Subject: [PATCH] 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. --- OpenSim/Data/MySQL/MySQLSimulationData.cs | 4 +- .../MySQL/Resources/RegionStore.migrations | 8 + OpenSim/Region/Application/OpenSim.cs | 3 +- .../CoreModules/Avatar/Combat/CombatModule.cs | 10 +- .../UserManagement/UserManagementModule.cs | 297 ++++++++++++++++++ .../Resources/CoreModulePlugin.addin.xml | 1 + .../World/Archiver/ArchiveReadRequest.cs | 21 +- .../World/Archiver/ArchiverModule.cs | 1 + .../World/Estate/EstateManagementModule.cs | 8 +- .../Framework/Interfaces/IUserManagement.cs | 13 + .../Framework/Scenes/Scene.PacketHandlers.cs | 16 - OpenSim/Region/Framework/Scenes/Scene.cs | 36 +-- .../Framework/Scenes/SceneObjectPart.cs | 51 +++ .../Serialization/SceneObjectSerializer.cs | 21 ++ 14 files changed, 434 insertions(+), 56 deletions(-) create mode 100644 OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs create mode 100644 OpenSim/Region/Framework/Interfaces/IUserManagement.cs diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index ae78814f06..f630dc1540 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -1090,7 +1090,7 @@ namespace OpenSim.Data.MySQL // depending on the MySQL connector version, CHAR(36) may be already converted to Guid! prim.UUID = DBGuid.FromDB(row["UUID"]); - prim.CreatorID = DBGuid.FromDB(row["CreatorID"]); + prim.CreatorIdentification = (string)row["CreatorID"]; prim.OwnerID = DBGuid.FromDB(row["OwnerID"]); prim.GroupID = DBGuid.FromDB(row["GroupID"]); prim.LastOwnerID = DBGuid.FromDB(row["LastOwnerID"]); @@ -1453,7 +1453,7 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("TouchName", prim.TouchName); // permissions cmd.Parameters.AddWithValue("ObjectFlags", (uint)prim.Flags); - cmd.Parameters.AddWithValue("CreatorID", prim.CreatorID.ToString()); + cmd.Parameters.AddWithValue("CreatorID", prim.CreatorIdentification.ToString()); cmd.Parameters.AddWithValue("OwnerID", prim.OwnerID.ToString()); cmd.Parameters.AddWithValue("GroupID", prim.GroupID.ToString()); cmd.Parameters.AddWithValue("LastOwnerID", prim.LastOwnerID.ToString()); diff --git a/OpenSim/Data/MySQL/Resources/RegionStore.migrations b/OpenSim/Data/MySQL/Resources/RegionStore.migrations index 1405207a4c..364c4d38a1 100644 --- a/OpenSim/Data/MySQL/Resources/RegionStore.migrations +++ b/OpenSim/Data/MySQL/Resources/RegionStore.migrations @@ -817,3 +817,11 @@ ALTER TABLE `land` ADD COLUMN `MediaLoop` BOOLEAN NOT NULL DEFAULT FALSE; ALTER TABLE `land` ADD COLUMN `ObscureMusic` BOOLEAN NOT NULL DEFAULT FALSE; ALTER TABLE `land` ADD COLUMN `ObscureMedia` BOOLEAN NOT NULL DEFAULT FALSE; COMMIT; + +:VERSION 37 #--------------------- + +BEGIN; + +ALTER TABLE `prims` MODIFY COLUMN `CreatorID` VARCHAR(255) NOT NULL DEFAULT ''; + +COMMIT; diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index dd2e859acb..6127c2d6c7 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs @@ -265,9 +265,10 @@ namespace OpenSim LoadOar); m_console.Commands.AddCommand("region", false, "save oar", - "save oar [-v|--version=N] []", + "save oar [-v|--version=N] [-p|--profile=url] []", "Save a region's data to an OAR archive.", "-v|--version=N generates scene objects as per older versions of the serialization (e.g. -v=0)" + Environment.NewLine + + "-p|--profile=url adds the url of the profile service to the saved user information" + Environment.NewLine + "The OAR path must be a filesystem path." + " If this is not given then the oar is saved to region.oar in the current directory.", SaveOar); diff --git a/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs b/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs index 25322a17c0..a5fcb493bd 100644 --- a/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs @@ -115,10 +115,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Combat.CombatModule // Try to find the avatar wielding the killing object killingAvatar = deadAvatar.Scene.GetScenePresence(part.OwnerID); if (killingAvatar == null) - deadAvatarMessage = String.Format("You impaled yourself on {0} owned by {1}!", part.Name, deadAvatar.Scene.GetUserName(part.OwnerID)); + { + IUserManagement userManager = deadAvatar.Scene.RequestModuleInterface(); + string userName = "Unkown User"; + if (userManager != null) + userName = userManager.GetUserName(part.OwnerID); + deadAvatarMessage = String.Format("You impaled yourself on {0} owned by {1}!", part.Name, userName); + } else { -// killingAvatarMessage = String.Format("You fragged {0}!", deadAvatar.Name); + // killingAvatarMessage = String.Format("You fragged {0}!", deadAvatar.Name); deadAvatarMessage = String.Format("You got killed by {0}!", killingAvatar.Name); } } diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs new file mode 100644 index 0000000000..88ed763337 --- /dev/null +++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs @@ -0,0 +1,297 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +using System; +using System.Collections.Generic; +using System.IO; +using System.Reflection; + +using OpenSim.Framework; + +using OpenSim.Region.Framework; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Services.Interfaces; + +using OpenMetaverse; +using log4net; +using Nini.Config; + +namespace OpenSim.Region.CoreModules.Framework.UserManagement +{ + struct UserData + { + public UUID Id; + public string FirstName; + public string LastName; + public string ProfileURL; + } + + public class UserManagementModule : ISharedRegionModule, IUserManagement + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private List m_Scenes = new List(); + + // The cache + Dictionary m_UserCache = new Dictionary(); + + #region ISharedRegionModule + + public void Initialise(IConfigSource config) + { + //m_Enabled = config.Configs["Modules"].GetBoolean("LibraryModule", m_Enabled); + //if (m_Enabled) + //{ + // IConfig libConfig = config.Configs["LibraryService"]; + // if (libConfig != null) + // { + // string dllName = libConfig.GetString("LocalServiceModule", string.Empty); + // m_log.Debug("[LIBRARY MODULE]: Library service dll is " + dllName); + // if (dllName != string.Empty) + // { + // Object[] args = new Object[] { config }; + // m_Library = ServerUtils.LoadPlugin(dllName, args); + // } + // } + //} + } + + public bool IsSharedModule + { + get { return true; } + } + + public string Name + { + get { return "UserManagement Module"; } + } + + public Type ReplaceableInterface + { + get { return null; } + } + + public void AddRegion(Scene scene) + { + m_Scenes.Add(scene); + + scene.RegisterModuleInterface(this); + scene.EventManager.OnNewClient += new EventManager.OnNewClientDelegate(EventManager_OnNewClient); + } + + public void RemoveRegion(Scene scene) + { + scene.UnregisterModuleInterface(this); + m_Scenes.Remove(scene); + } + + public void RegionLoaded(Scene scene) + { + } + + public void PostInitialise() + { + foreach (Scene s in m_Scenes) + { + // let's sniff all the user names referenced by objects in the scene + m_log.DebugFormat("[USER MANAGEMENT MODULE]: Caching creators' data from {0} ({1} objects)...", s.RegionInfo.RegionName, s.GetEntities().Length); + s.ForEachSOG(delegate(SceneObjectGroup sog) { CacheCreators(sog); }); + } + } + + public void Close() + { + m_Scenes.Clear(); + m_UserCache.Clear(); + } + + #endregion ISharedRegionModule + + + #region Event Handlers + + void EventManager_OnNewClient(IClientAPI client) + { + client.OnNameFromUUIDRequest += new UUIDNameRequest(HandleUUIDNameRequest); + } + + void HandleUUIDNameRequest(UUID uuid, IClientAPI remote_client) + { + if (m_Scenes[0].LibraryService != null && (m_Scenes[0].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]); + } + + } + } + + #endregion Event Handlers + + private void CacheCreators(SceneObjectGroup sog) + { + //m_log.DebugFormat("[USER MANAGEMENT MODULE]: processing {0} {1}; {2}", sog.RootPart.Name, sog.RootPart.CreatorData, sog.RootPart.CreatorIdentification); + AddUser(sog.RootPart.CreatorID, sog.RootPart.CreatorData); + + foreach (SceneObjectPart sop in sog.Parts) + AddUser(sop.CreatorID, sop.CreatorData); + } + + + private string[] GetUserNames(UUID uuid) + { + string[] returnstring = new string[2]; + + if (m_UserCache.ContainsKey(uuid)) + { + returnstring[0] = m_UserCache[uuid].FirstName; + returnstring[1] = m_UserCache[uuid].LastName; + return returnstring; + } + + UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, uuid); + + if (account != null) + { + returnstring[0] = account.FirstName; + returnstring[1] = account.LastName; + + UserData user = new UserData(); + user.FirstName = account.FirstName; + user.LastName = account.LastName; + + lock (m_UserCache) + m_UserCache[uuid] = user; + } + else + { + returnstring[0] = "Unknown"; + returnstring[1] = "User"; + } + + return returnstring; + } + + #region IUserManagement + + 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)"; + } + + public void AddUser(UUID id, string creatorData) + { + if (m_UserCache.ContainsKey(id)) + return; + + UserData user = new UserData(); + user.Id = id; + + if (creatorData != null && creatorData != string.Empty) + { + //creatorData = ; + + string[] parts = creatorData.Split(';'); + if (parts.Length >= 1) + { + user.ProfileURL = parts[0]; + try + { + Uri uri = new Uri(parts[0]); + user.LastName = "@" + uri.Authority; + } + catch + { + m_log.DebugFormat("[SCENE]: Unable to parse Uri {0}", parts[0]); + user.LastName = "@unknown"; + } + } + if (parts.Length >= 2) + user.FirstName = parts[1].Replace(' ', '.'); + } + else + { + UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, id); + user.FirstName = account.FirstName; + user.LastName = account.LastName; + // user.ProfileURL = we should initialize this to the default + } + + lock (m_UserCache) + m_UserCache[id] = user; + + //m_log.DebugFormat("[USER MANAGEMENT MODULE]: Added user {0} {1} {2} {3}", user.Id, user.FirstName, user.LastName, user.ProfileURL); + } + + //public void AddUser(UUID uuid, string userData) + //{ + // if (m_UserCache.ContainsKey(uuid)) + // return; + + // UserData user = new UserData(); + // user.Id = uuid; + + // // userData = ; + // string[] parts = userData.Split(';'); + // if (parts.Length >= 1) + // user.ProfileURL = parts[0].Trim(); + // if (parts.Length >= 2) + // { + // string[] name = parts[1].Trim().Split(' '); + // if (name.Length >= 1) + // user.FirstName = name[0]; + // if (name.Length >= 2) + // user.LastName = name[1]; + // else + // user.LastName = "?"; + // } + + // lock (m_UserCache) + // m_UserCache.Add(uuid, user); + + // m_log.DebugFormat("[USER MANAGEMENT MODULE]: Added user {0} {1} {2} {3}", user.Id, user.FirstName, user.LastName, user.ProfileURL); + + //} + + #endregion IUserManagement + } +} diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml index df23eacde0..cfa41095c8 100644 --- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml +++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml @@ -8,6 +8,7 @@ + diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs index d5d4468b49..b7fa799cc1 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs @@ -78,6 +78,19 @@ namespace OpenSim.Region.CoreModules.World.Archiver /// private IDictionary m_validUserUuids = new Dictionary(); + private IUserManagement m_UserMan; + private IUserManagement UserManager + { + get + { + if (m_UserMan == null) + { + m_UserMan = m_scene.RequestModuleInterface(); + } + return m_UserMan; + } + } + public ArchiveReadRequest(Scene scene, string loadPath, bool merge, bool skipAssets, Guid requestId) { m_scene = scene; @@ -251,8 +264,12 @@ namespace OpenSim.Region.CoreModules.World.Archiver foreach (SceneObjectPart part in sceneObject.Parts) { - if (!ResolveUserUuid(part.CreatorID)) - part.CreatorID = m_scene.RegionInfo.EstateSettings.EstateOwner; + if (part.CreatorData == null || part.CreatorData == string.Empty) + { + if (!ResolveUserUuid(part.CreatorID)) + part.CreatorID = m_scene.RegionInfo.EstateSettings.EstateOwner; + } + UserManager.AddUser(part.CreatorID, part.CreatorData); if (!ResolveUserUuid(part.OwnerID)) part.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs index e0ad71e007..358d0a7205 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs @@ -126,6 +126,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver OptionSet ops = new OptionSet(); ops.Add("v|version=", delegate(string v) { options["version"] = v; }); + ops.Add("p|profile=", delegate(string v) { options["profile"] = v; }); List mainParams = ops.Parse(cmdparams); diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index 6844c6024a..622fc0802d 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs @@ -771,8 +771,14 @@ namespace OpenSim.Region.CoreModules.World.Estate for (int i = 0; i < uuidarr.Length; i++) { // string lookupname = m_scene.CommsManager.UUIDNameRequestString(uuidarr[i]); - m_scene.GetUserName(uuidarr[i]); + + IUserManagement userManager = m_scene.RequestModuleInterface(); + string userName = "Unkown User"; + if (userManager != null) + userName = userManager.GetUserName(uuidarr[i]); + // we drop it. It gets cached though... so we're ready for the next request. + // diva commnent 11/21/2010: uh?!? wft? } } #endregion diff --git a/OpenSim/Region/Framework/Interfaces/IUserManagement.cs b/OpenSim/Region/Framework/Interfaces/IUserManagement.cs new file mode 100644 index 0000000000..1a5cb7ecd1 --- /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 21c36d3316..ab567fbcb0 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 96a9f998c3..4fc2cbca5e 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 f1642015af..6d5a53afad 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 fb4ef28050..fceeafa907 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());