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.
This commit is contained in:
Diva Canto
2010-11-21 13:16:52 -08:00
parent f1151f20dc
commit 6a9ae9e7cb
14 changed files with 434 additions and 56 deletions

View File

@@ -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);
}
}

View File

@@ -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]);
}
}
}
/// <summary>
/// Handle a fetch inventory request from the client

View File

@@ -185,6 +185,8 @@ namespace OpenSim.Region.Framework.Scenes
private Timer m_mapGenerationTimer = new Timer();
private bool m_generateMaptiles;
private Dictionary<UUID, string[]> m_UserNamesCache = new Dictionary<UUID, string[]>();
#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)";
}
/// <summary>
/// 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;

View File

@@ -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 // <uuid>[;<endpoint>[;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;
}
}
}
/// <summary>
/// A relic from when we we thought that prims contained folder objects. In
/// reality, prim == folder

View File

@@ -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;
/// <summary>
/// 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<IUserManagement>();
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());