diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | 76 |
1 files changed, 33 insertions, 43 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 8fcfcc5..74b4e54 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 | private Dictionary<UUID, ArrayList> m_scriptErrors = new Dictionary<UUID, ArrayList>(); | 52 | private Dictionary<UUID, ArrayList> m_scriptErrors = new Dictionary<UUID, ArrayList>(); |
@@ -930,39 +931,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
930 | return -1; | 931 | return -1; |
931 | } | 932 | } |
932 | 933 | ||
933 | public string GetInventoryFileName() | 934 | private bool CreateInventoryFileName() |
934 | { | 935 | { |
935 | if (m_inventoryFileName == String.Empty) | 936 | if (m_inventoryFileName == String.Empty || |
936 | m_inventoryFileName = "inventory_" + UUID.Random().ToString() + ".tmp"; | 937 | m_inventoryFileNameSerial < m_inventorySerial) |
937 | if (m_inventoryFileNameSerial < m_inventorySerial) | ||
938 | { | 938 | { |
939 | m_inventoryFileName = "inventory_" + UUID.Random().ToString() + ".tmp"; | 939 | m_inventoryFileName = "inventory_" + UUID.Random().ToString() + ".tmp"; |
940 | } | ||
941 | return m_inventoryFileName; | ||
942 | } | ||
943 | |||
944 | /// <summary> | ||
945 | /// Return the name with which a client can request a xfer of this prim's inventory metadata | ||
946 | /// </summary> | ||
947 | /// <param name="client"></param> | ||
948 | /// <param name="localID"></param> | ||
949 | public bool GetInventoryFileName(IClientAPI client, uint localID) | ||
950 | { | ||
951 | // m_log.DebugFormat( | ||
952 | // "[PRIM INVENTORY]: Received request from client {0} for inventory file name of {1}, {2}", | ||
953 | // client.AgentId, Name, UUID); | ||
954 | |||
955 | if (m_inventorySerial > 0) | ||
956 | { | ||
957 | client.SendTaskInventory(m_part.UUID, (short)m_inventorySerial, | ||
958 | Utils.StringToBytes(GetInventoryFileName())); | ||
959 | return true; | 940 | return true; |
960 | } | 941 | } |
961 | else | 942 | |
962 | { | 943 | return false; |
963 | client.SendTaskInventory(m_part.UUID, 0, new byte[0]); | ||
964 | return false; | ||
965 | } | ||
966 | } | 944 | } |
967 | 945 | ||
968 | /// <summary> | 946 | /// <summary> |
@@ -971,19 +949,34 @@ namespace OpenSim.Region.Framework.Scenes | |||
971 | /// <param name="xferManager"></param> | 949 | /// <param name="xferManager"></param> |
972 | public void RequestInventoryFile(IClientAPI client, IXfer xferManager) | 950 | public void RequestInventoryFile(IClientAPI client, IXfer xferManager) |
973 | { | 951 | { |
974 | byte[] fileData = new byte[0]; | 952 | bool changed = CreateInventoryFileName(); |
975 | 953 | ||
976 | // Confusingly, the folder item has to be the object id, while the 'parent id' has to be zero. This matches | ||
977 | // what appears to happen in the Second Life protocol. If this isn't the case. then various functionality | ||
978 | // isn't available (such as drag from prim inventory to agent inventory) | ||
979 | InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero); | 954 | InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero); |
980 | 955 | ||
981 | bool includeAssets = false; | ||
982 | if (m_part.ParentGroup.Scene.Permissions.CanEditObjectInventory(m_part.UUID, client.AgentId)) | ||
983 | includeAssets = true; | ||
984 | |||
985 | lock (m_items) | 956 | lock (m_items) |
986 | { | 957 | { |
958 | if (m_inventorySerial == 0) // No inventory | ||
959 | { | ||
960 | client.SendTaskInventory(m_part.UUID, 0, new byte[0]); | ||
961 | return; | ||
962 | } | ||
963 | |||
964 | client.SendTaskInventory(m_part.UUID, (short)m_inventorySerial, | ||
965 | Util.StringToBytes256(m_inventoryFileName)); | ||
966 | |||
967 | if (!changed) | ||
968 | { | ||
969 | if (m_inventoryFileData.Length > 2) | ||
970 | { | ||
971 | xferManager.AddNewFile(m_inventoryFileName, | ||
972 | m_inventoryFileData); | ||
973 | } | ||
974 | } | ||
975 | |||
976 | bool includeAssets = false; | ||
977 | if (m_part.ParentGroup.Scene.Permissions.CanEditObjectInventory(m_part.UUID, client.AgentId)) | ||
978 | includeAssets = true; | ||
979 | |||
987 | foreach (TaskInventoryItem item in m_items.Values) | 980 | foreach (TaskInventoryItem item in m_items.Values) |
988 | { | 981 | { |
989 | UUID ownerID = item.OwnerID; | 982 | UUID ownerID = item.OwnerID; |
@@ -1032,17 +1025,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1032 | invString.AddSectionEnd(); | 1025 | invString.AddSectionEnd(); |
1033 | } | 1026 | } |
1034 | } | 1027 | } |
1035 | int count = m_items.Count; | ||
1036 | m_items.LockItemsForRead(false); | ||
1037 | 1028 | ||
1038 | fileData = Utils.StringToBytes(invString.BuildString); | 1029 | int count = m_items.Count; |
1039 | 1030 | ||
1040 | //m_log.Debug(Utils.BytesToString(fileData)); | 1031 | m_inventoryFileData = Utils.StringToBytes(invString.BuildString); |
1041 | //m_log.Debug("[PRIM INVENTORY]: RequestInventoryFile fileData: " + Utils.BytesToString(fileData)); | ||
1042 | 1032 | ||
1043 | if (fileData.Length > 2) | 1033 | if (m_inventoryFileData.Length > 2) |
1044 | { | 1034 | { |
1045 | xferManager.AddNewFile(m_inventoryFileName, fileData); | 1035 | xferManager.AddNewFile(m_inventoryFileName, m_inventoryFileData); |
1046 | } | 1036 | } |
1047 | } | 1037 | } |
1048 | 1038 | ||