diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/Framework/InventoryAccess')
3 files changed, 171 insertions, 128 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs index 7871eda..d4fb1ba 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs | |||
@@ -73,6 +73,9 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
73 | 73 | ||
74 | private AssetMetadata FetchMetadata(string url, UUID assetID) | 74 | private AssetMetadata FetchMetadata(string url, UUID assetID) |
75 | { | 75 | { |
76 | if (string.IsNullOrEmpty(url)) | ||
77 | return null; | ||
78 | |||
76 | if (!url.EndsWith("/") && !url.EndsWith("=")) | 79 | if (!url.EndsWith("/") && !url.EndsWith("=")) |
77 | url = url + "/"; | 80 | url = url + "/"; |
78 | 81 | ||
@@ -92,6 +95,9 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
92 | AssetBase asset = m_scene.AssetService.Get(assetID.ToString()); | 95 | AssetBase asset = m_scene.AssetService.Get(assetID.ToString()); |
93 | if (asset == null) | 96 | if (asset == null) |
94 | { | 97 | { |
98 | if (string.IsNullOrEmpty(url)) | ||
99 | return null; | ||
100 | |||
95 | if (!url.EndsWith("/") && !url.EndsWith("=")) | 101 | if (!url.EndsWith("/") && !url.EndsWith("=")) |
96 | url = url + "/"; | 102 | url = url + "/"; |
97 | 103 | ||
@@ -109,6 +115,9 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
109 | 115 | ||
110 | public bool PostAsset(string url, AssetBase asset) | 116 | public bool PostAsset(string url, AssetBase asset) |
111 | { | 117 | { |
118 | if (string.IsNullOrEmpty(url)) | ||
119 | return false; | ||
120 | |||
112 | if (asset != null) | 121 | if (asset != null) |
113 | { | 122 | { |
114 | if (!url.EndsWith("/") && !url.EndsWith("=")) | 123 | if (!url.EndsWith("/") && !url.EndsWith("=")) |
@@ -165,7 +174,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
165 | 174 | ||
166 | private void AdjustIdentifiers(AssetMetadata meta) | 175 | private void AdjustIdentifiers(AssetMetadata meta) |
167 | { | 176 | { |
168 | if (meta.CreatorID != null && meta.CreatorID != string.Empty) | 177 | if (!string.IsNullOrEmpty(meta.CreatorID)) |
169 | { | 178 | { |
170 | UUID uuid = UUID.Zero; | 179 | UUID uuid = UUID.Zero; |
171 | UUID.TryParse(meta.CreatorID, out uuid); | 180 | UUID.TryParse(meta.CreatorID, out uuid); |
@@ -251,9 +260,9 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
251 | 260 | ||
252 | // The act of gathering UUIDs downloads some assets from the remote server | 261 | // The act of gathering UUIDs downloads some assets from the remote server |
253 | // but not all... | 262 | // but not all... |
254 | Dictionary<UUID, AssetType> ids = new Dictionary<UUID, AssetType>(); | 263 | Dictionary<UUID, sbyte> ids = new Dictionary<UUID, sbyte>(); |
255 | HGUuidGatherer uuidGatherer = new HGUuidGatherer(m_scene.AssetService, userAssetURL); | 264 | HGUuidGatherer uuidGatherer = new HGUuidGatherer(m_scene.AssetService, userAssetURL); |
256 | uuidGatherer.GatherAssetUuids(assetID, (AssetType)meta.Type, ids); | 265 | uuidGatherer.GatherAssetUuids(assetID, meta.Type, ids); |
257 | m_log.DebugFormat("[HG ASSET MAPPER]: Preparing to get {0} assets", ids.Count); | 266 | m_log.DebugFormat("[HG ASSET MAPPER]: Preparing to get {0} assets", ids.Count); |
258 | bool success = true; | 267 | bool success = true; |
259 | foreach (UUID uuid in ids.Keys) | 268 | foreach (UUID uuid in ids.Keys) |
@@ -277,9 +286,9 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
277 | AssetBase asset = m_scene.AssetService.Get(assetID.ToString()); | 286 | AssetBase asset = m_scene.AssetService.Get(assetID.ToString()); |
278 | if (asset != null) | 287 | if (asset != null) |
279 | { | 288 | { |
280 | Dictionary<UUID, AssetType> ids = new Dictionary<UUID, AssetType>(); | 289 | Dictionary<UUID, sbyte> ids = new Dictionary<UUID, sbyte>(); |
281 | HGUuidGatherer uuidGatherer = new HGUuidGatherer(m_scene.AssetService, string.Empty); | 290 | HGUuidGatherer uuidGatherer = new HGUuidGatherer(m_scene.AssetService, string.Empty); |
282 | uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids); | 291 | uuidGatherer.GatherAssetUuids(asset.FullID, asset.Type, ids); |
283 | bool success = false; | 292 | bool success = false; |
284 | foreach (UUID uuid in ids.Keys) | 293 | foreach (UUID uuid in ids.Keys) |
285 | { | 294 | { |
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs index b2b628d..ce7ed26 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs | |||
@@ -62,6 +62,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
62 | private string m_ThisGatekeeper; | 62 | private string m_ThisGatekeeper; |
63 | private bool m_RestrictInventoryAccessAbroad; | 63 | private bool m_RestrictInventoryAccessAbroad; |
64 | 64 | ||
65 | private bool m_bypassPermissions = true; | ||
66 | |||
65 | // private bool m_Initialized = false; | 67 | // private bool m_Initialized = false; |
66 | 68 | ||
67 | #region INonSharedRegionModule | 69 | #region INonSharedRegionModule |
@@ -100,6 +102,10 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
100 | } | 102 | } |
101 | else | 103 | else |
102 | m_log.Warn("[HG INVENTORY ACCESS MODULE]: HGInventoryAccessModule configs not found. ProfileServerURI not set!"); | 104 | m_log.Warn("[HG INVENTORY ACCESS MODULE]: HGInventoryAccessModule configs not found. ProfileServerURI not set!"); |
105 | |||
106 | m_bypassPermissions = !Util.GetConfigVarFromSections<bool>(source, "serverside_object_permissions", | ||
107 | new string[] { "Startup", "Permissions" }, true); | ||
108 | |||
103 | } | 109 | } |
104 | } | 110 | } |
105 | } | 111 | } |
@@ -114,6 +120,11 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
114 | scene.EventManager.OnNewInventoryItemUploadComplete += UploadInventoryItem; | 120 | scene.EventManager.OnNewInventoryItemUploadComplete += UploadInventoryItem; |
115 | scene.EventManager.OnTeleportStart += TeleportStart; | 121 | scene.EventManager.OnTeleportStart += TeleportStart; |
116 | scene.EventManager.OnTeleportFail += TeleportFail; | 122 | scene.EventManager.OnTeleportFail += TeleportFail; |
123 | |||
124 | // We're fgoing to enforce some stricter permissions if Outbound is false | ||
125 | scene.Permissions.OnTakeObject += CanTakeObject; | ||
126 | scene.Permissions.OnTakeCopyObject += CanTakeObject; | ||
127 | scene.Permissions.OnTransferUserInventory += OnTransferUserInventory; | ||
117 | } | 128 | } |
118 | 129 | ||
119 | #endregion | 130 | #endregion |
@@ -135,7 +146,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
135 | if (sp is ScenePresence) | 146 | if (sp is ScenePresence) |
136 | { | 147 | { |
137 | AgentCircuitData aCircuit = ((ScenePresence)sp).Scene.AuthenticateHandler.GetAgentCircuitData(client.AgentId); | 148 | AgentCircuitData aCircuit = ((ScenePresence)sp).Scene.AuthenticateHandler.GetAgentCircuitData(client.AgentId); |
138 | if ((aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0) | 149 | if (aCircuit != null && (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0) |
139 | { | 150 | { |
140 | if (m_RestrictInventoryAccessAbroad) | 151 | if (m_RestrictInventoryAccessAbroad) |
141 | { | 152 | { |
@@ -185,8 +196,11 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
185 | } | 196 | } |
186 | } | 197 | } |
187 | 198 | ||
188 | public void UploadInventoryItem(UUID avatarID, UUID assetID, string name, int userlevel) | 199 | public void UploadInventoryItem(UUID avatarID, AssetType type, UUID assetID, string name, int userlevel) |
189 | { | 200 | { |
201 | if (type == AssetType.Link) | ||
202 | return; | ||
203 | |||
190 | string userAssetServer = string.Empty; | 204 | string userAssetServer = string.Empty; |
191 | if (IsForeignUser(avatarID, out userAssetServer) && userAssetServer != string.Empty && m_OutboundPermission) | 205 | if (IsForeignUser(avatarID, out userAssetServer) && userAssetServer != string.Empty && m_OutboundPermission) |
192 | { | 206 | { |
@@ -221,7 +235,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
221 | { | 235 | { |
222 | UUID newAssetID = base.CapsUpdateInventoryItemAsset(remoteClient, itemID, data); | 236 | UUID newAssetID = base.CapsUpdateInventoryItemAsset(remoteClient, itemID, data); |
223 | 237 | ||
224 | UploadInventoryItem(remoteClient.AgentId, newAssetID, "", 0); | 238 | UploadInventoryItem(remoteClient.AgentId, AssetType.Unknown, newAssetID, "", 0); |
225 | 239 | ||
226 | return newAssetID; | 240 | return newAssetID; |
227 | } | 241 | } |
@@ -232,7 +246,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
232 | protected override void ExportAsset(UUID agentID, UUID assetID) | 246 | protected override void ExportAsset(UUID agentID, UUID assetID) |
233 | { | 247 | { |
234 | if (!assetID.Equals(UUID.Zero)) | 248 | if (!assetID.Equals(UUID.Zero)) |
235 | UploadInventoryItem(agentID, assetID, "", 0); | 249 | UploadInventoryItem(agentID, AssetType.Unknown, assetID, "", 0); |
236 | else | 250 | else |
237 | m_log.Debug("[HGScene]: Scene.Inventory did not create asset"); | 251 | m_log.Debug("[HGScene]: Scene.Inventory did not create asset"); |
238 | } | 252 | } |
@@ -244,7 +258,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
244 | UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, | 258 | UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, |
245 | bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment) | 259 | bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment) |
246 | { | 260 | { |
247 | m_log.DebugFormat("[HGScene] RezObject itemID={0} fromTaskID={1}", itemID, fromTaskID); | 261 | m_log.DebugFormat("[HGScene]: RezObject itemID={0} fromTaskID={1}", itemID, fromTaskID); |
248 | 262 | ||
249 | //if (fromTaskID.Equals(UUID.Zero)) | 263 | //if (fromTaskID.Equals(UUID.Zero)) |
250 | //{ | 264 | //{ |
@@ -297,7 +311,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
297 | if (m_Scene.TryGetScenePresence(userID, out sp)) | 311 | if (m_Scene.TryGetScenePresence(userID, out sp)) |
298 | { | 312 | { |
299 | AgentCircuitData aCircuit = m_Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); | 313 | AgentCircuitData aCircuit = m_Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); |
300 | if (aCircuit.ServiceURLs.ContainsKey("AssetServerURI")) | 314 | if (aCircuit != null && aCircuit.ServiceURLs != null && aCircuit.ServiceURLs.ContainsKey("AssetServerURI")) |
301 | { | 315 | { |
302 | assetServerURL = aCircuit.ServiceURLs["AssetServerURI"].ToString(); | 316 | assetServerURL = aCircuit.ServiceURLs["AssetServerURI"].ToString(); |
303 | assetServerURL = assetServerURL.Trim(new char[] { '/' }); | 317 | assetServerURL = assetServerURL.Trim(new char[] { '/' }); |
@@ -348,7 +362,15 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
348 | InventoryFolderBase root = m_Scene.InventoryService.GetRootFolder(client.AgentId); | 362 | InventoryFolderBase root = m_Scene.InventoryService.GetRootFolder(client.AgentId); |
349 | InventoryCollection content = m_Scene.InventoryService.GetFolderContent(client.AgentId, root.ID); | 363 | InventoryCollection content = m_Scene.InventoryService.GetFolderContent(client.AgentId, root.ID); |
350 | 364 | ||
351 | inv.SendBulkUpdateInventory(content.Folders.ToArray(), content.Items.ToArray()); | 365 | List<InventoryFolderBase> keep = new List<InventoryFolderBase>(); |
366 | |||
367 | foreach (InventoryFolderBase f in content.Folders) | ||
368 | { | ||
369 | if (f.Name != "My Suitcase" && f.Name != "Current Outfit") | ||
370 | keep.Add(f); | ||
371 | } | ||
372 | |||
373 | inv.SendBulkUpdateInventory(keep.ToArray(), content.Items.ToArray()); | ||
352 | } | 374 | } |
353 | } | 375 | } |
354 | } | 376 | } |
@@ -381,7 +403,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
381 | 403 | ||
382 | foreach (InventoryFolderBase f in content.Folders) | 404 | foreach (InventoryFolderBase f in content.Folders) |
383 | { | 405 | { |
384 | if (f.Name != "My Suitcase") | 406 | if (f.Name != "My Suitcase" && f.Name != "Current Outfit") |
385 | { | 407 | { |
386 | f.Name = f.Name + " (Unavailable)"; | 408 | f.Name = f.Name + " (Unavailable)"; |
387 | keep.Add(f); | 409 | keep.Add(f); |
@@ -406,5 +428,36 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
406 | } | 428 | } |
407 | 429 | ||
408 | #endregion | 430 | #endregion |
431 | |||
432 | #region Permissions | ||
433 | |||
434 | private bool CanTakeObject(UUID objectID, UUID stealer, Scene scene) | ||
435 | { | ||
436 | if (m_bypassPermissions) return true; | ||
437 | |||
438 | if (!m_OutboundPermission && !UserManagementModule.IsLocalGridUser(stealer)) | ||
439 | { | ||
440 | SceneObjectGroup sog = null; | ||
441 | if (m_Scene.TryGetSceneObjectGroup(objectID, out sog) && sog.OwnerID == stealer) | ||
442 | return true; | ||
443 | |||
444 | return false; | ||
445 | } | ||
446 | |||
447 | return true; | ||
448 | } | ||
449 | |||
450 | private bool OnTransferUserInventory(UUID itemID, UUID userID, UUID recipientID) | ||
451 | { | ||
452 | if (m_bypassPermissions) return true; | ||
453 | |||
454 | if (!m_OutboundPermission && !UserManagementModule.IsLocalGridUser(recipientID)) | ||
455 | return false; | ||
456 | |||
457 | return true; | ||
458 | } | ||
459 | |||
460 | |||
461 | #endregion | ||
409 | } | 462 | } |
410 | } \ No newline at end of file | 463 | } \ No newline at end of file |
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index d09ea3e..fadcd5e 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs | |||
@@ -358,7 +358,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
358 | bool asAttachment) | 358 | bool asAttachment) |
359 | { | 359 | { |
360 | CoalescedSceneObjects coa = new CoalescedSceneObjects(UUID.Zero); | 360 | CoalescedSceneObjects coa = new CoalescedSceneObjects(UUID.Zero); |
361 | Dictionary<UUID, Vector3> originalPositions = new Dictionary<UUID, Vector3>(); | 361 | // Dictionary<UUID, Vector3> originalPositions = new Dictionary<UUID, Vector3>(); |
362 | 362 | ||
363 | foreach (SceneObjectGroup objectGroup in objlist) | 363 | foreach (SceneObjectGroup objectGroup in objlist) |
364 | { | 364 | { |
@@ -379,7 +379,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
379 | objectGroup.AbsolutePosition.Z); | 379 | objectGroup.AbsolutePosition.Z); |
380 | 380 | ||
381 | Quaternion inventoryStoredRotation = objectGroup.GroupRotation; | 381 | Quaternion inventoryStoredRotation = objectGroup.GroupRotation; |
382 | originalPositions[objectGroup.UUID] = objectGroup.AbsolutePosition; | 382 | //originalPositions[objectGroup.UUID] = objectGroup.AbsolutePosition; |
383 | 383 | ||
384 | // Restore attachment data after trip through the sim | 384 | // Restore attachment data after trip through the sim |
385 | if (objectGroup.RootPart.AttachPoint > 0) | 385 | if (objectGroup.RootPart.AttachPoint > 0) |
@@ -390,9 +390,13 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
390 | 390 | ||
391 | // Trees could be attached and it's been done, but it makes | 391 | // Trees could be attached and it's been done, but it makes |
392 | // no sense. State must be preserved because it's the tree type | 392 | // no sense. State must be preserved because it's the tree type |
393 | if (objectGroup.RootPart.Shape.PCode != (byte)PCode.Tree && | 393 | if (objectGroup.RootPart.Shape.PCode != (byte) PCode.Tree && |
394 | objectGroup.RootPart.Shape.PCode != (byte)PCode.NewTree) | 394 | objectGroup.RootPart.Shape.PCode != (byte) PCode.NewTree) |
395 | { | ||
395 | objectGroup.RootPart.Shape.State = objectGroup.RootPart.AttachPoint; | 396 | objectGroup.RootPart.Shape.State = objectGroup.RootPart.AttachPoint; |
397 | if (objectGroup.RootPart.AttachPoint > 0) | ||
398 | objectGroup.RootPart.Shape.LastAttachPoint = objectGroup.RootPart.AttachPoint; | ||
399 | } | ||
396 | 400 | ||
397 | objectGroup.AbsolutePosition = inventoryStoredPosition; | 401 | objectGroup.AbsolutePosition = inventoryStoredPosition; |
398 | objectGroup.RootPart.RotationOffset = inventoryStoredRotation; | 402 | objectGroup.RootPart.RotationOffset = inventoryStoredRotation; |
@@ -423,9 +427,9 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
423 | else | 427 | else |
424 | itemXml = SceneObjectSerializer.ToOriginalXmlFormat(objlist[0], !asAttachment); | 428 | itemXml = SceneObjectSerializer.ToOriginalXmlFormat(objlist[0], !asAttachment); |
425 | 429 | ||
426 | // Restore the position of each group now that it has been stored to inventory. | 430 | // // Restore the position of each group now that it has been stored to inventory. |
427 | foreach (SceneObjectGroup objectGroup in objlist) | 431 | // foreach (SceneObjectGroup objectGroup in objlist) |
428 | objectGroup.AbsolutePosition = originalPositions[objectGroup.UUID]; | 432 | // objectGroup.AbsolutePosition = originalPositions[objectGroup.UUID]; |
429 | 433 | ||
430 | InventoryItemBase item = CreateItemForObject(action, remoteClient, objlist[0], folderID); | 434 | InventoryItemBase item = CreateItemForObject(action, remoteClient, objlist[0], folderID); |
431 | 435 | ||
@@ -435,17 +439,28 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
435 | 439 | ||
436 | if (item == null) | 440 | if (item == null) |
437 | return null; | 441 | return null; |
442 | |||
443 | item.CreatorId = objlist[0].RootPart.CreatorID.ToString(); | ||
444 | item.CreatorData = objlist[0].RootPart.CreatorData; | ||
438 | 445 | ||
439 | // Can't know creator is the same, so null it in inventory | ||
440 | if (objlist.Count > 1) | 446 | if (objlist.Count > 1) |
441 | { | 447 | { |
442 | item.CreatorId = UUID.Zero.ToString(); | ||
443 | item.Flags = (uint)InventoryItemFlags.ObjectHasMultipleItems; | 448 | item.Flags = (uint)InventoryItemFlags.ObjectHasMultipleItems; |
449 | |||
450 | // If the objects have different creators then don't specify a creator at all | ||
451 | foreach (SceneObjectGroup objectGroup in objlist) | ||
452 | { | ||
453 | if ((objectGroup.RootPart.CreatorID.ToString() != item.CreatorId) | ||
454 | || (objectGroup.RootPart.CreatorData.ToString() != item.CreatorData)) | ||
455 | { | ||
456 | item.CreatorId = UUID.Zero.ToString(); | ||
457 | item.CreatorData = string.Empty; | ||
458 | break; | ||
459 | } | ||
460 | } | ||
444 | } | 461 | } |
445 | else | 462 | else |
446 | { | 463 | { |
447 | item.CreatorId = objlist[0].RootPart.CreatorID.ToString(); | ||
448 | item.CreatorData = objlist[0].RootPart.CreatorData; | ||
449 | item.SaleType = objlist[0].RootPart.ObjectSaleType; | 464 | item.SaleType = objlist[0].RootPart.ObjectSaleType; |
450 | item.SalePrice = objlist[0].RootPart.SalePrice; | 465 | item.SalePrice = objlist[0].RootPart.SalePrice; |
451 | } | 466 | } |
@@ -466,13 +481,13 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
466 | } | 481 | } |
467 | else | 482 | else |
468 | { | 483 | { |
469 | AddPermissions(item, objlist[0], objlist, remoteClient); | ||
470 | |||
471 | item.CreationDate = Util.UnixTimeSinceEpoch(); | 484 | item.CreationDate = Util.UnixTimeSinceEpoch(); |
472 | item.Description = asset.Description; | 485 | item.Description = asset.Description; |
473 | item.Name = asset.Name; | 486 | item.Name = asset.Name; |
474 | item.AssetType = asset.Type; | 487 | item.AssetType = asset.Type; |
475 | 488 | ||
489 | AddPermissions(item, objlist[0], objlist, remoteClient); | ||
490 | |||
476 | m_Scene.AddInventoryItem(item); | 491 | m_Scene.AddInventoryItem(item); |
477 | 492 | ||
478 | if (remoteClient != null && item.Owner == remoteClient.AgentId) | 493 | if (remoteClient != null && item.Owner == remoteClient.AgentId) |
@@ -527,16 +542,12 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
527 | } | 542 | } |
528 | effectivePerms |= (uint)PermissionMask.Move; | 543 | effectivePerms |= (uint)PermissionMask.Move; |
529 | 544 | ||
545 | //PermissionsUtil.LogPermissions(item.Name, "Before AddPermissions", item.BasePermissions, item.CurrentPermissions, item.NextPermissions); | ||
546 | |||
530 | if (remoteClient != null && (remoteClient.AgentId != so.RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions()) | 547 | if (remoteClient != null && (remoteClient.AgentId != so.RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions()) |
531 | { | 548 | { |
532 | uint perms = effectivePerms; | 549 | uint perms = effectivePerms; |
533 | uint nextPerms = (perms & 7) << 13; | 550 | PermissionsUtil.ApplyFoldedPermissions(effectivePerms, ref perms); |
534 | if ((nextPerms & (uint)PermissionMask.Copy) == 0) | ||
535 | perms &= ~(uint)PermissionMask.Copy; | ||
536 | if ((nextPerms & (uint)PermissionMask.Transfer) == 0) | ||
537 | perms &= ~(uint)PermissionMask.Transfer; | ||
538 | if ((nextPerms & (uint)PermissionMask.Modify) == 0) | ||
539 | perms &= ~(uint)PermissionMask.Modify; | ||
540 | 551 | ||
541 | item.BasePermissions = perms & so.RootPart.NextOwnerMask; | 552 | item.BasePermissions = perms & so.RootPart.NextOwnerMask; |
542 | item.CurrentPermissions = item.BasePermissions; | 553 | item.CurrentPermissions = item.BasePermissions; |
@@ -544,10 +555,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
544 | item.EveryOnePermissions = so.RootPart.EveryoneMask & so.RootPart.NextOwnerMask; | 555 | item.EveryOnePermissions = so.RootPart.EveryoneMask & so.RootPart.NextOwnerMask; |
545 | item.GroupPermissions = so.RootPart.GroupMask & so.RootPart.NextOwnerMask; | 556 | item.GroupPermissions = so.RootPart.GroupMask & so.RootPart.NextOwnerMask; |
546 | 557 | ||
547 | // Magic number badness. Maybe this deserves an enum. | 558 | // apply next owner perms on rez |
548 | // bit 4 (16) is the "Slam" bit, it means treat as passed | 559 | item.CurrentPermissions |= SceneObjectGroup.SLAM; |
549 | // and apply next owner perms on rez | ||
550 | item.CurrentPermissions |= 16; // Slam! | ||
551 | } | 560 | } |
552 | else | 561 | else |
553 | { | 562 | { |
@@ -564,8 +573,10 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
564 | (uint)PermissionMask.Move | | 573 | (uint)PermissionMask.Move | |
565 | (uint)PermissionMask.Export | | 574 | (uint)PermissionMask.Export | |
566 | 7); // Preserve folded permissions | 575 | 7); // Preserve folded permissions |
567 | } | 576 | } |
568 | 577 | ||
578 | //PermissionsUtil.LogPermissions(item.Name, "After AddPermissions", item.BasePermissions, item.CurrentPermissions, item.NextPermissions); | ||
579 | |||
569 | return item; | 580 | return item; |
570 | } | 581 | } |
571 | 582 | ||
@@ -707,6 +718,12 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
707 | InventoryFolderBase f = new InventoryFolderBase(so.FromFolderID, userID); | 718 | InventoryFolderBase f = new InventoryFolderBase(so.FromFolderID, userID); |
708 | if (f != null) | 719 | if (f != null) |
709 | folder = m_Scene.InventoryService.GetFolder(f); | 720 | folder = m_Scene.InventoryService.GetFolder(f); |
721 | |||
722 | if(folder.Type == 14 || folder.Type == 16) | ||
723 | { | ||
724 | // folder.Type = 6; | ||
725 | folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.Object); | ||
726 | } | ||
710 | } | 727 | } |
711 | } | 728 | } |
712 | 729 | ||
@@ -779,83 +796,29 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
779 | 796 | ||
780 | SceneObjectGroup group = null; | 797 | SceneObjectGroup group = null; |
781 | 798 | ||
782 | string xmlData = Utils.BytesToString(rezAsset.Data); | 799 | List<SceneObjectGroup> objlist; |
783 | List<SceneObjectGroup> objlist = new List<SceneObjectGroup>(); | 800 | List<Vector3> veclist; |
784 | List<Vector3> veclist = new List<Vector3>(); | 801 | Vector3 bbox; |
802 | float offsetHeight; | ||
785 | byte bRayEndIsIntersection = (byte)(RayEndIsIntersection ? 1 : 0); | 803 | byte bRayEndIsIntersection = (byte)(RayEndIsIntersection ? 1 : 0); |
786 | Vector3 pos; | 804 | Vector3 pos; |
787 | 805 | ||
788 | XmlDocument doc = new XmlDocument(); | 806 | bool single = m_Scene.GetObjectsToRez(rezAsset.Data, attachment, out objlist, out veclist, out bbox, out offsetHeight); |
789 | doc.LoadXml(xmlData); | ||
790 | XmlElement e = (XmlElement)doc.SelectSingleNode("/CoalescedObject"); | ||
791 | Vector3 rez_pos; | ||
792 | if (e == null || attachment) // Single | ||
793 | { | ||
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 | if (g.RootPart.Shape.PCode != (byte)PCode.NewTree && | ||
801 | g.RootPart.Shape.PCode != (byte)PCode.Tree) | ||
802 | g.RootPart.Shape.State = 0; | ||
803 | } | ||
804 | 807 | ||
805 | objlist.Add(g); | 808 | if (single) |
806 | veclist.Add(new Vector3(0, 0, 0)); | 809 | { |
807 | |||
808 | float offsetHeight = 0; | ||
809 | pos = m_Scene.GetNewRezLocation( | 810 | pos = m_Scene.GetNewRezLocation( |
810 | RayStart, RayEnd, RayTargetID, Quaternion.Identity, | 811 | RayStart, RayEnd, RayTargetID, Quaternion.Identity, |
811 | BypassRayCast, bRayEndIsIntersection, true, g.GetAxisAlignedBoundingBox(out offsetHeight), false); | 812 | BypassRayCast, bRayEndIsIntersection, true, bbox, false); |
812 | pos.Z += offsetHeight; | 813 | pos.Z += offsetHeight; |
813 | rez_pos = pos; | ||
814 | } | 814 | } |
815 | else | 815 | else |
816 | { | 816 | { |
817 | XmlElement coll = (XmlElement)e; | ||
818 | float bx = Convert.ToSingle(coll.GetAttribute("x")); | ||
819 | float by = Convert.ToSingle(coll.GetAttribute("y")); | ||
820 | float bz = Convert.ToSingle(coll.GetAttribute("z")); | ||
821 | Vector3 bbox = new Vector3(bx, by, bz); | ||
822 | |||
823 | pos = m_Scene.GetNewRezLocation(RayStart, RayEnd, | 817 | pos = m_Scene.GetNewRezLocation(RayStart, RayEnd, |
824 | RayTargetID, Quaternion.Identity, | 818 | RayTargetID, Quaternion.Identity, |
825 | BypassRayCast, bRayEndIsIntersection, true, | 819 | BypassRayCast, bRayEndIsIntersection, true, |
826 | bbox, false); | 820 | bbox, false); |
827 | |||
828 | rez_pos = pos; | ||
829 | |||
830 | pos -= bbox / 2; | 821 | pos -= bbox / 2; |
831 | |||
832 | XmlNodeList groups = e.SelectNodes("SceneObjectGroup"); | ||
833 | foreach (XmlNode n in groups) | ||
834 | { | ||
835 | SceneObjectGroup g = SceneObjectSerializer.FromOriginalXmlFormat(n.OuterXml); | ||
836 | g.RootPart.AttachPoint = g.RootPart.Shape.State; | ||
837 | g.RootPart.AttachOffset = g.AbsolutePosition; | ||
838 | g.RootPart.AttachRotation = g.GroupRotation; | ||
839 | if (g.RootPart.Shape.PCode != (byte)PCode.NewTree && | ||
840 | g.RootPart.Shape.PCode != (byte)PCode.Tree) | ||
841 | g.RootPart.Shape.State = 0; | ||
842 | |||
843 | objlist.Add(g); | ||
844 | XmlElement el = (XmlElement)n; | ||
845 | |||
846 | string rawX = el.GetAttribute("offsetx"); | ||
847 | string rawY = el.GetAttribute("offsety"); | ||
848 | string rawZ = el.GetAttribute("offsetz"); | ||
849 | // | ||
850 | // m_log.DebugFormat( | ||
851 | // "[INVENTORY ACCESS MODULE]: Converting coalesced object {0} offset <{1}, {2}, {3}>", | ||
852 | // g.Name, rawX, rawY, rawZ); | ||
853 | |||
854 | float x = Convert.ToSingle(rawX); | ||
855 | float y = Convert.ToSingle(rawY); | ||
856 | float z = Convert.ToSingle(rawZ); | ||
857 | veclist.Add(new Vector3(x, y, z)); | ||
858 | } | ||
859 | } | 822 | } |
860 | 823 | ||
861 | int primcount = 0; | 824 | int primcount = 0; |
@@ -863,7 +826,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
863 | primcount += g.PrimCount; | 826 | primcount += g.PrimCount; |
864 | 827 | ||
865 | if (!m_Scene.Permissions.CanRezObject( | 828 | if (!m_Scene.Permissions.CanRezObject( |
866 | primcount, remoteClient.AgentId, rez_pos) | 829 | primcount, remoteClient.AgentId, pos) |
867 | && !attachment) | 830 | && !attachment) |
868 | { | 831 | { |
869 | // The client operates in no fail mode. It will | 832 | // The client operates in no fail mode. It will |
@@ -880,7 +843,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
880 | return null; | 843 | return null; |
881 | } | 844 | } |
882 | 845 | ||
883 | if (item != null && !DoPreRezWhenFromItem(remoteClient, item, objlist, rez_pos, attachment)) | 846 | if (item != null && !DoPreRezWhenFromItem(remoteClient, item, objlist, pos, veclist, attachment)) |
884 | return null; | 847 | return null; |
885 | 848 | ||
886 | for (int i = 0; i < objlist.Count; i++) | 849 | for (int i = 0; i < objlist.Count; i++) |
@@ -900,11 +863,23 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
900 | m_log.Debug("[INVENTORY ACCESS MODULE]: Object has UUID.Zero! Position 3"); | 863 | m_log.Debug("[INVENTORY ACCESS MODULE]: Object has UUID.Zero! Position 3"); |
901 | } | 864 | } |
902 | 865 | ||
903 | foreach (SceneObjectPart part in group.Parts) | 866 | // if this was previously an attachment and is now being rezzed, |
867 | // save the old attachment info. | ||
868 | if (group.IsAttachment == false && group.RootPart.Shape.State != 0) | ||
904 | { | 869 | { |
905 | // Make the rezzer the owner, as this is not necessarily set correctly in the serialized asset. | 870 | group.RootPart.AttachedPos = group.AbsolutePosition; |
906 | part.LastOwnerID = part.OwnerID; | 871 | group.RootPart.Shape.LastAttachPoint = (byte)group.AttachmentPoint; |
907 | part.OwnerID = remoteClient.AgentId; | 872 | } |
873 | |||
874 | if (item == null) | ||
875 | { | ||
876 | // Change ownership. Normally this is done in DoPreRezWhenFromItem(), but in this case we must do it here. | ||
877 | foreach (SceneObjectPart part in group.Parts) | ||
878 | { | ||
879 | // Make the rezzer the owner, as this is not necessarily set correctly in the serialized asset. | ||
880 | part.LastOwnerID = part.OwnerID; | ||
881 | part.OwnerID = remoteClient.AgentId; | ||
882 | } | ||
908 | } | 883 | } |
909 | 884 | ||
910 | if (!attachment) | 885 | if (!attachment) |
@@ -979,10 +954,15 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
979 | /// <param name="item"></param> | 954 | /// <param name="item"></param> |
980 | /// <param name="objlist"></param> | 955 | /// <param name="objlist"></param> |
981 | /// <param name="pos"></param> | 956 | /// <param name="pos"></param> |
957 | /// <param name="veclist"> | ||
958 | /// List of vector position adjustments for a coalesced objects. For ordinary objects | ||
959 | /// this list will contain just Vector3.Zero. The order of adjustments must match the order of objlist | ||
960 | /// </param> | ||
982 | /// <param name="isAttachment"></param> | 961 | /// <param name="isAttachment"></param> |
983 | /// <returns>true if we can processed with rezzing, false if we need to abort</returns> | 962 | /// <returns>true if we can processed with rezzing, false if we need to abort</returns> |
984 | private bool DoPreRezWhenFromItem( | 963 | private bool DoPreRezWhenFromItem( |
985 | IClientAPI remoteClient, InventoryItemBase item, List<SceneObjectGroup> objlist, Vector3 pos, bool isAttachment) | 964 | IClientAPI remoteClient, InventoryItemBase item, List<SceneObjectGroup> objlist, |
965 | Vector3 pos, List<Vector3> veclist, bool isAttachment) | ||
986 | { | 966 | { |
987 | UUID fromUserInventoryItemId = UUID.Zero; | 967 | UUID fromUserInventoryItemId = UUID.Zero; |
988 | 968 | ||
@@ -1005,28 +985,29 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
1005 | } | 985 | } |
1006 | } | 986 | } |
1007 | 987 | ||
1008 | int primcount = 0; | 988 | for (int i = 0; i < objlist.Count; i++) |
1009 | foreach (SceneObjectGroup g in objlist) | ||
1010 | primcount += g.PrimCount; | ||
1011 | |||
1012 | if (!m_Scene.Permissions.CanRezObject( | ||
1013 | primcount, remoteClient.AgentId, pos) | ||
1014 | && !isAttachment) | ||
1015 | { | 989 | { |
1016 | // The client operates in no fail mode. It will | 990 | SceneObjectGroup g = objlist[i]; |
1017 | // have already removed the item from the folder | ||
1018 | // if it's no copy. | ||
1019 | // Put it back if it's not an attachment | ||
1020 | // | ||
1021 | if (((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) && (!isAttachment)) | ||
1022 | remoteClient.SendBulkUpdateInventory(item); | ||
1023 | 991 | ||
1024 | ILandObject land = m_Scene.LandChannel.GetLandObject(pos.X, pos.Y); | 992 | if (!m_Scene.Permissions.CanRezObject( |
1025 | remoteClient.SendAlertMessage(string.Format( | 993 | g.PrimCount, remoteClient.AgentId, pos + veclist[i]) |
1026 | "Can't rez object '{0}' at <{1:F3}, {2:F3}, {3:F3}> on parcel '{4}' in region {5}.", | 994 | && !isAttachment) |
1027 | item.Name, pos.X, pos.Y, pos.Z, land != null ? land.LandData.Name : "Unknown", m_Scene.RegionInfo.RegionName)); | 995 | { |
996 | // The client operates in no fail mode. It will | ||
997 | // have already removed the item from the folder | ||
998 | // if it's no copy. | ||
999 | // Put it back if it's not an attachment | ||
1000 | // | ||
1001 | if (((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) && (!isAttachment)) | ||
1002 | remoteClient.SendBulkUpdateInventory(item); | ||
1028 | 1003 | ||
1029 | return false; | 1004 | ILandObject land = m_Scene.LandChannel.GetLandObject(pos.X, pos.Y); |
1005 | remoteClient.SendAlertMessage(string.Format( | ||
1006 | "Can't rez object '{0}' at <{1:F3}, {2:F3}, {3:F3}> on parcel '{4}' in region {5}.", | ||
1007 | item.Name, pos.X, pos.Y, pos.Z, land != null ? land.LandData.Name : "Unknown", m_Scene.Name)); | ||
1008 | |||
1009 | return false; | ||
1010 | } | ||
1030 | } | 1011 | } |
1031 | 1012 | ||
1032 | for (int i = 0; i < objlist.Count; i++) | 1013 | for (int i = 0; i < objlist.Count; i++) |
@@ -1107,7 +1088,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
1107 | part.GroupMask = item.GroupPermissions; | 1088 | part.GroupMask = item.GroupPermissions; |
1108 | } | 1089 | } |
1109 | } | 1090 | } |
1110 | 1091 | ||
1111 | rootPart.TrimPermissions(); | 1092 | rootPart.TrimPermissions(); |
1112 | 1093 | ||
1113 | if (isAttachment) | 1094 | if (isAttachment) |