diff options
author | Diva Canto | 2010-03-01 09:23:33 -0800 |
---|---|---|
committer | Diva Canto | 2010-03-01 09:23:33 -0800 |
commit | cfaf087b89d8d90322a4a86237c246534c26f961 (patch) | |
tree | 9a5929fc47e7f225fecf2e005430ae6703718c1f /OpenSim/Region | |
parent | Fix -1 checks for login case (diff) | |
download | opensim-SC-cfaf087b89d8d90322a4a86237c246534c26f961.zip opensim-SC-cfaf087b89d8d90322a4a86237c246534c26f961.tar.gz opensim-SC-cfaf087b89d8d90322a4a86237c246534c26f961.tar.bz2 opensim-SC-cfaf087b89d8d90322a4a86237c246534c26f961.tar.xz |
More work on GrantRights. Still not right.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs | 141 | ||||
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs | 4 |
2 files changed, 101 insertions, 44 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index 7ec4a9c..61116a7 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs | |||
@@ -566,52 +566,64 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
566 | if (!m_Friends.ContainsKey(remoteClient.AgentId)) | 566 | if (!m_Friends.ContainsKey(remoteClient.AgentId)) |
567 | return; | 567 | return; |
568 | 568 | ||
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 | ||
569 | UserFriendData fd = m_Friends[remoteClient.AgentId]; | 571 | UserFriendData fd = m_Friends[remoteClient.AgentId]; |
570 | 572 | FriendInfo friend = new FriendInfo(); | |
571 | FriendsService.StoreFriend(requester, target.ToString(), rights); | ||
572 | |||
573 | foreach (FriendInfo fi in fd.Friends) | 573 | foreach (FriendInfo fi in fd.Friends) |
574 | { | ||
575 | if (fi.Friend == target.ToString()) | 574 | if (fi.Friend == target.ToString()) |
576 | { | 575 | friend = fi; |
577 | IClientAPI friendClient = LocateClientObject(target); | ||
578 | 576 | ||
579 | int delta = rights ^ fi.MyFlags; | 577 | if (!friend.PrincipalID.Equals(UUID.Zero)) // Found it |
580 | if ((delta & ~1) != 0) | 578 | { |
581 | { | 579 | FriendsService.StoreFriend(requester, target.ToString(), rights); |
582 | remoteClient.SendChangeUserRights(remoteClient.AgentId, target, rights & ~1); | 580 | |
583 | // | 581 | bool onlineBitChanged = ((rights ^ friend.MyFlags) & (int)FriendRights.CanSeeOnline) == 0; |
584 | // Notify the friend | 582 | if (!onlineBitChanged) |
585 | // | 583 | { |
586 | 584 | remoteClient.SendChangeUserRights(requester, target, rights); | |
587 | if (friendClient != null) | ||
588 | { | ||
589 | friendClient.SendChangeUserRights(target, remoteClient.AgentId, rights & ~1); | ||
590 | } | ||
591 | } | ||
592 | if ((delta & 1) != 0) | ||
593 | { | ||
594 | if (friendClient != null) | ||
595 | { | ||
596 | if ((rights & 1) != 0) | ||
597 | friendClient.SendAgentOnline(new UUID[] { new UUID(remoteClient.AgentId) } ); | ||
598 | else | ||
599 | friendClient.SendAgentOffline(new UUID[] { new UUID(remoteClient.AgentId) } ); | ||
600 | } | ||
601 | } | ||
602 | if (friendClient != null) // Local, we're done | ||
603 | return; | ||
604 | } | 585 | } |
605 | } | ||
606 | 586 | ||
607 | PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { target.ToString() }); | 587 | // Try local |
608 | PresenceInfo friendSession = PresenceInfo.GetOnlinePresence(friendSessions); | 588 | if (LocalGrantRights(requester, target, friend.MyFlags, rights)) |
609 | if (friendSession != null) | 589 | return; |
610 | { | 590 | |
611 | GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); | 591 | |
612 | // TODO: You might want to send the delta to save the lookup | 592 | //int delta = rights ^ friend.MyFlags; |
613 | // on the other end!! | 593 | //if ((delta & ~1) != 0) |
614 | m_FriendsSimConnector.GrantRights(region, requester, target); | 594 | //{ |
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 | |||
618 | PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { target.ToString() }); | ||
619 | PresenceInfo friendSession = PresenceInfo.GetOnlinePresence(friendSessions); | ||
620 | if (friendSession != null) | ||
621 | { | ||
622 | GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); | ||
623 | // TODO: You might want to send the delta to save the lookup | ||
624 | // on the other end!! | ||
625 | m_FriendsSimConnector.GrantRights(region, requester, target); | ||
626 | } | ||
615 | } | 627 | } |
616 | } | 628 | } |
617 | 629 | ||
@@ -681,10 +693,53 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
681 | return false; | 693 | return false; |
682 | } | 694 | } |
683 | 695 | ||
684 | public bool LocalGrantRights() | 696 | public bool LocalGrantRights(UUID userID, UUID friendID, int myFlags, int rights) |
685 | { | 697 | { |
686 | // TODO | 698 | m_log.DebugFormat("XXX Trying to locate {0}", friendID); |
687 | return true; | 699 | IClientAPI friendClient = LocateClientObject(friendID); |
700 | if (friendClient != null) | ||
701 | { | ||
702 | bool onlineBitChanged = ((rights ^ myFlags) & (int)FriendRights.CanSeeOnline) == 0; | ||
703 | if (!onlineBitChanged) | ||
704 | friendClient.SendChangeUserRights(userID, friendID, rights); | ||
705 | else | ||
706 | { | ||
707 | if ((rights & (int)FriendRights.CanSeeOnline) == 1) | ||
708 | friendClient.SendAgentOnline(new UUID[] { new UUID(userID) }); | ||
709 | else | ||
710 | friendClient.SendAgentOffline(new UUID[] { new UUID(userID) }); | ||
711 | } | ||
712 | return true; | ||
713 | } | ||
714 | |||
715 | return false; | ||
716 | |||
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 | |||
688 | } | 743 | } |
689 | 744 | ||
690 | public bool LocalStatusNotification(UUID userID, UUID friendID, bool online) | 745 | 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 e7b74a9..140660b 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs | |||
@@ -34,6 +34,7 @@ using System.Xml; | |||
34 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
35 | using OpenSim.Server.Base; | 35 | using OpenSim.Server.Base; |
36 | using OpenSim.Framework.Servers.HttpServer; | 36 | using OpenSim.Framework.Servers.HttpServer; |
37 | using FriendInfo = OpenSim.Services.Interfaces.FriendInfo; | ||
37 | 38 | ||
38 | using OpenMetaverse; | 39 | using OpenMetaverse; |
39 | using log4net; | 40 | using log4net; |
@@ -205,7 +206,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
205 | if (!UUID.TryParse(request["ToID"].ToString(), out toID)) | 206 | if (!UUID.TryParse(request["ToID"].ToString(), out toID)) |
206 | return FailureResult(); | 207 | return FailureResult(); |
207 | 208 | ||
208 | if (m_FriendsModule.LocalGrantRights(/* ??? */)) | 209 | // !!! |
210 | if (m_FriendsModule.LocalGrantRights(UUID.Zero, UUID.Zero, 0, 0)) | ||
209 | return SuccessResult(); | 211 | return SuccessResult(); |
210 | 212 | ||
211 | return FailureResult(); | 213 | return FailureResult(); |