TaskInventoryItem.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  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;
  28. using System.Reflection;
  29. using log4net;
  30. using OpenMetaverse;
  31. namespace OpenSim.Framework
  32. {
  33. /// <summary>
  34. /// Represents an item in a task inventory
  35. /// </summary>
  36. public class TaskInventoryItem : ICloneable
  37. {
  38. // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  39. /// <summary>
  40. /// XXX This should really be factored out into some constants class.
  41. /// </summary>
  42. private const uint FULL_MASK_PERMISSIONS_GENERAL = 2147483647;
  43. private UUID _assetID = UUID.Zero;
  44. private uint _baseMask = FULL_MASK_PERMISSIONS_GENERAL;
  45. private uint _creationDate = 0;
  46. private UUID _creatorID = UUID.Zero;
  47. private string _creatorData = String.Empty;
  48. private string _description = String.Empty;
  49. private uint _everyoneMask = FULL_MASK_PERMISSIONS_GENERAL;
  50. private uint _flags = 0;
  51. private UUID _groupID = UUID.Zero;
  52. private uint _groupMask = FULL_MASK_PERMISSIONS_GENERAL;
  53. private int _invType = 0;
  54. private UUID _itemID = UUID.Zero;
  55. private UUID _lastOwnerID = UUID.Zero;
  56. private UUID _rezzerID = UUID.Zero;
  57. private string _name = String.Empty;
  58. private uint _nextOwnerMask = FULL_MASK_PERMISSIONS_GENERAL;
  59. private UUID _ownerID = UUID.Zero;
  60. private uint _ownerMask = FULL_MASK_PERMISSIONS_GENERAL;
  61. private UUID _parentID = UUID.Zero; //parent folder id
  62. private UUID _parentPartID = UUID.Zero; // SceneObjectPart this is inside
  63. private UUID _permsGranter;
  64. private int _permsMask;
  65. private int _type = 0;
  66. private UUID _oldID;
  67. private UUID _loadedID = UUID.Zero;
  68. private bool _ownerChanged = false;
  69. public UUID AssetID {
  70. get {
  71. return _assetID;
  72. }
  73. set {
  74. _assetID = value;
  75. }
  76. }
  77. public uint BasePermissions {
  78. get {
  79. return _baseMask;
  80. }
  81. set {
  82. _baseMask = value;
  83. }
  84. }
  85. public uint CreationDate {
  86. get {
  87. return _creationDate;
  88. }
  89. set {
  90. _creationDate = value;
  91. }
  92. }
  93. public UUID CreatorID {
  94. get {
  95. return _creatorID;
  96. }
  97. set {
  98. _creatorID = value;
  99. }
  100. }
  101. public string CreatorData // = <profile url>;<name>
  102. {
  103. get { return _creatorData; }
  104. set { _creatorData = value; }
  105. }
  106. /// <summary>
  107. /// Used by the DB layer to retrieve / store the entire user identification.
  108. /// The identification can either be a simple UUID or a string of the form
  109. /// uuid[;profile_url[;name]]
  110. /// </summary>
  111. public string CreatorIdentification
  112. {
  113. get
  114. {
  115. if (!string.IsNullOrEmpty(_creatorData))
  116. return _creatorID.ToString() + ';' + _creatorData;
  117. else
  118. return _creatorID.ToString();
  119. }
  120. set
  121. {
  122. if ((value == null) || (value != null && value == string.Empty))
  123. {
  124. _creatorData = string.Empty;
  125. return;
  126. }
  127. if (!value.Contains(";")) // plain UUID
  128. {
  129. UUID uuid = UUID.Zero;
  130. UUID.TryParse(value, out uuid);
  131. _creatorID = uuid;
  132. }
  133. else // <uuid>[;<endpoint>[;name]]
  134. {
  135. string name = "Unknown User";
  136. string[] parts = value.Split(';');
  137. if (parts.Length >= 1)
  138. {
  139. UUID uuid = UUID.Zero;
  140. UUID.TryParse(parts[0], out uuid);
  141. _creatorID = uuid;
  142. }
  143. if (parts.Length >= 2)
  144. _creatorData = parts[1];
  145. if (parts.Length >= 3)
  146. name = parts[2];
  147. _creatorData += ';' + name;
  148. }
  149. }
  150. }
  151. public string Description {
  152. get {
  153. return _description;
  154. }
  155. set {
  156. _description = value;
  157. }
  158. }
  159. public uint EveryonePermissions {
  160. get {
  161. return _everyoneMask;
  162. }
  163. set {
  164. _everyoneMask = value;
  165. }
  166. }
  167. public uint Flags {
  168. get {
  169. return _flags;
  170. }
  171. set {
  172. _flags = value;
  173. }
  174. }
  175. public UUID GroupID {
  176. get {
  177. return _groupID;
  178. }
  179. set {
  180. _groupID = value;
  181. }
  182. }
  183. public uint GroupPermissions {
  184. get {
  185. return _groupMask;
  186. }
  187. set {
  188. _groupMask = value;
  189. }
  190. }
  191. public int InvType {
  192. get {
  193. return _invType;
  194. }
  195. set {
  196. _invType = value;
  197. }
  198. }
  199. public UUID ItemID {
  200. get {
  201. return _itemID;
  202. }
  203. set {
  204. _itemID = value;
  205. }
  206. }
  207. public UUID OldItemID {
  208. get {
  209. return _oldID;
  210. }
  211. set {
  212. _oldID = value;
  213. }
  214. }
  215. public UUID LoadedItemID {
  216. get {
  217. return _loadedID;
  218. }
  219. set {
  220. _loadedID = value;
  221. }
  222. }
  223. public UUID LastOwnerID {
  224. get {
  225. return _lastOwnerID;
  226. }
  227. set {
  228. _lastOwnerID = value;
  229. }
  230. }
  231. public UUID RezzerID
  232. {
  233. get {
  234. return _rezzerID;
  235. }
  236. set {
  237. _rezzerID = value;
  238. }
  239. }
  240. public string Name {
  241. get {
  242. return _name;
  243. }
  244. set {
  245. _name = value;
  246. }
  247. }
  248. public uint NextPermissions {
  249. get {
  250. return _nextOwnerMask;
  251. }
  252. set {
  253. _nextOwnerMask = value;
  254. }
  255. }
  256. public UUID OwnerID {
  257. get {
  258. return _ownerID;
  259. }
  260. set {
  261. _ownerID = value;
  262. }
  263. }
  264. public uint CurrentPermissions {
  265. get {
  266. return _ownerMask;
  267. }
  268. set {
  269. _ownerMask = value;
  270. }
  271. }
  272. public UUID ParentID {
  273. get {
  274. return _parentID;
  275. }
  276. set {
  277. _parentID = value;
  278. }
  279. }
  280. public UUID ParentPartID {
  281. get {
  282. return _parentPartID;
  283. }
  284. set {
  285. _parentPartID = value;
  286. }
  287. }
  288. public UUID PermsGranter {
  289. get {
  290. return _permsGranter;
  291. }
  292. set {
  293. _permsGranter = value;
  294. }
  295. }
  296. public int PermsMask {
  297. get {
  298. return _permsMask;
  299. }
  300. set {
  301. _permsMask = value;
  302. }
  303. }
  304. public int Type {
  305. get {
  306. return _type;
  307. }
  308. set {
  309. _type = value;
  310. }
  311. }
  312. public bool OwnerChanged
  313. {
  314. get
  315. {
  316. return _ownerChanged;
  317. }
  318. set
  319. {
  320. _ownerChanged = value;
  321. // m_log.DebugFormat(
  322. // "[TASK INVENTORY ITEM]: Owner changed set {0} for {1} {2} owned by {3}",
  323. // _ownerChanged, Name, ItemID, OwnerID);
  324. }
  325. }
  326. /// <summary>
  327. /// This used ONLY during copy. It can't be relied on at other times!
  328. /// </summary>
  329. /// <remarks>
  330. /// For true script running status, use IEntityInventory.TryGetScriptInstanceRunning() for now.
  331. /// </remarks>
  332. public bool ScriptRunning { get; set; }
  333. // See ICloneable
  334. #region ICloneable Members
  335. public Object Clone()
  336. {
  337. return MemberwiseClone();
  338. }
  339. #endregion
  340. /// <summary>
  341. /// Reset the UUIDs for this item.
  342. /// </summary>
  343. /// <param name="partID">The new part ID to which this item belongs</param>
  344. public void ResetIDs(UUID partID)
  345. {
  346. LoadedItemID = OldItemID;
  347. OldItemID = ItemID;
  348. ItemID = UUID.Random();
  349. ParentPartID = partID;
  350. ParentID = partID;
  351. }
  352. public TaskInventoryItem()
  353. {
  354. ScriptRunning = true;
  355. CreationDate = (uint)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
  356. }
  357. }
  358. }