diff options
author | Mic Bowman | 2011-04-18 11:29:43 -0700 |
---|---|---|
committer | Mic Bowman | 2011-04-18 11:29:43 -0700 |
commit | 452ae375f0fdd62ba16fb170869ea470c6906cfe (patch) | |
tree | b5a7d364e509f2ff7f1b9086e2ba5658f4ee99ac /OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs | |
parent | Remove the call to remove tokens from the parent. Under heavy load (diff) | |
parent | Mantis #5442: Add admin_save_heightmap (diff) | |
download | opensim-SC_OLD-452ae375f0fdd62ba16fb170869ea470c6906cfe.zip opensim-SC_OLD-452ae375f0fdd62ba16fb170869ea470c6906cfe.tar.gz opensim-SC_OLD-452ae375f0fdd62ba16fb170869ea470c6906cfe.tar.bz2 opensim-SC_OLD-452ae375f0fdd62ba16fb170869ea470c6906cfe.tar.xz |
Merge branch 'master' into test-merge0418
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs | 416 |
1 files changed, 228 insertions, 188 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index c0946f4..a716326 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs | |||
@@ -274,238 +274,278 @@ 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; | 279 | return UUID.Zero; |
280 | 280 | ||
281 | if (action == DeRezAction.Take || action == DeRezAction.TakeCopy || | 281 | // Can't know creator is the same, so null it in inventory |
282 | action == DeRezAction.SaveToExistingUserInventoryItem) | 282 | if (objlist.Count > 1) |
283 | { | 283 | { |
284 | // Take or take copy require a taker | 284 | item.CreatorId = UUID.Zero.ToString(); |
285 | // Saving changes requires a local user | 285 | item.Flags = (uint)InventoryItemFlags.ObjectHasMultipleItems; |
286 | // | ||
287 | if (remoteClient == null) | ||
288 | return UUID.Zero; | ||
289 | |||
290 | userID = remoteClient.AgentId; | ||
291 | } | 286 | } |
292 | else | 287 | else |
293 | { | 288 | { |
294 | // All returns / deletes go to the object owner | 289 | item.CreatorId = objlist[0].RootPart.CreatorID.ToString(); |
295 | // | 290 | item.SaleType = objlist[0].RootPart.ObjectSaleType; |
296 | userID = objlist[0].RootPart.OwnerID; | 291 | item.SalePrice = objlist[0].RootPart.SalePrice; |
297 | } | 292 | } |
298 | 293 | ||
299 | if (userID == UUID.Zero) // Can't proceed | 294 | AssetBase asset = CreateAsset( |
300 | { | 295 | objlist[0].GetPartName(objlist[0].RootPart.LocalId), |
301 | return UUID.Zero; | 296 | objlist[0].GetPartDescription(objlist[0].RootPart.LocalId), |
302 | } | 297 | (sbyte)AssetType.Object, |
303 | 298 | Utils.StringToBytes(itemXml), | |
304 | // If we're returning someone's item, it goes back to the | 299 | objlist[0].OwnerID.ToString()); |
305 | // owner's Lost And Found folder. | 300 | m_Scene.AssetService.Store(asset); |
306 | // Delete is treated like return in this case | ||
307 | // Deleting your own items makes them go to trash | ||
308 | // | ||
309 | 301 | ||
310 | InventoryFolderBase folder = null; | 302 | item.AssetID = asset.FullID; |
311 | InventoryItemBase item = null; | 303 | assetID = asset.FullID; |
312 | 304 | ||
313 | if (DeRezAction.SaveToExistingUserInventoryItem == action) | 305 | if (DeRezAction.SaveToExistingUserInventoryItem == action) |
314 | { | 306 | { |
315 | item = new InventoryItemBase(objlist[0].RootPart.FromUserInventoryItemID, userID); | 307 | m_Scene.InventoryService.UpdateItem(item); |
316 | item = m_Scene.InventoryService.GetItem(item); | ||
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 | } | 308 | } |
329 | else | 309 | else |
330 | { | 310 | { |
331 | // Folder magic | 311 | AddPermissions(item, objlist[0], objlist, remoteClient); |
332 | // | ||
333 | if (action == DeRezAction.Delete) | ||
334 | { | ||
335 | // Deleting someone else's item | ||
336 | // | ||
337 | if (remoteClient == null || | ||
338 | objlist[0].OwnerID != remoteClient.AgentId) | ||
339 | { | ||
340 | 312 | ||
341 | folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); | 313 | item.CreationDate = Util.UnixTimeSinceEpoch(); |
342 | } | 314 | item.Description = asset.Description; |
343 | else | 315 | item.Name = asset.Name; |
344 | { | 316 | item.AssetType = asset.Type; |
345 | folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.TrashFolder); | ||
346 | } | ||
347 | } | ||
348 | else if (action == DeRezAction.Return) | ||
349 | { | ||
350 | 317 | ||
351 | // Dump to lost + found unconditionally | 318 | m_Scene.AddInventoryItem(item); |
352 | // | ||
353 | folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); | ||
354 | } | ||
355 | 319 | ||
356 | if (folderID == UUID.Zero && folder == null) | 320 | if (remoteClient != null && item.Owner == remoteClient.AgentId) |
357 | { | 321 | { |
358 | if (action == DeRezAction.Delete) | 322 | remoteClient.SendInventoryItemCreateUpdate(item, 0); |
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 | } | 323 | } |
382 | 324 | else | |
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 | { | 325 | { |
388 | if (objlist[0].RootPart.FromFolderID != UUID.Zero) | 326 | ScenePresence notifyUser = m_Scene.GetScenePresence(item.Owner); |
327 | if (notifyUser != null) | ||
389 | { | 328 | { |
390 | InventoryFolderBase f = new InventoryFolderBase(objlist[0].RootPart.FromFolderID, userID); | 329 | notifyUser.ControllingClient.SendInventoryItemCreateUpdate(item, 0); |
391 | folder = m_Scene.InventoryService.GetFolder(f); | ||
392 | } | 330 | } |
393 | } | 331 | } |
332 | } | ||
394 | 333 | ||
395 | if (folder == null) // None of the above | 334 | // This is a hook to do some per-asset post-processing for subclasses that need that |
396 | { | 335 | ExportAsset(remoteClient.AgentId, assetID); |
397 | folder = new InventoryFolderBase(folderID); | 336 | } |
337 | |||
338 | return assetID; | ||
339 | } | ||
398 | 340 | ||
399 | if (folder == null) // Nowhere to put it | 341 | protected virtual void ExportAsset(UUID agentID, UUID assetID) |
400 | { | 342 | { |
401 | return UUID.Zero; | 343 | // nothing to do here |
402 | } | 344 | } |
403 | } | ||
404 | 345 | ||
405 | item = new InventoryItemBase(); | 346 | /// <summary> |
406 | // Can't know creator is the same, so null it in inventory | 347 | /// Add relevant permissions for an object to the item. |
407 | if (objlist.Count > 1) | 348 | /// </summary> |
408 | item.CreatorId = UUID.Zero.ToString(); | 349 | /// <param name="item"></param> |
409 | else | 350 | /// <param name="so"></param> |
410 | item.CreatorId = objlist[0].RootPart.CreatorID.ToString(); | 351 | /// <param name="objsForEffectivePermissions"></param> |
411 | item.ID = UUID.Random(); | 352 | /// <param name="remoteClient"></param> |
412 | item.InvType = (int)InventoryType.Object; | 353 | /// <returns></returns> |
413 | item.Folder = folder.ID; | 354 | protected InventoryItemBase AddPermissions( |
414 | item.Owner = userID; | 355 | InventoryItemBase item, SceneObjectGroup so, List<SceneObjectGroup> objsForEffectivePermissions, |
415 | if (objlist.Count > 1) | 356 | IClientAPI remoteClient) |
357 | { | ||
358 | uint effectivePerms = (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify | PermissionMask.Move) | 7; | ||
359 | foreach (SceneObjectGroup grp in objsForEffectivePermissions) | ||
360 | effectivePerms &= grp.GetEffectivePermissions(); | ||
361 | effectivePerms |= (uint)PermissionMask.Move; | ||
362 | |||
363 | if (remoteClient != null && (remoteClient.AgentId != so.RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions()) | ||
364 | { | ||
365 | uint perms = effectivePerms; | ||
366 | uint nextPerms = (perms & 7) << 13; | ||
367 | if ((nextPerms & (uint)PermissionMask.Copy) == 0) | ||
368 | perms &= ~(uint)PermissionMask.Copy; | ||
369 | if ((nextPerms & (uint)PermissionMask.Transfer) == 0) | ||
370 | perms &= ~(uint)PermissionMask.Transfer; | ||
371 | if ((nextPerms & (uint)PermissionMask.Modify) == 0) | ||
372 | perms &= ~(uint)PermissionMask.Modify; | ||
373 | |||
374 | item.BasePermissions = perms & so.RootPart.NextOwnerMask; | ||
375 | item.CurrentPermissions = item.BasePermissions; | ||
376 | item.NextPermissions = perms & so.RootPart.NextOwnerMask; | ||
377 | item.EveryOnePermissions = so.RootPart.EveryoneMask & so.RootPart.NextOwnerMask; | ||
378 | item.GroupPermissions = so.RootPart.GroupMask & so.RootPart.NextOwnerMask; | ||
379 | |||
380 | // Magic number badness. Maybe this deserves an enum. | ||
381 | // bit 4 (16) is the "Slam" bit, it means treat as passed | ||
382 | // and apply next owner perms on rez | ||
383 | item.CurrentPermissions |= 16; // Slam! | ||
384 | } | ||
385 | else | ||
386 | { | ||
387 | item.BasePermissions = effectivePerms; | ||
388 | item.CurrentPermissions = effectivePerms; | ||
389 | item.NextPermissions = so.RootPart.NextOwnerMask & effectivePerms; | ||
390 | item.EveryOnePermissions = so.RootPart.EveryoneMask & effectivePerms; | ||
391 | item.GroupPermissions = so.RootPart.GroupMask & effectivePerms; | ||
392 | |||
393 | item.CurrentPermissions &= | ||
394 | ((uint)PermissionMask.Copy | | ||
395 | (uint)PermissionMask.Transfer | | ||
396 | (uint)PermissionMask.Modify | | ||
397 | (uint)PermissionMask.Move | | ||
398 | 7); // Preserve folded permissions | ||
399 | } | ||
400 | |||
401 | return item; | ||
402 | } | ||
403 | |||
404 | /// <summary> | ||
405 | /// Create an item using details for the given scene object. | ||
406 | /// </summary> | ||
407 | /// <param name="action"></param> | ||
408 | /// <param name="remoteClient"></param> | ||
409 | /// <param name="so"></param> | ||
410 | /// <param name="folderID"></param> | ||
411 | /// <returns></returns> | ||
412 | protected InventoryItemBase CreateItemForObject( | ||
413 | DeRezAction action, IClientAPI remoteClient, SceneObjectGroup so, UUID folderID) | ||
414 | { | ||
415 | // Get the user info of the item destination | ||
416 | // | ||
417 | UUID userID = UUID.Zero; | ||
418 | |||
419 | if (action == DeRezAction.Take || action == DeRezAction.TakeCopy || | ||
420 | action == DeRezAction.SaveToExistingUserInventoryItem) | ||
421 | { | ||
422 | // Take or take copy require a taker | ||
423 | // Saving changes requires a local user | ||
424 | // | ||
425 | if (remoteClient == null) | ||
426 | return null; | ||
427 | |||
428 | userID = remoteClient.AgentId; | ||
429 | } | ||
430 | else | ||
431 | { | ||
432 | // All returns / deletes go to the object owner | ||
433 | // | ||
434 | userID = so.RootPart.OwnerID; | ||
435 | } | ||
436 | |||
437 | if (userID == UUID.Zero) // Can't proceed | ||
438 | { | ||
439 | return null; | ||
440 | } | ||
441 | |||
442 | // If we're returning someone's item, it goes back to the | ||
443 | // owner's Lost And Found folder. | ||
444 | // Delete is treated like return in this case | ||
445 | // Deleting your own items makes them go to trash | ||
446 | // | ||
447 | |||
448 | InventoryFolderBase folder = null; | ||
449 | InventoryItemBase item = null; | ||
450 | |||
451 | if (DeRezAction.SaveToExistingUserInventoryItem == action) | ||
452 | { | ||
453 | item = new InventoryItemBase(so.RootPart.FromUserInventoryItemID, userID); | ||
454 | item = m_Scene.InventoryService.GetItem(item); | ||
455 | |||
456 | //item = userInfo.RootFolder.FindItem( | ||
457 | // objectGroup.RootPart.FromUserInventoryItemID); | ||
458 | |||
459 | if (null == item) | ||
460 | { | ||
461 | m_log.DebugFormat( | ||
462 | "[AGENT INVENTORY]: Object {0} {1} scheduled for save to inventory has already been deleted.", | ||
463 | so.Name, so.UUID); | ||
464 | |||
465 | return null; | ||
466 | } | ||
467 | } | ||
468 | else | ||
469 | { | ||
470 | // Folder magic | ||
471 | // | ||
472 | if (action == DeRezAction.Delete) | ||
473 | { | ||
474 | // Deleting someone else's item | ||
475 | // | ||
476 | if (remoteClient == null || | ||
477 | so.OwnerID != remoteClient.AgentId) | ||
416 | { | 478 | { |
417 | item.Flags = (uint)InventoryItemFlags.ObjectHasMultipleItems; | 479 | folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); |
418 | } | 480 | } |
419 | else | 481 | else |
420 | { | 482 | { |
421 | item.SaleType = objlist[0].RootPart.ObjectSaleType; | 483 | folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.TrashFolder); |
422 | item.SalePrice = objlist[0].RootPart.SalePrice; | ||
423 | } | 484 | } |
424 | } | 485 | } |
425 | 486 | else if (action == DeRezAction.Return) | |
426 | AssetBase asset = CreateAsset( | ||
427 | objlist[0].GetPartName(objlist[0].RootPart.LocalId), | ||
428 | objlist[0].GetPartDescription(objlist[0].RootPart.LocalId), | ||
429 | (sbyte)AssetType.Object, | ||
430 | Utils.StringToBytes(itemXml), | ||
431 | objlist[0].OwnerID.ToString()); | ||
432 | m_Scene.AssetService.Store(asset); | ||
433 | assetID = asset.FullID; | ||
434 | |||
435 | if (DeRezAction.SaveToExistingUserInventoryItem == action) | ||
436 | { | 487 | { |
437 | item.AssetID = asset.FullID; | 488 | // Dump to lost + found unconditionally |
438 | m_Scene.InventoryService.UpdateItem(item); | 489 | // |
490 | folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); | ||
439 | } | 491 | } |
440 | else | ||
441 | { | ||
442 | item.AssetID = asset.FullID; | ||
443 | 492 | ||
444 | uint effectivePerms = (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify | PermissionMask.Move) | 7; | 493 | if (folderID == UUID.Zero && folder == null) |
445 | foreach (SceneObjectGroup grp in objlist) | 494 | { |
446 | effectivePerms &= grp.GetEffectivePermissions(); | 495 | if (action == DeRezAction.Delete) |
447 | effectivePerms |= (uint)PermissionMask.Move; | ||
448 | |||
449 | if (remoteClient != null && (remoteClient.AgentId != objlist[0].RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions()) | ||
450 | { | 496 | { |
451 | uint perms = effectivePerms; | 497 | // Deletes go to trash by default |
452 | uint nextPerms = (perms & 7) << 13; | 498 | // |
453 | if ((nextPerms & (uint)PermissionMask.Copy) == 0) | 499 | folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.TrashFolder); |
454 | perms &= ~(uint)PermissionMask.Copy; | ||
455 | if ((nextPerms & (uint)PermissionMask.Transfer) == 0) | ||
456 | perms &= ~(uint)PermissionMask.Transfer; | ||
457 | if ((nextPerms & (uint)PermissionMask.Modify) == 0) | ||
458 | perms &= ~(uint)PermissionMask.Modify; | ||
459 | |||
460 | item.BasePermissions = perms & objlist[0].RootPart.NextOwnerMask; | ||
461 | item.CurrentPermissions = item.BasePermissions; | ||
462 | item.NextPermissions = perms & objlist[0].RootPart.NextOwnerMask; | ||
463 | item.EveryOnePermissions = objlist[0].RootPart.EveryoneMask & objlist[0].RootPart.NextOwnerMask; | ||
464 | item.GroupPermissions = objlist[0].RootPart.GroupMask & objlist[0].RootPart.NextOwnerMask; | ||
465 | |||
466 | // Magic number badness. Maybe this deserves an enum. | ||
467 | // bit 4 (16) is the "Slam" bit, it means treat as passed | ||
468 | // and apply next owner perms on rez | ||
469 | item.CurrentPermissions |= 16; // Slam! | ||
470 | } | 500 | } |
471 | else | 501 | else |
472 | { | 502 | { |
473 | item.BasePermissions = effectivePerms; | 503 | if (remoteClient == null || so.OwnerID != remoteClient.AgentId) |
474 | item.CurrentPermissions = effectivePerms; | 504 | { |
475 | item.NextPermissions = objlist[0].RootPart.NextOwnerMask & effectivePerms; | 505 | // Taking copy of another person's item. Take to |
476 | item.EveryOnePermissions = objlist[0].RootPart.EveryoneMask & effectivePerms; | 506 | // Objects folder. |
477 | item.GroupPermissions = objlist[0].RootPart.GroupMask & effectivePerms; | 507 | folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.Object); |
478 | 508 | } | |
479 | item.CurrentPermissions &= | 509 | else |
480 | ((uint)PermissionMask.Copy | | 510 | { |
481 | (uint)PermissionMask.Transfer | | 511 | // Catch all. Use lost & found |
482 | (uint)PermissionMask.Modify | | 512 | // |
483 | (uint)PermissionMask.Move | | ||
484 | 7); // Preserve folded permissions | ||
485 | } | ||
486 | |||
487 | item.CreationDate = Util.UnixTimeSinceEpoch(); | ||
488 | item.Description = asset.Description; | ||
489 | item.Name = asset.Name; | ||
490 | item.AssetType = asset.Type; | ||
491 | 513 | ||
492 | m_Scene.AddInventoryItem(item); | 514 | folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); |
515 | } | ||
516 | } | ||
517 | } | ||
493 | 518 | ||
494 | if (remoteClient != null && item.Owner == remoteClient.AgentId) | 519 | // Override and put into where it came from, if it came |
520 | // from anywhere in inventory | ||
521 | // | ||
522 | if (action == DeRezAction.Take || action == DeRezAction.TakeCopy) | ||
523 | { | ||
524 | if (so.RootPart.FromFolderID != UUID.Zero) | ||
495 | { | 525 | { |
496 | remoteClient.SendInventoryItemCreateUpdate(item, 0); | 526 | InventoryFolderBase f = new InventoryFolderBase(so.RootPart.FromFolderID, userID); |
527 | folder = m_Scene.InventoryService.GetFolder(f); | ||
497 | } | 528 | } |
498 | else | 529 | } |
530 | |||
531 | if (folder == null) // None of the above | ||
532 | { | ||
533 | folder = new InventoryFolderBase(folderID); | ||
534 | |||
535 | if (folder == null) // Nowhere to put it | ||
499 | { | 536 | { |
500 | ScenePresence notifyUser = m_Scene.GetScenePresence(item.Owner); | 537 | return null; |
501 | if (notifyUser != null) | ||
502 | { | ||
503 | notifyUser.ControllingClient.SendInventoryItemCreateUpdate(item, 0); | ||
504 | } | ||
505 | } | 538 | } |
506 | } | 539 | } |
507 | } | 540 | |
508 | return assetID; | 541 | item = new InventoryItemBase(); |
542 | item.ID = UUID.Random(); | ||
543 | item.InvType = (int)InventoryType.Object; | ||
544 | item.Folder = folder.ID; | ||
545 | item.Owner = userID; | ||
546 | } | ||
547 | |||
548 | return item; | ||
509 | } | 549 | } |
510 | 550 | ||
511 | /// <summary> | 551 | /// <summary> |