diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.Inventory.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 107 |
1 files changed, 47 insertions, 60 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 91f1b63..542d454 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | |||
@@ -125,13 +125,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
125 | 125 | ||
126 | return false; | 126 | return false; |
127 | } | 127 | } |
128 | } | ||
129 | |||
130 | public bool AddInventoryItem(InventoryItemBase item) | ||
131 | { | ||
132 | return AddInventoryItem(item, true); | ||
128 | } | 133 | } |
129 | 134 | ||
130 | /// <summary> | 135 | /// <summary> |
131 | /// Add the given inventory item to a user's inventory. | 136 | /// Add the given inventory item to a user's inventory. |
132 | /// </summary> | 137 | /// </summary> |
133 | /// <param name="item"></param> | 138 | /// <param name="item"></param> |
134 | public bool AddInventoryItem(InventoryItemBase item) | 139 | public bool AddInventoryItem(InventoryItemBase item, bool trigger) |
135 | { | 140 | { |
136 | if (item.Folder != UUID.Zero && InventoryService.AddItem(item)) | 141 | if (item.Folder != UUID.Zero && InventoryService.AddItem(item)) |
137 | { | 142 | { |
@@ -140,7 +145,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
140 | { | 145 | { |
141 | userlevel = 1; | 146 | userlevel = 1; |
142 | } | 147 | } |
143 | EventManager.TriggerOnNewInventoryItemUploadComplete(item.Owner, (AssetType)item.AssetType, item.AssetID, item.Name, userlevel); | 148 | if (trigger) |
149 | EventManager.TriggerOnNewInventoryItemUploadComplete(item.Owner, (AssetType)item.AssetType, item.AssetID, item.Name, userlevel); | ||
144 | 150 | ||
145 | return true; | 151 | return true; |
146 | } | 152 | } |
@@ -179,7 +185,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
179 | { | 185 | { |
180 | userlevel = 1; | 186 | userlevel = 1; |
181 | } | 187 | } |
182 | EventManager.TriggerOnNewInventoryItemUploadComplete(item.Owner, (AssetType)item.AssetType, item.AssetID, item.Name, userlevel); | 188 | if (trigger) |
189 | EventManager.TriggerOnNewInventoryItemUploadComplete(item.Owner, (AssetType)item.AssetType, item.AssetID, item.Name, userlevel); | ||
183 | 190 | ||
184 | if (originalFolder != UUID.Zero) | 191 | if (originalFolder != UUID.Zero) |
185 | { | 192 | { |
@@ -764,7 +771,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
764 | IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>(); | 771 | IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>(); |
765 | if (invAccess != null) | 772 | if (invAccess != null) |
766 | invAccess.TransferInventoryAssets(itemCopy, senderId, recipient); | 773 | invAccess.TransferInventoryAssets(itemCopy, senderId, recipient); |
767 | AddInventoryItem(itemCopy); | 774 | AddInventoryItem(itemCopy, false); |
768 | 775 | ||
769 | if (!Permissions.BypassPermissions()) | 776 | if (!Permissions.BypassPermissions()) |
770 | { | 777 | { |
@@ -872,51 +879,34 @@ namespace OpenSim.Region.Framework.Scenes | |||
872 | return; | 879 | return; |
873 | } | 880 | } |
874 | 881 | ||
875 | AssetBase asset = AssetService.Get(item.AssetID.ToString()); | 882 | if (newName == String.Empty) |
883 | newName = item.Name; | ||
876 | 884 | ||
877 | if (asset != null) | 885 | if (remoteClient.AgentId == oldAgentID |
886 | || (LibraryService != null | ||
887 | && LibraryService.LibraryRootFolder != null | ||
888 | && oldAgentID == LibraryService.LibraryRootFolder.Owner)) | ||
878 | { | 889 | { |
879 | if (newName != String.Empty) | 890 | CreateNewInventoryItem( |
880 | { | 891 | remoteClient, item.CreatorId, item.CreatorData, newFolderID, |
881 | asset.Name = newName; | 892 | newName, item.Description, item.Flags, callbackID, item.AssetID, (sbyte)item.AssetType, (sbyte)item.InvType, |
882 | } | 893 | item.BasePermissions, item.CurrentPermissions, item.EveryOnePermissions, |
883 | else | 894 | item.NextPermissions, item.GroupPermissions, Util.UnixTimeSinceEpoch(), false); |
884 | { | 895 | } |
885 | newName = item.Name; | 896 | else |
886 | } | 897 | { |
887 | 898 | // If item is transfer or permissions are off or calling agent is allowed to copy item owner's inventory item. | |
888 | if (remoteClient.AgentId == oldAgentID | 899 | if (((item.CurrentPermissions & (uint)PermissionMask.Transfer) != 0) |
889 | || (LibraryService != null | 900 | && (m_permissions.BypassPermissions() |
890 | && LibraryService.LibraryRootFolder != null | 901 | || m_permissions.CanCopyUserInventory(remoteClient.AgentId, oldItemID))) |
891 | && oldAgentID == LibraryService.LibraryRootFolder.Owner)) | ||
892 | { | 902 | { |
893 | CreateNewInventoryItem( | 903 | CreateNewInventoryItem( |
894 | remoteClient, item.CreatorId, item.CreatorData, newFolderID, | 904 | remoteClient, item.CreatorId, item.CreatorData, newFolderID, newName, item.Description, item.Flags, callbackID, |
895 | newName, item.Description, item.Flags, callbackID, asset, (sbyte)item.InvType, | 905 | item.AssetID, (sbyte)item.AssetType, (sbyte) item.InvType, |
896 | item.BasePermissions, item.CurrentPermissions, item.EveryOnePermissions, | 906 | item.NextPermissions, item.NextPermissions, item.EveryOnePermissions & item.NextPermissions, |
897 | item.NextPermissions, item.GroupPermissions, Util.UnixTimeSinceEpoch()); | 907 | item.NextPermissions, item.GroupPermissions, Util.UnixTimeSinceEpoch(), false); |
898 | } | ||
899 | else | ||
900 | { | ||
901 | // If item is transfer or permissions are off or calling agent is allowed to copy item owner's inventory item. | ||
902 | if (((item.CurrentPermissions & (uint)PermissionMask.Transfer) != 0) | ||
903 | && (m_permissions.BypassPermissions() | ||
904 | || m_permissions.CanCopyUserInventory(remoteClient.AgentId, oldItemID))) | ||
905 | { | ||
906 | CreateNewInventoryItem( | ||
907 | remoteClient, item.CreatorId, item.CreatorData, newFolderID, newName, item.Description, item.Flags, callbackID, | ||
908 | asset, (sbyte) item.InvType, | ||
909 | item.NextPermissions, item.NextPermissions, item.EveryOnePermissions & item.NextPermissions, | ||
910 | item.NextPermissions, item.GroupPermissions, Util.UnixTimeSinceEpoch()); | ||
911 | } | ||
912 | } | 908 | } |
913 | } | 909 | } |
914 | else | ||
915 | { | ||
916 | m_log.ErrorFormat( | ||
917 | "[AGENT INVENTORY]: Could not copy item {0} since asset {1} could not be found", | ||
918 | item.Name, item.AssetID); | ||
919 | } | ||
920 | } | 910 | } |
921 | 911 | ||
922 | /// <summary> | 912 | /// <summary> |
@@ -966,11 +956,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
966 | public void CreateNewInventoryItem( | 956 | public void CreateNewInventoryItem( |
967 | IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, | 957 | IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, |
968 | string name, string description, uint flags, uint callbackID, | 958 | string name, string description, uint flags, uint callbackID, |
969 | AssetBase asset, sbyte invType, uint nextOwnerMask, int creationDate) | 959 | UUID assetID, sbyte assetType, sbyte invType, uint nextOwnerMask, int creationDate) |
970 | { | 960 | { |
971 | CreateNewInventoryItem( | 961 | CreateNewInventoryItem( |
972 | remoteClient, creatorID, creatorData, folderID, name, description, flags, callbackID, asset, invType, | 962 | remoteClient, creatorID, creatorData, folderID, name, description, flags, callbackID, assetID, assetType, invType, |
973 | (uint)PermissionMask.All | (uint)PermissionMask.Export, (uint)PermissionMask.All | (uint)PermissionMask.Export, 0, nextOwnerMask, 0, creationDate); | 963 | (uint)PermissionMask.All | (uint)PermissionMask.Export, (uint)PermissionMask.All | (uint)PermissionMask.Export, 0, nextOwnerMask, 0, |
964 | creationDate, true); | ||
974 | } | 965 | } |
975 | 966 | ||
976 | /// <summary> | 967 | /// <summary> |
@@ -994,19 +985,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
994 | /// <param name="creationDate">Unix timestamp at which this item was created.</param> | 985 | /// <param name="creationDate">Unix timestamp at which this item was created.</param> |
995 | private void CreateNewInventoryItem( | 986 | private void CreateNewInventoryItem( |
996 | IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, | 987 | IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, |
997 | string name, string description, uint flags, uint callbackID, AssetBase asset, sbyte invType, | 988 | string name, string description, uint flags, uint callbackID, UUID assetID, sbyte assetType, sbyte invType, |
998 | uint baseMask, uint currentMask, uint everyoneMask, uint nextOwnerMask, uint groupMask, int creationDate) | 989 | uint baseMask, uint currentMask, uint everyoneMask, uint nextOwnerMask, uint groupMask, int creationDate, |
990 | bool assetUpload) | ||
999 | { | 991 | { |
1000 | InventoryItemBase item = new InventoryItemBase(); | 992 | InventoryItemBase item = new InventoryItemBase(); |
1001 | item.Owner = remoteClient.AgentId; | 993 | item.Owner = remoteClient.AgentId; |
1002 | item.CreatorId = creatorID; | 994 | item.CreatorId = creatorID; |
1003 | item.CreatorData = creatorData; | 995 | item.CreatorData = creatorData; |
1004 | item.ID = UUID.Random(); | 996 | item.ID = UUID.Random(); |
1005 | item.AssetID = asset.FullID; | 997 | item.AssetID = assetID; |
1006 | item.Name = name; | 998 | item.Name = name; |
1007 | item.Description = description; | 999 | item.Description = description; |
1008 | item.Flags = flags; | 1000 | item.Flags = flags; |
1009 | item.AssetType = asset.Type; | 1001 | item.AssetType = assetType; |
1010 | item.InvType = invType; | 1002 | item.InvType = invType; |
1011 | item.Folder = folderID; | 1003 | item.Folder = folderID; |
1012 | item.CurrentPermissions = currentMask; | 1004 | item.CurrentPermissions = currentMask; |
@@ -1016,7 +1008,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1016 | item.BasePermissions = baseMask; | 1008 | item.BasePermissions = baseMask; |
1017 | item.CreationDate = creationDate; | 1009 | item.CreationDate = creationDate; |
1018 | 1010 | ||
1019 | if (AddInventoryItem(item)) | 1011 | if (AddInventoryItem(item, assetUpload)) |
1020 | { | 1012 | { |
1021 | remoteClient.SendInventoryItemCreateUpdate(item, callbackID); | 1013 | remoteClient.SendInventoryItemCreateUpdate(item, callbackID); |
1022 | } | 1014 | } |
@@ -1079,17 +1071,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1079 | // return; | 1071 | // return; |
1080 | // } | 1072 | // } |
1081 | 1073 | ||
1082 | AssetBase asset = new AssetBase(); | ||
1083 | asset.FullID = olditemID; | ||
1084 | asset.Type = type; | ||
1085 | asset.Name = name; | ||
1086 | asset.Description = description; | ||
1087 | |||
1088 | CreateNewInventoryItem( | 1074 | CreateNewInventoryItem( |
1089 | remoteClient, remoteClient.AgentId.ToString(), string.Empty, folderID, | 1075 | remoteClient, remoteClient.AgentId.ToString(), string.Empty, folderID, |
1090 | name, description, 0, callbackID, asset, invType, | 1076 | name, description, 0, callbackID, olditemID, type, invType, |
1091 | (uint)PermissionMask.All | (uint)PermissionMask.Export, (uint)PermissionMask.All | (uint)PermissionMask.Export, (uint)PermissionMask.All, | 1077 | (uint)PermissionMask.All | (uint)PermissionMask.Export, (uint)PermissionMask.All | (uint)PermissionMask.Export, (uint)PermissionMask.All, |
1092 | (uint)PermissionMask.All | (uint)PermissionMask.Export, (uint)PermissionMask.All | (uint)PermissionMask.Export, Util.UnixTimeSinceEpoch()); | 1078 | (uint)PermissionMask.All | (uint)PermissionMask.Export, (uint)PermissionMask.All | (uint)PermissionMask.Export, Util.UnixTimeSinceEpoch(), |
1079 | false); | ||
1093 | } | 1080 | } |
1094 | else | 1081 | else |
1095 | { | 1082 | { |