aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs302
1 files changed, 159 insertions, 143 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
index c0946f4..0f2b9a6 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
@@ -274,154 +274,22 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
274 foreach (SceneObjectGroup objectGroup in objlist) 274 foreach (SceneObjectGroup objectGroup in objlist)
275 objectGroup.AbsolutePosition = originalPositions[objectGroup.UUID]; 275 objectGroup.AbsolutePosition = originalPositions[objectGroup.UUID];
276 276
277 // Get the user info of the item destination 277 InventoryItemBase item = CreateItemForObject(action, remoteClient, objlist[0], folderID);
278 // 278 if (item == null)
279 UUID userID = UUID.Zero;
280
281 if (action == DeRezAction.Take || action == DeRezAction.TakeCopy ||
282 action == DeRezAction.SaveToExistingUserInventoryItem)
283 {
284 // Take or take copy require a taker
285 // Saving changes requires a local user
286 //
287 if (remoteClient == null)
288 return UUID.Zero;
289
290 userID = remoteClient.AgentId;
291 }
292 else
293 {
294 // All returns / deletes go to the object owner
295 //
296 userID = objlist[0].RootPart.OwnerID;
297 }
298
299 if (userID == UUID.Zero) // Can't proceed
300 {
301 return UUID.Zero; 279 return UUID.Zero;
302 } 280
303 281 // Can't know creator is the same, so null it in inventory
304 // If we're returning someone's item, it goes back to the 282 if (objlist.Count > 1)
305 // owner's Lost And Found folder.
306 // Delete is treated like return in this case
307 // Deleting your own items makes them go to trash
308 //
309
310 InventoryFolderBase folder = null;
311 InventoryItemBase item = null;
312
313 if (DeRezAction.SaveToExistingUserInventoryItem == action)
314 { 283 {
315 item = new InventoryItemBase(objlist[0].RootPart.FromUserInventoryItemID, userID); 284 item.CreatorId = UUID.Zero.ToString();
316 item = m_Scene.InventoryService.GetItem(item); 285 item.Flags = (uint)InventoryItemFlags.ObjectHasMultipleItems;
317
318 //item = userInfo.RootFolder.FindItem(
319 // objectGroup.RootPart.FromUserInventoryItemID);
320
321 if (null == item)
322 {
323 m_log.DebugFormat(
324 "[AGENT INVENTORY]: Object {0} {1} scheduled for save to inventory has already been deleted.",
325 objlist[0].Name, objlist[0].UUID);
326 return UUID.Zero;
327 }
328 } 286 }
329 else 287 else
330 { 288 {
331 // Folder magic 289 item.CreatorId = objlist[0].RootPart.CreatorID.ToString();
332 // 290 item.SaleType = objlist[0].RootPart.ObjectSaleType;
333 if (action == DeRezAction.Delete) 291 item.SalePrice = objlist[0].RootPart.SalePrice;
334 { 292 }
335 // Deleting someone else's item
336 //
337 if (remoteClient == null ||
338 objlist[0].OwnerID != remoteClient.AgentId)
339 {
340
341 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
342 }
343 else
344 {
345 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.TrashFolder);
346 }
347 }
348 else if (action == DeRezAction.Return)
349 {
350
351 // Dump to lost + found unconditionally
352 //
353 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
354 }
355
356 if (folderID == UUID.Zero && folder == null)
357 {
358 if (action == DeRezAction.Delete)
359 {
360 // Deletes go to trash by default
361 //
362 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.TrashFolder);
363 }
364 else
365 {
366 if (remoteClient == null ||
367 objlist[0].OwnerID != remoteClient.AgentId)
368 {
369 // Taking copy of another person's item. Take to
370 // Objects folder.
371 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.Object);
372 }
373 else
374 {
375 // Catch all. Use lost & found
376 //
377
378 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
379 }
380 }
381 }
382
383 // Override and put into where it came from, if it came
384 // from anywhere in inventory
385 //
386 if (action == DeRezAction.Take || action == DeRezAction.TakeCopy)
387 {
388 if (objlist[0].RootPart.FromFolderID != UUID.Zero)
389 {
390 InventoryFolderBase f = new InventoryFolderBase(objlist[0].RootPart.FromFolderID, userID);
391 folder = m_Scene.InventoryService.GetFolder(f);
392 }
393 }
394
395 if (folder == null) // None of the above
396 {
397 folder = new InventoryFolderBase(folderID);
398
399 if (folder == null) // Nowhere to put it
400 {
401 return UUID.Zero;
402 }
403 }
404
405 item = new InventoryItemBase();
406 // Can't know creator is the same, so null it in inventory
407 if (objlist.Count > 1)
408 item.CreatorId = UUID.Zero.ToString();
409 else
410 item.CreatorId = objlist[0].RootPart.CreatorID.ToString();
411 item.ID = UUID.Random();
412 item.InvType = (int)InventoryType.Object;
413 item.Folder = folder.ID;
414 item.Owner = userID;
415 if (objlist.Count > 1)
416 {
417 item.Flags = (uint)InventoryItemFlags.ObjectHasMultipleItems;
418 }
419 else
420 {
421 item.SaleType = objlist[0].RootPart.ObjectSaleType;
422 item.SalePrice = objlist[0].RootPart.SalePrice;
423 }
424 }
425 293
426 AssetBase asset = CreateAsset( 294 AssetBase asset = CreateAsset(
427 objlist[0].GetPartName(objlist[0].RootPart.LocalId), 295 objlist[0].GetPartName(objlist[0].RootPart.LocalId),
@@ -505,8 +373,156 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
505 } 373 }
506 } 374 }
507 } 375 }
376
508 return assetID; 377 return assetID;
509 } 378 }
379
380 /// <summary>
381 /// Create an item using details for the given scene object.
382 /// </summary>
383 /// <param name="action"></param>
384 /// <param name="remoteClient"></param>
385 /// <param name="so"></param>
386 /// <param name="folderID"></param>
387 /// <returns></returns>
388 protected InventoryItemBase CreateItemForObject(
389 DeRezAction action, IClientAPI remoteClient, SceneObjectGroup so, UUID folderID)
390 {
391 // Get the user info of the item destination
392 //
393 UUID userID = UUID.Zero;
394
395 if (action == DeRezAction.Take || action == DeRezAction.TakeCopy ||
396 action == DeRezAction.SaveToExistingUserInventoryItem)
397 {
398 // Take or take copy require a taker
399 // Saving changes requires a local user
400 //
401 if (remoteClient == null)
402 return null;
403
404 userID = remoteClient.AgentId;
405 }
406 else
407 {
408 // All returns / deletes go to the object owner
409 //
410 userID = so.RootPart.OwnerID;
411 }
412
413 if (userID == UUID.Zero) // Can't proceed
414 {
415 return null;
416 }
417
418 // If we're returning someone's item, it goes back to the
419 // owner's Lost And Found folder.
420 // Delete is treated like return in this case
421 // Deleting your own items makes them go to trash
422 //
423
424 InventoryFolderBase folder = null;
425 InventoryItemBase item = null;
426
427 if (DeRezAction.SaveToExistingUserInventoryItem == action)
428 {
429 item = new InventoryItemBase(so.RootPart.FromUserInventoryItemID, userID);
430 item = m_Scene.InventoryService.GetItem(item);
431
432 //item = userInfo.RootFolder.FindItem(
433 // objectGroup.RootPart.FromUserInventoryItemID);
434
435 if (null == item)
436 {
437 m_log.DebugFormat(
438 "[AGENT INVENTORY]: Object {0} {1} scheduled for save to inventory has already been deleted.",
439 so.Name, so.UUID);
440
441 return null;
442 }
443 }
444 else
445 {
446 // Folder magic
447 //
448 if (action == DeRezAction.Delete)
449 {
450 // Deleting someone else's item
451 //
452 if (remoteClient == null ||
453 so.OwnerID != remoteClient.AgentId)
454 {
455 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
456 }
457 else
458 {
459 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.TrashFolder);
460 }
461 }
462 else if (action == DeRezAction.Return)
463 {
464 // Dump to lost + found unconditionally
465 //
466 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
467 }
468
469 if (folderID == UUID.Zero && folder == null)
470 {
471 if (action == DeRezAction.Delete)
472 {
473 // Deletes go to trash by default
474 //
475 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.TrashFolder);
476 }
477 else
478 {
479 if (remoteClient == null || so.OwnerID != remoteClient.AgentId)
480 {
481 // Taking copy of another person's item. Take to
482 // Objects folder.
483 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.Object);
484 }
485 else
486 {
487 // Catch all. Use lost & found
488 //
489
490 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
491 }
492 }
493 }
494
495 // Override and put into where it came from, if it came
496 // from anywhere in inventory
497 //
498 if (action == DeRezAction.Take || action == DeRezAction.TakeCopy)
499 {
500 if (so.RootPart.FromFolderID != UUID.Zero)
501 {
502 InventoryFolderBase f = new InventoryFolderBase(so.RootPart.FromFolderID, userID);
503 folder = m_Scene.InventoryService.GetFolder(f);
504 }
505 }
506
507 if (folder == null) // None of the above
508 {
509 folder = new InventoryFolderBase(folderID);
510
511 if (folder == null) // Nowhere to put it
512 {
513 return null;
514 }
515 }
516
517 item = new InventoryItemBase();
518 item.ID = UUID.Random();
519 item.InvType = (int)InventoryType.Object;
520 item.Folder = folder.ID;
521 item.Owner = userID;
522 }
523
524 return item;
525 }
510 526
511 /// <summary> 527 /// <summary>
512 /// Rez an object into the scene from the user's inventory 528 /// Rez an object into the scene from the user's inventory