30 using System.Reflection;
33 using OpenSim.Framework;
34 using OpenSim.Region.Framework.Interfaces;
35 using System.Collections.Generic;
39 namespace OpenSim.
Region.Framework.Scenes
41 public partial class SceneObjectGroup : EntityBase
43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
51 for (
int i = 0; i < parts.Length; i++)
52 parts[i].Inventory.ForceInventoryPersistence();
68 int scriptsStarted = 0;
72 m_log.DebugFormat(
"[PRIM INVENTORY]: m_scene is null. Unable to create script instances");
77 if (!m_scene.RegionInfo.RegionSettings.DisableScripts)
80 for (
int i = 0; i < parts.Length; i++)
82 += parts[i].Inventory.CreateScriptInstances(startParam, postOnRez, engine, stateSource);
85 return scriptsStarted;
94 for (
int i = 0; i < parts.Length; i++)
95 parts[i].Inventory.RemoveScriptInstances(sceneObjectBeingDeleted);
103 Array.ForEach<
SceneObjectPart>(m_parts.GetArray(), p => p.Inventory.StopScriptInstances());
120 UUID newItemId = (copyItemID != UUID.Zero) ? copyItemID : item.
ID;
127 taskItem.ItemID = newItemId;
128 taskItem.AssetID = item.AssetID;
129 taskItem.Name = item.Name;
130 taskItem.Description = item.Description;
131 taskItem.OwnerID = part.OwnerID;
132 taskItem.CreatorID = item.CreatorIdAsUuid;
133 taskItem.Type = item.AssetType;
134 taskItem.InvType = item.InvType;
136 if (agentID != part.OwnerID && m_scene.Permissions.PropagatePermissions())
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;
149 taskItem.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm;
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;
160 taskItem.Flags = item.Flags;
171 bool addFromAllowedDrop = agentID != part.OwnerID;
173 part.Inventory.AddInventoryItem(taskItem, addFromAllowedDrop);
180 "[PRIM INVENTORY]: " +
181 "Couldn't find prim local ID {0} in group {1}, {2} to add inventory item ID {3}",
182 localID, Name,
UUID, newItemId);
199 return part.Inventory.GetInventoryItem(itemID);
204 "[PRIM INVENTORY]: " +
205 "Couldn't find prim local ID {0} in prim {1}, {2} to get inventory item ID {3}",
206 primID, part.Name, part.UUID, itemID);
223 part.Inventory.UpdateInventoryItem(item);
230 "[PRIM INVENTORY]: " +
231 "Couldn't find prim ID {0} to update item {1}, {2}",
232 item.ParentPartID, item.Name, item.ItemID);
243 int type = part.Inventory.RemoveInventoryItem(itemID);
253 return GetEffectivePermissions(
false);
263 uint ownerMask = 0x7fffffff;
266 for (
int i = 0; i < parts.Length; i++)
271 ownerMask &= part.BaseMask;
273 ownerMask &= part.OwnerMask;
275 perms &= part.Inventory.MaskEffectivePermissions();
278 if ((ownerMask & (uint)PermissionMask.Modify) == 0)
280 if ((ownerMask & (uint)PermissionMask.Copy) == 0)
282 if ((ownerMask & (uint)PermissionMask.Transfer) == 0)
304 for (
int i = 0; i < parts.Length; i++)
305 parts[i].ApplyNextOwnerPermissions();
310 Dictionary<UUID, string> states =
new Dictionary<UUID, string>();
313 for (
int i = 0; i < parts.Length; i++)
316 foreach (KeyValuePair<UUID, string> s
in part.Inventory.GetScriptStates())
317 states[s.Key] = s.Value;
320 if (states.Count < 1)
323 XmlDocument xmldoc =
new XmlDocument();
325 XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration,
326 String.Empty, String.Empty);
328 xmldoc.AppendChild(xmlnode);
329 XmlElement rootElement = xmldoc.CreateElement(
"",
"ScriptData",
332 xmldoc.AppendChild(rootElement);
335 XmlElement wrapper = xmldoc.CreateElement(
"",
"ScriptStates",
338 rootElement.AppendChild(wrapper);
340 foreach (KeyValuePair<UUID, string> state
in states)
342 XmlDocument sdoc =
new XmlDocument();
343 sdoc.LoadXml(state.Value);
344 XmlNodeList rootL = sdoc.GetElementsByTagName(
"State");
345 XmlNode rootNode = rootL[0];
347 XmlNode newNode = xmldoc.ImportNode(rootNode,
true);
348 wrapper.AppendChild(newNode);
351 return xmldoc.InnerXml;
359 Scene s = (Scene)ins;
361 if (objXMLData ==
String.Empty)
370 else if (scriptModule == null)
374 if (scriptModule == null)
377 XmlDocument doc =
new XmlDocument();
380 doc.LoadXml(objXMLData);
393 XmlNodeList rootL = doc.GetElementsByTagName(
"ScriptData");
394 if (rootL.Count != 1)
397 XmlElement rootE = (XmlElement)rootL[0];
399 XmlNodeList dataL = rootE.GetElementsByTagName(
"ScriptStates");
400 if (dataL.Count != 1)
403 XmlElement dataE = (XmlElement)dataL[0];
405 foreach (XmlNode n
in dataE.ChildNodes)
407 XmlElement stateE = (XmlElement)n;
408 UUID itemID =
new UUID(stateE.GetAttribute(
"UUID"));
410 scriptModule.SetXMLState(itemID, n.OuterXml);
416 if (m_scene.RegionInfo.RegionSettings.DisableScripts)
420 for (
int i = 0; i < parts.Length; i++)
421 parts[i].Inventory.ResumeScripts();
uint GetEffectivePermissions()
IEntityInventory Inventory
This part's inventory
bool UpdateInventoryItem(TaskInventoryItem item)
Update an existing inventory item.
void ApplyNextOwnerPermissions()
bool ContainsScripts()
Returns true if any part in the scene object contains scripts, false otherwise.
int CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource)
Start the scripts contained in all the prims in this group.
bool AddInventoryItem(UUID agentID, uint localID, InventoryItemBase item, UUID copyItemID)
Add an inventory item from a user's inventory to a prim in this scene object.
bool ContainsScripts()
Returns true if this inventory contains any scripts
SceneObjectPart Copy(uint plocalID, UUID AgentID, UUID GroupID, int linkNum, bool userExposed)
Duplicates this part.
void RemoveScriptInstances(bool sceneObjectBeingDeleted)
Stop and remove the scripts contained in all the prims in this group
void SetState(string objXMLData, IScene ins)
Represents an item in a task inventory
OpenSim.Framework.PermissionMask PermissionMask
Inventory Item - contains all the properties associated with an individual inventory piece...
string GetStateSnapshot()
TaskInventoryItem GetInventoryItem(uint primID, UUID itemID)
Returns an existing inventory item. Returns the original, so any changes will be live.
UUID ID
A UUID containing the ID for the inventory node itself
uint GetEffectivePermissions(bool useBase)
int RemoveInventoryItem(uint localID, UUID itemID)
void ForceInventoryPersistence()
Force all task inventories of prims in the scene object to persist
void StopScriptInstances()
Stop the scripts contained in all the prims in this group