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

View File

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

View File

@ -42,7 +42,6 @@ namespace OpenSim.Framework
Data = a.Data; Data = a.Data;
FullID = a.FullID; FullID = a.FullID;
Type = a.Type; Type = a.Type;
InvType = a.InvType;
Name = a.Name; Name = a.Name;
Description = a.Description; Description = a.Description;
InternData(); InternData();
@ -58,4 +57,4 @@ namespace OpenSim.Framework
ulong.TryParse(parts[3].Substring(14, parts[3].Length - 14), out RegionHandle); 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 assetIdStr = source.Configs[i].GetString("assetID", LLUUID.Random().ToString());
string name = source.Configs[i].GetString("name", String.Empty); string name = source.Configs[i].GetString("name", String.Empty);
sbyte type = (sbyte) source.Configs[i].GetInt("assetType", 0); 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)); string assetPath = Path.Combine(dir, source.Configs[i].GetString("fileName", String.Empty));
AssetBase newAsset = CreateAsset(assetIdStr, name, assetPath, false); AssetBase newAsset = CreateAsset(assetIdStr, name, assetPath, false);
newAsset.Type = type; newAsset.Type = type;
newAsset.InvType = invType;
assets.Add(newAsset); assets.Add(newAsset);
} }
} }

View File

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

View File

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

View File

@ -433,7 +433,7 @@ namespace OpenSim.Region.Environment.Scenes
SceneObjectGroup group = (SceneObjectGroup)obj; SceneObjectGroup group = (SceneObjectGroup)obj;
group.DetachToInventoryPrep(); group.DetachToInventoryPrep();
m_log.Debug("[DETACH]: Saving attachpoint: " + ((uint)group.GetAttachmentPoint()).ToString()); 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); m_parentScene.DeleteSceneObject(group);
} }
} }

View File

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

View File

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