1
0

InventoryItemBase.cs 10 KB

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