diff options
author | onefang | 2019-05-19 21:24:15 +1000 |
---|---|---|
committer | onefang | 2019-05-19 21:24:15 +1000 |
commit | 5e4d6cab00cb29cd088ab7b62ab13aff103b64cb (patch) | |
tree | a9fbc62df9eb2d1d9ba2698d8552eae71eca20d8 /OpenSim/Region/CoreModules/Framework/InventoryAccess | |
parent | Add a build script. (diff) | |
download | opensim-SC_OLD-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.zip opensim-SC_OLD-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.tar.gz opensim-SC_OLD-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.tar.bz2 opensim-SC_OLD-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.tar.xz |
Dump OpenSim 0.9.0.1 into it's own branch.
Diffstat (limited to 'OpenSim/Region/CoreModules/Framework/InventoryAccess')
5 files changed, 445 insertions, 279 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs index f54298c..51ae217 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs | |||
@@ -178,7 +178,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
178 | { | 178 | { |
179 | UUID uuid = UUID.Zero; | 179 | UUID uuid = UUID.Zero; |
180 | UUID.TryParse(meta.CreatorID, out uuid); | 180 | UUID.TryParse(meta.CreatorID, out uuid); |
181 | UserAccount creator = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, uuid); | 181 | UserAccount creator = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, uuid); |
182 | if (creator != null) | 182 | if (creator != null) |
183 | meta.CreatorID = m_HomeURI + ";" + creator.FirstName + " " + creator.LastName; | 183 | meta.CreatorID = m_HomeURI + ";" + creator.FirstName + " " + creator.LastName; |
184 | } | 184 | } |
@@ -300,8 +300,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
300 | { | 300 | { |
301 | m_log.Error( | 301 | m_log.Error( |
302 | string.Format( | 302 | string.Format( |
303 | "[HG ASSET MAPPER]: Failed to post asset {0} (type {1}, length {2}) referenced from {3} to {4} with exception ", | 303 | "[HG ASSET MAPPER]: Failed to post asset {0} (type {1}, length {2}) referenced from {3} to {4} with exception ", |
304 | asset.ID, asset.Type, asset.Data.Length, assetID, userAssetURL), | 304 | asset.ID, asset.Type, asset.Data.Length, assetID, userAssetURL), |
305 | e); | 305 | e); |
306 | 306 | ||
307 | // For debugging purposes for now we will continue to throw the exception up the stack as was already happening. However, after | 307 | // For debugging purposes for now we will continue to throw the exception up the stack as was already happening. However, after |
@@ -315,7 +315,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
315 | else | 315 | else |
316 | { | 316 | { |
317 | m_log.DebugFormat( | 317 | m_log.DebugFormat( |
318 | "[HG ASSET MAPPER]: Didn't post asset {0} referenced from {1} because it already exists in asset server {2}", | 318 | "[HG ASSET MAPPER]: Didn't post asset {0} referenced from {1} because it already exists in asset server {2}", |
319 | uuid, assetID, userAssetURL); | 319 | uuid, assetID, userAssetURL); |
320 | } | 320 | } |
321 | } | 321 | } |
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs index 582b267..ba3a7c9 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs | |||
@@ -91,9 +91,9 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
91 | if (name == Name) | 91 | if (name == Name) |
92 | { | 92 | { |
93 | m_Enabled = true; | 93 | m_Enabled = true; |
94 | 94 | ||
95 | InitialiseCommon(source); | 95 | InitialiseCommon(source); |
96 | 96 | ||
97 | m_log.InfoFormat("[HG INVENTORY ACCESS MODULE]: {0} enabled.", Name); | 97 | m_log.InfoFormat("[HG INVENTORY ACCESS MODULE]: {0} enabled.", Name); |
98 | 98 | ||
99 | IConfig thisModuleConfig = source.Configs["HGInventoryAccessModule"]; | 99 | IConfig thisModuleConfig = source.Configs["HGInventoryAccessModule"]; |
@@ -117,7 +117,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
117 | m_log.Warn("[HG INVENTORY ACCESS MODULE]: HGInventoryAccessModule configs not found. ProfileServerURI not set!"); | 117 | m_log.Warn("[HG INVENTORY ACCESS MODULE]: HGInventoryAccessModule configs not found. ProfileServerURI not set!"); |
118 | 118 | ||
119 | m_bypassPermissions = !Util.GetConfigVarFromSections<bool>(source, "serverside_object_permissions", | 119 | m_bypassPermissions = !Util.GetConfigVarFromSections<bool>(source, "serverside_object_permissions", |
120 | new string[] { "Startup", "Permissions" }, true); | 120 | new string[] { "Startup", "Permissions" }, true); |
121 | 121 | ||
122 | } | 122 | } |
123 | } | 123 | } |
@@ -209,7 +209,14 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
209 | } | 209 | } |
210 | } | 210 | } |
211 | 211 | ||
212 | public void PostInventoryAsset(UUID avatarID, AssetType type, UUID assetID, string name, int userlevel) | 212 | private void PostInventoryAsset(InventoryItemBase item, int userlevel) |
213 | { | ||
214 | InventoryFolderBase f = m_Scene.InventoryService.GetFolderForType(item.Owner, FolderType.Trash); | ||
215 | if (f == null || (f != null && item.Folder != f.ID)) | ||
216 | PostInventoryAsset(item.Owner, (AssetType)item.AssetType, item.AssetID, item.Name, userlevel); | ||
217 | } | ||
218 | |||
219 | private void PostInventoryAsset(UUID avatarID, AssetType type, UUID assetID, string name, int userlevel) | ||
213 | { | 220 | { |
214 | if (type == AssetType.Link) | 221 | if (type == AssetType.Link) |
215 | return; | 222 | return; |
@@ -241,26 +248,34 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
241 | } | 248 | } |
242 | 249 | ||
243 | 250 | ||
244 | /// | 251 | /// |
245 | /// CapsUpdateInventoryItemAsset | 252 | /// CapsUpdateInventoryItemAsset |
246 | /// | 253 | /// |
247 | public override UUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, UUID itemID, byte[] data) | 254 | public override UUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, UUID itemID, byte[] data) |
248 | { | 255 | { |
249 | UUID newAssetID = base.CapsUpdateInventoryItemAsset(remoteClient, itemID, data); | 256 | UUID newAssetID = base.CapsUpdateInventoryItemAsset(remoteClient, itemID, data); |
250 | 257 | ||
251 | PostInventoryAsset(remoteClient.AgentId, AssetType.Unknown, newAssetID, "", 0); | 258 | // We need to construct this here to satisfy the calling convention. |
259 | // Better this in two places than five formal params in all others. | ||
260 | InventoryItemBase item = new InventoryItemBase(); | ||
261 | item.Owner = remoteClient.AgentId; | ||
262 | item.AssetType = (int)AssetType.Unknown; | ||
263 | item.AssetID = newAssetID; | ||
264 | item.Name = String.Empty; | ||
265 | |||
266 | PostInventoryAsset(item, 0); | ||
252 | 267 | ||
253 | return newAssetID; | 268 | return newAssetID; |
254 | } | 269 | } |
255 | 270 | ||
256 | /// | 271 | /// |
257 | /// UpdateInventoryItemAsset | 272 | /// UpdateInventoryItemAsset |
258 | /// | 273 | /// |
259 | public override bool UpdateInventoryItemAsset(UUID ownerID, InventoryItemBase item, AssetBase asset) | 274 | public override bool UpdateInventoryItemAsset(UUID ownerID, InventoryItemBase item, AssetBase asset) |
260 | { | 275 | { |
261 | if (base.UpdateInventoryItemAsset(ownerID, item, asset)) | 276 | if (base.UpdateInventoryItemAsset(ownerID, item, asset)) |
262 | { | 277 | { |
263 | PostInventoryAsset(ownerID, (AssetType)asset.Type, asset.FullID, asset.Name, 0); | 278 | PostInventoryAsset(item, 0); |
264 | return true; | 279 | return true; |
265 | } | 280 | } |
266 | 281 | ||
@@ -273,25 +288,45 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
273 | protected override void ExportAsset(UUID agentID, UUID assetID) | 288 | protected override void ExportAsset(UUID agentID, UUID assetID) |
274 | { | 289 | { |
275 | if (!assetID.Equals(UUID.Zero)) | 290 | if (!assetID.Equals(UUID.Zero)) |
276 | PostInventoryAsset(agentID, AssetType.Unknown, assetID, "", 0); | 291 | { |
292 | InventoryItemBase item = new InventoryItemBase(); | ||
293 | item.Owner = agentID; | ||
294 | item.AssetType = (int)AssetType.Unknown; | ||
295 | item.AssetID = assetID; | ||
296 | item.Name = String.Empty; | ||
297 | |||
298 | PostInventoryAsset(item, 0); | ||
299 | } | ||
277 | else | 300 | else |
301 | { | ||
278 | m_log.Debug("[HGScene]: Scene.Inventory did not create asset"); | 302 | m_log.Debug("[HGScene]: Scene.Inventory did not create asset"); |
303 | } | ||
279 | } | 304 | } |
280 | 305 | ||
281 | /// | 306 | /// |
282 | /// RezObject | 307 | /// RezObject |
283 | /// | 308 | /// |
284 | public override SceneObjectGroup RezObject(IClientAPI remoteClient, UUID itemID, Vector3 RayEnd, Vector3 RayStart, | 309 | // compatibility do not use |
285 | UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, | 310 | public override SceneObjectGroup RezObject( |
286 | bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment) | 311 | IClientAPI remoteClient, UUID itemID, Vector3 RayEnd, Vector3 RayStart, |
312 | UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, | ||
313 | bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment) | ||
314 | { | ||
315 | return RezObject(remoteClient, itemID, UUID.Zero, RayEnd, RayStart, | ||
316 | RayTargetID, BypassRayCast, RayEndIsIntersection, | ||
317 | RezSelected, RemoveItem, fromTaskID, attachment); | ||
318 | } | ||
319 | |||
320 | public override SceneObjectGroup RezObject(IClientAPI remoteClient, UUID itemID, | ||
321 | UUID groupID, Vector3 RayEnd, Vector3 RayStart, | ||
322 | UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, | ||
323 | bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment) | ||
287 | { | 324 | { |
288 | m_log.DebugFormat("[HGScene]: RezObject itemID={0} fromTaskID={1}", itemID, fromTaskID); | 325 | //m_log.DebugFormat("[HGScene]: RezObject itemID={0} fromTaskID={1}", itemID, fromTaskID); |
289 | 326 | ||
290 | //if (fromTaskID.Equals(UUID.Zero)) | 327 | //if (fromTaskID.Equals(UUID.Zero)) |
291 | //{ | 328 | //{ |
292 | InventoryItemBase item = new InventoryItemBase(itemID); | 329 | InventoryItemBase item = m_Scene.InventoryService.GetItem(remoteClient.AgentId, itemID); |
293 | item.Owner = remoteClient.AgentId; | ||
294 | item = m_Scene.InventoryService.GetItem(item); | ||
295 | //if (item == null) | 330 | //if (item == null) |
296 | //{ // Fetch the item | 331 | //{ // Fetch the item |
297 | // item = new InventoryItemBase(); | 332 | // item = new InventoryItemBase(); |
@@ -308,7 +343,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
308 | //} | 343 | //} |
309 | 344 | ||
310 | // OK, we're done fetching. Pass it up to the default RezObject | 345 | // OK, we're done fetching. Pass it up to the default RezObject |
311 | SceneObjectGroup sog = base.RezObject(remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection, | 346 | SceneObjectGroup sog = base.RezObject(remoteClient, itemID, groupID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection, |
312 | RezSelected, RemoveItem, fromTaskID, attachment); | 347 | RezSelected, RemoveItem, fromTaskID, attachment); |
313 | 348 | ||
314 | return sog; | 349 | return sog; |
@@ -351,7 +386,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
351 | if (!m_CheckSeparateAssets) | 386 | if (!m_CheckSeparateAssets) |
352 | { | 387 | { |
353 | if (!UserManagementModule.IsLocalGridUser(userID)) | 388 | if (!UserManagementModule.IsLocalGridUser(userID)) |
354 | { // foreign | 389 | { // foreign |
355 | ScenePresence sp = null; | 390 | ScenePresence sp = null; |
356 | if (m_Scene.TryGetScenePresence(userID, out sp)) | 391 | if (m_Scene.TryGetScenePresence(userID, out sp)) |
357 | { | 392 | { |
@@ -489,7 +524,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
489 | foreach (InventoryItemBase it in content.Items) | 524 | foreach (InventoryItemBase it in content.Items) |
490 | it.Name = it.Name + " (Unavailable)"; ; | 525 | it.Name = it.Name + " (Unavailable)"; ; |
491 | 526 | ||
492 | // Send the new names | 527 | // Send the new names |
493 | inv.SendBulkUpdateInventory(keep.ToArray(), content.Items.ToArray()); | 528 | inv.SendBulkUpdateInventory(keep.ToArray(), content.Items.ToArray()); |
494 | 529 | ||
495 | } | 530 | } |
@@ -506,16 +541,17 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
506 | 541 | ||
507 | #region Permissions | 542 | #region Permissions |
508 | 543 | ||
509 | private bool CanTakeObject(UUID objectID, UUID stealer, Scene scene) | 544 | private bool CanTakeObject(SceneObjectGroup sog, ScenePresence sp) |
510 | { | 545 | { |
511 | if (m_bypassPermissions) return true; | 546 | if (m_bypassPermissions) return true; |
512 | 547 | ||
513 | if (!m_OutboundPermission && !UserManagementModule.IsLocalGridUser(stealer)) | 548 | if(sp == null || sog == null) |
549 | return false; | ||
550 | |||
551 | if (!m_OutboundPermission && !UserManagementModule.IsLocalGridUser(sp.UUID)) | ||
514 | { | 552 | { |
515 | SceneObjectGroup sog = null; | 553 | if (sog.OwnerID == sp.UUID) |
516 | if (m_Scene.TryGetSceneObjectGroup(objectID, out sog) && sog.OwnerID == stealer) | ||
517 | return true; | 554 | return true; |
518 | |||
519 | return false; | 555 | return false; |
520 | } | 556 | } |
521 | 557 | ||
@@ -535,4 +571,4 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
535 | 571 | ||
536 | #endregion | 572 | #endregion |
537 | } | 573 | } |
538 | } \ No newline at end of file | 574 | } |
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 | ||
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/HGAssetMapperTests.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/HGAssetMapperTests.cs index 007ff63..01c5d3b 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/HGAssetMapperTests.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/HGAssetMapperTests.cs | |||
@@ -77,7 +77,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess.Tests | |||
77 | scene.StartScripts(); | 77 | scene.StartScripts(); |
78 | 78 | ||
79 | HGAssetMapper hgam = new HGAssetMapper(scene, homeUrl); | 79 | HGAssetMapper hgam = new HGAssetMapper(scene, homeUrl); |
80 | UserAccount ua | 80 | UserAccount ua |
81 | = UserAccountHelpers.CreateUserWithInventory(scene, userFirstName, userLastName, userId, "password"); | 81 | = UserAccountHelpers.CreateUserWithInventory(scene, userFirstName, userLastName, userId, "password"); |
82 | 82 | ||
83 | SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, soPartsCount, ua.PrincipalID, "part", soIdTail); | 83 | SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, soPartsCount, ua.PrincipalID, "part", soIdTail); |
@@ -93,6 +93,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess.Tests | |||
93 | Assert.AreEqual(foreignUrl, ncAssetGet.CreatorID); | 93 | Assert.AreEqual(foreignUrl, ncAssetGet.CreatorID); |
94 | string xmlData = Utils.BytesToString(ncAssetGet.Data); | 94 | string xmlData = Utils.BytesToString(ncAssetGet.Data); |
95 | XmlDocument ncAssetGetXmlDoc = new XmlDocument(); | 95 | XmlDocument ncAssetGetXmlDoc = new XmlDocument(); |
96 | ncAssetGetXmlDoc.XmlResolver=null; | ||
96 | ncAssetGetXmlDoc.LoadXml(xmlData); | 97 | ncAssetGetXmlDoc.LoadXml(xmlData); |
97 | 98 | ||
98 | // Console.WriteLine(ncAssetGetXmlDoc.OuterXml); | 99 | // Console.WriteLine(ncAssetGetXmlDoc.OuterXml); |
@@ -116,7 +117,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess.Tests | |||
116 | XmlNode uuidAttribute = savedScriptStateNodes[0].Attributes.GetNamedItem("UUID"); | 117 | XmlNode uuidAttribute = savedScriptStateNodes[0].Attributes.GetNamedItem("UUID"); |
117 | Assert.NotNull(uuidAttribute); | 118 | Assert.NotNull(uuidAttribute); |
118 | // XXX: To check the actual UUID attribute we would have to do some work to retreive the UUID of the task | 119 | // XXX: To check the actual UUID attribute we would have to do some work to retreive the UUID of the task |
119 | // item created earlier. | 120 | // item created earlier. |
120 | } | 121 | } |
121 | 122 | ||
122 | private void RezScript(Scene scene, UUID soId, string script, string itemName, UUID userId) | 123 | private void RezScript(Scene scene, UUID soId, string script, string itemName, UUID userId) |
@@ -131,9 +132,9 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess.Tests | |||
131 | // immediately for tests rather than chunter through it's threaded mechanisms. | 132 | // immediately for tests rather than chunter through it's threaded mechanisms. |
132 | AutoResetEvent chatEvent = new AutoResetEvent(false); | 133 | AutoResetEvent chatEvent = new AutoResetEvent(false); |
133 | 134 | ||
134 | scene.EventManager.OnChatFromWorld += (s, c) => | 135 | scene.EventManager.OnChatFromWorld += (s, c) => |
135 | { | 136 | { |
136 | // Console.WriteLine("Got chat [{0}]", c.Message); | 137 | // Console.WriteLine("Got chat [{0}]", c.Message); |
137 | chatEvent.Set(); | 138 | chatEvent.Set(); |
138 | }; | 139 | }; |
139 | 140 | ||
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs index 1d91165..de29ae9 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs | |||
@@ -48,12 +48,12 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess.Tests | |||
48 | { | 48 | { |
49 | [TestFixture] | 49 | [TestFixture] |
50 | public class InventoryAccessModuleTests : OpenSimTestCase | 50 | public class InventoryAccessModuleTests : OpenSimTestCase |
51 | { | 51 | { |
52 | protected TestScene m_scene; | 52 | protected TestScene m_scene; |
53 | protected BasicInventoryAccessModule m_iam; | 53 | protected BasicInventoryAccessModule m_iam; |
54 | protected UUID m_userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); | 54 | protected UUID m_userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); |
55 | protected TestClient m_tc; | 55 | protected TestClient m_tc; |
56 | 56 | ||
57 | [SetUp] | 57 | [SetUp] |
58 | public override void SetUp() | 58 | public override void SetUp() |
59 | { | 59 | { |
@@ -68,31 +68,32 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess.Tests | |||
68 | SceneHelpers sceneHelpers = new SceneHelpers(); | 68 | SceneHelpers sceneHelpers = new SceneHelpers(); |
69 | m_scene = sceneHelpers.SetupScene(); | 69 | m_scene = sceneHelpers.SetupScene(); |
70 | SceneHelpers.SetupSceneModules(m_scene, config, m_iam); | 70 | SceneHelpers.SetupSceneModules(m_scene, config, m_iam); |
71 | 71 | ||
72 | // Create user | 72 | // Create user |
73 | string userFirstName = "Jock"; | 73 | string userFirstName = "Jock"; |
74 | string userLastName = "Stirrup"; | 74 | string userLastName = "Stirrup"; |
75 | string userPassword = "troll"; | 75 | string userPassword = "troll"; |
76 | UserAccountHelpers.CreateUserWithInventory(m_scene, userFirstName, userLastName, m_userId, userPassword); | 76 | UserAccountHelpers.CreateUserWithInventory(m_scene, userFirstName, userLastName, m_userId, userPassword); |
77 | 77 | ||
78 | AgentCircuitData acd = new AgentCircuitData(); | 78 | AgentCircuitData acd = new AgentCircuitData(); |
79 | acd.AgentID = m_userId; | 79 | acd.AgentID = m_userId; |
80 | m_tc = new TestClient(acd, m_scene); | 80 | m_tc = new TestClient(acd, m_scene); |
81 | } | 81 | } |
82 | 82 | ||
83 | [Test] | 83 | [Test] |
84 | public void TestRezCoalescedObject() | 84 | public void TestRezCoalescedObject() |
85 | { | 85 | { |
86 | /* | ||
86 | TestHelpers.InMethod(); | 87 | TestHelpers.InMethod(); |
87 | // log4net.Config.XmlConfigurator.Configure(); | 88 | // log4net.Config.XmlConfigurator.Configure(); |
88 | 89 | ||
89 | // Create asset | 90 | // Create asset |
90 | SceneObjectGroup object1 = SceneHelpers.CreateSceneObject(1, m_userId, "Object1", 0x20); | 91 | SceneObjectGroup object1 = SceneHelpers.CreateSceneObject(1, m_userId, "Object1", 0x20); |
91 | object1.AbsolutePosition = new Vector3(15, 30, 45); | 92 | object1.AbsolutePosition = new Vector3(15, 30, 45); |
92 | 93 | ||
93 | SceneObjectGroup object2 = SceneHelpers.CreateSceneObject(1, m_userId, "Object2", 0x40); | 94 | SceneObjectGroup object2 = SceneHelpers.CreateSceneObject(1, m_userId, "Object2", 0x40); |
94 | object2.AbsolutePosition = new Vector3(25, 50, 75); | 95 | object2.AbsolutePosition = new Vector3(25, 50, 75); |
95 | 96 | ||
96 | CoalescedSceneObjects coa = new CoalescedSceneObjects(m_userId, object1, object2); | 97 | CoalescedSceneObjects coa = new CoalescedSceneObjects(m_userId, object1, object2); |
97 | 98 | ||
98 | UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); | 99 | UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); |
@@ -106,45 +107,46 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess.Tests | |||
106 | item1.Name = item1Name; | 107 | item1.Name = item1Name; |
107 | item1.AssetID = asset1.FullID; | 108 | item1.AssetID = asset1.FullID; |
108 | item1.ID = item1Id; | 109 | item1.ID = item1Id; |
109 | InventoryFolderBase objsFolder | 110 | InventoryFolderBase objsFolder |
110 | = InventoryArchiveUtils.FindFoldersByPath(m_scene.InventoryService, m_userId, "Objects")[0]; | 111 | = InventoryArchiveUtils.FindFoldersByPath(m_scene.InventoryService, m_userId, "Objects")[0]; |
111 | item1.Folder = objsFolder.ID; | 112 | item1.Folder = objsFolder.ID; |
112 | item1.Flags |= (uint)InventoryItemFlags.ObjectHasMultipleItems; | 113 | item1.Flags |= (uint)InventoryItemFlags.ObjectHasMultipleItems; |
113 | m_scene.AddInventoryItem(item1); | 114 | m_scene.AddInventoryItem(item1); |
114 | 115 | ||
115 | SceneObjectGroup so | 116 | SceneObjectGroup so |
116 | = m_iam.RezObject( | 117 | = m_iam.RezObject( |
117 | m_tc, item1Id, new Vector3(100, 100, 100), Vector3.Zero, UUID.Zero, 1, false, false, false, UUID.Zero, false); | 118 | m_tc, item1Id, new Vector3(100, 100, 100), Vector3.Zero, UUID.Zero, 1, false, false, false, UUID.Zero, false); |
118 | 119 | ||
119 | Assert.That(so, Is.Not.Null); | 120 | Assert.That(so, Is.Not.Null); |
120 | 121 | ||
121 | Assert.That(m_scene.SceneGraph.GetTotalObjectsCount(), Is.EqualTo(2)); | 122 | Assert.That(m_scene.SceneGraph.GetTotalObjectsCount(), Is.EqualTo(2)); |
122 | 123 | ||
123 | SceneObjectPart retrievedObj1Part = m_scene.GetSceneObjectPart(object1.Name); | 124 | SceneObjectPart retrievedObj1Part = m_scene.GetSceneObjectPart(object1.Name); |
124 | Assert.That(retrievedObj1Part, Is.Null); | 125 | Assert.That(retrievedObj1Part, Is.Null); |
125 | 126 | ||
126 | retrievedObj1Part = m_scene.GetSceneObjectPart(item1.Name); | 127 | retrievedObj1Part = m_scene.GetSceneObjectPart(item1.Name); |
127 | Assert.That(retrievedObj1Part, Is.Not.Null); | 128 | Assert.That(retrievedObj1Part, Is.Not.Null); |
128 | Assert.That(retrievedObj1Part.Name, Is.EqualTo(item1.Name)); | 129 | Assert.That(retrievedObj1Part.Name, Is.EqualTo(item1.Name)); |
129 | 130 | ||
130 | // Bottom of coalescence is placed on ground, hence we end up with 100.5 rather than 85 since the bottom | 131 | // Bottom of coalescence is placed on ground, hence we end up with 100.5 rather than 85 since the bottom |
131 | // object is unit square. | 132 | // object is unit square. |
132 | Assert.That(retrievedObj1Part.AbsolutePosition, Is.EqualTo(new Vector3(95, 90, 100.5f))); | 133 | Assert.That(retrievedObj1Part.AbsolutePosition, Is.EqualTo(new Vector3(95, 90, 100.5f))); |
133 | 134 | ||
134 | SceneObjectPart retrievedObj2Part = m_scene.GetSceneObjectPart(object2.Name); | 135 | SceneObjectPart retrievedObj2Part = m_scene.GetSceneObjectPart(object2.Name); |
135 | Assert.That(retrievedObj2Part, Is.Not.Null); | 136 | Assert.That(retrievedObj2Part, Is.Not.Null); |
136 | Assert.That(retrievedObj2Part.Name, Is.EqualTo(object2.Name)); | 137 | Assert.That(retrievedObj2Part.Name, Is.EqualTo(object2.Name)); |
137 | Assert.That(retrievedObj2Part.AbsolutePosition, Is.EqualTo(new Vector3(105, 110, 130.5f))); | 138 | Assert.That(retrievedObj2Part.AbsolutePosition, Is.EqualTo(new Vector3(105, 110, 130.5f))); |
138 | } | 139 | */ |
139 | 140 | } | |
141 | |||
140 | [Test] | 142 | [Test] |
141 | public void TestRezObject() | 143 | public void TestRezObject() |
142 | { | 144 | { |
143 | TestHelpers.InMethod(); | 145 | TestHelpers.InMethod(); |
144 | // log4net.Config.XmlConfigurator.Configure(); | 146 | // log4net.Config.XmlConfigurator.Configure(); |
145 | 147 | ||
146 | // Create asset | 148 | // Create asset |
147 | SceneObjectGroup object1 = SceneHelpers.CreateSceneObject(1, m_userId, "My Little Dog Object", 0x40); | 149 | SceneObjectGroup object1 = SceneHelpers.CreateSceneObject(1, m_userId, "My Little Dog Object", 0x40); |
148 | 150 | ||
149 | UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); | 151 | UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); |
150 | AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); | 152 | AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); |
@@ -157,17 +159,17 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess.Tests | |||
157 | item1.Name = item1Name; | 159 | item1.Name = item1Name; |
158 | item1.AssetID = asset1.FullID; | 160 | item1.AssetID = asset1.FullID; |
159 | item1.ID = item1Id; | 161 | item1.ID = item1Id; |
160 | InventoryFolderBase objsFolder | 162 | InventoryFolderBase objsFolder |
161 | = InventoryArchiveUtils.FindFoldersByPath(m_scene.InventoryService, m_userId, "Objects")[0]; | 163 | = InventoryArchiveUtils.FindFoldersByPath(m_scene.InventoryService, m_userId, "Objects")[0]; |
162 | item1.Folder = objsFolder.ID; | 164 | item1.Folder = objsFolder.ID; |
163 | m_scene.AddInventoryItem(item1); | 165 | m_scene.AddInventoryItem(item1); |
164 | 166 | ||
165 | SceneObjectGroup so | 167 | SceneObjectGroup so |
166 | = m_iam.RezObject( | 168 | = m_iam.RezObject( |
167 | m_tc, item1Id, Vector3.Zero, Vector3.Zero, UUID.Zero, 1, false, false, false, UUID.Zero, false); | 169 | m_tc, item1Id, UUID.Zero, Vector3.Zero, Vector3.Zero, UUID.Zero, 1, false, false, false, UUID.Zero, false); |
168 | 170 | ||
169 | Assert.That(so, Is.Not.Null); | 171 | Assert.That(so, Is.Not.Null); |
170 | 172 | ||
171 | SceneObjectPart retrievedPart = m_scene.GetSceneObjectPart(so.UUID); | 173 | SceneObjectPart retrievedPart = m_scene.GetSceneObjectPart(so.UUID); |
172 | Assert.That(retrievedPart, Is.Not.Null); | 174 | Assert.That(retrievedPart, Is.Not.Null); |
173 | } | 175 | } |