diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs | 216 |
1 files changed, 146 insertions, 70 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index e6d6cbf..f5b509f 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs | |||
@@ -183,44 +183,49 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
183 | if (!m_Scene.Permissions.CanCreateUserInventory(invType, remoteClient.AgentId)) | 183 | if (!m_Scene.Permissions.CanCreateUserInventory(invType, remoteClient.AgentId)) |
184 | return; | 184 | return; |
185 | 185 | ||
186 | if (transactionID == UUID.Zero) | 186 | InventoryFolderBase f = new InventoryFolderBase(folderID, remoteClient.AgentId); |
187 | InventoryFolderBase folder = m_Scene.InventoryService.GetFolder(f); | ||
188 | |||
189 | if (folder == null || folder.Owner != remoteClient.AgentId) | ||
190 | return; | ||
191 | |||
192 | if (transactionID != UUID.Zero) | ||
187 | { | 193 | { |
188 | ScenePresence presence; | 194 | IAgentAssetTransactions agentTransactions = m_Scene.AgentTransactionsModule; |
189 | if (m_Scene.TryGetScenePresence(remoteClient.AgentId, out presence)) | 195 | if (agentTransactions != null) |
190 | { | 196 | { |
191 | byte[] data = null; | 197 | if (agentTransactions.HandleItemCreationFromTransaction( |
198 | remoteClient, transactionID, folderID, callbackID, description, | ||
199 | name, invType, assetType, wearableType, nextOwnerMask)) | ||
200 | return; | ||
201 | } | ||
202 | } | ||
192 | 203 | ||
193 | if (invType == (sbyte)InventoryType.Landmark && presence != null) | 204 | ScenePresence presence; |
194 | { | 205 | if (m_Scene.TryGetScenePresence(remoteClient.AgentId, out presence)) |
195 | string suffix = string.Empty, prefix = string.Empty; | 206 | { |
196 | string strdata = GenerateLandmark(presence, out prefix, out suffix); | 207 | byte[] data = null; |
197 | data = Encoding.ASCII.GetBytes(strdata); | ||
198 | name = prefix + name; | ||
199 | description += suffix; | ||
200 | } | ||
201 | 208 | ||
202 | AssetBase asset = m_Scene.CreateAsset(name, description, assetType, data, remoteClient.AgentId); | 209 | if (invType == (sbyte)InventoryType.Landmark && presence != null) |
203 | m_Scene.AssetService.Store(asset); | ||
204 | m_Scene.CreateNewInventoryItem( | ||
205 | remoteClient, remoteClient.AgentId.ToString(), string.Empty, folderID, | ||
206 | name, description, 0, callbackID, asset, invType, nextOwnerMask, creationDate); | ||
207 | } | ||
208 | else | ||
209 | { | 210 | { |
210 | m_log.ErrorFormat( | 211 | string suffix = string.Empty, prefix = string.Empty; |
211 | "[INVENTORY ACCESS MODULE]: ScenePresence for agent uuid {0} unexpectedly not found in CreateNewInventoryItem", | 212 | string strdata = GenerateLandmark(presence, out prefix, out suffix); |
212 | remoteClient.AgentId); | 213 | data = Encoding.ASCII.GetBytes(strdata); |
214 | name = prefix + name; | ||
215 | description += suffix; | ||
213 | } | 216 | } |
217 | |||
218 | AssetBase asset = m_Scene.CreateAsset(name, description, assetType, data, remoteClient.AgentId); | ||
219 | m_Scene.AssetService.Store(asset); | ||
220 | m_Scene.CreateNewInventoryItem( | ||
221 | remoteClient, remoteClient.AgentId.ToString(), string.Empty, folderID, | ||
222 | name, description, 0, callbackID, asset, invType, nextOwnerMask, creationDate,transactionID); | ||
214 | } | 223 | } |
215 | else | 224 | else |
216 | { | 225 | { |
217 | IAgentAssetTransactions agentTransactions = m_Scene.AgentTransactionsModule; | 226 | m_log.ErrorFormat( |
218 | if (agentTransactions != null) | 227 | "[INVENTORY ACCESS MODULE]: ScenePresence for agent uuid {0} unexpectedly not found in CreateNewInventoryItem", |
219 | { | 228 | remoteClient.AgentId); |
220 | agentTransactions.HandleItemCreationFromTransaction( | ||
221 | remoteClient, transactionID, folderID, callbackID, description, | ||
222 | name, invType, assetType, wearableType, nextOwnerMask); | ||
223 | } | ||
224 | } | 229 | } |
225 | } | 230 | } |
226 | 231 | ||
@@ -357,19 +362,35 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
357 | 362 | ||
358 | foreach (SceneObjectGroup objectGroup in objlist) | 363 | foreach (SceneObjectGroup objectGroup in objlist) |
359 | { | 364 | { |
360 | // Vector3 inventoryStoredPosition = new Vector3 | 365 | if (objectGroup.RootPart.KeyframeMotion != null) |
361 | // (((objectGroup.AbsolutePosition.X > (int)Constants.RegionSize) | 366 | objectGroup.RootPart.KeyframeMotion.Stop(); |
362 | // ? 250 | 367 | objectGroup.RootPart.SetForce(Vector3.Zero); |
363 | // : objectGroup.AbsolutePosition.X) | 368 | objectGroup.RootPart.SetAngularImpulse(Vector3.Zero, false); |
364 | // , | 369 | objectGroup.RootPart.KeyframeMotion = null; |
365 | // (objectGroup.AbsolutePosition.Y > (int)Constants.RegionSize) | 370 | |
366 | // ? 250 | 371 | Vector3 inventoryStoredPosition = new Vector3 |
367 | // : objectGroup.AbsolutePosition.Y, | 372 | (((objectGroup.AbsolutePosition.X > (int)Constants.RegionSize) |
368 | // objectGroup.AbsolutePosition.Z); | 373 | ? 250 |
369 | // | 374 | : objectGroup.AbsolutePosition.X) |
370 | // originalPositions[objectGroup.UUID] = objectGroup.AbsolutePosition; | 375 | , |
371 | // | 376 | (objectGroup.AbsolutePosition.Y > (int)Constants.RegionSize) |
372 | // objectGroup.AbsolutePosition = inventoryStoredPosition; | 377 | ? 250 |
378 | : objectGroup.AbsolutePosition.Y, | ||
379 | objectGroup.AbsolutePosition.Z); | ||
380 | |||
381 | Quaternion inventoryStoredRotation = objectGroup.GroupRotation; | ||
382 | //originalPositions[objectGroup.UUID] = objectGroup.AbsolutePosition; | ||
383 | |||
384 | // Restore attachment data after trip through the sim | ||
385 | if (objectGroup.RootPart.AttachPoint > 0) | ||
386 | { | ||
387 | inventoryStoredPosition = objectGroup.RootPart.AttachOffset; | ||
388 | inventoryStoredRotation = objectGroup.RootPart.AttachRotation; | ||
389 | } | ||
390 | objectGroup.RootPart.Shape.State = objectGroup.RootPart.AttachPoint; | ||
391 | |||
392 | objectGroup.AbsolutePosition = inventoryStoredPosition; | ||
393 | objectGroup.RootPart.RotationOffset = inventoryStoredRotation; | ||
373 | 394 | ||
374 | // Make sure all bits but the ones we want are clear | 395 | // Make sure all bits but the ones we want are clear |
375 | // on take. | 396 | // on take. |
@@ -488,8 +509,17 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
488 | IClientAPI remoteClient) | 509 | IClientAPI remoteClient) |
489 | { | 510 | { |
490 | uint effectivePerms = (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify | PermissionMask.Move | PermissionMask.Export) | 7; | 511 | uint effectivePerms = (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify | PermissionMask.Move | PermissionMask.Export) | 7; |
512 | // For the porposes of inventory, an object is modify if the prims | ||
513 | // are modify. This allows renaming an object that contains no | ||
514 | // mod items. | ||
491 | foreach (SceneObjectGroup grp in objsForEffectivePermissions) | 515 | foreach (SceneObjectGroup grp in objsForEffectivePermissions) |
492 | effectivePerms &= grp.GetEffectivePermissions(); | 516 | { |
517 | uint groupPerms = grp.GetEffectivePermissions(true); | ||
518 | if ((grp.RootPart.BaseMask & (uint)PermissionMask.Modify) != 0) | ||
519 | groupPerms |= (uint)PermissionMask.Modify; | ||
520 | |||
521 | effectivePerms &= groupPerms; | ||
522 | } | ||
493 | effectivePerms |= (uint)PermissionMask.Move; | 523 | effectivePerms |= (uint)PermissionMask.Move; |
494 | 524 | ||
495 | if (remoteClient != null && (remoteClient.AgentId != so.RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions()) | 525 | if (remoteClient != null && (remoteClient.AgentId != so.RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions()) |
@@ -670,7 +700,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
670 | if (so.FromFolderID != UUID.Zero && so.RootPart.OwnerID == remoteClient.AgentId) | 700 | if (so.FromFolderID != UUID.Zero && so.RootPart.OwnerID == remoteClient.AgentId) |
671 | { | 701 | { |
672 | InventoryFolderBase f = new InventoryFolderBase(so.FromFolderID, userID); | 702 | InventoryFolderBase f = new InventoryFolderBase(so.FromFolderID, userID); |
673 | folder = m_Scene.InventoryService.GetFolder(f); | 703 | if (f != null) |
704 | folder = m_Scene.InventoryService.GetFolder(f); | ||
674 | 705 | ||
675 | if(folder.Type == 14 || folder.Type == 16) | 706 | if(folder.Type == 14 || folder.Type == 16) |
676 | { | 707 | { |
@@ -706,16 +737,11 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
706 | bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment) | 737 | bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment) |
707 | { | 738 | { |
708 | // m_log.DebugFormat("[INVENTORY ACCESS MODULE]: RezObject for {0}, item {1}", remoteClient.Name, itemID); | 739 | // m_log.DebugFormat("[INVENTORY ACCESS MODULE]: RezObject for {0}, item {1}", remoteClient.Name, itemID); |
709 | |||
710 | InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); | 740 | InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); |
711 | item = m_Scene.InventoryService.GetItem(item); | 741 | item = m_Scene.InventoryService.GetItem(item); |
712 | 742 | ||
713 | if (item == null) | 743 | if (item == null) |
714 | { | 744 | { |
715 | m_log.WarnFormat( | ||
716 | "[INVENTORY ACCESS MODULE]: Could not find item {0} for {1} in RezObject()", | ||
717 | itemID, remoteClient.Name); | ||
718 | |||
719 | return null; | 745 | return null; |
720 | } | 746 | } |
721 | 747 | ||
@@ -766,6 +792,13 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
766 | if (e == null || attachment) // Single | 792 | if (e == null || attachment) // Single |
767 | { | 793 | { |
768 | SceneObjectGroup g = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); | 794 | SceneObjectGroup g = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); |
795 | if (!attachment) | ||
796 | { | ||
797 | g.RootPart.AttachPoint = g.RootPart.Shape.State; | ||
798 | g.RootPart.AttachOffset = g.AbsolutePosition; | ||
799 | g.RootPart.AttachRotation = g.GroupRotation; | ||
800 | g.RootPart.Shape.State = 0; | ||
801 | } | ||
769 | 802 | ||
770 | objlist.Add(g); | 803 | objlist.Add(g); |
771 | veclist.Add(new Vector3(0, 0, 0)); | 804 | veclist.Add(new Vector3(0, 0, 0)); |
@@ -795,6 +828,10 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
795 | foreach (XmlNode n in groups) | 828 | foreach (XmlNode n in groups) |
796 | { | 829 | { |
797 | SceneObjectGroup g = SceneObjectSerializer.FromOriginalXmlFormat(n.OuterXml); | 830 | SceneObjectGroup g = SceneObjectSerializer.FromOriginalXmlFormat(n.OuterXml); |
831 | g.RootPart.AttachPoint = g.RootPart.Shape.State; | ||
832 | g.RootPart.AttachOffset = g.AbsolutePosition; | ||
833 | g.RootPart.AttachRotation = g.GroupRotation; | ||
834 | g.RootPart.Shape.State = 0; | ||
798 | 835 | ||
799 | objlist.Add(g); | 836 | objlist.Add(g); |
800 | XmlElement el = (XmlElement)n; | 837 | XmlElement el = (XmlElement)n; |
@@ -814,12 +851,35 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
814 | } | 851 | } |
815 | } | 852 | } |
816 | 853 | ||
854 | int primcount = 0; | ||
855 | foreach (SceneObjectGroup g in objlist) | ||
856 | primcount += g.PrimCount; | ||
857 | |||
858 | if (!m_Scene.Permissions.CanRezObject( | ||
859 | primcount, remoteClient.AgentId, pos) | ||
860 | && !attachment) | ||
861 | { | ||
862 | // The client operates in no fail mode. It will | ||
863 | // have already removed the item from the folder | ||
864 | // if it's no copy. | ||
865 | // Put it back if it's not an attachment | ||
866 | // | ||
867 | if (item != null) | ||
868 | { | ||
869 | if (((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) && (!attachment)) | ||
870 | remoteClient.SendBulkUpdateInventory(item); | ||
871 | } | ||
872 | |||
873 | return null; | ||
874 | } | ||
875 | |||
817 | if (item != null && !DoPreRezWhenFromItem(remoteClient, item, objlist, pos, veclist, attachment)) | 876 | if (item != null && !DoPreRezWhenFromItem(remoteClient, item, objlist, pos, veclist, attachment)) |
818 | return null; | 877 | return null; |
819 | 878 | ||
820 | for (int i = 0; i < objlist.Count; i++) | 879 | for (int i = 0; i < objlist.Count; i++) |
821 | { | 880 | { |
822 | group = objlist[i]; | 881 | group = objlist[i]; |
882 | SceneObjectPart rootPart = group.RootPart; | ||
823 | 883 | ||
824 | // m_log.DebugFormat( | 884 | // m_log.DebugFormat( |
825 | // "[INVENTORY ACCESS MODULE]: Preparing to rez {0} {1} {2} ownermask={3:X} nextownermask={4:X} groupmask={5:X} everyonemask={6:X} for {7}", | 885 | // "[INVENTORY ACCESS MODULE]: Preparing to rez {0} {1} {2} ownermask={3:X} nextownermask={4:X} groupmask={5:X} everyonemask={6:X} for {7}", |
@@ -880,8 +940,6 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
880 | 940 | ||
881 | if (!attachment) | 941 | if (!attachment) |
882 | { | 942 | { |
883 | SceneObjectPart rootPart = group.RootPart; | ||
884 | |||
885 | if (rootPart.Shape.PCode == (byte)PCode.Prim) | 943 | if (rootPart.Shape.PCode == (byte)PCode.Prim) |
886 | group.ClearPartAttachmentData(); | 944 | group.ClearPartAttachmentData(); |
887 | 945 | ||
@@ -899,6 +957,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
899 | // remoteClient.Name); | 957 | // remoteClient.Name); |
900 | } | 958 | } |
901 | 959 | ||
960 | group.SetGroup(remoteClient.ActiveGroupId, remoteClient); | ||
961 | |||
902 | if (item != null) | 962 | if (item != null) |
903 | DoPostRezWhenFromItem(item, attachment); | 963 | DoPostRezWhenFromItem(item, attachment); |
904 | 964 | ||
@@ -983,8 +1043,11 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
983 | { | 1043 | { |
984 | rootPart.Name = item.Name; | 1044 | rootPart.Name = item.Name; |
985 | rootPart.Description = item.Description; | 1045 | rootPart.Description = item.Description; |
986 | rootPart.ObjectSaleType = item.SaleType; | 1046 | if ((item.Flags & (uint)InventoryItemFlags.ObjectSlamSale) != 0) |
987 | rootPart.SalePrice = item.SalePrice; | 1047 | { |
1048 | rootPart.ObjectSaleType = item.SaleType; | ||
1049 | rootPart.SalePrice = item.SalePrice; | ||
1050 | } | ||
988 | } | 1051 | } |
989 | 1052 | ||
990 | so.FromFolderID = item.Folder; | 1053 | so.FromFolderID = item.Folder; |
@@ -994,7 +1057,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
994 | // rootPart.OwnerID, item.Owner, item.CurrentPermissions); | 1057 | // rootPart.OwnerID, item.Owner, item.CurrentPermissions); |
995 | 1058 | ||
996 | if ((rootPart.OwnerID != item.Owner) || | 1059 | if ((rootPart.OwnerID != item.Owner) || |
997 | (item.CurrentPermissions & 16) != 0) | 1060 | (item.CurrentPermissions & 16) != 0 || |
1061 | (item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0) | ||
998 | { | 1062 | { |
999 | //Need to kill the for sale here | 1063 | //Need to kill the for sale here |
1000 | rootPart.ObjectSaleType = 0; | 1064 | rootPart.ObjectSaleType = 0; |
@@ -1004,31 +1068,43 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
1004 | { | 1068 | { |
1005 | foreach (SceneObjectPart part in so.Parts) | 1069 | foreach (SceneObjectPart part in so.Parts) |
1006 | { | 1070 | { |
1007 | if ((item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0) | ||
1008 | { | ||
1009 | part.EveryoneMask = item.EveryOnePermissions; | ||
1010 | part.NextOwnerMask = item.NextPermissions; | ||
1011 | } | ||
1012 | part.GroupMask = 0; // DO NOT propagate here | 1071 | part.GroupMask = 0; // DO NOT propagate here |
1072 | |||
1073 | part.LastOwnerID = part.OwnerID; | ||
1074 | part.OwnerID = item.Owner; | ||
1075 | part.Inventory.ChangeInventoryOwner(item.Owner); | ||
1013 | } | 1076 | } |
1014 | 1077 | ||
1015 | so.ApplyNextOwnerPermissions(); | 1078 | so.ApplyNextOwnerPermissions(); |
1079 | |||
1080 | // In case the user has changed flags on a received item | ||
1081 | // we have to apply those changes after the slam. Else we | ||
1082 | // get a net loss of permissions | ||
1083 | foreach (SceneObjectPart part in so.Parts) | ||
1084 | { | ||
1085 | if ((item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0) | ||
1086 | { | ||
1087 | if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteEveryone) != 0) | ||
1088 | part.EveryoneMask = item.EveryOnePermissions & part.BaseMask; | ||
1089 | if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteNextOwner) != 0) | ||
1090 | part.NextOwnerMask = item.NextPermissions & part.BaseMask; | ||
1091 | } | ||
1092 | } | ||
1016 | } | 1093 | } |
1017 | } | 1094 | } |
1018 | 1095 | else | |
1019 | foreach (SceneObjectPart part in so.Parts) | ||
1020 | { | 1096 | { |
1021 | part.FromUserInventoryItemID = fromUserInventoryItemId; | 1097 | foreach (SceneObjectPart part in so.Parts) |
1022 | |||
1023 | if ((part.OwnerID != item.Owner) || | ||
1024 | (item.CurrentPermissions & 16) != 0) | ||
1025 | { | 1098 | { |
1026 | part.Inventory.ChangeInventoryOwner(item.Owner); | 1099 | part.FromUserInventoryItemID = fromUserInventoryItemId; |
1027 | part.GroupMask = 0; // DO NOT propagate here | 1100 | |
1101 | if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteEveryone) != 0) | ||
1102 | part.EveryoneMask = item.EveryOnePermissions; | ||
1103 | if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteNextOwner) != 0) | ||
1104 | part.NextOwnerMask = item.NextPermissions; | ||
1105 | if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteGroup) != 0) | ||
1106 | part.GroupMask = item.GroupPermissions; | ||
1028 | } | 1107 | } |
1029 | |||
1030 | part.EveryoneMask = item.EveryOnePermissions; | ||
1031 | part.NextOwnerMask = item.NextPermissions; | ||
1032 | } | 1108 | } |
1033 | 1109 | ||
1034 | rootPart.TrimPermissions(); | 1110 | rootPart.TrimPermissions(); |