From 83b4b4440b7becb405840bc69d665e260fdecea0 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 5 Nov 2009 02:09:07 +0000 Subject: Patch by revolution, thank you. Mantis #1789 . Implement friends permissions. Applied with major changes. Core functionality commented pending review for possible rights escalation. No user functionality yet. --- .../Region/ClientStack/LindenUDP/LLClientView.cs | 22 +++++++++++++- .../CoreModules/Avatar/Friends/FriendsModule.cs | 9 ++++-- .../World/Permissions/PermissionsModule.cs | 34 ++++++++++++++++++++++ .../Region/Examples/SimpleModule/MyNpcCharacter.cs | 1 + .../Server/IRCClientView.cs | 1 + .../Region/OptionalModules/World/NPC/NPCAvatar.cs | 1 + 6 files changed, 65 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 70abe77..34cad7b 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -220,6 +220,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP public event FriendActionDelegate OnApproveFriendRequest; public event FriendActionDelegate OnDenyFriendRequest; public event FriendshipTermination OnTerminateFriendship; + public event GrantUserFriendRights OnGrantUserRights; public event MoneyTransferRequest OnMoneyTransferRequest; public event EconomyDataRequest OnEconomyDataRequest; public event MoneyBalanceRequest OnMoneyBalanceRequest; @@ -9719,7 +9720,26 @@ namespace OpenSim.Region.ClientStack.LindenUDP Utils.BytesToString(avatarInterestUpdate.PropertiesData.SkillsText), Utils.BytesToString(avatarInterestUpdate.PropertiesData.LanguagesText)); break; - + + case PacketType.GrantUserRights: + GrantUserRightsPacket GrantUserRights = + (GrantUserRightsPacket)Pack; + #region Packet Session and User Check + if (m_checkPackets) + { + if (GrantUserRights.AgentData.SessionID != SessionId || + GrantUserRights.AgentData.AgentID != AgentId) + break; + } + #endregion + GrantUserFriendRights GrantUserRightsHandler = OnGrantUserRights; + if (GrantUserRightsHandler != null) + GrantUserRightsHandler(this, + GrantUserRights.AgentData.AgentID, + GrantUserRights.Rights[0].AgentRelated, + GrantUserRights.Rights[0].RelatedRights); + break; + case PacketType.PlacesQuery: PlacesQueryPacket placesQueryPacket = (PlacesQueryPacket)Pack; diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index fc7d63a..c6fd72e 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -395,6 +395,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends // if it leaves, we want to know, too client.OnLogout += OnLogout; + client.OnGrantUserRights += GrantUserFriendRights; + } private void ClientClosed(UUID AgentId, Scene scene) @@ -1108,7 +1110,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends // tell everyone that we are offline SendPresenceState(remoteClient, fl, false); } - } - + private void GrantUserFriendRights(IClientAPI remoteClient, UUID requester, UUID target, int rights) + { + ((Scene)remoteClient.Scene).CommsManager.UpdateUserFriendPerms(requester, target, (uint)rights); + } + } #endregion } diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index fe9de1b..effe1f0 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs @@ -476,6 +476,37 @@ namespace OpenSim.Region.CoreModules.World.Permissions return false; } + protected bool IsFriendWithPerms(UUID user,UUID objectOwner) + { + + if (user == UUID.Zero) return false; + + List profile = m_scene.CommsManager.GetUserFriendList(user); + foreach (FriendListItem item in profile) + { + m_log.Warn("IsFriendWithPerms called" + item.FriendPerms.ToString()); + if(item.Friend == objectOwner) + { +// if (item.FriendPerms == 3) +// { +// return true; +// } +// if (item.FriendPerms == 4) +// { +// return true; +// } +// if (item.FriendPerms == 5) +// { +// return true; +// } +// if (item.FriendPerms == 7) +// { +// return true; +// } + } + } + return false; + } protected bool IsEstateManager(UUID user) { @@ -565,6 +596,9 @@ namespace OpenSim.Region.CoreModules.World.Permissions // Object owners should be able to edit their own content if (user == objectOwner) return objectOwnerMask; + + if (IsFriendWithPerms(user, objectOwner)) + return objectOwnerMask; // Estate users should be able to edit anything in the sim if (IsEstateManager(user) && m_RegionOwnerIsGod && !IsAdministrator(objectOwner)) diff --git a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs index 5891c7e..9754da3 100644 --- a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs +++ b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs @@ -179,6 +179,7 @@ namespace OpenSim.Region.Examples.SimpleModule public event FriendActionDelegate OnApproveFriendRequest; public event FriendActionDelegate OnDenyFriendRequest; public event FriendshipTermination OnTerminateFriendship; + public event GrantUserFriendRights OnGrantUserRights; public event EconomyDataRequest OnEconomyDataRequest; public event MoneyBalanceRequest OnMoneyBalanceRequest; diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs index f1bd705..6c3e7eb 100644 --- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs +++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs @@ -758,6 +758,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server public event FriendActionDelegate OnApproveFriendRequest; public event FriendActionDelegate OnDenyFriendRequest; public event FriendshipTermination OnTerminateFriendship; + public event GrantUserFriendRights OnGrantUserRights; public event MoneyTransferRequest OnMoneyTransferRequest; public event EconomyDataRequest OnEconomyDataRequest; public event MoneyBalanceRequest OnMoneyBalanceRequest; diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index cf81198..cf36d08 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs @@ -283,6 +283,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC public event FriendActionDelegate OnApproveFriendRequest; public event FriendActionDelegate OnDenyFriendRequest; public event FriendshipTermination OnTerminateFriendship; + public event GrantUserFriendRights OnGrantUserRights; public event EconomyDataRequest OnEconomyDataRequest; public event MoneyBalanceRequest OnMoneyBalanceRequest; -- cgit v1.1