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.
0.6.8-post-fixes
Melanie 2009-11-05 02:09:07 +00:00
parent 30a2411e58
commit 83b4b4440b
10 changed files with 71 additions and 3 deletions

View File

@ -676,6 +676,7 @@ namespace OpenSim.Client.MXP.ClientStack
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;

View File

@ -327,6 +327,7 @@ namespace OpenSim.Client.VWoHTTP.ClientStack
public event FriendActionDelegate OnApproveFriendRequest = delegate { };
public event FriendActionDelegate OnDenyFriendRequest = delegate { };
public event FriendshipTermination OnTerminateFriendship = delegate { };
public event GrantUserFriendRights OnGrantUserRights = delegate { };
public event MoneyTransferRequest OnMoneyTransferRequest = delegate { };
public event EconomyDataRequest OnEconomyDataRequest = delegate { };
public event MoneyBalanceRequest OnMoneyBalanceRequest = delegate { };
@ -406,6 +407,7 @@ namespace OpenSim.Client.VWoHTTP.ClientStack
public event PlacesQuery OnPlacesQuery = delegate { };
public void SetDebugPacketLevel(int newDebug)
{
throw new System.NotImplementedException();

View File

@ -446,6 +446,7 @@ namespace OpenSim.Framework
public delegate void AvatarNotesUpdate(IClientAPI client, UUID targetID, string notes);
public delegate void MuteListRequest(IClientAPI client, uint muteCRC);
public delegate void AvatarInterestUpdate(IClientAPI client, uint wantmask, string wanttext, uint skillsmask, string skillstext, string languages);
public delegate void GrantUserFriendRights(IClientAPI client, UUID requester, UUID target, int rights);
public delegate void PlacesQuery(UUID QueryID, UUID TransactionID, string QueryText, uint QueryFlags, byte Category, string SimName, IClientAPI client);
public delegate void AgentFOV(IClientAPI client, float verticalAngle);
@ -1023,6 +1024,7 @@ namespace OpenSim.Framework
event PickInfoUpdate OnPickInfoUpdate;
event AvatarNotesUpdate OnAvatarNotesUpdate;
event AvatarInterestUpdate OnAvatarInterestUpdate;
event GrantUserFriendRights OnGrantUserRights;
event MuteListRequest OnMuteListRequest;

View File

@ -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;

View File

@ -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
}

View File

@ -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<FriendListItem> 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))

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -191,6 +191,7 @@ namespace OpenSim.Tests.Common.Mock
public event FriendActionDelegate OnApproveFriendRequest;
public event FriendActionDelegate OnDenyFriendRequest;
public event FriendshipTermination OnTerminateFriendship;
public event GrantUserFriendRights OnGrantUserRights;
public event EconomyDataRequest OnEconomyDataRequest;
public event MoneyBalanceRequest OnMoneyBalanceRequest;