TaskInventoryItem.cs 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  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 OpenSim 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.Collections.Generic;
  29. using System.Reflection;
  30. using System.Xml;
  31. using System.Xml.Schema;
  32. using System.Xml.Serialization;
  33. using OpenMetaverse;
  34. using log4net;
  35. namespace OpenSim.Framework
  36. {
  37. /// <summary>
  38. /// Represents an item in a task inventory
  39. /// </summary>
  40. public class TaskInventoryItem : ICloneable
  41. {
  42. /// <summary>
  43. /// XXX This should really be factored out into some constants class.
  44. /// </summary>
  45. private const uint FULL_MASK_PERMISSIONS_GENERAL = 2147483647;
  46. /// <summary>
  47. /// Inventory types
  48. /// </summary>
  49. public static string[] InvTypes = new string[]
  50. {
  51. "texture",
  52. "sound",
  53. "calling_card",
  54. "landmark",
  55. String.Empty,
  56. String.Empty,
  57. "object",
  58. "notecard",
  59. String.Empty,
  60. String.Empty,
  61. "lsl_text",
  62. String.Empty,
  63. String.Empty,
  64. "bodypart",
  65. String.Empty,
  66. "snapshot",
  67. String.Empty,
  68. String.Empty,
  69. "wearable",
  70. "animation",
  71. "gesture"
  72. };
  73. /// <summary>
  74. /// Asset types
  75. /// </summary>
  76. public static string[] Types = new string[]
  77. {
  78. "texture",
  79. "sound",
  80. "callcard",
  81. "landmark",
  82. "clothing", // Deprecated
  83. "clothing",
  84. "object",
  85. "notecard",
  86. "category",
  87. "root",
  88. "lsltext",
  89. "lslbyte",
  90. "txtr_tga",
  91. "bodypart",
  92. "trash",
  93. "snapshot",
  94. "lstndfnd",
  95. "snd_wav",
  96. "img_tga",
  97. "jpeg",
  98. "animatn",
  99. "gesture"
  100. };
  101. private UUID _assetID = UUID.Zero;
  102. private uint _baseMask = FULL_MASK_PERMISSIONS_GENERAL;
  103. private uint _creationDate = 0;
  104. private UUID _creatorID = UUID.Zero;
  105. private string _description = String.Empty;
  106. private uint _everyoneMask = FULL_MASK_PERMISSIONS_GENERAL;
  107. private uint _flags = 0;
  108. private UUID _groupID = UUID.Zero;
  109. private uint _groupMask = FULL_MASK_PERMISSIONS_GENERAL;
  110. private int _invType = 0;
  111. private UUID _itemID = UUID.Zero;
  112. private UUID _lastOwnerID = UUID.Zero;
  113. private string _name = String.Empty;
  114. private uint _nextOwnerMask = FULL_MASK_PERMISSIONS_GENERAL;
  115. private UUID _ownerID = UUID.Zero;
  116. private uint _ownerMask = FULL_MASK_PERMISSIONS_GENERAL;
  117. private UUID _parentID = UUID.Zero; //parent folder id
  118. private UUID _parentPartID = UUID.Zero; // SceneObjectPart this is inside
  119. private UUID _permsGranter;
  120. private int _permsMask;
  121. private int _type = 0;
  122. public UUID AssetID {
  123. get {
  124. return _assetID;
  125. }
  126. set {
  127. _assetID = value;
  128. }
  129. }
  130. public uint BasePermissions {
  131. get {
  132. return _baseMask;
  133. }
  134. set {
  135. _baseMask = value;
  136. }
  137. }
  138. public uint CreationDate {
  139. get {
  140. return _creationDate;
  141. }
  142. set {
  143. _creationDate = value;
  144. }
  145. }
  146. public UUID CreatorID {
  147. get {
  148. return _creatorID;
  149. }
  150. set {
  151. _creatorID = value;
  152. }
  153. }
  154. public string Description {
  155. get {
  156. return _description;
  157. }
  158. set {
  159. _description = value;
  160. }
  161. }
  162. public uint EveryonePermissions {
  163. get {
  164. return _everyoneMask;
  165. }
  166. set {
  167. _everyoneMask = value;
  168. }
  169. }
  170. public uint Flags {
  171. get {
  172. return _flags;
  173. }
  174. set {
  175. _flags = value;
  176. }
  177. }
  178. public UUID GroupID {
  179. get {
  180. return _groupID;
  181. }
  182. set {
  183. _groupID = value;
  184. }
  185. }
  186. public uint GroupPermissions {
  187. get {
  188. return _groupMask;
  189. }
  190. set {
  191. _groupMask = value;
  192. }
  193. }
  194. public int InvType {
  195. get {
  196. return _invType;
  197. }
  198. set {
  199. _invType = value;
  200. }
  201. }
  202. public UUID ItemID {
  203. get {
  204. return _itemID;
  205. }
  206. set {
  207. _itemID = value;
  208. }
  209. }
  210. public UUID LastOwnerID {
  211. get {
  212. return _lastOwnerID;
  213. }
  214. set {
  215. _lastOwnerID = value;
  216. }
  217. }
  218. public string Name {
  219. get {
  220. return _name;
  221. }
  222. set {
  223. _name = value;
  224. }
  225. }
  226. public uint NextPermissions {
  227. get {
  228. return _nextOwnerMask;
  229. }
  230. set {
  231. _nextOwnerMask = value;
  232. }
  233. }
  234. public UUID OwnerID {
  235. get {
  236. return _ownerID;
  237. }
  238. set {
  239. _ownerID = value;
  240. }
  241. }
  242. public uint CurrentPermissions {
  243. get {
  244. return _ownerMask;
  245. }
  246. set {
  247. _ownerMask = value;
  248. }
  249. }
  250. public UUID ParentID {
  251. get {
  252. return _parentID;
  253. }
  254. set {
  255. _parentID = value;
  256. }
  257. }
  258. public UUID ParentPartID {
  259. get {
  260. return _parentPartID;
  261. }
  262. set {
  263. _parentPartID = value;
  264. }
  265. }
  266. public UUID PermsGranter {
  267. get {
  268. return _permsGranter;
  269. }
  270. set {
  271. _permsGranter = value;
  272. }
  273. }
  274. public int PermsMask {
  275. get {
  276. return _permsMask;
  277. }
  278. set {
  279. _permsMask = value;
  280. }
  281. }
  282. public int Type {
  283. get {
  284. return _type;
  285. }
  286. set {
  287. _type = value;
  288. }
  289. }
  290. // See ICloneable
  291. #region ICloneable Members
  292. public Object Clone()
  293. {
  294. return MemberwiseClone();
  295. }
  296. #endregion
  297. /// <summary>
  298. /// Reset the UUIDs for this item.
  299. /// </summary>
  300. /// <param name="partID">The new part ID to which this item belongs</param>
  301. public void ResetIDs(UUID partID)
  302. {
  303. _itemID = UUID.Random();
  304. _parentPartID = partID;
  305. }
  306. public TaskInventoryItem()
  307. {
  308. _creationDate = (uint)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
  309. }
  310. }
  311. }