aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs337
1 files changed, 256 insertions, 81 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
index 81cef5b..c20c81d 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
@@ -88,10 +88,6 @@ namespace OpenSim.Region.Framework.Scenes
88 /// <summary> 88 /// <summary>
89 /// Stop and remove the scripts contained in all the prims in this group 89 /// Stop and remove the scripts contained in all the prims in this group
90 /// </summary> 90 /// </summary>
91 /// <param name="sceneObjectBeingDeleted">
92 /// Should be true if these scripts are being removed because the scene
93 /// object is being deleted. This will prevent spurious updates to the client.
94 /// </param>
95 public void RemoveScriptInstances(bool sceneObjectBeingDeleted) 91 public void RemoveScriptInstances(bool sceneObjectBeingDeleted)
96 { 92 {
97 SceneObjectPart[] parts = m_parts.GetArray(); 93 SceneObjectPart[] parts = m_parts.GetArray();
@@ -115,78 +111,81 @@ namespace OpenSim.Region.Framework.Scenes
115 /// <param name="item">The user inventory item being added.</param> 111 /// <param name="item">The user inventory item being added.</param>
116 /// <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>
117 /// <returns></returns> 113 /// <returns></returns>
118 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)
119 { 115 {
120// m_log.DebugFormat( 116// m_log.DebugFormat(
121// "[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}",
122// item.Name, remoteClient.Name, localID); 118// item.Name, remoteClient.Name, localID);
123 119
124 UUID newItemId = (copyItemID != UUID.Zero) ? copyItemID : item.ID; 120 UUID newItemId = (copyItemID != UUID.Zero) ? copyItemID : item.ID;
125 121
126 SceneObjectPart part = GetPart(localID); 122 SceneObjectPart part = GetPart(localID);
127 if (part != null) 123 if (part == null)
128 { 124 {
129 TaskInventoryItem taskItem = new TaskInventoryItem(); 125 m_log.ErrorFormat(
130 126 "[PRIM INVENTORY]: " +
131 taskItem.ItemID = newItemId; 127 "Couldn't find prim local ID {0} in group {1}, {2} to add inventory item ID {3}",
132 taskItem.AssetID = item.AssetID; 128 localID, Name, UUID, newItemId);
133 taskItem.Name = item.Name; 129 return false;
134 taskItem.Description = item.Description; 130 }
135 taskItem.OwnerID = part.OwnerID; // Transfer ownership
136 taskItem.CreatorID = item.CreatorIdAsUuid;
137 taskItem.Type = item.AssetType;
138 taskItem.InvType = item.InvType;
139
140 if (agentID != part.OwnerID && m_scene.Permissions.PropagatePermissions())
141 {
142 taskItem.BasePermissions = item.BasePermissions &
143 item.NextPermissions;
144 taskItem.CurrentPermissions = item.CurrentPermissions &
145 item.NextPermissions;
146 taskItem.EveryonePermissions = item.EveryOnePermissions &
147 item.NextPermissions;
148 taskItem.GroupPermissions = item.GroupPermissions &
149 item.NextPermissions;
150 taskItem.NextPermissions = item.NextPermissions;
151 // We're adding this to a prim we don't own. Force
152 // owner change
153 taskItem.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm;
154 }
155 else
156 {
157 taskItem.BasePermissions = item.BasePermissions;
158 taskItem.CurrentPermissions = item.CurrentPermissions;
159 taskItem.EveryonePermissions = item.EveryOnePermissions;
160 taskItem.GroupPermissions = item.GroupPermissions;
161 taskItem.NextPermissions = item.NextPermissions;
162 }
163
164 taskItem.Flags = item.Flags;
165 131
166// m_log.DebugFormat( 132 TaskInventoryItem taskItem = new TaskInventoryItem();
167// "[PRIM INVENTORY]: Flags are 0x{0:X} for item {1} added to part {2} by {3}",
168// taskItem.Flags, taskItem.Name, localID, remoteClient.Name);
169
170 // TODO: These are pending addition of those fields to TaskInventoryItem
171// taskItem.SalePrice = item.SalePrice;
172// taskItem.SaleType = item.SaleType;
173 taskItem.CreationDate = (uint)item.CreationDate;
174 133
175 bool addFromAllowedDrop = agentID != part.OwnerID; 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;
176 142
177 part.Inventory.AddInventoryItem(taskItem, addFromAllowedDrop); 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;
178 157
179 return true;
180 } 158 }
181 else 159 else
182 { 160 {
183 m_log.ErrorFormat( 161 taskItem.BasePermissions = item.BasePermissions;
184 "[PRIM INVENTORY]: " + 162 taskItem.CurrentPermissions = item.CurrentPermissions;
185 "Couldn't find prim local ID {0} in group {1}, {2} to add inventory item ID {3}", 163 taskItem.EveryonePermissions = item.EveryOnePermissions;
186 localID, Name, UUID, newItemId); 164 taskItem.GroupPermissions = item.GroupPermissions;
165 taskItem.NextPermissions = item.NextPermissions;
187 } 166 }
188 167
189 return false; 168 taskItem.Flags = item.Flags;
169
170// m_log.DebugFormat(
171// "[PRIM INVENTORY]: Flags are 0x{0:X} for item {1} added to part {2} by {3}",
172// taskItem.Flags, taskItem.Name, localID, remoteClient.Name);
173
174 // TODO: These are pending addition of those fields to TaskInventoryItem
175// taskItem.SalePrice = item.SalePrice;
176// taskItem.SaleType = item.SaleType;
177 taskItem.CreationDate = (uint)item.CreationDate;
178
179 bool addFromAllowedDrop;
180 if(withModRights)
181 addFromAllowedDrop = false;
182 else
183 addFromAllowedDrop = (part.ParentGroup.RootPart.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) != 0;
184
185 part.Inventory.AddInventoryItem(taskItem, addFromAllowedDrop);
186 part.ParentGroup.InvalidateEffectivePerms();
187 return true;
188
190 } 189 }
191 190
192 /// <summary> 191 /// <summary>
@@ -252,21 +251,201 @@ namespace OpenSim.Region.Framework.Scenes
252 return -1; 251 return -1;
253 } 252 }
254 253
255 public uint GetEffectivePermissions() 254 // new test code, to place in better place later
255 private object m_PermissionsLock = new object();
256 private bool m_EffectivePermsInvalid = true;
257 private bool m_DeepEffectivePermsInvalid = true;
258
259 // should called when parts chanced by their contents did not, so we know their cacche is valid
260 // in case of doubt call InvalidateDeepEffectivePerms(), it only costs a bit more cpu time
261 public void InvalidateEffectivePerms()
262 {
263 lock(m_PermissionsLock)
264 m_EffectivePermsInvalid = true;
265 }
266
267 // should called when parts chanced and their contents where accounted for
268 public void InvalidateDeepEffectivePerms()
269 {
270 lock(m_PermissionsLock)
271 {
272 m_DeepEffectivePermsInvalid = true;
273 m_EffectivePermsInvalid = true;
274 }
275 }
276
277 private uint m_EffectiveEveryOnePerms;
278 public uint EffectiveEveryOnePerms
279 {
280 get
281 {
282 lock(m_PermissionsLock)
283 {
284 if(m_EffectivePermsInvalid)
285 AggregatePerms();
286 return m_EffectiveEveryOnePerms;
287 }
288 }
289 }
290
291 private uint m_EffectiveGroupPerms;
292 public uint EffectiveGroupPerms
293 {
294 get
295 {
296 lock(m_PermissionsLock)
297 {
298 if(m_EffectivePermsInvalid)
299 AggregatePerms();
300 return m_EffectiveGroupPerms;
301 }
302 }
303 }
304
305 private uint m_EffectiveGroupOrEveryOnePerms;
306 public uint EffectiveGroupOrEveryOnePerms
307 {
308 get
309 {
310 lock(m_PermissionsLock)
311 {
312 if(m_EffectivePermsInvalid)
313 AggregatePerms();
314 return m_EffectiveGroupOrEveryOnePerms;
315 }
316 }
317 }
318
319 private uint m_EffectiveOwnerPerms;
320 public uint EffectiveOwnerPerms
321 {
322 get
323 {
324 lock(m_PermissionsLock)
325 {
326 if(m_EffectivePermsInvalid)
327 AggregatePerms();
328 return m_EffectiveOwnerPerms;
329 }
330 }
331 }
332
333 public void AggregatePerms()
334 {
335 lock(m_PermissionsLock)
336 {
337 // aux
338 const uint allmask = (uint)PermissionMask.AllEffective;
339 const uint movemodmask = (uint)(PermissionMask.Move | PermissionMask.Modify);
340 const uint copytransfermast = (uint)(PermissionMask.Copy | PermissionMask.Transfer);
341
342 uint basePerms = (RootPart.BaseMask & allmask) | (uint)PermissionMask.Move;
343 bool noBaseTransfer = (basePerms & (uint)PermissionMask.Transfer) == 0;
344
345 uint rootOwnerPerms = RootPart.OwnerMask;
346 uint owner = rootOwnerPerms;
347 uint rootGroupPerms = RootPart.GroupMask;
348 uint group = rootGroupPerms;
349 uint rootEveryonePerms = RootPart.EveryoneMask;
350 uint everyone = rootEveryonePerms;
351
352 bool needUpdate = false;
353 // date is time of writing april 30th 2017
354 bool newobj = (RootPart.CreationDate == 0 || RootPart.CreationDate > 1493574994);
355 SceneObjectPart[] parts = m_parts.GetArray();
356 for (int i = 0; i < parts.Length; i++)
357 {
358 SceneObjectPart part = parts[i];
359
360 if(m_DeepEffectivePermsInvalid)
361 part.AggregatedInnerPermsForGroup();
362
363 owner &= part.AggregatedInnerOwnerPerms;
364 group &= part.AggregatedInnerGroupPerms;
365 if(newobj)
366 group &= part.AggregatedInnerGroupPerms;
367 if(newobj)
368 everyone &= part.AggregatedInnerEveryonePerms;
369 }
370 // recover modify and move
371 rootOwnerPerms &= movemodmask;
372 owner |= rootOwnerPerms;
373 if((owner & copytransfermast) == 0)
374 owner |= (uint)PermissionMask.Transfer;
375
376 owner &= basePerms;
377 if(owner != m_EffectiveOwnerPerms)
378 {
379 needUpdate = true;
380 m_EffectiveOwnerPerms = owner;
381 }
382
383 uint ownertransfermask = owner & (uint)PermissionMask.Transfer;
384
385 // recover modify and move
386 rootGroupPerms &= movemodmask;
387 group |= rootGroupPerms;
388 if(noBaseTransfer)
389 group &=~(uint)PermissionMask.Copy;
390 else
391 group |= ownertransfermask;
392
393 uint groupOrEveryone = group;
394 uint tmpPerms = group & owner;
395 if(tmpPerms != m_EffectiveGroupPerms)
396 {
397 needUpdate = true;
398 m_EffectiveGroupPerms = tmpPerms;
399 }
400
401 // recover move
402 rootEveryonePerms &= (uint)PermissionMask.Move;
403 everyone |= rootEveryonePerms;
404 everyone &= ~(uint)PermissionMask.Modify;
405 if(noBaseTransfer)
406 everyone &=~(uint)PermissionMask.Copy;
407 else
408 everyone |= ownertransfermask;
409
410 groupOrEveryone |= everyone;
411
412 tmpPerms = everyone & owner;
413 if(tmpPerms != m_EffectiveEveryOnePerms)
414 {
415 needUpdate = true;
416 m_EffectiveEveryOnePerms = tmpPerms;
417 }
418
419 tmpPerms = groupOrEveryone & owner;
420 if(tmpPerms != m_EffectiveGroupOrEveryOnePerms)
421 {
422 needUpdate = true;
423 m_EffectiveGroupOrEveryOnePerms = tmpPerms;
424 }
425
426 m_DeepEffectivePermsInvalid = false;
427 m_EffectivePermsInvalid = false;
428
429 if(needUpdate)
430 RootPart.ScheduleFullUpdate();
431 }
432 }
433
434 public uint CurrentAndFoldedNextPermissions()
256 { 435 {
257 uint perms=(uint)(PermissionMask.Modify | 436 uint perms=(uint)(PermissionMask.Modify |
258 PermissionMask.Copy | 437 PermissionMask.Copy |
259 PermissionMask.Move | 438 PermissionMask.Move |
260 PermissionMask.Transfer) | 7; 439 PermissionMask.Transfer |
440 PermissionMask.FoldedMask);
261 441
262 uint ownerMask = 0x7fffffff; 442 uint ownerMask = RootPart.OwnerMask;
263 443
264 SceneObjectPart[] parts = m_parts.GetArray(); 444 SceneObjectPart[] parts = m_parts.GetArray();
265 for (int i = 0; i < parts.Length; i++) 445 for (int i = 0; i < parts.Length; i++)
266 { 446 {
267 SceneObjectPart part = parts[i]; 447 SceneObjectPart part = parts[i];
268// m_log.DebugFormat("[SCENE OBJECT GROUP INVENTORY]: Effective perms of {0} are {1}", part.Name, (OpenMetaverse.PermissionMask)part.OwnerMask); 448 ownerMask &= part.BaseMask;
269 ownerMask &= part.OwnerMask;
270 perms &= part.Inventory.MaskEffectivePermissions(); 449 perms &= part.Inventory.MaskEffectivePermissions();
271 } 450 }
272 451
@@ -276,17 +455,8 @@ namespace OpenSim.Region.Framework.Scenes
276 perms &= ~(uint)PermissionMask.Copy; 455 perms &= ~(uint)PermissionMask.Copy;
277 if ((ownerMask & (uint)PermissionMask.Transfer) == 0) 456 if ((ownerMask & (uint)PermissionMask.Transfer) == 0)
278 perms &= ~(uint)PermissionMask.Transfer; 457 perms &= ~(uint)PermissionMask.Transfer;
279 458 if ((ownerMask & (uint)PermissionMask.Export) == 0)
280 // If root prim permissions are applied here, this would screw 459 perms &= ~(uint)PermissionMask.Export;
281 // with in-inventory manipulation of the next owner perms
282 // in a major way. So, let's move this to the give itself.
283 // Yes. I know. Evil.
284// if ((ownerMask & RootPart.NextOwnerMask & (uint)PermissionMask.Modify) == 0)
285// perms &= ~((uint)PermissionMask.Modify >> 13);
286// if ((ownerMask & RootPart.NextOwnerMask & (uint)PermissionMask.Copy) == 0)
287// perms &= ~((uint)PermissionMask.Copy >> 13);
288// if ((ownerMask & RootPart.NextOwnerMask & (uint)PermissionMask.Transfer) == 0)
289// perms &= ~((uint)PermissionMask.Transfer >> 13);
290 460
291 return perms; 461 return perms;
292 } 462 }
@@ -323,18 +493,19 @@ namespace OpenSim.Region.Framework.Scenes
323 xmldoc.AppendChild(xmlnode); 493 xmldoc.AppendChild(xmlnode);
324 XmlElement rootElement = xmldoc.CreateElement("", "ScriptData", 494 XmlElement rootElement = xmldoc.CreateElement("", "ScriptData",
325 String.Empty); 495 String.Empty);
326 496
327 xmldoc.AppendChild(rootElement); 497 xmldoc.AppendChild(rootElement);
328 498
329 499
330 XmlElement wrapper = xmldoc.CreateElement("", "ScriptStates", 500 XmlElement wrapper = xmldoc.CreateElement("", "ScriptStates",
331 String.Empty); 501 String.Empty);
332 502
333 rootElement.AppendChild(wrapper); 503 rootElement.AppendChild(wrapper);
334 504
335 foreach (KeyValuePair<UUID, string> state in states) 505 foreach (KeyValuePair<UUID, string> state in states)
336 { 506 {
337 XmlDocument sdoc = new XmlDocument(); 507 XmlDocument sdoc = new XmlDocument();
508 sdoc.XmlResolver=null;
338 sdoc.LoadXml(state.Value); 509 sdoc.LoadXml(state.Value);
339 XmlNodeList rootL = sdoc.GetElementsByTagName("State"); 510 XmlNodeList rootL = sdoc.GetElementsByTagName("State");
340 XmlNode rootNode = rootL[0]; 511 XmlNode rootNode = rootL[0];
@@ -357,7 +528,7 @@ namespace OpenSim.Region.Framework.Scenes
357 return; 528 return;
358 529
359 IScriptModule scriptModule = null; 530 IScriptModule scriptModule = null;
360 531
361 foreach (IScriptModule sm in s.RequestModuleInterfaces<IScriptModule>()) 532 foreach (IScriptModule sm in s.RequestModuleInterfaces<IScriptModule>())
362 { 533 {
363 if (sm.ScriptEngineName == s.DefaultScriptEngine) 534 if (sm.ScriptEngineName == s.DefaultScriptEngine)
@@ -370,6 +541,7 @@ namespace OpenSim.Region.Framework.Scenes
370 return; 541 return;
371 542
372 XmlDocument doc = new XmlDocument(); 543 XmlDocument doc = new XmlDocument();
544 doc.XmlResolver=null;
373 try 545 try
374 { 546 {
375 doc.LoadXml(objXMLData); 547 doc.LoadXml(objXMLData);
@@ -396,7 +568,7 @@ namespace OpenSim.Region.Framework.Scenes
396 return; 568 return;
397 569
398 XmlElement dataE = (XmlElement)dataL[0]; 570 XmlElement dataE = (XmlElement)dataL[0];
399 571
400 foreach (XmlNode n in dataE.ChildNodes) 572 foreach (XmlNode n in dataE.ChildNodes)
401 { 573 {
402 XmlElement stateE = (XmlElement)n; 574 XmlElement stateE = (XmlElement)n;
@@ -408,6 +580,9 @@ namespace OpenSim.Region.Framework.Scenes
408 580
409 public void ResumeScripts() 581 public void ResumeScripts()
410 { 582 {
583 if (m_scene.RegionInfo.RegionSettings.DisableScripts)
584 return;
585
411 SceneObjectPart[] parts = m_parts.GetArray(); 586 SceneObjectPart[] parts = m_parts.GetArray();
412 for (int i = 0; i < parts.Length; i++) 587 for (int i = 0; i < parts.Length; i++)
413 parts[i].Inventory.ResumeScripts(); 588 parts[i].Inventory.ResumeScripts();