diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs | 557 |
1 files changed, 342 insertions, 215 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index 5a9efb8..788ed1c 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs | |||
@@ -68,7 +68,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
68 | return m_UserManagement; | 68 | return m_UserManagement; |
69 | } | 69 | } |
70 | } | 70 | } |
71 | 71 | ||
72 | public bool CoalesceMultipleObjectsToInventory { get; set; } | 72 | public bool CoalesceMultipleObjectsToInventory { get; set; } |
73 | 73 | ||
74 | #region INonSharedRegionModule | 74 | #region INonSharedRegionModule |
@@ -92,14 +92,14 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
92 | if (name == Name) | 92 | if (name == Name) |
93 | { | 93 | { |
94 | m_Enabled = true; | 94 | m_Enabled = true; |
95 | 95 | ||
96 | InitialiseCommon(source); | 96 | InitialiseCommon(source); |
97 | 97 | ||
98 | m_log.InfoFormat("[INVENTORY ACCESS MODULE]: {0} enabled.", Name); | 98 | m_log.InfoFormat("[INVENTORY ACCESS MODULE]: {0} enabled.", Name); |
99 | } | 99 | } |
100 | } | 100 | } |
101 | } | 101 | } |
102 | 102 | ||
103 | /// <summary> | 103 | /// <summary> |
104 | /// Common module config for both this and descendant classes. | 104 | /// Common module config for both this and descendant classes. |
105 | /// </summary> | 105 | /// </summary> |
@@ -107,9 +107,9 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
107 | protected virtual void InitialiseCommon(IConfigSource source) | 107 | protected virtual void InitialiseCommon(IConfigSource source) |
108 | { | 108 | { |
109 | IConfig inventoryConfig = source.Configs["Inventory"]; | 109 | IConfig inventoryConfig = source.Configs["Inventory"]; |
110 | 110 | ||
111 | if (inventoryConfig != null) | 111 | if (inventoryConfig != null) |
112 | CoalesceMultipleObjectsToInventory | 112 | CoalesceMultipleObjectsToInventory |
113 | = inventoryConfig.GetBoolean("CoalesceMultipleObjectsToInventory", true); | 113 | = inventoryConfig.GetBoolean("CoalesceMultipleObjectsToInventory", true); |
114 | else | 114 | else |
115 | CoalesceMultipleObjectsToInventory = true; | 115 | CoalesceMultipleObjectsToInventory = true; |
@@ -175,53 +175,73 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
175 | /// <param name="nextOwnerMask"></param> | 175 | /// <param name="nextOwnerMask"></param> |
176 | public void CreateNewInventoryItem(IClientAPI remoteClient, UUID transactionID, UUID folderID, | 176 | public void CreateNewInventoryItem(IClientAPI remoteClient, UUID transactionID, UUID folderID, |
177 | uint callbackID, string description, string name, sbyte invType, | 177 | uint callbackID, string description, string name, sbyte invType, |
178 | sbyte assetType, | 178 | sbyte assetType, byte wearableType, |
179 | byte wearableType, uint nextOwnerMask, int creationDate) | 179 | uint nextOwnerMask, int creationDate) |
180 | { | 180 | { |
181 | m_log.DebugFormat("[INVENTORY ACCESS MODULE]: Received request to create inventory item {0} in folder {1}", name, folderID); | 181 | m_log.DebugFormat("[INVENTORY ACCESS MODULE]: Received request to create inventory item {0} in folder {1}, transactionID {2}", name, |
182 | folderID, transactionID); | ||
182 | 183 | ||
183 | if (!m_Scene.Permissions.CanCreateUserInventory(invType, remoteClient.AgentId)) | 184 | if (!m_Scene.Permissions.CanCreateUserInventory(invType, remoteClient.AgentId)) |
184 | return; | 185 | return; |
185 | 186 | ||
186 | if (transactionID == UUID.Zero) | 187 | InventoryFolderBase folder = m_Scene.InventoryService.GetFolder(remoteClient.AgentId, folderID); |
188 | |||
189 | if (folder == null && Enum.IsDefined(typeof(FolderType), (sbyte)invType)) | ||
187 | { | 190 | { |
188 | ScenePresence presence; | 191 | folder = m_Scene.InventoryService.GetFolderForType(remoteClient.AgentId, (FolderType)invType); |
189 | if (m_Scene.TryGetScenePresence(remoteClient.AgentId, out presence)) | 192 | if (folder != null) |
190 | { | 193 | m_log.DebugFormat("[INVENTORY ACCESS MODULE]: Requested folder not found but found folder for type {0}", invType); |
191 | byte[] data = null; | 194 | } |
192 | 195 | ||
193 | if (invType == (sbyte)InventoryType.Landmark && presence != null) | 196 | if (folder == null || folder.Owner != remoteClient.AgentId) |
194 | { | 197 | return; |
195 | string suffix = string.Empty, prefix = string.Empty; | ||
196 | string strdata = GenerateLandmark(presence, out prefix, out suffix); | ||
197 | data = Encoding.ASCII.GetBytes(strdata); | ||
198 | name = prefix + name; | ||
199 | description += suffix; | ||
200 | } | ||
201 | 198 | ||
202 | AssetBase asset = m_Scene.CreateAsset(name, description, assetType, data, remoteClient.AgentId); | 199 | if (transactionID != UUID.Zero) |
203 | m_Scene.AssetService.Store(asset); | ||
204 | m_Scene.CreateNewInventoryItem( | ||
205 | remoteClient, remoteClient.AgentId.ToString(), string.Empty, folderID, | ||
206 | name, description, 0, callbackID, asset.FullID, asset.Type, invType, nextOwnerMask, creationDate); | ||
207 | } | ||
208 | else | ||
209 | { | ||
210 | m_log.ErrorFormat( | ||
211 | "[INVENTORY ACCESS MODULE]: ScenePresence for agent uuid {0} unexpectedly not found in CreateNewInventoryItem", | ||
212 | remoteClient.AgentId); | ||
213 | } | ||
214 | } | ||
215 | else | ||
216 | { | 200 | { |
217 | IAgentAssetTransactions agentTransactions = m_Scene.AgentTransactionsModule; | 201 | IAgentAssetTransactions agentTransactions = m_Scene.AgentTransactionsModule; |
218 | if (agentTransactions != null) | 202 | if (agentTransactions != null) |
219 | { | 203 | { |
220 | agentTransactions.HandleItemCreationFromTransaction( | 204 | if (agentTransactions.HandleItemCreationFromTransaction( |
221 | remoteClient, transactionID, folderID, callbackID, description, | 205 | remoteClient, transactionID, folderID, callbackID, description, |
222 | name, invType, assetType, wearableType, nextOwnerMask); | 206 | name, invType, assetType, wearableType, nextOwnerMask)) |
207 | return; | ||
223 | } | 208 | } |
224 | } | 209 | } |
210 | |||
211 | ScenePresence presence; | ||
212 | if (m_Scene.TryGetScenePresence(remoteClient.AgentId, out presence)) | ||
213 | { | ||
214 | byte[] data = null; | ||
215 | uint everyonemask = 0; | ||
216 | uint groupmask = 0; | ||
217 | |||
218 | if (invType == (sbyte)InventoryType.Landmark && presence != null) | ||
219 | { | ||
220 | string suffix = string.Empty, prefix = string.Empty; | ||
221 | string strdata = GenerateLandmark(presence, out prefix, out suffix); | ||
222 | data = Encoding.ASCII.GetBytes(strdata); | ||
223 | name = prefix + name; | ||
224 | description += suffix; | ||
225 | groupmask = (uint)PermissionMask.AllAndExport; | ||
226 | everyonemask = (uint)(PermissionMask.AllAndExport & ~PermissionMask.Modify); | ||
227 | } | ||
228 | |||
229 | AssetBase asset = m_Scene.CreateAsset(name, description, assetType, data, remoteClient.AgentId); | ||
230 | m_Scene.AssetService.Store(asset); | ||
231 | m_Scene.CreateNewInventoryItem( | ||
232 | remoteClient, remoteClient.AgentId.ToString(), string.Empty, folderID, | ||
233 | name, description, 0, callbackID, asset.FullID, asset.Type, invType, | ||
234 | (uint)PermissionMask.AllAndExport, // Base | ||
235 | (uint)PermissionMask.AllAndExport, // Current | ||
236 | everyonemask, | ||
237 | nextOwnerMask, groupmask, creationDate, false); // Data from viewer | ||
238 | } | ||
239 | else | ||
240 | { | ||
241 | m_log.ErrorFormat( | ||
242 | "[INVENTORY ACCESS MODULE]: ScenePresence for agent uuid {0} unexpectedly not found in CreateNewInventoryItem", | ||
243 | remoteClient.AgentId); | ||
244 | } | ||
225 | } | 245 | } |
226 | 246 | ||
227 | protected virtual string GenerateLandmark(ScenePresence presence, out string prefix, out string suffix) | 247 | protected virtual string GenerateLandmark(ScenePresence presence, out string prefix, out string suffix) |
@@ -244,53 +264,65 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
244 | /// <returns></returns> | 264 | /// <returns></returns> |
245 | public virtual UUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, UUID itemID, byte[] data) | 265 | public virtual UUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, UUID itemID, byte[] data) |
246 | { | 266 | { |
247 | InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); | 267 | InventoryItemBase item = m_Scene.InventoryService.GetItem(remoteClient.AgentId, itemID); |
248 | item = m_Scene.InventoryService.GetItem(item); | 268 | |
269 | if (item == null) | ||
270 | { | ||
271 | m_log.ErrorFormat( | ||
272 | "[INVENTORY ACCESS MODULE]: Could not find item {0} for caps inventory update", itemID); | ||
273 | return UUID.Zero; | ||
274 | } | ||
249 | 275 | ||
250 | if (item.Owner != remoteClient.AgentId) | 276 | if (item.Owner != remoteClient.AgentId) |
251 | return UUID.Zero; | 277 | return UUID.Zero; |
252 | 278 | ||
253 | if (item != null) | 279 | if ((InventoryType)item.InvType == InventoryType.Notecard) |
254 | { | 280 | { |
255 | if ((InventoryType)item.InvType == InventoryType.Notecard) | 281 | if (!m_Scene.Permissions.CanEditNotecard(itemID, UUID.Zero, remoteClient.AgentId)) |
256 | { | 282 | { |
257 | if (!m_Scene.Permissions.CanEditNotecard(itemID, UUID.Zero, remoteClient.AgentId)) | 283 | remoteClient.SendAgentAlertMessage("Insufficient permissions to edit notecard", false); |
258 | { | 284 | return UUID.Zero; |
259 | remoteClient.SendAgentAlertMessage("Insufficient permissions to edit notecard", false); | ||
260 | return UUID.Zero; | ||
261 | } | ||
262 | |||
263 | remoteClient.SendAlertMessage("Notecard saved"); | ||
264 | } | 285 | } |
265 | else if ((InventoryType)item.InvType == InventoryType.LSL) | ||
266 | { | ||
267 | if (!m_Scene.Permissions.CanEditScript(itemID, UUID.Zero, remoteClient.AgentId)) | ||
268 | { | ||
269 | remoteClient.SendAgentAlertMessage("Insufficient permissions to edit script", false); | ||
270 | return UUID.Zero; | ||
271 | } | ||
272 | 286 | ||
273 | remoteClient.SendAlertMessage("Script saved"); | 287 | remoteClient.SendAlertMessage("Notecard saved"); |
288 | } | ||
289 | else if ((InventoryType)item.InvType == InventoryType.LSL) | ||
290 | { | ||
291 | if (!m_Scene.Permissions.CanEditScript(itemID, UUID.Zero, remoteClient.AgentId)) | ||
292 | { | ||
293 | remoteClient.SendAgentAlertMessage("Insufficient permissions to edit script", false); | ||
294 | return UUID.Zero; | ||
274 | } | 295 | } |
275 | 296 | ||
276 | AssetBase asset = | 297 | remoteClient.SendAlertMessage("Script saved"); |
277 | CreateAsset(item.Name, item.Description, (sbyte)item.AssetType, data, remoteClient.AgentId.ToString()); | ||
278 | item.AssetID = asset.FullID; | ||
279 | m_Scene.AssetService.Store(asset); | ||
280 | |||
281 | m_Scene.InventoryService.UpdateItem(item); | ||
282 | |||
283 | // remoteClient.SendInventoryItemCreateUpdate(item); | ||
284 | return (asset.FullID); | ||
285 | } | 298 | } |
286 | else | 299 | else if ((CustomInventoryType)item.InvType == CustomInventoryType.AnimationSet) |
287 | { | 300 | { |
288 | m_log.ErrorFormat( | 301 | AnimationSet animSet = new AnimationSet(data); |
289 | "[INVENTORY ACCESS MODULE]: Could not find item {0} for caps inventory update", | 302 | uint res = animSet.Validate(x => { |
290 | itemID); | 303 | const int required = (int)(PermissionMask.Transfer | PermissionMask.Copy); |
304 | int perms = m_Scene.InventoryService.GetAssetPermissions(remoteClient.AgentId, x); | ||
305 | // enforce previus perm rule | ||
306 | if ((perms & required) != required) | ||
307 | return 0; | ||
308 | return (uint) perms; | ||
309 | }); | ||
310 | if(res == 0) | ||
311 | { | ||
312 | remoteClient.SendAgentAlertMessage("Not enought permissions on asset(s) referenced by animation set '{0}', update failed", false); | ||
313 | return UUID.Zero; | ||
314 | } | ||
291 | } | 315 | } |
292 | 316 | ||
293 | return UUID.Zero; | 317 | AssetBase asset = |
318 | CreateAsset(item.Name, item.Description, (sbyte)item.AssetType, data, remoteClient.AgentId.ToString()); | ||
319 | item.AssetID = asset.FullID; | ||
320 | m_Scene.AssetService.Store(asset); | ||
321 | |||
322 | m_Scene.InventoryService.UpdateItem(item); | ||
323 | |||
324 | // remoteClient.SendInventoryItemCreateUpdate(item); | ||
325 | return (asset.FullID); | ||
294 | } | 326 | } |
295 | 327 | ||
296 | public virtual bool UpdateInventoryItemAsset(UUID ownerID, InventoryItemBase item, AssetBase asset) | 328 | public virtual bool UpdateInventoryItemAsset(UUID ownerID, InventoryItemBase item, AssetBase asset) |
@@ -298,7 +330,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
298 | if (item != null && item.Owner == ownerID && asset != null) | 330 | if (item != null && item.Owner == ownerID && asset != null) |
299 | { | 331 | { |
300 | // m_log.DebugFormat( | 332 | // m_log.DebugFormat( |
301 | // "[INVENTORY ACCESS MODULE]: Updating item {0} {1} with new asset {2}", | 333 | // "[INVENTORY ACCESS MODULE]: Updating item {0} {1} with new asset {2}", |
302 | // item.Name, item.ID, asset.ID); | 334 | // item.Name, item.ID, asset.ID); |
303 | 335 | ||
304 | item.AssetID = asset.FullID; | 336 | item.AssetID = asset.FullID; |
@@ -327,7 +359,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
327 | List<InventoryItemBase> copiedItems = new List<InventoryItemBase>(); | 359 | List<InventoryItemBase> copiedItems = new List<InventoryItemBase>(); |
328 | 360 | ||
329 | Dictionary<UUID, List<SceneObjectGroup>> bundlesToCopy = new Dictionary<UUID, List<SceneObjectGroup>>(); | 361 | Dictionary<UUID, List<SceneObjectGroup>> bundlesToCopy = new Dictionary<UUID, List<SceneObjectGroup>>(); |
330 | 362 | ||
331 | if (CoalesceMultipleObjectsToInventory) | 363 | if (CoalesceMultipleObjectsToInventory) |
332 | { | 364 | { |
333 | // The following code groups the SOG's by owner. No objects | 365 | // The following code groups the SOG's by owner. No objects |
@@ -337,7 +369,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
337 | { | 369 | { |
338 | if (!bundlesToCopy.ContainsKey(g.OwnerID)) | 370 | if (!bundlesToCopy.ContainsKey(g.OwnerID)) |
339 | bundlesToCopy[g.OwnerID] = new List<SceneObjectGroup>(); | 371 | bundlesToCopy[g.OwnerID] = new List<SceneObjectGroup>(); |
340 | 372 | ||
341 | bundlesToCopy[g.OwnerID].Add(g); | 373 | bundlesToCopy[g.OwnerID].Add(g); |
342 | } | 374 | } |
343 | } | 375 | } |
@@ -348,7 +380,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
348 | { | 380 | { |
349 | List<SceneObjectGroup> bundle = new List<SceneObjectGroup>(); | 381 | List<SceneObjectGroup> bundle = new List<SceneObjectGroup>(); |
350 | bundle.Add(g); | 382 | bundle.Add(g); |
351 | bundlesToCopy[g.UUID] = bundle; | 383 | bundlesToCopy[g.UUID] = bundle; |
352 | } | 384 | } |
353 | } | 385 | } |
354 | 386 | ||
@@ -360,10 +392,10 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
360 | // with distinct destinations as well. | 392 | // with distinct destinations as well. |
361 | foreach (List<SceneObjectGroup> bundle in bundlesToCopy.Values) | 393 | foreach (List<SceneObjectGroup> bundle in bundlesToCopy.Values) |
362 | copiedItems.Add(CopyBundleToInventory(action, folderID, bundle, remoteClient, asAttachment)); | 394 | copiedItems.Add(CopyBundleToInventory(action, folderID, bundle, remoteClient, asAttachment)); |
363 | 395 | ||
364 | return copiedItems; | 396 | return copiedItems; |
365 | } | 397 | } |
366 | 398 | ||
367 | /// <summary> | 399 | /// <summary> |
368 | /// Copy a bundle of objects to inventory. If there is only one object, then this will create an object | 400 | /// Copy a bundle of objects to inventory. If there is only one object, then this will create an object |
369 | /// item. If there are multiple objects then these will be saved as a single coalesced item. | 401 | /// item. If there are multiple objects then these will be saved as a single coalesced item. |
@@ -379,33 +411,42 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
379 | DeRezAction action, UUID folderID, List<SceneObjectGroup> objlist, IClientAPI remoteClient, | 411 | DeRezAction action, UUID folderID, List<SceneObjectGroup> objlist, IClientAPI remoteClient, |
380 | bool asAttachment) | 412 | bool asAttachment) |
381 | { | 413 | { |
382 | CoalescedSceneObjects coa = new CoalescedSceneObjects(UUID.Zero); | 414 | CoalescedSceneObjects coa = new CoalescedSceneObjects(UUID.Zero); |
383 | // Dictionary<UUID, Vector3> originalPositions = new Dictionary<UUID, Vector3>(); | 415 | Dictionary<UUID, Vector3> originalPositions = new Dictionary<UUID, Vector3>(); |
384 | 416 | Dictionary<UUID, Quaternion> originalRotations = new Dictionary<UUID, Quaternion>(); | |
385 | Dictionary<SceneObjectGroup, KeyframeMotion> group2Keyframe = new Dictionary<SceneObjectGroup, KeyframeMotion>(); | 417 | // this possible is not needed if keyframes are saved |
418 | // Dictionary<UUID, KeyframeMotion> originalKeyframes = new Dictionary<UUID, KeyframeMotion>(); | ||
386 | 419 | ||
387 | foreach (SceneObjectGroup objectGroup in objlist) | 420 | foreach (SceneObjectGroup objectGroup in objlist) |
388 | { | 421 | { |
389 | if (objectGroup.RootPart.KeyframeMotion != null) | 422 | if (objectGroup.RootPart.KeyframeMotion != null) |
390 | { | 423 | { |
391 | objectGroup.RootPart.KeyframeMotion.Pause(); | 424 | objectGroup.RootPart.KeyframeMotion.Suspend(); |
392 | group2Keyframe.Add(objectGroup, objectGroup.RootPart.KeyframeMotion); | ||
393 | objectGroup.RootPart.KeyframeMotion = null; | ||
394 | } | 425 | } |
426 | objectGroup.RootPart.SetForce(Vector3.Zero); | ||
427 | objectGroup.RootPart.SetAngularImpulse(Vector3.Zero, false); | ||
395 | 428 | ||
396 | // Vector3 inventoryStoredPosition = new Vector3 | 429 | // originalKeyframes[objectGroup.UUID] = objectGroup.RootPart.KeyframeMotion; |
397 | // (((objectGroup.AbsolutePosition.X > (int)Constants.RegionSize) | 430 | // objectGroup.RootPart.KeyframeMotion = null; |
398 | // ? 250 | 431 | |
399 | // : objectGroup.AbsolutePosition.X) | 432 | Vector3 inventoryStoredPosition = objectGroup.AbsolutePosition; |
400 | // , | 433 | originalPositions[objectGroup.UUID] = inventoryStoredPosition; |
401 | // (objectGroup.AbsolutePosition.Y > (int)Constants.RegionSize) | 434 | Quaternion inventoryStoredRotation = objectGroup.GroupRotation; |
402 | // ? 250 | 435 | originalRotations[objectGroup.UUID] = inventoryStoredRotation; |
403 | // : objectGroup.AbsolutePosition.Y, | 436 | |
404 | // objectGroup.AbsolutePosition.Z); | 437 | // Restore attachment data after trip through the sim |
405 | // | 438 | if (objectGroup.AttachmentPoint > 0) |
406 | // originalPositions[objectGroup.UUID] = objectGroup.AbsolutePosition; | 439 | { |
407 | // | 440 | inventoryStoredPosition = objectGroup.RootPart.AttachedPos; |
408 | // objectGroup.AbsolutePosition = inventoryStoredPosition; | 441 | inventoryStoredRotation = objectGroup.RootPart.AttachRotation; |
442 | if (objectGroup.RootPart.Shape.PCode != (byte) PCode.Tree && | ||
443 | objectGroup.RootPart.Shape.PCode != (byte) PCode.NewTree) | ||
444 | objectGroup.RootPart.Shape.LastAttachPoint = (byte)objectGroup.AttachmentPoint; | ||
445 | |||
446 | } | ||
447 | |||
448 | objectGroup.AbsolutePosition = inventoryStoredPosition; | ||
449 | objectGroup.RootPart.RotationOffset = inventoryStoredRotation; | ||
409 | 450 | ||
410 | // Make sure all bits but the ones we want are clear | 451 | // Make sure all bits but the ones we want are clear |
411 | // on take. | 452 | // on take. |
@@ -418,7 +459,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
418 | (uint)PermissionMask.Export); | 459 | (uint)PermissionMask.Export); |
419 | objectGroup.RootPart.NextOwnerMask |= | 460 | objectGroup.RootPart.NextOwnerMask |= |
420 | (uint)PermissionMask.Move; | 461 | (uint)PermissionMask.Move; |
421 | 462 | ||
422 | coa.Add(objectGroup); | 463 | coa.Add(objectGroup); |
423 | } | 464 | } |
424 | 465 | ||
@@ -432,10 +473,16 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
432 | itemXml = CoalescedSceneObjectsSerializer.ToXml(coa, !asAttachment); | 473 | itemXml = CoalescedSceneObjectsSerializer.ToXml(coa, !asAttachment); |
433 | else | 474 | else |
434 | itemXml = SceneObjectSerializer.ToOriginalXmlFormat(objlist[0], !asAttachment); | 475 | itemXml = SceneObjectSerializer.ToOriginalXmlFormat(objlist[0], !asAttachment); |
435 | 476 | ||
436 | // // Restore the position of each group now that it has been stored to inventory. | 477 | // Restore the position of each group now that it has been stored to inventory. |
437 | // foreach (SceneObjectGroup objectGroup in objlist) | 478 | foreach (SceneObjectGroup objectGroup in objlist) |
438 | // objectGroup.AbsolutePosition = originalPositions[objectGroup.UUID]; | 479 | { |
480 | objectGroup.AbsolutePosition = originalPositions[objectGroup.UUID]; | ||
481 | objectGroup.RootPart.RotationOffset = originalRotations[objectGroup.UUID]; | ||
482 | // objectGroup.RootPart.KeyframeMotion = originalKeyframes[objectGroup.UUID]; | ||
483 | if (objectGroup.RootPart.KeyframeMotion != null) | ||
484 | objectGroup.RootPart.KeyframeMotion.Resume(); | ||
485 | } | ||
439 | 486 | ||
440 | InventoryItemBase item = CreateItemForObject(action, remoteClient, objlist[0], folderID); | 487 | InventoryItemBase item = CreateItemForObject(action, remoteClient, objlist[0], folderID); |
441 | 488 | ||
@@ -448,11 +495,11 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
448 | 495 | ||
449 | item.CreatorId = objlist[0].RootPart.CreatorID.ToString(); | 496 | item.CreatorId = objlist[0].RootPart.CreatorID.ToString(); |
450 | item.CreatorData = objlist[0].RootPart.CreatorData; | 497 | item.CreatorData = objlist[0].RootPart.CreatorData; |
451 | 498 | ||
452 | if (objlist.Count > 1) | 499 | if (objlist.Count > 1) |
453 | { | 500 | { |
454 | item.Flags = (uint)InventoryItemFlags.ObjectHasMultipleItems; | 501 | item.Flags = (uint)InventoryItemFlags.ObjectHasMultipleItems; |
455 | 502 | ||
456 | // If the objects have different creators then don't specify a creator at all | 503 | // If the objects have different creators then don't specify a creator at all |
457 | foreach (SceneObjectGroup objectGroup in objlist) | 504 | foreach (SceneObjectGroup objectGroup in objlist) |
458 | { | 505 | { |
@@ -468,8 +515,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
468 | else | 515 | else |
469 | { | 516 | { |
470 | item.SaleType = objlist[0].RootPart.ObjectSaleType; | 517 | item.SaleType = objlist[0].RootPart.ObjectSaleType; |
471 | item.SalePrice = objlist[0].RootPart.SalePrice; | 518 | item.SalePrice = objlist[0].RootPart.SalePrice; |
472 | } | 519 | } |
473 | 520 | ||
474 | AssetBase asset = CreateAsset( | 521 | AssetBase asset = CreateAsset( |
475 | objlist[0].GetPartName(objlist[0].RootPart.LocalId), | 522 | objlist[0].GetPartName(objlist[0].RootPart.LocalId), |
@@ -478,7 +525,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
478 | Utils.StringToBytes(itemXml), | 525 | Utils.StringToBytes(itemXml), |
479 | objlist[0].OwnerID.ToString()); | 526 | objlist[0].OwnerID.ToString()); |
480 | m_Scene.AssetService.Store(asset); | 527 | m_Scene.AssetService.Store(asset); |
481 | 528 | ||
482 | item.AssetID = asset.FullID; | 529 | item.AssetID = asset.FullID; |
483 | 530 | ||
484 | if (DeRezAction.SaveToExistingUserInventoryItem == action) | 531 | if (DeRezAction.SaveToExistingUserInventoryItem == action) |
@@ -487,13 +534,13 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
487 | } | 534 | } |
488 | else | 535 | else |
489 | { | 536 | { |
537 | AddPermissions(item, objlist[0], objlist, remoteClient); | ||
538 | |||
490 | item.CreationDate = Util.UnixTimeSinceEpoch(); | 539 | item.CreationDate = Util.UnixTimeSinceEpoch(); |
491 | item.Description = asset.Description; | 540 | item.Description = asset.Description; |
492 | item.Name = asset.Name; | 541 | item.Name = asset.Name; |
493 | item.AssetType = asset.Type; | 542 | item.AssetType = asset.Type; |
494 | 543 | ||
495 | AddPermissions(item, objlist[0], objlist, remoteClient); | ||
496 | |||
497 | m_Scene.AddInventoryItem(item); | 544 | m_Scene.AddInventoryItem(item); |
498 | 545 | ||
499 | if (remoteClient != null && item.Owner == remoteClient.AgentId) | 546 | if (remoteClient != null && item.Owner == remoteClient.AgentId) |
@@ -510,17 +557,10 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
510 | } | 557 | } |
511 | } | 558 | } |
512 | 559 | ||
513 | // Restore KeyframeMotion | ||
514 | foreach (SceneObjectGroup objectGroup in group2Keyframe.Keys) | ||
515 | { | ||
516 | objectGroup.RootPart.KeyframeMotion = group2Keyframe[objectGroup]; | ||
517 | objectGroup.RootPart.KeyframeMotion.Start(); | ||
518 | } | ||
519 | |||
520 | // This is a hook to do some per-asset post-processing for subclasses that need that | 560 | // This is a hook to do some per-asset post-processing for subclasses that need that |
521 | if (remoteClient != null) | 561 | if (remoteClient != null && action != DeRezAction.Delete) |
522 | ExportAsset(remoteClient.AgentId, asset.FullID); | 562 | ExportAsset(remoteClient.AgentId, asset.FullID); |
523 | 563 | ||
524 | return item; | 564 | return item; |
525 | } | 565 | } |
526 | 566 | ||
@@ -538,56 +578,41 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
538 | /// <param name="remoteClient"></param> | 578 | /// <param name="remoteClient"></param> |
539 | /// <returns></returns> | 579 | /// <returns></returns> |
540 | protected InventoryItemBase AddPermissions( | 580 | protected InventoryItemBase AddPermissions( |
541 | InventoryItemBase item, SceneObjectGroup so, List<SceneObjectGroup> objsForEffectivePermissions, | 581 | InventoryItemBase item, SceneObjectGroup so, List<SceneObjectGroup> objsForEffectivePermissions, |
542 | IClientAPI remoteClient) | 582 | IClientAPI remoteClient) |
543 | { | 583 | { |
544 | uint effectivePerms = (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify | PermissionMask.Move | PermissionMask.Export) | 7; | 584 | uint effectivePerms = (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify | PermissionMask.Move | PermissionMask.Export | PermissionMask.FoldedMask); |
545 | uint allObjectsNextOwnerPerms = 0x7fffffff; | 585 | |
546 | uint allObjectsEveryOnePerms = 0x7fffffff; | ||
547 | uint allObjectsGroupPerms = 0x7fffffff; | ||
548 | |||
549 | foreach (SceneObjectGroup grp in objsForEffectivePermissions) | 586 | foreach (SceneObjectGroup grp in objsForEffectivePermissions) |
550 | { | 587 | { |
551 | effectivePerms &= grp.GetEffectivePermissions(); | 588 | effectivePerms &= grp.CurrentAndFoldedNextPermissions(); |
552 | allObjectsNextOwnerPerms &= grp.RootPart.NextOwnerMask; | ||
553 | allObjectsEveryOnePerms &= grp.RootPart.EveryoneMask; | ||
554 | allObjectsGroupPerms &= grp.RootPart.GroupMask; | ||
555 | } | 589 | } |
556 | effectivePerms |= (uint)PermissionMask.Move; | 590 | |
557 | |||
558 | //PermissionsUtil.LogPermissions(item.Name, "Before AddPermissions", item.BasePermissions, item.CurrentPermissions, item.NextPermissions); | ||
559 | |||
560 | if (remoteClient != null && (remoteClient.AgentId != so.RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions()) | 591 | if (remoteClient != null && (remoteClient.AgentId != so.RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions()) |
561 | { | 592 | { |
562 | // Changing ownership, so apply the "Next Owner" permissions to all of the | 593 | // apply parts inventory items next owner |
563 | // inventory item's permissions. | 594 | PermissionsUtil.ApplyNoModFoldedPermissions(effectivePerms, ref effectivePerms); |
564 | 595 | // change to next owner | |
565 | uint perms = effectivePerms; | 596 | uint basePerms = effectivePerms & so.RootPart.NextOwnerMask; |
566 | PermissionsUtil.ApplyFoldedPermissions(effectivePerms, ref perms); | 597 | // fix and update folded |
567 | 598 | basePerms = PermissionsUtil.FixAndFoldPermissions(basePerms); | |
568 | item.BasePermissions = perms & allObjectsNextOwnerPerms; | 599 | |
569 | item.CurrentPermissions = item.BasePermissions; | 600 | item.BasePermissions = basePerms; |
570 | item.NextPermissions = perms & allObjectsNextOwnerPerms; | 601 | item.CurrentPermissions = basePerms; |
571 | item.EveryOnePermissions = allObjectsEveryOnePerms & allObjectsNextOwnerPerms; | 602 | item.NextPermissions = basePerms & so.RootPart.NextOwnerMask; |
572 | item.GroupPermissions = allObjectsGroupPerms & allObjectsNextOwnerPerms; | 603 | item.EveryOnePermissions = basePerms & so.RootPart.EveryoneMask; |
573 | 604 | item.GroupPermissions = basePerms & so.RootPart.GroupMask; | |
605 | |||
574 | // apply next owner perms on rez | 606 | // apply next owner perms on rez |
575 | item.CurrentPermissions |= SceneObjectGroup.SLAM; | 607 | item.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm; |
576 | } | 608 | } |
577 | else | 609 | else |
578 | { | 610 | { |
579 | // Not changing ownership. | ||
580 | // In this case we apply the permissions in the object's items ONLY to the inventory | ||
581 | // item's "Next Owner" permissions, but NOT to its "Current", "Base", etc. permissions. | ||
582 | // E.g., if the object contains a No-Transfer item then the item's "Next Owner" | ||
583 | // permissions are also No-Transfer. | ||
584 | PermissionsUtil.ApplyFoldedPermissions(effectivePerms, ref allObjectsNextOwnerPerms); | ||
585 | |||
586 | item.BasePermissions = effectivePerms; | 611 | item.BasePermissions = effectivePerms; |
587 | item.CurrentPermissions = effectivePerms; | 612 | item.CurrentPermissions = effectivePerms; |
588 | item.NextPermissions = allObjectsNextOwnerPerms & effectivePerms; | 613 | item.NextPermissions = so.RootPart.NextOwnerMask & effectivePerms; |
589 | item.EveryOnePermissions = allObjectsEveryOnePerms & effectivePerms; | 614 | item.EveryOnePermissions = so.RootPart.EveryoneMask & effectivePerms; |
590 | item.GroupPermissions = allObjectsGroupPerms & effectivePerms; | 615 | item.GroupPermissions = so.RootPart.GroupMask & effectivePerms; |
591 | 616 | ||
592 | item.CurrentPermissions &= | 617 | item.CurrentPermissions &= |
593 | ((uint)PermissionMask.Copy | | 618 | ((uint)PermissionMask.Copy | |
@@ -595,14 +620,12 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
595 | (uint)PermissionMask.Modify | | 620 | (uint)PermissionMask.Modify | |
596 | (uint)PermissionMask.Move | | 621 | (uint)PermissionMask.Move | |
597 | (uint)PermissionMask.Export | | 622 | (uint)PermissionMask.Export | |
598 | 7); // Preserve folded permissions | 623 | (uint)PermissionMask.FoldedMask); // Preserve folded permissions ?? |
599 | } | 624 | } |
600 | 625 | ||
601 | //PermissionsUtil.LogPermissions(item.Name, "After AddPermissions", item.BasePermissions, item.CurrentPermissions, item.NextPermissions); | ||
602 | |||
603 | return item; | 626 | return item; |
604 | } | 627 | } |
605 | 628 | ||
606 | /// <summary> | 629 | /// <summary> |
607 | /// Create an item using details for the given scene object. | 630 | /// Create an item using details for the given scene object. |
608 | /// </summary> | 631 | /// </summary> |
@@ -615,7 +638,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
615 | DeRezAction action, IClientAPI remoteClient, SceneObjectGroup so, UUID folderID) | 638 | DeRezAction action, IClientAPI remoteClient, SceneObjectGroup so, UUID folderID) |
616 | { | 639 | { |
617 | // m_log.DebugFormat( | 640 | // m_log.DebugFormat( |
618 | // "[BASIC INVENTORY ACCESS MODULE]: Creating item for object {0} {1} for folder {2}, action {3}", | 641 | // "[BASIC INVENTORY ACCESS MODULE]: Creating item for object {0} {1} for folder {2}, action {3}", |
619 | // so.Name, so.UUID, folderID, action); | 642 | // so.Name, so.UUID, folderID, action); |
620 | // | 643 | // |
621 | // Get the user info of the item destination | 644 | // Get the user info of the item destination |
@@ -663,14 +686,13 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
663 | // Delete is treated like return in this case | 686 | // Delete is treated like return in this case |
664 | // Deleting your own items makes them go to trash | 687 | // Deleting your own items makes them go to trash |
665 | // | 688 | // |
666 | 689 | ||
667 | InventoryFolderBase folder = null; | 690 | InventoryFolderBase folder = null; |
668 | InventoryItemBase item = null; | 691 | InventoryItemBase item = null; |
669 | 692 | ||
670 | if (DeRezAction.SaveToExistingUserInventoryItem == action) | 693 | if (DeRezAction.SaveToExistingUserInventoryItem == action) |
671 | { | 694 | { |
672 | item = new InventoryItemBase(so.RootPart.FromUserInventoryItemID, userID); | 695 | item = m_Scene.InventoryService.GetItem(userID, so.RootPart.FromUserInventoryItemID); |
673 | item = m_Scene.InventoryService.GetItem(item); | ||
674 | 696 | ||
675 | //item = userInfo.RootFolder.FindItem( | 697 | //item = userInfo.RootFolder.FindItem( |
676 | // objectGroup.RootPart.FromUserInventoryItemID); | 698 | // objectGroup.RootPart.FromUserInventoryItemID); |
@@ -680,7 +702,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
680 | m_log.DebugFormat( | 702 | m_log.DebugFormat( |
681 | "[INVENTORY ACCESS MODULE]: Object {0} {1} scheduled for save to inventory has already been deleted.", | 703 | "[INVENTORY ACCESS MODULE]: Object {0} {1} scheduled for save to inventory has already been deleted.", |
682 | so.Name, so.UUID); | 704 | so.Name, so.UUID); |
683 | 705 | ||
684 | return null; | 706 | return null; |
685 | } | 707 | } |
686 | } | 708 | } |
@@ -742,8 +764,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
742 | { | 764 | { |
743 | if (so.FromFolderID != UUID.Zero && so.RootPart.OwnerID == remoteClient.AgentId) | 765 | if (so.FromFolderID != UUID.Zero && so.RootPart.OwnerID == remoteClient.AgentId) |
744 | { | 766 | { |
745 | InventoryFolderBase f = new InventoryFolderBase(so.FromFolderID, userID); | 767 | folder = m_Scene.InventoryService.GetFolder(userID, so.FromFolderID); |
746 | folder = m_Scene.InventoryService.GetFolder(f); | ||
747 | 768 | ||
748 | if(folder.Type == 14 || folder.Type == 16) | 769 | if(folder.Type == 14 || folder.Type == 16) |
749 | { | 770 | { |
@@ -763,49 +784,65 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
763 | } | 784 | } |
764 | } | 785 | } |
765 | 786 | ||
766 | item = new InventoryItemBase(); | 787 | item = new InventoryItemBase(); |
767 | item.ID = UUID.Random(); | 788 | item.ID = UUID.Random(); |
768 | item.InvType = (int)InventoryType.Object; | 789 | item.InvType = (int)InventoryType.Object; |
769 | item.Folder = folder.ID; | 790 | item.Folder = folder.ID; |
770 | item.Owner = userID; | 791 | item.Owner = userID; |
771 | } | 792 | } |
772 | 793 | ||
773 | return item; | 794 | return item; |
774 | } | 795 | } |
775 | 796 | // compatibility do not use | |
776 | public virtual SceneObjectGroup RezObject( | 797 | public virtual SceneObjectGroup RezObject( |
777 | IClientAPI remoteClient, UUID itemID, Vector3 RayEnd, Vector3 RayStart, | 798 | IClientAPI remoteClient, UUID itemID, Vector3 RayEnd, Vector3 RayStart, |
778 | UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, | 799 | UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, |
779 | bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment) | 800 | bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment) |
780 | { | 801 | { |
781 | // m_log.DebugFormat("[INVENTORY ACCESS MODULE]: RezObject for {0}, item {1}", remoteClient.Name, itemID); | 802 | return RezObject(remoteClient, itemID, UUID.Zero, RayEnd, RayStart, |
803 | RayTargetID, BypassRayCast, RayEndIsIntersection, | ||
804 | RezSelected, RemoveItem, fromTaskID, attachment); | ||
805 | } | ||
782 | 806 | ||
783 | InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); | 807 | public virtual SceneObjectGroup RezObject( |
784 | item = m_Scene.InventoryService.GetItem(item); | 808 | IClientAPI remoteClient, UUID itemID, UUID rezGroupID, Vector3 RayEnd, Vector3 RayStart, |
809 | UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, | ||
810 | bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment) | ||
811 | { | ||
812 | // m_log.DebugFormat("[INVENTORY ACCESS MODULE]: RezObject for {0}, item {1}", remoteClient.Name, itemID); | ||
813 | InventoryItemBase item = m_Scene.InventoryService.GetItem(remoteClient.AgentId, itemID); | ||
785 | 814 | ||
786 | if (item == null) | 815 | if (item == null) |
787 | { | 816 | { |
788 | m_log.WarnFormat( | ||
789 | "[INVENTORY ACCESS MODULE]: Could not find item {0} for {1} in RezObject()", | ||
790 | itemID, remoteClient.Name); | ||
791 | |||
792 | return null; | 817 | return null; |
793 | } | 818 | } |
794 | 819 | ||
795 | item.Owner = remoteClient.AgentId; | 820 | item.Owner = remoteClient.AgentId; |
796 | 821 | ||
797 | return RezObject( | 822 | return RezObject( |
798 | remoteClient, item, item.AssetID, | 823 | remoteClient, item, rezGroupID, item.AssetID, |
799 | RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection, | 824 | RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection, |
800 | RezSelected, RemoveItem, fromTaskID, attachment); | 825 | RezSelected, RemoveItem, fromTaskID, attachment); |
801 | } | 826 | } |
802 | 827 | // compatility | |
803 | public virtual SceneObjectGroup RezObject( | 828 | public virtual SceneObjectGroup RezObject( |
804 | IClientAPI remoteClient, InventoryItemBase item, UUID assetID, Vector3 RayEnd, Vector3 RayStart, | 829 | IClientAPI remoteClient, InventoryItemBase item, UUID assetID, Vector3 RayEnd, Vector3 RayStart, |
805 | UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, | 830 | UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, |
806 | bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment) | 831 | bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment) |
807 | { | 832 | { |
808 | AssetBase rezAsset = m_Scene.AssetService.Get(assetID.ToString()); | 833 | return RezObject(remoteClient, item, UUID.Zero, assetID, |
834 | RayEnd, RayStart, RayTargetID, | ||
835 | BypassRayCast, RayEndIsIntersection, | ||
836 | RezSelected, RemoveItem, fromTaskID, attachment); | ||
837 | } | ||
838 | |||
839 | public virtual SceneObjectGroup RezObject( | ||
840 | IClientAPI remoteClient, InventoryItemBase item, UUID groupID, UUID assetID, | ||
841 | Vector3 RayEnd, Vector3 RayStart, UUID RayTargetID, | ||
842 | byte BypassRayCast, bool RayEndIsIntersection, | ||
843 | bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment) | ||
844 | { | ||
845 | AssetBase rezAsset = m_Scene.AssetService.Get(assetID.ToString()); | ||
809 | 846 | ||
810 | if (rezAsset == null) | 847 | if (rezAsset == null) |
811 | { | 848 | { |
@@ -827,6 +864,15 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
827 | return null; | 864 | return null; |
828 | } | 865 | } |
829 | 866 | ||
867 | if(rezAsset.Data == null || rezAsset.Data.Length == 0) | ||
868 | { | ||
869 | m_log.WarnFormat( | ||
870 | "[INVENTORY ACCESS MODULE]: missing data in asset {0} to RezObject()", | ||
871 | assetID, remoteClient.Name); | ||
872 | remoteClient.SendAgentAlertMessage(string.Format("Unable to rez: missing data in asset {0} ", assetID), false); | ||
873 | return null; | ||
874 | } | ||
875 | |||
830 | SceneObjectGroup group = null; | 876 | SceneObjectGroup group = null; |
831 | 877 | ||
832 | List<SceneObjectGroup> objlist; | 878 | List<SceneObjectGroup> objlist; |
@@ -836,7 +882,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
836 | byte bRayEndIsIntersection = (byte)(RayEndIsIntersection ? 1 : 0); | 882 | byte bRayEndIsIntersection = (byte)(RayEndIsIntersection ? 1 : 0); |
837 | Vector3 pos; | 883 | Vector3 pos; |
838 | 884 | ||
839 | bool single | 885 | bool single |
840 | = m_Scene.GetObjectsToRez( | 886 | = m_Scene.GetObjectsToRez( |
841 | rezAsset.Data, attachment, out objlist, out veclist, out bbox, out offsetHeight); | 887 | rezAsset.Data, attachment, out objlist, out veclist, out bbox, out offsetHeight); |
842 | 888 | ||
@@ -856,12 +902,35 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
856 | pos -= bbox / 2; | 902 | pos -= bbox / 2; |
857 | } | 903 | } |
858 | 904 | ||
905 | int primcount = 0; | ||
906 | foreach (SceneObjectGroup g in objlist) | ||
907 | primcount += g.PrimCount; | ||
908 | |||
909 | if (!m_Scene.Permissions.CanRezObject( | ||
910 | primcount, remoteClient.AgentId, pos) | ||
911 | && !attachment) | ||
912 | { | ||
913 | // The client operates in no fail mode. It will | ||
914 | // have already removed the item from the folder | ||
915 | // if it's no copy. | ||
916 | // Put it back if it's not an attachment | ||
917 | // | ||
918 | if (item != null) | ||
919 | { | ||
920 | if (((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) && (!attachment)) | ||
921 | remoteClient.SendBulkUpdateInventory(item); | ||
922 | } | ||
923 | |||
924 | return null; | ||
925 | } | ||
926 | |||
859 | if (item != null && !DoPreRezWhenFromItem(remoteClient, item, objlist, pos, veclist, attachment)) | 927 | if (item != null && !DoPreRezWhenFromItem(remoteClient, item, objlist, pos, veclist, attachment)) |
860 | return null; | 928 | return null; |
861 | 929 | ||
862 | for (int i = 0; i < objlist.Count; i++) | 930 | for (int i = 0; i < objlist.Count; i++) |
863 | { | 931 | { |
864 | group = objlist[i]; | 932 | group = objlist[i]; |
933 | SceneObjectPart rootPart = group.RootPart; | ||
865 | 934 | ||
866 | // m_log.DebugFormat( | 935 | // m_log.DebugFormat( |
867 | // "[INVENTORY ACCESS MODULE]: Preparing to rez {0} {1} {2} ownermask={3:X} nextownermask={4:X} groupmask={5:X} everyonemask={6:X} for {7}", | 936 | // "[INVENTORY ACCESS MODULE]: Preparing to rez {0} {1} {2} ownermask={3:X} nextownermask={4:X} groupmask={5:X} everyonemask={6:X} for {7}", |
@@ -891,9 +960,12 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
891 | // Make the rezzer the owner, as this is not necessarily set correctly in the serialized asset. | 960 | // Make the rezzer the owner, as this is not necessarily set correctly in the serialized asset. |
892 | part.LastOwnerID = part.OwnerID; | 961 | part.LastOwnerID = part.OwnerID; |
893 | part.OwnerID = remoteClient.AgentId; | 962 | part.OwnerID = remoteClient.AgentId; |
963 | part.RezzerID = remoteClient.AgentId; | ||
894 | } | 964 | } |
895 | } | 965 | } |
896 | 966 | ||
967 | group.ResetIDs(); | ||
968 | |||
897 | if (!attachment) | 969 | if (!attachment) |
898 | { | 970 | { |
899 | // If it's rezzed in world, select it. Much easier to | 971 | // If it's rezzed in world, select it. Much easier to |
@@ -903,48 +975,38 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
903 | { | 975 | { |
904 | part.CreateSelected = true; | 976 | part.CreateSelected = true; |
905 | } | 977 | } |
906 | } | ||
907 | 978 | ||
908 | group.ResetIDs(); | 979 | if (rootPart.Shape.PCode == (byte)PCode.Prim) |
909 | 980 | group.ClearPartAttachmentData(); | |
910 | if (attachment) | 981 | } |
982 | else | ||
911 | { | 983 | { |
912 | group.RootPart.Flags |= PrimFlags.Phantom; | ||
913 | group.IsAttachment = true; | 984 | group.IsAttachment = true; |
914 | } | 985 | } |
915 | 986 | ||
987 | group.SetGroup(groupID, remoteClient); | ||
988 | |||
916 | // If we're rezzing an attachment then don't ask | 989 | // If we're rezzing an attachment then don't ask |
917 | // AddNewSceneObject() to update the client since | 990 | // AddNewSceneObject() to update the client since |
918 | // we'll be doing that later on. Scheduling more than | 991 | // we'll be doing that later on. Scheduling more than |
919 | // one full update during the attachment | 992 | // one full update during the attachment |
920 | // process causes some clients to fail to display the | 993 | // process causes some clients to fail to display the |
921 | // attachment properly. | 994 | // attachment properly. |
922 | m_Scene.AddNewSceneObject(group, !attachment, false); | ||
923 | 995 | ||
924 | // if attachment we set it's asset id so object updates | ||
925 | // can reflect that, if not, we set it's position in world. | ||
926 | if (!attachment) | 996 | if (!attachment) |
927 | { | 997 | { |
928 | group.ScheduleGroupForFullUpdate(); | ||
929 | |||
930 | group.AbsolutePosition = pos + veclist[i]; | 998 | group.AbsolutePosition = pos + veclist[i]; |
931 | } | 999 | m_Scene.AddNewSceneObject(group, true, false); |
932 | |||
933 | group.SetGroup(remoteClient.ActiveGroupId, remoteClient); | ||
934 | |||
935 | if (!attachment) | ||
936 | { | ||
937 | SceneObjectPart rootPart = group.RootPart; | ||
938 | |||
939 | if (rootPart.Shape.PCode == (byte)PCode.Prim) | ||
940 | group.ClearPartAttachmentData(); | ||
941 | 1000 | ||
942 | // Fire on_rez | 1001 | // Fire on_rez |
943 | group.CreateScriptInstances(0, true, m_Scene.DefaultScriptEngine, 1); | 1002 | group.CreateScriptInstances(0, true, m_Scene.DefaultScriptEngine, 1); |
944 | rootPart.ParentGroup.ResumeScripts(); | 1003 | rootPart.ParentGroup.ResumeScripts(); |
945 | 1004 | ||
946 | rootPart.ScheduleFullUpdate(); | 1005 | group.ScheduleGroupForFullUpdate(); |
947 | } | 1006 | } |
1007 | else | ||
1008 | m_Scene.AddNewSceneObject(group, true, false); | ||
1009 | |||
948 | 1010 | ||
949 | // m_log.DebugFormat( | 1011 | // m_log.DebugFormat( |
950 | // "[INVENTORY ACCESS MODULE]: Rezzed {0} {1} {2} ownermask={3:X} nextownermask={4:X} groupmask={5:X} everyonemask={6:X} for {7}", | 1012 | // "[INVENTORY ACCESS MODULE]: Rezzed {0} {1} {2} ownermask={3:X} nextownermask={4:X} groupmask={5:X} everyonemask={6:X} for {7}", |
@@ -953,6 +1015,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
953 | // remoteClient.Name); | 1015 | // remoteClient.Name); |
954 | } | 1016 | } |
955 | 1017 | ||
1018 | // group.SetGroup(remoteClient.ActiveGroupId, remoteClient); | ||
1019 | |||
956 | if (item != null) | 1020 | if (item != null) |
957 | DoPostRezWhenFromItem(item, attachment); | 1021 | DoPostRezWhenFromItem(item, attachment); |
958 | 1022 | ||
@@ -973,7 +1037,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
973 | /// <param name="isAttachment"></param> | 1037 | /// <param name="isAttachment"></param> |
974 | /// <returns>true if we can processed with rezzing, false if we need to abort</returns> | 1038 | /// <returns>true if we can processed with rezzing, false if we need to abort</returns> |
975 | private bool DoPreRezWhenFromItem( | 1039 | private bool DoPreRezWhenFromItem( |
976 | IClientAPI remoteClient, InventoryItemBase item, List<SceneObjectGroup> objlist, | 1040 | IClientAPI remoteClient, InventoryItemBase item, List<SceneObjectGroup> objlist, |
977 | Vector3 pos, List<Vector3> veclist, bool isAttachment) | 1041 | Vector3 pos, List<Vector3> veclist, bool isAttachment) |
978 | { | 1042 | { |
979 | UUID fromUserInventoryItemId = UUID.Zero; | 1043 | UUID fromUserInventoryItemId = UUID.Zero; |
@@ -1033,10 +1097,16 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
1033 | // object itself before we rez. | 1097 | // object itself before we rez. |
1034 | // | 1098 | // |
1035 | // Only do these for the first object if we are rezzing a coalescence. | 1099 | // Only do these for the first object if we are rezzing a coalescence. |
1036 | if (i == 0) | 1100 | // nahh dont mess with coalescence objects, |
1101 | // the name in inventory can be change for inventory purpuses only | ||
1102 | if (objlist.Count == 1) | ||
1037 | { | 1103 | { |
1038 | rootPart.Name = item.Name; | 1104 | rootPart.Name = item.Name; |
1039 | rootPart.Description = item.Description; | 1105 | rootPart.Description = item.Description; |
1106 | } | ||
1107 | |||
1108 | if ((item.Flags & (uint)InventoryItemFlags.ObjectSlamSale) != 0) | ||
1109 | { | ||
1040 | rootPart.ObjectSaleType = item.SaleType; | 1110 | rootPart.ObjectSaleType = item.SaleType; |
1041 | rootPart.SalePrice = item.SalePrice; | 1111 | rootPart.SalePrice = item.SalePrice; |
1042 | } | 1112 | } |
@@ -1047,20 +1117,78 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
1047 | // "[INVENTORY ACCESS MODULE]: rootPart.OwnedID {0}, item.Owner {1}, item.CurrentPermissions {2:X}", | 1117 | // "[INVENTORY ACCESS MODULE]: rootPart.OwnedID {0}, item.Owner {1}, item.CurrentPermissions {2:X}", |
1048 | // rootPart.OwnerID, item.Owner, item.CurrentPermissions); | 1118 | // rootPart.OwnerID, item.Owner, item.CurrentPermissions); |
1049 | 1119 | ||
1050 | if ((rootPart.OwnerID != item.Owner) || (item.CurrentPermissions & SceneObjectGroup.SLAM) != 0) | 1120 | if ((rootPart.OwnerID != item.Owner) || |
1121 | (item.CurrentPermissions & (uint)PermissionMask.Slam) != 0 || | ||
1122 | (item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0) | ||
1051 | { | 1123 | { |
1052 | //Need to kill the for sale here | 1124 | //Need to kill the for sale here |
1053 | rootPart.ObjectSaleType = 0; | 1125 | rootPart.ObjectSaleType = 0; |
1054 | rootPart.SalePrice = 10; | 1126 | rootPart.SalePrice = 10; |
1055 | } | ||
1056 | 1127 | ||
1057 | foreach (SceneObjectPart part in so.Parts) | 1128 | if (m_Scene.Permissions.PropagatePermissions()) |
1129 | { | ||
1130 | foreach (SceneObjectPart part in so.Parts) | ||
1131 | { | ||
1132 | part.GroupMask = 0; // DO NOT propagate here | ||
1133 | if( part.OwnerID != part.GroupID) | ||
1134 | part.LastOwnerID = part.OwnerID; | ||
1135 | part.OwnerID = item.Owner; | ||
1136 | part.RezzerID = item.Owner; | ||
1137 | part.Inventory.ChangeInventoryOwner(item.Owner); | ||
1138 | |||
1139 | // Reconstruct the original item's base permissions. They | ||
1140 | // can be found in the lower (folded) bits. | ||
1141 | if ((item.BasePermissions & (uint)PermissionMask.FoldedMask) != 0) | ||
1142 | { | ||
1143 | // We have permissions stored there so use them | ||
1144 | part.NextOwnerMask = ((item.BasePermissions & (uint)PermissionMask.FoldedMask) << (int)PermissionMask.FoldingShift); | ||
1145 | part.NextOwnerMask |= (uint)PermissionMask.Move; | ||
1146 | } | ||
1147 | else | ||
1148 | { | ||
1149 | // This is a legacy object and we can't avoid the issues that | ||
1150 | // caused perms loss or escalation before, treat it the legacy | ||
1151 | // way. | ||
1152 | part.NextOwnerMask = item.NextPermissions; | ||
1153 | } | ||
1154 | } | ||
1155 | |||
1156 | so.ApplyNextOwnerPermissions(); | ||
1157 | |||
1158 | // In case the user has changed flags on a received item | ||
1159 | // we have to apply those changes after the slam. Else we | ||
1160 | // get a net loss of permissions. | ||
1161 | // On legacy objects, this opts for a loss of permissions rather | ||
1162 | // than the previous handling that allowed escalation. | ||
1163 | foreach (SceneObjectPart part in so.Parts) | ||
1164 | { | ||
1165 | if ((item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0) | ||
1166 | { | ||
1167 | part.GroupMask = item.GroupPermissions & part.BaseMask; | ||
1168 | part.EveryoneMask = item.EveryOnePermissions & part.BaseMask; | ||
1169 | part.NextOwnerMask = item.NextPermissions & part.BaseMask; | ||
1170 | } | ||
1171 | } | ||
1172 | |||
1173 | } | ||
1174 | } | ||
1175 | else | ||
1058 | { | 1176 | { |
1059 | part.FromUserInventoryItemID = fromUserInventoryItemId; | 1177 | foreach (SceneObjectPart part in so.Parts) |
1060 | part.ApplyPermissionsOnRez(item, true, m_Scene); | 1178 | { |
1179 | part.FromUserInventoryItemID = fromUserInventoryItemId; | ||
1180 | |||
1181 | if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteEveryone) != 0) | ||
1182 | part.EveryoneMask = item.EveryOnePermissions; | ||
1183 | if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteNextOwner) != 0) | ||
1184 | part.NextOwnerMask = item.NextPermissions; | ||
1185 | if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteGroup) != 0) | ||
1186 | part.GroupMask = item.GroupPermissions; | ||
1187 | } | ||
1061 | } | 1188 | } |
1062 | 1189 | ||
1063 | rootPart.TrimPermissions(); | 1190 | rootPart.TrimPermissions(); |
1191 | so.InvalidateDeepEffectivePerms(); | ||
1064 | 1192 | ||
1065 | if (isAttachment) | 1193 | if (isAttachment) |
1066 | so.FromItemID = item.ID; | 1194 | so.FromItemID = item.ID; |
@@ -1184,9 +1312,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
1184 | protected virtual InventoryItemBase GetItem(UUID agentID, UUID itemID) | 1312 | protected virtual InventoryItemBase GetItem(UUID agentID, UUID itemID) |
1185 | { | 1313 | { |
1186 | IInventoryService invService = m_Scene.RequestModuleInterface<IInventoryService>(); | 1314 | IInventoryService invService = m_Scene.RequestModuleInterface<IInventoryService>(); |
1187 | InventoryItemBase item = new InventoryItemBase(itemID, agentID); | 1315 | InventoryItemBase item = invService.GetItem(agentID, itemID); |
1188 | item = invService.GetItem(item); | 1316 | |
1189 | |||
1190 | if (item != null && item.CreatorData != null && item.CreatorData != string.Empty) | 1317 | if (item != null && item.CreatorData != null && item.CreatorData != string.Empty) |
1191 | UserManagementModule.AddUser(item.CreatorIdAsUuid, item.CreatorData); | 1318 | UserManagementModule.AddUser(item.CreatorIdAsUuid, item.CreatorData); |
1192 | 1319 | ||