diff options
author | Justin Clark-Casey (justincc) | 2011-11-14 18:08:02 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2011-11-14 18:08:02 +0000 |
commit | 348d15707d129c99bc79cd35d544bc62b9a6f1b2 (patch) | |
tree | e1377950e09d753d2979134dd96e253ce83e5be9 /OpenSim/Region | |
parent | Add very simple FriendsModuleTests.TestNoFriends() (diff) | |
download | opensim-SC_OLD-348d15707d129c99bc79cd35d544bc62b9a6f1b2.zip opensim-SC_OLD-348d15707d129c99bc79cd35d544bc62b9a6f1b2.tar.gz opensim-SC_OLD-348d15707d129c99bc79cd35d544bc62b9a6f1b2.tar.bz2 opensim-SC_OLD-348d15707d129c99bc79cd35d544bc62b9a6f1b2.tar.xz |
Add test for adding a friend whilst online
Diffstat (limited to 'OpenSim/Region')
3 files changed, 44 insertions, 6 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index 28a2f73..f4281e5 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs | |||
@@ -576,9 +576,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
576 | 576 | ||
577 | private void OnApproveFriendRequest(IClientAPI client, UUID agentID, UUID friendID, List<UUID> callingCardFolders) | 577 | private void OnApproveFriendRequest(IClientAPI client, UUID agentID, UUID friendID, List<UUID> callingCardFolders) |
578 | { | 578 | { |
579 | m_log.DebugFormat("[FRIENDS]: {0} accepted friendship from {1}", agentID, friendID); | 579 | m_log.DebugFormat("[FRIENDS]: {0} accepted friendship from {1}", client.AgentId, friendID); |
580 | 580 | ||
581 | StoreFriendships(agentID, friendID); | 581 | AddFriend(client, friendID); |
582 | } | ||
583 | |||
584 | public void AddFriend(IClientAPI client, UUID friendID) | ||
585 | { | ||
586 | StoreFriendships(client.AgentId, friendID); | ||
582 | 587 | ||
583 | // Update the local cache | 588 | // Update the local cache |
584 | RefetchFriends(client); | 589 | RefetchFriends(client); |
@@ -588,7 +593,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
588 | // | 593 | // |
589 | 594 | ||
590 | // Try Local | 595 | // Try Local |
591 | if (LocalFriendshipApproved(agentID, client.Name, friendID)) | 596 | if (LocalFriendshipApproved(client.AgentId, client.Name, friendID)) |
592 | { | 597 | { |
593 | client.SendAgentOnline(new UUID[] { friendID }); | 598 | client.SendAgentOnline(new UUID[] { friendID }); |
594 | return; | 599 | return; |
@@ -602,7 +607,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
602 | if (friendSession != null) | 607 | if (friendSession != null) |
603 | { | 608 | { |
604 | GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); | 609 | GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); |
605 | m_FriendsSimConnector.FriendshipApproved(region, agentID, client.Name, friendID); | 610 | m_FriendsSimConnector.FriendshipApproved(region, client.AgentId, client.Name, friendID); |
606 | client.SendAgentOnline(new UUID[] { friendID }); | 611 | client.SendAgentOnline(new UUID[] { friendID }); |
607 | } | 612 | } |
608 | } | 613 | } |
@@ -869,7 +874,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
869 | } | 874 | } |
870 | 875 | ||
871 | /// <summary> | 876 | /// <summary> |
872 | /// Update loca cache only | 877 | /// Update local cache only |
873 | /// </summary> | 878 | /// </summary> |
874 | /// <param name="userID"></param> | 879 | /// <param name="userID"></param> |
875 | /// <param name="friendID"></param> | 880 | /// <param name="friendID"></param> |
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/Tests/FriendModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Friends/Tests/FriendModuleTests.cs index b52093a..3ad691a 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/Tests/FriendModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/Tests/FriendModuleTests.cs | |||
@@ -70,9 +70,28 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends.Tests | |||
70 | UUID userId = TestHelpers.ParseTail(0x1); | 70 | UUID userId = TestHelpers.ParseTail(0x1); |
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).OfflineNotificationsReceived.Count, Is.EqualTo(0)); |
75 | Assert.That(((TestClient)sp.ControllingClient).OnlineNotificationsReceived.Count, Is.EqualTo(0)); | 75 | Assert.That(((TestClient)sp.ControllingClient).OnlineNotificationsReceived.Count, Is.EqualTo(0)); |
76 | } | 76 | } |
77 | |||
78 | [Test] | ||
79 | public void TestAddFriendWhileOnline() | ||
80 | { | ||
81 | TestHelpers.InMethod(); | ||
82 | // log4net.Config.XmlConfigurator.Configure(); | ||
83 | |||
84 | UUID userId = TestHelpers.ParseTail(0x1); | ||
85 | UUID user2Id = TestHelpers.ParseTail(0x2); | ||
86 | |||
87 | ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId); | ||
88 | ScenePresence sp2 = SceneHelpers.AddScenePresence(m_scene, user2Id); | ||
89 | |||
90 | // This friendship is currently only one-way, which might be pathalogical in Second Life. | ||
91 | m_fm.AddFriend(sp.ControllingClient, user2Id); | ||
92 | |||
93 | Assert.That(((TestClient)sp.ControllingClient).OfflineNotificationsReceived.Count, Is.EqualTo(0)); | ||
94 | Assert.That(((TestClient)sp.ControllingClient).OnlineNotificationsReceived.Count, Is.EqualTo(1)); | ||
95 | } | ||
77 | } | 96 | } |
78 | } \ No newline at end of file | 97 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs b/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs index d4a6857..8143164 100644 --- a/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs | |||
@@ -33,6 +33,20 @@ namespace OpenSim.Region.Framework.Interfaces | |||
33 | { | 33 | { |
34 | public interface IFriendsModule | 34 | public interface IFriendsModule |
35 | { | 35 | { |
36 | /// <summary> | ||
37 | /// Add a friend for the given user. | ||
38 | /// </summary> | ||
39 | /// <remarks> | ||
40 | /// This is a one-way friendship. To make a two way friendship you will need to call this again with the | ||
41 | /// client and friend reversed. | ||
42 | /// | ||
43 | /// Ultimately, it would be more useful to take in a user account here rather than having to have a user | ||
44 | /// present in the scene. | ||
45 | /// </remarks> | ||
46 | /// <param name="client"></param> | ||
47 | /// <param name="friendID"></param> | ||
48 | void AddFriend(IClientAPI client, UUID friendID); | ||
49 | |||
36 | uint GetFriendPerms(UUID PrincipalID, UUID FriendID); | 50 | uint GetFriendPerms(UUID PrincipalID, UUID FriendID); |
37 | bool SendFriendsOnlineIfNeeded(IClientAPI client); | 51 | bool SendFriendsOnlineIfNeeded(IClientAPI client); |
38 | } | 52 | } |