OpenSim
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
SceneObjectPartInventory.cs
Go to the documentation of this file.
1 /*
2  * Copyright (c) Contributors, http://opensimulator.org/
3  * See CONTRIBUTORS.TXT for a full list of copyright holders.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  * * Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * * Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * * Neither the name of the OpenSimulator Project nor the
13  * names of its contributors may be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19  * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 using System;
29 using System.Xml;
30 using System.IO;
31 using System.Collections.Generic;
32 using System.Collections;
33 using System.Reflection;
34 using System.Threading;
35 using OpenMetaverse;
36 using log4net;
37 using OpenSim.Framework;
38 using OpenSim.Region.Framework.Interfaces;
39 using OpenSim.Region.Framework.Scenes.Scripting;
40 using OpenSim.Region.Framework.Scenes.Serialization;
42 
43 namespace OpenSim.Region.Framework.Scenes
44 {
46  {
47  private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48 
49  private byte[] m_inventoryFileData = new byte[0];
50  private uint m_inventoryFileNameSerial = 0;
51  private bool m_inventoryPrivileged = false;
52  private object m_inventoryFileLock = new object();
53 
54  private Dictionary<UUID, ArrayList> m_scriptErrors = new Dictionary<UUID, ArrayList>();
55 
59  private SceneObjectPart m_part;
60 
65  protected uint m_inventorySerial = 0;
66 
71 
75  internal bool HasInventoryChanged;
76 
80  protected internal uint Serial
81  {
82  get { return m_inventorySerial; }
83  set { m_inventorySerial = value; }
84  }
85 
89  protected internal TaskInventoryDictionary Items
90  {
91  get {
92  return m_items;
93  }
94  set
95  {
96  m_items = value;
97  m_inventorySerial++;
98  QueryScriptStates();
99  }
100  }
101 
102  public int Count
103  {
104  get
105  {
106  lock (m_items)
107  return m_items.Count;
108  }
109  }
110 
118  {
119  m_part = part;
120  }
121 
126  {
127  HasInventoryChanged = true;
128  }
129 
139  public void ResetInventoryIDs()
140  {
141  if (null == m_part)
142  m_items.LockItemsForWrite(true);
143 
144  if (Items.Count == 0)
145  {
146  m_items.LockItemsForWrite(false);
147  return;
148  }
149 
150  IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values);
151  Items.Clear();
152 
153  foreach (TaskInventoryItem item in items)
154  {
155  item.ResetIDs(m_part.UUID);
156  Items.Add(item.ItemID, item);
157  }
158  m_items.LockItemsForWrite(false);
159  }
160 
161  public void ResetObjectID()
162  {
163  m_items.LockItemsForWrite(true);
164 
165  if (Items.Count == 0)
166  {
167  m_items.LockItemsForWrite(false);
168  return;
169  }
170 
171  IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values);
172  Items.Clear();
173 
174  foreach (TaskInventoryItem item in items)
175  {
176  item.ParentPartID = m_part.UUID;
177  item.ParentID = m_part.UUID;
178  Items.Add(item.ItemID, item);
179  }
180  m_items.LockItemsForWrite(false);
181  }
182 
187  public void ChangeInventoryOwner(UUID ownerId)
188  {
189  List<TaskInventoryItem> items = GetInventoryItems();
190 
191  if (items.Count == 0)
192  return;
193 
194  m_items.LockItemsForWrite(true);
195  HasInventoryChanged = true;
196  m_part.ParentGroup.HasGroupChanged = true;
197  foreach (TaskInventoryItem item in items)
198  {
199  if (ownerId != item.OwnerID)
200  item.LastOwnerID = item.OwnerID;
201 
202  item.OwnerID = ownerId;
203  item.PermsMask = 0;
204  item.PermsGranter = UUID.Zero;
205  item.OwnerChanged = true;
206  }
207  m_items.LockItemsForWrite(false);
208  }
209 
214  public void ChangeInventoryGroup(UUID groupID)
215  {
216  m_items.LockItemsForWrite(true);
217  if (0 == Items.Count)
218  {
219  m_items.LockItemsForWrite(false);
220  return;
221  }
222 
223  // Don't let this set the HasGroupChanged flag for attachments
224  // as this happens during rez and we don't want a new asset
225  // for each attachment each time
226  if (!m_part.ParentGroup.IsAttachment)
227  {
228  HasInventoryChanged = true;
229  m_part.ParentGroup.HasGroupChanged = true;
230  }
231 
232  IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values);
233  foreach (TaskInventoryItem item in items)
234  {
235  if (groupID != item.GroupID)
236  {
237  item.GroupID = groupID;
238  }
239  }
240  m_items.LockItemsForWrite(false);
241  }
242 
243  private void QueryScriptStates()
244  {
245  if (m_part == null || m_part.ParentGroup == null || m_part.ParentGroup.Scene == null)
246  return;
247 
248  Items.LockItemsForRead(true);
249  foreach (TaskInventoryItem item in Items.Values)
250  {
251  if (item.InvType == (int)InventoryType.LSL)
252  {
253  bool running;
254  if (TryGetScriptInstanceRunning(m_part.ParentGroup.Scene, item, out running))
255  item.ScriptRunning = running;
256  }
257  }
258 
259  Items.LockItemsForRead(false);
260  }
261 
262  public bool TryGetScriptInstanceRunning(UUID itemId, out bool running)
263  {
264  running = false;
265 
266  TaskInventoryItem item = GetInventoryItem(itemId);
267 
268  if (item == null)
269  return false;
270 
271  return TryGetScriptInstanceRunning(m_part.ParentGroup.Scene, item, out running);
272  }
273 
274  public static bool TryGetScriptInstanceRunning(Scene scene, TaskInventoryItem item, out bool running)
275  {
276  running = false;
277 
278  if (item.InvType != (int)InventoryType.LSL)
279  return false;
280 
281  IScriptModule[] engines = scene.RequestModuleInterfaces<IScriptModule>();
282  if (engines == null) // No engine at all
283  return false;
284 
285  foreach (IScriptModule e in engines)
286  {
287  if (e.HasScript(item.ItemID, out running))
288  return true;
289  }
290 
291  return false;
292  }
293 
294  public int CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource)
295  {
296  int scriptsValidForStarting = 0;
297 
298  List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL);
299  foreach (TaskInventoryItem item in scripts)
300  if (CreateScriptInstance(item, startParam, postOnRez, engine, stateSource))
301  scriptsValidForStarting++;
302 
303  return scriptsValidForStarting;
304  }
305 
306  public ArrayList GetScriptErrors(UUID itemID)
307  {
308  ArrayList ret = new ArrayList();
309 
310  IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>();
311 
312  foreach (IScriptModule e in engines)
313  {
314  if (e != null)
315  {
316  ArrayList errors = e.GetScriptErrors(itemID);
317  foreach (Object line in errors)
318  ret.Add(line);
319  }
320  }
321 
322  return ret;
323  }
324 
332  public void RemoveScriptInstances(bool sceneObjectBeingDeleted)
333  {
334  List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL);
335  foreach (TaskInventoryItem item in scripts)
336  {
337  RemoveScriptInstance(item.ItemID, sceneObjectBeingDeleted);
338  m_part.RemoveScriptEvents(item.ItemID);
339  }
340  }
341 
345  public void StopScriptInstances()
346  {
347  GetInventoryItems(InventoryType.LSL).ForEach(i => StopScriptInstance(i));
348  }
349 
355  public bool CreateScriptInstance(TaskInventoryItem item, int startParam, bool postOnRez, string engine, int stateSource)
356  {
357 // m_log.DebugFormat("[PRIM INVENTORY]: Starting script {0} {1} in prim {2} {3} in {4}",
358 // item.Name, item.ItemID, m_part.Name, m_part.UUID, m_part.ParentGroup.Scene.RegionInfo.RegionName);
359 
360  if (!m_part.ParentGroup.Scene.Permissions.CanRunScript(item.ItemID, m_part.UUID, item.OwnerID))
361  {
362  StoreScriptError(item.ItemID, "no permission");
363  return false;
364  }
365 
366  m_part.AddFlag(PrimFlags.Scripted);
367 
368  if (m_part.ParentGroup.Scene.RegionInfo.RegionSettings.DisableScripts)
369  return false;
370 
371  if (stateSource == 2 && // Prim crossing
372  m_part.ParentGroup.Scene.m_trustBinaries)
373  {
374  m_items.LockItemsForWrite(true);
375  m_items[item.ItemID].PermsMask = 0;
376  m_items[item.ItemID].PermsGranter = UUID.Zero;
377  m_items.LockItemsForWrite(false);
378  m_part.ParentGroup.Scene.EventManager.TriggerRezScript(
379  m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource);
380  StoreScriptErrors(item.ItemID, null);
381  m_part.ParentGroup.AddActiveScriptCount(1);
382  m_part.ScheduleFullUpdate();
383  return true;
384  }
385 
386  AssetBase asset = m_part.ParentGroup.Scene.AssetService.Get(item.AssetID.ToString());
387  if (null == asset)
388  {
389  string msg = String.Format("asset ID {0} could not be found", item.AssetID);
390  StoreScriptError(item.ItemID, msg);
391  m_log.ErrorFormat(
392  "[PRIM INVENTORY]: Couldn't start script {0}, {1} at {2} in {3} since asset ID {4} could not be found",
393  item.Name, item.ItemID, m_part.AbsolutePosition,
394  m_part.ParentGroup.Scene.RegionInfo.RegionName, item.AssetID);
395 
396  return false;
397  }
398  else
399  {
400  if (m_part.ParentGroup.m_savedScriptState != null)
401  item.OldItemID = RestoreSavedScriptState(item.LoadedItemID, item.OldItemID, item.ItemID);
402 
403  m_items.LockItemsForWrite(true);
404 
405  m_items[item.ItemID].OldItemID = item.OldItemID;
406  m_items[item.ItemID].PermsMask = 0;
407  m_items[item.ItemID].PermsGranter = UUID.Zero;
408 
409  m_items.LockItemsForWrite(false);
410 
411  string script = Utils.BytesToString(asset.Data);
412  m_part.ParentGroup.Scene.EventManager.TriggerRezScript(
413  m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource);
414  StoreScriptErrors(item.ItemID, null);
415  if (!item.ScriptRunning)
416  m_part.ParentGroup.Scene.EventManager.TriggerStopScript(
417  m_part.LocalId, item.ItemID);
418  m_part.ParentGroup.AddActiveScriptCount(1);
419  m_part.ScheduleFullUpdate();
420 
421  return true;
422  }
423  }
424 
425  private UUID RestoreSavedScriptState(UUID loadedID, UUID oldID, UUID newID)
426  {
427 // m_log.DebugFormat(
428 // "[PRIM INVENTORY]: Restoring scripted state for item {0}, oldID {1}, loadedID {2}",
429 // newID, oldID, loadedID);
430 
431  IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>();
432  if (engines.Length == 0) // No engine at all
433  return oldID;
434 
435  UUID stateID = oldID;
436  if (!m_part.ParentGroup.m_savedScriptState.ContainsKey(oldID))
437  stateID = loadedID;
438  if (m_part.ParentGroup.m_savedScriptState.ContainsKey(stateID))
439  {
440  XmlDocument doc = new XmlDocument();
441 
442  doc.LoadXml(m_part.ParentGroup.m_savedScriptState[stateID]);
443 
445  //
446  // Old objects will have <ScriptState><State> ...
447  // This format is XEngine ONLY
448  //
449  // New objects have <State Engine="...." ...><ScriptState>...
450  // This can be passed to any engine
451  //
452  XmlNode n = doc.SelectSingleNode("ScriptState");
453  if (n != null) // Old format data
454  {
455  XmlDocument newDoc = new XmlDocument();
456 
457  XmlElement rootN = newDoc.CreateElement("", "State", "");
458  XmlAttribute uuidA = newDoc.CreateAttribute("", "UUID", "");
459  uuidA.Value = stateID.ToString();
460  rootN.Attributes.Append(uuidA);
461  XmlAttribute engineA = newDoc.CreateAttribute("", "Engine", "");
462  engineA.Value = "XEngine";
463  rootN.Attributes.Append(engineA);
464 
465  newDoc.AppendChild(rootN);
466 
467  XmlNode stateN = newDoc.ImportNode(n, true);
468  rootN.AppendChild(stateN);
469 
470  // This created document has only the minimun data
471  // necessary for XEngine to parse it successfully
472 
473 // m_log.DebugFormat("[PRIM INVENTORY]: Adding legacy state {0} in {1}", stateID, newID);
474 
475  m_part.ParentGroup.m_savedScriptState[stateID] = newDoc.OuterXml;
476  }
477 
478  foreach (IScriptModule e in engines)
479  {
480  if (e != null)
481  {
482  if (e.SetXMLState(newID, m_part.ParentGroup.m_savedScriptState[stateID]))
483  break;
484  }
485  }
486 
487  m_part.ParentGroup.m_savedScriptState.Remove(stateID);
488  }
489 
490  return stateID;
491  }
492 
500  public bool CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource)
501  {
502  lock (m_scriptErrors)
503  {
504  // Indicate to CreateScriptInstanceInternal() we don't want it to wait for completion
505  m_scriptErrors.Remove(itemId);
506  }
507  CreateScriptInstanceInternal(itemId, startParam, postOnRez, engine, stateSource);
508  return true;
509  }
510 
511  private void CreateScriptInstanceInternal(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource)
512  {
513  m_items.LockItemsForRead(true);
514 
515  if (m_items.ContainsKey(itemId))
516  {
517  TaskInventoryItem it = m_items[itemId];
518  m_items.LockItemsForRead(false);
519 
520  CreateScriptInstance(it, startParam, postOnRez, engine, stateSource);
521  }
522  else
523  {
524  m_items.LockItemsForRead(false);
525  string msg = String.Format("couldn't be found for prim {0}, {1} at {2} in {3}", m_part.Name, m_part.UUID,
526  m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName);
527  StoreScriptError(itemId, msg);
528  m_log.ErrorFormat(
529  "[PRIM INVENTORY]: " +
530  "Couldn't start script with ID {0} since it {1}", itemId, msg);
531  }
532  }
533 
540  public ArrayList CreateScriptInstanceEr(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource)
541  {
542  ArrayList errors;
543 
544  // Indicate to CreateScriptInstanceInternal() we want it to
545  // post any compilation/loading error messages
546  lock (m_scriptErrors)
547  {
548  m_scriptErrors[itemId] = null;
549  }
550 
551  // Perform compilation/loading
552  CreateScriptInstanceInternal(itemId, startParam, postOnRez, engine, stateSource);
553 
554  // Wait for and retrieve any errors
555  lock (m_scriptErrors)
556  {
557  while ((errors = m_scriptErrors[itemId]) == null)
558  {
559  if (!System.Threading.Monitor.Wait(m_scriptErrors, 15000))
560  {
561  m_log.ErrorFormat(
562  "[PRIM INVENTORY]: " +
563  "timedout waiting for script {0} errors", itemId);
564  errors = m_scriptErrors[itemId];
565  if (errors == null)
566  {
567  errors = new ArrayList(1);
568  errors.Add("timedout waiting for errors");
569  }
570  break;
571  }
572  }
573  m_scriptErrors.Remove(itemId);
574  }
575  return errors;
576  }
577 
578  // Signal to CreateScriptInstanceEr() that compilation/loading is complete
579  private void StoreScriptErrors(UUID itemId, ArrayList errors)
580  {
581  lock (m_scriptErrors)
582  {
583  // If compilation/loading initiated via CreateScriptInstance(),
584  // it does not want the errors, so just get out
585  if (!m_scriptErrors.ContainsKey(itemId))
586  {
587  return;
588  }
589 
590  // Initiated via CreateScriptInstanceEr(), if we know what the
591  // errors are, save them and wake CreateScriptInstanceEr().
592  if (errors != null)
593  {
594  m_scriptErrors[itemId] = errors;
595  System.Threading.Monitor.PulseAll(m_scriptErrors);
596  return;
597  }
598  }
599 
600  // Initiated via CreateScriptInstanceEr() but we don't know what
601  // the errors are yet, so retrieve them from the script engine.
602  // This may involve some waiting internal to GetScriptErrors().
603  errors = GetScriptErrors(itemId);
604 
605  // Get a default non-null value to indicate success.
606  if (errors == null)
607  {
608  errors = new ArrayList();
609  }
610 
611  // Post to CreateScriptInstanceEr() and wake it up
612  lock (m_scriptErrors)
613  {
614  m_scriptErrors[itemId] = errors;
615  System.Threading.Monitor.PulseAll(m_scriptErrors);
616  }
617  }
618 
619  // Like StoreScriptErrors(), but just posts a single string message
620  private void StoreScriptError(UUID itemId, string message)
621  {
622  ArrayList errors = new ArrayList(1);
623  errors.Add(message);
624  StoreScriptErrors(itemId, errors);
625  }
626 
635  public void RemoveScriptInstance(UUID itemId, bool sceneObjectBeingDeleted)
636  {
637  if (m_items.ContainsKey(itemId))
638  {
639  if (!sceneObjectBeingDeleted)
640  m_part.RemoveScriptEvents(itemId);
641 
642  m_part.ParentGroup.Scene.EventManager.TriggerRemoveScript(m_part.LocalId, itemId);
643  m_part.ParentGroup.AddActiveScriptCount(-1);
644  }
645  else
646  {
647  m_log.WarnFormat(
648  "[PRIM INVENTORY]: " +
649  "Couldn't stop script with ID {0} since it couldn't be found for prim {1}, {2} at {3} in {4}",
650  itemId, m_part.Name, m_part.UUID,
651  m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName);
652  }
653  }
654 
663  public void StopScriptInstance(UUID itemId)
664  {
665  TaskInventoryItem scriptItem;
666 
667  lock (m_items)
668  m_items.TryGetValue(itemId, out scriptItem);
669 
670  if (scriptItem != null)
671  {
672  StopScriptInstance(scriptItem);
673  }
674  else
675  {
676  m_log.WarnFormat(
677  "[PRIM INVENTORY]: " +
678  "Couldn't stop script with ID {0} since it couldn't be found for prim {1}, {2} at {3} in {4}",
679  itemId, m_part.Name, m_part.UUID,
680  m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName);
681  }
682  }
683 
693  {
694  if (m_part.ParentGroup.Scene != null)
695  m_part.ParentGroup.Scene.EventManager.TriggerStopScript(m_part.LocalId, item.ItemID);
696 
697  // At the moment, even stopped scripts are counted as active, which is probably wrong.
698 // m_part.ParentGroup.AddActiveScriptCount(-1);
699  }
700 
706  private bool InventoryContainsName(string name)
707  {
708  m_items.LockItemsForRead(true);
709  foreach (TaskInventoryItem item in m_items.Values)
710  {
711  if (item.Name == name)
712  {
713  m_items.LockItemsForRead(false);
714  return true;
715  }
716  }
717  m_items.LockItemsForRead(false);
718  return false;
719  }
720 
727  private string FindAvailableInventoryName(string name)
728  {
729  if (!InventoryContainsName(name))
730  return name;
731 
732  int suffix=1;
733  while (suffix < 256)
734  {
735  string tryName=String.Format("{0} {1}", name, suffix);
736  if (!InventoryContainsName(tryName))
737  return tryName;
738  suffix++;
739  }
740  return String.Empty;
741  }
742 
748  public void AddInventoryItem(TaskInventoryItem item, bool allowedDrop)
749  {
750  AddInventoryItem(item.Name, item, allowedDrop);
751  }
752 
757  public void AddInventoryItemExclusive(TaskInventoryItem item, bool allowedDrop)
758  {
759  m_items.LockItemsForRead(true);
760  List<TaskInventoryItem> il = new List<TaskInventoryItem>(m_items.Values);
761  m_items.LockItemsForRead(false);
762  foreach (TaskInventoryItem i in il)
763  {
764  if (i.Name == item.Name)
765  {
766  if (i.InvType == (int)InventoryType.LSL)
767  RemoveScriptInstance(i.ItemID, false);
768 
770  break;
771  }
772  }
773 
774  AddInventoryItem(item.Name, item, allowedDrop);
775  }
776 
788  protected void AddInventoryItem(string name, TaskInventoryItem item, bool allowedDrop)
789  {
790  name = FindAvailableInventoryName(name);
791  if (name == String.Empty)
792  return;
793 
794  item.ParentID = m_part.UUID;
795  item.ParentPartID = m_part.UUID;
796  item.Name = name;
797  item.GroupID = m_part.GroupID;
798 
799  m_items.LockItemsForWrite(true);
800  m_items.Add(item.ItemID, item);
801  m_items.LockItemsForWrite(false);
802  if (allowedDrop)
803  m_part.TriggerScriptChangedEvent(Changed.ALLOWED_DROP);
804  else
805  m_part.TriggerScriptChangedEvent(Changed.INVENTORY);
806 
807  m_inventorySerial++;
808  //m_inventorySerial += 2;
809  HasInventoryChanged = true;
810  m_part.ParentGroup.HasGroupChanged = true;
811  }
812 
820  public void RestoreInventoryItems(ICollection<TaskInventoryItem> items)
821  {
822  m_items.LockItemsForWrite(true);
823  foreach (TaskInventoryItem item in items)
824  {
825  m_items.Add(item.ItemID, item);
826 // m_part.TriggerScriptChangedEvent(Changed.INVENTORY);
827  }
828  m_items.LockItemsForWrite(false);
829 
830  m_inventorySerial++;
831  }
832 
839  {
840  TaskInventoryItem item;
841  m_items.LockItemsForRead(true);
842  m_items.TryGetValue(itemId, out item);
843  m_items.LockItemsForRead(false);
844  return item;
845  }
846 
848  {
849  m_items.LockItemsForRead(true);
850  foreach (TaskInventoryItem item in m_items.Values)
851  {
852  if (item.Name == name)
853  {
854  m_items.LockItemsForRead(false);
855  return item;
856  }
857  }
858  m_items.LockItemsForRead(false);
859 
860  return null;
861  }
862 
863  public List<TaskInventoryItem> GetInventoryItems(string name)
864  {
865  List<TaskInventoryItem> items = new List<TaskInventoryItem>();
866 
867  m_items.LockItemsForRead(true);
868 
869  foreach (TaskInventoryItem item in m_items.Values)
870  {
871  if (item.Name == name)
872  items.Add(item);
873  }
874 
875  m_items.LockItemsForRead(false);
876 
877  return items;
878  }
879 
880  public bool GetRezReadySceneObjects(TaskInventoryItem item, out List<SceneObjectGroup> objlist, out List<Vector3> veclist, out Vector3 bbox, out float offsetHeight)
881  {
882  AssetBase rezAsset = m_part.ParentGroup.Scene.AssetService.Get(item.AssetID.ToString());
883 
884  if (null == rezAsset)
885  {
886  m_log.WarnFormat(
887  "[PRIM INVENTORY]: Could not find asset {0} for inventory item {1} in {2}",
888  item.AssetID, item.Name, m_part.Name);
889  objlist = null;
890  veclist = null;
891  bbox = Vector3.Zero;
892  offsetHeight = 0;
893  return false;
894  }
895 
896  bool single = m_part.ParentGroup.Scene.GetObjectsToRez(rezAsset.Data, false, out objlist, out veclist, out bbox, out offsetHeight);
897 
898  for (int i = 0; i < objlist.Count; i++)
899  {
900  SceneObjectGroup group = objlist[i];
901 /*
902  group.RootPart.AttachPoint = group.RootPart.Shape.State;
903  group.RootPart.AttachedPos = group.AbsolutePosition;
904  group.RootPart.AttachRotation = group.GroupRotation;
905 */
906  group.ResetIDs();
907 
908  SceneObjectPart rootPart = group.GetPart(group.UUID);
909 
910  // Since renaming the item in the inventory does not affect the name stored
911  // in the serialization, transfer the correct name from the inventory to the
912  // object itself before we rez.
913  // Only do these for the first object if we are rezzing a coalescence.
914  // nahh dont mess with coalescence objects,
915  // the name in inventory can be change for inventory purpuses only
916  if (objlist.Count == 1)
917  {
918  rootPart.Name = item.Name;
919  rootPart.Description = item.Description;
920  }
921 /* reverted to old code till part.ApplyPermissionsOnRez is better reviewed/fixed
922  group.SetGroup(m_part.GroupID, null);
923 
924  foreach (SceneObjectPart part in group.Parts)
925  {
926  // Convert between InventoryItem classes. You can never have too many similar but slightly different classes :)
927  InventoryItemBase dest = new InventoryItemBase(item.ItemID, item.OwnerID);
928  dest.BasePermissions = item.BasePermissions;
929  dest.CurrentPermissions = item.CurrentPermissions;
930  dest.EveryOnePermissions = item.EveryonePermissions;
931  dest.GroupPermissions = item.GroupPermissions;
932  dest.NextPermissions = item.NextPermissions;
933  dest.Flags = item.Flags;
934 
935  part.ApplyPermissionsOnRez(dest, false, m_part.ParentGroup.Scene);
936  }
937 */
938 // old code start
939  SceneObjectPart[] partList = group.Parts;
940 
941  group.SetGroup(m_part.GroupID, null);
942 
943  // TODO: Remove magic number badness
944  if ((rootPart.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0 || (item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0) // Magic number
945  {
946  if (m_part.ParentGroup.Scene.Permissions.PropagatePermissions())
947  {
948  foreach (SceneObjectPart part in partList)
949  {
950  if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteEveryone) != 0)
951  part.EveryoneMask = item.EveryonePermissions;
952  if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteNextOwner) != 0)
953  part.NextOwnerMask = item.NextPermissions;
954  if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteGroup) != 0)
955  part.GroupMask = item.GroupPermissions;
956  }
957 
958  group.ApplyNextOwnerPermissions();
959  }
960  }
961 
962  foreach (SceneObjectPart part in partList)
963  {
964  // TODO: Remove magic number badness
965  if ((part.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0 || (item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0) // Magic number
966  {
967  part.LastOwnerID = part.OwnerID;
968  part.OwnerID = item.OwnerID;
969  part.Inventory.ChangeInventoryOwner(item.OwnerID);
970  }
971 
972  if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteEveryone) != 0)
973  part.EveryoneMask = item.EveryonePermissions;
974  if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteNextOwner) != 0)
975  part.NextOwnerMask = item.NextPermissions;
976  if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteGroup) != 0)
977  part.GroupMask = item.GroupPermissions;
978  }
979 // old code end
980  rootPart.TrimPermissions();
981  }
982 
983  return true;
984  }
985 
993  {
994  return UpdateInventoryItem(item, true, true);
995  }
996 
997  public bool UpdateInventoryItem(TaskInventoryItem item, bool fireScriptEvents)
998  {
999  return UpdateInventoryItem(item, fireScriptEvents, true);
1000  }
1001 
1002  public bool UpdateInventoryItem(TaskInventoryItem item, bool fireScriptEvents, bool considerChanged)
1003  {
1004  m_items.LockItemsForWrite(true);
1005 
1006  if (m_items.ContainsKey(item.ItemID))
1007  {
1008 // m_log.DebugFormat("[PRIM INVENTORY]: Updating item {0} in {1}", item.Name, m_part.Name);
1009 
1010  item.ParentID = m_part.UUID;
1011  item.ParentPartID = m_part.UUID;
1012 
1013  // If group permissions have been set on, check that the groupID is up to date in case it has
1014  // changed since permissions were last set.
1015  if (item.GroupPermissions != (uint)PermissionMask.None)
1016  item.GroupID = m_part.GroupID;
1017 
1018  if (item.AssetID == UUID.Zero)
1019  item.AssetID = m_items[item.ItemID].AssetID;
1020 
1021  m_items[item.ItemID] = item;
1022  m_inventorySerial++;
1023  if (fireScriptEvents)
1024  m_part.TriggerScriptChangedEvent(Changed.INVENTORY);
1025 
1026  if (considerChanged)
1027  {
1028  HasInventoryChanged = true;
1029  m_part.ParentGroup.HasGroupChanged = true;
1030  }
1031  m_items.LockItemsForWrite(false);
1032  return true;
1033  }
1034  else
1035  {
1036  m_log.ErrorFormat(
1037  "[PRIM INVENTORY]: " +
1038  "Tried to retrieve item ID {0} from prim {1}, {2} at {3} in {4} but the item does not exist in this inventory",
1039  item.ItemID, m_part.Name, m_part.UUID,
1040  m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName);
1041  }
1042  m_items.LockItemsForWrite(false);
1043 
1044  return false;
1045  }
1046 
1053  public int RemoveInventoryItem(UUID itemID)
1054  {
1055  m_items.LockItemsForRead(true);
1056 
1057  if (m_items.ContainsKey(itemID))
1058  {
1059  int type = m_items[itemID].InvType;
1060  m_items.LockItemsForRead(false);
1061  if (type == 10) // Script
1062  {
1063  m_part.ParentGroup.Scene.EventManager.TriggerRemoveScript(m_part.LocalId, itemID);
1064  }
1065  m_items.LockItemsForWrite(true);
1066  m_items.Remove(itemID);
1067  m_items.LockItemsForWrite(false);
1068  m_inventorySerial++;
1069  m_part.TriggerScriptChangedEvent(Changed.INVENTORY);
1070 
1071  HasInventoryChanged = true;
1072  m_part.ParentGroup.HasGroupChanged = true;
1073 
1074  int scriptcount = 0;
1075  m_items.LockItemsForRead(true);
1076  foreach (TaskInventoryItem item in m_items.Values)
1077  {
1078  if (item.Type == 10)
1079  {
1080  scriptcount++;
1081  }
1082  }
1083  m_items.LockItemsForRead(false);
1084 
1085 
1086  if (scriptcount <= 0)
1087  {
1088  m_part.RemFlag(PrimFlags.Scripted);
1089  }
1090 
1091  m_part.ScheduleFullUpdate();
1092 
1093  return type;
1094  }
1095  else
1096  {
1097  m_items.LockItemsForRead(false);
1098  m_log.ErrorFormat(
1099  "[PRIM INVENTORY]: " +
1100  "Tried to remove item ID {0} from prim {1}, {2} but the item does not exist in this inventory",
1101  itemID, m_part.Name, m_part.UUID);
1102  }
1103 
1104  return -1;
1105  }
1106 
1107 
1112  public void RequestInventoryFile(IClientAPI client, IXfer xferManager)
1113  {
1114 
1115  lock (m_inventoryFileLock)
1116  {
1117  string filename = "inventory_" + UUID.Random().ToString() + ".tmp";
1118 
1119  bool changed = false;
1120  if (m_inventoryFileNameSerial < m_inventorySerial)
1121  {
1122  m_inventoryFileNameSerial = m_inventorySerial;
1123  changed = true;
1124  }
1125 
1126  if (m_inventoryFileData.Length < 2)
1127  changed = true;
1128 
1129  bool includeAssets = false;
1130  if (m_part.ParentGroup.Scene.Permissions.CanEditObjectInventory(m_part.UUID, client.AgentId))
1131  includeAssets = true;
1132 
1133  if (m_inventoryPrivileged != includeAssets)
1134  changed = true;
1135 
1136 
1137  Items.LockItemsForRead(true);
1138 
1139  if (m_inventorySerial == 0) // No inventory
1140  {
1141  Items.LockItemsForRead(false);
1142  client.SendTaskInventory(m_part.UUID, 0, new byte[0]);
1143 
1144  return;
1145  }
1146 
1147  if (m_items.Count == 0) // No inventory
1148  {
1149  Items.LockItemsForRead(false);
1150  client.SendTaskInventory(m_part.UUID, 0, new byte[0]);
1151  return;
1152  }
1153 
1154  if (!changed)
1155  {
1156  Items.LockItemsForRead(false);
1157 
1158  xferManager.AddNewFile(filename,
1159  m_inventoryFileData);
1160  client.SendTaskInventory(m_part.UUID, (short)m_inventoryFileNameSerial,
1161  Util.StringToBytes256(filename));
1162 
1163  return;
1164  }
1165 
1166  m_inventoryPrivileged = includeAssets;
1167 
1168  InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero);
1169 
1170  foreach (TaskInventoryItem item in m_items.Values)
1171  {
1172  UUID ownerID = item.OwnerID;
1173  uint everyoneMask = 0;
1174  uint baseMask = item.BasePermissions;
1175  uint ownerMask = item.CurrentPermissions;
1176  uint groupMask = item.GroupPermissions;
1177 
1178  invString.AddItemStart();
1179  invString.AddNameValueLine("item_id", item.ItemID.ToString());
1180  invString.AddNameValueLine("parent_id", m_part.UUID.ToString());
1181 
1182  invString.AddPermissionsStart();
1183 
1184  invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask));
1185  invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask));
1186  invString.AddNameValueLine("group_mask", Utils.UIntToHexString(groupMask));
1187  invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask));
1188  invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions));
1189 
1190  invString.AddNameValueLine("creator_id", item.CreatorID.ToString());
1191  invString.AddNameValueLine("owner_id", ownerID.ToString());
1192 
1193  invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString());
1194 
1195  invString.AddNameValueLine("group_id", item.GroupID.ToString());
1196  invString.AddSectionEnd();
1197 
1198  if (includeAssets)
1199  invString.AddNameValueLine("asset_id", item.AssetID.ToString());
1200  else
1201  invString.AddNameValueLine("asset_id", UUID.Zero.ToString());
1202  invString.AddNameValueLine("type", Utils.AssetTypeToString((AssetType)item.Type));
1203  invString.AddNameValueLine("inv_type", Utils.InventoryTypeToString((InventoryType)item.InvType));
1204  invString.AddNameValueLine("flags", Utils.UIntToHexString(item.Flags));
1205 
1206  invString.AddSaleStart();
1207  invString.AddNameValueLine("sale_type", "not");
1208  invString.AddNameValueLine("sale_price", "0");
1209  invString.AddSectionEnd();
1210 
1211  invString.AddNameValueLine("name", item.Name + "|");
1212  invString.AddNameValueLine("desc", item.Description + "|");
1213 
1214  invString.AddNameValueLine("creation_date", item.CreationDate.ToString());
1215  invString.AddSectionEnd();
1216  }
1217 
1218  Items.LockItemsForRead(false);
1219 
1220  m_inventoryFileData = Utils.StringToBytes(invString.BuildString);
1221 
1222  if (m_inventoryFileData.Length > 2)
1223  {
1224  xferManager.AddNewFile(filename, m_inventoryFileData);
1225  client.SendTaskInventory(m_part.UUID, (short)m_inventoryFileNameSerial,
1226  Util.StringToBytes256(filename));
1227  return;
1228  }
1229 
1230  client.SendTaskInventory(m_part.UUID, 0, new byte[0]);
1231  }
1232  }
1233 
1239  {
1240 // Removed this because linking will cause an immediate delete of the new
1241 // child prim from the database and the subsequent storing of the prim sees
1242 // the inventory of it as unchanged and doesn't store it at all. The overhead
1243 // of storing prim inventory needlessly is much less than the aggravation
1244 // of prim inventory loss.
1245 // if (HasInventoryChanged)
1246 // {
1247  Items.LockItemsForRead(true);
1248  try
1249  {
1250  datastore.StorePrimInventory(m_part.UUID, Items.Values);
1251  }
1252  catch {}
1253 
1254  HasInventoryChanged = false;
1255 
1256  Items.LockItemsForRead(false);
1257 
1258 
1259 // }
1260  }
1261 
1263  {
1264  public string BuildString = String.Empty;
1265 
1266  public InventoryStringBuilder(UUID folderID, UUID parentID)
1267  {
1268  BuildString += "\tinv_object\t0\n\t{\n";
1269  AddNameValueLine("obj_id", folderID.ToString());
1270  AddNameValueLine("parent_id", parentID.ToString());
1271  AddNameValueLine("type", "category");
1272  AddNameValueLine("name", "Contents|");
1273  AddSectionEnd();
1274  }
1275 
1276  public void AddItemStart()
1277  {
1278  BuildString += "\tinv_item\t0\n";
1279  AddSectionStart();
1280  }
1281 
1282  public void AddPermissionsStart()
1283  {
1284  BuildString += "\tpermissions 0\n";
1285  AddSectionStart();
1286  }
1287 
1288  public void AddSaleStart()
1289  {
1290  BuildString += "\tsale_info\t0\n";
1291  AddSectionStart();
1292  }
1293 
1294  protected void AddSectionStart()
1295  {
1296  BuildString += "\t{\n";
1297  }
1298 
1299  public void AddSectionEnd()
1300  {
1301  BuildString += "\t}\n";
1302  }
1303 
1304  public void AddLine(string addLine)
1305  {
1306  BuildString += addLine;
1307  }
1308 
1309  public void AddNameValueLine(string name, string value)
1310  {
1311  BuildString += "\t\t";
1312  BuildString += name + "\t";
1313  BuildString += value + "\n";
1314  }
1315 
1316  public void Close()
1317  {
1318  }
1319  }
1320 
1322  {
1323  uint mask=0x7fffffff;
1324 
1325  foreach (TaskInventoryItem item in m_items.Values)
1326  {
1327  if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Copy) == 0)
1328  mask &= ~((uint)PermissionMask.Copy >> 13);
1329  if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Transfer) == 0)
1330  mask &= ~((uint)PermissionMask.Transfer >> 13);
1331  if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Modify) == 0)
1332  mask &= ~((uint)PermissionMask.Modify >> 13);
1333 
1334  if (item.InvType == (int)InventoryType.Object)
1335  {
1336  if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0)
1337  mask &= ~((uint)PermissionMask.Copy >> 13);
1338  if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0)
1339  mask &= ~((uint)PermissionMask.Transfer >> 13);
1340  if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0)
1341  mask &= ~((uint)PermissionMask.Modify >> 13);
1342  }
1343 
1344  if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0)
1345  mask &= ~(uint)PermissionMask.Copy;
1346  if ((item.CurrentPermissions & (uint)PermissionMask.Transfer) == 0)
1347  mask &= ~(uint)PermissionMask.Transfer;
1348  if ((item.CurrentPermissions & (uint)PermissionMask.Modify) == 0)
1349  mask &= ~(uint)PermissionMask.Modify;
1350  }
1351  return mask;
1352  }
1353 
1355  {
1356  foreach (TaskInventoryItem item in m_items.Values)
1357  {
1358  if (item.InvType == (int)InventoryType.Object && (item.CurrentPermissions & 7) != 0)
1359  {
1360  if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0)
1361  item.CurrentPermissions &= ~(uint)PermissionMask.Copy;
1362  if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0)
1363  item.CurrentPermissions &= ~(uint)PermissionMask.Transfer;
1364  if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0)
1365  item.CurrentPermissions &= ~(uint)PermissionMask.Modify;
1366  }
1367  item.CurrentPermissions &= item.NextPermissions;
1368  item.BasePermissions &= item.NextPermissions;
1369  item.EveryonePermissions &= item.NextPermissions;
1370  item.OwnerChanged = true;
1371  item.PermsMask = 0;
1372  item.PermsGranter = UUID.Zero;
1373  }
1374  }
1375 
1376  public void ApplyGodPermissions(uint perms)
1377  {
1378  foreach (TaskInventoryItem item in m_items.Values)
1379  {
1380  item.CurrentPermissions = perms;
1381  item.BasePermissions = perms;
1382  }
1383 
1384  m_inventorySerial++;
1385  HasInventoryChanged = true;
1386  }
1387 
1392  public bool ContainsScripts()
1393  {
1394  foreach (TaskInventoryItem item in m_items.Values)
1395  {
1396  if (item.InvType == (int)InventoryType.LSL)
1397  {
1398  return true;
1399  }
1400  }
1401 
1402  return false;
1403  }
1404 
1409  public int ScriptCount()
1410  {
1411  int count = 0;
1412  Items.LockItemsForRead(true);
1413  foreach (TaskInventoryItem item in m_items.Values)
1414  {
1415  if (item.InvType == (int)InventoryType.LSL)
1416  {
1417  count++;
1418  }
1419  }
1420  Items.LockItemsForRead(false);
1421  return count;
1422  }
1427  public int RunningScriptCount()
1428  {
1429  IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>();
1430  if (engines.Length == 0)
1431  return 0;
1432 
1433  int count = 0;
1434  List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL);
1435 
1436  foreach (TaskInventoryItem item in scripts)
1437  {
1438  foreach (IScriptModule engine in engines)
1439  {
1440  if (engine != null)
1441  {
1442  if (engine.GetScriptState(item.ItemID))
1443  {
1444  count++;
1445  }
1446  }
1447  }
1448  }
1449  return count;
1450  }
1451 
1452  public List<UUID> GetInventoryList()
1453  {
1454  List<UUID> ret = new List<UUID>();
1455 
1456  foreach (TaskInventoryItem item in m_items.Values)
1457  ret.Add(item.ItemID);
1458 
1459  return ret;
1460  }
1461 
1462  public List<TaskInventoryItem> GetInventoryItems()
1463  {
1464  List<TaskInventoryItem> ret = new List<TaskInventoryItem>();
1465 
1466  Items.LockItemsForRead(true);
1467  ret = new List<TaskInventoryItem>(m_items.Values);
1468  Items.LockItemsForRead(false);
1469 
1470  return ret;
1471  }
1472 
1473  public List<TaskInventoryItem> GetInventoryItems(InventoryType type)
1474  {
1475  List<TaskInventoryItem> ret = new List<TaskInventoryItem>();
1476 
1477  Items.LockItemsForRead(true);
1478 
1479  foreach (TaskInventoryItem item in m_items.Values)
1480  if (item.InvType == (int)type)
1481  ret.Add(item);
1482 
1483  Items.LockItemsForRead(false);
1484 
1485  return ret;
1486  }
1487 
1488  public Dictionary<UUID, string> GetScriptStates()
1489  {
1490  return GetScriptStates(false);
1491  }
1492 
1493  public Dictionary<UUID, string> GetScriptStates(bool oldIDs)
1494  {
1495  Dictionary<UUID, string> ret = new Dictionary<UUID, string>();
1496 
1497  if (m_part.ParentGroup.Scene == null) // Group not in a scene
1498  return ret;
1499 
1500  IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>();
1501 
1502  if (engines.Length == 0) // No engine at all
1503  return ret;
1504 
1505  List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL);
1506 
1507  foreach (TaskInventoryItem item in scripts)
1508  {
1509  foreach (IScriptModule e in engines)
1510  {
1511  if (e != null)
1512  {
1513 // m_log.DebugFormat(
1514 // "[PRIM INVENTORY]: Getting script state from engine {0} for {1} in part {2} in group {3} in {4}",
1515 // e.Name, item.Name, m_part.Name, m_part.ParentGroup.Name, m_part.ParentGroup.Scene.Name);
1516 
1517  string n = e.GetXMLState(item.ItemID);
1518  if (n != String.Empty)
1519  {
1520  if (oldIDs)
1521  {
1522  if (!ret.ContainsKey(item.OldItemID))
1523  ret[item.OldItemID] = n;
1524  }
1525  else
1526  {
1527  if (!ret.ContainsKey(item.ItemID))
1528  ret[item.ItemID] = n;
1529  }
1530  break;
1531  }
1532  }
1533  }
1534  }
1535  return ret;
1536  }
1537 
1538  public void ResumeScripts()
1539  {
1540  IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>();
1541  if (engines.Length == 0)
1542  return;
1543 
1544  List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL);
1545 
1546  foreach (TaskInventoryItem item in scripts)
1547  {
1548  foreach (IScriptModule engine in engines)
1549  {
1550  if (engine != null)
1551  {
1552 // m_log.DebugFormat(
1553 // "[PRIM INVENTORY]: Resuming script {0} {1} for {2}, OwnerChanged {3}",
1554 // item.Name, item.ItemID, item.OwnerID, item.OwnerChanged);
1555 
1556  engine.ResumeScript(item.ItemID);
1557 
1558  if (item.OwnerChanged)
1559  engine.PostScriptEvent(item.ItemID, "changed", new Object[] { (int)Changed.OWNER });
1560 
1561  item.OwnerChanged = false;
1562  }
1563  }
1564  }
1565  }
1566  }
1567 }
void RequestInventoryFile(IClientAPI client, IXfer xferManager)
Serialize all the metadata for the items in this prim's inventory ready for sending to the client ...
bool TryGetScriptInstanceRunning(UUID itemId, out bool running)
Try to get the script running status.
void ResetObjectID()
Reset parent object UUID for all the items in the prim's inventory.
bool SetXMLState(UUID itemID, string xml)
delegate void RemoveInventoryItem(IClientAPI remoteClient, List< UUID > itemIDs)
bool ScriptRunning
This used ONLY during copy. It can't be relied on at other times!
List< UUID > GetInventoryList()
Get the uuids of all items in this inventory
bool GetScriptState(UUID itemID)
Returns true if a script is running.
void ForceInventoryPersistence()
Force the task inventory of this prim to persist at the next update sweep
void ChangeInventoryOwner(UUID ownerId)
Change every item in this inventory to a new owner.
void AddInventoryItem(string name, TaskInventoryItem item, bool allowedDrop)
Add an item to this prim's inventory.
void StopScriptInstance(UUID itemId)
Stop a script which is in this prim's inventory.
A dictionary containing task inventory items. Indexed by item UUID.
void RestoreInventoryItems(ICollection< TaskInventoryItem > items)
Restore a whole collection of items to the prim's inventory at once. We assume that the items already...
A scene object group is conceptually an object in the scene. The object is constituted of SceneObject...
void AddInventoryItem(TaskInventoryItem item, bool allowedDrop)
Add an item to this prim's inventory. If an item with the same name already exists, then an alternative name is chosen.
Represents an item in a task inventory
int ScriptCount()
Returns the count of scripts in this parts inventory.
int CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource)
Start all the scripts contained in this entity's inventory
void RemoveScriptInstance(UUID itemId, bool sceneObjectBeingDeleted)
Stop and remove a script which is in this prim's inventory.
bool UpdateInventoryItem(TaskInventoryItem item, bool fireScriptEvents, bool considerChanged)
void StopScriptInstances()
Stop all the scripts in this prim.
Asset class. All Assets are reference by this class or a class derived from this class ...
Definition: AssetBase.cs:49
bool CreateScriptInstance(TaskInventoryItem item, int startParam, bool postOnRez, string engine, int stateSource)
Start a script which is in this prim's inventory.
bool GetRezReadySceneObjects(TaskInventoryItem item, out List< SceneObjectGroup > objlist, out List< Vector3 > veclist, out Vector3 bbox, out float offsetHeight)
Get the scene object(s) referenced by an inventory item.
List< TaskInventoryItem > GetInventoryItems(string name)
Get inventory items by name.
ArrayList CreateScriptInstanceEr(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource)
Start a script which is in this prim's inventory and return any compilation error messages...
void AddInventoryItemExclusive(TaskInventoryItem item, bool allowedDrop)
Add an item to this prim's inventory. If an item with the same name already exists, it is replaced.
void ProcessInventoryBackup(ISimulationDataService datastore)
Process inventory backup
void RemoveScriptInstances(bool sceneObjectBeingDeleted)
Stop and remove all the scripts in this prim.
delegate void UpdateInventoryItem(IClientAPI remoteClient, UUID transactionID, UUID itemID, InventoryItemBase itemUpd)
void ResetInventoryIDs()
Reset UUIDs for all the items in the prim's inventory.
List< TaskInventoryItem > GetInventoryItems(InventoryType type)
Get inventory items by type.
void StopScriptInstance(TaskInventoryItem item)
Stop a script which is in this prim's inventory.
TaskInventoryItem GetInventoryItem(string name)
Gets an inventory item by name
Dictionary< UUID, string > GetScriptStates()
Get the xml representing the saved states of scripts in this inventory.
int RemoveInventoryItem(UUID itemID)
Remove an item from this prim's inventory
OpenSim.Framework.PermissionMask PermissionMask
TaskInventoryItem GetInventoryItem(UUID itemId)
Returns an existing inventory item. Returns the original, so any changes will be live.
bool UpdateInventoryItem(TaskInventoryItem item)
Update an existing inventory item.
bool CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource)
Start a script which is in this prim's inventory. Some processing may occur in the background...
bool UpdateInventoryItem(TaskInventoryItem item, bool fireScriptEvents)
void ChangeInventoryGroup(UUID groupID)
Change every item in this inventory to a new group.
Interface to an entity's (SceneObjectPart's) inventory
int RunningScriptCount()
Returns the count of running scripts in this parts inventory.
bool HasScript(UUID itemID, out bool running)
static bool TryGetScriptInstanceRunning(Scene scene, TaskInventoryItem item, out bool running)
List< TaskInventoryItem > GetInventoryItems()
Get all inventory items.
bool ContainsScripts()
Returns true if this part inventory contains any scripts. False otherwise.