TaskInventoryItem.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  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 _creatorData = String.Empty;
  100. private string _description = String.Empty;
  101. private uint _everyoneMask = FULL_MASK_PERMISSIONS_GENERAL;
  102. private uint _flags = 0;
  103. private UUID _groupID = UUID.Zero;
  104. private uint _groupMask = FULL_MASK_PERMISSIONS_GENERAL;
  105. private int _invType = 0;
  106. private UUID _itemID = UUID.Zero;
  107. private UUID _lastOwnerID = UUID.Zero;
  108. private string _name = String.Empty;
  109. private uint _nextOwnerMask = FULL_MASK_PERMISSIONS_GENERAL;
  110. private UUID _ownerID = UUID.Zero;
  111. private uint _ownerMask = FULL_MASK_PERMISSIONS_GENERAL;
  112. private UUID _parentID = UUID.Zero; //parent folder id
  113. private UUID _parentPartID = UUID.Zero; // SceneObjectPart this is inside
  114. private UUID _permsGranter;
  115. private int _permsMask;
  116. private int _type = 0;
  117. private UUID _oldID;
  118. private bool _ownerChanged = false;
  119. public UUID AssetID {
  120. get {
  121. return _assetID;
  122. }
  123. set {
  124. _assetID = value;
  125. }
  126. }
  127. public uint BasePermissions {
  128. get {
  129. return _baseMask;
  130. }
  131. set {
  132. _baseMask = value;
  133. }
  134. }
  135. public uint CreationDate {
  136. get {
  137. return _creationDate;
  138. }
  139. set {
  140. _creationDate = value;
  141. }
  142. }
  143. public UUID CreatorID {
  144. get {
  145. return _creatorID;
  146. }
  147. set {
  148. _creatorID = value;
  149. }
  150. }
  151. public string CreatorData // = <profile url>;<name>
  152. {
  153. get { return _creatorData; }
  154. set { _creatorData = value; }
  155. }
  156. /// <summary>
  157. /// Used by the DB layer to retrieve / store the entire user identification.
  158. /// The identification can either be a simple UUID or a string of the form
  159. /// uuid[;profile_url[;name]]
  160. /// </summary>
  161. public string CreatorIdentification
  162. {
  163. get
  164. {
  165. if (_creatorData != null && _creatorData != string.Empty)
  166. return _creatorID.ToString() + ';' + _creatorData;
  167. else
  168. return _creatorID.ToString();
  169. }
  170. set
  171. {
  172. if ((value == null) || (value != null && value == string.Empty))
  173. {
  174. _creatorData = string.Empty;
  175. return;
  176. }
  177. if (!value.Contains(";")) // plain UUID
  178. {
  179. UUID uuid = UUID.Zero;
  180. UUID.TryParse(value, out uuid);
  181. _creatorID = uuid;
  182. }
  183. else // <uuid>[;<endpoint>[;name]]
  184. {
  185. string name = "Unknown User";
  186. string[] parts = value.Split(';');
  187. if (parts.Length >= 1)
  188. {
  189. UUID uuid = UUID.Zero;
  190. UUID.TryParse(parts[0], out uuid);
  191. _creatorID = uuid;
  192. }
  193. if (parts.Length >= 2)
  194. _creatorData = parts[1];
  195. if (parts.Length >= 3)
  196. name = parts[2];
  197. _creatorData += ';' + name;
  198. }
  199. }
  200. }
  201. public string Description {
  202. get {
  203. return _description;
  204. }
  205. set {
  206. _description = value;
  207. }
  208. }
  209. public uint EveryonePermissions {
  210. get {
  211. return _everyoneMask;
  212. }
  213. set {
  214. _everyoneMask = value;
  215. }
  216. }
  217. public uint Flags {
  218. get {
  219. return _flags;
  220. }
  221. set {
  222. _flags = value;
  223. }
  224. }
  225. public UUID GroupID {
  226. get {
  227. return _groupID;
  228. }
  229. set {
  230. _groupID = value;
  231. }
  232. }
  233. public uint GroupPermissions {
  234. get {
  235. return _groupMask;
  236. }
  237. set {
  238. _groupMask = value;
  239. }
  240. }
  241. public int InvType {
  242. get {
  243. return _invType;
  244. }
  245. set {
  246. _invType = value;
  247. }
  248. }
  249. public UUID ItemID {
  250. get {
  251. return _itemID;
  252. }
  253. set {
  254. _itemID = value;
  255. }
  256. }
  257. public UUID OldItemID {
  258. get {
  259. return _oldID;
  260. }
  261. set {
  262. _oldID = value;
  263. }
  264. }
  265. public UUID LastOwnerID {
  266. get {
  267. return _lastOwnerID;
  268. }
  269. set {
  270. _lastOwnerID = value;
  271. }
  272. }
  273. public string Name {
  274. get {
  275. return _name;
  276. }
  277. set {
  278. _name = value;
  279. }
  280. }
  281. public uint NextPermissions {
  282. get {
  283. return _nextOwnerMask;
  284. }
  285. set {
  286. _nextOwnerMask = value;
  287. }
  288. }
  289. public UUID OwnerID {
  290. get {
  291. return _ownerID;
  292. }
  293. set {
  294. _ownerID = value;
  295. }
  296. }
  297. public uint CurrentPermissions {
  298. get {
  299. return _ownerMask;
  300. }
  301. set {
  302. _ownerMask = value;
  303. }
  304. }
  305. public UUID ParentID {
  306. get {
  307. return _parentID;
  308. }
  309. set {
  310. _parentID = value;
  311. }
  312. }
  313. public UUID ParentPartID {
  314. get {
  315. return _parentPartID;
  316. }
  317. set {
  318. _parentPartID = value;
  319. }
  320. }
  321. public UUID PermsGranter {
  322. get {
  323. return _permsGranter;
  324. }
  325. set {
  326. _permsGranter = value;
  327. }
  328. }
  329. public int PermsMask {
  330. get {
  331. return _permsMask;
  332. }
  333. set {
  334. _permsMask = value;
  335. }
  336. }
  337. public int Type {
  338. get {
  339. return _type;
  340. }
  341. set {
  342. _type = value;
  343. }
  344. }
  345. public bool OwnerChanged {
  346. get {
  347. return _ownerChanged;
  348. }
  349. set {
  350. _ownerChanged = value;
  351. }
  352. }
  353. // See ICloneable
  354. #region ICloneable Members
  355. public Object Clone()
  356. {
  357. return MemberwiseClone();
  358. }
  359. #endregion
  360. /// <summary>
  361. /// Reset the UUIDs for this item.
  362. /// </summary>
  363. /// <param name="partID">The new part ID to which this item belongs</param>
  364. public void ResetIDs(UUID partID)
  365. {
  366. OldItemID = ItemID;
  367. ItemID = UUID.Random();
  368. ParentPartID = partID;
  369. ParentID = partID;
  370. }
  371. public TaskInventoryItem()
  372. {
  373. CreationDate = (uint)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
  374. }
  375. }
  376. }