aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules
diff options
context:
space:
mode:
authorMelanie2011-11-17 19:04:27 +0000
committerMelanie2011-11-17 19:04:27 +0000
commit31736b1aac0387e51fe37ea9bab2e2e8c86988b6 (patch)
tree14fbdc5f9b677185db1fe8080dafe28796c09336 /OpenSim/Region/CoreModules
parentMerge branch 'master' into bigmerge (diff)
parentStop OdePrim and OdeCharacter insanely overriding set LocalID to set their ow... (diff)
downloadopensim-SC_OLD-31736b1aac0387e51fe37ea9bab2e2e8c86988b6.zip
opensim-SC_OLD-31736b1aac0387e51fe37ea9bab2e2e8c86988b6.tar.gz
opensim-SC_OLD-31736b1aac0387e51fe37ea9bab2e2e8c86988b6.tar.bz2
opensim-SC_OLD-31736b1aac0387e51fe37ea9bab2e2e8c86988b6.tar.xz
Merge branch 'master' into bigmerge
Conflicts: OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs81
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs31
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Friends/Tests/FriendModuleTests.cs30
-rw-r--r--OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs103
-rw-r--r--OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs3
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs9
6 files changed, 177 insertions, 80 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
index 0c81bb2..5d94ff7 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
@@ -29,6 +29,7 @@ using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Reflection; 31using System.Reflection;
32using System.Threading;
32using log4net; 33using log4net;
33using Nini.Config; 34using Nini.Config;
34using Nwc.XmlRpc; 35using Nwc.XmlRpc;
@@ -79,10 +80,20 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
79 protected IFriendsService m_FriendsService = null; 80 protected IFriendsService m_FriendsService = null;
80 protected FriendsSimConnector m_FriendsSimConnector; 81 protected FriendsSimConnector m_FriendsSimConnector;
81 82
82 protected Dictionary<UUID, UserFriendData> m_Friends = 83 /// <summary>
83 new Dictionary<UUID, UserFriendData>(); 84 /// Cache friends lists for users.
85 /// </summary>
86 /// <remarks>
87 /// This is a complex and error-prone thing to do. At the moment, we assume that the efficiency gained in
88 /// permissions checks outweighs the disadvantages of that complexity.
89 /// </remarks>
90 protected Dictionary<UUID, UserFriendData> m_Friends = new Dictionary<UUID, UserFriendData>();
84 91
85 protected HashSet<UUID> m_NeedsListOfFriends = new HashSet<UUID>(); 92 /// <summary>
93 /// Maintain a record of viewers that need to be sent notifications for friends that are online. This only
94 /// needs to be done on login. Subsequent online/offline friend changes are sent by a different mechanism.
95 /// </summary>
96 protected HashSet<UUID> m_NeedsListOfOnlineFriends = new HashSet<UUID>();
86 97
87 protected IPresenceService PresenceService 98 protected IPresenceService PresenceService
88 { 99 {
@@ -189,6 +200,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
189 { 200 {
190 if (!m_Enabled) 201 if (!m_Enabled)
191 return; 202 return;
203
192 m_log.DebugFormat("[FRIENDS MODULE]: AddRegion on {0}", Name); 204 m_log.DebugFormat("[FRIENDS MODULE]: AddRegion on {0}", Name);
193 205
194 m_Scenes.Add(scene); 206 m_Scenes.Add(scene);
@@ -241,16 +253,25 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
241 client.OnInstantMessage += OnInstantMessage; 253 client.OnInstantMessage += OnInstantMessage;
242 client.OnApproveFriendRequest += OnApproveFriendRequest; 254 client.OnApproveFriendRequest += OnApproveFriendRequest;
243 client.OnDenyFriendRequest += OnDenyFriendRequest; 255 client.OnDenyFriendRequest += OnDenyFriendRequest;
244 client.OnTerminateFriendship += OnTerminateFriendship; 256 client.OnTerminateFriendship += (thisClient, agentID, exfriendID) => RemoveFriendship(thisClient, exfriendID);
245 client.OnGrantUserRights += OnGrantUserRights; 257 client.OnGrantUserRights += OnGrantUserRights;
246 258
247 Util.FireAndForget(delegate { FetchFriendslist(client); }); 259 // Do not do this asynchronously. If we do, then subsequent code can outrace CacheFriends() and
260 // return misleading results from the still empty friends cache.
261 // If we absolutely need to do this asynchronously, then a signalling mechanism is needed so that calls
262 // to GetFriends() will wait until CacheFriends() completes. Locks are insufficient.
263 CacheFriends(client);
248 } 264 }
249 265
250 /// Fetch the friends list or increment the refcount for the existing 266 /// <summary>
251 /// friends list 267 /// Cache the friends list or increment the refcount for the existing friends list.
268 /// </summary>
269 /// <param name="client">
270 /// </param>
271 /// <returns>
252 /// Returns true if the list was fetched, false if it wasn't 272 /// Returns true if the list was fetched, false if it wasn't
253 protected virtual bool FetchFriendslist(IClientAPI client) 273 /// </returns>
274 protected virtual bool CacheFriends(IClientAPI client)
254 { 275 {
255 UUID agentID = client.AgentId; 276 UUID agentID = client.AgentId;
256 lock (m_Friends) 277 lock (m_Friends)
@@ -297,7 +318,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
297 318
298 private void OnMakeRootAgent(ScenePresence sp) 319 private void OnMakeRootAgent(ScenePresence sp)
299 { 320 {
300 RefetchFriends(sp.ControllingClient); 321 RecacheFriends(sp.ControllingClient);
301 } 322 }
302 323
303 private void OnClientLogin(IClientAPI client) 324 private void OnClientLogin(IClientAPI client)
@@ -309,8 +330,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
309 StatusChange(agentID, true); 330 StatusChange(agentID, true);
310 331
311 // Register that we need to send the list of online friends to this user 332 // Register that we need to send the list of online friends to this user
312 lock (m_NeedsListOfFriends) 333 lock (m_NeedsListOfOnlineFriends)
313 m_NeedsListOfFriends.Add(agentID); 334 m_NeedsListOfOnlineFriends.Add(agentID);
314 } 335 }
315 336
316 public virtual bool SendFriendsOnlineIfNeeded(IClientAPI client) 337 public virtual bool SendFriendsOnlineIfNeeded(IClientAPI client)
@@ -318,9 +339,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
318 UUID agentID = client.AgentId; 339 UUID agentID = client.AgentId;
319 340
320 // Check if the online friends list is needed 341 // Check if the online friends list is needed
321 lock (m_NeedsListOfFriends) 342 lock (m_NeedsListOfOnlineFriends)
322 { 343 {
323 if (!m_NeedsListOfFriends.Remove(agentID)) 344 if (!m_NeedsListOfOnlineFriends.Remove(agentID))
324 return false; 345 return false;
325 } 346 }
326 347
@@ -328,7 +349,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
328 List<UUID> online = GetOnlineFriends(agentID); 349 List<UUID> online = GetOnlineFriends(agentID);
329 if (online.Count > 0) 350 if (online.Count > 0)
330 { 351 {
331 m_log.DebugFormat("[FRIENDS MODULE]: User {0} in region {1} has {2} friends online", client.AgentId, client.Scene.RegionInfo.RegionName, online.Count); 352 m_log.DebugFormat(
353 "[FRIENDS MODULE]: User {0} in region {1} has {2} friends online",
354 client.Name, client.Scene.RegionInfo.RegionName, online.Count);
355
332 client.SendAgentOnline(online.ToArray()); 356 client.SendAgentOnline(online.ToArray());
333 } 357 }
334 358
@@ -586,7 +610,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
586 } 610 }
587 611
588 // Update the local cache 612 // Update the local cache
589 RefetchFriends(client); 613 RecacheFriends(client);
590 614
591 // 615 //
592 // Notify the friend 616 // Notify the friend
@@ -641,14 +665,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
641 } 665 }
642 } 666 }
643 } 667 }
644 668
645 private void OnTerminateFriendship(IClientAPI client, UUID agentID, UUID exfriendID) 669 public void RemoveFriendship(IClientAPI client, UUID exfriendID)
646 { 670 {
647 if (!DeleteFriendship(agentID, exfriendID)) 671 if (!DeleteFriendship(client.AgentId, exfriendID))
648 client.SendAlertMessage("Unable to terminate friendship on this sim."); 672 client.SendAlertMessage("Unable to terminate friendship on this sim.");
649 673
650 // Update local cache 674 // Update local cache
651 RefetchFriends(client); 675 RecacheFriends(client);
652 676
653 client.SendTerminateFriend(exfriendID); 677 client.SendTerminateFriend(exfriendID);
654 678
@@ -667,9 +691,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
667 if (friendSession != null) 691 if (friendSession != null)
668 { 692 {
669 GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); 693 GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID);
670 m_FriendsSimConnector.FriendshipTerminated(region, agentID, exfriendID); 694 m_FriendsSimConnector.FriendshipTerminated(region, client.AgentId, exfriendID);
671 } 695 }
672 } 696 }
673 } 697 }
674 698
675 private void OnGrantUserRights(IClientAPI remoteClient, UUID requester, UUID target, int rights) 699 private void OnGrantUserRights(IClientAPI remoteClient, UUID requester, UUID target, int rights)
@@ -769,7 +793,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
769 793
770 794
771 // Update the local cache 795 // Update the local cache
772 RefetchFriends(friendClient); 796 RecacheFriends(friendClient);
773 797
774 // we're done 798 // we're done
775 return true; 799 return true;
@@ -802,7 +826,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
802 // the friend in this sim as root agent 826 // the friend in this sim as root agent
803 friendClient.SendTerminateFriend(exfriendID); 827 friendClient.SendTerminateFriend(exfriendID);
804 // update local cache 828 // update local cache
805 RefetchFriends(friendClient); 829 RecacheFriends(friendClient);
806 // we're done 830 // we're done
807 return true; 831 return true;
808 } 832 }
@@ -819,16 +843,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
819 if (onlineBitChanged) 843 if (onlineBitChanged)
820 { 844 {
821 if ((rights & (int)FriendRights.CanSeeOnline) == 1) 845 if ((rights & (int)FriendRights.CanSeeOnline) == 1)
822 friendClient.SendAgentOnline(new UUID[] { new UUID(userID) }); 846 friendClient.SendAgentOnline(new UUID[] { userID });
823 else 847 else
824 friendClient.SendAgentOffline(new UUID[] { new UUID(userID) }); 848 friendClient.SendAgentOffline(new UUID[] { userID });
825 } 849 }
826 else 850 else
827 { 851 {
828 bool canEditObjectsChanged = ((rights ^ userFlags) & (int)FriendRights.CanModifyObjects) != 0; 852 bool canEditObjectsChanged = ((rights ^ userFlags) & (int)FriendRights.CanModifyObjects) != 0;
829 if (canEditObjectsChanged) 853 if (canEditObjectsChanged)
830 friendClient.SendChangeUserRights(userID, friendID, rights); 854 friendClient.SendChangeUserRights(userID, friendID, rights);
831
832 } 855 }
833 856
834 // Update local cache 857 // Update local cache
@@ -847,7 +870,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
847 IClientAPI friendClient = LocateClientObject(friendID); 870 IClientAPI friendClient = LocateClientObject(friendID);
848 if (friendClient != null) 871 if (friendClient != null)
849 { 872 {
850 // the friend in this sim as root agent 873 // the friend in this sim as root agent
851 if (online) 874 if (online)
852 friendClient.SendAgentOnline(new UUID[] { userID }); 875 friendClient.SendAgentOnline(new UUID[] { userID });
853 else 876 else
@@ -902,8 +925,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
902 return FriendsService.GetFriends(client.AgentId); 925 return FriendsService.GetFriends(client.AgentId);
903 } 926 }
904 927
905 private void RefetchFriends(IClientAPI client) 928 private void RecacheFriends(IClientAPI client)
906 { 929 {
930 // FIXME: Ideally, we want to avoid doing this here since it sits the EventManager.OnMakeRootAgent event
931 // is on the critical path for transferring an avatar from one region to another.
907 UUID agentID = client.AgentId; 932 UUID agentID = client.AgentId;
908 lock (m_Friends) 933 lock (m_Friends)
909 { 934 {
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs
index 02b417f..9a97925 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs
@@ -30,7 +30,6 @@ using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Reflection; 31using System.Reflection;
32using System.Threading; 32using System.Threading;
33
34using log4net; 33using log4net;
35using Nini.Config; 34using Nini.Config;
36using Nwc.XmlRpc; 35using Nwc.XmlRpc;
@@ -84,9 +83,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
84 83
85 #endregion 84 #endregion
86 85
87 protected override bool FetchFriendslist(IClientAPI client) 86 protected override bool CacheFriends(IClientAPI client)
88 { 87 {
89 if (base.FetchFriendslist(client)) 88// m_log.DebugFormat("[HGFRIENDS MODULE]: Entered CacheFriends for {0}", client.Name);
89
90 if (base.CacheFriends(client))
90 { 91 {
91 UUID agentID = client.AgentId; 92 UUID agentID = client.AgentId;
92 // we do this only for the root agent 93 // we do this only for the root agent
@@ -110,14 +111,20 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
110 } 111 }
111 } 112 }
112 } 113 }
114
115// m_log.DebugFormat("[HGFRIENDS MODULE]: Exiting CacheFriends for {0} since detected root agent", client.Name);
113 return true; 116 return true;
114 } 117 }
115 } 118 }
119
120// m_log.DebugFormat("[HGFRIENDS MODULE]: Exiting CacheFriends for {0} since detected not root agent", client.Name);
116 return false; 121 return false;
117 } 122 }
118 123
119 public override bool SendFriendsOnlineIfNeeded(IClientAPI client) 124 public override bool SendFriendsOnlineIfNeeded(IClientAPI client)
120 { 125 {
126// m_log.DebugFormat("[HGFRIENDS MODULE]: Entering SendFriendsOnlineIfNeeded for {0}", client.Name);
127
121 if (base.SendFriendsOnlineIfNeeded(client)) 128 if (base.SendFriendsOnlineIfNeeded(client))
122 { 129 {
123 AgentCircuitData aCircuit = ((Scene)client.Scene).AuthenticateHandler.GetAgentCircuitData(client.AgentId); 130 AgentCircuitData aCircuit = ((Scene)client.Scene).AuthenticateHandler.GetAgentCircuitData(client.AgentId);
@@ -134,11 +141,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
134 } 141 }
135 } 142 }
136 } 143 }
144
145// m_log.DebugFormat("[HGFRIENDS MODULE]: Exiting SendFriendsOnlineIfNeeded for {0}", client.Name);
137 return false; 146 return false;
138 } 147 }
139 148
140 protected override void GetOnlineFriends(UUID userID, List<string> friendList, /*collector*/ List<UUID> online) 149 protected override void GetOnlineFriends(UUID userID, List<string> friendList, /*collector*/ List<UUID> online)
141 { 150 {
151// m_log.DebugFormat("[HGFRIENDS MODULE]: Entering GetOnlineFriends for {0}", userID);
152
142 List<string> fList = new List<string>(); 153 List<string> fList = new List<string>();
143 foreach (string s in friendList) 154 foreach (string s in friendList)
144 { 155 {
@@ -157,6 +168,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
157 if (UUID.TryParse(pi.UserID, out presenceID)) 168 if (UUID.TryParse(pi.UserID, out presenceID))
158 online.Add(presenceID); 169 online.Add(presenceID);
159 } 170 }
171
172// m_log.DebugFormat("[HGFRIENDS MODULE]: Exiting GetOnlineFriends for {0}", userID);
160 } 173 }
161 174
162 //protected override void GetOnlineFriends(UUID userID, List<string> friendList, /*collector*/ List<UUID> online) 175 //protected override void GetOnlineFriends(UUID userID, List<string> friendList, /*collector*/ List<UUID> online)
@@ -246,6 +259,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
246 259
247 protected override void StatusNotify(List<FriendInfo> friendList, UUID userID, bool online) 260 protected override void StatusNotify(List<FriendInfo> friendList, UUID userID, bool online)
248 { 261 {
262// m_log.DebugFormat("[HGFRIENDS MODULE]: Entering StatusNotify for {0}", userID);
263
249 // First, let's divide the friends on a per-domain basis 264 // First, let's divide the friends on a per-domain basis
250 Dictionary<string, List<FriendInfo>> friendsPerDomain = new Dictionary<string, List<FriendInfo>>(); 265 Dictionary<string, List<FriendInfo>> friendsPerDomain = new Dictionary<string, List<FriendInfo>>();
251 foreach (FriendInfo friend in friendList) 266 foreach (FriendInfo friend in friendList)
@@ -298,6 +313,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
298 } 313 }
299 } 314 }
300 } 315 }
316
317// m_log.DebugFormat("[HGFRIENDS MODULE]: Exiting StatusNotify for {0}", userID);
301 } 318 }
302 319
303 protected override bool GetAgentInfo(UUID scopeID, string fid, out UUID agentID, out string first, out string last) 320 protected override bool GetAgentInfo(UUID scopeID, string fid, out UUID agentID, out string first, out string last)
@@ -351,6 +368,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
351 368
352 protected override FriendInfo[] GetFriendsFromService(IClientAPI client) 369 protected override FriendInfo[] GetFriendsFromService(IClientAPI client)
353 { 370 {
371// m_log.DebugFormat("[HGFRIENDS MODULE]: Entering GetFriendsFromService for {0}", client.Name);
372
354 UserAccount account1 = UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, client.AgentId); 373 UserAccount account1 = UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, client.AgentId);
355 if (account1 != null) 374 if (account1 != null)
356 return base.GetFriendsFromService(client); 375 return base.GetFriendsFromService(client);
@@ -365,6 +384,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
365 finfos = FriendsService.GetFriends(agentUUI); 384 finfos = FriendsService.GetFriends(agentUUI);
366 m_log.DebugFormat("[HGFRIENDS MODULE]: Fetched {0} local friends for visitor {1}", finfos.Length, agentUUI); 385 m_log.DebugFormat("[HGFRIENDS MODULE]: Fetched {0} local friends for visitor {1}", finfos.Length, agentUUI);
367 } 386 }
387
388// m_log.DebugFormat("[HGFRIENDS MODULE]: Exiting GetFriendsFromService for {0}", client.Name);
389
368 return finfos; 390 return finfos;
369 } 391 }
370 392
@@ -401,7 +423,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
401 } 423 }
402 424
403 return false; 425 return false;
404
405 } 426 }
406 427
407 protected override void StoreBackwards(UUID friendID, UUID agentID) 428 protected override void StoreBackwards(UUID friendID, UUID agentID)
@@ -627,4 +648,4 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
627 } 648 }
628 } 649 }
629 } 650 }
630} 651} \ No newline at end of file
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/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs
index bef0d69..a40a6a4 100644
--- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs
@@ -31,7 +31,6 @@ using System.Reflection;
31 31
32using OpenSim.Framework; 32using OpenSim.Framework;
33using OpenSim.Framework.Console; 33using OpenSim.Framework.Console;
34
35using OpenSim.Region.Framework; 34using OpenSim.Region.Framework;
36using OpenSim.Region.Framework.Interfaces; 35using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Region.Framework.Scenes; 36using OpenSim.Region.Framework.Scenes;
@@ -44,13 +43,13 @@ using Nini.Config;
44 43
45namespace OpenSim.Region.CoreModules.Framework.UserManagement 44namespace OpenSim.Region.CoreModules.Framework.UserManagement
46{ 45{
47 struct UserData 46 class UserData
48 { 47 {
49 public UUID Id; 48 public UUID Id { get; set; }
50 public string FirstName; 49 public string FirstName { get; set; }
51 public string LastName; 50 public string LastName { get; set; }
52 public string HomeURL; 51 public string HomeURL { get; set; }
53 public Dictionary<string, object> ServerURLs; 52 public Dictionary<string, object> ServerURLs { get; set; }
54 } 53 }
55 54
56 public class UserManagementModule : ISharedRegionModule, IUserManagement 55 public class UserManagementModule : ISharedRegionModule, IUserManagement
@@ -130,7 +129,9 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
130 public void Close() 129 public void Close()
131 { 130 {
132 m_Scenes.Clear(); 131 m_Scenes.Clear();
133 m_UserCache.Clear(); 132
133 lock (m_UserCache)
134 m_UserCache.Clear();
134 } 135 }
135 136
136 #endregion ISharedRegionModule 137 #endregion ISharedRegionModule
@@ -188,11 +189,14 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
188 { 189 {
189 string[] returnstring = new string[2]; 190 string[] returnstring = new string[2];
190 191
191 if (m_UserCache.ContainsKey(uuid)) 192 lock (m_UserCache)
192 { 193 {
193 returnstring[0] = m_UserCache[uuid].FirstName; 194 if (m_UserCache.ContainsKey(uuid))
194 returnstring[1] = m_UserCache[uuid].LastName; 195 {
195 return returnstring; 196 returnstring[0] = m_UserCache[uuid].FirstName;
197 returnstring[1] = m_UserCache[uuid].LastName;
198 return returnstring;
199 }
196 } 200 }
197 201
198 UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(UUID.Zero, uuid); 202 UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(UUID.Zero, uuid);
@@ -237,22 +241,36 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
237 241
238 public string GetUserHomeURL(UUID userID) 242 public string GetUserHomeURL(UUID userID)
239 { 243 {
240 if (m_UserCache.ContainsKey(userID)) 244 lock (m_UserCache)
241 return m_UserCache[userID].HomeURL; 245 {
246 if (m_UserCache.ContainsKey(userID))
247 return m_UserCache[userID].HomeURL;
248 }
242 249
243 return string.Empty; 250 return string.Empty;
244 } 251 }
245 252
246 public string GetUserServerURL(UUID userID, string serverType) 253 public string GetUserServerURL(UUID userID, string serverType)
247 { 254 {
248 if (m_UserCache.ContainsKey(userID)) 255 UserData userdata;
256 lock (m_UserCache)
257 m_UserCache.TryGetValue(userID, out userdata);
258
259 if (userdata != null)
249 { 260 {
250 UserData userdata = m_UserCache[userID]; 261// m_log.DebugFormat("[USER MANAGEMENT MODULE]: Requested url type {0} for {1}", serverType, userID);
262
251 if (userdata.ServerURLs != null && userdata.ServerURLs.ContainsKey(serverType) && userdata.ServerURLs[serverType] != null) 263 if (userdata.ServerURLs != null && userdata.ServerURLs.ContainsKey(serverType) && userdata.ServerURLs[serverType] != null)
264 {
252 return userdata.ServerURLs[serverType].ToString(); 265 return userdata.ServerURLs[serverType].ToString();
266 }
253 267
254 if (userdata.HomeURL != string.Empty) 268 if (userdata.HomeURL != null && userdata.HomeURL != string.Empty)
255 { 269 {
270 m_log.DebugFormat(
271 "[USER MANAGEMENT MODULE]: Did not find url type {0} so requesting urls from '{1}' for {2}",
272 serverType, userdata.HomeURL, userID);
273
256 UserAgentServiceConnector uConn = new UserAgentServiceConnector(userdata.HomeURL); 274 UserAgentServiceConnector uConn = new UserAgentServiceConnector(userdata.HomeURL);
257 userdata.ServerURLs = uConn.GetServerURLs(userID); 275 userdata.ServerURLs = uConn.GetServerURLs(userID);
258 if (userdata.ServerURLs != null && userdata.ServerURLs.ContainsKey(serverType) && userdata.ServerURLs[serverType] != null) 276 if (userdata.ServerURLs != null && userdata.ServerURLs.ContainsKey(serverType) && userdata.ServerURLs[serverType] != null)
@@ -269,9 +287,12 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
269 if (account != null) 287 if (account != null)
270 return userID.ToString(); 288 return userID.ToString();
271 289
272 if (m_UserCache.ContainsKey(userID)) 290 UserData ud;
291 lock (m_UserCache)
292 m_UserCache.TryGetValue(userID, out ud);
293
294 if (ud != null)
273 { 295 {
274 UserData ud = m_UserCache[userID];
275 string homeURL = ud.HomeURL; 296 string homeURL = ud.HomeURL;
276 string first = ud.FirstName, last = ud.LastName; 297 string first = ud.FirstName, last = ud.LastName;
277 if (ud.LastName.StartsWith("@")) 298 if (ud.LastName.StartsWith("@"))
@@ -291,8 +312,11 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
291 312
292 public void AddUser(UUID uuid, string first, string last) 313 public void AddUser(UUID uuid, string first, string last)
293 { 314 {
294 if (m_UserCache.ContainsKey(uuid)) 315 lock (m_UserCache)
295 return; 316 {
317 if (m_UserCache.ContainsKey(uuid))
318 return;
319 }
296 320
297 UserData user = new UserData(); 321 UserData user = new UserData();
298 user.Id = uuid; 322 user.Id = uuid;
@@ -310,8 +334,11 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
310 334
311 public void AddUser(UUID id, string creatorData) 335 public void AddUser(UUID id, string creatorData)
312 { 336 {
313 if (m_UserCache.ContainsKey(id)) 337 lock (m_UserCache)
314 return; 338 {
339 if (m_UserCache.ContainsKey(id))
340 return;
341 }
315 342
316// m_log.DebugFormat("[USER MANAGEMENT MODULE]: Adding user with id {0}, craetorData {1}", id, creatorData); 343// m_log.DebugFormat("[USER MANAGEMENT MODULE]: Adding user with id {0}, craetorData {1}", id, creatorData);
317 344
@@ -402,22 +429,24 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
402 429
403 private void HandleShowUsers(string module, string[] cmd) 430 private void HandleShowUsers(string module, string[] cmd)
404 { 431 {
405 if (m_UserCache.Count == 0) 432 lock (m_UserCache)
406 { 433 {
407 MainConsole.Instance.Output("No users not found"); 434 if (m_UserCache.Count == 0)
435 {
436 MainConsole.Instance.Output("No users not found");
437 return;
438 }
439
440 MainConsole.Instance.Output("UUID User Name");
441 MainConsole.Instance.Output("-----------------------------------------------------------------------------");
442 foreach (KeyValuePair<UUID, UserData> kvp in m_UserCache)
443 {
444 MainConsole.Instance.Output(String.Format("{0} {1} {2}",
445 kvp.Key, kvp.Value.FirstName, kvp.Value.LastName));
446 }
447
408 return; 448 return;
409 } 449 }
410
411 MainConsole.Instance.Output("UUID User Name");
412 MainConsole.Instance.Output("-----------------------------------------------------------------------------");
413 foreach (KeyValuePair<UUID, UserData> kvp in m_UserCache)
414 {
415 MainConsole.Instance.Output(String.Format("{0} {1} {2}",
416 kvp.Key, kvp.Value.FirstName, kvp.Value.LastName));
417 }
418 return;
419 } 450 }
420
421
422 } 451 }
423} 452} \ 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 2e877f0..3963474 100644
--- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
+++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
@@ -479,8 +479,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
479 } 479 }
480 480
481 protected bool IsFriendWithPerms(UUID user,UUID objectOwner) 481 protected bool IsFriendWithPerms(UUID user,UUID objectOwner)
482 { 482 {
483
484 if (user == UUID.Zero) 483 if (user == UUID.Zero)
485 return false; 484 return false;
486 485
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
index b49f23c..ba4ddc1 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
@@ -65,7 +65,6 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
65 65
66 private OpenSim.Framework.BlockingQueue<MapRequestState> requests = new OpenSim.Framework.BlockingQueue<MapRequestState>(); 66 private OpenSim.Framework.BlockingQueue<MapRequestState> requests = new OpenSim.Framework.BlockingQueue<MapRequestState>();
67 67
68 //private IConfig m_config;
69 protected Scene m_scene; 68 protected Scene m_scene;
70 private List<MapBlockData> cachedMapBlocks = new List<MapBlockData>(); 69 private List<MapBlockData> cachedMapBlocks = new List<MapBlockData>();
71 private int cachedTime = 0; 70 private int cachedTime = 0;
@@ -348,7 +347,11 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
348 347
349// m_log.Debug("[WORLD MAP]: Starting remote MapItem request thread"); 348// m_log.Debug("[WORLD MAP]: Starting remote MapItem request thread");
350 349
351 Watchdog.StartThread(process, "MapItemRequestThread", ThreadPriority.BelowNormal, true); 350 Watchdog.StartThread(
351 process,
352 string.Format("MapItemRequestThread ({0})", m_scene.RegionInfo.RegionName),
353 ThreadPriority.BelowNormal,
354 true);
352 } 355 }
353 356
354 /// <summary> 357 /// <summary>
@@ -357,7 +360,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
357 private void StopThread() 360 private void StopThread()
358 { 361 {
359 MapRequestState st = new MapRequestState(); 362 MapRequestState st = new MapRequestState();
360 st.agentID=STOP_UUID; 363 st.agentID = STOP_UUID;
361 st.EstateID=0; 364 st.EstateID=0;
362 st.flags=0; 365 st.flags=0;
363 st.godlike=false; 366 st.godlike=false;