Merge branch 'master' into httptests

httptests
UbitUmarov 2016-10-25 09:18:13 +01:00
commit 8c7fe3c0db
5 changed files with 484 additions and 348 deletions

View File

@ -46,12 +46,20 @@ namespace OpenSim.Framework
public enum EstateAccessCodex : uint public enum EstateAccessCodex : uint
{ {
AccessOptions = 1, AllowedAccess = 1,
AllowedGroups = 2, AllowedGroups = 2,
EstateBans = 4, EstateBans = 4,
EstateManagers = 8 EstateManagers = 8
} }
public enum EstateAccessLimits : int
{
AllowedAccess = 500,
AllowedGroups = 63,
EstateBans = 500,
EstateManagers = 10
}
[Flags]public enum TeleportFlags : uint [Flags]public enum TeleportFlags : uint
{ {
/// <summary>No flags set, or teleport failed</summary> /// <summary>No flags set, or teleport failed</summary>

View File

@ -305,11 +305,17 @@ namespace OpenSim.Framework
OnSave(this); OnSave(this);
} }
public int EstateUsersCount()
{
return l_EstateAccess.Count;
}
public void AddEstateUser(UUID avatarID) public void AddEstateUser(UUID avatarID)
{ {
if (avatarID == UUID.Zero) if (avatarID == UUID.Zero)
return; return;
if (!l_EstateAccess.Contains(avatarID)) if (!l_EstateAccess.Contains(avatarID) &&
(l_EstateAccess.Count < (int)Constants.EstateAccessLimits.AllowedAccess))
l_EstateAccess.Add(avatarID); l_EstateAccess.Add(avatarID);
} }
@ -319,11 +325,17 @@ namespace OpenSim.Framework
l_EstateAccess.Remove(avatarID); l_EstateAccess.Remove(avatarID);
} }
public int EstateGroupsCount()
{
return l_EstateGroups.Count;
}
public void AddEstateGroup(UUID avatarID) public void AddEstateGroup(UUID avatarID)
{ {
if (avatarID == UUID.Zero) if (avatarID == UUID.Zero)
return; return;
if (!l_EstateGroups.Contains(avatarID)) if (!l_EstateGroups.Contains(avatarID) &&
(l_EstateGroups.Count < (int)Constants.EstateAccessLimits.AllowedGroups))
l_EstateGroups.Add(avatarID); l_EstateGroups.Add(avatarID);
} }
@ -333,11 +345,17 @@ namespace OpenSim.Framework
l_EstateGroups.Remove(avatarID); l_EstateGroups.Remove(avatarID);
} }
public int EstateManagersCount()
{
return l_EstateManagers.Count;
}
public void AddEstateManager(UUID avatarID) public void AddEstateManager(UUID avatarID)
{ {
if (avatarID == UUID.Zero) if (avatarID == UUID.Zero)
return; return;
if (!l_EstateManagers.Contains(avatarID)) if (!l_EstateManagers.Contains(avatarID) &&
(l_EstateManagers.Count < (int)Constants.EstateAccessLimits.EstateManagers))
l_EstateManagers.Add(avatarID); l_EstateManagers.Add(avatarID);
} }
@ -403,11 +421,17 @@ namespace OpenSim.Framework
return false; return false;
} }
public int EstateBansCount()
{
return l_EstateBans.Count;
}
public void AddBan(EstateBan ban) public void AddBan(EstateBan ban)
{ {
if (ban == null) if (ban == null)
return; return;
if (!IsBanned(ban.BannedUserID, 32)) //Ignore age-based bans if (!IsBanned(ban.BannedUserID, 32) &&
(l_EstateBans.Count < (int)Constants.EstateAccessLimits.EstateBans)) //Ignore age-based bans
l_EstateBans.Add(ban); l_EstateBans.Add(ban);
} }

View File

@ -29,8 +29,8 @@ namespace OpenSim
{ {
public class VersionInfo public class VersionInfo
{ {
public const string VersionNumber = "0.9.0.0"; public const string VersionNumber = "0.9.1.0";
public const string AssemblyVersionNumber = "0.9.0.*"; public const string AssemblyVersionNumber = "0.9.1.*";
private const Flavour VERSION_FLAVOUR = Flavour.Dev; private const Flavour VERSION_FLAVOUR = Flavour.Dev;

View File

@ -5072,8 +5072,20 @@ namespace OpenSim.Region.ClientStack.LindenUDP
} }
public void SendEstateList(UUID invoice, int code, UUID[] Data, uint estateID) public void SendEstateList(UUID invoice, int code, UUID[] Data, uint estateID)
{ {
int TotalnumberIDs = Data.Length;
int numberIDs;
int IDIndex = 0;
do
{
if(TotalnumberIDs > 63)
numberIDs = 63;
else
numberIDs = TotalnumberIDs;
TotalnumberIDs -= numberIDs;
EstateOwnerMessagePacket packet = new EstateOwnerMessagePacket(); EstateOwnerMessagePacket packet = new EstateOwnerMessagePacket();
packet.AgentData.TransactionID = UUID.Random(); packet.AgentData.TransactionID = UUID.Random();
packet.AgentData.AgentID = AgentId; packet.AgentData.AgentID = AgentId;
@ -5081,43 +5093,53 @@ namespace OpenSim.Region.ClientStack.LindenUDP
packet.MethodData.Invoice = invoice; packet.MethodData.Invoice = invoice;
packet.MethodData.Method = Utils.StringToBytes("setaccess"); packet.MethodData.Method = Utils.StringToBytes("setaccess");
EstateOwnerMessagePacket.ParamListBlock[] returnblock = new EstateOwnerMessagePacket.ParamListBlock[6 + Data.Length]; EstateOwnerMessagePacket.ParamListBlock[] returnblock = new EstateOwnerMessagePacket.ParamListBlock[6 + numberIDs];
for (int i = 0; i < (6 + Data.Length); i++) for (int i = 0; i < (6 + numberIDs); i++)
{ {
returnblock[i] = new EstateOwnerMessagePacket.ParamListBlock(); returnblock[i] = new EstateOwnerMessagePacket.ParamListBlock();
} }
int j = 0;
returnblock[j].Parameter = Utils.StringToBytes(estateID.ToString()); j++; returnblock[0].Parameter = Utils.StringToBytes(estateID.ToString());
returnblock[j].Parameter = Utils.StringToBytes(code.ToString()); j++; returnblock[1].Parameter = Utils.StringToBytes(code.ToString());
returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
j = 2; // Agents if((code & 1) != 0) // allowagents
if ((code & 2) != 0) returnblock[2].Parameter = Utils.StringToBytes(numberIDs.ToString());
j = 3; // Groups else
if ((code & 8) != 0) returnblock[2].Parameter = Utils.StringToBytes("0");
j = 5; // Managers
returnblock[j].Parameter = Utils.StringToBytes(Data.Length.ToString()); if((code & 2) != 0) // groups
j = 6; returnblock[3].Parameter = Utils.StringToBytes(numberIDs.ToString());
else
returnblock[3].Parameter = Utils.StringToBytes("0");
for (int i = 0; i < Data.Length; i++) if((code & 4) != 0) // bans
returnblock[4].Parameter = Utils.StringToBytes(numberIDs.ToString());
else
returnblock[4].Parameter = Utils.StringToBytes("0");
if((code & 8) != 0) // managers
returnblock[5].Parameter = Utils.StringToBytes(numberIDs.ToString());
else
returnblock[5].Parameter = Utils.StringToBytes("0");
int j = 6;
for (int i = 0; i < numberIDs; i++)
{ {
returnblock[j].Parameter = Data[i].GetBytes(); j++; returnblock[j].Parameter = Data[IDIndex].GetBytes();
j++;
IDIndex++;
} }
packet.ParamList = returnblock; packet.ParamList = returnblock;
packet.Header.Reliable = true; packet.Header.Reliable = true;
OutPacket(packet, ThrottleOutPacketType.Task); OutPacket(packet, ThrottleOutPacketType.Task);
} while (TotalnumberIDs > 0);
} }
public void SendBannedUserList(UUID invoice, EstateBan[] bl, uint estateID) public void SendBannedUserList(UUID invoice, EstateBan[] bl, uint estateID)
{ {
List<UUID> BannedUsers = new List<UUID>(); List<UUID> BannedUsers = new List<UUID>();
for (int i = 0; i < bl.Length; i++) for (int i = 0; i < bl.Length; i++)
{ {
if (bl[i] == null) if (bl[i] == null)
@ -5125,44 +5147,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
if (bl[i].BannedUserID == UUID.Zero) if (bl[i].BannedUserID == UUID.Zero)
continue; continue;
BannedUsers.Add(bl[i].BannedUserID); BannedUsers.Add(bl[i].BannedUserID);
if (BannedUsers.Count >= 50 || (i == (bl.Length - 1) && BannedUsers.Count > 0))
{
EstateOwnerMessagePacket packet = new EstateOwnerMessagePacket();
packet.AgentData.TransactionID = UUID.Random();
packet.AgentData.AgentID = AgentId;
packet.AgentData.SessionID = SessionId;
packet.MethodData.Invoice = invoice;
packet.MethodData.Method = Utils.StringToBytes("setaccess");
EstateOwnerMessagePacket.ParamListBlock[] returnblock = new EstateOwnerMessagePacket.ParamListBlock[6 + BannedUsers.Count];
int j;
for (j = 0; j < (6 + BannedUsers.Count); j++)
{
returnblock[j] = new EstateOwnerMessagePacket.ParamListBlock();
} }
j = 0; SendEstateList(invoice, 4, BannedUsers.ToArray(), estateID);
returnblock[j].Parameter = Utils.StringToBytes(estateID.ToString()); j++;
returnblock[j].Parameter = Utils.StringToBytes(((int)Constants.EstateAccessCodex.EstateBans).ToString()); j++;
returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
returnblock[j].Parameter = Utils.StringToBytes(BannedUsers.Count.ToString()); j++;
returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
foreach (UUID banned in BannedUsers)
{
returnblock[j].Parameter = banned.GetBytes(); j++;
}
packet.ParamList = returnblock;
packet.Header.Reliable = true;
OutPacket(packet, ThrottleOutPacketType.Task);
BannedUsers.Clear();
}
}
} }
public void SendRegionInfoToEstateMenu(RegionInfoForEstateMenuArgs args) public void SendRegionInfoToEstateMenu(RegionInfoForEstateMenuArgs args)
@ -10240,6 +10226,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false)) if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
{ {
int estateAccessType = Convert.ToInt16(Utils.BytesToString(messagePacket.ParamList[1].Parameter)); int estateAccessType = Convert.ToInt16(Utils.BytesToString(messagePacket.ParamList[1].Parameter));
OnUpdateEstateAccessDeltaRequest(this, messagePacket.MethodData.Invoice, estateAccessType, new UUID(Utils.BytesToString(messagePacket.ParamList[2].Parameter))); OnUpdateEstateAccessDeltaRequest(this, messagePacket.MethodData.Invoice, estateAccessType, new UUID(Utils.BytesToString(messagePacket.ParamList[2].Parameter)));
} }

View File

@ -33,15 +33,19 @@ using System.Linq;
using System.Reflection; using System.Reflection;
using System.Security; using System.Security;
using System.Timers; using System.Timers;
using System.Threading;
using log4net; using log4net;
using Mono.Addins; using Mono.Addins;
using Nini.Config; using Nini.Config;
using OpenMetaverse; using OpenMetaverse;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Monitoring;
using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
using OpenSim.Services.Interfaces; using OpenSim.Services.Interfaces;
using RegionFlags = OpenMetaverse.RegionFlags; using RegionFlags = OpenMetaverse.RegionFlags;
using Timer = System.Timers.Timer;
namespace OpenSim.Region.CoreModules.World.Estate namespace OpenSim.Region.CoreModules.World.Estate
{ {
@ -441,7 +445,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
Scene.RegionInfo.EstateSettings.EstateID); Scene.RegionInfo.EstateSettings.EstateID);
remote_client.SendEstateList(invoice, remote_client.SendEstateList(invoice,
(int)Constants.EstateAccessCodex.AccessOptions, (int)Constants.EstateAccessCodex.AllowedAccess,
Scene.RegionInfo.EstateSettings.EstateAccess, Scene.RegionInfo.EstateSettings.EstateAccess,
Scene.RegionInfo.EstateSettings.EstateID); Scene.RegionInfo.EstateSettings.EstateID);
@ -651,145 +655,281 @@ namespace OpenSim.Region.CoreModules.World.Estate
TriggerRegionInfoChange(); TriggerRegionInfoChange();
} }
private void handleEstateAccessDeltaRequest(IClientAPI remote_client, UUID invoice, int estateAccessType, UUID user) private object deltareqLock = new object();
private bool runnigDeltaExec = false;
private class EstateAccessDeltaRequest
{
public IClientAPI remote_client;
public UUID invoice;
public int estateAccessType;
public UUID user;
}
private OpenSim.Framework.BlockingQueue<EstateAccessDeltaRequest> deltaRequests = new OpenSim.Framework.BlockingQueue<EstateAccessDeltaRequest>();
private void handleEstateAccessDeltaRequest(IClientAPI _remote_client, UUID _invoice, int _estateAccessType, UUID _user)
{ {
// EstateAccessDelta handles Estate Managers, Sim Access, Sim Banlist, allowed Groups.. etc. // EstateAccessDelta handles Estate Managers, Sim Access, Sim Banlist, allowed Groups.. etc.
if (user == Scene.RegionInfo.EstateSettings.EstateOwner) if (_user == Scene.RegionInfo.EstateSettings.EstateOwner)
return; // never process EO return; // never process EO
if ((estateAccessType & 4) != 0) // User add EstateAccessDeltaRequest newreq = new EstateAccessDeltaRequest();
{ newreq.remote_client = _remote_client;
if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true)) newreq.invoice = _invoice;
{ newreq.estateAccessType = _estateAccessType;
if ((estateAccessType & 1) != 0) // All estates newreq.user = _user;
{
List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner);
EstateSettings estateSettings;
foreach (int estateID in estateIDs) deltaRequests.Enqueue(newreq);
lock(deltareqLock)
{ {
if (estateID != Scene.RegionInfo.EstateSettings.EstateID) if(!runnigDeltaExec)
{ {
estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID); runnigDeltaExec = true;
estateSettings.AddEstateUser(user); WorkManager.RunInThreadPool(execDeltaRequests,null,"execDeltaRequests");
Scene.EstateDataService.StoreEstateSettings(estateSettings);
} }
} }
} }
Scene.RegionInfo.EstateSettings.AddEstateUser(user); private void execDeltaRequests(object o)
Scene.EstateDataService.StoreEstateSettings(Scene.RegionInfo.EstateSettings); {
IClientAPI remote_client;
UUID invoice;
int estateAccessType;
UUID user;
Dictionary<int,EstateSettings> changed = new Dictionary<int,EstateSettings>();
Dictionary<IClientAPI,UUID> sendAllowedOrBanList = new Dictionary<IClientAPI,UUID>();
Dictionary<IClientAPI,UUID> sendManagers = new Dictionary<IClientAPI,UUID>();
Dictionary<IClientAPI,UUID> sendGroups = new Dictionary<IClientAPI,UUID>();
List<EstateSettings> otherEstates = new List<EstateSettings>();
bool sentAllowedFull = false;
bool sentBansFull = false;
bool sentGroupsFull = false;
bool sentManagersFull = false;
while(Scene.IsRunning)
{
EstateAccessDeltaRequest req = deltaRequests.Dequeue(500);
if(!Scene.IsRunning)
break;
if(req == null)
{
if(changed.Count > 0)
{
foreach(EstateSettings est in changed.Values)
Scene.EstateDataService.StoreEstateSettings(est);
TriggerEstateInfoChange(); TriggerEstateInfoChange();
remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AccessOptions, Scene.RegionInfo.EstateSettings.EstateAccess, Scene.RegionInfo.EstateSettings.EstateID); }
EstateSettings es = Scene.RegionInfo.EstateSettings;
foreach(KeyValuePair<IClientAPI,UUID> kvp in sendAllowedOrBanList)
{
IClientAPI cli = kvp.Key;
UUID invoive = kvp.Value;
cli.SendEstateList(invoive, (int)Constants.EstateAccessCodex.AllowedAccess, es.EstateAccess, es.EstateID);
cli.SendBannedUserList(invoive, es.EstateBans, es.EstateID);
}
sendAllowedOrBanList.Clear();
foreach(KeyValuePair<IClientAPI,UUID> kvp in sendManagers)
{
IClientAPI cli = kvp.Key;
cli.SendEstateList(kvp.Value, (int)Constants.EstateAccessCodex.EstateManagers, es.EstateManagers, es.EstateID);
}
foreach(KeyValuePair<IClientAPI,UUID> kvp in sendGroups)
{
IClientAPI cli = kvp.Key;
cli.SendEstateList(kvp.Value, (int)Constants.EstateAccessCodex.AllowedGroups, es.EstateGroups, es.EstateID);
}
otherEstates.Clear();
sendAllowedOrBanList.Clear();
sendManagers.Clear();
sendGroups.Clear();
changed.Clear();
lock(deltareqLock)
{
if(deltaRequests.Count() != 0)
continue;
runnigDeltaExec = false;
return;
}
}
remote_client = req.remote_client;
if(!remote_client.IsActive)
continue;
invoice = req.invoice;
user = req.user;
estateAccessType = req.estateAccessType;
bool needReply = ((estateAccessType & 1024) == 0);
bool doOtherEstates = ((estateAccessType & 3) != 0);
EstateSettings thisSettings = Scene.RegionInfo.EstateSettings;
int thisEstateID =(int)thisSettings.EstateID;
UUID agentID = remote_client.AgentId;
bool isadmin = Scene.Permissions.IsAdministrator(agentID);
// just i case recheck rights
if (!isadmin && !Scene.Permissions.IsEstateManager(agentID))
{
remote_client.SendAlertMessage("Method EstateAccess Failed, you don't have permissions");
continue;
}
otherEstates.Clear();
if(doOtherEstates)
{
UUID thisOwner = Scene.RegionInfo.EstateSettings.EstateOwner;
List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(thisOwner);
foreach (int estateID in estateIDs)
{
if (estateID == thisEstateID)
continue;
EstateSettings estateSettings;
if(changed.ContainsKey(estateID))
estateSettings = changed[estateID];
else
estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
if(!isadmin && !estateSettings.IsEstateManagerOrOwner(agentID))
continue;
otherEstates.Add(estateSettings);
}
estateIDs.Clear();
}
// the commands
// first the ones allowed for estate managers on this region
if ((estateAccessType & 4) != 0) // User add
{
if(thisSettings.EstateUsersCount() >= (int)Constants.EstateAccessLimits.AllowedAccess)
{
if(!sentAllowedFull)
{
sentAllowedFull = true;
remote_client.SendAlertMessage("Estate Allowed users list is full");
}
} }
else else
{ {
remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions"); if (doOtherEstates)
{
foreach (EstateSettings estateSettings in otherEstates)
{
if(!isadmin && !estateSettings.IsEstateManagerOrOwner(agentID))
continue;
if(estateSettings.EstateUsersCount() >= (int)Constants.EstateAccessLimits.AllowedAccess)
continue;
estateSettings.AddEstateUser(user);
estateSettings.RemoveBan(user);
changed[(int)estateSettings.EstateID] = estateSettings;
}
} }
thisSettings.AddEstateUser(user);
thisSettings.RemoveBan(user);
changed[thisEstateID] = thisSettings;;
if(needReply)
sendAllowedOrBanList[remote_client] = invoice;
}
} }
if ((estateAccessType & 8) != 0) // User remove if ((estateAccessType & 8) != 0) // User remove
{ {
if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true)) if (doOtherEstates) // All estates
{ {
if ((estateAccessType & 1) != 0) // All estates foreach (EstateSettings estateSettings in otherEstates)
{ {
List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner); if(!isadmin && !estateSettings.IsEstateManagerOrOwner(agentID))
EstateSettings estateSettings; continue;
foreach (int estateID in estateIDs)
{
if (estateID != Scene.RegionInfo.EstateSettings.EstateID)
{
estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
estateSettings.RemoveEstateUser(user); estateSettings.RemoveEstateUser(user);
Scene.EstateDataService.StoreEstateSettings(estateSettings); changed[(int)estateSettings.EstateID] = estateSettings;
}
} }
} }
Scene.RegionInfo.EstateSettings.RemoveEstateUser(user); thisSettings.RemoveEstateUser(user);
Scene.EstateDataService.StoreEstateSettings(Scene.RegionInfo.EstateSettings); changed[thisEstateID] = thisSettings;;
TriggerEstateInfoChange(); if(needReply)
remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AccessOptions, Scene.RegionInfo.EstateSettings.EstateAccess, Scene.RegionInfo.EstateSettings.EstateID); sendAllowedOrBanList[remote_client] = invoice;
}
else
{
remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
}
} }
if ((estateAccessType & 16) != 0) // Group add if ((estateAccessType & 16) != 0) // Group add
{ {
if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true)) if(thisSettings.EstateGroupsCount() >= (int)Constants.EstateAccessLimits.AllowedGroups)
{ {
if ((estateAccessType & 1) != 0) // All estates if(!sentGroupsFull)
{ {
List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner); sentGroupsFull = true;
EstateSettings estateSettings; remote_client.SendAlertMessage("Estate Allowed groups list is full");
foreach (int estateID in estateIDs)
{
if (estateID != Scene.RegionInfo.EstateSettings.EstateID)
{
estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
estateSettings.AddEstateGroup(user);
Scene.EstateDataService.StoreEstateSettings(estateSettings);
} }
} }
}
Scene.RegionInfo.EstateSettings.AddEstateGroup(user);
Scene.EstateDataService.StoreEstateSettings(Scene.RegionInfo.EstateSettings);
TriggerEstateInfoChange();
remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AllowedGroups, Scene.RegionInfo.EstateSettings.EstateGroups, Scene.RegionInfo.EstateSettings.EstateID);
}
else else
{ {
remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions"); if (doOtherEstates) // All estates
{
foreach (EstateSettings estateSettings in otherEstates)
{
if(!isadmin && !estateSettings.IsEstateManagerOrOwner(agentID))
continue;
if(estateSettings.EstateGroupsCount() >= (int)Constants.EstateAccessLimits.AllowedGroups)
continue;
estateSettings.AddEstateGroup(user);
changed[(int)estateSettings.EstateID] = estateSettings;
}
}
thisSettings.AddEstateGroup(user);
changed[thisEstateID] = thisSettings;
sendGroups[remote_client] = invoice;
} }
} }
if ((estateAccessType & 32) != 0) // Group remove if ((estateAccessType & 32) != 0) // Group remove
{ {
if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true)) if (doOtherEstates) // All estates
{ {
if ((estateAccessType & 1) != 0) // All estates foreach (EstateSettings estateSettings in otherEstates)
{ {
List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner); if(!isadmin && !estateSettings.IsEstateManagerOrOwner(agentID))
EstateSettings estateSettings; continue;
foreach (int estateID in estateIDs)
{
if (estateID != Scene.RegionInfo.EstateSettings.EstateID)
{
estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
estateSettings.RemoveEstateGroup(user); estateSettings.RemoveEstateGroup(user);
Scene.EstateDataService.StoreEstateSettings(estateSettings); changed[(int)estateSettings.EstateID] = estateSettings;
}
} }
} }
Scene.RegionInfo.EstateSettings.RemoveEstateGroup(user); thisSettings.RemoveEstateGroup(user);
Scene.EstateDataService.StoreEstateSettings(Scene.RegionInfo.EstateSettings); changed[thisEstateID] = thisSettings;
TriggerEstateInfoChange(); sendGroups[remote_client] = invoice;
remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AllowedGroups, Scene.RegionInfo.EstateSettings.EstateGroups, Scene.RegionInfo.EstateSettings.EstateID);
}
else
{
remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
}
} }
if ((estateAccessType & 64) != 0) // Ban add if ((estateAccessType & 64) != 0) // Ban add
{ {
if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, false))
if(thisSettings.EstateBansCount() >= (int)Constants.EstateAccessLimits.EstateBans)
{
if(!sentBansFull)
{
sentBansFull = true;
remote_client.SendAlertMessage("Estate Ban list is full");
}
}
else
{ {
EstateBan[] banlistcheck = Scene.RegionInfo.EstateSettings.EstateBans; EstateBan[] banlistcheck = Scene.RegionInfo.EstateSettings.EstateBans;
@ -802,31 +942,29 @@ namespace OpenSim.Region.CoreModules.World.Estate
alreadyInList = true; alreadyInList = true;
break; break;
} }
} }
if (!alreadyInList) if (!alreadyInList)
{ {
if (doOtherEstates) // All estates
{
foreach (EstateSettings estateSettings in otherEstates)
{
if(!isadmin && !estateSettings.IsEstateManagerOrOwner(agentID))
continue;
if ((estateAccessType & 1) != 0) // All estates if(estateSettings.EstateBansCount() >= (int)Constants.EstateAccessLimits.EstateBans)
{ continue;
List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner);
EstateSettings estateSettings;
foreach (int estateID in estateIDs)
{
if (estateID != Scene.RegionInfo.EstateSettings.EstateID)
{
EstateBan bitem = new EstateBan(); EstateBan bitem = new EstateBan();
bitem.BannedUserID = user; bitem.BannedUserID = user;
bitem.EstateID = (uint)estateID; bitem.EstateID = estateSettings.EstateID;
bitem.BannedHostAddress = "0.0.0.0"; bitem.BannedHostAddress = "0.0.0.0";
bitem.BannedHostIPMask = "0.0.0.0"; bitem.BannedHostIPMask = "0.0.0.0";
estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
estateSettings.AddBan(bitem); estateSettings.AddBan(bitem);
Scene.EstateDataService.StoreEstateSettings(estateSettings); estateSettings.RemoveEstateUser(user);
} changed[(int)estateSettings.EstateID] = estateSettings;
} }
} }
@ -837,10 +975,9 @@ namespace OpenSim.Region.CoreModules.World.Estate
item.BannedHostAddress = "0.0.0.0"; item.BannedHostAddress = "0.0.0.0";
item.BannedHostIPMask = "0.0.0.0"; item.BannedHostIPMask = "0.0.0.0";
Scene.RegionInfo.EstateSettings.AddBan(item); thisSettings.AddBan(item);
Scene.EstateDataService.StoreEstateSettings(Scene.RegionInfo.EstateSettings); thisSettings.RemoveEstateUser(user);
changed[thisEstateID] = thisSettings;
TriggerEstateInfoChange();
ScenePresence s = Scene.GetScenePresence(user); ScenePresence s = Scene.GetScenePresence(user);
if (s != null) if (s != null)
@ -854,24 +991,18 @@ namespace OpenSim.Region.CoreModules.World.Estate
} }
} }
} }
} }
else else
{ {
remote_client.SendAlertMessage("User is already on the region ban list"); remote_client.SendAlertMessage("User is already on the region ban list");
} }
//Scene.RegionInfo.regionBanlist.Add(Manager(user); //Scene.RegionInfo.regionBanlist.Add(Manager(user);
remote_client.SendBannedUserList(invoice, Scene.RegionInfo.EstateSettings.EstateBans, Scene.RegionInfo.EstateSettings.EstateID); if(needReply)
} sendAllowedOrBanList[remote_client] = invoice;
else
{
remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
} }
} }
if ((estateAccessType & 128) != 0) // Ban remove if ((estateAccessType & 128) != 0) // Ban remove
{
if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, false))
{ {
EstateBan[] banlistcheck = Scene.RegionInfo.EstateSettings.EstateBans; EstateBan[] banlistcheck = Scene.RegionInfo.EstateSettings.EstateBans;
@ -890,104 +1021,90 @@ namespace OpenSim.Region.CoreModules.World.Estate
if (alreadyInList && listitem != null) if (alreadyInList && listitem != null)
{ {
if ((estateAccessType & 1) != 0) // All estates if (doOtherEstates) // All estates
{ {
List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner); foreach (EstateSettings estateSettings in otherEstates)
EstateSettings estateSettings;
foreach (int estateID in estateIDs)
{ {
if (estateID != Scene.RegionInfo.EstateSettings.EstateID) if(!isadmin && !estateSettings.IsEstateManagerOrOwner(agentID))
{ continue;
estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
estateSettings.RemoveBan(user); estateSettings.RemoveBan(user);
Scene.EstateDataService.StoreEstateSettings(estateSettings); changed[(int)estateSettings.EstateID] = estateSettings;
}
} }
} }
Scene.RegionInfo.EstateSettings.RemoveBan(listitem.BannedUserID); thisSettings.RemoveBan(listitem.BannedUserID);
Scene.EstateDataService.StoreEstateSettings(Scene.RegionInfo.EstateSettings); changed[thisEstateID] = thisSettings;
TriggerEstateInfoChange();
} }
else else
{ {
remote_client.SendAlertMessage("User is not on the region ban list"); remote_client.SendAlertMessage("User is not on the region ban list");
} }
//Scene.RegionInfo.regionBanlist.Add(Manager(user); if(needReply)
remote_client.SendBannedUserList(invoice, Scene.RegionInfo.EstateSettings.EstateBans, Scene.RegionInfo.EstateSettings.EstateID); sendAllowedOrBanList[remote_client] = invoice;
} }
else
// last the ones only for owners of this region
if (!Scene.Permissions.CanIssueEstateCommand(agentID, true))
{ {
remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions"); remote_client.SendAlertMessage("Method EstateAccess Failed, you don't have permissions");
} continue;
} }
if ((estateAccessType & 256) != 0) // Manager add if ((estateAccessType & 256) != 0) // Manager add
{ {
if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true)) if(thisSettings.EstateManagersCount() >= (int)Constants.EstateAccessLimits.EstateManagers)
{ {
if ((estateAccessType & 1) != 0) // All estates if(!sentManagersFull)
{ {
List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner); sentManagersFull = true;
EstateSettings estateSettings; remote_client.SendAlertMessage("Estate Managers list is full");
foreach (int estateID in estateIDs)
{
if (estateID != Scene.RegionInfo.EstateSettings.EstateID)
{
estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
estateSettings.AddEstateManager(user);
Scene.EstateDataService.StoreEstateSettings(estateSettings);
} }
} }
}
Scene.RegionInfo.EstateSettings.AddEstateManager(user);
Scene.EstateDataService.StoreEstateSettings(Scene.RegionInfo.EstateSettings);
TriggerEstateInfoChange();
remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.EstateManagers, Scene.RegionInfo.EstateSettings.EstateManagers, Scene.RegionInfo.EstateSettings.EstateID);
}
else else
{ {
remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions"); if (doOtherEstates) // All estates
{
foreach (EstateSettings estateSettings in otherEstates)
{
if(!isadmin && !estateSettings.IsEstateOwner(agentID)) // redundante check?
continue;
if(estateSettings.EstateManagersCount() >= (int)Constants.EstateAccessLimits.EstateManagers)
continue;
estateSettings.AddEstateManager(user);
changed[(int)estateSettings.EstateID] = estateSettings;
}
}
thisSettings.AddEstateManager(user);
changed[thisEstateID] = thisSettings;
sendManagers[remote_client] = invoice;
} }
} }
if ((estateAccessType & 512) != 0) // Manager remove if ((estateAccessType & 512) != 0) // Manager remove
{ {
if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true)) if (doOtherEstates) // All estates
{ {
if ((estateAccessType & 1) != 0) // All estates foreach (EstateSettings estateSettings in otherEstates)
{ {
List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner); if(!isadmin && !estateSettings.IsEstateOwner(agentID))
EstateSettings estateSettings; continue;
foreach (int estateID in estateIDs)
{
if (estateID != Scene.RegionInfo.EstateSettings.EstateID)
{
estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
estateSettings.RemoveEstateManager(user); estateSettings.RemoveEstateManager(user);
Scene.EstateDataService.StoreEstateSettings(estateSettings); changed[(int)estateSettings.EstateID] = estateSettings;
}
} }
} }
Scene.RegionInfo.EstateSettings.RemoveEstateManager(user); thisSettings.RemoveEstateManager(user);
Scene.EstateDataService.StoreEstateSettings(Scene.RegionInfo.EstateSettings); changed[thisEstateID] = thisSettings;
TriggerEstateInfoChange(); sendManagers[remote_client] = invoice;
remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.EstateManagers, Scene.RegionInfo.EstateSettings.EstateManagers, Scene.RegionInfo.EstateSettings.EstateID);
}
else
{
remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
} }
} }
lock(deltareqLock)
runnigDeltaExec = false;
} }
public void HandleOnEstateManageTelehub(IClientAPI client, UUID invoice, UUID senderID, string cmd, uint param1) public void HandleOnEstateManageTelehub(IClientAPI client, UUID invoice, UUID senderID, string cmd, uint param1)