Add group permissions to agent inventory.

Contains a migration. May contain nuts.
Please back up your inventory data store. This revision changes the interface
version!! No older regions can connect to these new UGAIM, and the new regions
can't connect to the old UGAIM. Fixes a long-standing issue of permissions loss
Currently persisted on MySQL only.
0.6.1-post-fixes
Melanie Thielker 2008-11-14 18:54:38 +00:00
parent e3770cfee6
commit d66f3993de
9 changed files with 59 additions and 19 deletions

View File

@ -1329,6 +1329,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
rdata.writer.WriteStartElement(String.Empty, "Permissions", String.Empty);
rdata.writer.WriteAttributeString("current", String.Empty, i.CurrentPermissions.ToString("X"));
rdata.writer.WriteAttributeString("next", String.Empty, i.NextPermissions.ToString("X"));
rdata.writer.WriteAttributeString("group", String.Empty, i.GroupPermissions.ToString("X"));
rdata.writer.WriteAttributeString("everyone", String.Empty, i.EveryOnePermissions.ToString("X"));
rdata.writer.WriteAttributeString("base", String.Empty, i.BasePermissions.ToString("X"));
rdata.writer.WriteEndElement();
@ -1950,6 +1951,9 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
case "next" :
ic.NextPermissions = UInt32.Parse(ic.xml.Value, System.Globalization.NumberStyles.HexNumber);
break;
case "group" :
ic.GroupPermissions = UInt32.Parse(ic.xml.Value, System.Globalization.NumberStyles.HexNumber);
break;
case "everyone" :
ic.EveryOnePermissions = UInt32.Parse(ic.xml.Value, System.Globalization.NumberStyles.HexNumber);
break;
@ -2061,6 +2065,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
ic.Item.CurrentPermissions = ic.CurrentPermissions;
ic.Item.EveryOnePermissions = ic.EveryOnePermissions;
ic.Item.BasePermissions = ic.BasePermissions;
ic.Item.GroupPermissions = ic.GroupPermissions;
ic.Item.NextPermissions = ic.NextPermissions;
// If no type was specified for this item, we can attempt to
@ -2258,11 +2263,13 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
internal /*static*/ const uint DefaultNext = 0x82000;
internal /*static*/ const uint DefaultBase = 0x7FFFFFFF;
internal /*static*/ const uint DefaultEveryOne = 0x0;
internal /*static*/ const uint DefaultGroup = 0x0;
internal uint CurrentPermissions = 0x00;
internal uint NextPermissions = 0x00;
internal uint BasePermissions = 0x00;
internal uint EveryOnePermissions = 0x00;
internal uint GroupPermissions = 0x00;
internal XmlInventoryCollection()
{
@ -2286,6 +2293,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
CurrentPermissions = DefaultCurrent;
NextPermissions = DefaultNext;
BasePermissions = DefaultBase;
GroupPermissions = DefaultGroup;
EveryOnePermissions = DefaultEveryOne;
}

View File

@ -333,6 +333,7 @@ namespace OpenSim.Data.MySQL
item.InvType = (int) reader["invType"];
item.BasePermissions = (uint) reader["inventoryBasePermissions"];
item.EveryOnePermissions = (uint) reader["inventoryEveryOnePermissions"];
item.GroupPermissions = (uint) reader["inventoryGroupPermissions"];
item.SalePrice = (int) reader["salePrice"];
item.SaleType = Convert.ToByte(reader["saleType"]);
item.CreationDate = (int) reader["creationDate"];
@ -455,12 +456,12 @@ namespace OpenSim.Data.MySQL
string sql =
"REPLACE INTO inventoryitems (inventoryID, assetID, assetType, parentFolderID, avatarID, inventoryName"
+ ", inventoryDescription, inventoryNextPermissions, inventoryCurrentPermissions, invType"
+ ", creatorID, inventoryBasePermissions, inventoryEveryOnePermissions, salePrice, saleType"
+ ", creatorID, inventoryBasePermissions, inventoryEveryOnePermissions, inventoryGroupPermissions, salePrice, saleType"
+ ", creationDate, groupID, groupOwned, flags) VALUES ";
sql +=
"(?inventoryID, ?assetID, ?assetType, ?parentFolderID, ?avatarID, ?inventoryName, ?inventoryDescription"
+ ", ?inventoryNextPermissions, ?inventoryCurrentPermissions, ?invType, ?creatorID"
+ ", ?inventoryBasePermissions, ?inventoryEveryOnePermissions, ?salePrice, ?saleType, ?creationDate"
+ ", ?inventoryBasePermissions, ?inventoryEveryOnePermissions, ?inventoryGroupPermissions, ?salePrice, ?saleType, ?creationDate"
+ ", ?groupID, ?groupOwned, ?flags)";
try
@ -482,6 +483,7 @@ namespace OpenSim.Data.MySQL
result.Parameters.AddWithValue("?creatorID", item.Creator.ToString());
result.Parameters.AddWithValue("?inventoryBasePermissions", item.BasePermissions);
result.Parameters.AddWithValue("?inventoryEveryOnePermissions", item.EveryOnePermissions);
result.Parameters.AddWithValue("?inventoryGroupPermissions", item.GroupPermissions);
result.Parameters.AddWithValue("?salePrice", item.SalePrice);
result.Parameters.AddWithValue("?saleType", item.SaleType);
result.Parameters.AddWithValue("?creationDate", item.CreationDate);

View File

@ -74,6 +74,11 @@ namespace OpenSim.Framework
/// </summary>
private uint _everyOnePermissions;
/// <summary>
///
/// </summary>
private uint _groupPermissions;
/// <summary>
/// The folder this item is contained in
/// </summary>
@ -190,6 +195,12 @@ namespace OpenSim.Framework
set { _everyOnePermissions = value; }
}
public uint GroupPermissions
{
get { return _groupPermissions; }
set { _groupPermissions = value; }
}
public int AssetType
{
get { return _assetType; }

View File

@ -48,6 +48,6 @@ namespace OpenSim
/// of the code that is too old.
///
/// </value>
public readonly static int MajorInterfaceVersion = 0;
public readonly static int MajorInterfaceVersion = 1;
}
}

View File

@ -1561,10 +1561,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
descend.ItemData[i].OwnerID = item.Owner;
descend.ItemData[i].Type = (sbyte)item.AssetType;
//descend.ItemData[i].GroupID = new UUID("00000000-0000-0000-0000-000000000000");
descend.ItemData[i].GroupID = item.GroupID;
descend.ItemData[i].GroupOwned = item.GroupOwned;
descend.ItemData[i].GroupMask = 0;
descend.ItemData[i].GroupMask = item.GroupPermissions;
descend.ItemData[i].CreationDate = item.CreationDate;
descend.ItemData[i].SalePrice = item.SalePrice;
descend.ItemData[i].SaleType = item.SaleType;
@ -1708,10 +1707,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
inventoryReply.InventoryData[0].OwnerMask = item.CurrentPermissions;
inventoryReply.InventoryData[0].Type = (sbyte)item.AssetType;
//inventoryReply.InventoryData[0].GroupID = new UUID("00000000-0000-0000-0000-000000000000");
inventoryReply.InventoryData[0].GroupID = item.GroupID;
inventoryReply.InventoryData[0].GroupOwned = item.GroupOwned;
inventoryReply.InventoryData[0].GroupMask = 0;
inventoryReply.InventoryData[0].GroupMask = item.GroupPermissions;
inventoryReply.InventoryData[0].Flags = item.Flags;
inventoryReply.InventoryData[0].SalePrice = item.SalePrice;
inventoryReply.InventoryData[0].SaleType = item.SaleType;
@ -1763,10 +1761,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
bulkUpdate.ItemData[0].OwnerMask = item.CurrentPermissions;
bulkUpdate.ItemData[0].Type = (sbyte)item.AssetType;
//bulkUpdate.ItemData[0].GroupID = new UUID("00000000-0000-0000-0000-000000000000");
bulkUpdate.ItemData[0].GroupID = item.GroupID;
bulkUpdate.ItemData[0].GroupOwned = item.GroupOwned;
bulkUpdate.ItemData[0].GroupMask = 0;
bulkUpdate.ItemData[0].GroupMask = item.GroupPermissions;
bulkUpdate.ItemData[0].Flags = item.Flags;
bulkUpdate.ItemData[0].SalePrice = item.SalePrice;
bulkUpdate.ItemData[0].SaleType = item.SaleType;
@ -1811,10 +1808,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
InventoryReply.InventoryData[0].OwnerMask = Item.CurrentPermissions;
InventoryReply.InventoryData[0].Type = (sbyte)Item.AssetType;
//InventoryReply.InventoryData[0].GroupID = new UUID("00000000-0000-0000-0000-000000000000");
InventoryReply.InventoryData[0].GroupID = Item.GroupID;
InventoryReply.InventoryData[0].GroupOwned = Item.GroupOwned;
InventoryReply.InventoryData[0].GroupMask = 0;
InventoryReply.InventoryData[0].GroupMask = Item.GroupPermissions;
InventoryReply.InventoryData[0].Flags = Item.Flags;
InventoryReply.InventoryData[0].SalePrice = Item.SalePrice;
InventoryReply.InventoryData[0].SaleType = Item.SaleType;
@ -5213,6 +5209,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
itemUpd.Description = Util.FieldToString(update.InventoryData[i].Description);
itemUpd.GroupID = update.InventoryData[i].GroupID;
itemUpd.GroupOwned = update.InventoryData[i].GroupOwned;
itemUpd.GroupPermissions = update.InventoryData[i].GroupMask;
itemUpd.NextPermissions = update.InventoryData[i].NextOwnerMask;
itemUpd.EveryOnePermissions = update.InventoryData[i].EveryoneMask;
itemUpd.CreationDate = update.InventoryData[i].CreationDate;
@ -5419,6 +5416,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
item.CurrentPermissions = rezScriptx.InventoryBlock.OwnerMask;
item.EveryOnePermissions = rezScriptx.InventoryBlock.EveryoneMask;
item.NextPermissions = rezScriptx.InventoryBlock.NextOwnerMask;
item.GroupPermissions = rezScriptx.InventoryBlock.GroupMask;
item.GroupOwned = rezScriptx.InventoryBlock.GroupOwned;
item.GroupID = rezScriptx.InventoryBlock.GroupID;
item.AssetType = rezScriptx.InventoryBlock.Type;

View File

@ -293,6 +293,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
item.Folder = InventFolder;
item.BasePermissions = 0x7fffffff;
item.CurrentPermissions = 0x7fffffff;
item.GroupPermissions=0;
item.EveryOnePermissions=0;
item.NextPermissions = nextPerm;
item.Flags = (uint) wearableType;

View File

@ -355,11 +355,11 @@ namespace OpenSim.Region.Environment.Scenes
item.NextPermissions = itemUpd.NextPermissions;
item.CurrentPermissions |= 8; // Slam!
item.EveryOnePermissions = itemUpd.EveryOnePermissions;
item.GroupPermissions = itemUpd.GroupPermissions;
// TODO: Requires sanity checks
//item.GroupID = itemUpd.GroupID;
//item.GroupOwned = itemUpd.GroupOwned;
//item.CreationDate = itemUpd.CreationDate;
item.GroupID = itemUpd.GroupID;
item.GroupOwned = itemUpd.GroupOwned;
item.CreationDate = itemUpd.CreationDate;
// The client sends zero if its newly created?
if (itemUpd.CreationDate == 0)
@ -480,12 +480,14 @@ namespace OpenSim.Region.Environment.Scenes
itemCopy.NextPermissions = item.NextPermissions;
itemCopy.EveryOnePermissions = item.EveryOnePermissions & item.NextPermissions;
itemCopy.GroupPermissions = item.GroupPermissions & item.NextPermissions;
}
else
{
itemCopy.CurrentPermissions = item.CurrentPermissions;
itemCopy.NextPermissions = item.NextPermissions;
itemCopy.EveryOnePermissions = item.EveryOnePermissions & item.NextPermissions;
itemCopy.GroupPermissions = item.GroupPermissions & item.NextPermissions;
itemCopy.BasePermissions = item.BasePermissions;
}
itemCopy.GroupID = UUID.Zero;
@ -584,13 +586,13 @@ namespace OpenSim.Region.Environment.Scenes
{
CreateNewInventoryItem(
remoteClient, newFolderID, newName, item.Flags, callbackID, asset, (sbyte)item.InvType,
item.BasePermissions, item.CurrentPermissions, item.EveryOnePermissions, item.NextPermissions, Util.UnixTimeSinceEpoch());
item.BasePermissions, item.CurrentPermissions, item.EveryOnePermissions, item.NextPermissions, item.GroupPermissions, Util.UnixTimeSinceEpoch());
}
else
{
CreateNewInventoryItem(
remoteClient, newFolderID, newName, item.Flags, callbackID, asset, (sbyte)item.InvType,
item.NextPermissions, item.NextPermissions, item.EveryOnePermissions & item.NextPermissions, item.NextPermissions, Util.UnixTimeSinceEpoch());
item.NextPermissions, item.NextPermissions, item.EveryOnePermissions & item.NextPermissions, item.NextPermissions, item.GroupPermissions, Util.UnixTimeSinceEpoch());
}
}
else
@ -690,7 +692,7 @@ namespace OpenSim.Region.Environment.Scenes
{
CreateNewInventoryItem(
remoteClient, folderID, name, flags, callbackID, asset, invType,
(uint)PermissionMask.All, (uint)PermissionMask.All, 0, nextOwnerMask, creationDate);
(uint)PermissionMask.All, (uint)PermissionMask.All, 0, nextOwnerMask, 0, creationDate);
}
/// <summary>
@ -705,7 +707,7 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="creationDate"></param>
private void CreateNewInventoryItem(
IClientAPI remoteClient, UUID folderID, string name, uint flags, uint callbackID, AssetBase asset, sbyte invType,
uint baseMask, uint currentMask, uint everyoneMask, uint nextOwnerMask, int creationDate)
uint baseMask, uint currentMask, uint everyoneMask, uint nextOwnerMask, uint groupMask, int creationDate)
{
CachedUserInfo userInfo
= CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
@ -726,6 +728,7 @@ namespace OpenSim.Region.Environment.Scenes
item.CurrentPermissions = currentMask;
item.NextPermissions = nextOwnerMask;
item.EveryOnePermissions = everyoneMask;
item.GroupPermissions = groupMask;
item.BasePermissions = baseMask;
item.CreationDate = creationDate;
@ -978,6 +981,7 @@ namespace OpenSim.Region.Environment.Scenes
agentItem.CurrentPermissions = taskItem.NextPermissions | 8;
agentItem.NextPermissions = taskItem.NextPermissions;
agentItem.EveryOnePermissions = taskItem.EveryonePermissions & taskItem.NextPermissions;
agentItem.GroupPermissions = taskItem.GroupPermissions & taskItem.NextPermissions;
}
else
{
@ -985,6 +989,7 @@ namespace OpenSim.Region.Environment.Scenes
agentItem.CurrentPermissions = taskItem.CurrentPermissions;
agentItem.NextPermissions = taskItem.NextPermissions;
agentItem.EveryOnePermissions = taskItem.EveryonePermissions;
agentItem.GroupPermissions = taskItem.GroupPermissions;
}
if (!ExternalChecks.ExternalChecksBypassPermissions())
@ -1416,6 +1421,7 @@ namespace OpenSim.Region.Environment.Scenes
taskItem.BasePermissions = itemBase.BasePermissions;
taskItem.CurrentPermissions = itemBase.CurrentPermissions;
taskItem.EveryonePermissions = itemBase.EveryOnePermissions;
taskItem.GroupPermissions = itemBase.GroupPermissions;
taskItem.NextPermissions = itemBase.NextPermissions;
taskItem.GroupID = itemBase.GroupID;
taskItem.GroupPermissions = 0;
@ -1728,6 +1734,7 @@ namespace OpenSim.Region.Environment.Scenes
item.CurrentPermissions = item.BasePermissions;
item.NextPermissions = objectGroup.RootPart.NextOwnerMask;
item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask & objectGroup.RootPart.NextOwnerMask;
item.GroupPermissions = objectGroup.RootPart.GroupMask & objectGroup.RootPart.NextOwnerMask;
item.CurrentPermissions |= 8; // Slam!
}
else
@ -1736,6 +1743,7 @@ namespace OpenSim.Region.Environment.Scenes
item.CurrentPermissions = objectGroup.GetEffectivePermissions();
item.NextPermissions = objectGroup.RootPart.NextOwnerMask;
item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask;
item.GroupPermissions = objectGroup.RootPart.GroupMask;
}
// TODO: add the new fields (Flags, Sale info, etc)
@ -1876,6 +1884,7 @@ namespace OpenSim.Region.Environment.Scenes
item.CurrentPermissions = grp.RootPart.NextOwnerMask;
item.NextPermissions = grp.RootPart.NextOwnerMask;
item.EveryOnePermissions = grp.RootPart.EveryoneMask & grp.RootPart.NextOwnerMask;
item.GroupPermissions = grp.RootPart.GroupMask & grp.RootPart.NextOwnerMask;
}
else
{
@ -1883,6 +1892,7 @@ namespace OpenSim.Region.Environment.Scenes
item.CurrentPermissions = grp.RootPart.OwnerMask;
item.NextPermissions = grp.RootPart.NextOwnerMask;
item.EveryOnePermissions = grp.RootPart.EveryoneMask;
item.GroupPermissions = grp.RootPart.GroupMask;
}
item.CreationDate = Util.UnixTimeSinceEpoch();
@ -2041,6 +2051,7 @@ namespace OpenSim.Region.Environment.Scenes
{
part.EveryoneMask = item.EveryOnePermissions;
part.NextOwnerMask = item.NextPermissions;
part.GroupMask = 0; // DO NOT propagate here
}
}
group.ApplyNextOwnerPermissions();
@ -2059,6 +2070,8 @@ namespace OpenSim.Region.Environment.Scenes
{
part.EveryoneMask = item.EveryOnePermissions;
part.NextOwnerMask = item.NextPermissions;
part.GroupMask = 0; // DO NOT propagate here
}
}
@ -2282,6 +2295,7 @@ namespace OpenSim.Region.Environment.Scenes
item.CurrentPermissions = item.BasePermissions;
item.NextPermissions = returnobjects[i].RootPart.NextOwnerMask;
item.EveryOnePermissions = returnobjects[i].RootPart.EveryoneMask & returnobjects[i].RootPart.NextOwnerMask;
item.GroupPermissions = returnobjects[i].RootPart.GroupMask & returnobjects[i].RootPart.NextOwnerMask;
item.CurrentPermissions |= 8; // Slam!
}
else
@ -2290,6 +2304,7 @@ namespace OpenSim.Region.Environment.Scenes
item.CurrentPermissions = returnobjects[i].GetEffectivePermissions();
item.NextPermissions = returnobjects[i].RootPart.NextOwnerMask;
item.EveryOnePermissions = returnobjects[i].RootPart.EveryoneMask;
item.GroupPermissions = returnobjects[i].RootPart.GroupMask;
}
// TODO: add the new fields (Flags, Sale info, etc)

View File

@ -4301,6 +4301,8 @@ namespace OpenSim.Region.Environment.Scenes
item.NextPermissions = part.NextOwnerMask;
item.EveryOnePermissions = part.EveryoneMask &
part.NextOwnerMask;
item.GroupPermissions = part.GroupMask &
part.NextOwnerMask;
item.CurrentPermissions |= 8; // Slam!
item.CreationDate = Util.UnixTimeSinceEpoch();

View File

@ -166,6 +166,8 @@ namespace OpenSim.Region.Environment.Scenes
item.NextPermissions;
taskItem.EveryonePermissions = item.EveryOnePermissions &
item.NextPermissions;
taskItem.GroupPermissions = item.GroupPermissions &
item.NextPermissions;
taskItem.NextPermissions = item.NextPermissions;
taskItem.CurrentPermissions |= 8;
} else {
@ -173,6 +175,7 @@ namespace OpenSim.Region.Environment.Scenes
taskItem.CurrentPermissions = item.CurrentPermissions;
taskItem.CurrentPermissions |= 8;
taskItem.EveryonePermissions = item.EveryOnePermissions;
taskItem.GroupPermissions = item.GroupPermissions;
taskItem.NextPermissions = item.NextPermissions;
}