From a1de9bc33f4f776f91e965af8bcf1a6bbc5deb41 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Thu, 29 Mar 2012 01:08:37 +0100
Subject: Revert "Add comment about setting client.SceneAgent in
AddNewClient()"
This reverts commit 964cae4f37120db34d0d3e2f08ab998215237dfd.
---
OpenSim/Region/Framework/Scenes/Scene.cs | 3 ---
1 file changed, 3 deletions(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 44cd30a..60fe48f 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -2670,10 +2670,7 @@ namespace OpenSim.Region.Framework.Scenes
sp.IsChildAgent ? "child" : "root", sp.Name, RegionInfo.RegionName);
}
- // We must set this here so that TriggerOnNewClient and TriggerOnClientLogin can determine whether the
- // client is for a root or child agent.
client.SceneAgent = sp;
-
m_LastLogin = Util.EnvironmentTickCount();
// Cache the user's name
--
cgit v1.1
From 93ac47f0d3968650bd7758ad0981e8e5d49b8138 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Thu, 29 Mar 2012 01:08:47 +0100
Subject: Revert "Simplify friends caching by only doing this for root agents -
no functions require caching for child agents." We need to cache child agents
so that friends object edit/delete permissions will work across boarders on
regions hosted by different simulators.
This reverts commit d9f7b8549b3cb9699eb8bd54242d31aac0f8241a.
---
.../Region/ClientStack/Linden/UDP/LLClientView.cs | 4 +-
.../CoreModules/Avatar/Friends/FriendsModule.cs | 62 +++++++++++++++-------
.../CoreModules/Avatar/Friends/HGFriendsModule.cs | 6 +--
OpenSim/Region/Framework/Scenes/EventManager.cs | 3 +-
OpenSim/Region/Framework/Scenes/Scene.cs | 1 -
.../Server/IRCClientView.cs | 4 +-
.../Region/OptionalModules/World/NPC/NPCAvatar.cs | 2 +-
7 files changed, 53 insertions(+), 29 deletions(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
index 9899669..cd81df5 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
@@ -384,7 +384,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
set { m_startpos = value; }
}
public UUID AgentId { get { return m_agentId; } }
- public ISceneAgent SceneAgent { get; set; }
+ public ISceneAgent SceneAgent { get; private set; }
public UUID ActiveGroupId { get { return m_activeGroupID; } }
public string ActiveGroupName { get { return m_activeGroupName; } }
public ulong ActiveGroupPowers { get { return m_activeGroupPowers; } }
@@ -695,7 +695,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public virtual void Start()
{
- m_scene.AddNewClient(this, PresenceType.User);
+ SceneAgent = m_scene.AddNewClient(this, PresenceType.User);
RefreshGroupMembership();
}
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
index 4cc0e19..aadd3bc 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
@@ -57,6 +57,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
{
public UUID PrincipalID;
public FriendInfo[] Friends;
+ public int Refcount;
public bool IsFriend(string friend)
{
@@ -254,9 +255,6 @@ 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;
@@ -283,14 +281,23 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
UUID agentID = client.AgentId;
lock (m_Friends)
{
- UserFriendData friendsData = new UserFriendData();
- friendsData.PrincipalID = agentID;
- friendsData.Friends = GetFriendsFromService(client);
+ 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;
- m_Friends[agentID] = friendsData;
+ m_Friends[agentID] = friendsData;
+ return true;
+ }
}
-
- return true;
}
private void OnClientClosed(UUID agentID, Scene scene)
@@ -300,17 +307,23 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
{
// do this for root agents closing out
StatusChange(agentID, false);
+ }
- lock (m_Friends)
- m_Friends.Remove(agentID);
+ lock (m_Friends)
+ {
+ UserFriendData friendsData;
+ if (m_Friends.TryGetValue(agentID, out friendsData))
+ {
+ friendsData.Refcount--;
+ if (friendsData.Refcount <= 0)
+ m_Friends.Remove(agentID);
+ }
}
}
private void OnMakeRootAgent(ScenePresence sp)
{
- // 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);
+ RecacheFriends(sp.ControllingClient);
}
private void OnClientLogin(IClientAPI client)
@@ -616,7 +629,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
}
// Update the local cache.
- CacheFriends(client);
+ RecacheFriends(client);
//
// Notify the friend
@@ -678,7 +691,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
client.SendAlertMessage("Unable to terminate friendship on this sim.");
// Update local cache
- CacheFriends(client);
+ RecacheFriends(client);
client.SendTerminateFriend(exfriendID);
@@ -799,7 +812,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
// Update the local cache
- CacheFriends(friendClient);
+ RecacheFriends(friendClient);
// we're done
return true;
@@ -832,7 +845,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
// the friend in this sim as root agent
friendClient.SendTerminateFriend(exfriendID);
// update local cache
- CacheFriends(friendClient);
+ RecacheFriends(friendClient);
// we're done
return true;
}
@@ -933,6 +946,19 @@ 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);
+ }
+ }
+
///
/// Are friends cached on this simulator for a particular user?
///
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs
index 7bc3018..e50a84a 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs
@@ -121,7 +121,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
{
UUID agentID = client.AgentId;
// we do this only for the root agent
- if (!client.SceneAgent.IsChildAgent)
+ if (m_Friends[agentID].Refcount == 1)
{
// 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();
- CacheFriends(agentClient);
+ RecacheFriends(agentClient);
}
if (friendClient != null)
{
friendClientCircuit = ((Scene)(friendClient.Scene)).AuthenticateHandler.GetAgentCircuitData(friendClient.CircuitCode);
friendUUI = Util.ProduceUserUniversalIdentifier(friendClientCircuit);
friendFriendService = friendClientCircuit.ServiceURLs["FriendsServerURI"].ToString();
- CacheFriends(friendClient);
+ RecacheFriends(friendClient);
}
m_log.DebugFormat("[HGFRIENDS MODULE] HG Friendship! thisUUI={0}; friendUUI={1}; foreignThisFriendService={2}; foreignFriendFriendService={3}",
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs
index fe3438e..7993abe 100644
--- a/OpenSim/Region/Framework/Scenes/EventManager.cs
+++ b/OpenSim/Region/Framework/Scenes/EventManager.cs
@@ -71,7 +71,6 @@ namespace OpenSim.Region.Framework.Scenes
/// Triggered when a new client is added to the scene.
///
///
- /// This is triggered for both child and root agent client connections.
/// Triggered before OnClientLogin.
///
public event OnNewClientDelegate OnNewClient;
@@ -192,7 +191,7 @@ namespace OpenSim.Region.Framework.Scenes
public delegate void ClientClosed(UUID clientID, Scene scene);
///
- /// Fired when a client is removed from a scene whether it's a child or a root agent.
+ /// Fired when a client is removed from a scene.
///
///
/// At the point of firing, the scene still contains the client's scene presence.
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 60fe48f..c887b4e 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -2670,7 +2670,6 @@ namespace OpenSim.Region.Framework.Scenes
sp.IsChildAgent ? "child" : "root", sp.Name, RegionInfo.RegionName);
}
- client.SceneAgent = sp;
m_LastLogin = Util.EnvironmentTickCount();
// Cache the user's name
diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
index 43548e6..5cf478a 100644
--- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
+++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
@@ -55,7 +55,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
private UUID m_agentID = UUID.Random();
- public ISceneAgent SceneAgent { get; set; }
+ public ISceneAgent SceneAgent { get; private set; }
private string m_username;
private string m_nick;
@@ -895,7 +895,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
public void Start()
{
- m_scene.AddNewClient(this, PresenceType.User);
+ SceneAgent = m_scene.AddNewClient(this, PresenceType.User);
// Mimicking LLClientView which gets always set appearance from client.
AvatarAppearance appearance;
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
index 5ea5af7..16ec34f 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
@@ -72,7 +72,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
get { return m_ownerID; }
}
- public ISceneAgent SceneAgent { get; set; }
+ public ISceneAgent SceneAgent { get { throw new NotImplementedException(); } }
public void Say(string message)
{
--
cgit v1.1
From bd83676d6c01b59c5d2b55f81e5f3ce9885f450e Mon Sep 17 00:00:00 2001
From: Melanie
Date: Thu, 29 Mar 2012 01:13:08 +0100
Subject: Change namespace on CallingCardModule and correct interface file
placemant. Also ass OpenSource header
---
.../Avatar/Friends/CallingCardModule.cs | 31 ++++++++++++++++++++--
.../Framework/Interfaces/ICallingCardModule.cs | 13 +++++++++
2 files changed, 42 insertions(+), 2 deletions(-)
create mode 100644 OpenSim/Region/Framework/Interfaces/ICallingCardModule.cs
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/CallingCardModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/CallingCardModule.cs
index 5e2a651..d942e87 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/CallingCardModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/CallingCardModule.cs
@@ -1,4 +1,31 @@
-using System;
+/*
+ * 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.Reflection;
using log4net;
@@ -10,7 +37,7 @@ using OpenSim.Region.Framework.Scenes;
using OpenSim.Services.Interfaces;
using Mono.Addins;
-namespace Careminster.XCallingCard.Modules
+namespace OpenSim.Region.CoreModules.Avatar.Friends
{
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "XCallingCard")]
public class CallingCardModule : ISharedRegionModule, ICallingCardModule
diff --git a/OpenSim/Region/Framework/Interfaces/ICallingCardModule.cs b/OpenSim/Region/Framework/Interfaces/ICallingCardModule.cs
new file mode 100644
index 0000000..17e6de35
--- /dev/null
+++ b/OpenSim/Region/Framework/Interfaces/ICallingCardModule.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using OpenMetaverse;
+using OpenSim.Framework;
+
+namespace OpenSim.Framework
+{
+ public interface ICallingCardModule
+ {
+ UUID CreateCallingCard(UUID userID, UUID creatorID, UUID folderID);
+ }
+}
--
cgit v1.1
From 62b1c807c2f1450cb29a7ba44b7e8c01c46383b3 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Thu, 29 Mar 2012 01:14:50 +0100
Subject: Also add OSS header to interface
---
.../Framework/Interfaces/ICallingCardModule.cs | 29 +++++++++++++++++++++-
1 file changed, 28 insertions(+), 1 deletion(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/Framework/Interfaces/ICallingCardModule.cs b/OpenSim/Region/Framework/Interfaces/ICallingCardModule.cs
index 17e6de35..69682ac 100644
--- a/OpenSim/Region/Framework/Interfaces/ICallingCardModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/ICallingCardModule.cs
@@ -1,4 +1,31 @@
-using System;
+/*
+ * 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.Text;
using OpenMetaverse;
--
cgit v1.1
From 22a85b947a16074525343a56203211806ce16834 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Thu, 29 Mar 2012 01:26:30 +0100
Subject: Add back parts of reverted changes that were not concerned with child
agent caching.
This adds ScenePresence to IClientAPI.SceneAgent earlier on in the add client process so that its information is available to EventManager.OnNewClient() and OnClientLogin()
Also add a code comment as to why we're caching friend information for child agents.
---
OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | 4 ++--
OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs | 3 +++
OpenSim/Region/Framework/Scenes/EventManager.cs | 3 ++-
OpenSim/Region/Framework/Scenes/Scene.cs | 4 ++++
.../Agent/InternetRelayClientView/Server/IRCClientView.cs | 4 ++--
OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs | 2 +-
6 files changed, 14 insertions(+), 6 deletions(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
index cd81df5..9899669 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
@@ -384,7 +384,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
set { m_startpos = value; }
}
public UUID AgentId { get { return m_agentId; } }
- public ISceneAgent SceneAgent { get; private set; }
+ public ISceneAgent SceneAgent { get; set; }
public UUID ActiveGroupId { get { return m_activeGroupID; } }
public string ActiveGroupName { get { return m_activeGroupName; } }
public ulong ActiveGroupPowers { get { return m_activeGroupPowers; } }
@@ -695,7 +695,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public virtual void Start()
{
- SceneAgent = m_scene.AddNewClient(this, PresenceType.User);
+ m_scene.AddNewClient(this, PresenceType.User);
RefreshGroupMembership();
}
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
index aadd3bc..0c83679 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
@@ -261,6 +261,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
client.OnTerminateFriendship += (thisClient, agentID, exfriendID) => RemoveFriendship(thisClient, exfriendID);
client.OnGrantUserRights += OnGrantUserRights;
+ // We need to cache information for child agents as well as root agents so that friend edit/move/delete
+ // permissions will work across borders where both regions are on different simulators.
+ //
// Do not do this asynchronously. If we do, then subsequent code can outrace CacheFriends() and
// return misleading results from the still empty friends cache.
// If we absolutely need to do this asynchronously, then a signalling mechanism is needed so that calls
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs
index 7993abe..fe3438e 100644
--- a/OpenSim/Region/Framework/Scenes/EventManager.cs
+++ b/OpenSim/Region/Framework/Scenes/EventManager.cs
@@ -71,6 +71,7 @@ namespace OpenSim.Region.Framework.Scenes
/// Triggered when a new client is added to the scene.
///
///
+ /// This is triggered for both child and root agent client connections.
/// Triggered before OnClientLogin.
///
public event OnNewClientDelegate OnNewClient;
@@ -191,7 +192,7 @@ namespace OpenSim.Region.Framework.Scenes
public delegate void ClientClosed(UUID clientID, Scene scene);
///
- /// Fired when a client is removed from a scene.
+ /// Fired when a client is removed from a scene whether it's a child or a root agent.
///
///
/// At the point of firing, the scene still contains the client's scene presence.
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index c887b4e..44cd30a 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -2670,6 +2670,10 @@ namespace OpenSim.Region.Framework.Scenes
sp.IsChildAgent ? "child" : "root", sp.Name, RegionInfo.RegionName);
}
+ // We must set this here so that TriggerOnNewClient and TriggerOnClientLogin can determine whether the
+ // client is for a root or child agent.
+ client.SceneAgent = sp;
+
m_LastLogin = Util.EnvironmentTickCount();
// Cache the user's name
diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
index 5cf478a..43548e6 100644
--- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
+++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
@@ -55,7 +55,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
private UUID m_agentID = UUID.Random();
- public ISceneAgent SceneAgent { get; private set; }
+ public ISceneAgent SceneAgent { get; set; }
private string m_username;
private string m_nick;
@@ -895,7 +895,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
public void Start()
{
- SceneAgent = m_scene.AddNewClient(this, PresenceType.User);
+ m_scene.AddNewClient(this, PresenceType.User);
// Mimicking LLClientView which gets always set appearance from client.
AvatarAppearance appearance;
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
index 16ec34f..5ea5af7 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
@@ -72,7 +72,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
get { return m_ownerID; }
}
- public ISceneAgent SceneAgent { get { throw new NotImplementedException(); } }
+ public ISceneAgent SceneAgent { get; set; }
public void Say(string message)
{
--
cgit v1.1
From 012b01f224dac8259eb0978aa7ef5a098924b7c8 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Thu, 29 Mar 2012 03:19:45 +0100
Subject: Add simple regression test for logging in with offline friends.
Don't expect to receive any in this instance.
---
.../Avatar/Friends/Tests/FriendModuleTests.cs | 47 +++++++++++++++++++++-
1 file changed, 46 insertions(+), 1 deletion(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/Tests/FriendModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Friends/Tests/FriendModuleTests.cs
index 682fbab..34c68cc 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/Tests/FriendModuleTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/Tests/FriendModuleTests.cs
@@ -44,6 +44,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends.Tests
private FriendsModule m_fm;
private TestScene m_scene;
+ [TestFixtureSetUp]
+ public void FixtureInit()
+ {
+ // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread.
+ Util.FireAndForgetMethod = FireAndForgetMethod.RegressionTest;
+ }
+
+ [TestFixtureTearDown]
+ public void TearDown()
+ {
+ // We must set this back afterwards, otherwise later tests will fail since they're expecting multiple
+ // threads. Possibly, later tests should be rewritten so none of them require async stuff (which regression
+ // tests really shouldn't).
+ Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod;
+ }
+
[SetUp]
public void Init()
{
@@ -62,7 +78,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends.Tests
}
[Test]
- public void TestNoFriends()
+ public void TestLoginWithNoFriends()
{
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
@@ -76,6 +92,35 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends.Tests
}
[Test]
+ public void TestLoginWithOfflineFriends()
+ {
+ TestHelpers.InMethod();
+// log4net.Config.XmlConfigurator.Configure();
+
+ UUID user1Id = TestHelpers.ParseTail(0x1);
+ UUID user2Id = TestHelpers.ParseTail(0x2);
+
+// UserAccountHelpers.CreateUserWithInventory(m_scene, user1Id);
+// UserAccountHelpers.CreateUserWithInventory(m_scene, user2Id);
+//
+// m_fm.AddFriendship(user1Id, user2Id);
+
+ ScenePresence sp1 = SceneHelpers.AddScenePresence(m_scene, user1Id);
+ ScenePresence sp2 = SceneHelpers.AddScenePresence(m_scene, user2Id);
+
+ m_fm.AddFriendship(sp1.ControllingClient, user2Id);
+
+ m_scene.RemoveClient(sp1.UUID, true);
+ m_scene.RemoveClient(sp2.UUID, true);
+
+ ScenePresence sp1Redux = SceneHelpers.AddScenePresence(m_scene, user1Id);
+
+ // We don't expect to receive notifications of offline friends on login, just online.
+ Assert.That(((TestClient)sp1Redux.ControllingClient).ReceivedOfflineNotifications.Count, Is.EqualTo(0));
+ Assert.That(((TestClient)sp1Redux.ControllingClient).ReceivedOnlineNotifications.Count, Is.EqualTo(0));
+ }
+
+ [Test]
public void TestAddFriendshipWhileOnline()
{
TestHelpers.InMethod();
--
cgit v1.1
From bf09d6a22be5f8e7a2584eaa11ccbc1c61cc6753 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Thu, 29 Mar 2012 18:31:57 +0100
Subject: refactor: Stop passing both IClientAPI and agentID to friend event
listeners, these are redundant. Replace a few magic numbers with
FriendRights enum already used elsewhere.
---
.../Region/ClientStack/Linden/UDP/LLClientView.cs | 13 ++++---
.../CoreModules/Avatar/Friends/FriendsModule.cs | 40 ++++++++++++----------
.../CoreModules/Avatar/Friends/HGFriendsModule.cs | 4 +--
.../Avatar/Friends/Tests/FriendModuleTests.cs | 28 +++++++++++++++
4 files changed, 58 insertions(+), 27 deletions(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
index 9899669..f79597e 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
@@ -5784,7 +5784,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
// My guess is this is the folder to stick the calling card into
List callingCardFolders = new List();
- UUID agentID = afriendpack.AgentData.AgentID;
UUID transactionID = afriendpack.TransactionBlock.TransactionID;
for (int fi = 0; fi < afriendpack.FolderData.Length; fi++)
@@ -5795,10 +5794,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
FriendActionDelegate handlerApproveFriendRequest = OnApproveFriendRequest;
if (handlerApproveFriendRequest != null)
{
- handlerApproveFriendRequest(this, agentID, transactionID, callingCardFolders);
+ handlerApproveFriendRequest(this, transactionID, callingCardFolders);
}
- return true;
+ return true;
}
private bool HandlerDeclineFriendship(IClientAPI sender, Packet Pack)
@@ -5817,7 +5816,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
if (OnDenyFriendRequest != null)
{
OnDenyFriendRequest(this,
- dfriendpack.AgentData.AgentID,
dfriendpack.TransactionBlock.TransactionID,
null);
}
@@ -5837,14 +5835,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP
}
#endregion
- UUID listOwnerAgentID = tfriendpack.AgentData.AgentID;
UUID exFriendID = tfriendpack.ExBlock.OtherID;
FriendshipTermination TerminateFriendshipHandler = OnTerminateFriendship;
if (TerminateFriendshipHandler != null)
{
- TerminateFriendshipHandler(this, listOwnerAgentID, exFriendID);
+ TerminateFriendshipHandler(this, exFriendID);
return true;
}
+
return false;
}
@@ -11162,12 +11160,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
return true;
}
#endregion
+
GrantUserFriendRights GrantUserRightsHandler = OnGrantUserRights;
if (GrantUserRightsHandler != null)
GrantUserRightsHandler(this,
- GrantUserRights.AgentData.AgentID,
GrantUserRights.Rights[0].AgentRelated,
GrantUserRights.Rights[0].RelatedRights);
+
return true;
}
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
index 0c83679..86e04b9 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
@@ -258,7 +258,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
client.OnInstantMessage += OnInstantMessage;
client.OnApproveFriendRequest += OnApproveFriendRequest;
client.OnDenyFriendRequest += OnDenyFriendRequest;
- client.OnTerminateFriendship += (thisClient, agentID, exfriendID) => RemoveFriendship(thisClient, exfriendID);
+ client.OnTerminateFriendship += RemoveFriendship;
client.OnGrantUserRights += OnGrantUserRights;
// We need to cache information for child agents as well as root agents so that friend edit/move/delete
@@ -355,14 +355,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
// Send the friends online
List online = GetOnlineFriends(agentID);
- if (online.Count > 0)
- {
- m_log.DebugFormat(
- "[FRIENDS MODULE]: User {0} in region {1} has {2} friends online",
- client.Name, client.Scene.RegionInfo.RegionName, online.Count);
+// m_log.DebugFormat(
+// "[FRIENDS MODULE]: User {0} in region {1} has {2} friends online",
+// client.Name, client.Scene.RegionInfo.RegionName, online.Count);
+
+ if (online.Count > 0)
client.SendAgentOnline(online.ToArray());
- }
// Send outstanding friendship offers
List outstanding = new List();
@@ -495,7 +494,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
List friendList = new List();
foreach (FriendInfo fi in friends)
{
- if (((fi.MyFlags & 1) != 0) && (fi.TheirFlags != -1))
+ if (((fi.MyFlags & (int)FriendRights.CanSeeOnline) != 0) && (fi.TheirFlags != -1))
friendList.Add(fi);
}
@@ -614,7 +613,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
return (account == null) ? "Unknown" : account.FirstName + " " + account.LastName;
}
- protected virtual void OnApproveFriendRequest(IClientAPI client, UUID agentID, UUID friendID, List callingCardFolders)
+ protected virtual void OnApproveFriendRequest(IClientAPI client, UUID friendID, List callingCardFolders)
{
m_log.DebugFormat("[FRIENDS]: {0} accepted friendship from {1}", client.AgentId, friendID);
@@ -659,18 +658,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
}
}
- private void OnDenyFriendRequest(IClientAPI client, UUID agentID, UUID friendID, List callingCardFolders)
+ private void OnDenyFriendRequest(IClientAPI client, UUID friendID, List callingCardFolders)
{
- m_log.DebugFormat("[FRIENDS]: {0} denied friendship to {1}", agentID, friendID);
+ m_log.DebugFormat("[FRIENDS]: {0} denied friendship to {1}", client.AgentId, friendID);
- DeleteFriendship(agentID, friendID);
+ DeleteFriendship(client.AgentId, friendID);
//
// Notify the friend
//
// Try local
- if (LocalFriendshipDenied(agentID, client.Name, friendID))
+ if (LocalFriendshipDenied(client.AgentId, client.Name, friendID))
return;
PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() });
@@ -681,7 +680,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
{
GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID);
if (region != null)
- m_FriendsSimConnector.FriendshipDenied(region, agentID, client.Name, friendID);
+ m_FriendsSimConnector.FriendshipDenied(region, client.AgentId, client.Name, friendID);
else
m_log.WarnFormat("[FRIENDS]: Could not find region {0} in locating {1}", friendSession.RegionID, friendID);
}
@@ -718,11 +717,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
}
}
- private void OnGrantUserRights(IClientAPI remoteClient, UUID requester, UUID target, int rights)
+ private void OnGrantUserRights(IClientAPI remoteClient, UUID target, int rights)
{
- m_log.DebugFormat("[FRIENDS MODULE]: User {0} changing rights to {1} for friend {2}", requester, rights, target);
+ UUID requester = remoteClient.AgentId;
- FriendInfo[] friends = GetFriends(remoteClient.AgentId);
+ m_log.DebugFormat(
+ "[FRIENDS MODULE]: User {0} changing rights to {1} for friend {2}",
+ requester, rights, target);
+
+ FriendInfo[] friends = GetFriends(requester);
if (friends.Length == 0)
{
return;
@@ -769,7 +772,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
}
}
else
+ {
m_log.DebugFormat("[FRIENDS MODULE]: friend {0} not found for {1}", target, requester);
+ }
}
protected virtual FriendInfo GetFriend(FriendInfo[] friends, UUID friendID)
@@ -813,7 +818,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
ccm.CreateCallingCard(friendID, userID, UUID.Zero);
}
-
// Update the local cache
RecacheFriends(friendClient);
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs
index e50a84a..b666dae 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs
@@ -105,12 +105,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
#endregion
- protected override void OnApproveFriendRequest(IClientAPI client, UUID agentID, UUID friendID, List callingCardFolders)
+ protected override void OnApproveFriendRequest(IClientAPI client, UUID friendID, List callingCardFolders)
{
// Update the local cache. Yes, we need to do it right here
// because the HGFriendsService placed something on the DB
// from under the sim
- base.OnApproveFriendRequest(client, agentID, friendID, callingCardFolders);
+ base.OnApproveFriendRequest(client, friendID, callingCardFolders);
}
protected override bool CacheFriends(IClientAPI client)
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/Tests/FriendModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Friends/Tests/FriendModuleTests.cs
index 34c68cc..94a78cb 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/Tests/FriendModuleTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/Tests/FriendModuleTests.cs
@@ -120,6 +120,34 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends.Tests
Assert.That(((TestClient)sp1Redux.ControllingClient).ReceivedOnlineNotifications.Count, Is.EqualTo(0));
}
+// [Test]
+// public void TestLoginWithOnlineFriends()
+// {
+// TestHelpers.InMethod();
+// log4net.Config.XmlConfigurator.Configure();
+//
+// UUID user1Id = TestHelpers.ParseTail(0x1);
+// UUID user2Id = TestHelpers.ParseTail(0x2);
+//
+//// UserAccountHelpers.CreateUserWithInventory(m_scene, user1Id);
+//// UserAccountHelpers.CreateUserWithInventory(m_scene, user2Id);
+////
+//// m_fm.AddFriendship(user1Id, user2Id);
+//
+// ScenePresence sp1 = SceneHelpers.AddScenePresence(m_scene, user1Id);
+// SceneHelpers.AddScenePresence(m_scene, user2Id);
+//
+// m_fm.AddFriendship(sp1.ControllingClient, user2Id);
+//// m_fm.LocalGrantRights
+//
+// m_scene.RemoveClient(sp1.UUID, true);
+//
+// ScenePresence sp1Redux = SceneHelpers.AddScenePresence(m_scene, user1Id);
+//
+// Assert.That(((TestClient)sp1Redux.ControllingClient).ReceivedOfflineNotifications.Count, Is.EqualTo(0));
+// Assert.That(((TestClient)sp1Redux.ControllingClient).ReceivedOnlineNotifications.Count, Is.EqualTo(1));
+// }
+
[Test]
public void TestAddFriendshipWhileOnline()
{
--
cgit v1.1
From 59157d9d63c0e038ca0a619bfae1be3ed6f77677 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 30 Mar 2012 00:40:19 +0100
Subject: Add simple login test with online friends. Add
IFriendsModule.GrantRights() for granting rights via a module call.
Rename IFriendsModule.GetFriendPerms() -> GetRightsGrantedByFriend() to be more self-documenting and consistent with friends module terminology.
Add some method doc.
---
.../CoreModules/Avatar/Friends/FriendsModule.cs | 50 ++++++++-------
.../Avatar/Friends/Tests/FriendModuleTests.cs | 73 ++++++++++++++--------
.../Presence/PresenceDetector.cs | 9 +--
.../World/Permissions/PermissionsModule.cs | 10 ++-
.../Region/Framework/Interfaces/IFriendsModule.cs | 24 ++++++-
5 files changed, 102 insertions(+), 64 deletions(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
index 86e04b9..9d7012e 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
@@ -51,6 +51,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
{
public class FriendsModule : ISharedRegionModule, IFriendsModule
{
+ private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+
protected bool m_Enabled = false;
protected class UserFriendData
@@ -72,7 +74,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
}
protected static readonly FriendInfo[] EMPTY_FRIENDS = new FriendInfo[0];
- private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
protected List m_Scenes = new List();
@@ -156,7 +157,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
InitModule(config);
m_Enabled = true;
- m_log.InfoFormat("[FRIENDS MODULE]: {0} enabled.", Name);
+ m_log.DebugFormat("[FRIENDS MODULE]: {0} enabled.", Name);
}
}
}
@@ -201,7 +202,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
if (!m_Enabled)
return;
- m_log.DebugFormat("[FRIENDS MODULE]: AddRegion on {0}", Name);
+// m_log.DebugFormat("[FRIENDS MODULE]: AddRegion on {0}", Name);
m_Scenes.Add(scene);
scene.RegisterModuleInterface(this);
@@ -241,13 +242,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
#endregion
- public virtual uint GetFriendPerms(UUID principalID, UUID friendID)
+ public virtual int GetRightsGrantedByFriend(UUID principalID, UUID friendID)
{
FriendInfo[] friends = GetFriends(principalID);
FriendInfo finfo = GetFriend(friends, friendID);
if (finfo != null)
{
- return (uint)finfo.TheirFlags;
+ return finfo.TheirFlags;
}
return 0;
@@ -259,7 +260,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
client.OnApproveFriendRequest += OnApproveFriendRequest;
client.OnDenyFriendRequest += OnDenyFriendRequest;
client.OnTerminateFriendship += RemoveFriendship;
- client.OnGrantUserRights += OnGrantUserRights;
+ client.OnGrantUserRights += GrantRights;
// We need to cache information for child agents as well as root agents so that friend edit/move/delete
// permissions will work across borders where both regions are on different simulators.
@@ -356,10 +357,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
// Send the friends online
List online = GetOnlineFriends(agentID);
-// m_log.DebugFormat(
-// "[FRIENDS MODULE]: User {0} in region {1} has {2} friends online",
-// client.Name, client.Scene.RegionInfo.RegionName, online.Count);
-
if (online.Count > 0)
client.SendAgentOnline(online.ToArray());
@@ -421,23 +418,30 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
List GetOnlineFriends(UUID userID)
{
List friendList = new List();
- List online = new List();
FriendInfo[] friends = GetFriends(userID);
foreach (FriendInfo fi in friends)
{
- if (((fi.TheirFlags & 1) != 0) && (fi.TheirFlags != -1))
+ if (((fi.TheirFlags & (int)FriendRights.CanSeeOnline) != 0) && (fi.TheirFlags != -1))
friendList.Add(fi.Friend);
}
+ List online = new List();
+
if (friendList.Count > 0)
GetOnlineFriends(userID, friendList, online);
+// m_log.DebugFormat(
+// "[FRIENDS MODULE]: User {0} has {1} friends online", userID, online.Count);
+
return online;
}
protected virtual void GetOnlineFriends(UUID userID, List friendList, /*collector*/ List online)
{
+// m_log.DebugFormat(
+// "[FRIENDS MODULE]: Looking for online presence of {0} users for {1}", friendList.Count, userID);
+
PresenceInfo[] presence = PresenceService.GetAgents(friendList.ToArray());
foreach (PresenceInfo pi in presence)
{
@@ -717,13 +721,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
}
}
- private void OnGrantUserRights(IClientAPI remoteClient, UUID target, int rights)
+ public void GrantRights(IClientAPI remoteClient, UUID friendID, int rights)
{
UUID requester = remoteClient.AgentId;
m_log.DebugFormat(
"[FRIENDS MODULE]: User {0} changing rights to {1} for friend {2}",
- requester, rights, target);
+ requester, rights, friendID);
FriendInfo[] friends = GetFriends(requester);
if (friends.Length == 0)
@@ -732,12 +736,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
}
// Let's find the friend in this user's friend list
- FriendInfo friend = GetFriend(friends, target);
+ FriendInfo friend = GetFriend(friends, friendID);
if (friend != null) // Found it
{
// Store it on the DB
- if (!StoreRights(requester, target, rights))
+ if (!StoreRights(requester, friendID, rights))
{
remoteClient.SendAlertMessage("Unable to grant rights.");
return;
@@ -748,17 +752,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
friend.MyFlags = rights;
// Always send this back to the original client
- remoteClient.SendChangeUserRights(requester, target, rights);
+ remoteClient.SendChangeUserRights(requester, friendID, rights);
//
// Notify the friend
//
// Try local
- if (LocalGrantRights(requester, target, myFlags, rights))
+ if (LocalGrantRights(requester, friendID, myFlags, rights))
return;
- PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { target.ToString() });
+ PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() });
if (friendSessions != null && friendSessions.Length > 0)
{
PresenceInfo friendSession = friendSessions[0];
@@ -767,13 +771,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID);
// TODO: You might want to send the delta to save the lookup
// on the other end!!
- m_FriendsSimConnector.GrantRights(region, requester, target, myFlags, rights);
+ m_FriendsSimConnector.GrantRights(region, requester, friendID, myFlags, rights);
}
}
}
else
{
- m_log.DebugFormat("[FRIENDS MODULE]: friend {0} not found for {1}", target, requester);
+ m_log.DebugFormat("[FRIENDS MODULE]: friend {0} not found for {1}", friendID, requester);
}
}
@@ -990,8 +994,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
protected virtual void StoreFriendships(UUID agentID, UUID friendID)
{
- FriendsService.StoreFriend(agentID.ToString(), friendID.ToString(), 1);
- FriendsService.StoreFriend(friendID.ToString(), agentID.ToString(), 1);
+ FriendsService.StoreFriend(agentID.ToString(), friendID.ToString(), (int)FriendRights.CanSeeOnline);
+ FriendsService.StoreFriend(friendID.ToString(), agentID.ToString(), (int)FriendRights.CanSeeOnline);
}
protected virtual bool DeleteFriendship(UUID agentID, UUID exfriendID)
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/Tests/FriendModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Friends/Tests/FriendModuleTests.cs
index 94a78cb..45b4264 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/Tests/FriendModuleTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/Tests/FriendModuleTests.cs
@@ -30,6 +30,7 @@ using System.Collections.Generic;
using Nini.Config;
using NUnit.Framework;
using OpenMetaverse;
+using OpenSim.Data.Null;
using OpenSim.Framework;
using OpenSim.Region.CoreModules.Avatar.Friends;
using OpenSim.Region.Framework.Scenes;
@@ -63,6 +64,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends.Tests
[SetUp]
public void Init()
{
+ // We must clear friends data between tests since Data.Null holds it in static properties. This is necessary
+ // so that different services and simulator can share the data in standalone mode. This is pretty horrible
+ // effectively the statics are global variables.
+ NullFriendsData.Clear();
+
IConfigSource config = new IniConfigSource();
config.AddConfig("Modules");
// Not strictly necessary since FriendsModule assumes it is the default (!)
@@ -110,8 +116,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends.Tests
m_fm.AddFriendship(sp1.ControllingClient, user2Id);
- m_scene.RemoveClient(sp1.UUID, true);
- m_scene.RemoveClient(sp2.UUID, true);
+ // Not necessary for this test. CanSeeOnline is automatically granted.
+// m_fm.GrantRights(sp1.ControllingClient, user2Id, (int)FriendRights.CanSeeOnline);
+
+ // We must logout from the client end so that the presence service is correctly updated by the presence
+ // detector. This is listening to the OnConnectionClosed event on the client.
+ ((TestClient)sp1.ControllingClient).Logout();
+ ((TestClient)sp2.ControllingClient).Logout();
+// m_scene.RemoveClient(sp1.UUID, true);
+// m_scene.RemoveClient(sp2.UUID, true);
ScenePresence sp1Redux = SceneHelpers.AddScenePresence(m_scene, user1Id);
@@ -120,33 +133,39 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends.Tests
Assert.That(((TestClient)sp1Redux.ControllingClient).ReceivedOnlineNotifications.Count, Is.EqualTo(0));
}
-// [Test]
-// public void TestLoginWithOnlineFriends()
-// {
-// TestHelpers.InMethod();
+ [Test]
+ public void TestLoginWithOnlineFriends()
+ {
+ TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
+
+ UUID user1Id = TestHelpers.ParseTail(0x1);
+ UUID user2Id = TestHelpers.ParseTail(0x2);
+
+// UserAccountHelpers.CreateUserWithInventory(m_scene, user1Id);
+// UserAccountHelpers.CreateUserWithInventory(m_scene, user2Id);
//
-// UUID user1Id = TestHelpers.ParseTail(0x1);
-// UUID user2Id = TestHelpers.ParseTail(0x2);
-//
-//// UserAccountHelpers.CreateUserWithInventory(m_scene, user1Id);
-//// UserAccountHelpers.CreateUserWithInventory(m_scene, user2Id);
-////
-//// m_fm.AddFriendship(user1Id, user2Id);
-//
-// ScenePresence sp1 = SceneHelpers.AddScenePresence(m_scene, user1Id);
-// SceneHelpers.AddScenePresence(m_scene, user2Id);
-//
-// m_fm.AddFriendship(sp1.ControllingClient, user2Id);
-//// m_fm.LocalGrantRights
-//
-// m_scene.RemoveClient(sp1.UUID, true);
-//
-// ScenePresence sp1Redux = SceneHelpers.AddScenePresence(m_scene, user1Id);
-//
-// Assert.That(((TestClient)sp1Redux.ControllingClient).ReceivedOfflineNotifications.Count, Is.EqualTo(0));
-// Assert.That(((TestClient)sp1Redux.ControllingClient).ReceivedOnlineNotifications.Count, Is.EqualTo(1));
-// }
+// m_fm.AddFriendship(user1Id, user2Id);
+
+ ScenePresence sp1 = SceneHelpers.AddScenePresence(m_scene, user1Id);
+ ScenePresence sp2 = SceneHelpers.AddScenePresence(m_scene, user2Id);
+
+ m_fm.AddFriendship(sp1.ControllingClient, user2Id);
+
+ // Not necessary for this test. CanSeeOnline is automatically granted.
+// m_fm.GrantRights(sp1.ControllingClient, user2Id, (int)FriendRights.CanSeeOnline);
+
+ // We must logout from the client end so that the presence service is correctly updated by the presence
+ // detector. This is listening to the OnConnectionClosed event on the client.
+// ((TestClient)sp1.ControllingClient).Logout();
+ ((TestClient)sp2.ControllingClient).Logout();
+// m_scene.RemoveClient(user2Id, true);
+
+ ScenePresence sp2Redux = SceneHelpers.AddScenePresence(m_scene, user2Id);
+
+ Assert.That(((TestClient)sp2Redux.ControllingClient).ReceivedOfflineNotifications.Count, Is.EqualTo(0));
+ Assert.That(((TestClient)sp2Redux.ControllingClient).ReceivedOnlineNotifications.Count, Is.EqualTo(1));
+ }
[Test]
public void TestAddFriendshipWhileOnline()
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs
index e2e383f..ccfbf78 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs
@@ -27,14 +27,12 @@
using System;
using System.Collections.Generic;
using System.Reflection;
-
+using log4net;
+using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Services.Interfaces;
-using OpenMetaverse;
-using log4net;
-
namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence
{
public class PresenceDetector
@@ -97,7 +95,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence
// m_log.DebugFormat("[PRESENCE DETECTOR]: Detected client logout {0} in {1}", client.AgentId, client.Scene.RegionInfo.RegionName);
m_PresenceService.LogoutAgent(client.SessionId);
}
-
}
}
-}
+}
\ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
index ac03747..64759a7 100644
--- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
+++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
@@ -487,7 +487,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
return false;
}
- protected bool IsFriendWithPerms(UUID user,UUID objectOwner)
+ protected bool IsFriendWithPerms(UUID user, UUID objectOwner)
{
if (user == UUID.Zero)
return false;
@@ -495,11 +495,8 @@ namespace OpenSim.Region.CoreModules.World.Permissions
if (m_friendsModule == null)
return false;
- uint friendPerms = m_friendsModule.GetFriendPerms(user, objectOwner);
- if ((friendPerms & (uint)FriendRights.CanModifyObjects) != 0)
- return true;
-
- return false;
+ int friendPerms = m_friendsModule.GetRightsGrantedByFriend(user, objectOwner);
+ return (friendPerms & (int)FriendRights.CanModifyObjects) != 0;
}
protected bool IsEstateManager(UUID user)
@@ -508,6 +505,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
return m_scene.RegionInfo.EstateSettings.IsEstateManager(user);
}
+
#endregion
public bool PropagatePermissions()
diff --git a/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs b/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs
index 061799e..10bef1e 100644
--- a/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs
@@ -55,7 +55,27 @@ namespace OpenSim.Region.Framework.Interfaces
///
void RemoveFriendship(IClientAPI client, UUID exFriendID);
- uint GetFriendPerms(UUID PrincipalID, UUID FriendID);
+ ///
+ /// Get permissions granted by a friend.
+ ///
+ /// The user.
+ /// The friend that granted.
+ /// The permissions. These come from the FriendRights enum.
+ int GetRightsGrantedByFriend(UUID PrincipalID, UUID FriendID);
+
+ ///
+ /// Grant permissions for a friend.
+ ///
+ ///
+ /// This includes giving them the ability to see when the user is online and permission to edit the user's
+ /// objects.
+ /// Granting lower permissions than the friend currently has will rescind the extra permissions.
+ ///
+ /// The user granting the permissions.
+ /// The friend.
+ /// These come from the FriendRights enum.
+ void GrantRights(IClientAPI remoteClient, UUID friendID, int perms);
+
bool SendFriendsOnlineIfNeeded(IClientAPI client);
}
-}
+}
\ No newline at end of file
--
cgit v1.1
From bce7964ac2b0e67ff8c8e5ab00bb45b93da219ad Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 30 Mar 2012 01:05:29 +0100
Subject: refactor: Move "friends show cache" console command out into separate
FriendsCommandsModule.
Expose required methods on IFriendsModule. Rename GetFriends() -> GetFriendsFromCache() for self-documentation
---
.../CoreModules/Avatar/Friends/FriendsModule.cs | 98 ++----------
.../CoreModules/Avatar/Friends/HGFriendsModule.cs | 14 +-
.../Region/Framework/Interfaces/IFriendsModule.cs | 25 +++-
.../Avatar/Friends/FriendsCommandsModule.cs | 165 +++++++++++++++++++++
4 files changed, 205 insertions(+), 97 deletions(-)
create mode 100644 OpenSim/Region/OptionalModules/Avatar/Friends/FriendsCommandsModule.cs
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
index 9d7012e..37e6600 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
@@ -213,14 +213,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
scene.EventManager.OnClientLogin += OnClientLogin;
}
- public virtual void RegionLoaded(Scene scene)
- {
- scene.AddCommand(
- "Friends", this, "friends show cache",
- "friends show cache [ ]",
- "Show the friends cache for the given user",
- HandleFriendsShowCacheCommand);
- }
+ public virtual void RegionLoaded(Scene scene) {}
public void RemoveRegion(Scene scene)
{
@@ -244,7 +237,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
public virtual int GetRightsGrantedByFriend(UUID principalID, UUID friendID)
{
- FriendInfo[] friends = GetFriends(principalID);
+ FriendInfo[] friends = GetFriendsFromCache(principalID);
FriendInfo finfo = GetFriend(friends, friendID);
if (finfo != null)
{
@@ -362,7 +355,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
// Send outstanding friendship offers
List outstanding = new List();
- FriendInfo[] friends = GetFriends(agentID);
+ FriendInfo[] friends = GetFriendsFromCache(agentID);
foreach (FriendInfo fi in friends)
{
if (fi.TheirFlags == -1)
@@ -419,7 +412,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
{
List friendList = new List();
- FriendInfo[] friends = GetFriends(userID);
+ FriendInfo[] friends = GetFriendsFromCache(userID);
foreach (FriendInfo fi in friends)
{
if (((fi.TheirFlags & (int)FriendRights.CanSeeOnline) != 0) && (fi.TheirFlags != -1))
@@ -492,7 +485,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
///
private void StatusChange(UUID agentID, bool online)
{
- FriendInfo[] friends = GetFriends(agentID);
+ FriendInfo[] friends = GetFriendsFromCache(agentID);
if (friends.Length > 0)
{
List friendList = new List();
@@ -564,7 +557,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
m_log.DebugFormat("[FRIENDS]: {0} ({1}) offered friendship to {2} ({3})", principalID, client.FirstName + client.LastName, friendID, im.fromAgentName);
// Check that the friendship doesn't exist yet
- FriendInfo[] finfos = GetFriends(principalID);
+ FriendInfo[] finfos = GetFriendsFromCache(principalID);
if (finfos != null)
{
FriendInfo f = GetFriend(finfos, friendID);
@@ -729,7 +722,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
"[FRIENDS MODULE]: User {0} changing rights to {1} for friend {2}",
requester, rights, friendID);
- FriendInfo[] friends = GetFriends(requester);
+ FriendInfo[] friends = GetFriendsFromCache(requester);
if (friends.Length == 0)
{
return;
@@ -915,20 +908,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
#endregion
#region Get / Set friends in several flavours
- ///
- /// Get friends from local cache only
- ///
- ///
- ///
- /// An empty array if the user has no friends or friends have not been cached.
- ///
- protected FriendInfo[] GetFriends(UUID agentID)
+
+ public FriendInfo[] GetFriendsFromCache(UUID userID)
{
UserFriendData friendsData;
lock (m_Friends)
{
- if (m_Friends.TryGetValue(agentID, out friendsData))
+ if (m_Friends.TryGetValue(userID, out friendsData))
return friendsData.Friends;
}
@@ -946,7 +933,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
// Update local cache
lock (m_Friends)
{
- FriendInfo[] friends = GetFriends(friendID);
+ FriendInfo[] friends = GetFriendsFromCache(friendID);
FriendInfo finfo = GetFriend(friends, userID);
finfo.TheirFlags = rights;
}
@@ -970,12 +957,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
}
}
- ///
- /// Are friends cached on this simulator for a particular user?
- ///
- ///
- ///
- protected bool AreFriendsCached(UUID userID)
+ public bool AreFriendsCached(UUID userID)
{
lock (m_Friends)
return m_Friends.ContainsKey(userID);
@@ -1006,61 +988,5 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
}
#endregion
-
- protected void HandleFriendsShowCacheCommand(string module, string[] cmd)
- {
- if (cmd.Length != 5)
- {
- MainConsole.Instance.OutputFormat("Usage: friends show cache [ ]");
- return;
- }
-
- string firstName = cmd[3];
- string lastName = cmd[4];
-
- IUserManagement umModule = m_Scenes[0].RequestModuleInterface();
- UUID userId = umModule.GetUserIdByName(firstName, lastName);
-
-// UserAccount ua
-// = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, firstName, lastName);
-
- if (userId == UUID.Zero)
- {
- MainConsole.Instance.OutputFormat("No such user as {0} {1}", firstName, lastName);
- return;
- }
-
- if (!AreFriendsCached(userId))
- {
- MainConsole.Instance.OutputFormat("No friends cached on this simulator for {0} {1}", firstName, lastName);
- return;
- }
-
- MainConsole.Instance.OutputFormat("Cached friends for {0} {1}:", firstName, lastName);
-
- MainConsole.Instance.OutputFormat("UUID\n");
-
- FriendInfo[] friends = GetFriends(userId);
-
- foreach (FriendInfo friend in friends)
- {
-// MainConsole.Instance.OutputFormat(friend.PrincipalID.ToString());
-
-// string friendFirstName, friendLastName;
-//
-// UserAccount friendUa
-// = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, friend.PrincipalID);
-
- UUID friendId;
- string friendName;
-
- if (UUID.TryParse(friend.Friend, out friendId))
- friendName = umModule.GetUserName(friendId);
- else
- friendName = friend.Friend;
-
- MainConsole.Instance.OutputFormat("{0} {1} {2}", friendName, friend.MyFlags, friend.TheirFlags);
- }
- }
}
}
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs
index b666dae..d3a3ee4 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs
@@ -163,7 +163,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(client.Scene.RegionInfo.ScopeID, client.AgentId);
if (account == null) // foreign
{
- FriendInfo[] friends = GetFriends(client.AgentId);
+ FriendInfo[] friends = GetFriendsFromCache(client.AgentId);
foreach (FriendInfo f in friends)
{
client.SendChangeUserRights(new UUID(f.Friend), client.AgentId, f.TheirFlags);
@@ -346,7 +346,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
if (agentIsLocal) // agent is local, friend is foreigner
{
- FriendInfo[] finfos = GetFriends(agentID);
+ FriendInfo[] finfos = GetFriendsFromCache(agentID);
FriendInfo finfo = GetFriend(finfos, friendID);
if (finfo != null)
{
@@ -453,7 +453,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
bool confirming = false;
if (friendUUI == string.Empty)
{
- finfos = GetFriends(agentID);
+ finfos = GetFriendsFromCache(agentID);
foreach (FriendInfo finfo in finfos)
{
if (finfo.TheirFlags == -1)
@@ -546,7 +546,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
// Delete any previous friendship relations
FriendInfo[] finfos = null;
FriendInfo f = null;
- finfos = GetFriends(a1);
+ finfos = GetFriendsFromCache(a1);
if (finfos != null)
{
f = GetFriend(finfos, a2);
@@ -558,7 +558,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
}
}
- finfos = GetFriends(a2);
+ finfos = GetFriendsFromCache(a2);
if (finfos != null)
{
f = GetFriend(finfos, a1);
@@ -595,7 +595,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
if (agentIsLocal) // agent is local, 'friend' is foreigner
{
// We need to look for its information in the friends list itself
- FriendInfo[] finfos = GetFriends(agentID);
+ FriendInfo[] finfos = GetFriendsFromCache(agentID);
FriendInfo finfo = GetFriend(finfos, exfriendID);
if (finfo != null)
{
@@ -639,7 +639,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
private string GetUUI(UUID localUser, UUID foreignUser)
{
// Let's see if the user is here by any chance
- FriendInfo[] finfos = GetFriends(localUser);
+ FriendInfo[] finfos = GetFriendsFromCache(localUser);
if (finfos != EMPTY_FRIENDS) // friend is here, cool
{
FriendInfo finfo = GetFriend(finfos, foreignUser);
diff --git a/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs b/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs
index 10bef1e..7e87006 100644
--- a/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs
@@ -25,15 +25,32 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+using System.Collections.Generic;
using OpenMetaverse;
using OpenSim.Framework;
-using System.Collections.Generic;
+using FriendInfo = OpenSim.Services.Interfaces.FriendInfo;
namespace OpenSim.Region.Framework.Interfaces
{
public interface IFriendsModule
{
///
+ /// Are friends cached on this simulator for a particular user?
+ ///
+ ///
+ ///
+ bool AreFriendsCached(UUID userID);
+
+ ///
+ /// Get friends from local cache only
+ ///
+ ///
+ ///
+ /// An empty array if the user has no friends or friends have not been cached.
+ ///
+ FriendInfo[] GetFriendsFromCache(UUID userID);
+
+ ///
/// Add a friendship between two users.
///
///
@@ -58,10 +75,10 @@ namespace OpenSim.Region.Framework.Interfaces
///
/// Get permissions granted by a friend.
///
- /// The user.
- /// The friend that granted.
+ /// The user.
+ /// The friend that granted.
/// The permissions. These come from the FriendRights enum.
- int GetRightsGrantedByFriend(UUID PrincipalID, UUID FriendID);
+ int GetRightsGrantedByFriend(UUID userID, UUID friendID);
///
/// Grant permissions for a friend.
diff --git a/OpenSim/Region/OptionalModules/Avatar/Friends/FriendsCommandsModule.cs b/OpenSim/Region/OptionalModules/Avatar/Friends/FriendsCommandsModule.cs
new file mode 100644
index 0000000..2bcb8a7
--- /dev/null
+++ b/OpenSim/Region/OptionalModules/Avatar/Friends/FriendsCommandsModule.cs
@@ -0,0 +1,165 @@
+/*
+ * 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.Linq;
+using System.Reflection;
+using System.Text;
+using log4net;
+using Mono.Addins;
+using Nini.Config;
+using OpenMetaverse;
+using OpenSim.Framework;
+using OpenSim.Framework.Console;
+using OpenSim.Framework.Statistics;
+using OpenSim.Region.ClientStack.LindenUDP;
+using OpenSim.Region.Framework.Interfaces;
+using OpenSim.Region.Framework.Scenes;
+using FriendInfo = OpenSim.Services.Interfaces.FriendInfo;
+
+namespace OpenSim.Region.OptionalModules.Avatar.Friends
+{
+ ///
+ /// A module that just holds commands for inspecting avatar appearance.
+ ///
+ [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "FriendsCommandModule")]
+ public class FriendsCommandsModule : ISharedRegionModule
+ {
+// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+
+ private Scene m_scene;
+ private IFriendsModule m_friendsModule;
+ private IUserManagement m_userManagementModule;
+
+// private IAvatarFactoryModule m_avatarFactory;
+
+ public string Name { get { return "Appearance Information Module"; } }
+
+ public Type ReplaceableInterface { get { return null; } }
+
+ public void Initialise(IConfigSource source)
+ {
+// m_log.DebugFormat("[FRIENDS COMMAND MODULE]: INITIALIZED MODULE");
+ }
+
+ public void PostInitialise()
+ {
+// m_log.DebugFormat("[FRIENDS COMMAND MODULE]: POST INITIALIZED MODULE");
+ }
+
+ public void Close()
+ {
+// m_log.DebugFormat("[FRIENDS COMMAND MODULE]: CLOSED MODULE");
+ }
+
+ public void AddRegion(Scene scene)
+ {
+// m_log.DebugFormat("[FRIENDS COMMANDO MODULE]: REGION {0} ADDED", scene.RegionInfo.RegionName);
+ }
+
+ public void RemoveRegion(Scene scene)
+ {
+// m_log.DebugFormat("[FRIENDS COMMAND MODULE]: REGION {0} REMOVED", scene.RegionInfo.RegionName);
+ }
+
+ public void RegionLoaded(Scene scene)
+ {
+// m_log.DebugFormat("[APPEARANCE INFO MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName);
+
+ if (m_scene == null)
+ m_scene = scene;
+
+ m_friendsModule = m_scene.RequestModuleInterface();
+ m_userManagementModule = m_scene.RequestModuleInterface();
+
+ if (m_friendsModule != null && m_userManagementModule != null)
+ {
+ m_scene.AddCommand(
+ "Friends", this, "friends show cache",
+ "friends show cache [ ]",
+ "Show the friends cache for the given user",
+ HandleFriendsShowCacheCommand);
+ }
+ }
+
+ protected void HandleFriendsShowCacheCommand(string module, string[] cmd)
+ {
+ if (cmd.Length != 5)
+ {
+ MainConsole.Instance.OutputFormat("Usage: friends show cache [ ]");
+ return;
+ }
+
+ string firstName = cmd[3];
+ string lastName = cmd[4];
+
+ UUID userId = m_userManagementModule.GetUserIdByName(firstName, lastName);
+
+// UserAccount ua
+// = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, firstName, lastName);
+
+ if (userId == UUID.Zero)
+ {
+ MainConsole.Instance.OutputFormat("No such user as {0} {1}", firstName, lastName);
+ return;
+ }
+
+ if (m_friendsModule.AreFriendsCached(userId))
+ {
+ MainConsole.Instance.OutputFormat("No friends cached on this simulator for {0} {1}", firstName, lastName);
+ return;
+ }
+
+ MainConsole.Instance.OutputFormat("Cached friends for {0} {1}:", firstName, lastName);
+
+ MainConsole.Instance.OutputFormat("UUID\n");
+
+ FriendInfo[] friends = m_friendsModule.GetFriendsFromCache(userId);
+
+ foreach (FriendInfo friend in friends)
+ {
+// MainConsole.Instance.OutputFormat(friend.PrincipalID.ToString());
+
+// string friendFirstName, friendLastName;
+//
+// UserAccount friendUa
+// = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, friend.PrincipalID);
+
+ UUID friendId;
+ string friendName;
+
+ if (UUID.TryParse(friend.Friend, out friendId))
+ friendName = m_userManagementModule.GetUserName(friendId);
+ else
+ friendName = friend.Friend;
+
+ MainConsole.Instance.OutputFormat("{0} {1} {2}", friendName, friend.MyFlags, friend.TheirFlags);
+ }
+ }
+ }
+}
\ No newline at end of file
--
cgit v1.1
From 3525c876c8972fb89a9981d4dc3dcb3220adee9e Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 30 Mar 2012 01:57:38 +0100
Subject: Make default "show friends" console command show friends fetched from
the friends service.
There is no a --cache option which will show friends from the local cache if available.
---
.../CoreModules/Avatar/Friends/FriendsModule.cs | 4 +-
.../CoreModules/Avatar/Friends/HGFriendsModule.cs | 3 +-
.../Avatar/Friends/FriendsCommandsModule.cs | 87 +++++++++++++++++++++-
3 files changed, 86 insertions(+), 8 deletions(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
index 37e6600..f64c161 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
@@ -110,7 +110,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
}
}
- protected IFriendsService FriendsService
+ public IFriendsService FriendsService
{
get
{
@@ -939,7 +939,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
}
}
- protected virtual FriendInfo[] GetFriendsFromService(IClientAPI client)
+ public virtual FriendInfo[] GetFriendsFromService(IClientAPI client)
{
return FriendsService.GetFriends(client.AgentId);
}
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs
index d3a3ee4..9a6d277 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs
@@ -300,8 +300,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
return null;
}
-
- protected override FriendInfo[] GetFriendsFromService(IClientAPI client)
+ public override FriendInfo[] GetFriendsFromService(IClientAPI client)
{
// m_log.DebugFormat("[HGFRIENDS MODULE]: Entering GetFriendsFromService for {0}", client.Name);
Boolean agentIsLocal = true;
diff --git a/OpenSim/Region/OptionalModules/Avatar/Friends/FriendsCommandsModule.cs b/OpenSim/Region/OptionalModules/Avatar/Friends/FriendsCommandsModule.cs
index 2bcb8a7..fe73770 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Friends/FriendsCommandsModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Friends/FriendsCommandsModule.cs
@@ -32,14 +32,17 @@ using System.Reflection;
using System.Text;
using log4net;
using Mono.Addins;
+using NDesk.Options;
using Nini.Config;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Framework.Console;
using OpenSim.Framework.Statistics;
using OpenSim.Region.ClientStack.LindenUDP;
+using OpenSim.Region.CoreModules.Avatar.Friends;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
+using OpenSim.Services.Interfaces;
using FriendInfo = OpenSim.Services.Interfaces.FriendInfo;
namespace OpenSim.Region.OptionalModules.Avatar.Friends
@@ -100,10 +103,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.Friends
if (m_friendsModule != null && m_userManagementModule != null)
{
m_scene.AddCommand(
- "Friends", this, "friends show cache",
- "friends show cache [ ]",
- "Show the friends cache for the given user",
- HandleFriendsShowCacheCommand);
+ "Friends", this, "friends show",
+ "friends show [--cache] ",
+ "Show the friends for the given user if they exist.\n",
+ "The --cache option will show locally cached information for that user.",
+ HandleFriendsShowCommand);
}
}
@@ -161,5 +165,80 @@ namespace OpenSim.Region.OptionalModules.Avatar.Friends
MainConsole.Instance.OutputFormat("{0} {1} {2}", friendName, friend.MyFlags, friend.TheirFlags);
}
}
+
+ protected void HandleFriendsShowCommand(string module, string[] cmd)
+ {
+ Dictionary options = new Dictionary();
+ OptionSet optionSet = new OptionSet().Add("c|cache", delegate (string v) { options["cache"] = v != null; });
+
+ List mainParams = optionSet.Parse(cmd);
+
+ if (mainParams.Count != 4)
+ {
+ MainConsole.Instance.OutputFormat("Usage: friends show [--cache] ");
+ return;
+ }
+
+ string firstName = mainParams[2];
+ string lastName = mainParams[3];
+
+ UUID userId = m_userManagementModule.GetUserIdByName(firstName, lastName);
+
+// UserAccount ua
+// = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, firstName, lastName);
+
+ if (userId == UUID.Zero)
+ {
+ MainConsole.Instance.OutputFormat("No such user as {0} {1}", firstName, lastName);
+ return;
+ }
+
+ FriendInfo[] friends;
+
+ if (options.ContainsKey("cache"))
+ {
+ if (!m_friendsModule.AreFriendsCached(userId))
+ {
+ MainConsole.Instance.OutputFormat("No friends cached on this simulator for {0} {1}", firstName, lastName);
+ return;
+ }
+ else
+ {
+ friends = m_friendsModule.GetFriendsFromCache(userId);
+ }
+ }
+ else
+ {
+ // FIXME: We're forced to do this right now because IFriendsService has no region connectors. We can't
+ // just expose FriendsModule.GetFriendsFromService() because it forces an IClientAPI requirement that
+ // can't currently be changed because of HGFriendsModule code that takes the scene from the client.
+ friends = ((FriendsModule)m_friendsModule).FriendsService.GetFriends(userId);
+ }
+
+ MainConsole.Instance.OutputFormat("Friends for {0} {1} {2}:", firstName, lastName, userId);
+
+ MainConsole.Instance.OutputFormat("UUID, Name, MyFlags, TheirFlags");
+
+ foreach (FriendInfo friend in friends)
+ {
+// MainConsole.Instance.OutputFormat(friend.PrincipalID.ToString());
+
+// string friendFirstName, friendLastName;
+//
+// UserAccount friendUa
+// = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, friend.PrincipalID);
+
+ UUID friendId;
+ string friendName;
+
+ if (UUID.TryParse(friend.Friend, out friendId))
+ friendName = m_userManagementModule.GetUserName(friendId);
+ else
+ friendName = friend.Friend;
+
+ MainConsole.Instance.OutputFormat(
+ "{0} {1} {2} {3}", friend.Friend, friendName, friend.MyFlags, friend.TheirFlags);
+ }
+ }
}
}
\ No newline at end of file
--
cgit v1.1
From 269e479cdc25c5420b4feaaebc233933323f93e2 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 30 Mar 2012 02:00:01 +0100
Subject: minor: remove some now unneeded code from FriendsCommandsModule
---
.../Avatar/Friends/FriendsCommandsModule.cs | 55 ----------------------
1 file changed, 55 deletions(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/OptionalModules/Avatar/Friends/FriendsCommandsModule.cs b/OpenSim/Region/OptionalModules/Avatar/Friends/FriendsCommandsModule.cs
index fe73770..e68f9d0 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Friends/FriendsCommandsModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Friends/FriendsCommandsModule.cs
@@ -111,61 +111,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Friends
}
}
- protected void HandleFriendsShowCacheCommand(string module, string[] cmd)
- {
- if (cmd.Length != 5)
- {
- MainConsole.Instance.OutputFormat("Usage: friends show cache [ ]");
- return;
- }
-
- string firstName = cmd[3];
- string lastName = cmd[4];
-
- UUID userId = m_userManagementModule.GetUserIdByName(firstName, lastName);
-
-// UserAccount ua
-// = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, firstName, lastName);
-
- if (userId == UUID.Zero)
- {
- MainConsole.Instance.OutputFormat("No such user as {0} {1}", firstName, lastName);
- return;
- }
-
- if (m_friendsModule.AreFriendsCached(userId))
- {
- MainConsole.Instance.OutputFormat("No friends cached on this simulator for {0} {1}", firstName, lastName);
- return;
- }
-
- MainConsole.Instance.OutputFormat("Cached friends for {0} {1}:", firstName, lastName);
-
- MainConsole.Instance.OutputFormat("UUID\n");
-
- FriendInfo[] friends = m_friendsModule.GetFriendsFromCache(userId);
-
- foreach (FriendInfo friend in friends)
- {
-// MainConsole.Instance.OutputFormat(friend.PrincipalID.ToString());
-
-// string friendFirstName, friendLastName;
-//
-// UserAccount friendUa
-// = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, friend.PrincipalID);
-
- UUID friendId;
- string friendName;
-
- if (UUID.TryParse(friend.Friend, out friendId))
- friendName = m_userManagementModule.GetUserName(friendId);
- else
- friendName = friend.Friend;
-
- MainConsole.Instance.OutputFormat("{0} {1} {2}", friendName, friend.MyFlags, friend.TheirFlags);
- }
- }
-
protected void HandleFriendsShowCommand(string module, string[] cmd)
{
Dictionary options = new Dictionary();
--
cgit v1.1
From 874140f950add3b698a3c75ab24727e62e83f329 Mon Sep 17 00:00:00 2001
From: PixelTomsen
Date: Wed, 14 Mar 2012 23:33:22 +0100
Subject: fix Infinite loading on No Rez
http://opensimulator.org/mantis/view.php?id=5932
---
.../Framework/InventoryAccess/InventoryAccessModule.cs | 5 +++++
OpenSim/Region/Framework/Scenes/Scene.cs | 8 +++++++-
2 files changed, 12 insertions(+), 1 deletion(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
index d320af4..1c84e77 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
@@ -935,6 +935,11 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
if (((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) && (!isAttachment))
remoteClient.SendBulkUpdateInventory(item);
+ ILandObject land = m_Scene.LandChannel.GetLandObject(pos.X, pos.Y);
+ remoteClient.SendAlertMessage(string.Format(
+ "Can't rez object '{0}' at <{1:F3}, {2:F3}, {3:F3}> on parcel '{4}' in region {5}.",
+ item.Name, pos.X, pos.Y, pos.Z, land != null ? land.LandData.Name : "Unknow", m_Scene.RegionInfo.RegionName));
+
return false;
}
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 44cd30a..954b76f 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -1971,10 +1971,16 @@ namespace OpenSim.Region.Framework.Scenes
if (Permissions.CanRezObject(1, ownerID, pos))
{
// rez ON the ground, not IN the ground
- // pos.Z += 0.25F; The rez point should now be correct so that its not in the ground
+ // pos.Z += 0.25F; The rez point should now be correct so that its not in the ground
AddNewPrim(ownerID, groupID, pos, rot, shape);
}
+ else
+ {
+ IClientAPI client = null;
+ if (this.TryGetClient(ownerID, out client))
+ client.SendAlertMessage("You cannot create objects here.");
+ }
}
public virtual SceneObjectGroup AddNewPrim(
--
cgit v1.1
From 69fc8c4985ebb9e205b86114b7c4e3dd4063153b Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Sat, 31 Mar 2012 01:07:14 +0100
Subject: minor: small message adjustment and unnecessary code elimination when
notifying client of no build permission
---
.../CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs | 2 +-
OpenSim/Region/Framework/Scenes/Scene.cs | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
index 1c84e77..4dd89d2 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
@@ -938,7 +938,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
ILandObject land = m_Scene.LandChannel.GetLandObject(pos.X, pos.Y);
remoteClient.SendAlertMessage(string.Format(
"Can't rez object '{0}' at <{1:F3}, {2:F3}, {3:F3}> on parcel '{4}' in region {5}.",
- item.Name, pos.X, pos.Y, pos.Z, land != null ? land.LandData.Name : "Unknow", m_Scene.RegionInfo.RegionName));
+ item.Name, pos.X, pos.Y, pos.Z, land != null ? land.LandData.Name : "Unknown", m_Scene.RegionInfo.RegionName));
return false;
}
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 954b76f..fc61571 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -1978,7 +1978,7 @@ namespace OpenSim.Region.Framework.Scenes
else
{
IClientAPI client = null;
- if (this.TryGetClient(ownerID, out client))
+ if (TryGetClient(ownerID, out client))
client.SendAlertMessage("You cannot create objects here.");
}
}
--
cgit v1.1
From 387d7fdad56267b845c12a52cbc6b80c56c8a558 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Sat, 31 Mar 2012 01:29:13 +0100
Subject: Allow llRegionSayTo() to work on the PUBLIC_CHANNEL, as per
http://wiki.secondlife.com/wiki/LlRegionSayTo
Addresses http://opensimulator.org/mantis/view.php?id=5950
---
OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs
index ef9b4e0..176c86d 100644
--- a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs
@@ -319,7 +319,7 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
// Send message to avatar
if (channel == 0)
{
- m_scene.SimChatBroadcast(Utils.StringToBytes(msg), ChatTypeEnum.Owner, 0, pos, name, id, false);
+ m_scene.SimChatBroadcast(Utils.StringToBytes(msg), ChatTypeEnum.Broadcast, 0, pos, name, id, false);
}
List attachments = sp.GetAttachments();
--
cgit v1.1
From f0406f9fe2f7a1d4d135934280735a3fdc41935f Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Sat, 31 Mar 2012 01:45:37 +0100
Subject: Rename SOG.HasChildPrim(uint) to SOG.ContainsPart(uint) to match
existing ContainsPart method and remove method duplication.
HasChildPrim is also misleading since the 'root' prim can also be returned.
---
OpenSim/Region/Framework/Scenes/SceneGraph.cs | 6 +--
.../Region/Framework/Scenes/SceneObjectGroup.cs | 47 +++++++++-------------
.../Shared/Api/Implementation/LSL_Api.cs | 6 +--
3 files changed, 24 insertions(+), 35 deletions(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index 5c542d6..cd1366c 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -860,7 +860,7 @@ namespace OpenSim.Region.Framework.Scenes
if (sog != null)
{
- if (sog.HasChildPrim(localID))
+ if (sog.ContainsPart(localID))
{
// m_log.DebugFormat(
// "[SCENE GRAPH]: Found scene object {0} {1} {2} containing part with local id {3} in {4}. Returning.",
@@ -888,7 +888,7 @@ namespace OpenSim.Region.Framework.Scenes
if (ent is SceneObjectGroup)
{
sog = (SceneObjectGroup)ent;
- if (sog.HasChildPrim(localID))
+ if (sog.ContainsPart(localID))
{
lock (SceneObjectGroupsByLocalPartID)
SceneObjectGroupsByLocalPartID[localID] = sog;
@@ -926,7 +926,7 @@ namespace OpenSim.Region.Framework.Scenes
if (ent is SceneObjectGroup)
{
sog = (SceneObjectGroup)ent;
- if (sog.HasChildPrim(fullID))
+ if (sog.ContainsPart(fullID))
{
lock (SceneObjectGroupsByFullPartID)
SceneObjectGroupsByFullPartID[fullID] = sog;
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index afb5ccf..9d16beb 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -338,6 +338,24 @@ namespace OpenSim.Region.Framework.Scenes
return m_parts.ContainsKey(partID);
}
+ ///
+ /// Does this group contain the given part?
+ /// should be able to remove these methods once we have a entity index in scene
+ ///
+ ///
+ ///
+ public bool ContainsPart(uint localID)
+ {
+ SceneObjectPart[] parts = m_parts.GetArray();
+ for (int i = 0; i < parts.Length; i++)
+ {
+ if (parts[i].LocalId == localID)
+ return true;
+ }
+
+ return false;
+ }
+
///
/// The root part of this scene object
///
@@ -1911,35 +1929,6 @@ namespace OpenSim.Region.Framework.Scenes
return null;
}
- ///
- /// Does this group contain the child prim
- /// should be able to remove these methods once we have a entity index in scene
- ///
- ///
- ///
- public bool HasChildPrim(UUID primID)
- {
- return m_parts.ContainsKey(primID);
- }
-
- ///
- /// Does this group contain the child prim
- /// should be able to remove these methods once we have a entity index in scene
- ///
- ///
- ///
- public bool HasChildPrim(uint localID)
- {
- SceneObjectPart[] parts = m_parts.GetArray();
- for (int i = 0; i < parts.Length; i++)
- {
- if (parts[i].LocalId == localID)
- return true;
- }
-
- return false;
- }
-
#endregion
#region Packet Handlers
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 7455929..b502ab8 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -3763,7 +3763,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
// parse for sitting avatare-uuids
World.ForEachRootScenePresence(delegate(ScenePresence presence)
{
- if (presence.ParentID != 0 && m_host.ParentGroup.HasChildPrim(presence.ParentID))
+ if (presence.ParentID != 0 && m_host.ParentGroup.ContainsPart(presence.ParentID))
keytable.Add(presence.UUID);
});
@@ -3826,7 +3826,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
World.ForEachRootScenePresence(delegate(ScenePresence presence)
{
SceneObjectPart sitPart = presence.ParentPart;
- if (sitPart != null && m_host.ParentGroup.HasChildPrim(sitPart.LocalId))
+ if (sitPart != null && m_host.ParentGroup.ContainsPart(sitPart.LocalId))
nametable.Add(presence.ControllingClient.Name);
});
@@ -7684,7 +7684,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
int avatarCount = 0;
World.ForEachRootScenePresence(delegate(ScenePresence presence)
{
- if (presence.ParentID != 0 && m_host.ParentGroup.HasChildPrim(presence.ParentID))
+ if (presence.ParentID != 0 && m_host.ParentGroup.ContainsPart(presence.ParentID))
avatarCount++;
});
--
cgit v1.1
From 32a953fed727fdadd65228b7c9282091da3521ac Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Sat, 31 Mar 2012 01:52:06 +0100
Subject: refactor: Rename SOG.GetChildPart() to GetPart() since it can also
return the 'root' part.
---
.../World/Vegetation/VegetationModule.cs | 2 +-
OpenSim/Region/Framework/Scenes/Scene.cs | 4 +--
OpenSim/Region/Framework/Scenes/SceneGraph.cs | 4 +--
.../Framework/Scenes/SceneObjectGroup.Inventory.cs | 8 ++---
.../Region/Framework/Scenes/SceneObjectGroup.cs | 40 +++++++++++-----------
.../Framework/Scenes/SceneObjectPartInventory.cs | 2 +-
.../World/TreePopulator/TreePopulatorModule.cs | 2 +-
7 files changed, 31 insertions(+), 31 deletions(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/CoreModules/World/Vegetation/VegetationModule.cs b/OpenSim/Region/CoreModules/World/Vegetation/VegetationModule.cs
index ab8e1bf..f5f35bb 100644
--- a/OpenSim/Region/CoreModules/World/Vegetation/VegetationModule.cs
+++ b/OpenSim/Region/CoreModules/World/Vegetation/VegetationModule.cs
@@ -79,7 +79,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Vegetation
}
SceneObjectGroup sceneObject = new SceneObjectGroup(ownerID, pos, rot, shape);
- SceneObjectPart rootPart = sceneObject.GetChildPart(sceneObject.UUID);
+ SceneObjectPart rootPart = sceneObject.GetPart(sceneObject.UUID);
// if grass or tree, make phantom
//rootPart.TrimPermissions();
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index fc61571..06f7c0f 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -1833,7 +1833,7 @@ namespace OpenSim.Region.Framework.Scenes
{
AddRestoredSceneObject(group, true, true);
EventManager.TriggerOnSceneObjectLoaded(group);
- SceneObjectPart rootPart = group.GetChildPart(group.UUID);
+ SceneObjectPart rootPart = group.GetPart(group.UUID);
rootPart.Flags &= ~PrimFlags.Scripted;
rootPart.TrimPermissions();
@@ -4174,7 +4174,7 @@ namespace OpenSim.Region.Framework.Scenes
{
if (ent is SceneObjectGroup)
{
- SceneObjectPart part = ((SceneObjectGroup)ent).GetChildPart(((SceneObjectGroup)ent).UUID);
+ SceneObjectPart part = ((SceneObjectGroup)ent).GetPart(((SceneObjectGroup)ent).UUID);
if (part != null)
{
if (part.Name == cmdparams[2])
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index cd1366c..8a05772 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -1015,7 +1015,7 @@ namespace OpenSim.Region.Framework.Scenes
SceneObjectGroup group = GetGroupByPrim(localID);
if (group == null)
return null;
- return group.GetChildPart(localID);
+ return group.GetPart(localID);
}
///
@@ -1062,7 +1062,7 @@ namespace OpenSim.Region.Framework.Scenes
SceneObjectGroup group = GetGroupByPrim(fullID);
if (group == null)
return null;
- return group.GetChildPart(fullID);
+ return group.GetPart(fullID);
}
///
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
index a73d9b6..10012d0 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
@@ -96,7 +96,7 @@ namespace OpenSim.Region.Framework.Scenes
UUID newItemId = (copyItemID != UUID.Zero) ? copyItemID : item.ID;
- SceneObjectPart part = GetChildPart(localID);
+ SceneObjectPart part = GetPart(localID);
if (part != null)
{
TaskInventoryItem taskItem = new TaskInventoryItem();
@@ -170,7 +170,7 @@ namespace OpenSim.Region.Framework.Scenes
/// null if the item does not exist
public TaskInventoryItem GetInventoryItem(uint primID, UUID itemID)
{
- SceneObjectPart part = GetChildPart(primID);
+ SceneObjectPart part = GetPart(primID);
if (part != null)
{
return part.Inventory.GetInventoryItem(itemID);
@@ -194,7 +194,7 @@ namespace OpenSim.Region.Framework.Scenes
/// false if the item did not exist, true if the update occurred succesfully
public bool UpdateInventoryItem(TaskInventoryItem item)
{
- SceneObjectPart part = GetChildPart(item.ParentPartID);
+ SceneObjectPart part = GetPart(item.ParentPartID);
if (part != null)
{
part.Inventory.UpdateInventoryItem(item);
@@ -214,7 +214,7 @@ namespace OpenSim.Region.Framework.Scenes
public int RemoveInventoryItem(uint localID, UUID itemID)
{
- SceneObjectPart part = GetChildPart(localID);
+ SceneObjectPart part = GetPart(localID);
if (part != null)
{
int type = part.Inventory.RemoveInventoryItem(itemID);
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 9d16beb..04b3766 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -1127,7 +1127,7 @@ namespace OpenSim.Region.Framework.Scenes
public UUID GetPartsFullID(uint localID)
{
- SceneObjectPart part = GetChildPart(localID);
+ SceneObjectPart part = GetPart(localID);
if (part != null)
{
return part.UUID;
@@ -1143,7 +1143,7 @@ namespace OpenSim.Region.Framework.Scenes
}
else
{
- SceneObjectPart part = GetChildPart(localId);
+ SceneObjectPart part = GetPart(localId);
OnGrabPart(part, offsetPos, remoteClient);
}
}
@@ -1904,8 +1904,8 @@ namespace OpenSim.Region.Framework.Scenes
/// Get a part with a given UUID
///
///
- /// null if a child part with the primID was not found
- public SceneObjectPart GetChildPart(UUID primID)
+ /// null if a part with the primID was not found
+ public SceneObjectPart GetPart(UUID primID)
{
SceneObjectPart childPart;
m_parts.TryGetValue(primID, out childPart);
@@ -1916,8 +1916,8 @@ namespace OpenSim.Region.Framework.Scenes
/// Get a part with a given local ID
///
///
- /// null if a child part with the local ID was not found
- public SceneObjectPart GetChildPart(uint localID)
+ /// null if a part with the local ID was not found
+ public SceneObjectPart GetPart(uint localID)
{
SceneObjectPart[] parts = m_parts.GetArray();
for (int i = 0; i < parts.Length; i++)
@@ -2035,7 +2035,7 @@ namespace OpenSim.Region.Framework.Scenes
/// The object group of the newly delinked prim. Null if part could not be found
public SceneObjectGroup DelinkFromGroup(uint partID, bool sendEvents)
{
- SceneObjectPart linkPart = GetChildPart(partID);
+ SceneObjectPart linkPart = GetPart(partID);
if (linkPart != null)
{
@@ -2326,7 +2326,7 @@ namespace OpenSim.Region.Framework.Scenes
///
public void SetPartName(string name, uint localID)
{
- SceneObjectPart part = GetChildPart(localID);
+ SceneObjectPart part = GetPart(localID);
if (part != null)
{
part.Name = name;
@@ -2335,7 +2335,7 @@ namespace OpenSim.Region.Framework.Scenes
public void SetPartDescription(string des, uint localID)
{
- SceneObjectPart part = GetChildPart(localID);
+ SceneObjectPart part = GetPart(localID);
if (part != null)
{
part.Description = des;
@@ -2344,7 +2344,7 @@ namespace OpenSim.Region.Framework.Scenes
public void SetPartText(string text, uint localID)
{
- SceneObjectPart part = GetChildPart(localID);
+ SceneObjectPart part = GetPart(localID);
if (part != null)
{
part.SetText(text);
@@ -2353,7 +2353,7 @@ namespace OpenSim.Region.Framework.Scenes
public void SetPartText(string text, UUID partID)
{
- SceneObjectPart part = GetChildPart(partID);
+ SceneObjectPart part = GetPart(partID);
if (part != null)
{
part.SetText(text);
@@ -2362,7 +2362,7 @@ namespace OpenSim.Region.Framework.Scenes
public string GetPartName(uint localID)
{
- SceneObjectPart part = GetChildPart(localID);
+ SceneObjectPart part = GetPart(localID);
if (part != null)
{
return part.Name;
@@ -2372,7 +2372,7 @@ namespace OpenSim.Region.Framework.Scenes
public string GetPartDescription(uint localID)
{
- SceneObjectPart part = GetChildPart(localID);
+ SceneObjectPart part = GetPart(localID);
if (part != null)
{
return part.Description;
@@ -2390,7 +2390,7 @@ namespace OpenSim.Region.Framework.Scenes
///
public void UpdatePrimFlags(uint localID, bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVolumeDetect)
{
- SceneObjectPart selectionPart = GetChildPart(localID);
+ SceneObjectPart selectionPart = GetPart(localID);
if (SetTemporary && Scene != null)
{
@@ -2427,7 +2427,7 @@ namespace OpenSim.Region.Framework.Scenes
public void UpdateExtraParam(uint localID, ushort type, bool inUse, byte[] data)
{
- SceneObjectPart part = GetChildPart(localID);
+ SceneObjectPart part = GetPart(localID);
if (part != null)
{
part.UpdateExtraParam(type, inUse, data);
@@ -2441,7 +2441,7 @@ namespace OpenSim.Region.Framework.Scenes
///
public void UpdateTextureEntry(uint localID, byte[] textureEntry)
{
- SceneObjectPart part = GetChildPart(localID);
+ SceneObjectPart part = GetPart(localID);
if (part != null)
{
part.UpdateTextureEntry(textureEntry);
@@ -2473,7 +2473,7 @@ namespace OpenSim.Region.Framework.Scenes
///
public void UpdateShape(ObjectShapePacket.ObjectDataBlock shapeBlock, uint localID)
{
- SceneObjectPart part = GetChildPart(localID);
+ SceneObjectPart part = GetPart(localID);
if (part != null)
{
part.UpdateShape(shapeBlock);
@@ -2685,7 +2685,7 @@ namespace OpenSim.Region.Framework.Scenes
///
public void UpdateSinglePosition(Vector3 pos, uint localID)
{
- SceneObjectPart part = GetChildPart(localID);
+ SceneObjectPart part = GetPart(localID);
// SceneObjectPart[] parts = m_parts.GetArray();
// for (int i = 0; i < parts.Length; i++)
@@ -2824,7 +2824,7 @@ namespace OpenSim.Region.Framework.Scenes
///
public void UpdateSingleRotation(Quaternion rot, uint localID)
{
- SceneObjectPart part = GetChildPart(localID);
+ SceneObjectPart part = GetPart(localID);
SceneObjectPart[] parts = m_parts.GetArray();
for (int i = 0; i < parts.Length; i++)
@@ -2853,7 +2853,7 @@ namespace OpenSim.Region.Framework.Scenes
///
public void UpdateSingleRotation(Quaternion rot, Vector3 pos, uint localID)
{
- SceneObjectPart part = GetChildPart(localID);
+ SceneObjectPart part = GetPart(localID);
if (part != null)
{
// m_log.DebugFormat(
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index 71a9084..f7e123b 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -623,7 +623,7 @@ namespace OpenSim.Region.Framework.Scenes
group.ResetIDs();
- SceneObjectPart rootPart = group.GetChildPart(group.UUID);
+ SceneObjectPart rootPart = group.GetPart(group.UUID);
// Since renaming the item in the inventory does not affect the name stored
// in the serialization, transfer the correct name from the inventory to the
diff --git a/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs b/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs
index a17eb41..51b0592 100644
--- a/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs
+++ b/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs
@@ -510,7 +510,7 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator
}
SceneObjectGroup sceneObject = new SceneObjectGroup(ownerID, pos, rot, shape);
- SceneObjectPart rootPart = sceneObject.GetChildPart(sceneObject.UUID);
+ SceneObjectPart rootPart = sceneObject.GetPart(sceneObject.UUID);
rootPart.AddFlag(PrimFlags.Phantom);
--
cgit v1.1