Merge branch 'master' into careminster

Conflicts:
	OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
This commit is contained in:
Melanie
2012-03-29 00:27:35 +01:00
20 changed files with 471 additions and 85 deletions

View File

@@ -57,7 +57,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
{
public UUID PrincipalID;
public FriendInfo[] Friends;
public int Refcount;
public bool IsFriend(string friend)
{
@@ -255,6 +254,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
private void OnNewClient(IClientAPI client)
{
if (client.SceneAgent.IsChildAgent)
return;
client.OnInstantMessage += OnInstantMessage;
client.OnApproveFriendRequest += OnApproveFriendRequest;
client.OnDenyFriendRequest += OnDenyFriendRequest;
@@ -281,23 +283,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
UUID agentID = client.AgentId;
lock (m_Friends)
{
UserFriendData friendsData;
if (m_Friends.TryGetValue(agentID, out friendsData))
{
friendsData.Refcount++;
return false;
}
else
{
friendsData = new UserFriendData();
friendsData.PrincipalID = agentID;
friendsData.Friends = GetFriendsFromService(client);
friendsData.Refcount = 1;
UserFriendData friendsData = new UserFriendData();
friendsData.PrincipalID = agentID;
friendsData.Friends = GetFriendsFromService(client);
m_Friends[agentID] = friendsData;
return true;
}
m_Friends[agentID] = friendsData;
}
return true;
}
private void OnClientClosed(UUID agentID, Scene scene)
@@ -307,23 +300,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
{
// do this for root agents closing out
StatusChange(agentID, false);
}
lock (m_Friends)
{
UserFriendData friendsData;
if (m_Friends.TryGetValue(agentID, out friendsData))
{
friendsData.Refcount--;
if (friendsData.Refcount <= 0)
m_Friends.Remove(agentID);
}
lock (m_Friends)
m_Friends.Remove(agentID);
}
}
private void OnMakeRootAgent(ScenePresence sp)
{
RecacheFriends(sp.ControllingClient);
// FIXME: Ideally, we want to avoid doing this here since it sits the EventManager.OnMakeRootAgent event
// is on the critical path for transferring an avatar from one region to another.
CacheFriends(sp.ControllingClient);
}
private void OnClientLogin(IClientAPI client)
@@ -628,8 +615,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
ccm.CreateCallingCard(client.AgentId, friendID, UUID.Zero);
}
// Update the local cache
RecacheFriends(client);
// Update the local cache.
CacheFriends(client);
//
// Notify the friend
@@ -691,7 +678,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
client.SendAlertMessage("Unable to terminate friendship on this sim.");
// Update local cache
RecacheFriends(client);
CacheFriends(client);
client.SendTerminateFriend(exfriendID);
@@ -812,7 +799,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
// Update the local cache
RecacheFriends(friendClient);
CacheFriends(friendClient);
// we're done
return true;
@@ -845,7 +832,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
// the friend in this sim as root agent
friendClient.SendTerminateFriend(exfriendID);
// update local cache
RecacheFriends(friendClient);
CacheFriends(friendClient);
// we're done
return true;
}
@@ -946,19 +933,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
return FriendsService.GetFriends(client.AgentId);
}
protected void RecacheFriends(IClientAPI client)
{
// FIXME: Ideally, we want to avoid doing this here since it sits the EventManager.OnMakeRootAgent event
// is on the critical path for transferring an avatar from one region to another.
UUID agentID = client.AgentId;
lock (m_Friends)
{
UserFriendData friendsData;
if (m_Friends.TryGetValue(agentID, out friendsData))
friendsData.Friends = GetFriendsFromService(client);
}
}
/// <summary>
/// Are friends cached on this simulator for a particular user?
/// </summary>
@@ -1052,4 +1026,4 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
}
}
}
}
}

View File

@@ -121,7 +121,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
{
UUID agentID = client.AgentId;
// we do this only for the root agent
if (m_Friends[agentID].Refcount == 1)
if (!client.SceneAgent.IsChildAgent)
{
// We need to preload the user management cache with the names
// of foreign friends, just like we do with SOPs' creators
@@ -426,14 +426,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
agentClientCircuit = ((Scene)(agentClient.Scene)).AuthenticateHandler.GetAgentCircuitData(agentClient.CircuitCode);
agentUUI = Util.ProduceUserUniversalIdentifier(agentClientCircuit);
agentFriendService = agentClientCircuit.ServiceURLs["FriendsServerURI"].ToString();
RecacheFriends(agentClient);
CacheFriends(agentClient);
}
if (friendClient != null)
{
friendClientCircuit = ((Scene)(friendClient.Scene)).AuthenticateHandler.GetAgentCircuitData(friendClient.CircuitCode);
friendUUI = Util.ProduceUserUniversalIdentifier(friendClientCircuit);
friendFriendService = friendClientCircuit.ServiceURLs["FriendsServerURI"].ToString();
RecacheFriends(friendClient);
CacheFriends(friendClient);
}
m_log.DebugFormat("[HGFRIENDS MODULE] HG Friendship! thisUUI={0}; friendUUI={1}; foreignThisFriendService={2}; foreignFriendFriendService={3}",

View File

@@ -71,7 +71,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
if (name == Name)
{
InitialiseCommon(source);
IConfig transferConfig = source.Configs["HGEntityTransfer"];
IConfig transferConfig = source.Configs["HGEntityTransferModule"];
if (transferConfig != null)
m_RestrictInventoryAccessAbroad = transferConfig.GetBoolean("RestrictInventoryAccessAbroad", false);
@@ -94,6 +94,31 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
client.OnTeleportHomeRequest += TriggerTeleportHome;
client.OnTeleportLandmarkRequest += RequestTeleportLandmark;
client.OnConnectionClosed += new Action<IClientAPI>(OnConnectionClosed);
client.OnCompleteMovementToRegion += new Action<IClientAPI, bool>(OnCompleteMovementToRegion);
}
protected void OnCompleteMovementToRegion(IClientAPI client, bool arg2)
{
// HACK HACK -- just seeing how the viewer responds
// Let's send the Suitcase or the real root folder folder for incoming HG agents
// Visiting agents get their suitcase contents; incoming local users get their real root folder's content
m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: OnCompleteMovementToRegion of user {0}", client.AgentId);
object sp = null;
if (client.Scene.TryGetScenePresence(client.AgentId, out sp))
{
if (sp is ScenePresence)
{
AgentCircuitData aCircuit = ((ScenePresence)sp).Scene.AuthenticateHandler.GetAgentCircuitData(client.AgentId);
if ((aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0)
{
m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: ViaHGLogin");
if (m_RestrictInventoryAccessAbroad)
{
RestoreRootFolderContents(client);
}
}
}
}
}
@@ -105,6 +130,13 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
{
m_GatekeeperConnector = new GatekeeperServiceConnector(scene.AssetService);
m_Initialized = true;
scene.AddCommand(
"HG", this, "send inventory",
"send inventory",
"Don't use this",
HandleSendInventory);
}
}
@@ -374,7 +406,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
InventoryFolderBase root = m_Scenes[0].InventoryService.GetRootFolder(client.AgentId);
if (root != null)
{
m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Removing root inventory");
m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Removing root inventory for user {0}", client.AgentId);
InventoryCollection content = m_Scenes[0].InventoryService.GetFolderContent(client.AgentId, root.ID);
UUID[] ids = new UUID[content.Folders.Count];
int i = 0;
@@ -393,12 +425,26 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
private void RestoreRootFolderContents(IClientAPI client)
{
// Restore the user's inventory, because we removed it earlier on
InventoryFolderBase root = m_Scenes[0].InventoryService.GetRootFolder(client.AgentId);
if (root != null)
if (client is IClientCore)
{
m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Restoring root inventory");
client.SendBulkUpdateInventory(root);
IClientCore core = (IClientCore)client;
IClientInventory inv;
if (core.TryGet<IClientInventory>(out inv))
{
InventoryFolderBase root = m_Scenes[0].InventoryService.GetRootFolder(client.AgentId);
client.SendBulkUpdateInventory(root);
//if (root != null)
//{
// m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Restoring root inventory for user {0}", client.AgentId);
// InventoryCollection content = m_Scenes[0].InventoryService.GetFolderContent(client.AgentId, root.ID);
// m_log.DebugFormat("[XXX]: Folder name {0}, id {1}, parent {2}", root.Name, root.ID, root.ParentID);
// foreach (InventoryItemBase i in content.Items)
// m_log.DebugFormat("[XXX]: Name={0}, folderID={1}", i.Name, i.Folder);
// inv.SendBulkUpdateInventory(content.Folders.ToArray(), content.Items.ToArray());
//}
}
}
}
@@ -418,5 +464,14 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
region.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), (int)0);
return region;
}
protected void HandleSendInventory(string module, string[] cmd)
{
m_Scenes[0].ForEachClient(delegate(IClientAPI client)
{
RestoreRootFolderContents(client);
});
}
}
}