aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs12
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Friends/Tests/FriendModuleTests.cs30
-rw-r--r--OpenSim/Region/Framework/Interfaces/IFriendsModule.cs11
-rw-r--r--OpenSim/Tests/Common/Mock/TestClient.cs15
4 files changed, 51 insertions, 17 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
index 7a2a46e..529d7cf 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
@@ -241,7 +241,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
241 client.OnInstantMessage += OnInstantMessage; 241 client.OnInstantMessage += OnInstantMessage;
242 client.OnApproveFriendRequest += OnApproveFriendRequest; 242 client.OnApproveFriendRequest += OnApproveFriendRequest;
243 client.OnDenyFriendRequest += OnDenyFriendRequest; 243 client.OnDenyFriendRequest += OnDenyFriendRequest;
244 client.OnTerminateFriendship += OnTerminateFriendship; 244 client.OnTerminateFriendship += (thisClient, agentID, exfriendID) => RemoveFriendship(thisClient, exfriendID);
245 client.OnGrantUserRights += OnGrantUserRights; 245 client.OnGrantUserRights += OnGrantUserRights;
246 246
247 Util.FireAndForget(delegate { FetchFriendslist(client); }); 247 Util.FireAndForget(delegate { FetchFriendslist(client); });
@@ -635,10 +635,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
635 } 635 }
636 } 636 }
637 } 637 }
638 638
639 private void OnTerminateFriendship(IClientAPI client, UUID agentID, UUID exfriendID) 639 public void RemoveFriendship(IClientAPI client, UUID exfriendID)
640 { 640 {
641 if (!DeleteFriendship(agentID, exfriendID)) 641 if (!DeleteFriendship(client.AgentId, exfriendID))
642 client.SendAlertMessage("Unable to terminate friendship on this sim."); 642 client.SendAlertMessage("Unable to terminate friendship on this sim.");
643 643
644 // Update local cache 644 // Update local cache
@@ -661,9 +661,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
661 if (friendSession != null) 661 if (friendSession != null)
662 { 662 {
663 GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); 663 GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID);
664 m_FriendsSimConnector.FriendshipTerminated(region, agentID, exfriendID); 664 m_FriendsSimConnector.FriendshipTerminated(region, client.AgentId, exfriendID);
665 } 665 }
666 } 666 }
667 } 667 }
668 668
669 private void OnGrantUserRights(IClientAPI remoteClient, UUID requester, UUID target, int rights) 669 private void OnGrantUserRights(IClientAPI remoteClient, UUID requester, UUID target, int rights)
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/Tests/FriendModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Friends/Tests/FriendModuleTests.cs
index c945dcf..682fbab 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/Tests/FriendModuleTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/Tests/FriendModuleTests.cs
@@ -71,12 +71,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends.Tests
71 71
72 ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId); 72 ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId);
73 73
74 Assert.That(((TestClient)sp.ControllingClient).OfflineNotificationsReceived.Count, Is.EqualTo(0)); 74 Assert.That(((TestClient)sp.ControllingClient).ReceivedOfflineNotifications.Count, Is.EqualTo(0));
75 Assert.That(((TestClient)sp.ControllingClient).OnlineNotificationsReceived.Count, Is.EqualTo(0)); 75 Assert.That(((TestClient)sp.ControllingClient).ReceivedOnlineNotifications.Count, Is.EqualTo(0));
76 } 76 }
77 77
78 [Test] 78 [Test]
79 public void TestAddFriendWhileOnline() 79 public void TestAddFriendshipWhileOnline()
80 { 80 {
81 TestHelpers.InMethod(); 81 TestHelpers.InMethod();
82// log4net.Config.XmlConfigurator.Configure(); 82// log4net.Config.XmlConfigurator.Configure();
@@ -91,8 +91,28 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends.Tests
91 // notification. 91 // notification.
92 m_fm.AddFriendship(sp.ControllingClient, user2Id); 92 m_fm.AddFriendship(sp.ControllingClient, user2Id);
93 93
94 Assert.That(((TestClient)sp.ControllingClient).OfflineNotificationsReceived.Count, Is.EqualTo(0)); 94 Assert.That(((TestClient)sp.ControllingClient).ReceivedOfflineNotifications.Count, Is.EqualTo(0));
95 Assert.That(((TestClient)sp.ControllingClient).OnlineNotificationsReceived.Count, Is.EqualTo(1)); 95 Assert.That(((TestClient)sp.ControllingClient).ReceivedOnlineNotifications.Count, Is.EqualTo(1));
96 }
97
98 [Test]
99 public void TestRemoveFriendshipWhileOnline()
100 {
101 TestHelpers.InMethod();
102// log4net.Config.XmlConfigurator.Configure();
103
104 UUID user1Id = TestHelpers.ParseTail(0x1);
105 UUID user2Id = TestHelpers.ParseTail(0x2);
106
107 ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, user1Id);
108 SceneHelpers.AddScenePresence(m_scene, user2Id);
109
110 m_fm.AddFriendship(sp.ControllingClient, user2Id);
111 m_fm.RemoveFriendship(sp.ControllingClient, user2Id);
112
113 TestClient user1Client = sp.ControllingClient as TestClient;
114 Assert.That(user1Client.ReceivedFriendshipTerminations.Count, Is.EqualTo(1));
115 Assert.That(user1Client.ReceivedFriendshipTerminations[0], Is.EqualTo(user2Id));
96 } 116 }
97 } 117 }
98} \ No newline at end of file 118} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs b/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs
index fdede34..061799e 100644
--- a/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs
@@ -44,6 +44,17 @@ namespace OpenSim.Region.Framework.Interfaces
44 /// <param name="friendID"></param> 44 /// <param name="friendID"></param>
45 void AddFriendship(IClientAPI client, UUID friendID); 45 void AddFriendship(IClientAPI client, UUID friendID);
46 46
47 /// <summary>
48 /// Remove a friendship between two users.
49 /// </summary>
50 /// <remarks>
51 /// Ultimately, it would be more useful to take in a user account here rather than having to have a user
52 /// present in the scene.
53 /// </remarks>
54 /// <param name="client"></param>
55 /// <param name="exFriendID"></param>
56 void RemoveFriendship(IClientAPI client, UUID exFriendID);
57
47 uint GetFriendPerms(UUID PrincipalID, UUID FriendID); 58 uint GetFriendPerms(UUID PrincipalID, UUID FriendID);
48 bool SendFriendsOnlineIfNeeded(IClientAPI client); 59 bool SendFriendsOnlineIfNeeded(IClientAPI client);
49 } 60 }
diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs
index 3ba9ed4..b83ef9b 100644
--- a/OpenSim/Tests/Common/Mock/TestClient.cs
+++ b/OpenSim/Tests/Common/Mock/TestClient.cs
@@ -57,8 +57,9 @@ namespace OpenSim.Tests.Common.Mock
57 private IScene m_scene; 57 private IScene m_scene;
58 58
59 // Properties so that we can get at received data for test purposes 59 // Properties so that we can get at received data for test purposes
60 public List<UUID> OfflineNotificationsReceived { get; private set; } 60 public List<UUID> ReceivedOfflineNotifications { get; private set; }
61 public List<UUID> OnlineNotificationsReceived { get; private set; } 61 public List<UUID> ReceivedOnlineNotifications { get; private set; }
62 public List<UUID> ReceivedFriendshipTerminations { get; private set; }
62 63
63// disable warning: public events, part of the public API 64// disable warning: public events, part of the public API
64#pragma warning disable 67 65#pragma warning disable 67
@@ -445,8 +446,9 @@ namespace OpenSim.Tests.Common.Mock
445 m_scene = scene; 446 m_scene = scene;
446 CapsSeedUrl = agentData.CapsPath; 447 CapsSeedUrl = agentData.CapsPath;
447 448
448 OfflineNotificationsReceived = new List<UUID>(); 449 ReceivedOfflineNotifications = new List<UUID>();
449 OnlineNotificationsReceived = new List<UUID>(); 450 ReceivedOnlineNotifications = new List<UUID>();
451 ReceivedFriendshipTerminations = new List<UUID>();
450 } 452 }
451 453
452 /// <summary> 454 /// <summary>
@@ -834,12 +836,12 @@ namespace OpenSim.Tests.Common.Mock
834 836
835 public void SendAgentOffline(UUID[] agentIDs) 837 public void SendAgentOffline(UUID[] agentIDs)
836 { 838 {
837 OfflineNotificationsReceived.AddRange(agentIDs); 839 ReceivedOfflineNotifications.AddRange(agentIDs);
838 } 840 }
839 841
840 public void SendAgentOnline(UUID[] agentIDs) 842 public void SendAgentOnline(UUID[] agentIDs)
841 { 843 {
842 OnlineNotificationsReceived.AddRange(agentIDs); 844 ReceivedOnlineNotifications.AddRange(agentIDs);
843 } 845 }
844 846
845 public void SendSitResponse(UUID TargetID, Vector3 OffsetPos, Quaternion SitOrientation, bool autopilot, 847 public void SendSitResponse(UUID TargetID, Vector3 OffsetPos, Quaternion SitOrientation, bool autopilot,
@@ -1109,6 +1111,7 @@ namespace OpenSim.Tests.Common.Mock
1109 1111
1110 public void SendTerminateFriend(UUID exFriendID) 1112 public void SendTerminateFriend(UUID exFriendID)
1111 { 1113 {
1114 ReceivedFriendshipTerminations.Add(exFriendID);
1112 } 1115 }
1113 1116
1114 public bool AddGenericPacketHandler(string MethodName, GenericMessage handler) 1117 public bool AddGenericPacketHandler(string MethodName, GenericMessage handler)