TaskInventoryItem.cs 11 KB

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