aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Scenes/Scene.Inventory.cs')
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.Inventory.cs170
1 files changed, 110 insertions, 60 deletions
diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
index 7c518c4..c1decaa 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
@@ -1686,7 +1686,15 @@ namespace OpenSim.Region.Environment.Scenes
1686 bool permissionToTake = false; 1686 bool permissionToTake = false;
1687 bool permissionToDelete = false; 1687 bool permissionToDelete = false;
1688 1688
1689 if (action == DeRezAction.TakeCopy) 1689 if (action == DeRezAction.SaveToExistingUserInventoryItem)
1690 {
1691 if (grp.OwnerID == remoteClient.AgentId && grp.RootPart.FromUserInventoryItemID != UUID.Zero)
1692 {
1693 permissionToTake = true;
1694 permissionToDelete = false;
1695 }
1696 }
1697 else if (action == DeRezAction.TakeCopy)
1690 { 1698 {
1691 permissionToTake = 1699 permissionToTake =
1692 Permissions.CanTakeCopyObject( 1700 Permissions.CanTakeCopyObject(
@@ -1726,6 +1734,7 @@ namespace OpenSim.Region.Environment.Scenes
1726 grp.UUID, 1734 grp.UUID,
1727 remoteClient.AgentId); 1735 remoteClient.AgentId);
1728 permissionToDelete = permissionToTake; 1736 permissionToDelete = permissionToTake;
1737
1729 if (permissionToDelete) 1738 if (permissionToDelete)
1730 { 1739 {
1731 AddReturn(grp.OwnerID, grp.Name, grp.AbsolutePosition, "parcel owner return"); 1740 AddReturn(grp.OwnerID, grp.Name, grp.AbsolutePosition, "parcel owner return");
@@ -1737,6 +1746,12 @@ namespace OpenSim.Region.Environment.Scenes
1737 permissionToDelete = true; 1746 permissionToDelete = true;
1738 } 1747 }
1739 } 1748 }
1749 else
1750 {
1751 m_log.DebugFormat(
1752 "[AGENT INVENTORY]: Ignoring unexpected derez action {0} for {1}", action, remoteClient.Name);
1753 return;
1754 }
1740 1755
1741 if (permissionToTake) 1756 if (permissionToTake)
1742 { 1757 {
@@ -1769,13 +1784,11 @@ namespace OpenSim.Region.Environment.Scenes
1769 1784
1770 if (remoteClient == null) 1785 if (remoteClient == null)
1771 { 1786 {
1772 userInfo = CommsManager.UserProfileCacheService.GetUserDetails( 1787 userInfo = CommsManager.UserProfileCacheService.GetUserDetails(objectGroup.RootPart.OwnerID);
1773 objectGroup.RootPart.OwnerID);
1774 } 1788 }
1775 else 1789 else
1776 { 1790 {
1777 userInfo = CommsManager.UserProfileCacheService.GetUserDetails( 1791 userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
1778 remoteClient.AgentId);
1779 } 1792 }
1780 1793
1781 if (userInfo != null) 1794 if (userInfo != null)
@@ -1785,8 +1798,8 @@ namespace OpenSim.Region.Environment.Scenes
1785 // If we're returning someone's item, it goes back to the 1798 // If we're returning someone's item, it goes back to the
1786 // owner's Lost And Found folder. 1799 // owner's Lost And Found folder.
1787 1800
1788 if (folderID == UUID.Zero || (action == DeRezAction.Delete && 1801 if (folderID == UUID.Zero
1789 objectGroup.OwnerID != remoteClient.AgentId)) 1802 || (action == DeRezAction.Delete && objectGroup.OwnerID != remoteClient.AgentId))
1790 { 1803 {
1791 InventoryFolderBase folder = 1804 InventoryFolderBase folder =
1792 userInfo.FindFolderForType( 1805 userInfo.FindFolderForType(
@@ -1811,6 +1824,21 @@ namespace OpenSim.Region.Environment.Scenes
1811 } 1824 }
1812 } 1825 }
1813 1826
1827 InventoryItemBase item = null;
1828
1829 if (DeRezAction.SaveToExistingUserInventoryItem == action)
1830 {
1831 item = userInfo.RootFolder.FindItem(objectGroup.RootPart.FromUserInventoryItemID);
1832
1833 if (null == item)
1834 {
1835 m_log.DebugFormat(
1836 "[AGENT INVENTORY]: Object {0} {1} scheduled for save to inventory has already been deleted.",
1837 objectGroup.Name, objectGroup.UUID);
1838 return UUID.Zero;
1839 }
1840 }
1841
1814 AssetBase asset = CreateAsset( 1842 AssetBase asset = CreateAsset(
1815 objectGroup.GetPartName(objectGroup.RootPart.LocalId), 1843 objectGroup.GetPartName(objectGroup.RootPart.LocalId),
1816 objectGroup.GetPartDescription(objectGroup.RootPart.LocalId), 1844 objectGroup.GetPartDescription(objectGroup.RootPart.LocalId),
@@ -1818,65 +1846,74 @@ namespace OpenSim.Region.Environment.Scenes
1818 Utils.StringToBytes(sceneObjectXml)); 1846 Utils.StringToBytes(sceneObjectXml));
1819 AssetCache.AddAsset(asset); 1847 AssetCache.AddAsset(asset);
1820 assetID = asset.FullID; 1848 assetID = asset.FullID;
1821
1822 InventoryItemBase item = new InventoryItemBase();
1823 item.Creator = objectGroup.RootPart.CreatorID;
1824
1825 if (action == DeRezAction.TakeCopy || action == DeRezAction.Take)
1826 item.Owner = remoteClient.AgentId;
1827 else // Delete / Return
1828 item.Owner = objectGroup.OwnerID;
1829
1830 item.ID = UUID.Random();
1831 item.AssetID = asset.FullID;
1832 item.Description = asset.Description;
1833 item.Name = asset.Name;
1834 item.AssetType = asset.Type;
1835 item.InvType = (int)InventoryType.Object;
1836 item.Folder = folderID;
1837 1849
1838 if (remoteClient != null && (remoteClient.AgentId != objectGroup.RootPart.OwnerID) && Permissions.PropagatePermissions()) 1850 if (DeRezAction.SaveToExistingUserInventoryItem == action)
1839 { 1851 {
1840 uint perms=objectGroup.GetEffectivePermissions(); 1852 item.AssetID = asset.FullID;
1841 uint nextPerms=(perms & 7) << 13; 1853 userInfo.UpdateItem(item);
1842 if ((nextPerms & (uint)PermissionMask.Copy) == 0)
1843 perms &= ~(uint)PermissionMask.Copy;
1844 if ((nextPerms & (uint)PermissionMask.Transfer) == 0)
1845 perms &= ~(uint)PermissionMask.Transfer;
1846 if ((nextPerms & (uint)PermissionMask.Modify) == 0)
1847 perms &= ~(uint)PermissionMask.Modify;
1848
1849 item.BasePermissions = perms & objectGroup.RootPart.NextOwnerMask;
1850 item.CurrentPermissions = item.BasePermissions;
1851 item.NextPermissions = objectGroup.RootPart.NextOwnerMask;
1852 item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask & objectGroup.RootPart.NextOwnerMask;
1853 item.GroupPermissions = objectGroup.RootPart.GroupMask & objectGroup.RootPart.NextOwnerMask;
1854 item.CurrentPermissions |= 8; // Slam!
1855 } 1854 }
1856 else 1855 else
1857 { 1856 {
1858 item.BasePermissions = objectGroup.GetEffectivePermissions(); 1857 item = new InventoryItemBase();
1859 item.CurrentPermissions = objectGroup.GetEffectivePermissions(); 1858 item.Creator = objectGroup.RootPart.CreatorID;
1860 item.NextPermissions = objectGroup.RootPart.NextOwnerMask;
1861 item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask;
1862 item.GroupPermissions = objectGroup.RootPart.GroupMask;
1863 }
1864 1859
1865 // TODO: add the new fields (Flags, Sale info, etc) 1860 if (action == DeRezAction.TakeCopy || action == DeRezAction.Take)
1866 item.CreationDate = Util.UnixTimeSinceEpoch(); 1861 item.Owner = remoteClient.AgentId;
1862 else // Delete / Return
1863 item.Owner = objectGroup.OwnerID;
1867 1864
1868 userInfo.AddItem(item); 1865 item.ID = UUID.Random();
1869 if (remoteClient != null && item.Owner == remoteClient.AgentId) 1866 item.AssetID = asset.FullID;
1870 { 1867 item.Description = asset.Description;
1871 remoteClient.SendInventoryItemCreateUpdate(item); 1868 item.Name = asset.Name;
1872 } 1869 item.AssetType = asset.Type;
1873 else 1870 item.InvType = (int)InventoryType.Object;
1874 { 1871 item.Folder = folderID;
1875 ScenePresence notifyUser = GetScenePresence(item.Owner); 1872
1876 if (notifyUser != null) 1873 if (remoteClient != null && (remoteClient.AgentId != objectGroup.RootPart.OwnerID) && Permissions.PropagatePermissions())
1874 {
1875 uint perms=objectGroup.GetEffectivePermissions();
1876 uint nextPerms=(perms & 7) << 13;
1877 if ((nextPerms & (uint)PermissionMask.Copy) == 0)
1878 perms &= ~(uint)PermissionMask.Copy;
1879 if ((nextPerms & (uint)PermissionMask.Transfer) == 0)
1880 perms &= ~(uint)PermissionMask.Transfer;
1881 if ((nextPerms & (uint)PermissionMask.Modify) == 0)
1882 perms &= ~(uint)PermissionMask.Modify;
1883
1884 item.BasePermissions = perms & objectGroup.RootPart.NextOwnerMask;
1885 item.CurrentPermissions = item.BasePermissions;
1886 item.NextPermissions = objectGroup.RootPart.NextOwnerMask;
1887 item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask & objectGroup.RootPart.NextOwnerMask;
1888 item.GroupPermissions = objectGroup.RootPart.GroupMask & objectGroup.RootPart.NextOwnerMask;
1889 item.CurrentPermissions |= 8; // Slam!
1890 }
1891 else
1892 {
1893 item.BasePermissions = objectGroup.GetEffectivePermissions();
1894 item.CurrentPermissions = objectGroup.GetEffectivePermissions();
1895 item.NextPermissions = objectGroup.RootPart.NextOwnerMask;
1896 item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask;
1897 item.GroupPermissions = objectGroup.RootPart.GroupMask;
1898 }
1899
1900 // TODO: add the new fields (Flags, Sale info, etc)
1901 item.CreationDate = Util.UnixTimeSinceEpoch();
1902
1903 userInfo.AddItem(item);
1904
1905 if (remoteClient != null && item.Owner == remoteClient.AgentId)
1877 { 1906 {
1878 notifyUser.ControllingClient.SendInventoryItemCreateUpdate(item); 1907 remoteClient.SendInventoryItemCreateUpdate(item);
1879 } 1908 }
1909 else
1910 {
1911 ScenePresence notifyUser = GetScenePresence(item.Owner);
1912 if (notifyUser != null)
1913 {
1914 notifyUser.ControllingClient.SendInventoryItemCreateUpdate(item);
1915 }
1916 }
1880 } 1917 }
1881 } 1918 }
1882 1919
@@ -2093,7 +2130,7 @@ namespace OpenSim.Region.Environment.Scenes
2093 CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); 2130 CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
2094 if (userInfo != null) 2131 if (userInfo != null)
2095 { 2132 {
2096 if (userInfo.RootFolder != null) 2133 if (userInfo.HasReceivedInventory)
2097 { 2134 {
2098 InventoryItemBase item = userInfo.RootFolder.FindItem(itemID); 2135 InventoryItemBase item = userInfo.RootFolder.FindItem(itemID);
2099 2136
@@ -2103,8 +2140,21 @@ namespace OpenSim.Region.Environment.Scenes
2103 2140
2104 if (rezAsset != null) 2141 if (rezAsset != null)
2105 { 2142 {
2143 UUID itemId = UUID.Zero;
2144
2145 // If we have permission to copy then link the rezzed object back to the user inventory
2146 // item that it came from. This allows us to enable 'save object to inventory'
2147 if (!Permissions.BypassPermissions())
2148 {
2149 if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == (uint)PermissionMask.Copy)
2150 {
2151 itemId = item.ID;
2152 }
2153 }
2154
2106 string xmlData = Utils.BytesToString(rezAsset.Data); 2155 string xmlData = Utils.BytesToString(rezAsset.Data);
2107 SceneObjectGroup group = new SceneObjectGroup(xmlData, true); 2156 SceneObjectGroup group = new SceneObjectGroup(itemId, xmlData, true);
2157
2108 if (!Permissions.CanRezObject( 2158 if (!Permissions.CanRezObject(
2109 group.Children.Count, remoteClient.AgentId, pos) 2159 group.Children.Count, remoteClient.AgentId, pos)
2110 && !attachment) 2160 && !attachment)