InventoryItemBase.cs 11 KB

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