IEntityInventory.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  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. using System.Collections.Generic;
  28. using System.Collections;
  29. using OpenMetaverse;
  30. using OpenSim.Framework;
  31. using OpenSim.Region.Framework.Scenes;
  32. namespace OpenSim.Region.Framework.Interfaces
  33. {
  34. /// <summary>
  35. /// Interface to an entity's (SceneObjectPart's) inventory
  36. /// </summary>
  37. ///
  38. /// This is not a finished 1.0 candidate interface
  39. public interface IEntityInventory
  40. {
  41. /// <summary>
  42. /// Force the task inventory of this prim to persist at the next update sweep
  43. /// </summary>
  44. void ForceInventoryPersistence();
  45. /// <summary>
  46. /// Reset UUIDs for all the items in the prim's inventory.
  47. /// </summary>
  48. ///
  49. /// This involves either generating
  50. /// new ones or setting existing UUIDs to the correct parent UUIDs.
  51. ///
  52. /// If this method is called and there are inventory items, then we regard the inventory as having changed.
  53. ///
  54. /// <param name="linkNum">Link number for the part</param>
  55. void ResetInventoryIDs();
  56. /// <summary>
  57. /// Reset parent object UUID for all the items in the prim's inventory.
  58. /// </summary>
  59. ///
  60. /// If this method is called and there are inventory items, then we regard the inventory as having changed.
  61. ///
  62. /// <param name="linkNum">Link number for the part</param>
  63. void ResetObjectID();
  64. /// <summary>
  65. /// Change every item in this inventory to a new owner.
  66. /// </summary>
  67. /// <param name="ownerId"></param>
  68. void ChangeInventoryOwner(UUID ownerId);
  69. /// <summary>
  70. /// Change every item in this inventory to a new group.
  71. /// </summary>
  72. /// <param name="groupID"></param>
  73. void ChangeInventoryGroup(UUID groupID);
  74. /// <summary>
  75. /// Start all the scripts contained in this entity's inventory
  76. /// </summary>
  77. /// <param name="startParam"></param>
  78. /// <param name="postOnRez"></param>
  79. /// <param name="engine"></param>
  80. /// <param name="stateSource"></param>
  81. /// <returns>Number of scripts started.</returns>
  82. int CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource);
  83. ArrayList GetScriptErrors(UUID itemID);
  84. void ResumeScripts();
  85. /// <summary>
  86. /// Stop and remove all the scripts in this entity from the scene.
  87. /// </summary>
  88. /// <param name="sceneObjectBeingDeleted">
  89. /// Should be true if these scripts are being removed because the scene
  90. /// object is being deleted. This will prevent spurious updates to the client.
  91. /// </param>
  92. void RemoveScriptInstances(bool sceneObjectBeingDeleted);
  93. /// <summary>
  94. /// Stop all the scripts in this entity.
  95. /// </summary>
  96. void StopScriptInstances();
  97. void SendReleaseScriptsControl();
  98. void RemoveScriptsPermissions(int permissions);
  99. void RemoveScriptsPermissions(ScenePresence sp, int permissions);
  100. /// <summary>
  101. /// Start a script which is in this entity's inventory.
  102. /// </summary>
  103. /// <param name="item"></param>
  104. /// <param name="postOnRez"></param>
  105. /// <param name="engine"></param>
  106. /// <param name="stateSource"></param>
  107. /// <returns>
  108. /// true if the script instance was valid for starting, false otherwise. This does not guarantee
  109. /// that the script was actually started, just that the script was valid (i.e. its asset data could be found, etc.)
  110. /// </returns>
  111. bool CreateScriptInstance(TaskInventoryItem item, int startParam, bool postOnRez, string engine, int stateSource);
  112. /// <summary>
  113. /// Start a script which is in this entity's inventory.
  114. /// </summary>
  115. /// <param name="itemId"></param>
  116. /// <param name="startParam"></param>
  117. /// <param name="postOnRez"></param>
  118. /// <param name="engine"></param>
  119. /// <param name="stateSource"></param>
  120. /// <returns>
  121. /// true if the script instance was valid for starting, false otherwise. This does not guarantee
  122. /// that the script was actually started, just that the script was valid (i.e. its asset data could be found, etc.)
  123. /// </returns>
  124. bool CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource);
  125. ArrayList CreateScriptInstanceEr(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource);
  126. /// <summary>
  127. /// Stop and remove a script which is in this prim's inventory from the scene.
  128. /// </summary>
  129. /// <param name="itemId"></param>
  130. /// <param name="sceneObjectBeingDeleted">
  131. /// Should be true if these scripts are being removed because the scene
  132. /// object is being deleted. This will prevent spurious updates to the client.
  133. /// </param>
  134. void RemoveScriptInstance(UUID itemId, bool sceneObjectBeingDeleted);
  135. /// <summary>
  136. /// Stop a script which is in this prim's inventory.
  137. /// </summary>
  138. /// <param name="itemId"></param>
  139. void StopScriptInstance(UUID itemId);
  140. /// <summary>
  141. /// Try to get the script running status.
  142. /// </summary>
  143. /// <returns>
  144. /// Returns true if a script for the item was found in one of the simulator's script engines. In this case,
  145. /// the running parameter will reflect the running status.
  146. /// Returns false if the item could not be found, if the item is not a script or if a script instance for the
  147. /// item was not found in any of the script engines. In this case, running status is irrelevant.
  148. /// </returns>
  149. /// <param name='itemId'></param>
  150. /// <param name='running'></param>
  151. bool TryGetScriptInstanceRunning(UUID itemId, out bool running);
  152. /// <summary>
  153. /// Add an item to this entity's inventory. If an item with the same name already exists, then an alternative
  154. /// name is chosen.
  155. /// </summary>
  156. /// <param name="item"></param>
  157. void AddInventoryItem(TaskInventoryItem item, bool allowedDrop);
  158. /// <summary>
  159. /// Add an item to this entity's inventory. If an item with the same name already exists, it is replaced.
  160. /// </summary>
  161. /// <param name="item"></param>
  162. void AddInventoryItemExclusive(TaskInventoryItem item, bool allowedDrop);
  163. /// <summary>
  164. /// Restore a whole collection of items to the entity's inventory at once.
  165. /// We assume that the items already have all their fields correctly filled out.
  166. /// The items are not flagged for persistence to the database, since they are being restored
  167. /// from persistence rather than being newly added.
  168. /// </summary>
  169. /// <param name="items"></param>
  170. void RestoreInventoryItems(ICollection<TaskInventoryItem> items);
  171. /// <summary>
  172. /// Returns an existing inventory item. Returns the original, so any changes will be live.
  173. /// </summary>
  174. /// <param name="itemID"></param>
  175. /// <returns>null if the item does not exist</returns>
  176. TaskInventoryItem GetInventoryItem(UUID itemId);
  177. /// <summary>
  178. /// Get all inventory items.
  179. /// </summary>
  180. /// <param name="name"></param>
  181. /// <returns>
  182. /// If there are no inventory items then an empty list is returned.
  183. /// </returns>
  184. List<TaskInventoryItem> GetInventoryItems();
  185. /// <summary>
  186. /// Gets an inventory item by name
  187. /// </summary>
  188. /// <remarks>
  189. /// This method returns the first inventory item that matches the given name. In SL this is all you need
  190. /// since each item in a prim inventory must have a unique name.
  191. /// </remarks>
  192. /// <param name='name'></param>
  193. /// <returns>
  194. /// The inventory item. Null if no such item was found.
  195. /// </returns>
  196. TaskInventoryItem GetInventoryItem(string name);
  197. TaskInventoryItem GetInventoryItem(string name, int assetType);
  198. /// <summary>
  199. /// Get inventory items by name.
  200. /// </summary>
  201. /// <param name="name"></param>
  202. /// <returns>
  203. /// A list of inventory items with that name.
  204. /// If no inventory item has that name then an empty list is returned.
  205. /// </returns>
  206. List<TaskInventoryItem> GetInventoryItems(string name);
  207. /// <summary>
  208. /// Get inventory items by type.
  209. /// </summary>
  210. /// <param type="name"></param>
  211. /// <returns>
  212. /// A list of inventory items of that type.
  213. /// If no inventory items of that type then an empty list is returned.
  214. /// </returns>
  215. List<TaskInventoryItem> GetInventoryItems(InventoryType type);
  216. /// <summary>
  217. /// Get the scene object(s) referenced by an inventory item.
  218. /// </summary>
  219. ///
  220. /// This is returned in a 'rez ready' state. That is, name, description, permissions and other details have
  221. /// been adjusted to reflect the part and item from which it originates.
  222. ///
  223. /// <param name="item">Inventory item</param>
  224. /// <param name="objlist">The scene objects</param>
  225. /// <param name="veclist">Relative offsets for each object</param>
  226. /// <returns>true = success, false = the scene object asset couldn't be found</returns>
  227. bool GetRezReadySceneObjects(TaskInventoryItem item, out List<SceneObjectGroup> objlist, out List<Vector3> veclist, out Vector3 bbox, out float offsetHeight);
  228. bool GetRezReadySceneObjects(TaskInventoryItem item, UUID newOwner, UUID NewGroup, out List<SceneObjectGroup> objlist, out List<Vector3> veclist, out Vector3 bbox, out float offsetHeight);
  229. /// <summary>
  230. /// Update an existing inventory item.
  231. /// </summary>
  232. /// <param name="item">The updated item. An item with the same id must already exist
  233. /// in this prim's inventory.</param>
  234. /// <returns>false if the item did not exist, true if the update occurred successfully</returns>
  235. bool UpdateInventoryItem(TaskInventoryItem item);
  236. bool UpdateInventoryItem(TaskInventoryItem item, bool fireScriptEvents);
  237. bool UpdateInventoryItem(TaskInventoryItem item, bool fireScriptEvents, bool considerChanged);
  238. /// <summary>
  239. /// Remove an item from this entity's inventory
  240. /// </summary>
  241. /// <param name="itemID"></param>
  242. /// <returns>Numeric asset type of the item removed. Returns -1 if the item did not exist
  243. /// in this prim's inventory.</returns>
  244. int RemoveInventoryItem(UUID itemID);
  245. /// <summary>
  246. /// Serialize all the metadata for the items in this prim's inventory ready for sending to the client
  247. /// </summary>
  248. /// <param name="xferManager"></param>
  249. void RequestInventoryFile(IClientAPI client, IXfer xferManager);
  250. /// <summary>
  251. /// Backup the inventory to the given data store
  252. /// </summary>
  253. /// <param name="datastore"></param>
  254. void ProcessInventoryBackup(ISimulationDataService datastore);
  255. void AggregateInnerPerms(ref uint owner, ref uint group, ref uint everyone);
  256. uint MaskEffectivePermissions();
  257. void ApplyNextOwnerPermissions();
  258. void ApplyGodPermissions(uint perms);
  259. /// <summary>
  260. /// Number of items in this inventory.
  261. /// </summary>
  262. int Count { get; }
  263. /// <summary>
  264. /// Returns true if this inventory contains any scripts
  265. /// </summary></returns>
  266. bool ContainsScripts();
  267. /// <summary>
  268. /// Number of scripts in this inventory.
  269. /// </summary>
  270. /// <remarks>
  271. /// Includes both running and non running scripts.
  272. /// </remarks>
  273. int ScriptCount();
  274. /// <summary>
  275. /// Number of running scripts in this inventory.
  276. /// </summary></returns>
  277. int RunningScriptCount();
  278. /// <summary>
  279. /// Get the uuids of all items in this inventory
  280. /// </summary>
  281. /// <returns></returns>
  282. List<UUID> GetInventoryList();
  283. /// <summary>
  284. /// Get the xml representing the saved states of scripts in this inventory.
  285. /// </summary>
  286. /// <returns>
  287. /// A <see cref="Dictionary`2"/>
  288. /// </returns>
  289. Dictionary<UUID, string> GetScriptStates();
  290. Dictionary<UUID, string> GetScriptStates(bool oldIDs);
  291. }
  292. }