aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDiva Canto2010-03-01 21:32:55 -0800
committerDiva Canto2010-03-01 21:32:55 -0800
commitc6a5ff26fff6a1d0c3ab916a526cf0dd4e4142bc (patch)
tree3dcf44addbc232a86e16c6732aaabe3b76a28c71
parentMore work on GrantRights. Still not right. (diff)
downloadopensim-SC-c6a5ff26fff6a1d0c3ab916a526cf0dd4e4142bc.zip
opensim-SC-c6a5ff26fff6a1d0c3ab916a526cf0dd4e4142bc.tar.gz
opensim-SC-c6a5ff26fff6a1d0c3ab916a526cf0dd4e4142bc.tar.bz2
opensim-SC-c6a5ff26fff6a1d0c3ab916a526cf0dd4e4142bc.tar.xz
Friends rights under control.
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs93
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs10
-rw-r--r--OpenSim/Services/Connectors/Friends/FriendsSimConnector.cs4
-rw-r--r--OpenSim/Services/Interfaces/IFriendsService.cs6
4 files changed, 41 insertions, 72 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();
diff --git a/OpenSim/Services/Connectors/Friends/FriendsSimConnector.cs b/OpenSim/Services/Connectors/Friends/FriendsSimConnector.cs
index 490c8cf..a29ac28 100644
--- a/OpenSim/Services/Connectors/Friends/FriendsSimConnector.cs
+++ b/OpenSim/Services/Connectors/Friends/FriendsSimConnector.cs
@@ -99,7 +99,7 @@ namespace OpenSim.Services.Connectors.Friends
99 return Call(region, sendData); 99 return Call(region, sendData);
100 } 100 }
101 101
102 public bool GrantRights(GridRegion region, UUID userID, UUID friendID) 102 public bool GrantRights(GridRegion region, UUID userID, UUID friendID, int userFlags, int rights)
103 { 103 {
104 Dictionary<string, object> sendData = new Dictionary<string, object>(); 104 Dictionary<string, object> sendData = new Dictionary<string, object>();
105 //sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString(); 105 //sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
@@ -108,6 +108,8 @@ namespace OpenSim.Services.Connectors.Friends
108 108
109 sendData["FromID"] = userID.ToString(); 109 sendData["FromID"] = userID.ToString();
110 sendData["ToID"] = friendID.ToString(); 110 sendData["ToID"] = friendID.ToString();
111 sendData["UserFlags"] = userFlags.ToString();
112 sendData["Rights"] = rights.ToString();
111 113
112 return Call(region, sendData); 114 return Call(region, sendData);
113 } 115 }
diff --git a/OpenSim/Services/Interfaces/IFriendsService.cs b/OpenSim/Services/Interfaces/IFriendsService.cs
index fc20224..2692c48 100644
--- a/OpenSim/Services/Interfaces/IFriendsService.cs
+++ b/OpenSim/Services/Interfaces/IFriendsService.cs
@@ -32,13 +32,17 @@ using System.Collections.Generic;
32 32
33namespace OpenSim.Services.Interfaces 33namespace OpenSim.Services.Interfaces
34{ 34{
35 public struct FriendInfo 35 public class FriendInfo
36 { 36 {
37 public UUID PrincipalID; 37 public UUID PrincipalID;
38 public string Friend; 38 public string Friend;
39 public int MyFlags; 39 public int MyFlags;
40 public int TheirFlags; 40 public int TheirFlags;
41 41
42 public FriendInfo()
43 {
44 }
45
42 public FriendInfo(Dictionary<string, object> kvp) 46 public FriendInfo(Dictionary<string, object> kvp)
43 { 47 {
44 PrincipalID = UUID.Zero; 48 PrincipalID = UUID.Zero;