aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorDiva Canto2011-05-21 16:48:00 -0700
committerDiva Canto2011-05-21 16:48:00 -0700
commit58c53c41de2cae0bb041a2e8121792e136d1edb2 (patch)
treeb792158cd178f88234f86ab4d72c4224b45fe6ba /OpenSim/Region
parentMerge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff)
downloadopensim-SC_OLD-58c53c41de2cae0bb041a2e8121792e136d1edb2.zip
opensim-SC_OLD-58c53c41de2cae0bb041a2e8121792e136d1edb2.tar.gz
opensim-SC_OLD-58c53c41de2cae0bb041a2e8121792e136d1edb2.tar.bz2
opensim-SC_OLD-58c53c41de2cae0bb041a2e8121792e136d1edb2.tar.xz
Fixed permissions bug related to friends in PermissionsModule. Added FriendsData[] GetFriends(string principalID) to IFriendsData and FriendInfo[] GetFriends(string PrincipalID) to IFriendsService. Refactored some more in the FriendsModule. Made client get notification of local friends permissions upon HGLogin. HG Friends object permissions work.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs103
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs259
-rw-r--r--OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs41
-rw-r--r--OpenSim/Region/Framework/Interfaces/IFriendsModule.cs2
4 files changed, 181 insertions, 224 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
index 21cd924..4879d20 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
@@ -69,7 +69,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
69 } 69 }
70 } 70 }
71 71
72 private static readonly FriendInfo[] EMPTY_FRIENDS = new FriendInfo[0]; 72 protected static readonly FriendInfo[] EMPTY_FRIENDS = new FriendInfo[0];
73 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 73 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
74 74
75 protected List<Scene> m_Scenes = new List<Scene>(); 75 protected List<Scene> m_Scenes = new List<Scene>();
@@ -187,6 +187,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
187 { 187 {
188 if (!m_Enabled) 188 if (!m_Enabled)
189 return; 189 return;
190 m_log.DebugFormat("[FRIENDS MODULE]: AddRegion on {0}", Name);
190 191
191 m_Scenes.Add(scene); 192 m_Scenes.Add(scene);
192 scene.RegisterModuleInterface<IFriendsModule>(this); 193 scene.RegisterModuleInterface<IFriendsModule>(this);
@@ -221,13 +222,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
221 222
222 #endregion 223 #endregion
223 224
224 public uint GetFriendPerms(UUID principalID, UUID friendID) 225 public virtual uint GetFriendPerms(UUID principalID, UUID friendID)
225 { 226 {
226 FriendInfo[] friends = GetFriends(principalID); 227 FriendInfo[] friends = GetFriends(principalID);
227 foreach (FriendInfo fi in friends) 228 FriendInfo finfo = GetFriend(friends, friendID);
229 if (finfo != null)
228 { 230 {
229 if (fi.Friend == friendID.ToString()) 231 return (uint)finfo.TheirFlags;
230 return (uint)fi.TheirFlags;
231 } 232 }
232 233
233 return 0; 234 return 0;
@@ -241,14 +242,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
241 client.OnTerminateFriendship += OnTerminateFriendship; 242 client.OnTerminateFriendship += OnTerminateFriendship;
242 client.OnGrantUserRights += OnGrantUserRights; 243 client.OnGrantUserRights += OnGrantUserRights;
243 244
244 Util.FireAndForget(delegate { FetchFriendslist(client.AgentId); }); 245 Util.FireAndForget(delegate { FetchFriendslist(client); });
245 } 246 }
246 247
247 /// Fetch the friends list or increment the refcount for the existing 248 /// Fetch the friends list or increment the refcount for the existing
248 /// friends list 249 /// friends list
249 /// Returns true if the list was fetched, false if it wasn't 250 /// Returns true if the list was fetched, false if it wasn't
250 protected virtual bool FetchFriendslist(UUID agentID) 251 protected virtual bool FetchFriendslist(IClientAPI client)
251 { 252 {
253 UUID agentID = client.AgentId;
252 lock (m_Friends) 254 lock (m_Friends)
253 { 255 {
254 UserFriendData friendsData; 256 UserFriendData friendsData;
@@ -261,7 +263,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
261 { 263 {
262 friendsData = new UserFriendData(); 264 friendsData = new UserFriendData();
263 friendsData.PrincipalID = agentID; 265 friendsData.PrincipalID = agentID;
264 friendsData.Friends = FriendsService.GetFriends(agentID); 266 friendsData.Friends = GetFriendsFromService(client);
265 friendsData.Refcount = 1; 267 friendsData.Refcount = 1;
266 268
267 m_Friends[agentID] = friendsData; 269 m_Friends[agentID] = friendsData;
@@ -270,6 +272,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
270 } 272 }
271 } 273 }
272 274
275 protected virtual FriendInfo[] GetFriendsFromService(IClientAPI client)
276 {
277 return FriendsService.GetFriends(client.AgentId);
278 }
279
273 private void OnClientClosed(UUID agentID, Scene scene) 280 private void OnClientClosed(UUID agentID, Scene scene)
274 { 281 {
275 ScenePresence sp = scene.GetScenePresence(agentID); 282 ScenePresence sp = scene.GetScenePresence(agentID);
@@ -293,8 +300,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
293 300
294 private void OnMakeRootAgent(ScenePresence sp) 301 private void OnMakeRootAgent(ScenePresence sp)
295 { 302 {
296 UUID agentID = sp.ControllingClient.AgentId; 303 UpdateFriendsCache(sp.ControllingClient);
297 UpdateFriendsCache(agentID);
298 } 304 }
299 305
300 private void OnClientLogin(IClientAPI client) 306 private void OnClientLogin(IClientAPI client)
@@ -309,7 +315,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
309 m_NeedsListOfFriends.Add(agentID); 315 m_NeedsListOfFriends.Add(agentID);
310 } 316 }
311 317
312 public void SendFriendsOnlineIfNeeded(IClientAPI client) 318 public virtual bool SendFriendsOnlineIfNeeded(IClientAPI client)
313 { 319 {
314 UUID agentID = client.AgentId; 320 UUID agentID = client.AgentId;
315 321
@@ -317,7 +323,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
317 lock (m_NeedsListOfFriends) 323 lock (m_NeedsListOfFriends)
318 { 324 {
319 if (!m_NeedsListOfFriends.Remove(agentID)) 325 if (!m_NeedsListOfFriends.Remove(agentID))
320 return; 326 return false;
321 } 327 }
322 328
323 // Send the friends online 329 // Send the friends online
@@ -366,6 +372,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
366 // Finally 372 // Finally
367 LocalFriendshipOffered(agentID, im); 373 LocalFriendshipOffered(agentID, im);
368 } 374 }
375
376 return true;
369 } 377 }
370 378
371 protected virtual string FriendshipMessage(string friendID) 379 protected virtual string FriendshipMessage(string friendID)
@@ -579,7 +587,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
579 StoreFriendships(agentID, friendID); 587 StoreFriendships(agentID, friendID);
580 588
581 // Update the local cache 589 // Update the local cache
582 UpdateFriendsCache(agentID); 590 UpdateFriendsCache(client);
583 591
584 // 592 //
585 // Notify the friend 593 // Notify the friend
@@ -647,7 +655,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
647 DeleteFriendship(agentID, exfriendID); 655 DeleteFriendship(agentID, exfriendID);
648 656
649 // Update local cache 657 // Update local cache
650 UpdateFriendsCache(agentID); 658 UpdateFriendsCache(client);
651 659
652 client.SendTerminateFriend(exfriendID); 660 client.SendTerminateFriend(exfriendID);
653 661
@@ -679,23 +687,26 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
679 687
680 private void OnGrantUserRights(IClientAPI remoteClient, UUID requester, UUID target, int rights) 688 private void OnGrantUserRights(IClientAPI remoteClient, UUID requester, UUID target, int rights)
681 { 689 {
690 m_log.DebugFormat("[FRIENDS MODULE]: User {0} changing rights to {1} for friend {2}", requester, rights, target);
691
682 FriendInfo[] friends = GetFriends(remoteClient.AgentId); 692 FriendInfo[] friends = GetFriends(remoteClient.AgentId);
683 if (friends.Length == 0) 693 if (friends.Length == 0)
694 {
695 m_log.DebugFormat("[XXX]: agent {0} has no friends", requester);
684 return; 696 return;
697 }
685 698
686 m_log.DebugFormat("[FRIENDS MODULE]: User {0} changing rights to {1} for friend {2}", requester, rights, target);
687 // Let's find the friend in this user's friend list 699 // Let's find the friend in this user's friend list
688 FriendInfo friend = null; 700 FriendInfo friend = GetFriend(friends, target);
689 foreach (FriendInfo fi in friends)
690 {
691 if (fi.Friend == target.ToString())
692 friend = fi;
693 }
694 701
695 if (friend != null) // Found it 702 if (friend != null) // Found it
696 { 703 {
697 // Store it on the DB 704 // Store it on the DB
698 FriendsService.StoreFriend(requester.ToString(), target.ToString(), rights); 705 if (!SimpleStore(requester, target, rights))
706 {
707 remoteClient.SendAlertMessage("Unable to grant rights.");
708 return;
709 }
699 710
700 // Store it in the local cache 711 // Store it in the local cache
701 int myFlags = friend.MyFlags; 712 int myFlags = friend.MyFlags;
@@ -725,6 +736,24 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
725 } 736 }
726 } 737 }
727 } 738 }
739 else
740 m_log.DebugFormat("[FRIENDS MODULE]: friend {0} not found for {1}", target, requester);
741 }
742
743 protected virtual bool SimpleStore(UUID agentID, UUID friendID, int rights)
744 {
745 FriendsService.StoreFriend(agentID.ToString(), friendID.ToString(), rights);
746 return true;
747 }
748
749 protected virtual FriendInfo GetFriend(FriendInfo[] friends, UUID friendID)
750 {
751 foreach (FriendInfo fi in friends)
752 {
753 if (fi.Friend == friendID.ToString())
754 return fi;
755 }
756 return null;
728 } 757 }
729 758
730 #region Local 759 #region Local
@@ -753,7 +782,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
753 friendClient.SendInstantMessage(im); 782 friendClient.SendInstantMessage(im);
754 783
755 // Update the local cache 784 // Update the local cache
756 UpdateFriendsCache(friendID); 785 UpdateFriendsCache(friendClient);
757 786
758 // we're done 787 // we're done
759 return true; 788 return true;
@@ -786,7 +815,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
786 // the friend in this sim as root agent 815 // the friend in this sim as root agent
787 friendClient.SendTerminateFriend(exfriendID); 816 friendClient.SendTerminateFriend(exfriendID);
788 // update local cache 817 // update local cache
789 UpdateFriendsCache(exfriendID); 818 UpdateFriendsCache(friendClient);
790 // we're done 819 // we're done
791 return true; 820 return true;
792 } 821 }
@@ -816,15 +845,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
816 } 845 }
817 846
818 // Update local cache 847 // Update local cache
819 lock (m_Friends) 848 UpdateLocalCache(userID, friendID, rights);
820 {
821 FriendInfo[] friends = GetFriends(friendID);
822 foreach (FriendInfo finfo in friends)
823 {
824 if (finfo.Friend == userID.ToString())
825 finfo.TheirFlags = rights;
826 }
827 }
828 849
829 return true; 850 return true;
830 } 851 }
@@ -866,13 +887,25 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
866 return EMPTY_FRIENDS; 887 return EMPTY_FRIENDS;
867 } 888 }
868 889
869 private void UpdateFriendsCache(UUID agentID) 890 private void UpdateFriendsCache(IClientAPI client)
870 { 891 {
892 UUID agentID = client.AgentId;
871 lock (m_Friends) 893 lock (m_Friends)
872 { 894 {
873 UserFriendData friendsData; 895 UserFriendData friendsData;
874 if (m_Friends.TryGetValue(agentID, out friendsData)) 896 if (m_Friends.TryGetValue(agentID, out friendsData))
875 friendsData.Friends = FriendsService.GetFriends(agentID); 897 friendsData.Friends = GetFriendsFromService(client);
898 }
899 }
900
901 protected void UpdateLocalCache(UUID userID, UUID friendID, int rights)
902 {
903 // Update local cache
904 lock (m_Friends)
905 {
906 FriendInfo[] friends = GetFriends(friendID);
907 FriendInfo finfo = GetFriend(friends, userID);
908 finfo.TheirFlags = rights;
876 } 909 }
877 } 910 }
878 } 911 }
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs
index 645ecdc..abffb94 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs
@@ -58,129 +58,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
58 58
59 #endregion 59 #endregion
60 60
61 //public void SendFriendsOnlineIfNeeded(IClientAPI client) 61 protected override bool FetchFriendslist(IClientAPI client)
62 //{
63 // UUID agentID = client.AgentId;
64
65 // // Check if the online friends list is needed
66 // lock (m_NeedsListOfFriends)
67 // {
68 // if (!m_NeedsListOfFriends.Remove(agentID))
69 // return;
70 // }
71
72 // // Send the friends online
73 // List<UUID> online = GetOnlineFriends(agentID);
74 // if (online.Count > 0)
75 // {
76 // m_log.DebugFormat("[FRIENDS MODULE]: User {0} in region {1} has {2} friends online", client.AgentId, client.Scene.RegionInfo.RegionName, online.Count);
77 // client.SendAgentOnline(online.ToArray());
78 // }
79
80 // // Send outstanding friendship offers
81 // List<string> outstanding = new List<string>();
82 // FriendInfo[] friends = GetFriends(agentID);
83 // foreach (FriendInfo fi in friends)
84 // {
85 // if (fi.TheirFlags == -1)
86 // outstanding.Add(fi.Friend);
87 // }
88
89 // GridInstantMessage im = new GridInstantMessage(client.Scene, UUID.Zero, String.Empty, agentID, (byte)InstantMessageDialog.FriendshipOffered,
90 // "Will you be my friend?", true, Vector3.Zero);
91
92 // foreach (string fid in outstanding)
93 // {
94 // UUID fromAgentID;
95 // if (!UUID.TryParse(fid, out fromAgentID))
96 // continue;
97
98 // UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(client.Scene.RegionInfo.ScopeID, fromAgentID);
99
100 // PresenceInfo presence = null;
101 // PresenceInfo[] presences = PresenceService.GetAgents(new string[] { fid });
102 // if (presences != null && presences.Length > 0)
103 // presence = presences[0];
104 // if (presence != null)
105 // im.offline = 0;
106
107 // im.fromAgentID = fromAgentID.Guid;
108 // im.fromAgentName = account.FirstName + " " + account.LastName;
109 // im.offline = (byte)((presence == null) ? 1 : 0);
110 // im.imSessionID = im.fromAgentID;
111
112 // // Finally
113 // LocalFriendshipOffered(agentID, im);
114 // }
115 //}
116
117 //List<UUID> GetOnlineFriends(UUID userID)
118 //{
119 // List<string> friendList = new List<string>();
120 // List<UUID> online = new List<UUID>();
121
122 // FriendInfo[] friends = GetFriends(userID);
123 // foreach (FriendInfo fi in friends)
124 // {
125 // if (((fi.TheirFlags & 1) != 0) && (fi.TheirFlags != -1))
126 // friendList.Add(fi.Friend);
127 // }
128
129 // if (friendList.Count > 0)
130 // {
131 // PresenceInfo[] presence = PresenceService.GetAgents(friendList.ToArray());
132 // foreach (PresenceInfo pi in presence)
133 // {
134 // UUID presenceID;
135 // if (UUID.TryParse(pi.UserID, out presenceID))
136 // online.Add(presenceID);
137 // }
138 // }
139
140 // return online;
141 //}
142
143 //private void StatusNotify(FriendInfo friend, UUID userID, bool online)
144 //{
145 // UUID friendID;
146 // if (UUID.TryParse(friend.Friend, out friendID))
147 // {
148 // // Try local
149 // if (LocalStatusNotification(userID, friendID, online))
150 // return;
151
152 // // The friend is not here [as root]. Let's forward.
153 // PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() });
154 // if (friendSessions != null && friendSessions.Length > 0)
155 // {
156 // PresenceInfo friendSession = null;
157 // foreach (PresenceInfo pinfo in friendSessions)
158 // if (pinfo.RegionID != UUID.Zero) // let's guard against sessions-gone-bad
159 // {
160 // friendSession = pinfo;
161 // break;
162 // }
163
164 // if (friendSession != null)
165 // {
166 // GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID);
167 // //m_log.DebugFormat("[FRIENDS]: Remote Notify to region {0}", region.RegionName);
168 // m_FriendsSimConnector.StatusNotify(region, userID, friendID, online);
169 // }
170 // }
171
172 // // Friend is not online. Ignore.
173 // }
174 // else
175 // {
176 // m_log.WarnFormat("[FRIENDS]: Error parsing friend ID {0}", friend.Friend);
177 // }
178 //}
179
180 protected override bool FetchFriendslist(UUID agentID)
181 { 62 {
182 if (base.FetchFriendslist(agentID)) 63 if (base.FetchFriendslist(client))
183 { 64 {
65 UUID agentID = client.AgentId;
184 // We need to preload the user management cache with the names 66 // We need to preload the user management cache with the names
185 // of foreign friends, just like we do with SOPs' creators 67 // of foreign friends, just like we do with SOPs' creators
186 foreach (FriendInfo finfo in m_Friends[agentID].Friends) 68 foreach (FriendInfo finfo in m_Friends[agentID].Friends)
@@ -204,6 +86,39 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
204 return false; 86 return false;
205 } 87 }
206 88
89 public override bool SendFriendsOnlineIfNeeded(IClientAPI client)
90 {
91 if (base.SendFriendsOnlineIfNeeded(client))
92 {
93 UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(client.Scene.RegionInfo.ScopeID, client.AgentId);
94 if (account == null) // foreign
95 {
96 FriendInfo[] friends = GetFriends(client.AgentId);
97 foreach (FriendInfo f in friends)
98 {
99 client.SendChangeUserRights(new UUID(f.Friend), client.AgentId, f.TheirFlags);
100 }
101 }
102 }
103 return false;
104 }
105
106 protected override FriendInfo[] GetFriendsFromService(IClientAPI client)
107 {
108 UserAccount account1 = UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, client.AgentId);
109 if (account1 != null)
110 return base.GetFriendsFromService(client);
111
112 // Foreigner
113 AgentCircuitData agentClientCircuit = ((Scene)(client.Scene)).AuthenticateHandler.GetAgentCircuitData(client.CircuitCode);
114 string agentUUI = Util.ProduceUserUniversalIdentifier(agentClientCircuit);
115
116 FriendInfo[] finfos = FriendsService.GetFriends(agentUUI);
117 m_log.DebugFormat("[HGFRIENDS MODULE]: Fetched {0} local friends for visitor {1}", finfos.Length, agentUUI);
118 return finfos;
119 }
120
121
207 protected override bool GetAgentInfo(UUID scopeID, string fid, out UUID agentID, out string first, out string last) 122 protected override bool GetAgentInfo(UUID scopeID, string fid, out UUID agentID, out string first, out string last)
208 { 123 {
209 first = "Unknown"; last = "User"; 124 first = "Unknown"; last = "User";
@@ -249,6 +164,45 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
249 return "Please confirm this friendship you made while you were away."; 164 return "Please confirm this friendship you made while you were away.";
250 } 165 }
251 166
167 protected override bool SimpleStore(UUID agentID, UUID friendID, int rights)
168 {
169 UserAccount account1 = UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, agentID);
170 UserAccount account2 = UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, friendID);
171 // Are they both local users?
172 if (account1 != null && account2 != null)
173 {
174 // local grid users
175 return base.SimpleStore(agentID, friendID, rights);
176 }
177
178 if (account1 != null)
179 {
180 FriendInfo[] finfos = GetFriends(agentID);
181 if (finfos.Length > 0)
182 {
183 FriendInfo finfo = GetFriend(finfos, friendID);
184 FriendsService.StoreFriend(agentID.ToString(), finfo.Friend, rights);
185 return true;
186 }
187 }
188 if (account2 != null)
189 {
190 IClientAPI client = LocateClientObject(agentID);
191 if (client != null)
192 {
193 AgentCircuitData acircuit = m_Scenes[0].AuthenticateHandler.GetAgentCircuitData(client.CircuitCode);
194 if (acircuit != null)
195 {
196 FriendsService.StoreFriend(Util.ProduceUserUniversalIdentifier(acircuit), friendID.ToString(), rights);
197 return true;
198 }
199 }
200 }
201
202 return false;
203
204 }
205
252 protected override void StoreBackwards(UUID friendID, UUID agentID) 206 protected override void StoreBackwards(UUID friendID, UUID agentID)
253 { 207 {
254 UserAccount account1 = UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, agentID); 208 UserAccount account1 = UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, agentID);
@@ -366,6 +320,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
366 // my brain hurts now 320 // my brain hurts now
367 } 321 }
368 322
323 protected override FriendInfo GetFriend(FriendInfo[] friends, UUID friendID)
324 {
325 foreach (FriendInfo fi in friends)
326 {
327 if (fi.Friend.StartsWith(friendID.ToString()))
328 return fi;
329 }
330 return null;
331 }
332
369 protected override void DeleteFriendship(UUID agentID, UUID exfriendID) 333 protected override void DeleteFriendship(UUID agentID, UUID exfriendID)
370 { 334 {
371 base.DeleteFriendship(agentID, exfriendID); 335 base.DeleteFriendship(agentID, exfriendID);
@@ -374,7 +338,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
374 FriendInfo[] friends = GetFriends(agentID); 338 FriendInfo[] friends = GetFriends(agentID);
375 foreach (FriendInfo finfo in friends) 339 foreach (FriendInfo finfo in friends)
376 { 340 {
377 if (finfo.Friend != exfriendID.ToString() && finfo.Friend.EndsWith(exfriendID.ToString())) 341 if (finfo.Friend != exfriendID.ToString() && finfo.Friend.StartsWith(exfriendID.ToString()))
378 { 342 {
379 FriendsService.Delete(agentID, exfriendID.ToString()); 343 FriendsService.Delete(agentID, exfriendID.ToString());
380 // TODO: delete the friendship on the other side 344 // TODO: delete the friendship on the other side
@@ -383,56 +347,5 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
383 } 347 }
384 } 348 }
385 349
386 //private void OnGrantUserRights(IClientAPI remoteClient, UUID requester, UUID target, int rights)
387 //{
388 // FriendInfo[] friends = GetFriends(remoteClient.AgentId);
389 // if (friends.Length == 0)
390 // return;
391
392 // m_log.DebugFormat("[FRIENDS MODULE]: User {0} changing rights to {1} for friend {2}", requester, rights, target);
393 // // Let's find the friend in this user's friend list
394 // FriendInfo friend = null;
395 // foreach (FriendInfo fi in friends)
396 // {
397 // if (fi.Friend == target.ToString())
398 // friend = fi;
399 // }
400
401 // if (friend != null) // Found it
402 // {
403 // // Store it on the DB
404 // FriendsService.StoreFriend(requester, target.ToString(), rights);
405
406 // // Store it in the local cache
407 // int myFlags = friend.MyFlags;
408 // friend.MyFlags = rights;
409
410 // // Always send this back to the original client
411 // remoteClient.SendChangeUserRights(requester, target, rights);
412
413 // //
414 // // Notify the friend
415 // //
416
417 // // Try local
418 // if (LocalGrantRights(requester, target, myFlags, rights))
419 // return;
420
421 // PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { target.ToString() });
422 // if (friendSessions != null && friendSessions.Length > 0)
423 // {
424 // PresenceInfo friendSession = friendSessions[0];
425 // if (friendSession != null)
426 // {
427 // GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID);
428 // // TODO: You might want to send the delta to save the lookup
429 // // on the other end!!
430 // m_FriendsSimConnector.GrantRights(region, requester, target, myFlags, rights);
431 // }
432 // }
433 // }
434 //}
435
436
437 } 350 }
438} 351}
diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
index 170c35f..d7324c6 100644
--- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
+++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
@@ -548,18 +548,18 @@ namespace OpenSim.Region.CoreModules.World.Permissions
548 548
549 // libomv will moan about PrimFlags.ObjectYouOfficer being 549 // libomv will moan about PrimFlags.ObjectYouOfficer being
550 // deprecated 550 // deprecated
551 #pragma warning disable 0612 551#pragma warning disable 0612
552 objflags &= (uint) 552 objflags &= (uint)
553 ~(PrimFlags.ObjectCopy | // Tells client you can copy the object 553 ~(PrimFlags.ObjectCopy | // Tells client you can copy the object
554 PrimFlags.ObjectModify | // tells client you can modify the object 554 PrimFlags.ObjectModify | // tells client you can modify the object
555 PrimFlags.ObjectMove | // tells client that you can move the object (only, no mod) 555 PrimFlags.ObjectMove | // tells client that you can move the object (only, no mod)
556 PrimFlags.ObjectTransfer | // tells the client that you can /take/ the object if you don't own it 556 PrimFlags.ObjectTransfer | // tells the client that you can /take/ the object if you don't own it
557 PrimFlags.ObjectYouOwner | // Tells client that you're the owner of the object 557 PrimFlags.ObjectYouOwner | // Tells client that you're the owner of the object
558 PrimFlags.ObjectAnyOwner | // Tells client that someone owns the object 558 PrimFlags.ObjectAnyOwner | // Tells client that someone owns the object
559 PrimFlags.ObjectOwnerModify | // Tells client that you're the owner of the object 559 PrimFlags.ObjectOwnerModify | // Tells client that you're the owner of the object
560 PrimFlags.ObjectYouOfficer // Tells client that you've got group object editing permission. Used when ObjectGroupOwned is set 560 PrimFlags.ObjectYouOfficer // Tells client that you've got group object editing permission. Used when ObjectGroupOwned is set
561 ); 561 );
562 #pragma warning restore 0612 562#pragma warning restore 0612
563 563
564 // Creating the three ObjectFlags options for this method to choose from. 564 // Creating the three ObjectFlags options for this method to choose from.
565 // Customize the OwnerMask 565 // Customize the OwnerMask
@@ -576,22 +576,27 @@ namespace OpenSim.Region.CoreModules.World.Permissions
576 576
577 if (m_bypassPermissions) 577 if (m_bypassPermissions)
578 return objectOwnerMask; 578 return objectOwnerMask;
579 579
580 // Object owners should be able to edit their own content 580 // Object owners should be able to edit their own content
581 if (user == objectOwner) 581 if (user == objectOwner)
582 return objectOwnerMask; 582 return objectOwnerMask;
583 583
584 if (IsFriendWithPerms(user, objectOwner)) 584 if (IsFriendWithPerms(user, objectOwner))
585 {
585 return objectOwnerMask; 586 return objectOwnerMask;
586 587 }
587 // Estate users should be able to edit anything in the sim if RegionOwnerIsGod is set 588 // Estate users should be able to edit anything in the sim if RegionOwnerIsGod is set
588 if (m_RegionOwnerIsGod && IsEstateManager(user) && !IsAdministrator(objectOwner)) 589 if (m_RegionOwnerIsGod && IsEstateManager(user) && !IsAdministrator(objectOwner))
590 {
589 return objectOwnerMask; 591 return objectOwnerMask;
592 }
590 593
591 // Admin should be able to edit anything in the sim (including admin objects) 594 // Admin should be able to edit anything in the sim (including admin objects)
592 if (IsAdministrator(user)) 595 if (IsAdministrator(user))
596 {
593 return objectOwnerMask; 597 return objectOwnerMask;
594 598 }
599
595 // Users should be able to edit what is over their land. 600 // Users should be able to edit what is over their land.
596 Vector3 taskPos = task.AbsolutePosition; 601 Vector3 taskPos = task.AbsolutePosition;
597 ILandObject parcel = m_scene.LandChannel.GetLandObject(taskPos.X, taskPos.Y); 602 ILandObject parcel = m_scene.LandChannel.GetLandObject(taskPos.X, taskPos.Y);
@@ -599,13 +604,15 @@ namespace OpenSim.Region.CoreModules.World.Permissions
599 { 604 {
600 // Admin objects should not be editable by the above 605 // Admin objects should not be editable by the above
601 if (!IsAdministrator(objectOwner)) 606 if (!IsAdministrator(objectOwner))
607 {
602 return objectOwnerMask; 608 return objectOwnerMask;
609 }
603 } 610 }
604 611
605 // Group permissions 612 // Group permissions
606 if ((task.GroupID != UUID.Zero) && IsGroupMember(task.GroupID, user, 0)) 613 if ((task.GroupID != UUID.Zero) && IsGroupMember(task.GroupID, user, 0))
607 return objectGroupMask | objectEveryoneMask; 614 return objectGroupMask | objectEveryoneMask;
608 615
609 return objectEveryoneMask; 616 return objectEveryoneMask;
610 } 617 }
611 618
@@ -673,7 +680,6 @@ namespace OpenSim.Region.CoreModules.World.Permissions
673 // 680 //
674 // Nobody but the object owner can set permissions on an object 681 // Nobody but the object owner can set permissions on an object
675 // 682 //
676
677 if (locked && (!IsAdministrator(currentUser)) && denyOnLocked) 683 if (locked && (!IsAdministrator(currentUser)) && denyOnLocked)
678 { 684 {
679 return false; 685 return false;
@@ -704,6 +710,11 @@ namespace OpenSim.Region.CoreModules.World.Permissions
704 // Return immediately, so that the administrator can shares group objects 710 // Return immediately, so that the administrator can shares group objects
705 return true; 711 return true;
706 } 712 }
713
714 // Friends with benefits should be able to edit the objects too
715 if (IsFriendWithPerms(currentUser, objectOwner))
716 // Return immediately, so that the administrator can share objects with friends
717 return true;
707 718
708 // Users should be able to edit what is over their land. 719 // Users should be able to edit what is over their land.
709 ILandObject parcel = m_scene.LandChannel.GetLandObject(group.AbsolutePosition.X, group.AbsolutePosition.Y); 720 ILandObject parcel = m_scene.LandChannel.GetLandObject(group.AbsolutePosition.X, group.AbsolutePosition.Y);
diff --git a/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs b/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs
index 0ff7dee..d4a6857 100644
--- a/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs
@@ -34,6 +34,6 @@ namespace OpenSim.Region.Framework.Interfaces
34 public interface IFriendsModule 34 public interface IFriendsModule
35 { 35 {
36 uint GetFriendPerms(UUID PrincipalID, UUID FriendID); 36 uint GetFriendPerms(UUID PrincipalID, UUID FriendID);
37 void SendFriendsOnlineIfNeeded(IClientAPI client); 37 bool SendFriendsOnlineIfNeeded(IClientAPI client);
38 } 38 }
39} 39}