aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Data/Null/NullFriendsData.cs10
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs2
-rw-r--r--OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs2
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs28
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs9
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Friends/Tests/FriendModuleTests.cs97
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/HGMessageTransferModule.cs3
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs3
-rw-r--r--OpenSim/Region/Framework/Interfaces/IFriendsModule.cs14
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs2
-rw-r--r--OpenSim/Tests/Common/Mock/TestClient.cs11
11 files changed, 158 insertions, 23 deletions
diff --git a/OpenSim/Data/Null/NullFriendsData.cs b/OpenSim/Data/Null/NullFriendsData.cs
index d90788a..0a4b242 100644
--- a/OpenSim/Data/Null/NullFriendsData.cs
+++ b/OpenSim/Data/Null/NullFriendsData.cs
@@ -56,13 +56,21 @@ namespace OpenSim.Data.Null
56 /// <returns></returns> 56 /// <returns></returns>
57 public FriendsData[] GetFriends(string userID) 57 public FriendsData[] GetFriends(string userID)
58 { 58 {
59 List<FriendsData> lst = m_Data.FindAll(delegate (FriendsData fdata) 59 List<FriendsData> lst = m_Data.FindAll(fdata =>
60 { 60 {
61 return fdata.PrincipalID == userID.ToString(); 61 return fdata.PrincipalID == userID.ToString();
62 }); 62 });
63 63
64 if (lst != null) 64 if (lst != null)
65 {
66 lst.ForEach(f =>
67 {
68 FriendsData f2 = m_Data.Find(candidateF2 => f.Friend == candidateF2.PrincipalID);
69 if (f2 != null) { f.Data["TheirFlags"] = f2.Data["Flags"]; }
70 });
71
65 return lst.ToArray(); 72 return lst.ToArray();
73 }
66 74
67 return new FriendsData[0]; 75 return new FriendsData[0];
68 } 76 }
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
index 2e76acb..8fdbe7b 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
@@ -11197,6 +11197,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11197 Utils.BytesToString(avatarInterestUpdate.PropertiesData.LanguagesText)); 11197 Utils.BytesToString(avatarInterestUpdate.PropertiesData.LanguagesText));
11198 return true; 11198 return true;
11199 } 11199 }
11200
11200 private bool HandleGrantUserRights(IClientAPI sender, Packet Pack) 11201 private bool HandleGrantUserRights(IClientAPI sender, Packet Pack)
11201 { 11202 {
11202 GrantUserRightsPacket GrantUserRights = 11203 GrantUserRightsPacket GrantUserRights =
@@ -11217,6 +11218,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11217 GrantUserRights.Rights[0].RelatedRights); 11218 GrantUserRights.Rights[0].RelatedRights);
11218 return true; 11219 return true;
11219 } 11220 }
11221
11220 private bool HandlePlacesQuery(IClientAPI sender, Packet Pack) 11222 private bool HandlePlacesQuery(IClientAPI sender, Packet Pack)
11221 { 11223 {
11222 PlacesQueryPacket placesQueryPacket = 11224 PlacesQueryPacket placesQueryPacket =
diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs
index eed7cd5..b557ffe 100644
--- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs
+++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs
@@ -46,7 +46,6 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
46 // Fields 46 // Fields
47 private bool m_dumpAssetsToFile; 47 private bool m_dumpAssetsToFile;
48 private Scene m_Scene; 48 private Scene m_Scene;
49 private UUID UserID;
50 private Dictionary<UUID, AssetXferUploader> XferUploaders = new Dictionary<UUID, AssetXferUploader>(); 49 private Dictionary<UUID, AssetXferUploader> XferUploaders = new Dictionary<UUID, AssetXferUploader>();
51 50
52 // Methods 51 // Methods
@@ -54,7 +53,6 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
54 bool dumpAssetsToFile) 53 bool dumpAssetsToFile)
55 { 54 {
56 m_Scene = scene; 55 m_Scene = scene;
57 UserID = agentID;
58 m_dumpAssetsToFile = dumpAssetsToFile; 56 m_dumpAssetsToFile = dumpAssetsToFile;
59 } 57 }
60 58
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
index a5131ec..74f32e7 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
@@ -165,7 +165,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
165 165
166 // Instantiate the request handler 166 // Instantiate the request handler
167 IHttpServer server = MainServer.GetHttpServer((uint)mPort); 167 IHttpServer server = MainServer.GetHttpServer((uint)mPort);
168 server.AddStreamHandler(new FriendsRequestHandler(this)); 168
169 if (server != null)
170 server.AddStreamHandler(new FriendsRequestHandler(this));
169 } 171 }
170 172
171 if (m_FriendsService == null) 173 if (m_FriendsService == null)
@@ -352,20 +354,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
352 continue; 354 continue;
353 } 355 }
354 356
355 PresenceInfo presence = null; 357 im.offline = 0;
356 PresenceInfo[] presences = PresenceService.GetAgents(new string[] { fid });
357 if (presences != null && presences.Length > 0)
358 presence = presences[0];
359 if (presence != null)
360 im.offline = 0;
361
362 im.fromAgentID = fromAgentID.Guid; 358 im.fromAgentID = fromAgentID.Guid;
363 im.fromAgentName = firstname + " " + lastname; 359 im.fromAgentName = firstname + " " + lastname;
364 im.offline = (byte)((presence == null) ? 1 : 0); 360 im.offline = (byte)((presence == null) ? 1 : 0);
365 im.imSessionID = im.fromAgentID; 361 im.imSessionID = im.fromAgentID;
366 im.message = FriendshipMessage(fid); 362 im.message = FriendshipMessage(fid);
367 363
368 // Finally
369 LocalFriendshipOffered(agentID, im); 364 LocalFriendshipOffered(agentID, im);
370 } 365 }
371 366
@@ -576,9 +571,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
576 571
577 private void OnApproveFriendRequest(IClientAPI client, UUID agentID, UUID friendID, List<UUID> callingCardFolders) 572 private void OnApproveFriendRequest(IClientAPI client, UUID agentID, UUID friendID, List<UUID> callingCardFolders)
578 { 573 {
579 m_log.DebugFormat("[FRIENDS]: {0} accepted friendship from {1}", agentID, friendID); 574 m_log.DebugFormat("[FRIENDS]: {0} accepted friendship from {1}", client.AgentId, friendID);
580 575
581 StoreFriendships(agentID, friendID); 576 AddFriend(client, friendID);
577 }
578
579 public void AddFriend(IClientAPI client, UUID friendID)
580 {
581 StoreFriendships(client.AgentId, friendID);
582 582
583 ICallingCardModule ccm = client.Scene.RequestModuleInterface<ICallingCardModule>(); 583 ICallingCardModule ccm = client.Scene.RequestModuleInterface<ICallingCardModule>();
584 if (ccm != null) 584 if (ccm != null)
@@ -594,7 +594,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
594 // 594 //
595 595
596 // Try Local 596 // Try Local
597 if (LocalFriendshipApproved(agentID, client.Name, friendID)) 597 if (LocalFriendshipApproved(client.AgentId, client.Name, friendID))
598 { 598 {
599 client.SendAgentOnline(new UUID[] { friendID }); 599 client.SendAgentOnline(new UUID[] { friendID });
600 return; 600 return;
@@ -608,7 +608,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
608 if (friendSession != null) 608 if (friendSession != null)
609 { 609 {
610 GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); 610 GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID);
611 m_FriendsSimConnector.FriendshipApproved(region, agentID, client.Name, friendID); 611 m_FriendsSimConnector.FriendshipApproved(region, client.AgentId, client.Name, friendID);
612 client.SendAgentOnline(new UUID[] { friendID }); 612 client.SendAgentOnline(new UUID[] { friendID });
613 } 613 }
614 } 614 }
@@ -882,7 +882,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
882 } 882 }
883 883
884 /// <summary> 884 /// <summary>
885 /// Update loca cache only 885 /// Update local cache only
886 /// </summary> 886 /// </summary>
887 /// <param name="userID"></param> 887 /// <param name="userID"></param>
888 /// <param name="friendID"></param> 888 /// <param name="friendID"></param>
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs
index dda67f9..02b417f 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs
@@ -141,7 +141,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
141 { 141 {
142 List<string> fList = new List<string>(); 142 List<string> fList = new List<string>();
143 foreach (string s in friendList) 143 foreach (string s in friendList)
144 fList.Add(s.Substring(0, 36)); 144 {
145 if (s.Length < 36)
146 m_log.WarnFormat(
147 "[HGFRIENDS MODULE]: Ignoring friend {0} ({1} chars) for {2} since identifier too short",
148 s, s.Length, userID);
149 else
150 fList.Add(s.Substring(0, 36));
151 }
145 152
146 PresenceInfo[] presence = PresenceService.GetAgents(fList.ToArray()); 153 PresenceInfo[] presence = PresenceService.GetAgents(fList.ToArray());
147 foreach (PresenceInfo pi in presence) 154 foreach (PresenceInfo pi in presence)
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/Tests/FriendModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Friends/Tests/FriendModuleTests.cs
new file mode 100644
index 0000000..942091c
--- /dev/null
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/Tests/FriendModuleTests.cs
@@ -0,0 +1,97 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using Nini.Config;
31using NUnit.Framework;
32using OpenMetaverse;
33using OpenSim.Framework;
34using OpenSim.Region.CoreModules.Avatar.Friends;
35using OpenSim.Region.Framework.Scenes;
36using OpenSim.Tests.Common;
37using OpenSim.Tests.Common.Mock;
38
39namespace OpenSim.Region.CoreModules.Avatar.Friends.Tests
40{
41 [TestFixture]
42 public class FriendsModuleTests
43 {
44 private FriendsModule m_fm;
45 private TestScene m_scene;
46
47 [SetUp]
48 public void Init()
49 {
50 IConfigSource config = new IniConfigSource();
51 config.AddConfig("Modules");
52 // Not strictly necessary since FriendsModule assumes it is the default (!)
53 config.Configs["Modules"].Set("FriendsModule", "FriendsModule");
54 config.AddConfig("Friends");
55 config.Configs["Friends"].Set("Connector", "OpenSim.Services.FriendsService.dll");
56 config.AddConfig("FriendsService");
57 config.Configs["FriendsService"].Set("StorageProvider", "OpenSim.Data.Null.dll");
58
59 m_scene = SceneHelpers.SetupScene();
60 m_fm = new FriendsModule();
61 SceneHelpers.SetupSceneModules(m_scene, config, m_fm);
62 }
63
64 [Test]
65 public void TestNoFriends()
66 {
67 TestHelpers.InMethod();
68// log4net.Config.XmlConfigurator.Configure();
69
70 UUID userId = TestHelpers.ParseTail(0x1);
71
72 ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId);
73
74 Assert.That(((TestClient)sp.ControllingClient).OfflineNotificationsReceived.Count, Is.EqualTo(0));
75 Assert.That(((TestClient)sp.ControllingClient).OnlineNotificationsReceived.Count, Is.EqualTo(0));
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 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 }
96 }
97} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/HGMessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/HGMessageTransferModule.cs
index 321a705..560d913 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/HGMessageTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/HGMessageTransferModule.cs
@@ -225,12 +225,13 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
225 foreach (Scene scene in m_Scenes) 225 foreach (Scene scene in m_Scenes)
226 { 226 {
227 ScenePresence sp = scene.GetScenePresence(toAgentID); 227 ScenePresence sp = scene.GetScenePresence(toAgentID);
228 if(!sp.IsChildAgent) 228 if(sp != null && !sp.IsChildAgent)
229 { 229 {
230 scene.EventManager.TriggerIncomingInstantMessage(gim); 230 scene.EventManager.TriggerIncomingInstantMessage(gim);
231 successful = true; 231 successful = true;
232 } 232 }
233 } 233 }
234
234 if (!successful) 235 if (!successful)
235 { 236 {
236 // If the message can't be delivered to an agent, it 237 // If the message can't be delivered to an agent, it
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs
index 73ab4e3..10ab6d0 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs
@@ -50,8 +50,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
50 /// </summary> 50 /// </summary>
51 public Scene Scene { get; set; } 51 public Scene Scene { get; set; }
52 52
53 private bool m_Enabled = false; 53 private bool m_Enabled;
54 private Scene m_Scene;
55 private XInventoryServicesConnector m_RemoteConnector; 54 private XInventoryServicesConnector m_RemoteConnector;
56 55
57 private IUserManagement m_UserManager; 56 private IUserManagement m_UserManager;
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 }
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 087697f..8906c6f 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -2862,6 +2862,8 @@ namespace OpenSim.Region.Framework.Scenes
2862 Velocity = Vector3.Zero; 2862 Velocity = Vector3.Zero;
2863 AbsolutePosition = pos; 2863 AbsolutePosition = pos;
2864 2864
2865// m_log.DebugFormat("[SCENE PRESENCE]: Prevented flyoff for {0} at {1}", Name, AbsolutePosition);
2866
2865 AddToPhysicalScene(isFlying); 2867 AddToPhysicalScene(isFlying);
2866 } 2868 }
2867 } 2869 }
diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs
index 60a23f5..5fe1985 100644
--- a/OpenSim/Tests/Common/Mock/TestClient.cs
+++ b/OpenSim/Tests/Common/Mock/TestClient.cs
@@ -56,6 +56,10 @@ namespace OpenSim.Tests.Common.Mock
56 56
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
60 public List<UUID> OfflineNotificationsReceived { get; private set; }
61 public List<UUID> OnlineNotificationsReceived { get; private set; }
62
59// disable warning: public events, part of the public API 63// disable warning: public events, part of the public API
60#pragma warning disable 67 64#pragma warning disable 67
61 65
@@ -440,6 +444,9 @@ namespace OpenSim.Tests.Common.Mock
440 m_circuitCode = agentData.circuitcode; 444 m_circuitCode = agentData.circuitcode;
441 m_scene = scene; 445 m_scene = scene;
442 CapsSeedUrl = agentData.CapsPath; 446 CapsSeedUrl = agentData.CapsPath;
447
448 OfflineNotificationsReceived = new List<UUID>();
449 OnlineNotificationsReceived = new List<UUID>();
443 } 450 }
444 451
445 /// <summary> 452 /// <summary>
@@ -827,12 +834,12 @@ namespace OpenSim.Tests.Common.Mock
827 834
828 public void SendAgentOffline(UUID[] agentIDs) 835 public void SendAgentOffline(UUID[] agentIDs)
829 { 836 {
830 837 OfflineNotificationsReceived.AddRange(agentIDs);
831 } 838 }
832 839
833 public void SendAgentOnline(UUID[] agentIDs) 840 public void SendAgentOnline(UUID[] agentIDs)
834 { 841 {
835 842 OnlineNotificationsReceived.AddRange(agentIDs);
836 } 843 }
837 844
838 public void SendSitResponse(UUID TargetID, Vector3 OffsetPos, Quaternion SitOrientation, bool autopilot, 845 public void SendSitResponse(UUID TargetID, Vector3 OffsetPos, Quaternion SitOrientation, bool autopilot,