Merge branch 'master-core' into mantis5110

This commit is contained in:
Jonathan Freedman
2010-11-21 20:01:48 -08:00
68 changed files with 2022 additions and 1124 deletions

View File

@@ -273,6 +273,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
if (objatt != null)
{
// Loading the inventory from XML will have set this, but
// there is no way the object could have changed yet,
// since scripts aren't running yet. So, clear it here.
objatt.HasGroupChanged = false;
bool tainted = false;
if (AttachmentPt != 0 && AttachmentPt != objatt.GetAttachmentPoint())
tainted = true;
@@ -470,6 +474,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
m_scene.EventManager.TriggerOnAttach(group.LocalId, itemID, UUID.Zero);
group.DetachToInventoryPrep();
m_log.Debug("[ATTACHMENTS MODULE]: Saving attachpoint: " + ((uint)group.GetAttachmentPoint()).ToString());
// If an item contains scripts, it's always changed.
// This ensures script state is saved on detach
foreach (SceneObjectPart p in group.Parts)
if (p.Inventory.ContainsScripts())
group.HasGroupChanged = true;
UpdateKnownItem(remoteClient, group, group.GetFromItemID(), group.OwnerID);
m_scene.DeleteSceneObject(group, false);
return;
@@ -478,25 +489,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
}
}
public void UpdateAttachmentPosition(IClientAPI client, SceneObjectGroup sog, Vector3 pos)
{
// If this is an attachment, then we need to save the modified
// object back into the avatar's inventory. First we save the
// attachment point information, then we update the relative
// positioning (which caused this method to get driven in the
// first place. Then we have to mark the object as NOT an
// attachment. This is necessary in order to correctly save
// and retrieve GroupPosition information for the attachment.
// Then we save the asset back into the appropriate inventory
// entry. Finally, we restore the object's attachment status.
byte attachmentPoint = sog.GetAttachmentPoint();
sog.UpdateGroupPosition(pos);
sog.RootPart.IsAttachment = false;
sog.AbsolutePosition = sog.RootPart.AttachedPos;
UpdateKnownItem(client, sog, sog.GetFromItemID(), sog.OwnerID);
sog.SetAttachmentPoint(attachmentPoint);
}
/// <summary>
/// Update the attachment asset for the new sog details if they have changed.
/// </summary>
@@ -508,7 +500,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
/// <param name="grp"></param>
/// <param name="itemID"></param>
/// <param name="agentID"></param>
protected void UpdateKnownItem(IClientAPI remoteClient, SceneObjectGroup grp, UUID itemID, UUID agentID)
public void UpdateKnownItem(IClientAPI remoteClient, SceneObjectGroup grp, UUID itemID, UUID agentID)
{
if (grp != null)
{
@@ -523,7 +515,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
grp.UUID, grp.GetAttachmentPoint());
string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp);
InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
item = m_scene.InventoryService.GetItem(item);
@@ -617,7 +608,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
// In case it is later dropped again, don't let
// it get cleaned up
so.RootPart.RemFlag(PrimFlags.TemporaryOnRez);
so.HasGroupChanged = false;
}
}
}

View File

@@ -55,6 +55,8 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
private Dictionary<UUID,long> m_savequeue = new Dictionary<UUID,long>();
private Dictionary<UUID,long> m_sendqueue = new Dictionary<UUID,long>();
private object m_setAppearanceLock = new object();
#region RegionModule Members
public void Initialise(Scene scene, IConfigSource config)
@@ -69,6 +71,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
{
m_savetime = Convert.ToInt32(sconfig.GetString("DelayBeforeAppearanceSave",Convert.ToString(m_savetime)));
m_sendtime = Convert.ToInt32(sconfig.GetString("DelayBeforeAppearanceSend",Convert.ToString(m_sendtime)));
// m_log.InfoFormat("[AVFACTORY] configured for {0} save and {1} send",m_savetime,m_sendtime);
}
}
@@ -117,26 +120,28 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
ScenePresence sp = m_scene.GetScenePresence(client.AgentId);
if (sp == null)
{
m_log.WarnFormat("[AVATAR FACTORY MODULE]: SetAppearance unable to find presence for {0}", client.AgentId);
m_log.WarnFormat("[AVFACTORY]: SetAppearance unable to find presence for {0}", client.AgentId);
return false;
}
bool cached = true;
bool defonly = true; // are we only using default textures
// Process the texture entry
for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++)
{
int idx = AvatarAppearance.BAKE_INDICES[i];
Primitive.TextureEntryFace face = sp.Appearance.Texture.FaceTextures[idx];
if (face != null && face.TextureID != AppearanceManager.DEFAULT_AVATAR_TEXTURE)
if (! CheckBakedTextureAsset(client,face.TextureID,idx))
{
sp.Appearance.Texture.FaceTextures[idx] = null;
cached = false;
}
if (face == null || face.TextureID != AppearanceManager.DEFAULT_AVATAR_TEXTURE)
continue;
defonly = false; // found a non-default texture reference
if (! CheckBakedTextureAsset(client,face.TextureID,idx))
return false;
}
return cached;
// If we only found default textures, then the appearance is not cached
return (defonly ? false : true);
}
/// <summary>
@@ -146,44 +151,59 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
/// <param name="visualParam"></param>
public void SetAppearance(IClientAPI client, Primitive.TextureEntry textureEntry, byte[] visualParams)
{
// m_log.WarnFormat("[AVATAR FACTORY MODULE]: SetAppearance for {0}",client.AgentId);
ScenePresence sp = m_scene.GetScenePresence(client.AgentId);
if (sp == null)
{
m_log.WarnFormat("[AVATAR FACTORY MODULE]: SetAppearance unable to find presence for {0}",client.AgentId);
m_log.WarnFormat("[AVFACTORY]: SetAppearance unable to find presence for {0}",client.AgentId);
return;
}
// m_log.WarnFormat("[AVFACTORY]: Start SetAppearance for {0}",client.AgentId);
bool changed = false;
// Process the texture entry
if (textureEntry != null)
// Process the texture entry transactionally, this doesn't guarantee that Appearance is
// going to be handled correctly but it does serialize the updates to the appearance
lock (m_setAppearanceLock)
{
changed = sp.Appearance.SetTextureEntries(textureEntry);
for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++)
if (textureEntry != null)
{
int idx = AvatarAppearance.BAKE_INDICES[i];
Primitive.TextureEntryFace face = sp.Appearance.Texture.FaceTextures[idx];
if (face != null && face.TextureID != AppearanceManager.DEFAULT_AVATAR_TEXTURE)
Util.FireAndForget(delegate(object o) {
if (! CheckBakedTextureAsset(client,face.TextureID,idx))
client.SendRebakeAvatarTextures(face.TextureID);
});
}
}
changed = sp.Appearance.SetTextureEntries(textureEntry);
// Process the visual params, this may change height as well
if (visualParams != null)
{
if (sp.Appearance.SetVisualParams(visualParams))
{
changed = true;
if (sp.Appearance.AvatarHeight > 0)
sp.SetHeight(sp.Appearance.AvatarHeight);
// m_log.WarnFormat("[AVFACTORY]: Prepare to check textures for {0}",client.AgentId);
for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++)
{
int idx = AvatarAppearance.BAKE_INDICES[i];
Primitive.TextureEntryFace face = sp.Appearance.Texture.FaceTextures[idx];
if (face != null && face.TextureID != AppearanceManager.DEFAULT_AVATAR_TEXTURE)
Util.FireAndForget(delegate(object o) {
if (! CheckBakedTextureAsset(client,face.TextureID,idx))
client.SendRebakeAvatarTextures(face.TextureID);
});
}
// m_log.WarnFormat("[AVFACTORY]: Complete texture check for {0}",client.AgentId);
}
// Process the visual params, this may change height as well
if (visualParams != null)
{
if (sp.Appearance.SetVisualParams(visualParams))
{
changed = true;
if (sp.Appearance.AvatarHeight > 0)
sp.SetHeight(sp.Appearance.AvatarHeight);
}
}
// Send the appearance back to the avatar, not clear that this is needed
sp.ControllingClient.SendAvatarDataImmediate(sp);
// AvatarAppearance avp = sp.Appearance;
// sp.ControllingClient.SendAppearance(avp.Owner,avp.VisualParams,avp.Texture.GetBytes());
}
// If something changed in the appearance then queue an appearance save
if (changed)
@@ -192,10 +212,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
// And always queue up an appearance update to send out
QueueAppearanceSend(client.AgentId);
// Send the appearance back to the avatar
// AvatarAppearance avp = sp.Appearance;
// sp.ControllingClient.SendAvatarDataImmediate(sp);
// sp.ControllingClient.SendAppearance(avp.Owner,avp.VisualParams,avp.Texture.GetBytes());
// m_log.WarnFormat("[AVFACTORY]: Complete SetAppearance for {0}:\n{1}",client.AgentId,sp.Appearance.ToString());
}
/// <summary>
@@ -209,7 +226,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
{
if (m_scene.AssetService.Get(textureID.ToString()) == null)
{
m_log.WarnFormat("[AVATAR FACTORY MODULE]: Missing baked texture {0} ({1}) for avatar {2}",
m_log.WarnFormat("[AVFACTORY]: Missing baked texture {0} ({1}) for avatar {2}",
textureID, idx, client.Name);
return false;
}
@@ -220,10 +237,10 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
public void QueueAppearanceSend(UUID agentid)
{
// m_log.WarnFormat("[AVATAR FACTORY MODULE]: Queue appearance send for {0}", agentid);
// m_log.WarnFormat("[AVFACTORY]: Queue appearance send for {0}", agentid);
// 100 nanoseconds (ticks) we should wait
long timestamp = DateTime.Now.Ticks + Convert.ToInt64(m_sendtime * 10000000);
// 10000 ticks per millisecond, 1000 milliseconds per second
long timestamp = DateTime.Now.Ticks + Convert.ToInt64(m_sendtime * 1000 * 10000);
lock (m_sendqueue)
{
m_sendqueue[agentid] = timestamp;
@@ -233,10 +250,10 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
public void QueueAppearanceSave(UUID agentid)
{
// m_log.WarnFormat("[AVATAR FACTORY MODULE]: Queue appearance save for {0}", agentid);
// m_log.WarnFormat("[AVFACTORY]: Queue appearance save for {0}", agentid);
// 100 nanoseconds (ticks) we should wait
long timestamp = DateTime.Now.Ticks + Convert.ToInt64(m_savetime * 10000000);
// 10000 ticks per millisecond, 1000 milliseconds per second
long timestamp = DateTime.Now.Ticks + Convert.ToInt64(m_savetime * 1000 * 10000);
lock (m_savequeue)
{
m_savequeue[agentid] = timestamp;
@@ -249,15 +266,15 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
ScenePresence sp = m_scene.GetScenePresence(agentid);
if (sp == null)
{
m_log.WarnFormat("[AVATAR FACTORY MODULE]: Agent {0} no longer in the scene", agentid);
m_log.WarnFormat("[AVFACTORY]: Agent {0} no longer in the scene", agentid);
return;
}
// m_log.WarnFormat("[AVATAR FACTORY MODULE]: Handle appearance send for {0}", agentid);
// m_log.WarnFormat("[AVFACTORY]: Handle appearance send for {0}", agentid);
// Send the appearance to everyone in the scene
sp.SendAppearanceToAllOtherAgents();
sp.ControllingClient.SendAvatarDataImmediate(sp);
// sp.ControllingClient.SendAvatarDataImmediate(sp);
// Send the appearance back to the avatar
// AvatarAppearance avp = sp.Appearance;
@@ -279,10 +296,12 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
ScenePresence sp = m_scene.GetScenePresence(agentid);
if (sp == null)
{
m_log.WarnFormat("[AVATAR FACTORY MODULE]: Agent {0} no longer in the scene", agentid);
m_log.WarnFormat("[AVFACTORY]: Agent {0} no longer in the scene", agentid);
return;
}
// m_log.WarnFormat("[AVFACTORY] avatar {0} save appearance",agentid);
m_scene.AvatarService.SetAppearance(agentid, sp.Appearance);
}
@@ -330,11 +349,11 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
ScenePresence sp = m_scene.GetScenePresence(client.AgentId);
if (sp == null)
{
m_log.WarnFormat("[AVATAR FACTORY MODULE]: SendWearables unable to find presence for {0}", client.AgentId);
m_log.WarnFormat("[AVFACTORY]: SendWearables unable to find presence for {0}", client.AgentId);
return;
}
// m_log.WarnFormat("[AVATAR FACTORY MODULE]: Received request for wearables of {0}", client.AgentId);
// m_log.WarnFormat("[AVFACTORY]: Received request for wearables of {0}", client.AgentId);
client.SendWearables(sp.Appearance.Wearables, sp.Appearance.Serial++);
}
@@ -349,11 +368,11 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
ScenePresence sp = m_scene.GetScenePresence(client.AgentId);
if (sp == null)
{
m_log.WarnFormat("[AVATAR FACTORY MODULE]: AvatarIsWearing unable to find presence for {0}", client.AgentId);
m_log.WarnFormat("[AVFACTORY]: AvatarIsWearing unable to find presence for {0}", client.AgentId);
return;
}
// m_log.WarnFormat("[AVATAR FACTORY MODULE]: AvatarIsWearing called for {0}", client.AgentId);
// m_log.WarnFormat("[AVFACTORY]: AvatarIsWearing called for {0}", client.AgentId);
AvatarAppearance avatAppearance = new AvatarAppearance(sp.Appearance, false);
@@ -368,6 +387,8 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
// This could take awhile since it needs to pull inventory
SetAppearanceAssets(sp.UUID, ref avatAppearance);
// could get fancier with the locks here, but in the spirit of "last write wins"
// this should work correctly
sp.Appearance = avatAppearance;
m_scene.AvatarService.SetAppearance(client.AgentId, sp.Appearance);
}
@@ -398,7 +419,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
else
{
m_log.ErrorFormat(
"[AVATAR FACTORY MODULE]: Can't find inventory item {0} for {1}, setting to default",
"[AVFACTORY]: Can't find inventory item {0} for {1}, setting to default",
appearance.Wearables[i][j].ItemID, (WearableType)i);
appearance.Wearables[i].RemoveItem(appearance.Wearables[i][j].ItemID);
@@ -408,7 +429,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
}
else
{
m_log.WarnFormat("[AVATAR FACTORY MODULE]: user {0} has no inventory, appearance isn't going to work", userID);
m_log.WarnFormat("[AVFACTORY]: user {0} has no inventory, appearance isn't going to work", userID);
}
}
}

View File

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

View File

@@ -1200,11 +1200,16 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
}
m_log.Debug("[ENTITY TRANSFER MODULE]: Completed inform client about neighbour " + endPoint.ToString());
}
}
/// <summary>
/// Return the list of regions that are considered to be neighbours to the given scene.
/// </summary>
/// <param name="pScene"></param>
/// <param name="pRegionLocX"></param>
/// <param name="pRegionLocY"></param>
/// <returns></returns>
protected List<GridRegion> RequestNeighbours(Scene pScene, uint pRegionLocX, uint pRegionLocY)
{
RegionInfo m_regionInfo = pScene.RegionInfo;

View File

@@ -370,6 +370,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
item = new InventoryItemBase();
item.CreatorId = objectGroup.RootPart.CreatorID.ToString();
item.CreatorData = objectGroup.RootPart.CreatorData;
item.ID = UUID.Random();
item.InvType = (int)InventoryType.Object;
item.Folder = folder.ID;
@@ -569,12 +570,20 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
{
group.RootPart.Flags |= PrimFlags.Phantom;
group.RootPart.IsAttachment = true;
}
// If we're rezzing an attachment then don't ask AddNewSceneObject() to update the client since
// we'll be doing that later on. Scheduling more than one full update during the attachment
// process causes some clients to fail to display the attachment properly.
m_Scene.AddNewSceneObject(group, true, false);
// If we're rezzing an attachment then don't ask
// AddNewSceneObject() to update the client since
// we'll be doing that later on. Scheduling more
// than one full update during the attachment
// process causes some clients to fail to display
// the attachment properly.
// Also, don't persist attachments.
m_Scene.AddNewSceneObject(group, false, false);
}
else
{
m_Scene.AddNewSceneObject(group, true, false);
}
// m_log.InfoFormat("ray end point for inventory rezz is {0} {1} {2} ", RayEnd.X, RayEnd.Y, RayEnd.Z);
// if attachment we set it's asset id so object updates can reflect that

View File

@@ -0,0 +1,310 @@
/*
* 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<Scene> m_Scenes = new List<Scene>();
// The cache
Dictionary<UUID, UserData> m_UserCache = new Dictionary<UUID, UserData>();
#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<ILibraryService>(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<IUserManagement>(this);
scene.EventManager.OnNewClient += new EventManager.OnNewClientDelegate(EventManager_OnNewClient);
}
public void RemoveRegion(Scene scene)
{
scene.UnregisterModuleInterface<IUserManagement>(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);
foreach (TaskInventoryItem item in sop.TaskInventory.Values)
AddUser(item.CreatorID, item.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;
UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, id);
if (account != null)
{
user.FirstName = account.FirstName;
user.LastName = account.LastName;
// user.ProfileURL = we should initialize this to the default
}
else
{
if (creatorData != null && creatorData != string.Empty)
{
//creatorData = <endpoint>;<name>
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
{
user.FirstName = "Unknown";
user.LastName = "User";
}
}
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 = <profile url>;<name>
// 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
}
}

View File

@@ -8,6 +8,7 @@
</Dependencies>
<Extension path = "/OpenSim/RegionModules">
<RegionModule id="UserManagementModule" type="OpenSim.Region.CoreModules.Framework.UserManagement.UserManagementModule" />
<RegionModule id="EntityTransferModule" type="OpenSim.Region.CoreModules.Framework.EntityTransfer.EntityTransferModule" />
<RegionModule id="HGEntityTransferModule" type="OpenSim.Region.CoreModules.Framework.EntityTransfer.HGEntityTransferModule" />
<RegionModule id="InventoryAccessModule" type="OpenSim.Region.CoreModules.Framework.InventoryAccess.BasicInventoryAccessModule" />

View File

@@ -49,6 +49,21 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
private IInventoryService m_InventoryService;
private Scene m_Scene;
private IUserManagement m_UserManager;
private IUserManagement UserManager
{
get
{
if (m_UserManager == null)
{
m_UserManager = m_Scene.RequestModuleInterface<IUserManagement>();
}
return m_UserManager;
}
}
private bool m_Enabled = false;
public Type ReplaceableInterface
@@ -115,6 +130,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
return;
scene.RegisterModuleInterface<IInventoryService>(this);
if (m_Scene == null)
m_Scene = scene;
}
public void RemoveRegion(Scene scene)
@@ -163,7 +181,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
public InventoryCollection GetFolderContent(UUID userID, UUID folderID)
{
return m_InventoryService.GetFolderContent(userID, folderID);
InventoryCollection invCol = m_InventoryService.GetFolderContent(userID, folderID);
if (UserManager != null)
foreach (InventoryItemBase item in invCol.Items)
UserManager.AddUser(item.CreatorIdAsUuid, item.CreatorData);
return invCol;
}
public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID)

View File

@@ -47,9 +47,23 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
private bool m_Enabled = false;
private bool m_Initialized = false;
// private Scene m_Scene;
private Scene m_Scene;
private InventoryServicesConnector m_RemoteConnector;
private IUserManagement m_UserManager;
private IUserManagement UserManager
{
get
{
if (m_UserManager == null)
{
m_UserManager = m_Scene.RequestModuleInterface<IUserManagement>();
}
return m_UserManager;
}
}
public Type ReplaceableInterface
{
get { return null; }
@@ -116,6 +130,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
scene.RegisterModuleInterface<IInventoryService>(this);
m_cache.AddRegion(scene);
if (m_Scene == null)
m_Scene = scene;
}
public void RemoveRegion(Scene scene)
@@ -186,7 +203,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
UUID sessionID = GetSessionID(userID);
try
{
return m_RemoteConnector.GetFolderContent(userID.ToString(), folderID, sessionID);
InventoryCollection invCol = m_RemoteConnector.GetFolderContent(userID.ToString(), folderID, sessionID);
foreach (InventoryItemBase item in invCol.Items)
UserManager.AddUser(item.CreatorIdAsUuid, item.CreatorData);
return invCol;
}
catch (Exception e)
{

View File

@@ -56,7 +56,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
/// The maximum major version of OAR that we can read. Minor versions shouldn't need a max number since version
/// bumps here should be compatible.
/// </summary>
public static int MAX_MAJOR_VERSION = 0;
public static int MAX_MAJOR_VERSION = 1;
protected Scene m_scene;
protected Stream m_loadStream;
@@ -78,6 +78,19 @@ namespace OpenSim.Region.CoreModules.World.Archiver
/// </summary>
private IDictionary<UUID, bool> m_validUserUuids = new Dictionary<UUID, bool>();
private IUserManagement m_UserMan;
private IUserManagement UserManager
{
get
{
if (m_UserMan == null)
{
m_UserMan = m_scene.RequestModuleInterface<IUserManagement>();
}
return m_UserMan;
}
}
public ArchiveReadRequest(Scene scene, string loadPath, bool merge, bool skipAssets, Guid requestId)
{
m_scene = scene;
@@ -251,8 +264,13 @@ 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;
}
if (UserManager != null)
UserManager.AddUser(part.CreatorID, part.CreatorData);
if (!ResolveUserUuid(part.OwnerID))
part.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
@@ -276,10 +294,13 @@ namespace OpenSim.Region.CoreModules.World.Archiver
{
kvp.Value.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
}
if (!ResolveUserUuid(kvp.Value.CreatorID))
if (kvp.Value.CreatorData == null || kvp.Value.CreatorData == string.Empty)
{
kvp.Value.CreatorID = m_scene.RegionInfo.EstateSettings.EstateOwner;
if (!ResolveUserUuid(kvp.Value.CreatorID))
kvp.Value.CreatorID = m_scene.RegionInfo.EstateSettings.EstateOwner;
}
if (UserManager != null)
UserManager.AddUser(kvp.Value.CreatorID, kvp.Value.CreatorData);
}
}
}

View File

@@ -49,7 +49,17 @@ namespace OpenSim.Region.CoreModules.World.Archiver
public class ArchiveWriteRequestPreparation
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// The minimum major version of OAR that we can write.
/// </summary>
public static int MIN_MAJOR_VERSION = 0;
/// <summary>
/// The maximum major version of OAR that we can write.
/// </summary>
public static int MAX_MAJOR_VERSION = 1;
protected Scene m_scene;
protected Stream m_saveStream;
protected Guid m_requestId;
@@ -101,110 +111,137 @@ namespace OpenSim.Region.CoreModules.World.Archiver
/// <exception cref="System.IO.IOException">if there was an io problem with creating the file</exception>
public void ArchiveRegion(Dictionary<string, object> options)
{
Dictionary<UUID, AssetType> assetUuids = new Dictionary<UUID, AssetType>();
EntityBase[] entities = m_scene.GetEntities();
List<SceneObjectGroup> sceneObjects = new List<SceneObjectGroup>();
/*
foreach (ILandObject lo in m_scene.LandChannel.AllParcels())
{
if (name == lo.LandData.Name)
try
{
Dictionary<UUID, AssetType> assetUuids = new Dictionary<UUID, AssetType>();
EntityBase[] entities = m_scene.GetEntities();
List<SceneObjectGroup> sceneObjects = new List<SceneObjectGroup>();
/*
foreach (ILandObject lo in m_scene.LandChannel.AllParcels())
{
// This is the parcel we want
if (name == lo.LandData.Name)
{
// This is the parcel we want
}
}
*/
// Filter entities so that we only have scene objects.
// FIXME: Would be nicer to have this as a proper list in SceneGraph, since lots of methods
// end up having to do this
foreach (EntityBase entity in entities)
{
if (entity is SceneObjectGroup)
{
SceneObjectGroup sceneObject = (SceneObjectGroup)entity;
if (!sceneObject.IsDeleted && !sceneObject.IsAttachment)
sceneObjects.Add((SceneObjectGroup)entity);
}
}
*/
// Filter entities so that we only have scene objects.
// FIXME: Would be nicer to have this as a proper list in SceneGraph, since lots of methods
// end up having to do this
foreach (EntityBase entity in entities)
{
if (entity is SceneObjectGroup)
UuidGatherer assetGatherer = new UuidGatherer(m_scene.AssetService);
foreach (SceneObjectGroup sceneObject in sceneObjects)
{
SceneObjectGroup sceneObject = (SceneObjectGroup)entity;
if (!sceneObject.IsDeleted && !sceneObject.IsAttachment)
sceneObjects.Add((SceneObjectGroup)entity);
assetGatherer.GatherAssetUuids(sceneObject, assetUuids);
}
m_log.DebugFormat(
"[ARCHIVER]: {0} scene objects to serialize requiring save of {1} assets",
sceneObjects.Count, assetUuids.Count);
// Make sure that we also request terrain texture assets
RegionSettings regionSettings = m_scene.RegionInfo.RegionSettings;
if (regionSettings.TerrainTexture1 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_1)
assetUuids[regionSettings.TerrainTexture1] = AssetType.Texture;
if (regionSettings.TerrainTexture2 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_2)
assetUuids[regionSettings.TerrainTexture2] = AssetType.Texture;
if (regionSettings.TerrainTexture3 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_3)
assetUuids[regionSettings.TerrainTexture3] = AssetType.Texture;
if (regionSettings.TerrainTexture4 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_4)
assetUuids[regionSettings.TerrainTexture4] = AssetType.Texture;
TarArchiveWriter archiveWriter = new TarArchiveWriter(m_saveStream);
// Asynchronously request all the assets required to perform this archive operation
ArchiveWriteRequestExecution awre
= new ArchiveWriteRequestExecution(
sceneObjects,
m_scene.RequestModuleInterface<ITerrainModule>(),
m_scene.RequestModuleInterface<IRegionSerialiserModule>(),
m_scene,
archiveWriter,
m_requestId,
options);
m_log.InfoFormat("[ARCHIVER]: Creating archive file. This may take some time.");
// Write out control file. This has to be done first so that subsequent loaders will see this file first
// XXX: I know this is a weak way of doing it since external non-OAR aware tar executables will not do this
archiveWriter.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, CreateControlFile(options));
m_log.InfoFormat("[ARCHIVER]: Added control file to archive.");
new AssetsRequest(
new AssetsArchiver(archiveWriter), assetUuids,
m_scene.AssetService, awre.ReceivedAllAssets).Execute();
}
UuidGatherer assetGatherer = new UuidGatherer(m_scene.AssetService);
foreach (SceneObjectGroup sceneObject in sceneObjects)
catch (Exception)
{
assetGatherer.GatherAssetUuids(sceneObject, assetUuids);
}
m_log.DebugFormat(
"[ARCHIVER]: {0} scene objects to serialize requiring save of {1} assets",
sceneObjects.Count, assetUuids.Count);
// Make sure that we also request terrain texture assets
RegionSettings regionSettings = m_scene.RegionInfo.RegionSettings;
if (regionSettings.TerrainTexture1 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_1)
assetUuids[regionSettings.TerrainTexture1] = AssetType.Texture;
if (regionSettings.TerrainTexture2 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_2)
assetUuids[regionSettings.TerrainTexture2] = AssetType.Texture;
if (regionSettings.TerrainTexture3 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_3)
assetUuids[regionSettings.TerrainTexture3] = AssetType.Texture;
if (regionSettings.TerrainTexture4 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_4)
assetUuids[regionSettings.TerrainTexture4] = AssetType.Texture;
TarArchiveWriter archiveWriter = new TarArchiveWriter(m_saveStream);
// Asynchronously request all the assets required to perform this archive operation
ArchiveWriteRequestExecution awre
= new ArchiveWriteRequestExecution(
sceneObjects,
m_scene.RequestModuleInterface<ITerrainModule>(),
m_scene.RequestModuleInterface<IRegionSerialiserModule>(),
m_scene,
archiveWriter,
m_requestId,
options);
m_log.InfoFormat("[ARCHIVER]: Creating archive file. This may take some time.");
// Write out control file. This has to be done first so that subsequent loaders will see this file first
// XXX: I know this is a weak way of doing it since external non-OAR aware tar executables will not do this
archiveWriter.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, Create0p2ControlFile(options));
m_log.InfoFormat("[ARCHIVER]: Added control file to archive.");
new AssetsRequest(
new AssetsArchiver(archiveWriter), assetUuids,
m_scene.AssetService, awre.ReceivedAllAssets).Execute();
m_saveStream.Close();
throw;
}
}
/// <summary>
/// Create the control file for the most up to date archive
/// </summary>
/// <returns></returns>
public static string Create0p2ControlFile(Dictionary<string, object> options)
public static string CreateControlFile(Dictionary<string, object> options)
{
int majorVersion = 0, minorVersion = 5;
int majorVersion = MAX_MAJOR_VERSION, minorVersion = 0;
if (options.ContainsKey("version"))
{
minorVersion = 0;
string[] parts = options["version"].ToString().Split('.');
if (parts.Length >= 1)
majorVersion = Int32.Parse(parts[0]);
if (parts.Length >= 2)
minorVersion = Int32.Parse(parts[1]);
{
majorVersion = Int32.Parse(parts[0]);
if (parts.Length >= 2)
minorVersion = Int32.Parse(parts[1]);
}
}
if (majorVersion < MIN_MAJOR_VERSION || majorVersion > MAX_MAJOR_VERSION)
{
throw new Exception(
string.Format(
"OAR version number for save must be between {0} and {1}",
MIN_MAJOR_VERSION, MAX_MAJOR_VERSION));
}
else if (majorVersion == MAX_MAJOR_VERSION)
{
// Force 1.0
minorVersion = 0;
}
else if (majorVersion == MIN_MAJOR_VERSION)
{
// Force 0.4
minorVersion = 4;
}
m_log.InfoFormat("[ARCHIVER]: Creating version {0}.{1} OAR", majorVersion, minorVersion);
// if (majorVersion == 1)
// {
// m_log.WarnFormat("[ARCHIVER]: Please be aware that version 1.0 OARs are not compatible with OpenSim 0.7.0.2 and earlier. Please use the --version=0 option if you want to produce a compatible OAR");
// }
if (majorVersion == 1)
{
m_log.WarnFormat("[ARCHIVER]: Please be aware that version 1.0 OARs are not compatible with OpenSim 0.7.0.2 and earlier. Please use the --version=0 option if you want to produce a compatible OAR");
}
StringWriter sw = new StringWriter();
XmlTextWriter xtw = new XmlTextWriter(sw);

View File

@@ -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<string> mainParams = ops.Parse(cmdparams);

View File

@@ -122,13 +122,13 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
}
/// <summary>
/// Test saving a V0.2 OpenSim Region Archive.
/// Test saving an OpenSim Region Archive.
/// </summary>
[Test]
public void TestSaveOarV0_2()
public void TestSaveOar()
{
TestHelper.InMethod();
//log4net.Config.XmlConfigurator.Configure();
// log4net.Config.XmlConfigurator.Configure();
SceneObjectPart part1 = CreateSceneObjectPart1();
SceneObjectGroup sog1 = new SceneObjectGroup(part1);
@@ -212,10 +212,10 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
}
/// <summary>
/// Test loading a V0.2 OpenSim Region Archive.
/// Test loading an OpenSim Region Archive.
/// </summary>
[Test]
public void TestLoadOarV0_2()
public void TestLoadOar()
{
TestHelper.InMethod();
// log4net.Config.XmlConfigurator.Configure();
@@ -230,7 +230,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
// upset load
tar.WriteDir(ArchiveConstants.TERRAINS_PATH);
tar.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, ArchiveWriteRequestPreparation.Create0p2ControlFile(new Dictionary<string, Object>()));
tar.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, ArchiveWriteRequestPreparation.CreateControlFile(new Dictionary<string, Object>()));
SceneObjectPart part1 = CreateSceneObjectPart1();
SceneObjectGroup object1 = new SceneObjectGroup(part1);
@@ -317,10 +317,10 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
}
/// <summary>
/// Test loading the region settings of a V0.2 OpenSim Region Archive.
/// Test loading the region settings of an OpenSim Region Archive.
/// </summary>
[Test]
public void TestLoadOarV0_2RegionSettings()
public void TestLoadOarRegionSettings()
{
TestHelper.InMethod();
//log4net.Config.XmlConfigurator.Configure();
@@ -329,7 +329,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);
tar.WriteDir(ArchiveConstants.TERRAINS_PATH);
tar.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, ArchiveWriteRequestPreparation.Create0p2ControlFile(new Dictionary<string, Object>()));
tar.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, ArchiveWriteRequestPreparation.CreateControlFile(new Dictionary<string, Object>()));
RegionSettings rs = new RegionSettings();
rs.AgentLimit = 17;
@@ -409,10 +409,10 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
}
/// <summary>
/// Test merging a V0.2 OpenSim Region Archive into an existing scene
/// Test merging an OpenSim Region Archive into an existing scene
/// </summary>
//[Test]
public void TestMergeOarV0_2()
public void TestMergeOar()
{
TestHelper.InMethod();
//XmlConfigurator.Configure();

View File

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

View File

@@ -189,6 +189,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell
InventoryItemBase item = new InventoryItemBase();
item.CreatorId = part.CreatorID.ToString();
item.CreatorData = part.CreatorData;
item.ID = UUID.Random();
item.Owner = remoteClient.AgentId;

View File

@@ -106,14 +106,20 @@ namespace OpenSim.Region.CoreModules.World.Sound
{
SceneObjectPart part = m_scene.GetSceneObjectPart(objectID);
if (part == null)
return;
SceneObjectGroup grp = part.ParentGroup;
if (grp.IsAttachment && grp.GetAttachmentPoint() > 30)
{
objectID = ownerID;
parentID = ownerID;
ScenePresence sp;
if (!m_scene.TryGetScenePresence(objectID, out sp))
return;
}
else
{
SceneObjectGroup grp = part.ParentGroup;
if (grp.IsAttachment && grp.GetAttachmentPoint() > 30)
{
objectID = ownerID;
parentID = ownerID;
}
}
m_scene.ForEachScenePresence(delegate(ScenePresence sp)