aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Assets/GetMeshModule.cs7
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Assets/NewFileAgentInventoryVariablePriceModule.cs7
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs27
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs4
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs29
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs562
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs9
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs2
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs18
9 files changed, 363 insertions, 302 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Assets/GetMeshModule.cs b/OpenSim/Region/CoreModules/Avatar/Assets/GetMeshModule.cs
index d2278bc..deec444 100644
--- a/OpenSim/Region/CoreModules/Avatar/Assets/GetMeshModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Assets/GetMeshModule.cs
@@ -66,12 +66,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Assets
66 66
67 public void Initialise(IConfigSource source) 67 public void Initialise(IConfigSource source)
68 { 68 {
69 IConfig startupConfig = source.Configs["Startup"]; 69 IConfig meshConfig = source.Configs["Mesh"];
70 if (startupConfig == null) 70 if (meshConfig == null)
71 return; 71 return;
72 72
73 if (!startupConfig.GetBoolean("ColladaMesh",true)) 73 m_enabled = meshConfig.GetBoolean("ColladaMesh", true);
74 m_enabled = false;
75 } 74 }
76 75
77 public void AddRegion(Scene pScene) 76 public void AddRegion(Scene pScene)
diff --git a/OpenSim/Region/CoreModules/Avatar/Assets/NewFileAgentInventoryVariablePriceModule.cs b/OpenSim/Region/CoreModules/Avatar/Assets/NewFileAgentInventoryVariablePriceModule.cs
index fb07cc9..d651cb2 100644
--- a/OpenSim/Region/CoreModules/Avatar/Assets/NewFileAgentInventoryVariablePriceModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Assets/NewFileAgentInventoryVariablePriceModule.cs
@@ -68,12 +68,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Assets
68 68
69 public void Initialise(IConfigSource source) 69 public void Initialise(IConfigSource source)
70 { 70 {
71 IConfig startupConfig = source.Configs["Startup"]; 71 IConfig meshConfig = source.Configs["Mesh"];
72 if (startupConfig == null) 72 if (meshConfig == null)
73 return; 73 return;
74 74
75 if (!startupConfig.GetBoolean("ColladaMesh",true)) 75 m_enabled = meshConfig.GetBoolean("ColladaMesh", true);
76 m_enabled = false;
77 } 76 }
78 77
79 public void AddRegion(Scene pScene) 78 public void AddRegion(Scene pScene)
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
index 2fff533..a19bbfd 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
@@ -77,7 +77,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
77 /// </value> 77 /// </value>
78 private Stream m_loadStream; 78 private Stream m_loadStream;
79 79
80 protected bool m_controlFileLoaded; 80 /// <summary>
81 /// Has the control file been loaded for this archive?
82 /// </summary>
83 public bool ControlFileLoaded { get; private set; }
84
85 /// <summary>
86 /// Do we want to enforce the check. IAR versions before 0.2 and 1.1 do not guarantee this order, so we can't
87 /// enforce.
88 /// </summary>
89 public bool EnforceControlFileCheck { get; private set; }
90
81 protected bool m_assetsLoaded; 91 protected bool m_assetsLoaded;
82 protected bool m_inventoryNodesLoaded; 92 protected bool m_inventoryNodesLoaded;
83 93
@@ -126,6 +136,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
126 m_userInfo = userInfo; 136 m_userInfo = userInfo;
127 m_invPath = invPath; 137 m_invPath = invPath;
128 m_loadStream = loadStream; 138 m_loadStream = loadStream;
139
140 // FIXME: Do not perform this check since older versions of OpenSim do save the control file after other things
141 // (I thought they weren't). We will need to bump the version number and perform this check on all
142 // subsequent IAR versions only
143 ControlFileLoaded = true;
129 } 144 }
130 145
131 /// <summary> 146 /// <summary>
@@ -517,7 +532,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
517 /// </summary> 532 /// </summary>
518 /// <param name="path"></param> 533 /// <param name="path"></param>
519 /// <param name="data"></param> 534 /// <param name="data"></param>
520 protected void LoadControlFile(string path, byte[] data) 535 public void LoadControlFile(string path, byte[] data)
521 { 536 {
522 XDocument doc = XDocument.Parse(Encoding.ASCII.GetString(data)); 537 XDocument doc = XDocument.Parse(Encoding.ASCII.GetString(data));
523 XElement archiveElement = doc.Element("archive"); 538 XElement archiveElement = doc.Element("archive");
@@ -533,7 +548,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
533 majorVersion, MAX_MAJOR_VERSION)); 548 majorVersion, MAX_MAJOR_VERSION));
534 } 549 }
535 550
536 m_controlFileLoaded = true; 551 ControlFileLoaded = true;
537 m_log.InfoFormat("[INVENTORY ARCHIVER]: Loading IAR with version {0}", version); 552 m_log.InfoFormat("[INVENTORY ARCHIVER]: Loading IAR with version {0}", version);
538 } 553 }
539 554
@@ -545,7 +560,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
545 /// <param name="data"></param> 560 /// <param name="data"></param>
546 protected void LoadInventoryFile(string path, TarArchiveReader.TarEntryType entryType, byte[] data) 561 protected void LoadInventoryFile(string path, TarArchiveReader.TarEntryType entryType, byte[] data)
547 { 562 {
548 if (!m_controlFileLoaded) 563 if (!ControlFileLoaded)
549 throw new Exception( 564 throw new Exception(
550 string.Format( 565 string.Format(
551 "The IAR you are trying to load does not list {0} before {1}. Aborting load", 566 "The IAR you are trying to load does not list {0} before {1}. Aborting load",
@@ -592,7 +607,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
592 /// <param name="data"></param> 607 /// <param name="data"></param>
593 protected void LoadAssetFile(string path, byte[] data) 608 protected void LoadAssetFile(string path, byte[] data)
594 { 609 {
595 if (!m_controlFileLoaded) 610 if (!ControlFileLoaded)
596 throw new Exception( 611 throw new Exception(
597 string.Format( 612 string.Format(
598 "The IAR you are trying to load does not list {0} before {1}. Aborting load", 613 "The IAR you are trying to load does not list {0} before {1}. Aborting load",
@@ -617,4 +632,4 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
617 m_assetsLoaded = true; 632 m_assetsLoaded = true;
618 } 633 }
619 } 634 }
620} \ No newline at end of file 635}
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
index 5e5f6c0..dd16bfe 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
@@ -388,12 +388,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
388 if (options.ContainsKey("profile")) 388 if (options.ContainsKey("profile"))
389 { 389 {
390 majorVersion = 1; 390 majorVersion = 1;
391 minorVersion = 0; 391 minorVersion = 1;
392 } 392 }
393 else 393 else
394 { 394 {
395 majorVersion = 0; 395 majorVersion = 0;
396 minorVersion = 1; 396 minorVersion = 2;
397 } 397 }
398 398
399 m_log.InfoFormat("[INVENTORY ARCHIVER]: Creating version {0}.{1} IAR", majorVersion, minorVersion); 399 m_log.InfoFormat("[INVENTORY ARCHIVER]: Creating version {0}.{1} IAR", majorVersion, minorVersion);
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
index d03f6da..52232a0 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
@@ -94,7 +94,34 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
94 94
95 Assert.That(coaObjects[1].UUID, Is.EqualTo(UUID.Parse("00000000-0000-0000-0000-000000000140"))); 95 Assert.That(coaObjects[1].UUID, Is.EqualTo(UUID.Parse("00000000-0000-0000-0000-000000000140")));
96 Assert.That(coaObjects[1].AbsolutePosition, Is.EqualTo(new Vector3(25, 50, 75))); 96 Assert.That(coaObjects[1].AbsolutePosition, Is.EqualTo(new Vector3(25, 50, 75)));
97 } 97 }
98
99 /// <summary>
100 /// Test that the IAR has the required files in the right order.
101 /// </summary>
102 /// <remarks>
103 /// At the moment, the only thing that matters is that the control file is the very first one.
104 /// </remarks>
105 [Test]
106 public void TestOrder()
107 {
108 TestHelper.InMethod();
109// log4net.Config.XmlConfigurator.Configure();
110
111 MemoryStream archiveReadStream = new MemoryStream(m_iarStreamBytes);
112 TarArchiveReader tar = new TarArchiveReader(archiveReadStream);
113 string filePath;
114 TarArchiveReader.TarEntryType tarEntryType;
115
116 byte[] data = tar.ReadEntry(out filePath, out tarEntryType);
117 Assert.That(filePath, Is.EqualTo(ArchiveConstants.CONTROL_FILE_PATH));
118
119 InventoryArchiveReadRequest iarr
120 = new InventoryArchiveReadRequest(null, null, null, (Stream)null, false);
121 iarr.LoadControlFile(filePath, data);
122
123 Assert.That(iarr.ControlFileLoaded, Is.True);
124 }
98 125
99 /// <summary> 126 /// <summary>
100 /// Test saving a single inventory item to a V0.1 OpenSim Inventory Archive 127 /// Test saving a single inventory item to a V0.1 OpenSim Inventory Archive
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
index 6d40e12..a165bbd 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
@@ -213,19 +213,11 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
213 213
214 return UUID.Zero; 214 return UUID.Zero;
215 } 215 }
216 216
217 /// <summary> 217 public virtual UUID CopyToInventory(DeRezAction action, UUID folderID,
218 /// Delete a scene object from a scene and place in the given avatar's inventory.
219 /// Returns the UUID of the newly created asset.
220 /// </summary>
221 /// <param name="action"></param>
222 /// <param name="folderID"></param>
223 /// <param name="objectGroup"></param>
224 /// <param name="remoteClient"> </param>
225 public virtual UUID DeleteToInventory(DeRezAction action, UUID folderID,
226 List<SceneObjectGroup> objectGroups, IClientAPI remoteClient) 218 List<SceneObjectGroup> objectGroups, IClientAPI remoteClient)
227 { 219 {
228 Dictionary<UUID, List<SceneObjectGroup>> deletes = new Dictionary<UUID, List<SceneObjectGroup>>(); 220 Dictionary<UUID, List<SceneObjectGroup>> bundlesToCopy = new Dictionary<UUID, List<SceneObjectGroup>>();
229 221
230 if (CoalesceMultipleObjectsToInventory) 222 if (CoalesceMultipleObjectsToInventory)
231 { 223 {
@@ -234,10 +226,10 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
234 // reasons. 226 // reasons.
235 foreach (SceneObjectGroup g in objectGroups) 227 foreach (SceneObjectGroup g in objectGroups)
236 { 228 {
237 if (!deletes.ContainsKey(g.OwnerID)) 229 if (!bundlesToCopy.ContainsKey(g.OwnerID))
238 deletes[g.OwnerID] = new List<SceneObjectGroup>(); 230 bundlesToCopy[g.OwnerID] = new List<SceneObjectGroup>();
239 231
240 deletes[g.OwnerID].Add(g); 232 bundlesToCopy[g.OwnerID].Add(g);
241 } 233 }
242 } 234 }
243 else 235 else
@@ -247,7 +239,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
247 { 239 {
248 List<SceneObjectGroup> bundle = new List<SceneObjectGroup>(); 240 List<SceneObjectGroup> bundle = new List<SceneObjectGroup>();
249 bundle.Add(g); 241 bundle.Add(g);
250 deletes[g.UUID] = bundle; 242 bundlesToCopy[g.UUID] = bundle;
251 } 243 }
252 } 244 }
253 245
@@ -257,328 +249,348 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
257 249
258 // Each iteration is really a separate asset being created, 250 // Each iteration is really a separate asset being created,
259 // with distinct destinations as well. 251 // with distinct destinations as well.
260 foreach (List<SceneObjectGroup> objlist in deletes.Values) 252 foreach (List<SceneObjectGroup> bundle in bundlesToCopy.Values)
253 assetID = CopyBundleToInventory(action, folderID, bundle, remoteClient);
254
255 return assetID;
256 }
257
258 /// <summary>
259 /// Copy a bundle of objects to inventory. If there is only one object, then this will create an object
260 /// item. If there are multiple objects then these will be saved as a single coalesced item.
261 /// </summary>
262 /// <param name="action"></param>
263 /// <param name="folderID"></param>
264 /// <param name="objlist"></param>
265 /// <param name="remoteClient"></param>
266 /// <returns></returns>
267 protected UUID CopyBundleToInventory(
268 DeRezAction action, UUID folderID, List<SceneObjectGroup> objlist, IClientAPI remoteClient)
269 {
270 UUID assetID = UUID.Zero;
271
272 CoalescedSceneObjects coa = new CoalescedSceneObjects(UUID.Zero);
273 Dictionary<UUID, Vector3> originalPositions = new Dictionary<UUID, Vector3>();
274
275 Dictionary<UUID, string> xmlStrings =
276 new Dictionary<UUID, string>();
277
278 foreach (SceneObjectGroup objectGroup in objlist)
261 { 279 {
262 Dictionary<UUID, string> xmlStrings = 280 Vector3 inventoryStoredPosition = new Vector3
263 new Dictionary<UUID, string>(); 281 (((objectGroup.AbsolutePosition.X > (int)Constants.RegionSize)
282 ? 250
283 : objectGroup.AbsolutePosition.X)
284 ,
285 (objectGroup.AbsolutePosition.Y > (int)Constants.RegionSize)
286 ? 250
287 : objectGroup.AbsolutePosition.Y,
288 objectGroup.AbsolutePosition.Z);
289
290 Vector3 originalPosition = objectGroup.AbsolutePosition;
291
292 // Restore attachment data after trip through the sim
293 if (objectGroup.RootPart.AttachPoint > 0)
294 inventoryStoredPosition = objectGroup.RootPart.AttachOffset;
295 objectGroup.RootPart.Shape.State = objectGroup.RootPart.AttachPoint;
296
297 objectGroup.AbsolutePosition = inventoryStoredPosition;
298
299 // Make sure all bits but the ones we want are clear
300 // on take.
301 // This will be applied to the current perms, so
302 // it will do what we want.
303 objectGroup.RootPart.NextOwnerMask &=
304 ((uint)PermissionMask.Copy |
305 (uint)PermissionMask.Transfer |
306 (uint)PermissionMask.Modify);
307 objectGroup.RootPart.NextOwnerMask |=
308 (uint)PermissionMask.Move;
309
310 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(objectGroup);
311
312 objectGroup.AbsolutePosition = originalPosition;
313
314 xmlStrings[objectGroup.UUID] = sceneObjectXml;
315 }
264 316
265 foreach (SceneObjectGroup objectGroup in objlist) 317 string itemXml;
266 {
267 Vector3 inventoryStoredPosition = new Vector3
268 (((objectGroup.AbsolutePosition.X > (int)Constants.RegionSize)
269 ? 250
270 : objectGroup.AbsolutePosition.X)
271 ,
272 (objectGroup.AbsolutePosition.Y > (int)Constants.RegionSize)
273 ? 250
274 : objectGroup.AbsolutePosition.Y,
275 objectGroup.AbsolutePosition.Z);
276
277 Vector3 originalPosition = objectGroup.AbsolutePosition;
278
279 // Restore attachment data after trip through the sim
280 if (objectGroup.RootPart.AttachPoint > 0)
281 inventoryStoredPosition = objectGroup.RootPart.AttachOffset;
282 objectGroup.RootPart.Shape.State = objectGroup.RootPart.AttachPoint;
283
284 objectGroup.AbsolutePosition = inventoryStoredPosition;
285
286 // Make sure all bits but the ones we want are clear
287 // on take.
288 // This will be applied to the current perms, so
289 // it will do what we want.
290 objectGroup.RootPart.NextOwnerMask &=
291 ((uint)PermissionMask.Copy |
292 (uint)PermissionMask.Transfer |
293 (uint)PermissionMask.Modify);
294 objectGroup.RootPart.NextOwnerMask |=
295 (uint)PermissionMask.Move;
296 318
297 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(objectGroup); 319 if (objlist.Count > 1)
320 {
321 float minX, minY, minZ;
322 float maxX, maxY, maxZ;
323
324 Vector3[] offsets = Scene.GetCombinedBoundingBox(objlist,
325 out minX, out maxX, out minY, out maxY,
326 out minZ, out maxZ);
298 327
299 objectGroup.AbsolutePosition = originalPosition; 328 // CreateWrapper
329 XmlDocument itemDoc = new XmlDocument();
330 XmlElement root = itemDoc.CreateElement("", "CoalescedObject", "");
331 itemDoc.AppendChild(root);
300 332
301 xmlStrings[objectGroup.UUID] = sceneObjectXml; 333 // Embed the offsets into the group XML
334 for ( int i = 0 ; i < objlist.Count ; i++ )
335 {
336 XmlDocument doc = new XmlDocument();
337 SceneObjectGroup g = objlist[i];
338 doc.LoadXml(xmlStrings[g.UUID]);
339 XmlElement e = (XmlElement)doc.SelectSingleNode("/SceneObjectGroup");
340 e.SetAttribute("offsetx", offsets[i].X.ToString());
341 e.SetAttribute("offsety", offsets[i].Y.ToString());
342 e.SetAttribute("offsetz", offsets[i].Z.ToString());
343
344 XmlNode objectNode = itemDoc.ImportNode(e, true);
345 root.AppendChild(objectNode);
302 } 346 }
303 347
304 string itemXml; 348 float sizeX = maxX - minX;
349 float sizeY = maxY - minY;
350 float sizeZ = maxZ - minZ;
305 351
306 if (objlist.Count > 1) 352 root.SetAttribute("x", sizeX.ToString());
307 { 353 root.SetAttribute("y", sizeY.ToString());
308 float minX, minY, minZ; 354 root.SetAttribute("z", sizeZ.ToString());
309 float maxX, maxY, maxZ;
310 355
311 Vector3[] offsets = Scene.GetCombinedBoundingBox(objlist, 356 itemXml = itemDoc.InnerXml;
312 out minX, out maxX, out minY, out maxY, 357 }
313 out minZ, out maxZ); 358 else
359 {
360 itemXml = xmlStrings[objlist[0].UUID];
361 }
314 362
315 // CreateWrapper 363 // Get the user info of the item destination
316 XmlDocument itemDoc = new XmlDocument(); 364 //
317 XmlElement root = itemDoc.CreateElement("", "CoalescedObject", ""); 365 UUID userID = UUID.Zero;
318 itemDoc.AppendChild(root);
319 366
320 // Embed the offsets into the group XML 367 if (action == DeRezAction.Take || action == DeRezAction.TakeCopy ||
321 for ( int i = 0 ; i < objlist.Count ; i++ ) 368 action == DeRezAction.SaveToExistingUserInventoryItem)
322 { 369 {
323 XmlDocument doc = new XmlDocument(); 370 // Take or take copy require a taker
324 SceneObjectGroup g = objlist[i]; 371 // Saving changes requires a local user
325 doc.LoadXml(xmlStrings[g.UUID]); 372 //
326 XmlElement e = (XmlElement)doc.SelectSingleNode("/SceneObjectGroup"); 373 if (remoteClient == null)
327 e.SetAttribute("offsetx", offsets[i].X.ToString()); 374 return UUID.Zero;
328 e.SetAttribute("offsety", offsets[i].Y.ToString());
329 e.SetAttribute("offsetz", offsets[i].Z.ToString());
330
331 XmlNode objectNode = itemDoc.ImportNode(e, true);
332 root.AppendChild(objectNode);
333 }
334 375
335 float sizeX = maxX - minX; 376 userID = remoteClient.AgentId;
336 float sizeY = maxY - minY; 377 }
337 float sizeZ = maxZ - minZ; 378 else
379 {
380 // All returns / deletes go to the object owner
381 //
338 382
339 root.SetAttribute("x", sizeX.ToString()); 383 userID = objlist[0].RootPart.OwnerID;
340 root.SetAttribute("y", sizeY.ToString()); 384 }
341 root.SetAttribute("z", sizeZ.ToString());
342 385
343 itemXml = itemDoc.InnerXml; 386 if (userID == UUID.Zero) // Can't proceed
344 } 387 {
345 else 388 return UUID.Zero;
346 { 389 }
347 itemXml = xmlStrings[objlist[0].UUID];
348 }
349 390
350 // Get the user info of the item destination 391 // If we're returning someone's item, it goes back to the
351 // 392 // owner's Lost And Found folder.
352 UUID userID = UUID.Zero; 393 // Delete is treated like return in this case
394 // Deleting your own items makes them go to trash
395 //
353 396
354 if (action == DeRezAction.Take || action == DeRezAction.TakeCopy || 397 InventoryFolderBase folder = null;
355 action == DeRezAction.SaveToExistingUserInventoryItem) 398 InventoryItemBase item = null;
356 {
357 // Take or take copy require a taker
358 // Saving changes requires a local user
359 //
360 if (remoteClient == null)
361 return UUID.Zero;
362 399
363 userID = remoteClient.AgentId; 400 if (DeRezAction.SaveToExistingUserInventoryItem == action)
364 } 401 {
365 else 402 item = new InventoryItemBase(objlist[0].RootPart.FromUserInventoryItemID, userID);
366 { 403 item = m_Scene.InventoryService.GetItem(item);
367 // All returns / deletes go to the object owner
368 //
369 404
370 userID = objlist[0].RootPart.OwnerID; 405 //item = userInfo.RootFolder.FindItem(
371 } 406 // objectGroup.RootPart.FromUserInventoryItemID);
372 407
373 if (userID == UUID.Zero) // Can't proceed 408 if (null == item)
374 { 409 {
410 m_log.DebugFormat(
411 "[AGENT INVENTORY]: Object {0} {1} scheduled for save to inventory has already been deleted.",
412 objlist[0].Name, objlist[0].UUID);
375 return UUID.Zero; 413 return UUID.Zero;
376 } 414 }
377 415 }
378 // If we're returning someone's item, it goes back to the 416 else
379 // owner's Lost And Found folder. 417 {
380 // Delete is treated like return in this case 418 // Folder magic
381 // Deleting your own items makes them go to trash
382 // 419 //
383 420 if (action == DeRezAction.Delete)
384 InventoryFolderBase folder = null;
385 InventoryItemBase item = null;
386
387 if (DeRezAction.SaveToExistingUserInventoryItem == action)
388 { 421 {
389 item = new InventoryItemBase(objlist[0].RootPart.FromUserInventoryItemID, userID); 422 // Deleting someone else's item
390 item = m_Scene.InventoryService.GetItem(item); 423 //
391 424 if (remoteClient == null ||
392 //item = userInfo.RootFolder.FindItem( 425 objlist[0].OwnerID != remoteClient.AgentId)
393 // objectGroup.RootPart.FromUserInventoryItemID); 426 {
394 427
395 if (null == item) 428 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
429 }
430 else
396 { 431 {
397 m_log.DebugFormat( 432 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.TrashFolder);
398 "[AGENT INVENTORY]: Object {0} {1} scheduled for save to inventory has already been deleted.",
399 objlist[0].Name, objlist[0].UUID);
400 return UUID.Zero;
401 } 433 }
402 } 434 }
403 else 435 else if (action == DeRezAction.Return)
404 { 436 {
405 // Folder magic 437
438 // Dump to lost + found unconditionally
406 // 439 //
440 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
441 }
442
443 if (folderID == UUID.Zero && folder == null)
444 {
407 if (action == DeRezAction.Delete) 445 if (action == DeRezAction.Delete)
408 { 446 {
409 // Deleting someone else's item 447 // Deletes go to trash by default
410 // 448 //
449 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.TrashFolder);
450 }
451 else
452 {
411 if (remoteClient == null || 453 if (remoteClient == null ||
412 objlist[0].OwnerID != remoteClient.AgentId) 454 objlist[0].OwnerID != remoteClient.AgentId)
413 { 455 {
414 456 // Taking copy of another person's item. Take to
415 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); 457 // Objects folder.
458 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.Object);
416 } 459 }
417 else 460 else
418 { 461 {
419 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.TrashFolder); 462 // Catch all. Use lost & found
420 }
421 }
422 else if (action == DeRezAction.Return)
423 {
424
425 // Dump to lost + found unconditionally
426 //
427 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
428 }
429
430 if (folderID == UUID.Zero && folder == null)
431 {
432 if (action == DeRezAction.Delete)
433 {
434 // Deletes go to trash by default
435 // 463 //
436 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.TrashFolder);
437 }
438 else
439 {
440 if (remoteClient == null ||
441 objlist[0].OwnerID != remoteClient.AgentId)
442 {
443 // Taking copy of another person's item. Take to
444 // Objects folder.
445 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.Object);
446 }
447 else
448 {
449 // Catch all. Use lost & found
450 //
451 464
452 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); 465 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
453 }
454 } 466 }
455 } 467 }
468 }
456 469
457 // Override and put into where it came from, if it came 470 // Override and put into where it came from, if it came
458 // from anywhere in inventory 471 // from anywhere in inventory
459 // 472 //
460 if (action == DeRezAction.Take || action == DeRezAction.TakeCopy) 473 if (action == DeRezAction.Take || action == DeRezAction.TakeCopy)
474 {
475 if (objlist[0].RootPart.FromFolderID != UUID.Zero && objlist[0].OwnerID == remoteClient.AgentId)
461 { 476 {
462 if (objlist[0].RootPart.FromFolderID != UUID.Zero && objlist[0].OwnerID == remoteClient.AgentId) 477 InventoryFolderBase f = new InventoryFolderBase(objlist[0].RootPart.FromFolderID, userID);
463 { 478 folder = m_Scene.InventoryService.GetFolder(f);
464 InventoryFolderBase f = new InventoryFolderBase(objlist[0].RootPart.FromFolderID, userID);
465 folder = m_Scene.InventoryService.GetFolder(f);
466 }
467 } 479 }
480 }
468 481
469 if (folder == null) // None of the above 482 if (folder == null) // None of the above
470 { 483 {
471 folder = new InventoryFolderBase(folderID); 484 folder = new InventoryFolderBase(folderID);
472
473 if (folder == null) // Nowhere to put it
474 {
475 return UUID.Zero;
476 }
477 }
478 485
479 item = new InventoryItemBase(); 486 if (folder == null) // Nowhere to put it
480 // Can't know creator is the same, so null it in inventory
481 if (objlist.Count > 1)
482 { 487 {
483 item.CreatorId = UUID.Zero.ToString(); 488 return UUID.Zero;
484 item.CreatorData = String.Empty;
485 }
486 else
487 {
488 item.CreatorId = objlist[0].RootPart.CreatorID.ToString();
489 item.CreatorData = objlist[0].RootPart.CreatorData;
490 }
491 item.ID = UUID.Random();
492 item.InvType = (int)InventoryType.Object;
493 item.Folder = folder.ID;
494 item.Owner = userID;
495 if (objlist.Count > 1)
496 {
497 item.Flags = (uint)InventoryItemFlags.ObjectHasMultipleItems;
498 }
499 else
500 {
501 item.SaleType = objlist[0].RootPart.ObjectSaleType;
502 item.SalePrice = objlist[0].RootPart.SalePrice;
503 } 489 }
504 } 490 }
505 491
506 AssetBase asset = CreateAsset( 492 item = new InventoryItemBase();
507 objlist[0].GetPartName(objlist[0].RootPart.LocalId), 493 // Can't know creator is the same, so null it in inventory
508 objlist[0].GetPartDescription(objlist[0].RootPart.LocalId), 494 if (objlist.Count > 1)
509 (sbyte)AssetType.Object,
510 Utils.StringToBytes(itemXml),
511 objlist[0].OwnerID.ToString());
512 m_Scene.AssetService.Store(asset);
513 assetID = asset.FullID;
514
515 if (DeRezAction.SaveToExistingUserInventoryItem == action)
516 { 495 {
517 item.AssetID = asset.FullID; 496 item.CreatorId = UUID.Zero.ToString();
518 m_Scene.InventoryService.UpdateItem(item); 497 item.CreatorData = String.Empty;
519 } 498 }
520 else 499 else
521 { 500 {
522 item.AssetID = asset.FullID; 501 item.CreatorId = objlist[0].RootPart.CreatorID.ToString();
502 item.CreatorData = objlist[0].RootPart.CreatorData;
503 }
504 item.ID = UUID.Random();
505 item.InvType = (int)InventoryType.Object;
506 item.Folder = folder.ID;
507 item.Owner = userID;
508 if (objlist.Count > 1)
509 {
510 item.Flags = (uint)InventoryItemFlags.ObjectHasMultipleItems;
511 }
512 else
513 {
514 item.SaleType = objlist[0].RootPart.ObjectSaleType;
515 item.SalePrice = objlist[0].RootPart.SalePrice;
516 }
517 }
523 518
524 uint effectivePerms = (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify | PermissionMask.Move) | 7; 519 AssetBase asset = CreateAsset(
525 foreach (SceneObjectGroup grp in objlist) 520 objlist[0].GetPartName(objlist[0].RootPart.LocalId),
526 effectivePerms &= grp.GetEffectivePermissions(); 521 objlist[0].GetPartDescription(objlist[0].RootPart.LocalId),
527 effectivePerms |= (uint)PermissionMask.Move; 522 (sbyte)AssetType.Object,
523 Utils.StringToBytes(itemXml),
524 objlist[0].OwnerID.ToString());
525 m_Scene.AssetService.Store(asset);
526 assetID = asset.FullID;
528 527
529 if (remoteClient != null && (remoteClient.AgentId != objlist[0].RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions()) 528 if (DeRezAction.SaveToExistingUserInventoryItem == action)
530 { 529 {
531 uint perms = effectivePerms; 530 item.AssetID = asset.FullID;
532 uint nextPerms = (perms & 7) << 13; 531 m_Scene.InventoryService.UpdateItem(item);
533 if ((nextPerms & (uint)PermissionMask.Copy) == 0) 532 }
534 perms &= ~(uint)PermissionMask.Copy; 533 else
535 if ((nextPerms & (uint)PermissionMask.Transfer) == 0) 534 {
536 perms &= ~(uint)PermissionMask.Transfer; 535 item.AssetID = asset.FullID;
537 if ((nextPerms & (uint)PermissionMask.Modify) == 0)
538 perms &= ~(uint)PermissionMask.Modify;
539
540 item.BasePermissions = perms & objlist[0].RootPart.NextOwnerMask;
541 item.CurrentPermissions = item.BasePermissions;
542 item.NextPermissions = perms & objlist[0].RootPart.NextOwnerMask;
543 item.EveryOnePermissions = objlist[0].RootPart.EveryoneMask & objlist[0].RootPart.NextOwnerMask;
544 item.GroupPermissions = objlist[0].RootPart.GroupMask & objlist[0].RootPart.NextOwnerMask;
545
546 item.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm;
547 }
548 else
549 {
550 item.BasePermissions = effectivePerms;
551 item.CurrentPermissions = effectivePerms;
552 item.NextPermissions = objlist[0].RootPart.NextOwnerMask & effectivePerms;
553 item.EveryOnePermissions = objlist[0].RootPart.EveryoneMask & effectivePerms;
554 item.GroupPermissions = objlist[0].RootPart.GroupMask & effectivePerms;
555
556 item.CurrentPermissions &=
557 ((uint)PermissionMask.Copy |
558 (uint)PermissionMask.Transfer |
559 (uint)PermissionMask.Modify |
560 (uint)PermissionMask.Move |
561 7); // Preserve folded permissions
562 }
563 536
564 item.CreationDate = Util.UnixTimeSinceEpoch(); 537 uint effectivePerms = (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify | PermissionMask.Move) | 7;
565 item.Description = asset.Description; 538 foreach (SceneObjectGroup grp in objlist)
566 item.Name = asset.Name; 539 effectivePerms &= grp.GetEffectivePermissions();
567 item.AssetType = asset.Type; 540 effectivePerms |= (uint)PermissionMask.Move;
568 541
569 m_Scene.AddInventoryItem(item); 542 if (remoteClient != null && (remoteClient.AgentId != objlist[0].RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions())
543 {
544 uint perms = effectivePerms;
545 uint nextPerms = (perms & 7) << 13;
546 if ((nextPerms & (uint)PermissionMask.Copy) == 0)
547 perms &= ~(uint)PermissionMask.Copy;
548 if ((nextPerms & (uint)PermissionMask.Transfer) == 0)
549 perms &= ~(uint)PermissionMask.Transfer;
550 if ((nextPerms & (uint)PermissionMask.Modify) == 0)
551 perms &= ~(uint)PermissionMask.Modify;
552
553 item.BasePermissions = perms & objlist[0].RootPart.NextOwnerMask;
554 item.CurrentPermissions = item.BasePermissions;
555 item.NextPermissions = perms & objlist[0].RootPart.NextOwnerMask;
556 item.EveryOnePermissions = objlist[0].RootPart.EveryoneMask & objlist[0].RootPart.NextOwnerMask;
557 item.GroupPermissions = objlist[0].RootPart.GroupMask & objlist[0].RootPart.NextOwnerMask;
558
559 item.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm;
560 }
561 else
562 {
563 item.BasePermissions = effectivePerms;
564 item.CurrentPermissions = effectivePerms;
565 item.NextPermissions = objlist[0].RootPart.NextOwnerMask & effectivePerms;
566 item.EveryOnePermissions = objlist[0].RootPart.EveryoneMask & effectivePerms;
567 item.GroupPermissions = objlist[0].RootPart.GroupMask & effectivePerms;
570 568
571 if (remoteClient != null && item.Owner == remoteClient.AgentId) 569 item.CurrentPermissions &=
572 { 570 ((uint)PermissionMask.Copy |
573 remoteClient.SendInventoryItemCreateUpdate(item, 0); 571 (uint)PermissionMask.Transfer |
574 } 572 (uint)PermissionMask.Modify |
575 else 573 (uint)PermissionMask.Move |
574 7); // Preserve folded permissions
575 }
576
577 item.CreationDate = Util.UnixTimeSinceEpoch();
578 item.Description = asset.Description;
579 item.Name = asset.Name;
580 item.AssetType = asset.Type;
581
582 m_Scene.AddInventoryItem(item);
583
584 if (remoteClient != null && item.Owner == remoteClient.AgentId)
585 {
586 remoteClient.SendInventoryItemCreateUpdate(item, 0);
587 }
588 else
589 {
590 ScenePresence notifyUser = m_Scene.GetScenePresence(item.Owner);
591 if (notifyUser != null)
576 { 592 {
577 ScenePresence notifyUser = m_Scene.GetScenePresence(item.Owner); 593 notifyUser.ControllingClient.SendInventoryItemCreateUpdate(item, 0);
578 if (notifyUser != null)
579 {
580 notifyUser.ControllingClient.SendInventoryItemCreateUpdate(item, 0);
581 }
582 } 594 }
583 } 595 }
584 } 596 }
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
index b1dec4c..930a117 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
@@ -57,6 +57,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver
57 /// bumps here should be compatible. 57 /// bumps here should be compatible.
58 /// </summary> 58 /// </summary>
59 public static int MAX_MAJOR_VERSION = 1; 59 public static int MAX_MAJOR_VERSION = 1;
60
61 /// <summary>
62 /// Has the control file been loaded for this archive?
63 /// </summary>
64 public bool ControlFileLoaded { get; private set; }
60 65
61 protected Scene m_scene; 66 protected Scene m_scene;
62 protected Stream m_loadStream; 67 protected Stream m_loadStream;
@@ -545,7 +550,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
545 /// </summary> 550 /// </summary>
546 /// <param name="path"></param> 551 /// <param name="path"></param>
547 /// <param name="data"></param> 552 /// <param name="data"></param>
548 protected void LoadControlFile(string path, byte[] data) 553 public void LoadControlFile(string path, byte[] data)
549 { 554 {
550 XmlNamespaceManager nsmgr = new XmlNamespaceManager(new NameTable()); 555 XmlNamespaceManager nsmgr = new XmlNamespaceManager(new NameTable());
551 XmlParserContext context = new XmlParserContext(null, nsmgr, null, XmlSpace.None); 556 XmlParserContext context = new XmlParserContext(null, nsmgr, null, XmlSpace.None);
@@ -591,6 +596,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver
591 } 596 }
592 597
593 currentRegionSettings.Save(); 598 currentRegionSettings.Save();
599
600 ControlFileLoaded = true;
594 } 601 }
595 } 602 }
596} \ No newline at end of file 603} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs
index f2d487e..597b780 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs
@@ -206,7 +206,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
206 /// <returns></returns> 206 /// <returns></returns>
207 public static string CreateControlFile(Dictionary<string, object> options) 207 public static string CreateControlFile(Dictionary<string, object> options)
208 { 208 {
209 int majorVersion = MAX_MAJOR_VERSION, minorVersion = 5; 209 int majorVersion = MAX_MAJOR_VERSION, minorVersion = 6;
210// 210//
211// if (options.ContainsKey("version")) 211// if (options.ContainsKey("version"))
212// { 212// {
diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
index e2760a2..2307c8e 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
@@ -171,7 +171,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
171 MemoryStream archiveReadStream = new MemoryStream(archive); 171 MemoryStream archiveReadStream = new MemoryStream(archive);
172 TarArchiveReader tar = new TarArchiveReader(archiveReadStream); 172 TarArchiveReader tar = new TarArchiveReader(archiveReadStream);
173 173
174 bool gotControlFile = false;
175 bool gotNcAssetFile = false; 174 bool gotNcAssetFile = false;
176 175
177 string expectedNcAssetFileName = string.Format("{0}_{1}", ncAssetUuid, "notecard.txt"); 176 string expectedNcAssetFileName = string.Format("{0}_{1}", ncAssetUuid, "notecard.txt");
@@ -182,15 +181,19 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
182 expectedPaths.Add(ArchiveHelpers.CreateObjectPath(sog2)); 181 expectedPaths.Add(ArchiveHelpers.CreateObjectPath(sog2));
183 182
184 string filePath; 183 string filePath;
185 TarArchiveReader.TarEntryType tarEntryType; 184 TarArchiveReader.TarEntryType tarEntryType;
186 185
186 byte[] data = tar.ReadEntry(out filePath, out tarEntryType);
187 Assert.That(filePath, Is.EqualTo(ArchiveConstants.CONTROL_FILE_PATH));
188
189 ArchiveReadRequest arr = new ArchiveReadRequest(m_scene, (Stream)null, false, false, Guid.Empty);
190 arr.LoadControlFile(filePath, data);
191
192 Assert.That(arr.ControlFileLoaded, Is.True);
193
187 while (tar.ReadEntry(out filePath, out tarEntryType) != null) 194 while (tar.ReadEntry(out filePath, out tarEntryType) != null)
188 { 195 {
189 if (ArchiveConstants.CONTROL_FILE_PATH == filePath) 196 if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH))
190 {
191 gotControlFile = true;
192 }
193 else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH))
194 { 197 {
195 string fileName = filePath.Remove(0, ArchiveConstants.ASSETS_PATH.Length); 198 string fileName = filePath.Remove(0, ArchiveConstants.ASSETS_PATH.Length);
196 199
@@ -203,7 +206,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
203 } 206 }
204 } 207 }
205 208
206 Assert.That(gotControlFile, Is.True, "No control file in archive");
207 Assert.That(gotNcAssetFile, Is.True, "No notecard asset file in archive"); 209 Assert.That(gotNcAssetFile, Is.True, "No notecard asset file in archive");
208 Assert.That(foundPaths, Is.EquivalentTo(expectedPaths)); 210 Assert.That(foundPaths, Is.EquivalentTo(expectedPaths));
209 211