InventoryItemBase.cs 10 KB

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