aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs87
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs8
2 files changed, 78 insertions, 17 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
index 08e7dd2..d6c4d5b 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
@@ -262,6 +262,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
262 client.OnDenyFriendRequest += OnDenyFriendRequest; 262 client.OnDenyFriendRequest += OnDenyFriendRequest;
263 client.OnTerminateFriendship += RemoveFriendship; 263 client.OnTerminateFriendship += RemoveFriendship;
264 client.OnGrantUserRights += GrantRights; 264 client.OnGrantUserRights += GrantRights;
265 client.OnFindAgent += FindFriend;
265 266
266 // We need to cache information for child agents as well as root agents so that friend edit/move/delete 267 // We need to cache information for child agents as well as root agents so that friend edit/move/delete
267 // permissions will work across borders where both regions are on different simulators. 268 // permissions will work across borders where both regions are on different simulators.
@@ -726,6 +727,64 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
726 } 727 }
727 } 728 }
728 729
730 public void FindFriend(IClientAPI remoteClient,UUID HunterID ,UUID PreyID)
731 {
732 UUID requester = remoteClient.AgentId;
733 if(requester != HunterID) // only allow client agent to be the hunter (?)
734 return;
735
736 FriendInfo[] friends = GetFriendsFromCache(requester);
737 if (friends.Length == 0)
738 return;
739
740 FriendInfo friend = GetFriend(friends, PreyID);
741 if (friend == null)
742 return;
743
744 if((friend.TheirFlags & (int)FriendRights.CanSeeOnMap) == 0)
745 return;
746
747 Scene hunterScene = (Scene)remoteClient.Scene;
748
749 if(hunterScene == null)
750 return;
751
752 // check local
753 ScenePresence sp;
754 double px;
755 double py;
756 if(hunterScene.TryGetScenePresence(PreyID, out sp))
757 {
758 if(sp == null)
759 return;
760 px = hunterScene.RegionInfo.WorldLocX + sp.AbsolutePosition.X;
761 py = hunterScene.RegionInfo.WorldLocY + sp.AbsolutePosition.Y;
762
763 remoteClient.SendFindAgent(HunterID, PreyID, px, py);
764 return;
765 }
766
767 PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { PreyID.ToString() });
768
769 if (friendSessions == null || friendSessions.Length == 0)
770 return;
771
772 PresenceInfo friendSession = friendSessions[0];
773 if (friendSession == null)
774 return;
775
776 GridRegion region = GridService.GetRegionByUUID(hunterScene.RegionInfo.ScopeID, friendSession.RegionID);
777
778 if(region == null)
779 return;
780
781 // we don't have presence location so point to a standard region center for now
782 px = region.RegionLocX + 128.0;
783 py = region.RegionLocY + 128.0;
784
785 remoteClient.SendFindAgent(HunterID, PreyID, px, py);
786 }
787
729 public void GrantRights(IClientAPI remoteClient, UUID friendID, int rights) 788 public void GrantRights(IClientAPI remoteClient, UUID friendID, int rights)
730 { 789 {
731 UUID requester = remoteClient.AgentId; 790 UUID requester = remoteClient.AgentId;
@@ -745,7 +804,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
745 804
746 if (friend != null) // Found it 805 if (friend != null) // Found it
747 { 806 {
748 // Store it on the DB 807 // Store it on service
749 if (!StoreRights(requester, friendID, rights)) 808 if (!StoreRights(requester, friendID, rights))
750 { 809 {
751 remoteClient.SendAlertMessage("Unable to grant rights."); 810 remoteClient.SendAlertMessage("Unable to grant rights.");
@@ -869,28 +928,26 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
869 return false; 928 return false;
870 } 929 }
871 930
872 public bool LocalGrantRights(UUID userID, UUID friendID, int userFlags, int rights) 931 public bool LocalGrantRights(UUID userID, UUID friendID, int oldRights, int newRights)
873 { 932 {
874 IClientAPI friendClient = LocateClientObject(friendID); 933 IClientAPI friendClient = LocateClientObject(friendID);
875 if (friendClient != null) 934 if (friendClient != null)
876 { 935 {
877 bool onlineBitChanged = ((rights ^ userFlags) & (int)FriendRights.CanSeeOnline) != 0; 936 int changedRights = newRights ^ oldRights;
937 bool onlineBitChanged = (changedRights & (int)FriendRights.CanSeeOnline) != 0;
878 if (onlineBitChanged) 938 if (onlineBitChanged)
879 { 939 {
880 if ((rights & (int)FriendRights.CanSeeOnline) == 1) 940 if ((newRights & (int)FriendRights.CanSeeOnline) == 1)
881 friendClient.SendAgentOnline(new UUID[] { userID }); 941 friendClient.SendAgentOnline(new UUID[] { userID });
882 else 942 else
883 friendClient.SendAgentOffline(new UUID[] { userID }); 943 friendClient.SendAgentOffline(new UUID[] { userID });
884 } 944 }
885 else 945
886 { 946 if(changedRights != 0)
887 bool canEditObjectsChanged = ((rights ^ userFlags) & (int)FriendRights.CanModifyObjects) != 0; 947 friendClient.SendChangeUserRights(userID, friendID, newRights);
888 if (canEditObjectsChanged)
889 friendClient.SendChangeUserRights(userID, friendID, rights);
890 }
891 948
892 // Update local cache 949 // Update local cache
893 UpdateLocalCache(userID, friendID, rights); 950 UpdateLocalCache(userID, friendID, newRights);
894 951
895 return true; 952 return true;
896 } 953 }
@@ -946,8 +1003,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
946 lock (m_Friends) 1003 lock (m_Friends)
947 { 1004 {
948 FriendInfo[] friends = GetFriendsFromCache(friendID); 1005 FriendInfo[] friends = GetFriendsFromCache(friendID);
949 FriendInfo finfo = GetFriend(friends, userID); 1006 if(friends != EMPTY_FRIENDS)
950 finfo.TheirFlags = rights; 1007 {
1008 FriendInfo finfo = GetFriend(friends, userID);
1009 if(finfo!= null)
1010 finfo.TheirFlags = rights;
1011 }
951 } 1012 }
952 } 1013 }
953 1014
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs
index 13512a2..c421740 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs
@@ -211,7 +211,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
211 { 211 {
212 UUID fromID = UUID.Zero; 212 UUID fromID = UUID.Zero;
213 UUID toID = UUID.Zero; 213 UUID toID = UUID.Zero;
214 int rights = 0, userFlags = 0; 214 int oldRights = 0, newRights = 0;
215 215
216 if (!request.ContainsKey("FromID") || !request.ContainsKey("ToID")) 216 if (!request.ContainsKey("FromID") || !request.ContainsKey("ToID"))
217 return FailureResult(); 217 return FailureResult();
@@ -222,13 +222,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
222 if (!UUID.TryParse(request["ToID"].ToString(), out toID)) 222 if (!UUID.TryParse(request["ToID"].ToString(), out toID))
223 return FailureResult(); 223 return FailureResult();
224 224
225 if (!Int32.TryParse(request["UserFlags"].ToString(), out userFlags)) 225 if (!Int32.TryParse(request["UserFlags"].ToString(), out oldRights))
226 return FailureResult(); 226 return FailureResult();
227 227
228 if (!Int32.TryParse(request["Rights"].ToString(), out rights)) 228 if (!Int32.TryParse(request["Rights"].ToString(), out newRights))
229 return FailureResult(); 229 return FailureResult();
230 230
231 if (m_FriendsModule.LocalGrantRights(UUID.Zero, UUID.Zero, userFlags, rights)) 231 if (m_FriendsModule.LocalGrantRights(fromID, toID, oldRights, newRights))
232 return SuccessResult(); 232 return SuccessResult();
233 233
234 return FailureResult(); 234 return FailureResult();