1
0

TaskInventoryItem.cs 8.8 KB

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