TaskInventoryItem.cs 9.9 KB

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