diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs | 93 | ||||
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs | 10 |
2 files changed, 33 insertions, 70 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index 61116a7..555fb00 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs | |||
@@ -569,51 +569,30 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
569 | m_log.DebugFormat("[FRIENDS MODULE]: User {0} changing rights to {1} for friend {2}", requester, rights, target); | 569 | m_log.DebugFormat("[FRIENDS MODULE]: User {0} changing rights to {1} for friend {2}", requester, rights, target); |
570 | // Let's find the friend in this user's friend list | 570 | // Let's find the friend in this user's friend list |
571 | UserFriendData fd = m_Friends[remoteClient.AgentId]; | 571 | UserFriendData fd = m_Friends[remoteClient.AgentId]; |
572 | FriendInfo friend = new FriendInfo(); | 572 | FriendInfo friend = null; |
573 | foreach (FriendInfo fi in fd.Friends) | 573 | foreach (FriendInfo fi in fd.Friends) |
574 | if (fi.Friend == target.ToString()) | 574 | if (fi.Friend == target.ToString()) |
575 | friend = fi; | 575 | friend = fi; |
576 | 576 | ||
577 | if (!friend.PrincipalID.Equals(UUID.Zero)) // Found it | 577 | if (friend != null) // Found it |
578 | { | 578 | { |
579 | // Store it on the DB | ||
579 | FriendsService.StoreFriend(requester, target.ToString(), rights); | 580 | FriendsService.StoreFriend(requester, target.ToString(), rights); |
580 | 581 | ||
581 | bool onlineBitChanged = ((rights ^ friend.MyFlags) & (int)FriendRights.CanSeeOnline) == 0; | 582 | // Store it in the local cache |
582 | if (!onlineBitChanged) | 583 | int myFlags = friend.MyFlags; |
583 | { | 584 | friend.MyFlags = rights; |
584 | remoteClient.SendChangeUserRights(requester, target, rights); | ||
585 | } | ||
586 | 585 | ||
587 | // Try local | 586 | // Always send this back to the original client |
588 | if (LocalGrantRights(requester, target, friend.MyFlags, rights)) | 587 | remoteClient.SendChangeUserRights(requester, target, rights); |
589 | return; | ||
590 | 588 | ||
589 | // | ||
590 | // Notify the friend | ||
591 | // | ||
591 | 592 | ||
592 | //int delta = rights ^ friend.MyFlags; | 593 | // Try local |
593 | //if ((delta & ~1) != 0) | 594 | if (LocalGrantRights(requester, target, myFlags, rights)) |
594 | //{ | 595 | return; |
595 | // //remoteClient.SendChangeUserRights(remoteClient.AgentId, target, rights & ~1); | ||
596 | // // | ||
597 | // // Notify the friend | ||
598 | // // | ||
599 | |||
600 | // if (friendClient != null) | ||
601 | // { | ||
602 | // friendClient.SendChangeUserRights(target, remoteClient.AgentId, rights & ~1); | ||
603 | // } | ||
604 | //} | ||
605 | //if ((delta & 1) != 0) | ||
606 | //{ | ||
607 | // if (friendClient != null) | ||
608 | // { | ||
609 | // if ((rights & 1) != 0) | ||
610 | // friendClient.SendAgentOnline(new UUID[] { new UUID(remoteClient.AgentId) }); | ||
611 | // else | ||
612 | // friendClient.SendAgentOffline(new UUID[] { new UUID(remoteClient.AgentId) }); | ||
613 | // } | ||
614 | //} | ||
615 | //if (friendClient != null) // Local, we're done | ||
616 | // return; | ||
617 | 596 | ||
618 | PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { target.ToString() }); | 597 | PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { target.ToString() }); |
619 | PresenceInfo friendSession = PresenceInfo.GetOnlinePresence(friendSessions); | 598 | PresenceInfo friendSession = PresenceInfo.GetOnlinePresence(friendSessions); |
@@ -622,7 +601,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
622 | GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); | 601 | GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); |
623 | // TODO: You might want to send the delta to save the lookup | 602 | // TODO: You might want to send the delta to save the lookup |
624 | // on the other end!! | 603 | // on the other end!! |
625 | m_FriendsSimConnector.GrantRights(region, requester, target); | 604 | m_FriendsSimConnector.GrantRights(region, requester, target, myFlags, rights); |
626 | } | 605 | } |
627 | } | 606 | } |
628 | } | 607 | } |
@@ -693,53 +672,31 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
693 | return false; | 672 | return false; |
694 | } | 673 | } |
695 | 674 | ||
696 | public bool LocalGrantRights(UUID userID, UUID friendID, int myFlags, int rights) | 675 | public bool LocalGrantRights(UUID userID, UUID friendID, int userFlags, int rights) |
697 | { | 676 | { |
698 | m_log.DebugFormat("XXX Trying to locate {0}", friendID); | ||
699 | IClientAPI friendClient = LocateClientObject(friendID); | 677 | IClientAPI friendClient = LocateClientObject(friendID); |
700 | if (friendClient != null) | 678 | if (friendClient != null) |
701 | { | 679 | { |
702 | bool onlineBitChanged = ((rights ^ myFlags) & (int)FriendRights.CanSeeOnline) == 0; | 680 | bool onlineBitChanged = ((rights ^ userFlags) & (int)FriendRights.CanSeeOnline) != 0; |
703 | if (!onlineBitChanged) | 681 | if (onlineBitChanged) |
704 | friendClient.SendChangeUserRights(userID, friendID, rights); | ||
705 | else | ||
706 | { | 682 | { |
707 | if ((rights & (int)FriendRights.CanSeeOnline) == 1) | 683 | if ((rights & (int)FriendRights.CanSeeOnline) == 1) |
708 | friendClient.SendAgentOnline(new UUID[] { new UUID(userID) }); | 684 | friendClient.SendAgentOnline(new UUID[] { new UUID(userID) }); |
709 | else | 685 | else |
710 | friendClient.SendAgentOffline(new UUID[] { new UUID(userID) }); | 686 | friendClient.SendAgentOffline(new UUID[] { new UUID(userID) }); |
711 | } | 687 | } |
688 | else | ||
689 | { | ||
690 | bool canEditObjectsChanged = ((rights ^ userFlags) & (int)FriendRights.CanModifyObjects) != 0; | ||
691 | if (canEditObjectsChanged) | ||
692 | friendClient.SendChangeUserRights(userID, friendID, rights); | ||
693 | } | ||
694 | |||
712 | return true; | 695 | return true; |
713 | } | 696 | } |
714 | 697 | ||
715 | return false; | 698 | return false; |
716 | 699 | ||
717 | //int delta = rights ^ friend.MyFlags; | ||
718 | //if ((delta & ~1) != 0) | ||
719 | //{ | ||
720 | // //remoteClient.SendChangeUserRights(remoteClient.AgentId, target, rights & ~1); | ||
721 | // // | ||
722 | // // Notify the friend | ||
723 | // // | ||
724 | |||
725 | // if (friendClient != null) | ||
726 | // { | ||
727 | // friendClient.SendChangeUserRights(target, remoteClient.AgentId, rights & ~1); | ||
728 | // } | ||
729 | //} | ||
730 | //if ((delta & 1) != 0) | ||
731 | //{ | ||
732 | // if (friendClient != null) | ||
733 | // { | ||
734 | // if ((rights & 1) != 0) | ||
735 | // friendClient.SendAgentOnline(new UUID[] { new UUID(remoteClient.AgentId) }); | ||
736 | // else | ||
737 | // friendClient.SendAgentOffline(new UUID[] { new UUID(remoteClient.AgentId) }); | ||
738 | // } | ||
739 | //} | ||
740 | //if (friendClient != null) // Local, we're done | ||
741 | // return; | ||
742 | |||
743 | } | 700 | } |
744 | 701 | ||
745 | public bool LocalStatusNotification(UUID userID, UUID friendID, bool online) | 702 | public bool LocalStatusNotification(UUID userID, UUID friendID, bool online) |
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs index 140660b..0883c5b 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs | |||
@@ -196,6 +196,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
196 | { | 196 | { |
197 | UUID fromID = UUID.Zero; | 197 | UUID fromID = UUID.Zero; |
198 | UUID toID = UUID.Zero; | 198 | UUID toID = UUID.Zero; |
199 | int rights = 0, userFlags = 0; | ||
199 | 200 | ||
200 | if (!request.ContainsKey("FromID") || !request.ContainsKey("ToID")) | 201 | if (!request.ContainsKey("FromID") || !request.ContainsKey("ToID")) |
201 | return FailureResult(); | 202 | return FailureResult(); |
@@ -206,8 +207,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
206 | if (!UUID.TryParse(request["ToID"].ToString(), out toID)) | 207 | if (!UUID.TryParse(request["ToID"].ToString(), out toID)) |
207 | return FailureResult(); | 208 | return FailureResult(); |
208 | 209 | ||
209 | // !!! | 210 | if (!Int32.TryParse(request["UserFlags"].ToString(), out userFlags)) |
210 | if (m_FriendsModule.LocalGrantRights(UUID.Zero, UUID.Zero, 0, 0)) | 211 | return FailureResult(); |
212 | |||
213 | if (!Int32.TryParse(request["Rights"].ToString(), out rights)) | ||
214 | return FailureResult(); | ||
215 | |||
216 | if (m_FriendsModule.LocalGrantRights(UUID.Zero, UUID.Zero, userFlags, rights)) | ||
211 | return SuccessResult(); | 217 | return SuccessResult(); |
212 | 218 | ||
213 | return FailureResult(); | 219 | return FailureResult(); |