* Remove all use of asset.InvType, as outlined in mailing list discussion

* This is stage 1, the field will be removed from AssetType and the assets table if this change doesn't prove problematic
0.6.0-stable
Justin Clarke Casey 2008-06-23 18:01:58 +00:00
parent 8b6bd93d68
commit de24380233
9 changed files with 83 additions and 72 deletions

View File

@ -157,31 +157,32 @@ namespace OpenSim.Framework
return true;
}
public LLUUID AddToInventory(LLUUID folderID, AssetBase asset)
{
if (InventoryFolders.ContainsKey(folderID))
{
LLUUID NewItemID = LLUUID.Random();
InventoryItem Item = new InventoryItem();
Item.FolderID = folderID;
Item.OwnerID = AgentID;
Item.AssetID = asset.FullID;
Item.ItemID = NewItemID;
Item.Type = asset.Type;
Item.Name = asset.Name;
Item.Description = asset.Description;
Item.InvType = asset.InvType;
InventoryItems.Add(Item.ItemID, Item);
InventoryFolder Folder = InventoryFolders[Item.FolderID];
Folder.Items.Add(Item);
return (Item.ItemID);
}
else
{
return (null);
}
}
// FIXME: Unused, pending possible cleanup for this whole class.
// public LLUUID AddToInventory(LLUUID folderID, AssetBase asset)
// {
// if (InventoryFolders.ContainsKey(folderID))
// {
// LLUUID NewItemID = LLUUID.Random();
//
// InventoryItem Item = new InventoryItem();
// Item.FolderID = folderID;
// Item.OwnerID = AgentID;
// Item.AssetID = asset.FullID;
// Item.ItemID = NewItemID;
// Item.Type = asset.Type;
// Item.Name = asset.Name;
// Item.Description = asset.Description;
// Item.InvType = asset.InvType;
// InventoryItems.Add(Item.ItemID, Item);
// InventoryFolder Folder = InventoryFolders[Item.FolderID];
// Folder.Items.Add(Item);
// return (Item.ItemID);
// }
// else
// {
// return (null);
// }
// }
public bool DeleteFromInventory(LLUUID itemID)
{
@ -252,4 +253,4 @@ namespace OpenSim.Framework
return result;
}
}
}
}

View File

@ -106,4 +106,4 @@ namespace OpenSim.Framework
set { _temporary = value; }
}
}
}
}

View File

@ -42,7 +42,6 @@ namespace OpenSim.Framework
Data = a.Data;
FullID = a.FullID;
Type = a.Type;
InvType = a.InvType;
Name = a.Name;
Description = a.Description;
InternData();
@ -58,4 +57,4 @@ namespace OpenSim.Framework
ulong.TryParse(parts[3].Substring(14, parts[3].Length - 14), out RegionHandle);
}
}
}
}

View File

@ -137,13 +137,11 @@ namespace OpenSim.Framework.AssetLoader.Filesystem
string assetIdStr = source.Configs[i].GetString("assetID", LLUUID.Random().ToString());
string name = source.Configs[i].GetString("name", String.Empty);
sbyte type = (sbyte) source.Configs[i].GetInt("assetType", 0);
sbyte invType = (sbyte) source.Configs[i].GetInt("inventoryType", 0);
string assetPath = Path.Combine(dir, source.Configs[i].GetString("fileName", String.Empty));
AssetBase newAsset = CreateAsset(assetIdStr, name, assetPath, false);
newAsset.Type = type;
newAsset.InvType = invType;
assets.Add(newAsset);
}
}

View File

@ -96,7 +96,6 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
xtw.WriteElementString("name", asset.Name);
xtw.WriteElementString("description", asset.Description);
xtw.WriteElementString("asset-type", asset.Type.ToString());
xtw.WriteElementString("inventory-type", asset.InvType.ToString());
xtw.WriteEndElement();
}

View File

@ -109,7 +109,6 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
metadata.Name = reader.ReadElementString("name");
metadata.Description = reader.ReadElementString("description");
metadata.AssetType = Convert.ToSByte(reader.ReadElementString("asset-type"));
metadata.AssetType = Convert.ToSByte(reader.ReadElementString("inventory-type"));
m_metadata[filename] = metadata;
@ -161,7 +160,6 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
AssetBase asset = new AssetBase(new LLUUID(filename), metadata.Name);
asset.Description = metadata.Description;
asset.Type = metadata.AssetType;
asset.InvType = metadata.InventoryType;
asset.Data = data;
m_cache.AddAsset(asset);
@ -182,7 +180,6 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
public string Name;
public string Description;
public sbyte AssetType;
public sbyte InventoryType;
}
}
}

View File

@ -433,7 +433,7 @@ namespace OpenSim.Region.Environment.Scenes
SceneObjectGroup group = (SceneObjectGroup)obj;
group.DetachToInventoryPrep();
m_log.Debug("[DETACH]: Saving attachpoint: " + ((uint)group.GetAttachmentPoint()).ToString());
m_parentScene.updateKnownAsset(remoteClient, group, group.GetFromAssetID(),group.OwnerID);
m_parentScene.updateKnownAsset(remoteClient, group, group.GetFromAssetID(), group.OwnerID);
m_parentScene.DeleteSceneObject(group);
}
}

View File

@ -164,8 +164,7 @@ namespace OpenSim.Region.Environment.Scenes
if (item != null)
{
AssetBase asset =
CreateAsset(item.Name, item.Description, (sbyte) item.InvType,
(sbyte) item.AssetType, data);
CreateAsset(item.Name, item.Description, (sbyte)item.AssetType, data);
AssetCache.AddAsset(asset);
item.AssetID = asset.FullID;
@ -241,10 +240,7 @@ namespace OpenSim.Region.Environment.Scenes
return;
}
// Create new asset
// XXX Hardcoding the numbers is a temporary measure - need an enumeration for this
// There may well be one in libsecondlife
AssetBase asset = CreateAsset(item.Name, item.Description, 10, 10, data);
AssetBase asset = CreateAsset(item.Name, item.Description, (sbyte)AssetType.LSLText, data);
AssetCache.AddAsset(asset);
// Update item with new asset
@ -521,12 +517,14 @@ namespace OpenSim.Region.Environment.Scenes
if (remoteClient.AgentId == oldAgentID)
{
CreateNewInventoryItem(
remoteClient, newFolderID, callbackID, asset, item.BasePermissions, item.CurrentPermissions, item.EveryOnePermissions, item.NextPermissions);
remoteClient, newFolderID, callbackID, asset, (sbyte)item.InvType,
item.BasePermissions, item.CurrentPermissions, item.EveryOnePermissions, item.NextPermissions);
}
else
{
CreateNewInventoryItem(
remoteClient, newFolderID, callbackID, asset, item.NextPermissions, item.NextPermissions, item.EveryOnePermissions & item.NextPermissions, item.NextPermissions);
remoteClient, newFolderID, callbackID, asset, (sbyte)item.InvType,
item.NextPermissions, item.NextPermissions, item.EveryOnePermissions & item.NextPermissions, item.NextPermissions);
}
}
else
@ -537,15 +535,24 @@ namespace OpenSim.Region.Environment.Scenes
}
}
private AssetBase CreateAsset(string name, string description, sbyte invType, sbyte assetType, byte[] data)
/// <summary>
/// Create a new asset data structure.
/// </summary>
/// <param name="name"></param>
/// <param name="description"></param>
/// <param name="invType"></param>
/// <param name="assetType"></param>
/// <param name="data"></param>
/// <returns></returns>
private AssetBase CreateAsset(string name, string description, sbyte assetType, byte[] data)
{
AssetBase asset = new AssetBase();
asset.Name = name;
asset.Description = description;
asset.InvType = invType;
asset.Type = assetType;
asset.FullID = LLUUID.Random();
asset.Data = (data == null) ? new byte[1] : data;
return asset;
}
@ -603,10 +610,21 @@ namespace OpenSim.Region.Environment.Scenes
}
}
/// <summary>
/// Create a new inventory item.
/// </summary>
/// <param name="remoteClient"></param>
/// <param name="folderID"></param>
/// <param name="callbackID"></param>
/// <param name="asset"></param>
/// <param name="invType"></param>
/// <param name="nextOwnerMask"></param>
private void CreateNewInventoryItem(IClientAPI remoteClient, LLUUID folderID, uint callbackID,
AssetBase asset, uint nextOwnerMask)
AssetBase asset, sbyte invType, uint nextOwnerMask)
{
CreateNewInventoryItem(remoteClient, folderID, callbackID, asset, (uint)PermissionMask.All, (uint)PermissionMask.All, 0, nextOwnerMask);
CreateNewInventoryItem(
remoteClient, folderID, callbackID, asset, invType,
(uint)PermissionMask.All, (uint)PermissionMask.All, 0, nextOwnerMask);
}
/// <summary>
@ -616,9 +634,11 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="folderID"></param>
/// <param name="callbackID"></param>
/// <param name="asset"></param>
/// <param name="invType"></param>
/// <param name="nextOwnerMask"></param>
private void CreateNewInventoryItem(IClientAPI remoteClient, LLUUID folderID, uint callbackID,
AssetBase asset, uint baseMask, uint currentMask, uint everyoneMask, uint nextOwnerMask)
private void CreateNewInventoryItem(
IClientAPI remoteClient, LLUUID folderID, uint callbackID, AssetBase asset, sbyte invType,
uint baseMask, uint currentMask, uint everyoneMask, uint nextOwnerMask)
{
CachedUserInfo userInfo
= CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
@ -633,7 +653,7 @@ namespace OpenSim.Region.Environment.Scenes
item.Description = asset.Description;
item.Name = asset.Name;
item.AssetType = asset.Type;
item.InvType = asset.InvType;
item.InvType = invType;
item.Folder = folderID;
item.CurrentPermissions = currentMask;
item.NextPermissions = nextOwnerMask;
@ -692,10 +712,10 @@ namespace OpenSim.Region.Environment.Scenes
data=Encoding.ASCII.GetBytes(strdata);
}
AssetBase asset = CreateAsset(name, description, invType, assetType, data);
AssetBase asset = CreateAsset(name, description, assetType, data);
AssetCache.AddAsset(asset);
CreateNewInventoryItem(remoteClient, folderID, callbackID, asset, nextOwnerMask);
CreateNewInventoryItem(remoteClient, folderID, callbackID, asset, invType, nextOwnerMask);
}
else
{
@ -926,8 +946,7 @@ namespace OpenSim.Region.Environment.Scenes
public void UpdateTaskInventory(IClientAPI remoteClient, LLUUID transactionID, TaskInventoryItem itemInfo,
uint primLocalID)
{
LLUUID itemID=itemInfo.ItemID;
LLUUID folderID=itemInfo.ParentID;
LLUUID itemID = itemInfo.ItemID;
// Find the prim we're dealing with
SceneObjectPart part = GetSceneObjectPart(primLocalID);
@ -1057,7 +1076,7 @@ namespace OpenSim.Region.Environment.Scenes
if (part == null)
return;
AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.InvType, (sbyte)itemBase.AssetType, Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n}"));
AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n}"));
AssetCache.AddAsset(asset);
TaskInventoryItem taskItem=new TaskInventoryItem();
@ -1084,6 +1103,7 @@ namespace OpenSim.Region.Environment.Scenes
part.AddInventoryItem(taskItem);
part.GetProperties(remoteClient);
if (ExternalChecks.ExternalChecksCanRunScript(taskItem.AssetID, part.UUID, remoteClient.AgentId))
{
part.StartScript(taskItem);
@ -1160,12 +1180,12 @@ namespace OpenSim.Region.Environment.Scenes
CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
if (userInfo != null)
{
string searchFolder = "";
// string searchFolder = "";
if (DeRezPacket.AgentBlock.Destination == 6)
searchFolder = "Trash";
else if (DeRezPacket.AgentBlock.Destination == 9)
searchFolder = "Lost And Found";
// if (DeRezPacket.AgentBlock.Destination == 6)
// searchFolder = "Trash";
// else if (DeRezPacket.AgentBlock.Destination == 9)
// searchFolder = "Lost And Found";
// If we're deleting someone else's item, it goes back to their deleted items folder
// If we're returning someone's item, it goes back to the owner's Lost And Found folder.
@ -1196,8 +1216,7 @@ namespace OpenSim.Region.Environment.Scenes
AssetBase asset = CreateAsset(
((SceneObjectGroup) selectedEnt).GetPartName(selectedEnt.LocalId),
((SceneObjectGroup) selectedEnt).GetPartDescription(selectedEnt.LocalId),
(sbyte) InventoryType.Object,
(sbyte) AssetType.Object,
(sbyte)AssetType.Object,
Helpers.StringToField(sceneObjectXml));
AssetCache.AddAsset(asset);
@ -1214,7 +1233,7 @@ namespace OpenSim.Region.Environment.Scenes
item.Description = asset.Description;
item.Name = asset.Name;
item.AssetType = asset.Type;
item.InvType = asset.InvType;
item.InvType = (int)InventoryType.Object;
item.Folder = folderID;
if ((remoteClient.AgentId != objectGroup.RootPart.OwnerID) && ExternalChecks.ExternalChecksPropagatePermissions())
{
@ -1286,7 +1305,6 @@ namespace OpenSim.Region.Environment.Scenes
// search through folders to find the asset.
while (searchfolders.Count > 0)
{
InventoryFolderImpl fld = searchfolders.Dequeue();
lock (fld)
{
@ -1308,10 +1326,10 @@ namespace OpenSim.Region.Environment.Scenes
}
}
}
AssetBase asset = CreateAsset(
objectGroup.GetPartName(objectGroup.LocalId),
objectGroup.GetPartDescription(objectGroup.LocalId),
(sbyte)InventoryType.Object,
(sbyte)AssetType.Object,
Helpers.StringToField(sceneObjectXml));
AssetCache.AddAsset(asset);
@ -1324,7 +1342,7 @@ namespace OpenSim.Region.Environment.Scenes
item.Description = asset.Description;
item.Name = asset.Name;
item.AssetType = asset.Type;
item.InvType = asset.InvType;
item.InvType = (int)InventoryType.Object;
// Sticking it in root folder for now.. objects folder later?
@ -1369,7 +1387,6 @@ namespace OpenSim.Region.Environment.Scenes
AssetBase asset = CreateAsset(
objectGroup.GetPartName(objectGroup.LocalId),
objectGroup.GetPartDescription(objectGroup.LocalId),
(sbyte)InventoryType.Object,
(sbyte)AssetType.Object,
Helpers.StringToField(sceneObjectXml));
AssetCache.AddAsset(asset);
@ -1382,7 +1399,7 @@ namespace OpenSim.Region.Environment.Scenes
item.Description = asset.Description;
item.Name = asset.Name;
item.AssetType = asset.Type;
item.InvType = asset.InvType;
item.InvType = (int)InventoryType.Object;
// Sticking it in root folder for now.. objects folder later?
@ -1748,7 +1765,6 @@ namespace OpenSim.Region.Environment.Scenes
AssetBase asset = CreateAsset(
returnobjects[i].GetPartName(returnobjects[i].LocalId),
returnobjects[i].GetPartDescription(returnobjects[i].LocalId),
(sbyte)InventoryType.Object,
(sbyte)AssetType.Object,
Helpers.StringToField(sceneObjectXml));
AssetCache.AddAsset(asset);
@ -1761,8 +1777,9 @@ namespace OpenSim.Region.Environment.Scenes
item.Description = asset.Description;
item.Name = asset.Name;
item.AssetType = asset.Type;
item.InvType = asset.InvType;
item.InvType = (int)InventoryType.Object;
item.Folder = folderID;
if ((AgentId != returnobjects[i].RootPart.OwnerID) && ExternalChecks.ExternalChecksPropagatePermissions())
{
uint perms = returnobjects[i].GetEffectivePermissions();

View File

@ -2696,7 +2696,7 @@ namespace OpenSim.Region.ScriptEngine.Common
public void llGiveInventory(string destination, string inventory)
{
m_host.AddScriptLPS(1);
NotImplemented("llGiveInventory");
NotImplemented("llGiveInventory not yet oh no!");
}
public void llRemoveInventory(string item)