Start of Task Inventory (ie prim's inventory). For now, you can only move scripts into a prim (from your user inventory) and although the script will now show up in the prims inventory, you can't make any changes to it (or delete it). Also a prim's inventory is currently not saved between restarts.

afrisby
MW 2007-08-22 14:37:54 +00:00
parent de2432b73e
commit b5921e2b95
9 changed files with 200 additions and 54 deletions

View File

@ -93,6 +93,7 @@ namespace OpenSim.Framework.Interfaces
public delegate void UDPAssetUploadRequest(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, byte[] data); public delegate void UDPAssetUploadRequest(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, byte[] data);
public delegate void XferReceive(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data); public delegate void XferReceive(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data);
public delegate void RequestXfer(IClientAPI remoteClient, ulong xferID, string fileName); public delegate void RequestXfer(IClientAPI remoteClient, ulong xferID, string fileName);
public delegate void ConfirmXfer(IClientAPI remoteClient, ulong xferID, uint packetID);
public interface IClientAPI public interface IClientAPI
{ {
@ -147,6 +148,7 @@ namespace OpenSim.Framework.Interfaces
event UDPAssetUploadRequest OnAssetUploadRequest; event UDPAssetUploadRequest OnAssetUploadRequest;
event XferReceive OnXferReceive; event XferReceive OnXferReceive;
event RequestXfer OnRequestXfer; event RequestXfer OnRequestXfer;
event ConfirmXfer OnConfirmXfer;
event RezScript OnRezScript; event RezScript OnRezScript;
event UUIDNameRequest OnNameFromUUIDRequest; event UUIDNameRequest OnNameFromUUIDRequest;

View File

@ -62,6 +62,7 @@ namespace OpenSim.Framework
public event UDPAssetUploadRequest OnAssetUploadRequest; public event UDPAssetUploadRequest OnAssetUploadRequest;
public event XferReceive OnXferReceive; public event XferReceive OnXferReceive;
public event RequestXfer OnRequestXfer; public event RequestXfer OnRequestXfer;
public event ConfirmXfer OnConfirmXfer;
public event RezScript OnRezScript; public event RezScript OnRezScript;
public event UUIDNameRequest OnNameFromUUIDRequest; public event UUIDNameRequest OnNameFromUUIDRequest;

View File

@ -91,6 +91,7 @@ namespace OpenSim.Region.ClientStack
public event UDPAssetUploadRequest OnAssetUploadRequest; public event UDPAssetUploadRequest OnAssetUploadRequest;
public event XferReceive OnXferReceive; public event XferReceive OnXferReceive;
public event RequestXfer OnRequestXfer; public event RequestXfer OnRequestXfer;
public event ConfirmXfer OnConfirmXfer;
public event RezScript OnRezScript; public event RezScript OnRezScript;
public event UUIDNameRequest OnNameFromUUIDRequest; public event UUIDNameRequest OnNameFromUUIDRequest;

View File

@ -383,6 +383,13 @@ namespace OpenSim.Region.ClientStack
OnXferReceive(this, xferRec.XferID.ID, xferRec.XferID.Packet, xferRec.DataPacket.Data); OnXferReceive(this, xferRec.XferID.ID, xferRec.XferID.Packet, xferRec.DataPacket.Data);
} }
break; break;
case PacketType.ConfirmXferPacket:
ConfirmXferPacketPacket confirmXfer = (ConfirmXferPacketPacket)Pack;
if (OnConfirmXfer != null)
{
OnConfirmXfer(this, confirmXfer.XferID.ID, confirmXfer.XferID.Packet);
}
break;
case PacketType.CreateInventoryFolder: case PacketType.CreateInventoryFolder:
if (this.OnCreateNewInventoryFolder != null) if (this.OnCreateNewInventoryFolder != null)
{ {

View File

@ -189,7 +189,6 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="primLocalID"></param> /// <param name="primLocalID"></param>
public void RequestTaskInventory(IClientAPI remoteClient, uint primLocalID) public void RequestTaskInventory(IClientAPI remoteClient, uint primLocalID)
{ {
bool hasPrim = false; bool hasPrim = false;
foreach (EntityBase ent in Entities.Values) foreach (EntityBase ent in Entities.Values)
{ {
@ -198,7 +197,11 @@ namespace OpenSim.Region.Environment.Scenes
hasPrim = ((SceneObjectGroup)ent).HasChildPrim(primLocalID); hasPrim = ((SceneObjectGroup)ent).HasChildPrim(primLocalID);
if (hasPrim != false) if (hasPrim != false)
{ {
((SceneObjectGroup)ent).GetPartInventoryFileName(remoteClient, primLocalID); bool fileChange = ((SceneObjectGroup)ent).GetPartInventoryFileName(remoteClient, primLocalID);
if (fileChange)
{
((SceneObjectGroup)ent).RequestInventoryFile(primLocalID, xferManager);
}
break; break;
} }
} }
@ -216,6 +219,7 @@ namespace OpenSim.Region.Environment.Scenes
if (item != null) if (item != null)
{ {
bool isTexture = false; bool isTexture = false;
bool rezzed = false;
if (item.invType == 0) if (item.invType == 0)
{ {
isTexture = true; isTexture = true;
@ -226,6 +230,7 @@ namespace OpenSim.Region.Environment.Scenes
string script = Util.FieldToString(rezAsset.Data); string script = Util.FieldToString(rezAsset.Data);
//Console.WriteLine("rez script "+script); //Console.WriteLine("rez script "+script);
this.EventManager.TriggerRezScript(localID, script); this.EventManager.TriggerRezScript(localID, script);
rezzed = true;
} }
else else
{ {
@ -236,8 +241,31 @@ namespace OpenSim.Region.Environment.Scenes
string script = Util.FieldToString(rezAsset.Data); string script = Util.FieldToString(rezAsset.Data);
// Console.WriteLine("rez script " + script); // Console.WriteLine("rez script " + script);
this.EventManager.TriggerRezScript(localID, script); this.EventManager.TriggerRezScript(localID, script);
rezzed = true;
} }
} }
if (rezzed)
{
bool hasPrim = false;
foreach (EntityBase ent in Entities.Values)
{
if (ent is SceneObjectGroup)
{
hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID);
if (hasPrim != false)
{
bool added = ((SceneObjectGroup)ent).AddInventoryItem(remoteClient, localID, item);
if (added)
{
userInfo.DeleteItem(remoteClient.AgentId, item);
remoteClient.SendRemoveInventoryItem(itemID);
}
}
}
}
}
} }
} }
} }

View File

@ -77,6 +77,7 @@ namespace OpenSim.Region.Environment.Scenes
protected AgentCircuitManager authenticateHandler; protected AgentCircuitManager authenticateHandler;
protected RegionCommsListener regionCommsHost; protected RegionCommsListener regionCommsHost;
protected CommunicationsManager commsManager; protected CommunicationsManager commsManager;
protected XferManagaer xferManager;
protected Dictionary<LLUUID, Caps> capsHandlers = new Dictionary<LLUUID, Caps>(); protected Dictionary<LLUUID, Caps> capsHandlers = new Dictionary<LLUUID, Caps>();
protected BaseHttpServer httpListener; protected BaseHttpServer httpListener;
@ -163,6 +164,7 @@ namespace OpenSim.Region.Environment.Scenes
m_scriptManager = new ScriptManager(this); m_scriptManager = new ScriptManager(this);
m_eventManager = new EventManager(); m_eventManager = new EventManager();
m_permissionManager = new PermissionManager(this); m_permissionManager = new PermissionManager(this);
xferManager = new XferManagaer();
m_eventManager.OnParcelPrimCountAdd += m_eventManager.OnParcelPrimCountAdd +=
m_LandManager.addPrimToLandPrimCounts; m_LandManager.addPrimToLandPrimCounts;
@ -711,6 +713,8 @@ namespace OpenSim.Region.Environment.Scenes
client.OnAssetUploadRequest += commsManager.TransactionsManager.HandleUDPUploadRequest; client.OnAssetUploadRequest += commsManager.TransactionsManager.HandleUDPUploadRequest;
client.OnXferReceive += commsManager.TransactionsManager.HandleXfer; client.OnXferReceive += commsManager.TransactionsManager.HandleXfer;
// client.OnRequestXfer += RequestXfer; // client.OnRequestXfer += RequestXfer;
client.OnRequestXfer += xferManager.RequestXfer;
client.OnConfirmXfer += xferManager.AckPacket;
client.OnRezScript += RezScript; client.OnRezScript += RezScript;
client.OnRequestAvatarProperties += RequestAvatarProperty; client.OnRequestAvatarProperties += RequestAvatarProperty;

View File

@ -10,6 +10,7 @@ using libsecondlife.Packets;
using OpenSim.Framework.Interfaces; using OpenSim.Framework.Interfaces;
using OpenSim.Framework.Types; using OpenSim.Framework.Types;
using OpenSim.Physics.Manager; using OpenSim.Physics.Manager;
using OpenSim.Framework.Data;
namespace OpenSim.Region.Environment.Scenes namespace OpenSim.Region.Environment.Scenes
{ {
@ -518,7 +519,7 @@ namespace OpenSim.Region.Environment.Scenes
proper.ObjectData[0].FolderID = LLUUID.Zero; proper.ObjectData[0].FolderID = LLUUID.Zero;
proper.ObjectData[0].FromTaskID = LLUUID.Zero; proper.ObjectData[0].FromTaskID = LLUUID.Zero;
proper.ObjectData[0].GroupID = LLUUID.Zero; proper.ObjectData[0].GroupID = LLUUID.Zero;
proper.ObjectData[0].InventorySerial = 0; proper.ObjectData[0].InventorySerial = (short) this.m_rootPart.InventorySerial;
proper.ObjectData[0].LastOwnerID = this.m_rootPart.LastOwnerID; proper.ObjectData[0].LastOwnerID = this.m_rootPart.LastOwnerID;
proper.ObjectData[0].ObjectID = this.UUID; proper.ObjectData[0].ObjectID = this.UUID;
proper.ObjectData[0].OwnerID = this.m_rootPart.OwnerID; proper.ObjectData[0].OwnerID = this.m_rootPart.OwnerID;
@ -601,27 +602,45 @@ namespace OpenSim.Region.Environment.Scenes
/// </summary> /// </summary>
/// <param name="remoteClient"></param> /// <param name="remoteClient"></param>
/// <param name="localID"></param> /// <param name="localID"></param>
public void GetPartInventoryFileName(IClientAPI remoteClient, uint localID) public bool GetPartInventoryFileName(IClientAPI remoteClient, uint localID)
{ {
SceneObjectPart part = this.GetChildPrim(localID); SceneObjectPart part = this.GetChildPrim(localID);
if (part != null) if (part != null)
{ {
part.GetInventoryFileName(remoteClient, localID); return part.GetInventoryFileName(remoteClient, localID);
} }
return false;
} }
/// <summary> public string RequestInventoryFile(uint localID, XferManagaer xferManager)
///
/// </summary>
/// <param name="remoteClient"></param>
/// <param name="partID"></param>
public void RequestInventoryFile(IClientAPI remoteClient, uint localID, ulong xferID)
{ {
SceneObjectPart part = this.GetChildPrim(localID); SceneObjectPart part = this.GetChildPrim(localID);
if (part != null) if (part != null)
{ {
part.RequestInventoryFile(remoteClient, xferID); return part.RequestInventoryFile(xferManager);
} }
return "";
}
public bool AddInventoryItem(IClientAPI remoteClient, uint localID, InventoryItemBase item)
{
SceneObjectPart part = this.GetChildPrim(localID);
if (part != null)
{
SceneObjectPart.TaskInventoryItem taskItem = new SceneObjectPart.TaskInventoryItem();
taskItem.item_id = item.inventoryID;
taskItem.asset_id = item.assetID;
taskItem.name = item.inventoryName;
taskItem.desc = item.inventoryDescription;
taskItem.owner_id = item.avatarID;
taskItem.creator_id = item.creatorsID;
taskItem.type = taskItem.AssetTypes[item.assetType];
taskItem.inv_type = taskItem.AssetTypes[item.invType];
part.AddInventoryItem(taskItem);
return true;
}
return false;
} }
/// <summary> /// <summary>

View File

@ -10,6 +10,7 @@ using libsecondlife.Packets;
using OpenSim.Framework.Interfaces; using OpenSim.Framework.Interfaces;
using OpenSim.Framework.Types; using OpenSim.Framework.Types;
using OpenSim.Region.Environment.Scenes.Scripting; using OpenSim.Region.Environment.Scenes.Scripting;
using OpenSim.Framework.Utilities;
namespace OpenSim.Region.Environment.Scenes namespace OpenSim.Region.Environment.Scenes
{ {
@ -18,6 +19,10 @@ namespace OpenSim.Region.Environment.Scenes
{ {
private const uint FULL_MASK_PERMISSIONS = 2147483647; private const uint FULL_MASK_PERMISSIONS = 2147483647;
private string m_inventoryFileName = "";
private LLUUID m_folderID = LLUUID.Zero;
protected Dictionary<LLUUID, TaskInventoryItem> TaskInventory = new Dictionary<LLUUID, TaskInventoryItem>();
public LLUUID CreatorID; public LLUUID CreatorID;
public LLUUID OwnerID; public LLUUID OwnerID;
@ -43,6 +48,16 @@ namespace OpenSim.Region.Environment.Scenes
#region Properties #region Properties
/// <summary>
/// Serial count for inventory file , used to tell if inventory has changed
/// no need for this to be part of Database backup
/// </summary>
protected uint m_inventorySerial = 0;
public uint InventorySerial
{
get { return m_inventorySerial; }
}
protected LLUUID m_uuid; protected LLUUID m_uuid;
public LLUUID UUID public LLUUID UUID
{ {
@ -221,6 +236,8 @@ namespace OpenSim.Region.Environment.Scenes
this.AngularVelocity = new LLVector3(0, 0, 0); this.AngularVelocity = new LLVector3(0, 0, 0);
this.Acceleration = new LLVector3(0, 0, 0); this.Acceleration = new LLVector3(0, 0, 0);
m_inventoryFileName = "taskinventory" + LLUUID.Random().ToString();
m_folderID = LLUUID.Random();
//temporary code just so the m_flags field doesn't give a compiler warning //temporary code just so the m_flags field doesn't give a compiler warning
if (m_flags == LLObject.ObjectFlags.AllowInventoryDrop) if (m_flags == LLObject.ObjectFlags.AllowInventoryDrop)
@ -396,9 +413,12 @@ namespace OpenSim.Region.Environment.Scenes
#endregion #endregion
#region Inventory #region Inventory
public void AddInventoryItem() public void AddInventoryItem(TaskInventoryItem item)
{ {
item.parent_id = m_folderID;
item.creation_date = 1000;
this.TaskInventory.Add(item.item_id, item);
this.m_inventorySerial++;
} }
public void RemoveInventoryItem() public void RemoveInventoryItem()
@ -410,54 +430,63 @@ namespace OpenSim.Region.Environment.Scenes
/// </summary> /// </summary>
/// <param name="client"></param> /// <param name="client"></param>
/// <param name="localID"></param> /// <param name="localID"></param>
public void GetInventoryFileName(IClientAPI client, uint localID) public bool GetInventoryFileName(IClientAPI client, uint localID)
{ {
if (localID == this.m_localID) if (localID == this.m_localID)
{ {
if (this.m_inventorySerial > 0)
{
client.SendTaskInventory(this.m_uuid, (short)m_inventorySerial, Helpers.StringToField(m_inventoryFileName));
return true;
}
else
{
client.SendTaskInventory(this.m_uuid, 0, new byte[0]);
return false;
}
//client.SendTaskInventory(this.m_uuid, 1, Helpers.StringToField("primInventory2")); //client.SendTaskInventory(this.m_uuid, 1, Helpers.StringToField("primInventory2"));
client.SendTaskInventory(this.m_uuid, 0, new byte[0]); //client.SendTaskInventory(this.m_uuid, 0, new byte[0]);
} }
return false;
} }
/// <summary> public string RequestInventoryFile(XferManagaer xferManager)
///
/// </summary>
/// <param name="client"></param>
/// <param name="xferID"></param>
public void RequestInventoryFile(IClientAPI client, ulong xferID)
{ {
// a test item byte[] fileData = new byte[0];
InventoryStringBuilder invString = new InventoryStringBuilder(); InventoryStringBuilder invString = new InventoryStringBuilder(m_folderID, this.UUID);
invString.AddItemStart(); foreach (TaskInventoryItem item in this.TaskInventory.Values)
invString.AddNameValueLine("item_id", LLUUID.Random().ToStringHyphenated()); {
invString.AddNameValueLine("parent_id", LLUUID.Zero.ToStringHyphenated()); invString.AddItemStart();
invString.AddNameValueLine("item_id", item.item_id.ToStringHyphenated());
invString.AddNameValueLine("parent_id", item.parent_id.ToStringHyphenated());
invString.AddPermissionsStart(); invString.AddPermissionsStart();
invString.AddNameValueLine("base_mask", "0x7FFFFFFF"); invString.AddNameValueLine("base_mask", "0x7FFFFFFF");
invString.AddNameValueLine("owner_mask", "0x7FFFFFFF"); invString.AddNameValueLine("owner_mask", "0x7FFFFFFF");
invString.AddNameValueLine("group_mask", "0x7FFFFFFF"); invString.AddNameValueLine("group_mask", "0x7FFFFFFF");
invString.AddNameValueLine("everyone_mask", "0x7FFFFFFF"); invString.AddNameValueLine("everyone_mask", "0x7FFFFFFF");
invString.AddNameValueLine("next_owner_mask", "0x7FFFFFFF"); invString.AddNameValueLine("next_owner_mask", "0x7FFFFFFF");
invString.AddNameValueLine("creator_id", client.AgentId.ToStringHyphenated()); invString.AddNameValueLine("creator_id", item.creator_id.ToStringHyphenated());
invString.AddNameValueLine("owner_id", client.AgentId.ToStringHyphenated()); invString.AddNameValueLine("owner_id", item.owner_id.ToStringHyphenated());
invString.AddNameValueLine("last_owner_id", LLUUID.Zero.ToStringHyphenated()); invString.AddNameValueLine("last_owner_id", item.last_owner_id.ToStringHyphenated());
invString.AddNameValueLine("group_id", LLUUID.Zero.ToStringHyphenated()); invString.AddNameValueLine("group_id", item.group_id.ToStringHyphenated());
invString.AddSectionEnd(); invString.AddSectionEnd();
invString.AddNameValueLine("asset_id", "00000000-0000-2222-3333-000000000001"); invString.AddNameValueLine("asset_id", item.asset_id.ToStringHyphenated());
invString.AddNameValueLine("type", "lsltext"); invString.AddNameValueLine("type", item.type);
invString.AddNameValueLine("inv_type", "lsltext"); invString.AddNameValueLine("inv_type", item.inv_type);
invString.AddNameValueLine("flags", "0x00"); invString.AddNameValueLine("flags", "0x00");
invString.AddNameValueLine("name", "Test inventory" + "|"); invString.AddNameValueLine("name", item.name + "|");
invString.AddNameValueLine("desc", "test description" + "|"); invString.AddNameValueLine("desc", item.desc + "|");
invString.AddNameValueLine("creation_date", "10000"); invString.AddNameValueLine("creation_date", item.creation_date.ToString());
invString.AddSectionEnd(); invString.AddSectionEnd();
}
byte[] fileInv = Helpers.StringToField(invString.BuildString); fileData = Helpers.StringToField(invString.BuildString);
byte[] data = new byte[fileInv.Length + 4]; if (fileData.Length > 2)
Array.Copy(Helpers.IntToBytes(fileInv.Length), 0, data, 0, 4); {
Array.Copy(fileInv, 0, data, 4, fileInv.Length); xferManager.AddNewFile(m_inventoryFileName, fileData);
client.SendXferPacket(xferID, 0 + 0x80000000, data); }
return "";
} }
#endregion #endregion
@ -643,9 +672,14 @@ namespace OpenSim.Region.Environment.Scenes
{ {
public string BuildString = ""; public string BuildString = "";
public InventoryStringBuilder() public InventoryStringBuilder(LLUUID folderID, LLUUID parentID)
{ {
BuildString += "\tinv_object\t0\n\t{\n";
this.AddNameValueLine("obj_id", folderID.ToStringHyphenated());
this.AddNameValueLine("parent_id", parentID.ToStringHyphenated());
this.AddNameValueLine("type", "category");
this.AddNameValueLine("name", "Contents");
this.AddSectionEnd();
} }
public void AddItemStart() public void AddItemStart()
@ -676,6 +710,55 @@ namespace OpenSim.Region.Environment.Scenes
BuildString += name + "\t"; BuildString += name + "\t";
BuildString += value + "\n"; BuildString += value + "\n";
} }
public void Close()
{
}
}
public class TaskInventoryItem
{
public string[] AssetTypes = new string[]
{
"texture",
"sound",
"",
"",
"",
"",
"",
"",
"",
"",
"lsltext",
""
};
public LLUUID item_id = LLUUID.Zero;
public LLUUID parent_id = LLUUID.Zero;
public uint base_mask = FULL_MASK_PERMISSIONS;
public uint owner_mask = FULL_MASK_PERMISSIONS;
public uint group_mask = FULL_MASK_PERMISSIONS;
public uint everyone_mask = FULL_MASK_PERMISSIONS;
public uint next_owner_mask = FULL_MASK_PERMISSIONS;
public LLUUID creator_id = LLUUID.Zero;
public LLUUID owner_id = LLUUID.Zero;
public LLUUID last_owner_id = LLUUID.Zero;
public LLUUID group_id = LLUUID.Zero;
public LLUUID asset_id = LLUUID.Zero;
public string type = "";
public string inv_type = "";
public uint flags = 0;
public string name = "";
public string desc = "";
public uint creation_date = 0;
public string FileName = "";
public TaskInventoryItem()
{
FileName = "taskItem" + LLUUID.Random().ToString();
}
} }
} }
} }

View File

@ -76,6 +76,7 @@ namespace SimpleApp
public event UDPAssetUploadRequest OnAssetUploadRequest; public event UDPAssetUploadRequest OnAssetUploadRequest;
public event XferReceive OnXferReceive; public event XferReceive OnXferReceive;
public event RequestXfer OnRequestXfer; public event RequestXfer OnRequestXfer;
public event ConfirmXfer OnConfirmXfer;
public event RezScript OnRezScript; public event RezScript OnRezScript;
public event UUIDNameRequest OnNameFromUUIDRequest; public event UUIDNameRequest OnNameFromUUIDRequest;