diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs | 50 |
1 files changed, 27 insertions, 23 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index 86e04b9..9d7012e 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs | |||
@@ -51,6 +51,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
51 | { | 51 | { |
52 | public class FriendsModule : ISharedRegionModule, IFriendsModule | 52 | public class FriendsModule : ISharedRegionModule, IFriendsModule |
53 | { | 53 | { |
54 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
55 | |||
54 | protected bool m_Enabled = false; | 56 | protected bool m_Enabled = false; |
55 | 57 | ||
56 | protected class UserFriendData | 58 | protected class UserFriendData |
@@ -72,7 +74,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
72 | } | 74 | } |
73 | 75 | ||
74 | protected static readonly FriendInfo[] EMPTY_FRIENDS = new FriendInfo[0]; | 76 | protected static readonly FriendInfo[] EMPTY_FRIENDS = new FriendInfo[0]; |
75 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
76 | 77 | ||
77 | protected List<Scene> m_Scenes = new List<Scene>(); | 78 | protected List<Scene> m_Scenes = new List<Scene>(); |
78 | 79 | ||
@@ -156,7 +157,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
156 | InitModule(config); | 157 | InitModule(config); |
157 | 158 | ||
158 | m_Enabled = true; | 159 | m_Enabled = true; |
159 | m_log.InfoFormat("[FRIENDS MODULE]: {0} enabled.", Name); | 160 | m_log.DebugFormat("[FRIENDS MODULE]: {0} enabled.", Name); |
160 | } | 161 | } |
161 | } | 162 | } |
162 | } | 163 | } |
@@ -201,7 +202,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
201 | if (!m_Enabled) | 202 | if (!m_Enabled) |
202 | return; | 203 | return; |
203 | 204 | ||
204 | m_log.DebugFormat("[FRIENDS MODULE]: AddRegion on {0}", Name); | 205 | // m_log.DebugFormat("[FRIENDS MODULE]: AddRegion on {0}", Name); |
205 | 206 | ||
206 | m_Scenes.Add(scene); | 207 | m_Scenes.Add(scene); |
207 | scene.RegisterModuleInterface<IFriendsModule>(this); | 208 | scene.RegisterModuleInterface<IFriendsModule>(this); |
@@ -241,13 +242,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
241 | 242 | ||
242 | #endregion | 243 | #endregion |
243 | 244 | ||
244 | public virtual uint GetFriendPerms(UUID principalID, UUID friendID) | 245 | public virtual int GetRightsGrantedByFriend(UUID principalID, UUID friendID) |
245 | { | 246 | { |
246 | FriendInfo[] friends = GetFriends(principalID); | 247 | FriendInfo[] friends = GetFriends(principalID); |
247 | FriendInfo finfo = GetFriend(friends, friendID); | 248 | FriendInfo finfo = GetFriend(friends, friendID); |
248 | if (finfo != null) | 249 | if (finfo != null) |
249 | { | 250 | { |
250 | return (uint)finfo.TheirFlags; | 251 | return finfo.TheirFlags; |
251 | } | 252 | } |
252 | 253 | ||
253 | return 0; | 254 | return 0; |
@@ -259,7 +260,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
259 | client.OnApproveFriendRequest += OnApproveFriendRequest; | 260 | client.OnApproveFriendRequest += OnApproveFriendRequest; |
260 | client.OnDenyFriendRequest += OnDenyFriendRequest; | 261 | client.OnDenyFriendRequest += OnDenyFriendRequest; |
261 | client.OnTerminateFriendship += RemoveFriendship; | 262 | client.OnTerminateFriendship += RemoveFriendship; |
262 | client.OnGrantUserRights += OnGrantUserRights; | 263 | client.OnGrantUserRights += GrantRights; |
263 | 264 | ||
264 | // We need to cache information for child agents as well as root agents so that friend edit/move/delete | 265 | // We need to cache information for child agents as well as root agents so that friend edit/move/delete |
265 | // permissions will work across borders where both regions are on different simulators. | 266 | // permissions will work across borders where both regions are on different simulators. |
@@ -356,10 +357,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
356 | // Send the friends online | 357 | // Send the friends online |
357 | List<UUID> online = GetOnlineFriends(agentID); | 358 | List<UUID> online = GetOnlineFriends(agentID); |
358 | 359 | ||
359 | // m_log.DebugFormat( | ||
360 | // "[FRIENDS MODULE]: User {0} in region {1} has {2} friends online", | ||
361 | // client.Name, client.Scene.RegionInfo.RegionName, online.Count); | ||
362 | |||
363 | if (online.Count > 0) | 360 | if (online.Count > 0) |
364 | client.SendAgentOnline(online.ToArray()); | 361 | client.SendAgentOnline(online.ToArray()); |
365 | 362 | ||
@@ -421,23 +418,30 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
421 | List<UUID> GetOnlineFriends(UUID userID) | 418 | List<UUID> GetOnlineFriends(UUID userID) |
422 | { | 419 | { |
423 | List<string> friendList = new List<string>(); | 420 | List<string> friendList = new List<string>(); |
424 | List<UUID> online = new List<UUID>(); | ||
425 | 421 | ||
426 | FriendInfo[] friends = GetFriends(userID); | 422 | FriendInfo[] friends = GetFriends(userID); |
427 | foreach (FriendInfo fi in friends) | 423 | foreach (FriendInfo fi in friends) |
428 | { | 424 | { |
429 | if (((fi.TheirFlags & 1) != 0) && (fi.TheirFlags != -1)) | 425 | if (((fi.TheirFlags & (int)FriendRights.CanSeeOnline) != 0) && (fi.TheirFlags != -1)) |
430 | friendList.Add(fi.Friend); | 426 | friendList.Add(fi.Friend); |
431 | } | 427 | } |
432 | 428 | ||
429 | List<UUID> online = new List<UUID>(); | ||
430 | |||
433 | if (friendList.Count > 0) | 431 | if (friendList.Count > 0) |
434 | GetOnlineFriends(userID, friendList, online); | 432 | GetOnlineFriends(userID, friendList, online); |
435 | 433 | ||
434 | // m_log.DebugFormat( | ||
435 | // "[FRIENDS MODULE]: User {0} has {1} friends online", userID, online.Count); | ||
436 | |||
436 | return online; | 437 | return online; |
437 | } | 438 | } |
438 | 439 | ||
439 | protected virtual void GetOnlineFriends(UUID userID, List<string> friendList, /*collector*/ List<UUID> online) | 440 | protected virtual void GetOnlineFriends(UUID userID, List<string> friendList, /*collector*/ List<UUID> online) |
440 | { | 441 | { |
442 | // m_log.DebugFormat( | ||
443 | // "[FRIENDS MODULE]: Looking for online presence of {0} users for {1}", friendList.Count, userID); | ||
444 | |||
441 | PresenceInfo[] presence = PresenceService.GetAgents(friendList.ToArray()); | 445 | PresenceInfo[] presence = PresenceService.GetAgents(friendList.ToArray()); |
442 | foreach (PresenceInfo pi in presence) | 446 | foreach (PresenceInfo pi in presence) |
443 | { | 447 | { |
@@ -717,13 +721,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
717 | } | 721 | } |
718 | } | 722 | } |
719 | 723 | ||
720 | private void OnGrantUserRights(IClientAPI remoteClient, UUID target, int rights) | 724 | public void GrantRights(IClientAPI remoteClient, UUID friendID, int rights) |
721 | { | 725 | { |
722 | UUID requester = remoteClient.AgentId; | 726 | UUID requester = remoteClient.AgentId; |
723 | 727 | ||
724 | m_log.DebugFormat( | 728 | m_log.DebugFormat( |
725 | "[FRIENDS MODULE]: User {0} changing rights to {1} for friend {2}", | 729 | "[FRIENDS MODULE]: User {0} changing rights to {1} for friend {2}", |
726 | requester, rights, target); | 730 | requester, rights, friendID); |
727 | 731 | ||
728 | FriendInfo[] friends = GetFriends(requester); | 732 | FriendInfo[] friends = GetFriends(requester); |
729 | if (friends.Length == 0) | 733 | if (friends.Length == 0) |
@@ -732,12 +736,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
732 | } | 736 | } |
733 | 737 | ||
734 | // Let's find the friend in this user's friend list | 738 | // Let's find the friend in this user's friend list |
735 | FriendInfo friend = GetFriend(friends, target); | 739 | FriendInfo friend = GetFriend(friends, friendID); |
736 | 740 | ||
737 | if (friend != null) // Found it | 741 | if (friend != null) // Found it |
738 | { | 742 | { |
739 | // Store it on the DB | 743 | // Store it on the DB |
740 | if (!StoreRights(requester, target, rights)) | 744 | if (!StoreRights(requester, friendID, rights)) |
741 | { | 745 | { |
742 | remoteClient.SendAlertMessage("Unable to grant rights."); | 746 | remoteClient.SendAlertMessage("Unable to grant rights."); |
743 | return; | 747 | return; |
@@ -748,17 +752,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
748 | friend.MyFlags = rights; | 752 | friend.MyFlags = rights; |
749 | 753 | ||
750 | // Always send this back to the original client | 754 | // Always send this back to the original client |
751 | remoteClient.SendChangeUserRights(requester, target, rights); | 755 | remoteClient.SendChangeUserRights(requester, friendID, rights); |
752 | 756 | ||
753 | // | 757 | // |
754 | // Notify the friend | 758 | // Notify the friend |
755 | // | 759 | // |
756 | 760 | ||
757 | // Try local | 761 | // Try local |
758 | if (LocalGrantRights(requester, target, myFlags, rights)) | 762 | if (LocalGrantRights(requester, friendID, myFlags, rights)) |
759 | return; | 763 | return; |
760 | 764 | ||
761 | PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { target.ToString() }); | 765 | PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() }); |
762 | if (friendSessions != null && friendSessions.Length > 0) | 766 | if (friendSessions != null && friendSessions.Length > 0) |
763 | { | 767 | { |
764 | PresenceInfo friendSession = friendSessions[0]; | 768 | PresenceInfo friendSession = friendSessions[0]; |
@@ -767,13 +771,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
767 | GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); | 771 | GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); |
768 | // TODO: You might want to send the delta to save the lookup | 772 | // TODO: You might want to send the delta to save the lookup |
769 | // on the other end!! | 773 | // on the other end!! |
770 | m_FriendsSimConnector.GrantRights(region, requester, target, myFlags, rights); | 774 | m_FriendsSimConnector.GrantRights(region, requester, friendID, myFlags, rights); |
771 | } | 775 | } |
772 | } | 776 | } |
773 | } | 777 | } |
774 | else | 778 | else |
775 | { | 779 | { |
776 | m_log.DebugFormat("[FRIENDS MODULE]: friend {0} not found for {1}", target, requester); | 780 | m_log.DebugFormat("[FRIENDS MODULE]: friend {0} not found for {1}", friendID, requester); |
777 | } | 781 | } |
778 | } | 782 | } |
779 | 783 | ||
@@ -990,8 +994,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
990 | 994 | ||
991 | protected virtual void StoreFriendships(UUID agentID, UUID friendID) | 995 | protected virtual void StoreFriendships(UUID agentID, UUID friendID) |
992 | { | 996 | { |
993 | FriendsService.StoreFriend(agentID.ToString(), friendID.ToString(), 1); | 997 | FriendsService.StoreFriend(agentID.ToString(), friendID.ToString(), (int)FriendRights.CanSeeOnline); |
994 | FriendsService.StoreFriend(friendID.ToString(), agentID.ToString(), 1); | 998 | FriendsService.StoreFriend(friendID.ToString(), agentID.ToString(), (int)FriendRights.CanSeeOnline); |
995 | } | 999 | } |
996 | 1000 | ||
997 | protected virtual bool DeleteFriendship(UUID agentID, UUID exfriendID) | 1001 | protected virtual bool DeleteFriendship(UUID agentID, UUID exfriendID) |