diff options
author | Melanie | 2010-12-21 20:47:00 +0000 |
---|---|---|
committer | Melanie | 2010-12-21 20:49:31 +0000 |
commit | 043dace1184b14c1b07863c2ffabaf5e24fb53c4 (patch) | |
tree | 694712bc17b61db47a6a2033de4b17d46894ac96 /OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | |
parent | Shooting in the dark for solutions to the appearance problem (diff) | |
download | opensim-SC-043dace1184b14c1b07863c2ffabaf5e24fb53c4.zip opensim-SC-043dace1184b14c1b07863c2ffabaf5e24fb53c4.tar.gz opensim-SC-043dace1184b14c1b07863c2ffabaf5e24fb53c4.tar.bz2 opensim-SC-043dace1184b14c1b07863c2ffabaf5e24fb53c4.tar.xz |
Make prim inventories a bit more sane
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | 74 |
1 files changed, 33 insertions, 41 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 6a204c3..ac69f16 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | |||
@@ -46,6 +46,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
47 | 47 | ||
48 | private string m_inventoryFileName = String.Empty; | 48 | private string m_inventoryFileName = String.Empty; |
49 | private byte[] m_inventoryFileData = new byte[0]; | ||
49 | private int m_inventoryFileNameSerial = 0; | 50 | private int m_inventoryFileNameSerial = 0; |
50 | 51 | ||
51 | /// <value> | 52 | /// <value> |
@@ -765,39 +766,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
765 | return -1; | 766 | return -1; |
766 | } | 767 | } |
767 | 768 | ||
768 | public string GetInventoryFileName() | 769 | private bool CreateInventoryFileName() |
769 | { | 770 | { |
770 | if (m_inventoryFileName == String.Empty) | 771 | if (m_inventoryFileName == String.Empty || |
771 | m_inventoryFileName = "inventory_" + UUID.Random().ToString() + ".tmp"; | 772 | m_inventoryFileNameSerial < m_inventorySerial) |
772 | if (m_inventoryFileNameSerial < m_inventorySerial) | ||
773 | { | 773 | { |
774 | m_inventoryFileName = "inventory_" + UUID.Random().ToString() + ".tmp"; | 774 | m_inventoryFileName = "inventory_" + UUID.Random().ToString() + ".tmp"; |
775 | } | ||
776 | return m_inventoryFileName; | ||
777 | } | ||
778 | |||
779 | /// <summary> | ||
780 | /// Return the name with which a client can request a xfer of this prim's inventory metadata | ||
781 | /// </summary> | ||
782 | /// <param name="client"></param> | ||
783 | /// <param name="localID"></param> | ||
784 | public bool GetInventoryFileName(IClientAPI client, uint localID) | ||
785 | { | ||
786 | // m_log.DebugFormat( | ||
787 | // "[PRIM INVENTORY]: Received request from client {0} for inventory file name of {1}, {2}", | ||
788 | // client.AgentId, Name, UUID); | ||
789 | |||
790 | if (m_inventorySerial > 0) | ||
791 | { | ||
792 | client.SendTaskInventory(m_part.UUID, (short)m_inventorySerial, | ||
793 | Utils.StringToBytes(GetInventoryFileName())); | ||
794 | return true; | 775 | return true; |
795 | } | 776 | } |
796 | else | 777 | |
797 | { | 778 | return false; |
798 | client.SendTaskInventory(m_part.UUID, 0, new byte[0]); | ||
799 | return false; | ||
800 | } | ||
801 | } | 779 | } |
802 | 780 | ||
803 | /// <summary> | 781 | /// <summary> |
@@ -806,19 +784,34 @@ namespace OpenSim.Region.Framework.Scenes | |||
806 | /// <param name="xferManager"></param> | 784 | /// <param name="xferManager"></param> |
807 | public void RequestInventoryFile(IClientAPI client, IXfer xferManager) | 785 | public void RequestInventoryFile(IClientAPI client, IXfer xferManager) |
808 | { | 786 | { |
809 | byte[] fileData = new byte[0]; | 787 | bool changed = CreateInventoryFileName(); |
810 | 788 | ||
811 | // Confusingly, the folder item has to be the object id, while the 'parent id' has to be zero. This matches | ||
812 | // what appears to happen in the Second Life protocol. If this isn't the case. then various functionality | ||
813 | // isn't available (such as drag from prim inventory to agent inventory) | ||
814 | InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero); | 789 | InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero); |
815 | 790 | ||
816 | bool includeAssets = false; | ||
817 | if (m_part.ParentGroup.Scene.Permissions.CanEditObjectInventory(m_part.UUID, client.AgentId)) | ||
818 | includeAssets = true; | ||
819 | |||
820 | lock (m_items) | 791 | lock (m_items) |
821 | { | 792 | { |
793 | if (m_inventorySerial == 0) // No inventory | ||
794 | { | ||
795 | client.SendTaskInventory(m_part.UUID, 0, new byte[0]); | ||
796 | return; | ||
797 | } | ||
798 | |||
799 | client.SendTaskInventory(m_part.UUID, (short)m_inventorySerial, | ||
800 | Util.StringToBytes256(m_inventoryFileName)); | ||
801 | |||
802 | if (!changed) | ||
803 | { | ||
804 | if (m_inventoryFileData.Length > 2) | ||
805 | { | ||
806 | xferManager.AddNewFile(m_inventoryFileName, | ||
807 | m_inventoryFileData); | ||
808 | } | ||
809 | } | ||
810 | |||
811 | bool includeAssets = false; | ||
812 | if (m_part.ParentGroup.Scene.Permissions.CanEditObjectInventory(m_part.UUID, client.AgentId)) | ||
813 | includeAssets = true; | ||
814 | |||
822 | foreach (TaskInventoryItem item in m_items.Values) | 815 | foreach (TaskInventoryItem item in m_items.Values) |
823 | { | 816 | { |
824 | UUID ownerID = item.OwnerID; | 817 | UUID ownerID = item.OwnerID; |
@@ -868,14 +861,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
868 | } | 861 | } |
869 | } | 862 | } |
870 | 863 | ||
871 | fileData = Utils.StringToBytes(invString.BuildString); | 864 | int count = m_items.Count; |
872 | 865 | ||
873 | //m_log.Debug(Utils.BytesToString(fileData)); | 866 | m_inventoryFileData = Utils.StringToBytes(invString.BuildString); |
874 | //m_log.Debug("[PRIM INVENTORY]: RequestInventoryFile fileData: " + Utils.BytesToString(fileData)); | ||
875 | 867 | ||
876 | if (fileData.Length > 2) | 868 | if (m_inventoryFileData.Length > 2) |
877 | { | 869 | { |
878 | xferManager.AddNewFile(m_inventoryFileName, fileData); | 870 | xferManager.AddNewFile(m_inventoryFileName, m_inventoryFileData); |
879 | } | 871 | } |
880 | } | 872 | } |
881 | 873 | ||