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.
0.7.4.1
Justin Clark-Casey (justincc) 2012-03-30 00:40:19 +01:00
parent b8d383da0a
commit 59157d9d63
12 changed files with 177 additions and 85 deletions

View File

@ -28,6 +28,8 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection;
using log4net;
using OpenMetaverse; using OpenMetaverse;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Data; using OpenSim.Data;
@ -36,12 +38,25 @@ namespace OpenSim.Data.Null
{ {
public class NullFriendsData : IFriendsData public class NullFriendsData : IFriendsData
{ {
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private static List<FriendsData> m_Data = new List<FriendsData>(); private static List<FriendsData> m_Data = new List<FriendsData>();
public NullFriendsData(string connectionString, string realm) public NullFriendsData(string connectionString, string realm)
{ {
} }
/// <summary>
/// Clear all friends data
/// </summary>
/// <remarks>
/// This is required by unit tests to clear the static data between test runs.
/// </remarks>
public static void Clear()
{
m_Data.Clear();
}
public FriendsData[] GetFriends(UUID principalID) public FriendsData[] GetFriends(UUID principalID)
{ {
return GetFriends(principalID.ToString()); return GetFriends(principalID.ToString());
@ -66,9 +81,16 @@ namespace OpenSim.Data.Null
lst.ForEach(f => lst.ForEach(f =>
{ {
FriendsData f2 = m_Data.Find(candidateF2 => f.Friend == candidateF2.PrincipalID); FriendsData f2 = m_Data.Find(candidateF2 => f.Friend == candidateF2.PrincipalID);
if (f2 != null) { f.Data["TheirFlags"] = f2.Data["Flags"]; } if (f2 != null)
f.Data["TheirFlags"] = f2.Data["Flags"];
// m_log.DebugFormat(
// "[NULL FRIENDS DATA]: Got {0} {1} {2} for {3}",
// f.Friend, f.Data["Flags"], f2 != null ? f.Data["TheirFlags"] : "not found!", f.PrincipalID);
}); });
// m_log.DebugFormat("[NULL FRIENDS DATA]: Got {0} friends for {1}", lst.Count, userID);
return lst.ToArray(); return lst.ToArray();
} }
@ -80,6 +102,9 @@ namespace OpenSim.Data.Null
if (data == null) if (data == null)
return false; return false;
// m_log.DebugFormat(
// "[NULL FRIENDS DATA]: Storing {0} {1} {2}", data.PrincipalID, data.Friend, data.Data["Flags"]);
m_Data.Add(data); m_Data.Add(data);
return true; return true;
@ -98,6 +123,10 @@ namespace OpenSim.Data.Null
FriendsData friend = lst.Find(delegate(FriendsData fdata) { return fdata.Friend == friendID; }); FriendsData friend = lst.Find(delegate(FriendsData fdata) { return fdata.Friend == friendID; });
if (friendID != null) if (friendID != null)
{ {
// m_log.DebugFormat(
// "[NULL FRIENDS DATA]: Deleting friend {0} {1} for {2}",
// friend.Friend, friend.Data["Flags"], friend.PrincipalID);
m_Data.Remove(friend); m_Data.Remove(friend);
return true; return true;
} }

View File

@ -110,7 +110,6 @@ namespace OpenSim.Data.Null
return false; return false;
} }
public PresenceData[] Get(string field, string data) public PresenceData[] Get(string field, string data)
{ {
if (Instance != this) if (Instance != this)

View File

@ -51,6 +51,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
{ {
public class FriendsModule : ISharedRegionModule, IFriendsModule public class FriendsModule : ISharedRegionModule, IFriendsModule
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
protected bool m_Enabled = false; protected bool m_Enabled = false;
protected class UserFriendData protected class UserFriendData
@ -72,7 +74,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
} }
protected static readonly FriendInfo[] EMPTY_FRIENDS = new FriendInfo[0]; protected static readonly FriendInfo[] EMPTY_FRIENDS = new FriendInfo[0];
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
protected List<Scene> m_Scenes = new List<Scene>(); protected List<Scene> m_Scenes = new List<Scene>();
@ -156,7 +157,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
InitModule(config); InitModule(config);
m_Enabled = true; 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) if (!m_Enabled)
return; return;
m_log.DebugFormat("[FRIENDS MODULE]: AddRegion on {0}", Name); // m_log.DebugFormat("[FRIENDS MODULE]: AddRegion on {0}", Name);
m_Scenes.Add(scene); m_Scenes.Add(scene);
scene.RegisterModuleInterface<IFriendsModule>(this); scene.RegisterModuleInterface<IFriendsModule>(this);
@ -241,13 +242,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
#endregion #endregion
public virtual uint GetFriendPerms(UUID principalID, UUID friendID) public virtual int GetRightsGrantedByFriend(UUID principalID, UUID friendID)
{ {
FriendInfo[] friends = GetFriends(principalID); FriendInfo[] friends = GetFriends(principalID);
FriendInfo finfo = GetFriend(friends, friendID); FriendInfo finfo = GetFriend(friends, friendID);
if (finfo != null) if (finfo != null)
{ {
return (uint)finfo.TheirFlags; return finfo.TheirFlags;
} }
return 0; return 0;
@ -259,7 +260,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
client.OnApproveFriendRequest += OnApproveFriendRequest; client.OnApproveFriendRequest += OnApproveFriendRequest;
client.OnDenyFriendRequest += OnDenyFriendRequest; client.OnDenyFriendRequest += OnDenyFriendRequest;
client.OnTerminateFriendship += RemoveFriendship; 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 // 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. // 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 // Send the friends online
List<UUID> online = GetOnlineFriends(agentID); List<UUID> 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) if (online.Count > 0)
client.SendAgentOnline(online.ToArray()); client.SendAgentOnline(online.ToArray());
@ -421,23 +418,30 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
List<UUID> GetOnlineFriends(UUID userID) List<UUID> GetOnlineFriends(UUID userID)
{ {
List<string> friendList = new List<string>(); List<string> friendList = new List<string>();
List<UUID> online = new List<UUID>();
FriendInfo[] friends = GetFriends(userID); FriendInfo[] friends = GetFriends(userID);
foreach (FriendInfo fi in friends) 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); friendList.Add(fi.Friend);
} }
List<UUID> online = new List<UUID>();
if (friendList.Count > 0) if (friendList.Count > 0)
GetOnlineFriends(userID, friendList, online); GetOnlineFriends(userID, friendList, online);
// m_log.DebugFormat(
// "[FRIENDS MODULE]: User {0} has {1} friends online", userID, online.Count);
return online; return online;
} }
protected virtual void GetOnlineFriends(UUID userID, List<string> friendList, /*collector*/ List<UUID> online) protected virtual void GetOnlineFriends(UUID userID, List<string> friendList, /*collector*/ List<UUID> online)
{ {
// m_log.DebugFormat(
// "[FRIENDS MODULE]: Looking for online presence of {0} users for {1}", friendList.Count, userID);
PresenceInfo[] presence = PresenceService.GetAgents(friendList.ToArray()); PresenceInfo[] presence = PresenceService.GetAgents(friendList.ToArray());
foreach (PresenceInfo pi in presence) 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; UUID requester = remoteClient.AgentId;
m_log.DebugFormat( m_log.DebugFormat(
"[FRIENDS MODULE]: User {0} changing rights to {1} for friend {2}", "[FRIENDS MODULE]: User {0} changing rights to {1} for friend {2}",
requester, rights, target); requester, rights, friendID);
FriendInfo[] friends = GetFriends(requester); FriendInfo[] friends = GetFriends(requester);
if (friends.Length == 0) 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 // 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 if (friend != null) // Found it
{ {
// Store it on the DB // Store it on the DB
if (!StoreRights(requester, target, rights)) if (!StoreRights(requester, friendID, rights))
{ {
remoteClient.SendAlertMessage("Unable to grant rights."); remoteClient.SendAlertMessage("Unable to grant rights.");
return; return;
@ -748,17 +752,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
friend.MyFlags = rights; friend.MyFlags = rights;
// Always send this back to the original client // Always send this back to the original client
remoteClient.SendChangeUserRights(requester, target, rights); remoteClient.SendChangeUserRights(requester, friendID, rights);
// //
// Notify the friend // Notify the friend
// //
// Try local // Try local
if (LocalGrantRights(requester, target, myFlags, rights)) if (LocalGrantRights(requester, friendID, myFlags, rights))
return; return;
PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { target.ToString() }); PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() });
if (friendSessions != null && friendSessions.Length > 0) if (friendSessions != null && friendSessions.Length > 0)
{ {
PresenceInfo friendSession = friendSessions[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); GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID);
// TODO: You might want to send the delta to save the lookup // TODO: You might want to send the delta to save the lookup
// on the other end!! // on the other end!!
m_FriendsSimConnector.GrantRights(region, requester, target, myFlags, rights); m_FriendsSimConnector.GrantRights(region, requester, friendID, myFlags, rights);
} }
} }
} }
else 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) protected virtual void StoreFriendships(UUID agentID, UUID friendID)
{ {
FriendsService.StoreFriend(agentID.ToString(), friendID.ToString(), 1); FriendsService.StoreFriend(agentID.ToString(), friendID.ToString(), (int)FriendRights.CanSeeOnline);
FriendsService.StoreFriend(friendID.ToString(), agentID.ToString(), 1); FriendsService.StoreFriend(friendID.ToString(), agentID.ToString(), (int)FriendRights.CanSeeOnline);
} }
protected virtual bool DeleteFriendship(UUID agentID, UUID exfriendID) protected virtual bool DeleteFriendship(UUID agentID, UUID exfriendID)

View File

@ -30,6 +30,7 @@ using System.Collections.Generic;
using Nini.Config; using Nini.Config;
using NUnit.Framework; using NUnit.Framework;
using OpenMetaverse; using OpenMetaverse;
using OpenSim.Data.Null;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Region.CoreModules.Avatar.Friends; using OpenSim.Region.CoreModules.Avatar.Friends;
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
@ -63,6 +64,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends.Tests
[SetUp] [SetUp]
public void Init() 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(); IConfigSource config = new IniConfigSource();
config.AddConfig("Modules"); config.AddConfig("Modules");
// Not strictly necessary since FriendsModule assumes it is the default (!) // 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_fm.AddFriendship(sp1.ControllingClient, user2Id);
m_scene.RemoveClient(sp1.UUID, true); // Not necessary for this test. CanSeeOnline is automatically granted.
m_scene.RemoveClient(sp2.UUID, true); // 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); 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)); Assert.That(((TestClient)sp1Redux.ControllingClient).ReceivedOnlineNotifications.Count, Is.EqualTo(0));
} }
// [Test] [Test]
// public void TestLoginWithOnlineFriends() public void TestLoginWithOnlineFriends()
// { {
// TestHelpers.InMethod(); TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure(); // 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); // m_fm.AddFriendship(user1Id, user2Id);
// UUID user2Id = TestHelpers.ParseTail(0x2);
// ScenePresence sp1 = SceneHelpers.AddScenePresence(m_scene, user1Id);
//// UserAccountHelpers.CreateUserWithInventory(m_scene, user1Id); ScenePresence sp2 = SceneHelpers.AddScenePresence(m_scene, user2Id);
//// UserAccountHelpers.CreateUserWithInventory(m_scene, user2Id);
//// m_fm.AddFriendship(sp1.ControllingClient, user2Id);
//// m_fm.AddFriendship(user1Id, user2Id);
// // Not necessary for this test. CanSeeOnline is automatically granted.
// ScenePresence sp1 = SceneHelpers.AddScenePresence(m_scene, user1Id); // m_fm.GrantRights(sp1.ControllingClient, user2Id, (int)FriendRights.CanSeeOnline);
// SceneHelpers.AddScenePresence(m_scene, user2Id);
// // We must logout from the client end so that the presence service is correctly updated by the presence
// m_fm.AddFriendship(sp1.ControllingClient, user2Id); // detector. This is listening to the OnConnectionClosed event on the client.
//// m_fm.LocalGrantRights // ((TestClient)sp1.ControllingClient).Logout();
// ((TestClient)sp2.ControllingClient).Logout();
// m_scene.RemoveClient(sp1.UUID, true); // m_scene.RemoveClient(user2Id, true);
//
// ScenePresence sp1Redux = SceneHelpers.AddScenePresence(m_scene, user1Id); ScenePresence sp2Redux = SceneHelpers.AddScenePresence(m_scene, user2Id);
//
// Assert.That(((TestClient)sp1Redux.ControllingClient).ReceivedOfflineNotifications.Count, Is.EqualTo(0)); Assert.That(((TestClient)sp2Redux.ControllingClient).ReceivedOfflineNotifications.Count, Is.EqualTo(0));
// Assert.That(((TestClient)sp1Redux.ControllingClient).ReceivedOnlineNotifications.Count, Is.EqualTo(1)); Assert.That(((TestClient)sp2Redux.ControllingClient).ReceivedOnlineNotifications.Count, Is.EqualTo(1));
// } }
[Test] [Test]
public void TestAddFriendshipWhileOnline() public void TestAddFriendshipWhileOnline()

View File

@ -27,14 +27,12 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection; using System.Reflection;
using log4net;
using OpenMetaverse;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
using OpenSim.Services.Interfaces; using OpenSim.Services.Interfaces;
using OpenMetaverse;
using log4net;
namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence
{ {
public class PresenceDetector 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_log.DebugFormat("[PRESENCE DETECTOR]: Detected client logout {0} in {1}", client.AgentId, client.Scene.RegionInfo.RegionName);
m_PresenceService.LogoutAgent(client.SessionId); m_PresenceService.LogoutAgent(client.SessionId);
} }
} }
} }
} }

View File

@ -487,7 +487,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
return false; return false;
} }
protected bool IsFriendWithPerms(UUID user,UUID objectOwner) protected bool IsFriendWithPerms(UUID user, UUID objectOwner)
{ {
if (user == UUID.Zero) if (user == UUID.Zero)
return false; return false;
@ -495,11 +495,8 @@ namespace OpenSim.Region.CoreModules.World.Permissions
if (m_friendsModule == null) if (m_friendsModule == null)
return false; return false;
uint friendPerms = m_friendsModule.GetFriendPerms(user, objectOwner); int friendPerms = m_friendsModule.GetRightsGrantedByFriend(user, objectOwner);
if ((friendPerms & (uint)FriendRights.CanModifyObjects) != 0) return (friendPerms & (int)FriendRights.CanModifyObjects) != 0;
return true;
return false;
} }
protected bool IsEstateManager(UUID user) protected bool IsEstateManager(UUID user)
@ -508,6 +505,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
return m_scene.RegionInfo.EstateSettings.IsEstateManager(user); return m_scene.RegionInfo.EstateSettings.IsEstateManager(user);
} }
#endregion #endregion
public bool PropagatePermissions() public bool PropagatePermissions()

View File

@ -55,7 +55,27 @@ namespace OpenSim.Region.Framework.Interfaces
/// <param name="exFriendID"></param> /// <param name="exFriendID"></param>
void RemoveFriendship(IClientAPI client, UUID exFriendID); void RemoveFriendship(IClientAPI client, UUID exFriendID);
uint GetFriendPerms(UUID PrincipalID, UUID FriendID); /// <summary>
/// Get permissions granted by a friend.
/// </summary>
/// <param name="PrincipalID">The user.</param>
/// <param name="FriendID">The friend that granted.</param>
/// <returns>The permissions. These come from the FriendRights enum.</returns>
int GetRightsGrantedByFriend(UUID PrincipalID, UUID FriendID);
/// <summary>
/// Grant permissions for a friend.
/// </summary>
/// <remarks>
/// 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.
/// </remarks>
/// <param name="remoteClient">The user granting the permissions.</param>
/// <param name="friendID">The friend.</param>
/// <param name="perms">These come from the FriendRights enum.</param>
void GrantRights(IClientAPI remoteClient, UUID friendID, int perms);
bool SendFriendsOnlineIfNeeded(IClientAPI client); bool SendFriendsOnlineIfNeeded(IClientAPI client);
} }
} }

View File

@ -36,7 +36,15 @@ namespace OpenSim.Services.Interfaces
{ {
public UUID PrincipalID; public UUID PrincipalID;
public string Friend; public string Friend;
/// <summary>
/// The permissions that this user has granted to the friend.
/// </summary>
public int MyFlags; public int MyFlags;
/// <summary>
/// The permissions that the friend has granted to this user.
/// </summary>
public int TheirFlags; public int TheirFlags;
public FriendInfo() public FriendInfo()

View File

@ -151,11 +151,12 @@ namespace OpenSim.Services.PresenceService
info.Add(ret); info.Add(ret);
} }
// m_log.DebugFormat(
// "[PRESENCE SERVICE]: GetAgents for {0} found {1} presences", userIDStr, data.Length);
} }
// m_log.DebugFormat("[PRESENCE SERVICE]: GetAgents for {0} userIDs found {1} presences", userIDs.Length, info.Count);
return info.ToArray(); return info.ToArray();
} }
} }
} }

View File

@ -369,8 +369,11 @@ namespace OpenSim.Tests.Common
agentData.AgentID = agentId; agentData.AgentID = agentId;
agentData.firstname = firstName; agentData.firstname = firstName;
agentData.lastname = "testlastname"; agentData.lastname = "testlastname";
agentData.SessionID = UUID.Zero;
agentData.SecureSessionID = UUID.Zero; // XXX: Sessions must be unique, otherwise one presence can overwrite another in NullPresenceData.
agentData.SessionID = UUID.Random();
agentData.SecureSessionID = UUID.Random();
agentData.circuitcode = 123; agentData.circuitcode = 123;
agentData.BaseFolder = UUID.Zero; agentData.BaseFolder = UUID.Zero;
agentData.InventoryFolder = UUID.Zero; agentData.InventoryFolder = UUID.Zero;
@ -416,7 +419,10 @@ namespace OpenSim.Tests.Common
// We emulate the proper login sequence here by doing things in four stages // We emulate the proper login sequence here by doing things in four stages
// Stage 0: login // Stage 0: login
scene.PresenceService.LoginAgent(agentData.AgentID.ToString(), agentData.SessionID, agentData.SecureSessionID); // We need to punch through to the underlying service because scene will not, correctly, let us call it
// through it's reference to the LPSC
LocalPresenceServicesConnector lpsc = (LocalPresenceServicesConnector)scene.PresenceService;
lpsc.m_PresenceService.LoginAgent(agentData.AgentID.ToString(), agentData.SessionID, agentData.SecureSessionID);
// Stages 1 & 2 // Stages 1 & 2
ScenePresence sp = IntroduceClientToScene(scene, agentData, TeleportFlags.ViaLogin); ScenePresence sp = IntroduceClientToScene(scene, agentData, TeleportFlags.ViaLogin);

View File

@ -347,15 +347,9 @@ namespace OpenSim.Tests.Common.Mock
get { return m_agentId; } get { return m_agentId; }
} }
public UUID SessionId public UUID SessionId { get; set; }
{
get { return UUID.Zero; }
}
public UUID SecureSessionId public UUID SecureSessionId { get; set; }
{
get { return UUID.Zero; }
}
public virtual string FirstName public virtual string FirstName
{ {
@ -379,11 +373,9 @@ namespace OpenSim.Tests.Common.Mock
get { return true; } get { return true; }
set { } set { }
} }
public bool IsLoggingOut
{ public bool IsLoggingOut { get; set; }
get { return false; }
set { }
}
public UUID ActiveGroupId public UUID ActiveGroupId
{ {
get { return UUID.Zero; } get { return UUID.Zero; }
@ -449,6 +441,8 @@ namespace OpenSim.Tests.Common.Mock
m_lastName = agentData.lastname; m_lastName = agentData.lastname;
m_circuitCode = agentData.circuitcode; m_circuitCode = agentData.circuitcode;
m_scene = scene; m_scene = scene;
SessionId = agentData.SessionID;
SecureSessionId = agentData.SecureSessionID;
CapsSeedUrl = agentData.CapsPath; CapsSeedUrl = agentData.CapsPath;
ReceivedOfflineNotifications = new List<UUID>(); ReceivedOfflineNotifications = new List<UUID>();
@ -900,8 +894,24 @@ namespace OpenSim.Tests.Common.Mock
{ {
} }
/// <summary>
/// This is a TestClient only method to do shutdown tasks that are normally carried out by LLUDPServer.RemoveClient()
/// </summary>
public void Logout()
{
// We must set this here so that the presence is removed from the PresenceService by the PresenceDetector
IsLoggingOut = true;
Close();
}
public void Close() public void Close()
{ {
// Fire the callback for this connection closing
// This is necesary to get the presence detector to notice that a client has logged out.
if (OnConnectionClosed != null)
OnConnectionClosed(this);
m_scene.RemoveClient(AgentId, true); m_scene.RemoveClient(AgentId, true);
} }

View File

@ -2913,6 +2913,7 @@
<Reference name="OpenMetaverseTypes" path="../../../bin/"/> <Reference name="OpenMetaverseTypes" path="../../../bin/"/>
<Reference name="OpenMetaverse" path="../../../bin/"/> <Reference name="OpenMetaverse" path="../../../bin/"/>
<Reference name="OpenSim.Data"/> <Reference name="OpenSim.Data"/>
<Reference name="OpenSim.Data.Null"/>
<Reference name="OpenSim.Framework"/> <Reference name="OpenSim.Framework"/>
<Reference name="OpenSim.Framework.Serialization"/> <Reference name="OpenSim.Framework.Serialization"/>
<Reference name="OpenSim.Framework.Communications"/> <Reference name="OpenSim.Framework.Communications"/>