diff options
author | onefang | 2019-09-11 16:36:50 +1000 |
---|---|---|
committer | onefang | 2019-09-11 16:36:50 +1000 |
commit | 50cd1ffd32f69228e566f2b0b89f86ea0d9fe489 (patch) | |
tree | 52f2ab0c04f1a5d7d6ac5dc872981b4b156447e7 /OpenSim/Region/CoreModules/Avatar/Friends | |
parent | Renamed branch to SledjChisl. (diff) | |
parent | Bump to release flavour, build 0. (diff) | |
download | opensim-SC_OLD-50cd1ffd32f69228e566f2b0b89f86ea0d9fe489.zip opensim-SC_OLD-50cd1ffd32f69228e566f2b0b89f86ea0d9fe489.tar.gz opensim-SC_OLD-50cd1ffd32f69228e566f2b0b89f86ea0d9fe489.tar.bz2 opensim-SC_OLD-50cd1ffd32f69228e566f2b0b89f86ea0d9fe489.tar.xz |
Merge branch 'SledjChisl'
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/Friends')
6 files changed, 185 insertions, 68 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/CallingCardModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/CallingCardModule.cs index eb23e83..4a55a7e 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/CallingCardModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/CallingCardModule.cs | |||
@@ -118,7 +118,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
118 | // If we're in god mode, we reverse the meaning. Offer | 118 | // If we're in god mode, we reverse the meaning. Offer |
119 | // calling card becomes "Take a calling card" for that | 119 | // calling card becomes "Take a calling card" for that |
120 | // person, no matter if they agree or not. | 120 | // person, no matter if they agree or not. |
121 | if (sp.GodLevel >= 200) | 121 | if (sp.IsViewerUIGod) |
122 | { | 122 | { |
123 | CreateCallingCard(client.AgentId, destID, UUID.Zero, true); | 123 | CreateCallingCard(client.AgentId, destID, UUID.Zero, true); |
124 | return; | 124 | return; |
@@ -239,8 +239,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
239 | InventoryFolderBase trashFolder = | 239 | InventoryFolderBase trashFolder = |
240 | invService.GetFolderForType(client.AgentId, FolderType.Trash); | 240 | invService.GetFolderForType(client.AgentId, FolderType.Trash); |
241 | 241 | ||
242 | InventoryItemBase item = new InventoryItemBase(transactionID, client.AgentId); | 242 | InventoryItemBase item = invService.GetItem(client.AgentId, transactionID); |
243 | item = invService.GetItem(item); | ||
244 | 243 | ||
245 | if (item != null && trashFolder != null) | 244 | if (item != null && trashFolder != null) |
246 | { | 245 | { |
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index 08e7dd2..772485c 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs | |||
@@ -167,7 +167,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
167 | m_Enabled = true; | 167 | m_Enabled = true; |
168 | m_log.DebugFormat("[FRIENDS MODULE]: {0} enabled.", Name); | 168 | m_log.DebugFormat("[FRIENDS MODULE]: {0} enabled.", Name); |
169 | } | 169 | } |
170 | } | 170 | } |
171 | } | 171 | } |
172 | 172 | ||
173 | protected virtual void InitModule(IConfigSource config) | 173 | protected virtual void InitModule(IConfigSource config) |
@@ -247,14 +247,30 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
247 | { | 247 | { |
248 | FriendInfo[] friends = GetFriendsFromCache(principalID); | 248 | FriendInfo[] friends = GetFriendsFromCache(principalID); |
249 | FriendInfo finfo = GetFriend(friends, friendID); | 249 | FriendInfo finfo = GetFriend(friends, friendID); |
250 | if (finfo != null) | 250 | if (finfo != null && finfo.TheirFlags != -1) |
251 | { | 251 | { |
252 | return finfo.TheirFlags; | 252 | return finfo.TheirFlags; |
253 | } | 253 | } |
254 | |||
255 | return 0; | 254 | return 0; |
256 | } | 255 | } |
257 | 256 | ||
257 | private void OnMakeRootAgent(ScenePresence sp) | ||
258 | { | ||
259 | if(sp.gotCrossUpdate) | ||
260 | return; | ||
261 | |||
262 | RecacheFriends(sp.ControllingClient); | ||
263 | |||
264 | lock (m_NeedsToNotifyStatus) | ||
265 | { | ||
266 | if (m_NeedsToNotifyStatus.Remove(sp.UUID)) | ||
267 | { | ||
268 | // Inform the friends that this user is online. This can only be done once the client is a Root Agent. | ||
269 | StatusChange(sp.UUID, true); | ||
270 | } | ||
271 | } | ||
272 | } | ||
273 | |||
258 | private void OnNewClient(IClientAPI client) | 274 | private void OnNewClient(IClientAPI client) |
259 | { | 275 | { |
260 | client.OnInstantMessage += OnInstantMessage; | 276 | client.OnInstantMessage += OnInstantMessage; |
@@ -262,6 +278,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
262 | client.OnDenyFriendRequest += OnDenyFriendRequest; | 278 | client.OnDenyFriendRequest += OnDenyFriendRequest; |
263 | client.OnTerminateFriendship += RemoveFriendship; | 279 | client.OnTerminateFriendship += RemoveFriendship; |
264 | client.OnGrantUserRights += GrantRights; | 280 | client.OnGrantUserRights += GrantRights; |
281 | client.OnFindAgent += FindFriend; | ||
265 | 282 | ||
266 | // We need to cache information for child agents as well as root agents so that friend edit/move/delete | 283 | // 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. | 284 | // permissions will work across borders where both regions are on different simulators. |
@@ -326,20 +343,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
326 | } | 343 | } |
327 | } | 344 | } |
328 | 345 | ||
329 | private void OnMakeRootAgent(ScenePresence sp) | ||
330 | { | ||
331 | RecacheFriends(sp.ControllingClient); | ||
332 | |||
333 | lock (m_NeedsToNotifyStatus) | ||
334 | { | ||
335 | if (m_NeedsToNotifyStatus.Remove(sp.UUID)) | ||
336 | { | ||
337 | // Inform the friends that this user is online. This can only be done once the client is a Root Agent. | ||
338 | StatusChange(sp.UUID, true); | ||
339 | } | ||
340 | } | ||
341 | } | ||
342 | |||
343 | private void OnClientLogin(IClientAPI client) | 346 | private void OnClientLogin(IClientAPI client) |
344 | { | 347 | { |
345 | UUID agentID = client.AgentId; | 348 | UUID agentID = client.AgentId; |
@@ -358,8 +361,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
358 | m_NeedsListOfOnlineFriends.Add(agentID); | 361 | m_NeedsListOfOnlineFriends.Add(agentID); |
359 | } | 362 | } |
360 | 363 | ||
364 | public void IsNowRoot(ScenePresence sp) | ||
365 | { | ||
366 | OnMakeRootAgent(sp); | ||
367 | } | ||
368 | |||
361 | public virtual bool SendFriendsOnlineIfNeeded(IClientAPI client) | 369 | public virtual bool SendFriendsOnlineIfNeeded(IClientAPI client) |
362 | { | 370 | { |
371 | if (client == null) | ||
372 | return false; | ||
373 | |||
363 | UUID agentID = client.AgentId; | 374 | UUID agentID = client.AgentId; |
364 | 375 | ||
365 | // Check if the online friends list is needed | 376 | // Check if the online friends list is needed |
@@ -500,18 +511,20 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
500 | if (((fi.MyFlags & (int)FriendRights.CanSeeOnline) != 0) && (fi.TheirFlags != -1)) | 511 | if (((fi.MyFlags & (int)FriendRights.CanSeeOnline) != 0) && (fi.TheirFlags != -1)) |
501 | friendList.Add(fi); | 512 | friendList.Add(fi); |
502 | } | 513 | } |
503 | 514 | if(friendList.Count > 0) | |
504 | Util.FireAndForget( | 515 | { |
505 | delegate | 516 | Util.FireAndForget( |
506 | { | 517 | delegate |
507 | // m_log.DebugFormat( | 518 | { |
508 | // "[FRIENDS MODULE]: Notifying {0} friends of {1} of online status {2}", | 519 | // m_log.DebugFormat( |
509 | // friendList.Count, agentID, online); | 520 | // "[FRIENDS MODULE]: Notifying {0} friends of {1} of online status {2}", |
510 | 521 | // friendList.Count, agentID, online); | |
511 | // Notify about this user status | 522 | |
512 | StatusNotify(friendList, agentID, online); | 523 | // Notify about this user status |
513 | }, null, "FriendsModule.StatusChange" | 524 | StatusNotify(friendList, agentID, online); |
514 | ); | 525 | }, null, "FriendsModule.StatusChange" |
526 | ); | ||
527 | } | ||
515 | } | 528 | } |
516 | } | 529 | } |
517 | 530 | ||
@@ -540,6 +553,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
540 | // We do this regrouping so that we can efficiently send a single request rather than one for each | 553 | // We do this regrouping so that we can efficiently send a single request rather than one for each |
541 | // friend in what may be a very large friends list. | 554 | // friend in what may be a very large friends list. |
542 | PresenceInfo[] friendSessions = PresenceService.GetAgents(remoteFriendStringIds.ToArray()); | 555 | PresenceInfo[] friendSessions = PresenceService.GetAgents(remoteFriendStringIds.ToArray()); |
556 | if(friendSessions == null) | ||
557 | return; | ||
543 | 558 | ||
544 | foreach (PresenceInfo friendSession in friendSessions) | 559 | foreach (PresenceInfo friendSession in friendSessions) |
545 | { | 560 | { |
@@ -561,7 +576,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
561 | protected virtual void OnInstantMessage(IClientAPI client, GridInstantMessage im) | 576 | protected virtual void OnInstantMessage(IClientAPI client, GridInstantMessage im) |
562 | { | 577 | { |
563 | if ((InstantMessageDialog)im.dialog == InstantMessageDialog.FriendshipOffered) | 578 | if ((InstantMessageDialog)im.dialog == InstantMessageDialog.FriendshipOffered) |
564 | { | 579 | { |
565 | // we got a friendship offer | 580 | // we got a friendship offer |
566 | UUID principalID = new UUID(im.fromAgentID); | 581 | UUID principalID = new UUID(im.fromAgentID); |
567 | UUID friendID = new UUID(im.toAgentID); | 582 | UUID friendID = new UUID(im.toAgentID); |
@@ -596,7 +611,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
596 | im.imSessionID = im.fromAgentID; | 611 | im.imSessionID = im.fromAgentID; |
597 | im.fromAgentName = GetFriendshipRequesterName(agentID); | 612 | im.fromAgentName = GetFriendshipRequesterName(agentID); |
598 | 613 | ||
599 | // Try the local sim | 614 | // Try the local sim |
600 | if (LocalFriendshipOffered(friendID, im)) | 615 | if (LocalFriendshipOffered(friendID, im)) |
601 | return true; | 616 | return true; |
602 | 617 | ||
@@ -639,7 +654,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
639 | ccm.CreateCallingCard(client.AgentId, friendID, UUID.Zero); | 654 | ccm.CreateCallingCard(client.AgentId, friendID, UUID.Zero); |
640 | } | 655 | } |
641 | 656 | ||
642 | // Update the local cache. | 657 | // Update the local cache. |
643 | RecacheFriends(client); | 658 | RecacheFriends(client); |
644 | 659 | ||
645 | // | 660 | // |
@@ -695,7 +710,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
695 | } | 710 | } |
696 | } | 711 | } |
697 | } | 712 | } |
698 | 713 | ||
699 | public void RemoveFriendship(IClientAPI client, UUID exfriendID) | 714 | public void RemoveFriendship(IClientAPI client, UUID exfriendID) |
700 | { | 715 | { |
701 | if (!DeleteFriendship(client.AgentId, exfriendID)) | 716 | if (!DeleteFriendship(client.AgentId, exfriendID)) |
@@ -723,7 +738,65 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
723 | GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); | 738 | GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); |
724 | m_FriendsSimConnector.FriendshipTerminated(region, client.AgentId, exfriendID); | 739 | m_FriendsSimConnector.FriendshipTerminated(region, client.AgentId, exfriendID); |
725 | } | 740 | } |
726 | } | 741 | } |
742 | } | ||
743 | |||
744 | public void FindFriend(IClientAPI remoteClient,UUID HunterID ,UUID PreyID) | ||
745 | { | ||
746 | UUID requester = remoteClient.AgentId; | ||
747 | if(requester != HunterID) // only allow client agent to be the hunter (?) | ||
748 | return; | ||
749 | |||
750 | FriendInfo[] friends = GetFriendsFromCache(requester); | ||
751 | if (friends.Length == 0) | ||
752 | return; | ||
753 | |||
754 | FriendInfo friend = GetFriend(friends, PreyID); | ||
755 | if (friend == null) | ||
756 | return; | ||
757 | |||
758 | if(friend.TheirFlags == -1 || (friend.TheirFlags & (int)FriendRights.CanSeeOnMap) == 0) | ||
759 | return; | ||
760 | |||
761 | Scene hunterScene = (Scene)remoteClient.Scene; | ||
762 | |||
763 | if(hunterScene == null) | ||
764 | return; | ||
765 | |||
766 | // check local | ||
767 | ScenePresence sp; | ||
768 | double px; | ||
769 | double py; | ||
770 | if(hunterScene.TryGetScenePresence(PreyID, out sp)) | ||
771 | { | ||
772 | if(sp == null) | ||
773 | return; | ||
774 | px = hunterScene.RegionInfo.WorldLocX + sp.AbsolutePosition.X; | ||
775 | py = hunterScene.RegionInfo.WorldLocY + sp.AbsolutePosition.Y; | ||
776 | |||
777 | remoteClient.SendFindAgent(HunterID, PreyID, px, py); | ||
778 | return; | ||
779 | } | ||
780 | |||
781 | PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { PreyID.ToString() }); | ||
782 | |||
783 | if (friendSessions == null || friendSessions.Length == 0) | ||
784 | return; | ||
785 | |||
786 | PresenceInfo friendSession = friendSessions[0]; | ||
787 | if (friendSession == null) | ||
788 | return; | ||
789 | |||
790 | GridRegion region = GridService.GetRegionByUUID(hunterScene.RegionInfo.ScopeID, friendSession.RegionID); | ||
791 | |||
792 | if(region == null) | ||
793 | return; | ||
794 | |||
795 | // we don't have presence location so point to a standard region center for now | ||
796 | px = region.RegionLocX + 128.0; | ||
797 | py = region.RegionLocY + 128.0; | ||
798 | |||
799 | remoteClient.SendFindAgent(HunterID, PreyID, px, py); | ||
727 | } | 800 | } |
728 | 801 | ||
729 | public void GrantRights(IClientAPI remoteClient, UUID friendID, int rights) | 802 | public void GrantRights(IClientAPI remoteClient, UUID friendID, int rights) |
@@ -745,7 +818,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
745 | 818 | ||
746 | if (friend != null) // Found it | 819 | if (friend != null) // Found it |
747 | { | 820 | { |
748 | // Store it on the DB | 821 | // Store it on service |
749 | if (!StoreRights(requester, friendID, rights)) | 822 | if (!StoreRights(requester, friendID, rights)) |
750 | { | 823 | { |
751 | remoteClient.SendAlertMessage("Unable to grant rights."); | 824 | remoteClient.SendAlertMessage("Unable to grant rights."); |
@@ -869,28 +942,26 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
869 | return false; | 942 | return false; |
870 | } | 943 | } |
871 | 944 | ||
872 | public bool LocalGrantRights(UUID userID, UUID friendID, int userFlags, int rights) | 945 | public bool LocalGrantRights(UUID userID, UUID friendID, int oldRights, int newRights) |
873 | { | 946 | { |
874 | IClientAPI friendClient = LocateClientObject(friendID); | 947 | IClientAPI friendClient = LocateClientObject(friendID); |
875 | if (friendClient != null) | 948 | if (friendClient != null) |
876 | { | 949 | { |
877 | bool onlineBitChanged = ((rights ^ userFlags) & (int)FriendRights.CanSeeOnline) != 0; | 950 | int changedRights = newRights ^ oldRights; |
951 | bool onlineBitChanged = (changedRights & (int)FriendRights.CanSeeOnline) != 0; | ||
878 | if (onlineBitChanged) | 952 | if (onlineBitChanged) |
879 | { | 953 | { |
880 | if ((rights & (int)FriendRights.CanSeeOnline) == 1) | 954 | if ((newRights & (int)FriendRights.CanSeeOnline) == 1) |
881 | friendClient.SendAgentOnline(new UUID[] { userID }); | 955 | friendClient.SendAgentOnline(new UUID[] { userID }); |
882 | else | 956 | else |
883 | friendClient.SendAgentOffline(new UUID[] { userID }); | 957 | friendClient.SendAgentOffline(new UUID[] { userID }); |
884 | } | 958 | } |
885 | else | 959 | |
886 | { | 960 | if(changedRights != 0) |
887 | bool canEditObjectsChanged = ((rights ^ userFlags) & (int)FriendRights.CanModifyObjects) != 0; | 961 | friendClient.SendChangeUserRights(userID, friendID, newRights); |
888 | if (canEditObjectsChanged) | ||
889 | friendClient.SendChangeUserRights(userID, friendID, rights); | ||
890 | } | ||
891 | 962 | ||
892 | // Update local cache | 963 | // Update local cache |
893 | UpdateLocalCache(userID, friendID, rights); | 964 | UpdateLocalCache(userID, friendID, newRights); |
894 | 965 | ||
895 | return true; | 966 | return true; |
896 | } | 967 | } |
@@ -946,8 +1017,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
946 | lock (m_Friends) | 1017 | lock (m_Friends) |
947 | { | 1018 | { |
948 | FriendInfo[] friends = GetFriendsFromCache(friendID); | 1019 | FriendInfo[] friends = GetFriendsFromCache(friendID); |
949 | FriendInfo finfo = GetFriend(friends, userID); | 1020 | if(friends != EMPTY_FRIENDS) |
950 | finfo.TheirFlags = rights; | 1021 | { |
1022 | FriendInfo finfo = GetFriend(friends, userID); | ||
1023 | if(finfo!= null) | ||
1024 | finfo.TheirFlags = rights; | ||
1025 | } | ||
951 | } | 1026 | } |
952 | } | 1027 | } |
953 | 1028 | ||
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs index 13512a2..091b197 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs | |||
@@ -65,9 +65,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
65 | protected override byte[] ProcessRequest( | 65 | protected override byte[] ProcessRequest( |
66 | string path, Stream requestData, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | 66 | string path, Stream requestData, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) |
67 | { | 67 | { |
68 | StreamReader sr = new StreamReader(requestData); | 68 | string body; |
69 | string body = sr.ReadToEnd(); | 69 | using(StreamReader sr = new StreamReader(requestData)) |
70 | sr.Close(); | 70 | body = sr.ReadToEnd(); |
71 | |||
71 | body = body.Trim(); | 72 | body = body.Trim(); |
72 | 73 | ||
73 | //m_log.DebugFormat("[XXX]: query String: {0}", body); | 74 | //m_log.DebugFormat("[XXX]: query String: {0}", body); |
@@ -127,7 +128,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
127 | UserAccount account = m_FriendsModule.UserAccountService.GetUserAccount(UUID.Zero, fromID); | 128 | UserAccount account = m_FriendsModule.UserAccountService.GetUserAccount(UUID.Zero, fromID); |
128 | string name = (account == null) ? "Unknown" : account.FirstName + " " + account.LastName; | 129 | string name = (account == null) ? "Unknown" : account.FirstName + " " + account.LastName; |
129 | 130 | ||
130 | GridInstantMessage im = new GridInstantMessage(m_FriendsModule.Scene, fromID, name, toID, | 131 | GridInstantMessage im = new GridInstantMessage(m_FriendsModule.Scene, fromID, name, toID, |
131 | (byte)InstantMessageDialog.FriendshipOffered, message, false, Vector3.Zero); | 132 | (byte)InstantMessageDialog.FriendshipOffered, message, false, Vector3.Zero); |
132 | 133 | ||
133 | // !! HACK | 134 | // !! HACK |
@@ -211,7 +212,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
211 | { | 212 | { |
212 | UUID fromID = UUID.Zero; | 213 | UUID fromID = UUID.Zero; |
213 | UUID toID = UUID.Zero; | 214 | UUID toID = UUID.Zero; |
214 | int rights = 0, userFlags = 0; | 215 | int oldRights = 0, newRights = 0; |
215 | 216 | ||
216 | if (!request.ContainsKey("FromID") || !request.ContainsKey("ToID")) | 217 | if (!request.ContainsKey("FromID") || !request.ContainsKey("ToID")) |
217 | return FailureResult(); | 218 | return FailureResult(); |
@@ -222,13 +223,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
222 | if (!UUID.TryParse(request["ToID"].ToString(), out toID)) | 223 | if (!UUID.TryParse(request["ToID"].ToString(), out toID)) |
223 | return FailureResult(); | 224 | return FailureResult(); |
224 | 225 | ||
225 | if (!Int32.TryParse(request["UserFlags"].ToString(), out userFlags)) | 226 | if (!Int32.TryParse(request["UserFlags"].ToString(), out oldRights)) |
226 | return FailureResult(); | 227 | return FailureResult(); |
227 | 228 | ||
228 | if (!Int32.TryParse(request["Rights"].ToString(), out rights)) | 229 | if (!Int32.TryParse(request["Rights"].ToString(), out newRights)) |
229 | return FailureResult(); | 230 | return FailureResult(); |
230 | 231 | ||
231 | if (m_FriendsModule.LocalGrantRights(UUID.Zero, UUID.Zero, userFlags, rights)) | 232 | if (m_FriendsModule.LocalGrantRights(fromID, toID, oldRights, newRights)) |
232 | return SuccessResult(); | 233 | return SuccessResult(); |
233 | 234 | ||
234 | return FailureResult(); | 235 | return FailureResult(); |
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs index 27b7376..fae1e05 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs | |||
@@ -141,7 +141,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
141 | if (avatar == null) | 141 | if (avatar == null) |
142 | return; | 142 | return; |
143 | 143 | ||
144 | if (avatar.UserLevel < m_levelHGFriends) | 144 | if (avatar.GodController.UserLevel < m_levelHGFriends) |
145 | { | 145 | { |
146 | client.SendAgentAlertMessage("Unable to send friendship invitation to foreigner. Insufficient permissions.", false); | 146 | client.SendAgentAlertMessage("Unable to send friendship invitation to foreigner. Insufficient permissions.", false); |
147 | return; | 147 | return; |
@@ -214,7 +214,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
214 | FriendInfo[] friends = GetFriendsFromCache(client.AgentId); | 214 | FriendInfo[] friends = GetFriendsFromCache(client.AgentId); |
215 | foreach (FriendInfo f in friends) | 215 | foreach (FriendInfo f in friends) |
216 | { | 216 | { |
217 | client.SendChangeUserRights(new UUID(f.Friend), client.AgentId, f.TheirFlags); | 217 | int rights = f.TheirFlags; |
218 | if(rights != -1 ) | ||
219 | client.SendChangeUserRights(new UUID(f.Friend), client.AgentId, rights); | ||
218 | } | 220 | } |
219 | } | 221 | } |
220 | } | 222 | } |
@@ -337,7 +339,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
337 | if (UUID.TryParse(friendID, out id)) | 339 | if (UUID.TryParse(friendID, out id)) |
338 | return base.FriendshipMessage(friendID); | 340 | return base.FriendshipMessage(friendID); |
339 | 341 | ||
340 | return "Please confirm this friendship you made while you were away."; | 342 | return "Please confirm this friendship you made while you where on another HG grid"; |
341 | } | 343 | } |
342 | 344 | ||
343 | protected override FriendInfo GetFriend(FriendInfo[] friends, UUID friendID) | 345 | protected override FriendInfo GetFriend(FriendInfo[] friends, UUID friendID) |
@@ -456,6 +458,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
456 | { | 458 | { |
457 | // local grid users | 459 | // local grid users |
458 | m_log.DebugFormat("[HGFRIENDS MODULE]: Users are both local"); | 460 | m_log.DebugFormat("[HGFRIENDS MODULE]: Users are both local"); |
461 | DeletePreviousHGRelations(agentID, friendID); | ||
459 | base.StoreFriendships(agentID, friendID); | 462 | base.StoreFriendships(agentID, friendID); |
460 | return; | 463 | return; |
461 | } | 464 | } |
@@ -538,8 +541,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
538 | // m_log.DebugFormat("[HGFRIENDS MODULE] HG Friendship! thisUUI={0}; friendUUI={1}; foreignThisFriendService={2}; foreignFriendFriendService={3}", | 541 | // m_log.DebugFormat("[HGFRIENDS MODULE] HG Friendship! thisUUI={0}; friendUUI={1}; foreignThisFriendService={2}; foreignFriendFriendService={3}", |
539 | // agentUUI, friendUUI, agentFriendService, friendFriendService); | 542 | // agentUUI, friendUUI, agentFriendService, friendFriendService); |
540 | 543 | ||
541 | } | 544 | } |
542 | 545 | ||
543 | // Delete any previous friendship relations | 546 | // Delete any previous friendship relations |
544 | DeletePreviousRelations(agentID, friendID); | 547 | DeletePreviousRelations(agentID, friendID); |
545 | 548 | ||
@@ -624,6 +627,45 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
624 | } | 627 | } |
625 | } | 628 | } |
626 | 629 | ||
630 | private void DeletePreviousHGRelations(UUID a1, UUID a2) | ||
631 | { | ||
632 | // Delete any previous friendship relations | ||
633 | FriendInfo[] finfos = null; | ||
634 | finfos = GetFriendsFromCache(a1); | ||
635 | if (finfos != null) | ||
636 | { | ||
637 | foreach (FriendInfo f in finfos) | ||
638 | { | ||
639 | if (f.TheirFlags == -1) | ||
640 | { | ||
641 | if (f.Friend.StartsWith(a2.ToString())) | ||
642 | { | ||
643 | FriendsService.Delete(a1, f.Friend); | ||
644 | // and also the converse | ||
645 | FriendsService.Delete(f.Friend, a1.ToString()); | ||
646 | } | ||
647 | } | ||
648 | } | ||
649 | } | ||
650 | |||
651 | finfos = GetFriendsFromCache(a1); | ||
652 | if (finfos != null) | ||
653 | { | ||
654 | foreach (FriendInfo f in finfos) | ||
655 | { | ||
656 | if (f.TheirFlags == -1) | ||
657 | { | ||
658 | if (f.Friend.StartsWith(a1.ToString())) | ||
659 | { | ||
660 | FriendsService.Delete(a2, f.Friend); | ||
661 | // and also the converse | ||
662 | FriendsService.Delete(f.Friend, a2.ToString()); | ||
663 | } | ||
664 | } | ||
665 | } | ||
666 | } | ||
667 | } | ||
668 | |||
627 | protected override bool DeleteFriendship(UUID agentID, UUID exfriendID) | 669 | protected override bool DeleteFriendship(UUID agentID, UUID exfriendID) |
628 | { | 670 | { |
629 | Boolean agentIsLocal = true; | 671 | Boolean agentIsLocal = true; |
@@ -743,7 +785,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
743 | m_log.DebugFormat("[HGFRIENDS MODULE]: Forwading friendship from {0} to {1} @ {2}", agentID, friendID, friendsURL); | 785 | m_log.DebugFormat("[HGFRIENDS MODULE]: Forwading friendship from {0} to {1} @ {2}", agentID, friendID, friendsURL); |
744 | GridRegion region = new GridRegion(); | 786 | GridRegion region = new GridRegion(); |
745 | region.ServerURI = friendsURL; | 787 | region.ServerURI = friendsURL; |
746 | 788 | ||
747 | string name = im.fromAgentName; | 789 | string name = im.fromAgentName; |
748 | if (m_uMan.IsLocalGridUser(agentID)) | 790 | if (m_uMan.IsLocalGridUser(agentID)) |
749 | { | 791 | { |
@@ -775,7 +817,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
775 | } | 817 | } |
776 | 818 | ||
777 | m_HGFriendsConnector.FriendshipOffered(region, agentID, friendID, im.message, name); | 819 | m_HGFriendsConnector.FriendshipOffered(region, agentID, friendID, im.message, name); |
778 | 820 | ||
779 | return true; | 821 | return true; |
780 | } | 822 | } |
781 | } | 823 | } |
@@ -804,4 +846,4 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
804 | return false; | 846 | return false; |
805 | } | 847 | } |
806 | } | 848 | } |
807 | } \ No newline at end of file | 849 | } |
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/HGStatusNotifier.cs b/OpenSim/Region/CoreModules/Avatar/Friends/HGStatusNotifier.cs index 1fa4dd6..3fae271 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/HGStatusNotifier.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/HGStatusNotifier.cs | |||
@@ -32,7 +32,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
32 | { | 32 | { |
33 | if (kvp.Key != "local") | 33 | if (kvp.Key != "local") |
34 | { | 34 | { |
35 | // For the others, call the user agent service | 35 | // For the others, call the user agent service |
36 | List<string> ids = new List<string>(); | 36 | List<string> ids = new List<string>(); |
37 | foreach (FriendInfo f in kvp.Value) | 37 | foreach (FriendInfo f in kvp.Value) |
38 | ids.Add(f.Friend); | 38 | ids.Add(f.Friend); |
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/Tests/FriendModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Friends/Tests/FriendModuleTests.cs index e6fd54e..3d9bd35 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/Tests/FriendModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/Tests/FriendModuleTests.cs | |||
@@ -67,7 +67,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends.Tests | |||
67 | // so that different services and simulator can share the data in standalone mode. This is pretty horrible | 67 | // so that different services and simulator can share the data in standalone mode. This is pretty horrible |
68 | // effectively the statics are global variables. | 68 | // effectively the statics are global variables. |
69 | NullFriendsData.Clear(); | 69 | NullFriendsData.Clear(); |
70 | 70 | ||
71 | IConfigSource config = new IniConfigSource(); | 71 | IConfigSource config = new IniConfigSource(); |
72 | config.AddConfig("Modules"); | 72 | config.AddConfig("Modules"); |
73 | // Not strictly necessary since FriendsModule assumes it is the default (!) | 73 | // Not strictly necessary since FriendsModule assumes it is the default (!) |