TaskInventoryItem.cs 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  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. /// <summary>
  41. /// Inventory types
  42. /// </summary>
  43. public static string[] InvTypes = new string[]
  44. {
  45. "texture",
  46. "sound",
  47. "calling_card",
  48. "landmark",
  49. String.Empty,
  50. String.Empty,
  51. "object",
  52. "notecard",
  53. String.Empty,
  54. String.Empty,
  55. "lsl_text",
  56. String.Empty,
  57. String.Empty,
  58. "bodypart",
  59. String.Empty,
  60. "snapshot",
  61. String.Empty,
  62. String.Empty,
  63. "wearable",
  64. "animation",
  65. "gesture"
  66. };
  67. /// <summary>
  68. /// Asset types
  69. /// </summary>
  70. public static string[] Types = new string[]
  71. {
  72. "texture",
  73. "sound",
  74. "callcard",
  75. "landmark",
  76. "clothing", // Deprecated
  77. "clothing",
  78. "object",
  79. "notecard",
  80. "category",
  81. "root",
  82. "lsltext",
  83. "lslbyte",
  84. "txtr_tga",
  85. "bodypart",
  86. "trash",
  87. "snapshot",
  88. "lstndfnd",
  89. "snd_wav",
  90. "img_tga",
  91. "jpeg",
  92. "animatn",
  93. "gesture"
  94. };
  95. private UUID _assetID = UUID.Zero;
  96. private uint _baseMask = FULL_MASK_PERMISSIONS_GENERAL;
  97. private uint _creationDate = 0;
  98. private UUID _creatorID = UUID.Zero;
  99. private string _description = String.Empty;
  100. private uint _everyoneMask = FULL_MASK_PERMISSIONS_GENERAL;
  101. private uint _flags = 0;
  102. private UUID _groupID = UUID.Zero;
  103. private uint _groupMask = FULL_MASK_PERMISSIONS_GENERAL;
  104. private int _invType = 0;
  105. private UUID _itemID = UUID.Zero;
  106. private UUID _lastOwnerID = UUID.Zero;
  107. private string _name = String.Empty;
  108. private uint _nextOwnerMask = FULL_MASK_PERMISSIONS_GENERAL;
  109. private UUID _ownerID = UUID.Zero;
  110. private uint _ownerMask = FULL_MASK_PERMISSIONS_GENERAL;
  111. private UUID _parentID = UUID.Zero; //parent folder id
  112. private UUID _parentPartID = UUID.Zero; // SceneObjectPart this is inside
  113. private UUID _permsGranter;
  114. private int _permsMask;
  115. private int _type = 0;
  116. private UUID _oldID;
  117. private bool _ownerChanged = false;
  118. public UUID AssetID {
  119. get {
  120. return _assetID;
  121. }
  122. set {
  123. _assetID = value;
  124. }
  125. }
  126. public uint BasePermissions {
  127. get {
  128. return _baseMask;
  129. }
  130. set {
  131. _baseMask = value;
  132. }
  133. }
  134. public uint CreationDate {
  135. get {
  136. return _creationDate;
  137. }
  138. set {
  139. _creationDate = value;
  140. }
  141. }
  142. public UUID CreatorID {
  143. get {
  144. return _creatorID;
  145. }
  146. set {
  147. _creatorID = value;
  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 LastOwnerID {
  215. get {
  216. return _lastOwnerID;
  217. }
  218. set {
  219. _lastOwnerID = value;
  220. }
  221. }
  222. public string Name {
  223. get {
  224. return _name;
  225. }
  226. set {
  227. _name = value;
  228. }
  229. }
  230. public uint NextPermissions {
  231. get {
  232. return _nextOwnerMask;
  233. }
  234. set {
  235. _nextOwnerMask = value;
  236. }
  237. }
  238. public UUID OwnerID {
  239. get {
  240. return _ownerID;
  241. }
  242. set {
  243. _ownerID = value;
  244. }
  245. }
  246. public uint CurrentPermissions {
  247. get {
  248. return _ownerMask;
  249. }
  250. set {
  251. _ownerMask = value;
  252. }
  253. }
  254. public UUID ParentID {
  255. get {
  256. return _parentID;
  257. }
  258. set {
  259. _parentID = value;
  260. }
  261. }
  262. public UUID ParentPartID {
  263. get {
  264. return _parentPartID;
  265. }
  266. set {
  267. _parentPartID = value;
  268. }
  269. }
  270. public UUID PermsGranter {
  271. get {
  272. return _permsGranter;
  273. }
  274. set {
  275. _permsGranter = value;
  276. }
  277. }
  278. public int PermsMask {
  279. get {
  280. return _permsMask;
  281. }
  282. set {
  283. _permsMask = value;
  284. }
  285. }
  286. public int Type {
  287. get {
  288. return _type;
  289. }
  290. set {
  291. _type = value;
  292. }
  293. }
  294. public bool OwnerChanged {
  295. get {
  296. return _ownerChanged;
  297. }
  298. set {
  299. _ownerChanged = value;
  300. }
  301. }
  302. // See ICloneable
  303. #region ICloneable Members
  304. public Object Clone()
  305. {
  306. return MemberwiseClone();
  307. }
  308. #endregion
  309. /// <summary>
  310. /// Reset the UUIDs for this item.
  311. /// </summary>
  312. /// <param name="partID">The new part ID to which this item belongs</param>
  313. public void ResetIDs(UUID partID)
  314. {
  315. _oldID = _itemID;
  316. _itemID = UUID.Random();
  317. _parentPartID = partID;
  318. _parentID = partID;
  319. }
  320. public TaskInventoryItem()
  321. {
  322. _creationDate = (uint)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
  323. }
  324. }
  325. }