InventoryItemBase.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  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. /// Inventory Item - contains all the properties associated with an individual inventory piece.
  33. /// </summary>
  34. public class InventoryItemBase : InventoryNodeBase, ICloneable
  35. {
  36. public static readonly string SUITCASE_FOLDER_NAME = "My Suitcase";
  37. public static readonly sbyte SUITCASE_FOLDER_TYPE = 100;
  38. public static readonly sbyte SUITCASE_FOLDER_FAKE_TYPE = 8;
  39. /// <value>
  40. /// The inventory type of the item. This is slightly different from the asset type in some situations.
  41. /// </value>
  42. public int InvType
  43. {
  44. get
  45. {
  46. return m_invType;
  47. }
  48. set
  49. {
  50. m_invType = value;
  51. }
  52. }
  53. protected int m_invType;
  54. /// <value>
  55. /// The folder this item is contained in
  56. /// </value>
  57. public UUID Folder
  58. {
  59. get
  60. {
  61. return m_folder;
  62. }
  63. set
  64. {
  65. m_folder = value;
  66. }
  67. }
  68. protected UUID m_folder;
  69. /// <value>
  70. /// The creator of this item
  71. /// </value>
  72. public string CreatorId
  73. {
  74. get
  75. {
  76. return m_creatorId;
  77. }
  78. set
  79. {
  80. m_creatorId = value;
  81. if ((m_creatorId == null) || !UUID.TryParse(m_creatorId, out m_creatorIdAsUuid))
  82. m_creatorIdAsUuid = UUID.Zero;
  83. }
  84. }
  85. protected string m_creatorId;
  86. /// <value>
  87. /// The CreatorId expressed as a UUID.
  88. /// </value>
  89. public UUID CreatorIdAsUuid
  90. {
  91. get
  92. {
  93. if (UUID.Zero == m_creatorIdAsUuid)
  94. {
  95. UUID.TryParse(CreatorId, out m_creatorIdAsUuid);
  96. }
  97. return m_creatorIdAsUuid;
  98. }
  99. }
  100. protected UUID m_creatorIdAsUuid = UUID.Zero;
  101. /// <summary>
  102. /// Extended creator information of the form <profile url>;<name>
  103. /// </summary>
  104. public string CreatorData // = <profile url>;<name>
  105. {
  106. get { return m_creatorData; }
  107. set { m_creatorData = value; }
  108. }
  109. protected string m_creatorData = string.Empty;
  110. /// <summary>
  111. /// Used by the DB layer to retrieve / store the entire user identification.
  112. /// The identification can either be a simple UUID or a string of the form
  113. /// uuid[;profile_url[;name]]
  114. /// </summary>
  115. public string CreatorIdentification
  116. {
  117. get
  118. {
  119. if (!string.IsNullOrEmpty(m_creatorData))
  120. return m_creatorId + ';' + m_creatorData;
  121. else
  122. return m_creatorId;
  123. }
  124. set
  125. {
  126. if ((value == null) || (value != null && value == string.Empty))
  127. {
  128. m_creatorData = string.Empty;
  129. return;
  130. }
  131. if (!value.Contains(";")) // plain UUID
  132. {
  133. m_creatorId = value;
  134. }
  135. else // <uuid>[;<endpoint>[;name]]
  136. {
  137. string name = "Unknown User";
  138. string[] parts = value.Split(';');
  139. if (parts.Length >= 1)
  140. m_creatorId = parts[0];
  141. if (parts.Length >= 2)
  142. m_creatorData = parts[1];
  143. if (parts.Length >= 3)
  144. name = parts[2];
  145. m_creatorData += ';' + name;
  146. }
  147. }
  148. }
  149. /// <value>
  150. /// The description of the inventory item (must be less than 64 characters)
  151. /// </value>
  152. public string Description
  153. {
  154. get
  155. {
  156. return m_description;
  157. }
  158. set
  159. {
  160. m_description = value;
  161. }
  162. }
  163. protected string m_description = String.Empty;
  164. /// <value>
  165. ///
  166. /// </value>
  167. public uint NextPermissions
  168. {
  169. get
  170. {
  171. return m_nextPermissions;
  172. }
  173. set
  174. {
  175. m_nextPermissions = value;
  176. }
  177. }
  178. protected uint m_nextPermissions;
  179. /// <value>
  180. /// A mask containing permissions for the current owner (cannot be enforced)
  181. /// </value>
  182. public uint CurrentPermissions
  183. {
  184. get
  185. {
  186. return m_currentPermissions;
  187. }
  188. set
  189. {
  190. m_currentPermissions = value;
  191. }
  192. }
  193. protected uint m_currentPermissions;
  194. /// <value>
  195. ///
  196. /// </value>
  197. public uint BasePermissions
  198. {
  199. get
  200. {
  201. return m_basePermissions;
  202. }
  203. set
  204. {
  205. m_basePermissions = value;
  206. }
  207. }
  208. protected uint m_basePermissions;
  209. /// <value>
  210. ///
  211. /// </value>
  212. public uint EveryOnePermissions
  213. {
  214. get
  215. {
  216. return m_everyonePermissions;
  217. }
  218. set
  219. {
  220. m_everyonePermissions = value;
  221. }
  222. }
  223. protected uint m_everyonePermissions;
  224. /// <value>
  225. ///
  226. /// </value>
  227. public uint GroupPermissions
  228. {
  229. get
  230. {
  231. return m_groupPermissions;
  232. }
  233. set
  234. {
  235. m_groupPermissions = value;
  236. }
  237. }
  238. protected uint m_groupPermissions;
  239. /// <value>
  240. /// This is an enumerated value determining the type of asset (eg Notecard, Sound, Object, etc)
  241. /// </value>
  242. public int AssetType
  243. {
  244. get
  245. {
  246. return m_assetType;
  247. }
  248. set
  249. {
  250. m_assetType = value;
  251. }
  252. }
  253. protected int m_assetType;
  254. /// <value>
  255. /// The UUID of the associated asset on the asset server
  256. /// </value>
  257. public UUID AssetID
  258. {
  259. get
  260. {
  261. return m_assetID;
  262. }
  263. set
  264. {
  265. m_assetID = value;
  266. }
  267. }
  268. protected UUID m_assetID;
  269. /// <value>
  270. ///
  271. /// </value>
  272. public UUID GroupID
  273. {
  274. get
  275. {
  276. return m_groupID;
  277. }
  278. set
  279. {
  280. m_groupID = value;
  281. }
  282. }
  283. protected UUID m_groupID;
  284. /// <value>
  285. ///
  286. /// </value>
  287. public bool GroupOwned
  288. {
  289. get
  290. {
  291. return m_groupOwned;
  292. }
  293. set
  294. {
  295. m_groupOwned = value;
  296. }
  297. }
  298. protected bool m_groupOwned;
  299. /// <value>
  300. ///
  301. /// </value>
  302. public int SalePrice
  303. {
  304. get
  305. {
  306. return m_salePrice;
  307. }
  308. set
  309. {
  310. m_salePrice = value;
  311. }
  312. }
  313. protected int m_salePrice;
  314. /// <value>
  315. ///
  316. /// </value>
  317. public byte SaleType
  318. {
  319. get
  320. {
  321. return m_saleType;
  322. }
  323. set
  324. {
  325. m_saleType = value;
  326. }
  327. }
  328. protected byte m_saleType;
  329. /// <value>
  330. ///
  331. /// </value>
  332. public uint Flags
  333. {
  334. get
  335. {
  336. return m_flags;
  337. }
  338. set
  339. {
  340. m_flags = value;
  341. }
  342. }
  343. protected uint m_flags;
  344. /// <value>
  345. ///
  346. /// </value>
  347. public int CreationDate
  348. {
  349. get
  350. {
  351. return m_creationDate;
  352. }
  353. set
  354. {
  355. m_creationDate = value;
  356. }
  357. }
  358. protected int m_creationDate = (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
  359. public InventoryItemBase()
  360. {
  361. }
  362. public InventoryItemBase(UUID id)
  363. {
  364. ID = id;
  365. }
  366. public InventoryItemBase(UUID id, UUID owner)
  367. {
  368. ID = id;
  369. Owner = owner;
  370. }
  371. public object Clone()
  372. {
  373. return MemberwiseClone();
  374. }
  375. }
  376. }