diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.Inventory.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 281 |
1 files changed, 174 insertions, 107 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index b62023b..dd3208a 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | |||
@@ -979,25 +979,40 @@ namespace OpenSim.Region.Framework.Scenes | |||
979 | public void RemoveTaskInventory(IClientAPI remoteClient, UUID itemID, uint localID) | 979 | public void RemoveTaskInventory(IClientAPI remoteClient, UUID itemID, uint localID) |
980 | { | 980 | { |
981 | SceneObjectPart part = GetSceneObjectPart(localID); | 981 | SceneObjectPart part = GetSceneObjectPart(localID); |
982 | if (part == null) | 982 | SceneObjectGroup group = null; |
983 | return; | 983 | if (part != null) |
984 | { | ||
985 | group = part.ParentGroup; | ||
986 | } | ||
987 | if (part != null && group != null) | ||
988 | { | ||
989 | if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId)) | ||
990 | return; | ||
984 | 991 | ||
985 | SceneObjectGroup group = part.ParentGroup; | 992 | TaskInventoryItem item = group.GetInventoryItem(localID, itemID); |
986 | if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId)) | 993 | if (item == null) |
987 | return; | 994 | return; |
988 | |||
989 | TaskInventoryItem item = group.GetInventoryItem(localID, itemID); | ||
990 | if (item == null) | ||
991 | return; | ||
992 | 995 | ||
993 | if (item.Type == 10) | 996 | InventoryFolderBase destFolder = InventoryService.GetFolderForType(remoteClient.AgentId, AssetType.TrashFolder); |
994 | { | 997 | |
995 | part.RemoveScriptEvents(itemID); | 998 | // Move the item to trash. If this is a copiable item, only |
996 | EventManager.TriggerRemoveScript(localID, itemID); | 999 | // a copy will be moved and we will still need to delete |
1000 | // the item from the prim. If it was no copy, is will be | ||
1001 | // deleted by this method. | ||
1002 | MoveTaskInventoryItem(remoteClient, destFolder.ID, part, itemID); | ||
1003 | |||
1004 | if (group.GetInventoryItem(localID, itemID) != null) | ||
1005 | { | ||
1006 | if (item.Type == 10) | ||
1007 | { | ||
1008 | part.RemoveScriptEvents(itemID); | ||
1009 | EventManager.TriggerRemoveScript(localID, itemID); | ||
1010 | } | ||
1011 | |||
1012 | group.RemoveInventoryItem(localID, itemID); | ||
1013 | } | ||
1014 | part.SendPropertiesToClient(remoteClient); | ||
997 | } | 1015 | } |
998 | |||
999 | group.RemoveInventoryItem(localID, itemID); | ||
1000 | part.SendPropertiesToClient(remoteClient); | ||
1001 | } | 1016 | } |
1002 | 1017 | ||
1003 | private InventoryItemBase CreateAgentInventoryItemFromTask(UUID destAgent, SceneObjectPart part, UUID itemId) | 1018 | private InventoryItemBase CreateAgentInventoryItemFromTask(UUID destAgent, SceneObjectPart part, UUID itemId) |
@@ -1058,7 +1073,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
1058 | if (!Permissions.BypassPermissions()) | 1073 | if (!Permissions.BypassPermissions()) |
1059 | { | 1074 | { |
1060 | if ((taskItem.CurrentPermissions & (uint)PermissionMask.Copy) == 0) | 1075 | if ((taskItem.CurrentPermissions & (uint)PermissionMask.Copy) == 0) |
1076 | { | ||
1077 | if (taskItem.Type == 10) | ||
1078 | { | ||
1079 | part.RemoveScriptEvents(itemId); | ||
1080 | EventManager.TriggerRemoveScript(part.LocalId, itemId); | ||
1081 | } | ||
1082 | |||
1061 | part.Inventory.RemoveInventoryItem(itemId); | 1083 | part.Inventory.RemoveInventoryItem(itemId); |
1084 | } | ||
1062 | } | 1085 | } |
1063 | 1086 | ||
1064 | return agentItem; | 1087 | return agentItem; |
@@ -1421,7 +1444,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1421 | // If we've found the item in the user's inventory or in the library | 1444 | // If we've found the item in the user's inventory or in the library |
1422 | if (item != null) | 1445 | if (item != null) |
1423 | { | 1446 | { |
1424 | part.ParentGroup.AddInventoryItem(remoteClient, primLocalID, item, copyID); | 1447 | part.ParentGroup.AddInventoryItem(remoteClient.AgentId, primLocalID, item, copyID); |
1425 | m_log.InfoFormat( | 1448 | m_log.InfoFormat( |
1426 | "[PRIM INVENTORY]: Update with item {0} requested of prim {1} for {2}", | 1449 | "[PRIM INVENTORY]: Update with item {0} requested of prim {1} for {2}", |
1427 | item.Name, primLocalID, remoteClient.Name); | 1450 | item.Name, primLocalID, remoteClient.Name); |
@@ -1449,20 +1472,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
1449 | // m_log.DebugFormat( | 1472 | // m_log.DebugFormat( |
1450 | // "[PRIM INVENTORY]: Updating item {0} in {1} for UpdateTaskInventory()", | 1473 | // "[PRIM INVENTORY]: Updating item {0} in {1} for UpdateTaskInventory()", |
1451 | // currentItem.Name, part.Name); | 1474 | // currentItem.Name, part.Name); |
1452 | |||
1453 | IAgentAssetTransactions agentTransactions = this.RequestModuleInterface<IAgentAssetTransactions>(); | ||
1454 | if (agentTransactions != null) | ||
1455 | { | ||
1456 | agentTransactions.HandleTaskItemUpdateFromTransaction( | ||
1457 | remoteClient, part, transactionID, currentItem); | ||
1458 | 1475 | ||
1459 | if ((InventoryType)itemInfo.InvType == InventoryType.Notecard) | 1476 | // Viewers from at least Linden Lab 1.23 onwards use a capability to update script contents rather |
1460 | remoteClient.SendAgentAlertMessage("Notecard saved", false); | 1477 | // than UDP. With viewers from at least 1.23 onwards, changing properties on scripts (e.g. renaming) causes |
1461 | else if ((InventoryType)itemInfo.InvType == InventoryType.LSL) | 1478 | // this to spew spurious errors and "thing saved" messages. |
1462 | remoteClient.SendAgentAlertMessage("Script saved", false); | 1479 | // Rather than retaining complexity in the code and removing useful error messages, I'm going to |
1463 | else | 1480 | // comment this section out. If this was still working for very old viewers and there is |
1464 | remoteClient.SendAgentAlertMessage("Item saved", false); | 1481 | // a large population using them which cannot upgrade to 1.23 or derivatives then we can revisit |
1465 | } | 1482 | // this - justincc |
1483 | // IAgentAssetTransactions agentTransactions = this.RequestModuleInterface<IAgentAssetTransactions>(); | ||
1484 | // if (agentTransactions != null) | ||
1485 | // { | ||
1486 | // agentTransactions.HandleTaskItemUpdateFromTransaction( | ||
1487 | // remoteClient, part, transactionID, currentItem); | ||
1488 | // | ||
1489 | // if ((InventoryType)itemInfo.InvType == InventoryType.Notecard) | ||
1490 | // remoteClient.SendAgentAlertMessage("Notecard saved", false); | ||
1491 | // else if ((InventoryType)itemInfo.InvType == InventoryType.LSL) | ||
1492 | // remoteClient.SendAgentAlertMessage("Script saved", false); | ||
1493 | // else | ||
1494 | // remoteClient.SendAgentAlertMessage("Item saved", false); | ||
1495 | // } | ||
1466 | 1496 | ||
1467 | // Base ALWAYS has move | 1497 | // Base ALWAYS has move |
1468 | currentItem.BasePermissions |= (uint)PermissionMask.Move; | 1498 | currentItem.BasePermissions |= (uint)PermissionMask.Move; |
@@ -1537,104 +1567,141 @@ namespace OpenSim.Region.Framework.Scenes | |||
1537 | /// Rez a script into a prim's inventory, either ex nihilo or from an existing avatar inventory | 1567 | /// Rez a script into a prim's inventory, either ex nihilo or from an existing avatar inventory |
1538 | /// </summary> | 1568 | /// </summary> |
1539 | /// <param name="remoteClient"></param> | 1569 | /// <param name="remoteClient"></param> |
1540 | /// <param name="itemID"> </param> | 1570 | /// <param name="itemBase"> </param> |
1571 | /// <param name="transactionID"></param> | ||
1541 | /// <param name="localID"></param> | 1572 | /// <param name="localID"></param> |
1542 | public void RezScript(IClientAPI remoteClient, InventoryItemBase itemBase, UUID transactionID, uint localID) | 1573 | public void RezScript(IClientAPI remoteClient, InventoryItemBase itemBase, UUID transactionID, uint localID) |
1543 | { | 1574 | { |
1544 | UUID itemID = itemBase.ID; | 1575 | SceneObjectPart partWhereRezzed; |
1576 | |||
1577 | if (itemBase.ID != UUID.Zero) | ||
1578 | partWhereRezzed = RezScriptFromAgentInventory(remoteClient.AgentId, itemBase.ID, localID); | ||
1579 | else | ||
1580 | partWhereRezzed = RezNewScript(remoteClient.AgentId, itemBase); | ||
1581 | |||
1582 | if (partWhereRezzed != null) | ||
1583 | partWhereRezzed.SendPropertiesToClient(remoteClient); | ||
1584 | } | ||
1585 | |||
1586 | /// <summary> | ||
1587 | /// Rez a script into a prim from an agent inventory. | ||
1588 | /// </summary> | ||
1589 | /// <param name="agentID"></param> | ||
1590 | /// <param name="fromItemID"></param> | ||
1591 | /// <param name="localID"></param> | ||
1592 | /// <returns>The part where the script was rezzed if successful. False otherwise.</returns> | ||
1593 | public SceneObjectPart RezScriptFromAgentInventory(UUID agentID, UUID fromItemID, uint localID) | ||
1594 | { | ||
1545 | UUID copyID = UUID.Random(); | 1595 | UUID copyID = UUID.Random(); |
1596 | InventoryItemBase item = new InventoryItemBase(fromItemID, agentID); | ||
1597 | item = InventoryService.GetItem(item); | ||
1546 | 1598 | ||
1547 | if (itemID != UUID.Zero) // transferred from an avatar inventory to the prim's inventory | 1599 | // Try library |
1600 | // XXX clumsy, possibly should be one call | ||
1601 | if (null == item && LibraryService != null && LibraryService.LibraryRootFolder != null) | ||
1548 | { | 1602 | { |
1549 | InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); | 1603 | item = LibraryService.LibraryRootFolder.FindItem(fromItemID); |
1550 | item = InventoryService.GetItem(item); | 1604 | } |
1551 | 1605 | ||
1552 | // Try library | 1606 | if (item != null) |
1553 | // XXX clumsy, possibly should be one call | 1607 | { |
1554 | if (null == item && LibraryService != null && LibraryService.LibraryRootFolder != null) | 1608 | SceneObjectPart part = GetSceneObjectPart(localID); |
1609 | if (part != null) | ||
1555 | { | 1610 | { |
1556 | item = LibraryService.LibraryRootFolder.FindItem(itemID); | 1611 | if (!Permissions.CanEditObjectInventory(part.UUID, agentID)) |
1557 | } | 1612 | return null; |
1558 | 1613 | ||
1559 | if (item != null) | 1614 | part.ParentGroup.AddInventoryItem(agentID, localID, item, copyID); |
1560 | { | 1615 | // TODO: switch to posting on_rez here when scripts |
1561 | SceneObjectPart part = GetSceneObjectPart(localID); | 1616 | // have state in inventory |
1562 | if (part != null) | 1617 | part.Inventory.CreateScriptInstance(copyID, 0, false, DefaultScriptEngine, 0); |
1563 | { | ||
1564 | if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId)) | ||
1565 | return; | ||
1566 | 1618 | ||
1567 | part.ParentGroup.AddInventoryItem(remoteClient, localID, item, copyID); | 1619 | // m_log.InfoFormat("[PRIMINVENTORY]: " + |
1568 | // TODO: switch to posting on_rez here when scripts | 1620 | // "Rezzed script {0} into prim local ID {1} for user {2}", |
1569 | // have state in inventory | 1621 | // item.inventoryName, localID, remoteClient.Name); |
1570 | part.Inventory.CreateScriptInstance(copyID, 0, false, DefaultScriptEngine, 0); | 1622 | part.ParentGroup.ResumeScripts(); |
1571 | 1623 | ||
1572 | // m_log.InfoFormat("[PRIMINVENTORY]: " + | 1624 | return part; |
1573 | // "Rezzed script {0} into prim local ID {1} for user {2}", | ||
1574 | // item.inventoryName, localID, remoteClient.Name); | ||
1575 | part.SendPropertiesToClient(remoteClient); | ||
1576 | part.ParentGroup.ResumeScripts(); | ||
1577 | } | ||
1578 | else | ||
1579 | { | ||
1580 | m_log.ErrorFormat( | ||
1581 | "[PRIM INVENTORY]: " + | ||
1582 | "Could not rez script {0} into prim local ID {1} for user {2}" | ||
1583 | + " because the prim could not be found in the region!", | ||
1584 | item.Name, localID, remoteClient.Name); | ||
1585 | } | ||
1586 | } | 1625 | } |
1587 | else | 1626 | else |
1588 | { | 1627 | { |
1589 | m_log.ErrorFormat( | 1628 | m_log.ErrorFormat( |
1590 | "[PRIM INVENTORY]: Could not find script inventory item {0} to rez for {1}!", | 1629 | "[PRIM INVENTORY]: " + |
1591 | itemID, remoteClient.Name); | 1630 | "Could not rez script {0} into prim local ID {1} for user {2}" |
1631 | + " because the prim could not be found in the region!", | ||
1632 | item.Name, localID, agentID); | ||
1592 | } | 1633 | } |
1593 | } | 1634 | } |
1594 | else // script has been rezzed directly into a prim's inventory | 1635 | else |
1595 | { | 1636 | { |
1596 | SceneObjectPart part = GetSceneObjectPart(itemBase.Folder); | 1637 | m_log.ErrorFormat( |
1597 | if (part == null) | 1638 | "[PRIM INVENTORY]: Could not find script inventory item {0} to rez for {1}!", |
1598 | return; | 1639 | fromItemID, agentID); |
1640 | } | ||
1599 | 1641 | ||
1600 | if (!Permissions.CanCreateObjectInventory( | 1642 | return null; |
1601 | itemBase.InvType, part.UUID, remoteClient.AgentId)) | 1643 | } |
1602 | return; | ||
1603 | 1644 | ||
1604 | AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, | 1645 | /// <summary> |
1605 | Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n}"), | 1646 | /// Rez a new script from nothing. |
1606 | remoteClient.AgentId); | 1647 | /// </summary> |
1607 | AssetService.Store(asset); | 1648 | /// <param name="remoteClient"></param> |
1608 | 1649 | /// <param name="itemBase"></param> | |
1609 | TaskInventoryItem taskItem = new TaskInventoryItem(); | 1650 | /// <returns>The part where the script was rezzed if successful. False otherwise.</returns> |
1610 | 1651 | public SceneObjectPart RezNewScript(UUID agentID, InventoryItemBase itemBase) | |
1611 | taskItem.ResetIDs(itemBase.Folder); | 1652 | { |
1612 | taskItem.ParentID = itemBase.Folder; | 1653 | // The part ID is the folder ID! |
1613 | taskItem.CreationDate = (uint)itemBase.CreationDate; | 1654 | SceneObjectPart part = GetSceneObjectPart(itemBase.Folder); |
1614 | taskItem.Name = itemBase.Name; | 1655 | if (part == null) |
1615 | taskItem.Description = itemBase.Description; | 1656 | { |
1616 | taskItem.Type = itemBase.AssetType; | 1657 | // m_log.DebugFormat( |
1617 | taskItem.InvType = itemBase.InvType; | 1658 | // "[SCENE INVENTORY]: Could not find part with id {0} for {1} to rez new script", |
1618 | taskItem.OwnerID = itemBase.Owner; | 1659 | // itemBase.Folder, agentID); |
1619 | taskItem.CreatorID = itemBase.CreatorIdAsUuid; | ||
1620 | taskItem.BasePermissions = itemBase.BasePermissions; | ||
1621 | taskItem.CurrentPermissions = itemBase.CurrentPermissions; | ||
1622 | taskItem.EveryonePermissions = itemBase.EveryOnePermissions; | ||
1623 | taskItem.GroupPermissions = itemBase.GroupPermissions; | ||
1624 | taskItem.NextPermissions = itemBase.NextPermissions; | ||
1625 | taskItem.GroupID = itemBase.GroupID; | ||
1626 | taskItem.GroupPermissions = 0; | ||
1627 | taskItem.Flags = itemBase.Flags; | ||
1628 | taskItem.PermsGranter = UUID.Zero; | ||
1629 | taskItem.PermsMask = 0; | ||
1630 | taskItem.AssetID = asset.FullID; | ||
1631 | |||
1632 | part.Inventory.AddInventoryItem(taskItem, false); | ||
1633 | part.SendPropertiesToClient(remoteClient); | ||
1634 | 1660 | ||
1635 | part.Inventory.CreateScriptInstance(taskItem, 0, false, DefaultScriptEngine, 0); | 1661 | return null; |
1636 | part.ParentGroup.ResumeScripts(); | 1662 | } |
1663 | |||
1664 | if (!Permissions.CanCreateObjectInventory(itemBase.InvType, part.UUID, agentID)) | ||
1665 | { | ||
1666 | // m_log.DebugFormat( | ||
1667 | // "[SCENE INVENTORY]: No permission to create new script in {0} for {1}", part.Name, agentID); | ||
1668 | |||
1669 | return null; | ||
1637 | } | 1670 | } |
1671 | |||
1672 | AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, | ||
1673 | Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n}"), | ||
1674 | agentID); | ||
1675 | AssetService.Store(asset); | ||
1676 | |||
1677 | TaskInventoryItem taskItem = new TaskInventoryItem(); | ||
1678 | |||
1679 | taskItem.ResetIDs(itemBase.Folder); | ||
1680 | taskItem.ParentID = itemBase.Folder; | ||
1681 | taskItem.CreationDate = (uint)itemBase.CreationDate; | ||
1682 | taskItem.Name = itemBase.Name; | ||
1683 | taskItem.Description = itemBase.Description; | ||
1684 | taskItem.Type = itemBase.AssetType; | ||
1685 | taskItem.InvType = itemBase.InvType; | ||
1686 | taskItem.OwnerID = itemBase.Owner; | ||
1687 | taskItem.CreatorID = itemBase.CreatorIdAsUuid; | ||
1688 | taskItem.BasePermissions = itemBase.BasePermissions; | ||
1689 | taskItem.CurrentPermissions = itemBase.CurrentPermissions; | ||
1690 | taskItem.EveryonePermissions = itemBase.EveryOnePermissions; | ||
1691 | taskItem.GroupPermissions = itemBase.GroupPermissions; | ||
1692 | taskItem.NextPermissions = itemBase.NextPermissions; | ||
1693 | taskItem.GroupID = itemBase.GroupID; | ||
1694 | taskItem.GroupPermissions = 0; | ||
1695 | taskItem.Flags = itemBase.Flags; | ||
1696 | taskItem.PermsGranter = UUID.Zero; | ||
1697 | taskItem.PermsMask = 0; | ||
1698 | taskItem.AssetID = asset.FullID; | ||
1699 | |||
1700 | part.Inventory.AddInventoryItem(taskItem, false); | ||
1701 | part.Inventory.CreateScriptInstance(taskItem, 0, false, DefaultScriptEngine, 0); | ||
1702 | part.ParentGroup.ResumeScripts(); | ||
1703 | |||
1704 | return part; | ||
1638 | } | 1705 | } |
1639 | 1706 | ||
1640 | /// <summary> | 1707 | /// <summary> |
@@ -1643,7 +1710,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1643 | /// <param name="remoteClient"></param> | 1710 | /// <param name="remoteClient"></param> |
1644 | /// <param name="itemID"> </param> | 1711 | /// <param name="itemID"> </param> |
1645 | /// <param name="localID"></param> | 1712 | /// <param name="localID"></param> |
1646 | public void RezScript(UUID srcId, SceneObjectPart srcPart, UUID destId, int pin, int running, int start_param) | 1713 | public void RezScriptFromPrim(UUID srcId, SceneObjectPart srcPart, UUID destId, int pin, int running, int start_param) |
1647 | { | 1714 | { |
1648 | TaskInventoryItem srcTaskItem = srcPart.Inventory.GetInventoryItem(srcId); | 1715 | TaskInventoryItem srcTaskItem = srcPart.Inventory.GetInventoryItem(srcId); |
1649 | 1716 | ||