diff options
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.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Environment/Scenes/SceneObjectPart.cs | 173 |
1 files changed, 128 insertions, 45 deletions
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs index 904b158..5fa79fb 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs | |||
@@ -10,6 +10,7 @@ using libsecondlife.Packets; | |||
10 | using OpenSim.Framework.Interfaces; | 10 | using OpenSim.Framework.Interfaces; |
11 | using OpenSim.Framework.Types; | 11 | using OpenSim.Framework.Types; |
12 | using OpenSim.Region.Environment.Scenes.Scripting; | 12 | using OpenSim.Region.Environment.Scenes.Scripting; |
13 | using OpenSim.Framework.Utilities; | ||
13 | 14 | ||
14 | namespace OpenSim.Region.Environment.Scenes | 15 | namespace OpenSim.Region.Environment.Scenes |
15 | { | 16 | { |
@@ -18,6 +19,10 @@ namespace OpenSim.Region.Environment.Scenes | |||
18 | { | 19 | { |
19 | private const uint FULL_MASK_PERMISSIONS = 2147483647; | 20 | private const uint FULL_MASK_PERMISSIONS = 2147483647; |
20 | 21 | ||
22 | private string m_inventoryFileName = ""; | ||
23 | private LLUUID m_folderID = LLUUID.Zero; | ||
24 | |||
25 | protected Dictionary<LLUUID, TaskInventoryItem> TaskInventory = new Dictionary<LLUUID, TaskInventoryItem>(); | ||
21 | 26 | ||
22 | public LLUUID CreatorID; | 27 | public LLUUID CreatorID; |
23 | public LLUUID OwnerID; | 28 | public LLUUID OwnerID; |
@@ -43,6 +48,16 @@ namespace OpenSim.Region.Environment.Scenes | |||
43 | 48 | ||
44 | #region Properties | 49 | #region Properties |
45 | 50 | ||
51 | /// <summary> | ||
52 | /// Serial count for inventory file , used to tell if inventory has changed | ||
53 | /// no need for this to be part of Database backup | ||
54 | /// </summary> | ||
55 | protected uint m_inventorySerial = 0; | ||
56 | public uint InventorySerial | ||
57 | { | ||
58 | get { return m_inventorySerial; } | ||
59 | } | ||
60 | |||
46 | protected LLUUID m_uuid; | 61 | protected LLUUID m_uuid; |
47 | public LLUUID UUID | 62 | public LLUUID UUID |
48 | { | 63 | { |
@@ -221,6 +236,8 @@ namespace OpenSim.Region.Environment.Scenes | |||
221 | this.AngularVelocity = new LLVector3(0, 0, 0); | 236 | this.AngularVelocity = new LLVector3(0, 0, 0); |
222 | this.Acceleration = new LLVector3(0, 0, 0); | 237 | this.Acceleration = new LLVector3(0, 0, 0); |
223 | 238 | ||
239 | m_inventoryFileName = "taskinventory" + LLUUID.Random().ToString(); | ||
240 | m_folderID = LLUUID.Random(); | ||
224 | 241 | ||
225 | //temporary code just so the m_flags field doesn't give a compiler warning | 242 | //temporary code just so the m_flags field doesn't give a compiler warning |
226 | if (m_flags == LLObject.ObjectFlags.AllowInventoryDrop) | 243 | if (m_flags == LLObject.ObjectFlags.AllowInventoryDrop) |
@@ -396,9 +413,12 @@ namespace OpenSim.Region.Environment.Scenes | |||
396 | #endregion | 413 | #endregion |
397 | 414 | ||
398 | #region Inventory | 415 | #region Inventory |
399 | public void AddInventoryItem() | 416 | public void AddInventoryItem(TaskInventoryItem item) |
400 | { | 417 | { |
401 | 418 | item.parent_id = m_folderID; | |
419 | item.creation_date = 1000; | ||
420 | this.TaskInventory.Add(item.item_id, item); | ||
421 | this.m_inventorySerial++; | ||
402 | } | 422 | } |
403 | 423 | ||
404 | public void RemoveInventoryItem() | 424 | public void RemoveInventoryItem() |
@@ -410,54 +430,63 @@ namespace OpenSim.Region.Environment.Scenes | |||
410 | /// </summary> | 430 | /// </summary> |
411 | /// <param name="client"></param> | 431 | /// <param name="client"></param> |
412 | /// <param name="localID"></param> | 432 | /// <param name="localID"></param> |
413 | public void GetInventoryFileName(IClientAPI client, uint localID) | 433 | public bool GetInventoryFileName(IClientAPI client, uint localID) |
414 | { | 434 | { |
415 | if (localID == this.m_localID) | 435 | if (localID == this.m_localID) |
416 | { | 436 | { |
437 | if (this.m_inventorySerial > 0) | ||
438 | { | ||
439 | client.SendTaskInventory(this.m_uuid, (short)m_inventorySerial, Helpers.StringToField(m_inventoryFileName)); | ||
440 | return true; | ||
441 | } | ||
442 | else | ||
443 | { | ||
444 | client.SendTaskInventory(this.m_uuid, 0, new byte[0]); | ||
445 | return false; | ||
446 | } | ||
417 | //client.SendTaskInventory(this.m_uuid, 1, Helpers.StringToField("primInventory2")); | 447 | //client.SendTaskInventory(this.m_uuid, 1, Helpers.StringToField("primInventory2")); |
418 | client.SendTaskInventory(this.m_uuid, 0, new byte[0]); | 448 | //client.SendTaskInventory(this.m_uuid, 0, new byte[0]); |
419 | } | 449 | } |
450 | return false; | ||
420 | } | 451 | } |
421 | 452 | ||
422 | /// <summary> | 453 | public string RequestInventoryFile(XferManagaer xferManager) |
423 | /// | 454 | { |
424 | /// </summary> | 455 | byte[] fileData = new byte[0]; |
425 | /// <param name="client"></param> | 456 | InventoryStringBuilder invString = new InventoryStringBuilder(m_folderID, this.UUID); |
426 | /// <param name="xferID"></param> | 457 | foreach (TaskInventoryItem item in this.TaskInventory.Values) |
427 | public void RequestInventoryFile(IClientAPI client, ulong xferID) | 458 | { |
428 | { | 459 | invString.AddItemStart(); |
429 | // a test item | 460 | invString.AddNameValueLine("item_id", item.item_id.ToStringHyphenated()); |
430 | InventoryStringBuilder invString = new InventoryStringBuilder(); | 461 | invString.AddNameValueLine("parent_id", item.parent_id.ToStringHyphenated()); |
431 | invString.AddItemStart(); | 462 | |
432 | invString.AddNameValueLine("item_id", LLUUID.Random().ToStringHyphenated()); | 463 | invString.AddPermissionsStart(); |
433 | invString.AddNameValueLine("parent_id", LLUUID.Zero.ToStringHyphenated()); | 464 | invString.AddNameValueLine("base_mask", "0x7FFFFFFF"); |
434 | 465 | invString.AddNameValueLine("owner_mask", "0x7FFFFFFF"); | |
435 | invString.AddPermissionsStart(); | 466 | invString.AddNameValueLine("group_mask", "0x7FFFFFFF"); |
436 | invString.AddNameValueLine("base_mask", "0x7FFFFFFF"); | 467 | invString.AddNameValueLine("everyone_mask", "0x7FFFFFFF"); |
437 | invString.AddNameValueLine("owner_mask", "0x7FFFFFFF"); | 468 | invString.AddNameValueLine("next_owner_mask", "0x7FFFFFFF"); |
438 | invString.AddNameValueLine("group_mask", "0x7FFFFFFF"); | 469 | invString.AddNameValueLine("creator_id", item.creator_id.ToStringHyphenated()); |
439 | invString.AddNameValueLine("everyone_mask", "0x7FFFFFFF"); | 470 | invString.AddNameValueLine("owner_id", item.owner_id.ToStringHyphenated()); |
440 | invString.AddNameValueLine("next_owner_mask", "0x7FFFFFFF"); | 471 | invString.AddNameValueLine("last_owner_id", item.last_owner_id.ToStringHyphenated()); |
441 | invString.AddNameValueLine("creator_id", client.AgentId.ToStringHyphenated()); | 472 | invString.AddNameValueLine("group_id", item.group_id.ToStringHyphenated()); |
442 | invString.AddNameValueLine("owner_id", client.AgentId.ToStringHyphenated()); | 473 | invString.AddSectionEnd(); |
443 | invString.AddNameValueLine("last_owner_id", LLUUID.Zero.ToStringHyphenated()); | 474 | |
444 | invString.AddNameValueLine("group_id", LLUUID.Zero.ToStringHyphenated()); | 475 | invString.AddNameValueLine("asset_id", item.asset_id.ToStringHyphenated()); |
445 | invString.AddSectionEnd(); | 476 | invString.AddNameValueLine("type", item.type); |
446 | 477 | invString.AddNameValueLine("inv_type", item.inv_type); | |
447 | invString.AddNameValueLine("asset_id", "00000000-0000-2222-3333-000000000001"); | 478 | invString.AddNameValueLine("flags", "0x00"); |
448 | invString.AddNameValueLine("type", "lsltext"); | 479 | invString.AddNameValueLine("name", item.name + "|"); |
449 | invString.AddNameValueLine("inv_type", "lsltext"); | 480 | invString.AddNameValueLine("desc", item.desc + "|"); |
450 | invString.AddNameValueLine("flags", "0x00"); | 481 | invString.AddNameValueLine("creation_date", item.creation_date.ToString()); |
451 | invString.AddNameValueLine("name", "Test inventory" + "|"); | 482 | invString.AddSectionEnd(); |
452 | invString.AddNameValueLine("desc", "test description" + "|"); | 483 | } |
453 | invString.AddNameValueLine("creation_date", "10000"); | 484 | fileData = Helpers.StringToField(invString.BuildString); |
454 | invString.AddSectionEnd(); | 485 | if (fileData.Length > 2) |
455 | 486 | { | |
456 | byte[] fileInv = Helpers.StringToField(invString.BuildString); | 487 | xferManager.AddNewFile(m_inventoryFileName, fileData); |
457 | byte[] data = new byte[fileInv.Length + 4]; | 488 | } |
458 | Array.Copy(Helpers.IntToBytes(fileInv.Length), 0, data, 0, 4); | 489 | return ""; |
459 | Array.Copy(fileInv, 0, data, 4, fileInv.Length); | ||
460 | client.SendXferPacket(xferID, 0 + 0x80000000, data); | ||
461 | } | 490 | } |
462 | #endregion | 491 | #endregion |
463 | 492 | ||
@@ -643,9 +672,14 @@ namespace OpenSim.Region.Environment.Scenes | |||
643 | { | 672 | { |
644 | public string BuildString = ""; | 673 | public string BuildString = ""; |
645 | 674 | ||
646 | public InventoryStringBuilder() | 675 | public InventoryStringBuilder(LLUUID folderID, LLUUID parentID) |
647 | { | 676 | { |
648 | 677 | BuildString += "\tinv_object\t0\n\t{\n"; | |
678 | this.AddNameValueLine("obj_id", folderID.ToStringHyphenated()); | ||
679 | this.AddNameValueLine("parent_id", parentID.ToStringHyphenated()); | ||
680 | this.AddNameValueLine("type", "category"); | ||
681 | this.AddNameValueLine("name", "Contents"); | ||
682 | this.AddSectionEnd(); | ||
649 | } | 683 | } |
650 | 684 | ||
651 | public void AddItemStart() | 685 | public void AddItemStart() |
@@ -676,6 +710,55 @@ namespace OpenSim.Region.Environment.Scenes | |||
676 | BuildString += name + "\t"; | 710 | BuildString += name + "\t"; |
677 | BuildString += value + "\n"; | 711 | BuildString += value + "\n"; |
678 | } | 712 | } |
713 | |||
714 | public void Close() | ||
715 | { | ||
716 | } | ||
717 | } | ||
718 | |||
719 | public class TaskInventoryItem | ||
720 | { | ||
721 | public string[] AssetTypes = new string[] | ||
722 | { | ||
723 | "texture", | ||
724 | "sound", | ||
725 | "", | ||
726 | "", | ||
727 | "", | ||
728 | "", | ||
729 | "", | ||
730 | "", | ||
731 | "", | ||
732 | "", | ||
733 | "lsltext", | ||
734 | "" | ||
735 | }; | ||
736 | public LLUUID item_id = LLUUID.Zero; | ||
737 | public LLUUID parent_id = LLUUID.Zero; | ||
738 | |||
739 | public uint base_mask = FULL_MASK_PERMISSIONS; | ||
740 | public uint owner_mask = FULL_MASK_PERMISSIONS; | ||
741 | public uint group_mask = FULL_MASK_PERMISSIONS; | ||
742 | public uint everyone_mask = FULL_MASK_PERMISSIONS; | ||
743 | public uint next_owner_mask = FULL_MASK_PERMISSIONS; | ||
744 | public LLUUID creator_id = LLUUID.Zero; | ||
745 | public LLUUID owner_id = LLUUID.Zero; | ||
746 | public LLUUID last_owner_id = LLUUID.Zero; | ||
747 | public LLUUID group_id = LLUUID.Zero; | ||
748 | |||
749 | public LLUUID asset_id = LLUUID.Zero; | ||
750 | public string type = ""; | ||
751 | public string inv_type = ""; | ||
752 | public uint flags = 0; | ||
753 | public string name = ""; | ||
754 | public string desc = ""; | ||
755 | public uint creation_date = 0; | ||
756 | public string FileName = ""; | ||
757 | |||
758 | public TaskInventoryItem() | ||
759 | { | ||
760 | FileName = "taskItem" + LLUUID.Random().ToString(); | ||
761 | } | ||
679 | } | 762 | } |
680 | } | 763 | } |
681 | } | 764 | } |