aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs')
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs59
1 files changed, 36 insertions, 23 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
index 8171487..f219d4c 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
@@ -295,9 +295,12 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
295 return UUID.Zero; 295 return UUID.Zero;
296 } 296 }
297 297
298 public virtual UUID CopyToInventory(DeRezAction action, UUID folderID, 298 public virtual List<InventoryItemBase> CopyToInventory(
299 List<SceneObjectGroup> objectGroups, IClientAPI remoteClient) 299 DeRezAction action, UUID folderID,
300 List<SceneObjectGroup> objectGroups, IClientAPI remoteClient, bool asAttachment)
300 { 301 {
302 List<InventoryItemBase> copiedItems = new List<InventoryItemBase>();
303
301 Dictionary<UUID, List<SceneObjectGroup>> bundlesToCopy = new Dictionary<UUID, List<SceneObjectGroup>>(); 304 Dictionary<UUID, List<SceneObjectGroup>> bundlesToCopy = new Dictionary<UUID, List<SceneObjectGroup>>();
302 305
303 if (CoalesceMultipleObjectsToInventory) 306 if (CoalesceMultipleObjectsToInventory)
@@ -324,16 +327,16 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
324 } 327 }
325 } 328 }
326 329
327 // This is method scoped and will be returned. It will be the 330// m_log.DebugFormat(
328 // last created asset id 331// "[INVENTORY ACCESS MODULE]: Copying {0} object bundles to folder {1} action {2} for {3}",
329 UUID assetID = UUID.Zero; 332// bundlesToCopy.Count, folderID, action, remoteClient.Name);
330 333
331 // Each iteration is really a separate asset being created, 334 // Each iteration is really a separate asset being created,
332 // with distinct destinations as well. 335 // with distinct destinations as well.
333 foreach (List<SceneObjectGroup> bundle in bundlesToCopy.Values) 336 foreach (List<SceneObjectGroup> bundle in bundlesToCopy.Values)
334 assetID = CopyBundleToInventory(action, folderID, bundle, remoteClient); 337 copiedItems.Add(CopyBundleToInventory(action, folderID, bundle, remoteClient, asAttachment));
335 338
336 return assetID; 339 return copiedItems;
337 } 340 }
338 341
339 /// <summary> 342 /// <summary>
@@ -344,12 +347,13 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
344 /// <param name="folderID"></param> 347 /// <param name="folderID"></param>
345 /// <param name="objlist"></param> 348 /// <param name="objlist"></param>
346 /// <param name="remoteClient"></param> 349 /// <param name="remoteClient"></param>
347 /// <returns></returns> 350 /// <param name="asAttachment">Should be true if the bundle is being copied as an attachment. This prevents
348 protected UUID CopyBundleToInventory( 351 /// attempted serialization of any script state which would abort any operating scripts.</param>
349 DeRezAction action, UUID folderID, List<SceneObjectGroup> objlist, IClientAPI remoteClient) 352 /// <returns>The inventory item created by the copy</returns>
353 protected InventoryItemBase CopyBundleToInventory(
354 DeRezAction action, UUID folderID, List<SceneObjectGroup> objlist, IClientAPI remoteClient,
355 bool asAttachment)
350 { 356 {
351 UUID assetID = UUID.Zero;
352
353 CoalescedSceneObjects coa = new CoalescedSceneObjects(UUID.Zero); 357 CoalescedSceneObjects coa = new CoalescedSceneObjects(UUID.Zero);
354 Dictionary<UUID, Vector3> originalPositions = new Dictionary<UUID, Vector3>(); 358 Dictionary<UUID, Vector3> originalPositions = new Dictionary<UUID, Vector3>();
355 359
@@ -385,18 +389,27 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
385 389
386 string itemXml; 390 string itemXml;
387 391
392 // If we're being called from a script, then trying to serialize that same script's state will not complete
393 // in any reasonable time period. Therefore, we'll avoid it. The worst that can happen is that if
394 // the client/server crashes rather than logging out normally, the attachment's scripts will resume
395 // without state on relog. Arguably, this is what we want anyway.
388 if (objlist.Count > 1) 396 if (objlist.Count > 1)
389 itemXml = CoalescedSceneObjectsSerializer.ToXml(coa); 397 itemXml = CoalescedSceneObjectsSerializer.ToXml(coa, !asAttachment);
390 else 398 else
391 itemXml = SceneObjectSerializer.ToOriginalXmlFormat(objlist[0]); 399 itemXml = SceneObjectSerializer.ToOriginalXmlFormat(objlist[0], !asAttachment);
392 400
393 // Restore the position of each group now that it has been stored to inventory. 401 // Restore the position of each group now that it has been stored to inventory.
394 foreach (SceneObjectGroup objectGroup in objlist) 402 foreach (SceneObjectGroup objectGroup in objlist)
395 objectGroup.AbsolutePosition = originalPositions[objectGroup.UUID]; 403 objectGroup.AbsolutePosition = originalPositions[objectGroup.UUID];
396 404
397 InventoryItemBase item = CreateItemForObject(action, remoteClient, objlist[0], folderID); 405 InventoryItemBase item = CreateItemForObject(action, remoteClient, objlist[0], folderID);
406
407// m_log.DebugFormat(
408// "[INVENTORY ACCESS MODULE]: Created item is {0}",
409// item != null ? item.ID.ToString() : "NULL");
410
398 if (item == null) 411 if (item == null)
399 return UUID.Zero; 412 return null;
400 413
401 // Can't know creator is the same, so null it in inventory 414 // Can't know creator is the same, so null it in inventory
402 if (objlist.Count > 1) 415 if (objlist.Count > 1)
@@ -406,7 +419,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
406 } 419 }
407 else 420 else
408 { 421 {
409 item.CreatorId = objlist[0].RootPart.CreatorID.ToString(); 422 item.CreatorId = objlist[0].RootPart.CreatorID.ToString();
423 item.CreatorData = objlist[0].RootPart.CreatorData;
410 item.SaleType = objlist[0].RootPart.ObjectSaleType; 424 item.SaleType = objlist[0].RootPart.ObjectSaleType;
411 item.SalePrice = objlist[0].RootPart.SalePrice; 425 item.SalePrice = objlist[0].RootPart.SalePrice;
412 } 426 }
@@ -419,8 +433,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
419 objlist[0].OwnerID.ToString()); 433 objlist[0].OwnerID.ToString());
420 m_Scene.AssetService.Store(asset); 434 m_Scene.AssetService.Store(asset);
421 435
422 item.AssetID = asset.FullID; 436 item.AssetID = asset.FullID;
423 assetID = asset.FullID;
424 437
425 if (DeRezAction.SaveToExistingUserInventoryItem == action) 438 if (DeRezAction.SaveToExistingUserInventoryItem == action)
426 { 439 {
@@ -453,9 +466,9 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
453 466
454 // This is a hook to do some per-asset post-processing for subclasses that need that 467 // This is a hook to do some per-asset post-processing for subclasses that need that
455 if (remoteClient != null) 468 if (remoteClient != null)
456 ExportAsset(remoteClient.AgentId, assetID); 469 ExportAsset(remoteClient.AgentId, asset.FullID);
457 470
458 return assetID; 471 return item;
459 } 472 }
460 473
461 protected virtual void ExportAsset(UUID agentID, UUID assetID) 474 protected virtual void ExportAsset(UUID agentID, UUID assetID)
@@ -643,7 +656,6 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
643 { 656 {
644 // Catch all. Use lost & found 657 // Catch all. Use lost & found
645 // 658 //
646
647 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); 659 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
648 } 660 }
649 } 661 }
@@ -964,8 +976,9 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
964 976
965 so.FromFolderID = item.Folder; 977 so.FromFolderID = item.Folder;
966 978
967// Console.WriteLine("rootPart.OwnedID {0}, item.Owner {1}, item.CurrentPermissions {2:X}", 979// m_log.DebugFormat(
968// rootPart.OwnerID, item.Owner, item.CurrentPermissions); 980// "[INVENTORY ACCESS MODULE]: rootPart.OwnedID {0}, item.Owner {1}, item.CurrentPermissions {2:X}",
981// rootPart.OwnerID, item.Owner, item.CurrentPermissions);
969 982
970 if ((rootPart.OwnerID != item.Owner) || 983 if ((rootPart.OwnerID != item.Owner) ||
971 (item.CurrentPermissions & 16) != 0) 984 (item.CurrentPermissions & 16) != 0)