diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs | 297 |
1 files changed, 244 insertions, 53 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs index 9f98554..12e53a8 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs | |||
@@ -111,7 +111,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
111 | /// <param name="item">The user inventory item being added.</param> | 111 | /// <param name="item">The user inventory item being added.</param> |
112 | /// <param name="copyItemID">The item UUID that should be used by the new item.</param> | 112 | /// <param name="copyItemID">The item UUID that should be used by the new item.</param> |
113 | /// <returns></returns> | 113 | /// <returns></returns> |
114 | public bool AddInventoryItem(UUID agentID, uint localID, InventoryItemBase item, UUID copyItemID) | 114 | public bool AddInventoryItem(UUID agentID, uint localID, InventoryItemBase item, UUID copyItemID, bool withModRights = true) |
115 | { | 115 | { |
116 | // m_log.DebugFormat( | 116 | // m_log.DebugFormat( |
117 | // "[PRIM INVENTORY]: Adding inventory item {0} from {1} to part with local ID {2}", | 117 | // "[PRIM INVENTORY]: Adding inventory item {0} from {1} to part with local ID {2}", |
@@ -120,69 +120,72 @@ namespace OpenSim.Region.Framework.Scenes | |||
120 | UUID newItemId = (copyItemID != UUID.Zero) ? copyItemID : item.ID; | 120 | UUID newItemId = (copyItemID != UUID.Zero) ? copyItemID : item.ID; |
121 | 121 | ||
122 | SceneObjectPart part = GetPart(localID); | 122 | SceneObjectPart part = GetPart(localID); |
123 | if (part != null) | 123 | if (part == null) |
124 | { | 124 | { |
125 | TaskInventoryItem taskItem = new TaskInventoryItem(); | 125 | m_log.ErrorFormat( |
126 | 126 | "[PRIM INVENTORY]: " + | |
127 | taskItem.ItemID = newItemId; | 127 | "Couldn't find prim local ID {0} in group {1}, {2} to add inventory item ID {3}", |
128 | taskItem.AssetID = item.AssetID; | 128 | localID, Name, UUID, newItemId); |
129 | taskItem.Name = item.Name; | 129 | return false; |
130 | taskItem.Description = item.Description; | 130 | } |
131 | taskItem.OwnerID = part.OwnerID; // Transfer ownership | 131 | |
132 | taskItem.CreatorID = item.CreatorIdAsUuid; | 132 | TaskInventoryItem taskItem = new TaskInventoryItem(); |
133 | taskItem.Type = item.AssetType; | ||
134 | taskItem.InvType = item.InvType; | ||
135 | |||
136 | if (agentID != part.OwnerID && m_scene.Permissions.PropagatePermissions()) | ||
137 | { | ||
138 | taskItem.BasePermissions = item.BasePermissions & | ||
139 | item.NextPermissions; | ||
140 | taskItem.CurrentPermissions = item.CurrentPermissions & | ||
141 | item.NextPermissions; | ||
142 | taskItem.EveryonePermissions = item.EveryOnePermissions & | ||
143 | item.NextPermissions; | ||
144 | taskItem.GroupPermissions = item.GroupPermissions & | ||
145 | item.NextPermissions; | ||
146 | taskItem.NextPermissions = item.NextPermissions; | ||
147 | // We're adding this to a prim we don't own. Force | ||
148 | // owner change | ||
149 | taskItem.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm; | ||
150 | } | ||
151 | else | ||
152 | { | ||
153 | taskItem.BasePermissions = item.BasePermissions; | ||
154 | taskItem.CurrentPermissions = item.CurrentPermissions; | ||
155 | taskItem.EveryonePermissions = item.EveryOnePermissions; | ||
156 | taskItem.GroupPermissions = item.GroupPermissions; | ||
157 | taskItem.NextPermissions = item.NextPermissions; | ||
158 | } | ||
159 | 133 | ||
160 | taskItem.Flags = item.Flags; | 134 | taskItem.ItemID = newItemId; |
135 | taskItem.AssetID = item.AssetID; | ||
136 | taskItem.Name = item.Name; | ||
137 | taskItem.Description = item.Description; | ||
138 | taskItem.OwnerID = part.OwnerID; // Transfer ownership | ||
139 | taskItem.CreatorID = item.CreatorIdAsUuid; | ||
140 | taskItem.Type = item.AssetType; | ||
141 | taskItem.InvType = item.InvType; | ||
142 | |||
143 | if (agentID != part.OwnerID && m_scene.Permissions.PropagatePermissions()) | ||
144 | { | ||
145 | taskItem.BasePermissions = item.BasePermissions & | ||
146 | item.NextPermissions; | ||
147 | taskItem.CurrentPermissions = item.CurrentPermissions & | ||
148 | item.NextPermissions; | ||
149 | taskItem.EveryonePermissions = item.EveryOnePermissions & | ||
150 | item.NextPermissions; | ||
151 | taskItem.GroupPermissions = item.GroupPermissions & | ||
152 | item.NextPermissions; | ||
153 | taskItem.NextPermissions = item.NextPermissions; | ||
154 | // We're adding this to a prim we don't own. Force | ||
155 | // owner change | ||
156 | taskItem.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm; | ||
157 | |||
158 | } | ||
159 | else | ||
160 | { | ||
161 | taskItem.BasePermissions = item.BasePermissions; | ||
162 | taskItem.CurrentPermissions = item.CurrentPermissions; | ||
163 | taskItem.EveryonePermissions = item.EveryOnePermissions; | ||
164 | taskItem.GroupPermissions = item.GroupPermissions; | ||
165 | taskItem.NextPermissions = item.NextPermissions; | ||
166 | } | ||
167 | |||
168 | taskItem.Flags = item.Flags; | ||
161 | 169 | ||
162 | // m_log.DebugFormat( | 170 | // m_log.DebugFormat( |
163 | // "[PRIM INVENTORY]: Flags are 0x{0:X} for item {1} added to part {2} by {3}", | 171 | // "[PRIM INVENTORY]: Flags are 0x{0:X} for item {1} added to part {2} by {3}", |
164 | // taskItem.Flags, taskItem.Name, localID, remoteClient.Name); | 172 | // taskItem.Flags, taskItem.Name, localID, remoteClient.Name); |
165 | 173 | ||
166 | // TODO: These are pending addition of those fields to TaskInventoryItem | 174 | // TODO: These are pending addition of those fields to TaskInventoryItem |
167 | // taskItem.SalePrice = item.SalePrice; | 175 | // taskItem.SalePrice = item.SalePrice; |
168 | // taskItem.SaleType = item.SaleType; | 176 | // taskItem.SaleType = item.SaleType; |
169 | taskItem.CreationDate = (uint)item.CreationDate; | 177 | taskItem.CreationDate = (uint)item.CreationDate; |
170 | 178 | ||
171 | bool addFromAllowedDrop = agentID != part.OwnerID; | 179 | bool addFromAllowedDrop; |
172 | 180 | if(withModRights) | |
173 | part.Inventory.AddInventoryItem(taskItem, addFromAllowedDrop); | 181 | addFromAllowedDrop = false; |
174 | |||
175 | return true; | ||
176 | } | ||
177 | else | 182 | else |
178 | { | 183 | addFromAllowedDrop = (part.ParentGroup.RootPart.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) != 0; |
179 | m_log.ErrorFormat( | 184 | |
180 | "[PRIM INVENTORY]: " + | 185 | part.Inventory.AddInventoryItem(taskItem, addFromAllowedDrop); |
181 | "Couldn't find prim local ID {0} in group {1}, {2} to add inventory item ID {3}", | 186 | part.ParentGroup.AggregatePerms(); |
182 | localID, Name, UUID, newItemId); | 187 | return true; |
183 | } | ||
184 | 188 | ||
185 | return false; | ||
186 | } | 189 | } |
187 | 190 | ||
188 | /// <summary> | 191 | /// <summary> |
@@ -248,6 +251,194 @@ namespace OpenSim.Region.Framework.Scenes | |||
248 | return -1; | 251 | return -1; |
249 | } | 252 | } |
250 | 253 | ||
254 | // new test code, to place in better place later | ||
255 | private object PermissionsLock = new object(); | ||
256 | |||
257 | private uint m_EffectiveEveryOnePerms; | ||
258 | public uint EffectiveEveryOnePerms | ||
259 | { | ||
260 | get | ||
261 | { | ||
262 | // this can't be done here but on every place where a change may happen (rez, (de)link, contents , perms, etc) | ||
263 | // bc this is on heavy duty code paths | ||
264 | // but for now we need to test the concept | ||
265 | // AggregateDeepPerms(); | ||
266 | return m_EffectiveEveryOnePerms; | ||
267 | } | ||
268 | } | ||
269 | |||
270 | private uint m_EffectiveGroupPerms; | ||
271 | public uint EffectiveGroupPerms | ||
272 | { | ||
273 | get | ||
274 | { | ||
275 | // this can't be done here but on every place where a change may happen (rez, (de)link, contents , perms, etc) | ||
276 | // bc this is on heavy duty code paths | ||
277 | // but for now we need to test the concept | ||
278 | // AggregateDeepPerms(); | ||
279 | return m_EffectiveGroupPerms; | ||
280 | } | ||
281 | } | ||
282 | |||
283 | private uint m_EffectiveGroupOrEveryOnePerms; | ||
284 | public uint EffectiveGroupOrEveryOnePerms | ||
285 | { | ||
286 | get | ||
287 | { | ||
288 | // this can't be done here but on every place where a change may happen (rez, (de)link, contents , perms, etc) | ||
289 | // bc this is on heavy duty code paths | ||
290 | // but for now we need to test the concept | ||
291 | // AggregateDeepPerms(); | ||
292 | return m_EffectiveGroupOrEveryOnePerms; | ||
293 | } | ||
294 | } | ||
295 | |||
296 | private uint m_EffectiveOwnerPerms; | ||
297 | public uint EffectiveOwnerPerms | ||
298 | { | ||
299 | get | ||
300 | { | ||
301 | // this can't be done here but on every place where a change may happen (rez, (de)link, contents , perms, etc) | ||
302 | // bc this is on heavy duty code paths | ||
303 | // but for now we need to test the concept | ||
304 | // AggregateDeepPerms(); | ||
305 | return m_EffectiveOwnerPerms; | ||
306 | } | ||
307 | } | ||
308 | |||
309 | // aggregates perms scanning parts and their contents | ||
310 | // AggregatePerms does same using cached parts content perms | ||
311 | public void AggregateDeepPerms() | ||
312 | { | ||
313 | lock(PermissionsLock) | ||
314 | { | ||
315 | // aux | ||
316 | const uint allmask = (uint)PermissionMask.AllEffective; | ||
317 | const uint movemodmask = (uint)(PermissionMask.Move | PermissionMask.Modify); | ||
318 | const uint copytransfermast = (uint)(PermissionMask.Copy | PermissionMask.Transfer); | ||
319 | |||
320 | uint basePerms = (RootPart.BaseMask & allmask) | (uint)PermissionMask.Move; | ||
321 | bool noBaseTransfer = (basePerms & (uint)PermissionMask.Transfer) == 0; | ||
322 | |||
323 | uint rootOwnerPerms = RootPart.OwnerMask; | ||
324 | uint owner = rootOwnerPerms; | ||
325 | uint rootGroupPerms = RootPart.GroupMask; | ||
326 | uint group = rootGroupPerms; | ||
327 | uint rootEveryonePerms = RootPart.EveryoneMask; | ||
328 | uint everyone = rootEveryonePerms; | ||
329 | |||
330 | SceneObjectPart[] parts = m_parts.GetArray(); | ||
331 | for (int i = 0; i < parts.Length; i++) | ||
332 | { | ||
333 | SceneObjectPart part = parts[i]; | ||
334 | part.AggregateInnerPerms(); | ||
335 | owner &= part.AggregatedInnerOwnerPerms; | ||
336 | group &= part.AggregatedInnerGroupPerms; | ||
337 | everyone &= part.AggregatedInnerEveryonePerms; | ||
338 | } | ||
339 | // recover modify and move | ||
340 | rootOwnerPerms &= movemodmask; | ||
341 | owner |= rootOwnerPerms; | ||
342 | if((owner & copytransfermast) == 0) | ||
343 | owner |= (uint)PermissionMask.Transfer; | ||
344 | |||
345 | owner &= basePerms; | ||
346 | m_EffectiveOwnerPerms = owner; | ||
347 | uint ownertransfermask = owner & (uint)PermissionMask.Transfer; | ||
348 | |||
349 | // recover modify and move | ||
350 | rootGroupPerms &= movemodmask; | ||
351 | group |= rootGroupPerms; | ||
352 | if(noBaseTransfer) | ||
353 | group &=~(uint)PermissionMask.Copy; | ||
354 | else | ||
355 | group |= ownertransfermask; | ||
356 | |||
357 | uint groupOrEveryone = group; | ||
358 | m_EffectiveGroupPerms = group & owner; | ||
359 | |||
360 | // recover move | ||
361 | rootEveryonePerms &= (uint)PermissionMask.Move; | ||
362 | everyone |= rootEveryonePerms; | ||
363 | everyone &= ~(uint)PermissionMask.Modify; | ||
364 | if(noBaseTransfer) | ||
365 | everyone &=~(uint)PermissionMask.Copy; | ||
366 | else | ||
367 | everyone |= ownertransfermask; | ||
368 | |||
369 | groupOrEveryone |= everyone; | ||
370 | |||
371 | m_EffectiveEveryOnePerms = everyone & owner; | ||
372 | m_EffectiveGroupOrEveryOnePerms = groupOrEveryone & owner; | ||
373 | } | ||
374 | } | ||
375 | |||
376 | // aggregates perms scanning parts, assuming their contents was already aggregated and cached | ||
377 | // ie is AggregateDeepPerms without the part.AggregateInnerPerms() call on parts loop | ||
378 | public void AggregatePerms() | ||
379 | { | ||
380 | lock(PermissionsLock) | ||
381 | { | ||
382 | // aux | ||
383 | const uint allmask = (uint)PermissionMask.AllEffective; | ||
384 | const uint movemodmask = (uint)(PermissionMask.Move | PermissionMask.Modify); | ||
385 | const uint copytransfermast = (uint)(PermissionMask.Copy | PermissionMask.Transfer); | ||
386 | |||
387 | uint basePerms = (RootPart.BaseMask & allmask) | (uint)PermissionMask.Move; | ||
388 | bool noBaseTransfer = (basePerms & (uint)PermissionMask.Transfer) == 0; | ||
389 | |||
390 | uint rootOwnerPerms = RootPart.OwnerMask; | ||
391 | uint owner = rootOwnerPerms; | ||
392 | uint rootGroupPerms = RootPart.GroupMask; | ||
393 | uint group = rootGroupPerms; | ||
394 | uint rootEveryonePerms = RootPart.EveryoneMask; | ||
395 | uint everyone = rootEveryonePerms; | ||
396 | |||
397 | SceneObjectPart[] parts = m_parts.GetArray(); | ||
398 | for (int i = 0; i < parts.Length; i++) | ||
399 | { | ||
400 | SceneObjectPart part = parts[i]; | ||
401 | owner &= part.AggregatedInnerOwnerPerms; | ||
402 | group &= part.AggregatedInnerGroupPerms; | ||
403 | everyone &= part.AggregatedInnerEveryonePerms; | ||
404 | } | ||
405 | // recover modify and move | ||
406 | rootOwnerPerms &= movemodmask; | ||
407 | owner |= rootOwnerPerms; | ||
408 | if((owner & copytransfermast) == 0) | ||
409 | owner |= (uint)PermissionMask.Transfer; | ||
410 | |||
411 | owner &= basePerms; | ||
412 | m_EffectiveOwnerPerms = owner; | ||
413 | uint ownertransfermask = owner & (uint)PermissionMask.Transfer; | ||
414 | |||
415 | // recover modify and move | ||
416 | rootGroupPerms &= movemodmask; | ||
417 | group |= rootGroupPerms; | ||
418 | if(noBaseTransfer) | ||
419 | group &=~(uint)PermissionMask.Copy; | ||
420 | else | ||
421 | group |= ownertransfermask; | ||
422 | |||
423 | uint groupOrEveryone = group; | ||
424 | m_EffectiveGroupPerms = group & owner; | ||
425 | |||
426 | // recover move | ||
427 | rootEveryonePerms &= (uint)PermissionMask.Move; | ||
428 | everyone |= rootEveryonePerms; | ||
429 | everyone &= ~(uint)PermissionMask.Modify; | ||
430 | if(noBaseTransfer) | ||
431 | everyone &=~(uint)PermissionMask.Copy; | ||
432 | else | ||
433 | everyone |= ownertransfermask; | ||
434 | |||
435 | groupOrEveryone |= everyone; | ||
436 | |||
437 | m_EffectiveEveryOnePerms = everyone & owner; | ||
438 | m_EffectiveGroupOrEveryOnePerms = groupOrEveryone & owner; | ||
439 | } | ||
440 | } | ||
441 | |||
251 | public uint GetEffectivePermissions() | 442 | public uint GetEffectivePermissions() |
252 | { | 443 | { |
253 | return GetEffectivePermissions(false); | 444 | return GetEffectivePermissions(false); |