From de243802334c44967273be2d1455a5f191f75955 Mon Sep 17 00:00:00 2001
From: Justin Clarke Casey
Date: Mon, 23 Jun 2008 18:01:58 +0000
Subject: * 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
---
OpenSim/Framework/AgentInventory.cs | 53 ++++++-------
OpenSim/Framework/AssetBase.cs | 2 +-
OpenSim/Framework/AssetLandmark.cs | 3 +-
.../Filesystem/AssetLoaderFileSystem.cs | 2 -
.../Modules/World/Archiver/AssetsArchiver.cs | 1 -
.../Modules/World/Archiver/AssetsDearchiver.cs | 3 -
OpenSim/Region/Environment/Scenes/InnerScene.cs | 2 +-
.../Region/Environment/Scenes/Scene.Inventory.cs | 87 +++++++++++++---------
.../ScriptEngine/Common/LSL_BuiltIn_Commands.cs | 2 +-
9 files changed, 83 insertions(+), 72 deletions(-)
diff --git a/OpenSim/Framework/AgentInventory.cs b/OpenSim/Framework/AgentInventory.cs
index 61e8636..e3f078b 100644
--- a/OpenSim/Framework/AgentInventory.cs
+++ b/OpenSim/Framework/AgentInventory.cs
@@ -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;
}
}
-}
\ No newline at end of file
+}
diff --git a/OpenSim/Framework/AssetBase.cs b/OpenSim/Framework/AssetBase.cs
index 29d996b..5435a43 100644
--- a/OpenSim/Framework/AssetBase.cs
+++ b/OpenSim/Framework/AssetBase.cs
@@ -106,4 +106,4 @@ namespace OpenSim.Framework
set { _temporary = value; }
}
}
-}
\ No newline at end of file
+}
diff --git a/OpenSim/Framework/AssetLandmark.cs b/OpenSim/Framework/AssetLandmark.cs
index de3028b..004e472 100644
--- a/OpenSim/Framework/AssetLandmark.cs
+++ b/OpenSim/Framework/AssetLandmark.cs
@@ -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);
}
}
-}
\ No newline at end of file
+}
diff --git a/OpenSim/Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs b/OpenSim/Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs
index 7adcb4a..ba23d82 100644
--- a/OpenSim/Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs
+++ b/OpenSim/Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs
@@ -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);
}
}
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/AssetsArchiver.cs b/OpenSim/Region/Environment/Modules/World/Archiver/AssetsArchiver.cs
index 4f4a3c3..8b4708c 100644
--- a/OpenSim/Region/Environment/Modules/World/Archiver/AssetsArchiver.cs
+++ b/OpenSim/Region/Environment/Modules/World/Archiver/AssetsArchiver.cs
@@ -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();
}
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/AssetsDearchiver.cs b/OpenSim/Region/Environment/Modules/World/Archiver/AssetsDearchiver.cs
index 98364d3..527d544 100644
--- a/OpenSim/Region/Environment/Modules/World/Archiver/AssetsDearchiver.cs
+++ b/OpenSim/Region/Environment/Modules/World/Archiver/AssetsDearchiver.cs
@@ -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;
}
}
}
diff --git a/OpenSim/Region/Environment/Scenes/InnerScene.cs b/OpenSim/Region/Environment/Scenes/InnerScene.cs
index 7529d77..c0edaba 100644
--- a/OpenSim/Region/Environment/Scenes/InnerScene.cs
+++ b/OpenSim/Region/Environment/Scenes/InnerScene.cs
@@ -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);
}
}
diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
index ff62a3b..e6bae4c 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
@@ -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)
+ ///
+ /// Create a new asset data structure.
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ 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
}
}
+ ///
+ /// Create a new inventory item.
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
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);
}
///
@@ -616,9 +634,11 @@ namespace OpenSim.Region.Environment.Scenes
///
///
///
+ ///
///
- 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();
diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
index 4d80603..6f4e481 100644
--- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
+++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
@@ -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)
--
cgit v1.1