aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorMelanie2010-12-21 20:47:00 +0000
committerMelanie2010-12-21 20:47:00 +0000
commit2f84f2171fb7e17f6c336a4e6db9a04ad822704a (patch)
tree8e83f98605b7dbb30960d0aa5ecf64d0d800a0ad /OpenSim/Region
parentMerge branch 'master' into careminster-presence-refactor (diff)
downloadopensim-SC_OLD-2f84f2171fb7e17f6c336a4e6db9a04ad822704a.zip
opensim-SC_OLD-2f84f2171fb7e17f6c336a4e6db9a04ad822704a.tar.gz
opensim-SC_OLD-2f84f2171fb7e17f6c336a4e6db9a04ad822704a.tar.bz2
opensim-SC_OLD-2f84f2171fb7e17f6c336a4e6db9a04ad822704a.tar.xz
Make prim inventories a bit more sane
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Framework/Interfaces/IEntityInventory.cs7
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs23
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs43
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs76
4 files changed, 39 insertions, 110 deletions
diff --git a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
index ed40da9..4b17b9a 100644
--- a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
+++ b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
@@ -196,13 +196,6 @@ namespace OpenSim.Region.Framework.Interfaces
196 int RemoveInventoryItem(UUID itemID); 196 int RemoveInventoryItem(UUID itemID);
197 197
198 /// <summary> 198 /// <summary>
199 /// Return the name with which a client can request a xfer of this prim's inventory metadata
200 /// </summary>
201 string GetInventoryFileName();
202
203 bool GetInventoryFileName(IClientAPI client, uint localID);
204
205 /// <summary>
206 /// Serialize all the metadata for the items in this prim's inventory ready for sending to the client 199 /// Serialize all the metadata for the items in this prim's inventory ready for sending to the client
207 /// </summary> 200 /// </summary>
208 /// <param name="xferManager"></param> 201 /// <param name="xferManager"></param>
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index a1f1ea5..47c574a 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -951,23 +951,12 @@ namespace OpenSim.Region.Framework.Scenes
951 /// <param name="primLocalID"></param> 951 /// <param name="primLocalID"></param>
952 public void RequestTaskInventory(IClientAPI remoteClient, uint primLocalID) 952 public void RequestTaskInventory(IClientAPI remoteClient, uint primLocalID)
953 { 953 {
954 SceneObjectGroup group = GetGroupByPrim(primLocalID); 954 SceneObjectPart part = GetSceneObjectPart(primLocalID);
955 if (group != null) 955 if (part == null)
956 { 956 return;
957 bool fileChange = group.GetPartInventoryFileName(remoteClient, primLocalID); 957
958 if (fileChange) 958 if (XferManager != null)
959 { 959 part.Inventory.RequestInventoryFile(remoteClient, XferManager);
960 if (XferManager != null)
961 {
962 group.RequestInventoryFile(remoteClient, primLocalID, XferManager);
963 }
964 }
965 }
966 else
967 {
968 m_log.ErrorFormat(
969 "[PRIM INVENTORY]: Inventory requested of prim {0} which doesn't exist", primLocalID);
970 }
971 } 960 }
972 961
973 /// <summary> 962 /// <summary>
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
index 6cc7231..50521c4 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
@@ -77,49 +77,6 @@ namespace OpenSim.Region.Framework.Scenes
77 } 77 }
78 78
79 /// <summary> 79 /// <summary>
80 ///
81 /// </summary>
82 /// <param name="remoteClient"></param>
83 /// <param name="localID"></param>
84 public bool GetPartInventoryFileName(IClientAPI remoteClient, uint localID)
85 {
86 SceneObjectPart part = GetChildPart(localID);
87 if (part != null)
88 {
89 return part.Inventory.GetInventoryFileName(remoteClient, localID);
90 }
91 else
92 {
93 m_log.ErrorFormat(
94 "[PRIM INVENTORY]: " +
95 "Couldn't find part {0} in object group {1}, {2} to retreive prim inventory",
96 localID, Name, UUID);
97 }
98 return false;
99 }
100
101 /// <summary>
102 /// Return serialized inventory metadata for the given constituent prim
103 /// </summary>
104 /// <param name="localID"></param>
105 /// <param name="xferManager"></param>
106 public void RequestInventoryFile(IClientAPI client, uint localID, IXfer xferManager)
107 {
108 SceneObjectPart part = GetChildPart(localID);
109 if (part != null)
110 {
111 part.Inventory.RequestInventoryFile(client, xferManager);
112 }
113 else
114 {
115 m_log.ErrorFormat(
116 "[PRIM INVENTORY]: " +
117 "Couldn't find part {0} in object group {1}, {2} to request inventory data",
118 localID, Name, UUID);
119 }
120 }
121
122 /// <summary>
123 /// Add an inventory item to a prim in this group. 80 /// Add an inventory item to a prim in this group.
124 /// </summary> 81 /// </summary>
125 /// <param name="remoteClient"></param> 82 /// <param name="remoteClient"></param>
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