Less refs to UserProfileCacheService. Compiles but likely doesn't run.

slimupdates
Diva Canto 2010-01-09 09:09:32 -08:00
parent 6b60f3cce5
commit 25fdbd6cbc
10 changed files with 163 additions and 113 deletions

View File

@ -135,69 +135,6 @@ namespace OpenSim.Framework.Communications
return;
}
public void HandleUUIDNameRequest(UUID uuid, IClientAPI remote_client)
{
if (uuid == m_userProfileCacheService.LibraryRoot.Owner)
{
remote_client.SendNameReply(uuid, "Mr", "OpenSim");
}
else
{
string[] names = doUUIDNameRequest(uuid);
if (names.Length == 2)
{
remote_client.SendNameReply(uuid, names[0], names[1]);
}
}
}
private string[] doUUIDNameRequest(UUID uuid)
{
lock (m_nameRequestCache)
{
if (m_nameRequestCache.ContainsKey(uuid))
return m_nameRequestCache[uuid];
}
string[] returnstring = new string[0];
CachedUserInfo uinfo = UserProfileCacheService.GetUserDetails(uuid);
if ((uinfo != null) && (uinfo.UserProfile != null))
{
returnstring = new string[2];
returnstring[0] = uinfo.UserProfile.FirstName;
returnstring[1] = uinfo.UserProfile.SurName;
lock (m_nameRequestCache)
{
if (!m_nameRequestCache.ContainsKey(uuid))
m_nameRequestCache.Add(uuid, returnstring);
}
}
return returnstring;
}
public bool UUIDNameCachedTest(UUID uuid)
{
lock (m_nameRequestCache)
return m_nameRequestCache.ContainsKey(uuid);
}
public string UUIDNameRequestString(UUID uuid)
{
string[] names = doUUIDNameRequest(uuid);
if (names.Length == 2)
{
string firstname = names[0];
string lastname = names[1];
return firstname + " " + lastname;
}
return "(hippos)";
}
public List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(UUID queryID, string query)
{
List<AvatarPickerAvatar> pickerlist = m_userService.GenerateAgentPickerRequestResponse(queryID, query);

View File

@ -28,6 +28,7 @@
using System.Collections.Generic;
using OpenSim.Data;
using OpenMetaverse;
using OpenSim.Services.Interfaces;
namespace OpenSim.Framework.Communications.Osp
{
@ -37,12 +38,13 @@ namespace OpenSim.Framework.Communications.Osp
public class OspInventoryWrapperPlugin : IInventoryDataPlugin
{
protected IInventoryDataPlugin m_wrappedPlugin;
protected CommunicationsManager m_commsManager;
//protected CommunicationsManager m_commsManager;
protected IUserAccountService m_userAccountService;
public OspInventoryWrapperPlugin(IInventoryDataPlugin wrappedPlugin, CommunicationsManager commsManager)
public OspInventoryWrapperPlugin(IInventoryDataPlugin wrappedPlugin, IUserAccountService userService)
{
m_wrappedPlugin = wrappedPlugin;
m_commsManager = commsManager;
m_userAccountService = userService;
}
public string Name { get { return "OspInventoryWrapperPlugin"; } }
@ -81,7 +83,7 @@ namespace OpenSim.Framework.Communications.Osp
protected InventoryItemBase PostProcessItem(InventoryItemBase item)
{
item.CreatorIdAsUuid = OspResolver.ResolveOspa(item.CreatorId, m_commsManager);
item.CreatorIdAsUuid = OspResolver.ResolveOspa(item.CreatorId, m_userAccountService);
return item;
}

View File

@ -31,6 +31,7 @@ using log4net;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Services.Interfaces;
namespace OpenSim.Framework.Communications.Osp
{
@ -55,11 +56,11 @@ namespace OpenSim.Framework.Communications.Osp
/// <param name="userId"></param>
/// <param name="commsManager"></param>
/// <returns>The OSPA. Null if a user with the given UUID could not be found.</returns>
public static string MakeOspa(UUID userId, CommunicationsManager commsManager)
public static string MakeOspa(UUID userId, IUserAccountService userService)
{
CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId);
if (userInfo != null)
return MakeOspa(userInfo.UserProfile.FirstName, userInfo.UserProfile.SurName);
UserAccount account = userService.GetUserAccount(UUID.Zero, userId);
if (account != null)
return MakeOspa(account.FirstName, account.LastName);
return null;
}
@ -88,7 +89,7 @@ namespace OpenSim.Framework.Communications.Osp
/// A suitable UUID for use in Second Life client communication. If the string was not a valid ospa, then UUID.Zero
/// is returned.
/// </returns>
public static UUID ResolveOspa(string ospa, CommunicationsManager commsManager)
public static UUID ResolveOspa(string ospa, IUserAccountService userService)
{
if (!ospa.StartsWith(OSPA_PREFIX))
return UUID.Zero;
@ -112,7 +113,7 @@ namespace OpenSim.Framework.Communications.Osp
string value = tuple.Substring(tupleSeparatorIndex + 1).Trim();
if (OSPA_NAME_KEY == key)
return ResolveOspaName(value, commsManager);
return ResolveOspaName(value, userService);
}
return UUID.Zero;
@ -137,7 +138,7 @@ namespace OpenSim.Framework.Communications.Osp
/// <returns>
/// An OpenSim internal identifier for the name given. Returns null if the name was not valid
/// </returns>
protected static UUID ResolveOspaName(string name, CommunicationsManager commsManager)
protected static UUID ResolveOspaName(string name, IUserAccountService userService)
{
int nameSeparatorIndex = name.IndexOf(OSPA_NAME_VALUE_SEPARATOR);
@ -150,9 +151,9 @@ namespace OpenSim.Framework.Communications.Osp
string firstName = name.Remove(nameSeparatorIndex).TrimEnd();
string lastName = name.Substring(nameSeparatorIndex + 1).TrimStart();
CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(firstName, lastName);
if (userInfo != null)
return userInfo.UserProfile.ID;
UserAccount account = userService.GetUserAccount(UUID.Zero, firstName, lastName);
if (account != null)
return account.PrincipalID;
// XXX: Disable temporary user profile creation for now as implementation is incomplete - justincc
/*

View File

@ -130,7 +130,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Combat.CombatModule
}
else
{
string killer = DeadAvatar.Scene.CommsManager.UUIDNameRequestString(part.OwnerID);
string killer = DeadAvatar.Scene.GetUserName(part.OwnerID);
DeadAvatar.ControllingClient.SendAgentAlertMessage("You impaled yourself on " + part.Name + " owned by " + killer +"!", true);
}
//DeadAvatar.Scene. part.ObjectOwner

View File

@ -357,7 +357,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
// Don't use the item ID that's in the file
item.ID = UUID.Random();
UUID ospResolvedId = OspResolver.ResolveOspa(item.CreatorId, m_scene.CommsManager);
UUID ospResolvedId = OspResolver.ResolveOspa(item.CreatorId, m_scene.UserAccountService);
if (UUID.Zero != ospResolvedId)
{
item.CreatorIdAsUuid = ospResolvedId;

View File

@ -148,7 +148,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
m_userUuids[inventoryItem.CreatorIdAsUuid] = 1;
InventoryItemBase saveItem = (InventoryItemBase)inventoryItem.Clone();
saveItem.CreatorId = OspResolver.MakeOspa(saveItem.CreatorIdAsUuid, m_scene.CommsManager);
saveItem.CreatorId = OspResolver.MakeOspa(saveItem.CreatorIdAsUuid, m_scene.UserAccountService);
string serialization = UserInventoryItemSerializer.Serialize(saveItem);
m_archiveWriter.WriteFile(filename, serialization);

View File

@ -649,16 +649,9 @@ namespace OpenSim.Region.CoreModules.World.Estate
lsri.TaskID = sog.UUID;
lsri.TaskLocalID = sog.LocalId;
lsri.TaskName = sog.GetPartName(obj);
if (m_scene.CommsManager.UUIDNameCachedTest(sog.OwnerID))
{
lsri.OwnerName = m_scene.CommsManager.UUIDNameRequestString(sog.OwnerID);
}
else
{
lsri.OwnerName = "waiting";
lock (uuidNameLookupList)
uuidNameLookupList.Add(sog.OwnerID);
}
if (filter.Length != 0)
{
@ -709,7 +702,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
for (int i = 0; i < uuidarr.Length; i++)
{
// string lookupname = m_scene.CommsManager.UUIDNameRequestString(uuidarr[i]);
m_scene.CommsManager.UUIDNameRequestString(uuidarr[i]);
m_scene.GetUserName(uuidarr[i]);
// we drop it. It gets cached though... so we're ready for the next request.
}
}

View File

@ -33,6 +33,7 @@ using OpenMetaverse.Packets;
using OpenSim.Framework;
using OpenSim.Framework.Communications;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Services.Interfaces;
namespace OpenSim.Region.Framework.Scenes
{
@ -416,6 +417,23 @@ namespace OpenSim.Region.Framework.Scenes
);
}
public void HandleUUIDNameRequest(UUID uuid, IClientAPI remote_client)
{
if (uuid == CommsManager.UserProfileCacheService.LibraryRoot.Owner)
{
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
/// </summary>

View File

@ -841,6 +841,36 @@ 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.
///
@ -2804,7 +2834,7 @@ namespace OpenSim.Region.Framework.Scenes
public virtual void SubscribeToClientGridEvents(IClientAPI client)
{
client.OnNameFromUUIDRequest += CommsManager.HandleUUIDNameRequest;
client.OnNameFromUUIDRequest += HandleUUIDNameRequest;
client.OnMoneyTransferRequest += ProcessMoneyTransferRequest;
client.OnAvatarPickerRequest += ProcessAvatarPickerRequest;
client.OnSetStartLocationRequest += SetHomeRezPoint;
@ -2959,7 +2989,7 @@ namespace OpenSim.Region.Framework.Scenes
public virtual void UnSubscribeToClientGridEvents(IClientAPI client)
{
client.OnNameFromUUIDRequest -= CommsManager.HandleUUIDNameRequest;
client.OnNameFromUUIDRequest -= HandleUUIDNameRequest;
client.OnMoneyTransferRequest -= ProcessMoneyTransferRequest;
client.OnAvatarPickerRequest -= ProcessAvatarPickerRequest;
client.OnSetStartLocationRequest -= SetHomeRezPoint;

View File

@ -29,6 +29,7 @@ using System;
using System.Reflection;
using Nini.Config;
using OpenSim.Data;
using OpenSim.Framework.Console;
using OpenSim.Services.Interfaces;
using System.Collections.Generic;
using OpenMetaverse;
@ -37,10 +38,17 @@ namespace OpenSim.Services.UserAccountService
{
public class UserAccountService : UserAccountServiceBase, IUserAccountService
{
public UserAccountService(IConfigSource config) : base(config)
public UserAccountService(IConfigSource config)
: base(config)
{
MainConsole.Instance.Commands.AddCommand("UserService", false,
"create user",
"create user [<first> [<last> [<pass> [<x> <y> [<email>]]]]]",
"Create a new user", HandleCreateUser);
}
#region IUserAccountService
public UserAccount GetUserAccount(UUID scopeID, string firstName,
string lastName)
{
@ -180,5 +188,66 @@ namespace OpenSim.Services.UserAccountService
return ret;
}
#endregion
#region Console commands
/// <summary>
/// Create a new user
/// </summary>
/// <param name="cmdparams">string array with parameters: firstname, lastname, password, locationX, locationY, email</param>
protected void HandleCreateUser(string module, string[] cmdparams)
{
string firstName;
string lastName;
string password;
string email;
uint regX = 1000;
uint regY = 1000;
// IConfig standalone;
// if ((standalone = m_config.Source.Configs["StandAlone"]) != null)
// {
// regX = (uint)standalone.GetInt("default_location_x", (int)regX);
// regY = (uint)standalone.GetInt("default_location_y", (int)regY);
// }
// if (cmdparams.Length < 3)
// firstName = MainConsole.Instance.CmdPrompt("First name", "Default");
// else firstName = cmdparams[2];
// if (cmdparams.Length < 4)
// lastName = MainConsole.Instance.CmdPrompt("Last name", "User");
// else lastName = cmdparams[3];
// if (cmdparams.Length < 5)
// password = MainConsole.Instance.PasswdPrompt("Password");
// else password = cmdparams[4];
// if (cmdparams.Length < 6)
// regX = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region X", regX.ToString()));
// else regX = Convert.ToUInt32(cmdparams[5]);
// if (cmdparams.Length < 7)
// regY = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region Y", regY.ToString()));
// else regY = Convert.ToUInt32(cmdparams[6]);
// if (cmdparams.Length < 8)
// email = MainConsole.Instance.CmdPrompt("Email", "");
// else email = cmdparams[7];
// if (null == m_commsManager.UserProfileCacheService.GetUserDetails(firstName, lastName))
// {
// m_commsManager.UserAdminService.AddUser(firstName, lastName, password, email, regX, regY);
// }
// else
// {
// m_log.ErrorFormat("[CONSOLE]: A user with the name {0} {1} already exists!", firstName, lastName);
// }
//}
}
#endregion
}
}