1
0

TaskInventoryItem.cs 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  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. public UUID AssetID {
  118. get {
  119. return _assetID;
  120. }
  121. set {
  122. _assetID = value;
  123. }
  124. }
  125. public uint BasePermissions {
  126. get {
  127. return _baseMask;
  128. }
  129. set {
  130. _baseMask = value;
  131. }
  132. }
  133. public uint CreationDate {
  134. get {
  135. return _creationDate;
  136. }
  137. set {
  138. _creationDate = value;
  139. }
  140. }
  141. public UUID CreatorID {
  142. get {
  143. return _creatorID;
  144. }
  145. set {
  146. _creatorID = value;
  147. }
  148. }
  149. public string Description {
  150. get {
  151. return _description;
  152. }
  153. set {
  154. _description = value;
  155. }
  156. }
  157. public uint EveryonePermissions {
  158. get {
  159. return _everyoneMask;
  160. }
  161. set {
  162. _everyoneMask = value;
  163. }
  164. }
  165. public uint Flags {
  166. get {
  167. return _flags;
  168. }
  169. set {
  170. _flags = value;
  171. }
  172. }
  173. public UUID GroupID {
  174. get {
  175. return _groupID;
  176. }
  177. set {
  178. _groupID = value;
  179. }
  180. }
  181. public uint GroupPermissions {
  182. get {
  183. return _groupMask;
  184. }
  185. set {
  186. _groupMask = value;
  187. }
  188. }
  189. public int InvType {
  190. get {
  191. return _invType;
  192. }
  193. set {
  194. _invType = value;
  195. }
  196. }
  197. public UUID ItemID {
  198. get {
  199. return _itemID;
  200. }
  201. set {
  202. _itemID = value;
  203. }
  204. }
  205. public UUID OldItemID {
  206. get {
  207. return _oldID;
  208. }
  209. set {
  210. _oldID = value;
  211. }
  212. }
  213. public UUID LastOwnerID {
  214. get {
  215. return _lastOwnerID;
  216. }
  217. set {
  218. _lastOwnerID = value;
  219. }
  220. }
  221. public string Name {
  222. get {
  223. return _name;
  224. }
  225. set {
  226. _name = value;
  227. }
  228. }
  229. public uint NextPermissions {
  230. get {
  231. return _nextOwnerMask;
  232. }
  233. set {
  234. _nextOwnerMask = value;
  235. }
  236. }
  237. public UUID OwnerID {
  238. get {
  239. return _ownerID;
  240. }
  241. set {
  242. _ownerID = value;
  243. }
  244. }
  245. public uint CurrentPermissions {
  246. get {
  247. return _ownerMask;
  248. }
  249. set {
  250. _ownerMask = value;
  251. }
  252. }
  253. public UUID ParentID {
  254. get {
  255. return _parentID;
  256. }
  257. set {
  258. _parentID = value;
  259. }
  260. }
  261. public UUID ParentPartID {
  262. get {
  263. return _parentPartID;
  264. }
  265. set {
  266. _parentPartID = value;
  267. }
  268. }
  269. public UUID PermsGranter {
  270. get {
  271. return _permsGranter;
  272. }
  273. set {
  274. _permsGranter = value;
  275. }
  276. }
  277. public int PermsMask {
  278. get {
  279. return _permsMask;
  280. }
  281. set {
  282. _permsMask = value;
  283. }
  284. }
  285. public int Type {
  286. get {
  287. return _type;
  288. }
  289. set {
  290. _type = value;
  291. }
  292. }
  293. // See ICloneable
  294. #region ICloneable Members
  295. public Object Clone()
  296. {
  297. return MemberwiseClone();
  298. }
  299. #endregion
  300. /// <summary>
  301. /// Reset the UUIDs for this item.
  302. /// </summary>
  303. /// <param name="partID">The new part ID to which this item belongs</param>
  304. public void ResetIDs(UUID partID)
  305. {
  306. _oldID = _itemID;
  307. _itemID = UUID.Random();
  308. _parentPartID = partID;
  309. _parentID = partID;
  310. }
  311. public TaskInventoryItem()
  312. {
  313. _creationDate = (uint)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
  314. }
  315. }
  316. }