PageRenderTime 54ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 1ms

/OpenMetaverse/Modules/InventoryManager.cs

https://bitbucket.org/VirtualReality/3rdparty-addon-modules
C# | 4807 lines | 3114 code | 580 blank | 1113 comment | 501 complexity | 3547c5ae30eec944425933a7545fecd0 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. /*
  2. * Copyright (c) 2006-2008, openmetaverse.org
  3. * All rights reserved.
  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. *
  8. * - Redistributions of source code must retain the above copyright notice, this
  9. * list of conditions and the following disclaimer.
  10. * - Neither the name of the openmetaverse.org nor the names
  11. * of its contributors may be used to endorse or promote products derived from
  12. * this software without specific prior written permission.
  13. *
  14. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  15. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  16. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  17. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  18. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  19. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  20. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  21. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  22. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  23. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  24. * POSSIBILITY OF SUCH DAMAGE.
  25. */
  26. using System;
  27. using System.Collections.Generic;
  28. using System.Net;
  29. using System.Text.RegularExpressions;
  30. using System.Threading;
  31. using System.Text;
  32. using System.Runtime.Serialization;
  33. using OpenMetaverse.Http;
  34. using OpenMetaverse.Messages.Linden;
  35. using OpenMetaverse.StructuredData;
  36. using OpenMetaverse.Packets;
  37. namespace OpenMetaverse
  38. {
  39. #region Enums
  40. [Flags]
  41. public enum InventorySortOrder : int
  42. {
  43. /// <summary>Sort by name</summary>
  44. ByName = 0,
  45. /// <summary>Sort by date</summary>
  46. ByDate = 1,
  47. /// <summary>Sort folders by name, regardless of whether items are
  48. /// sorted by name or date</summary>
  49. FoldersByName = 2,
  50. /// <summary>Place system folders at the top</summary>
  51. SystemFoldersToTop = 4
  52. }
  53. /// <summary>
  54. /// Possible destinations for DeRezObject request
  55. /// </summary>
  56. public enum DeRezDestination : byte
  57. {
  58. /// <summary></summary>
  59. AgentInventorySave = 0,
  60. /// <summary>Copy from in-world to agent inventory</summary>
  61. AgentInventoryCopy = 1,
  62. /// <summary>Derez to TaskInventory</summary>
  63. TaskInventory = 2,
  64. /// <summary></summary>
  65. Attachment = 3,
  66. /// <summary>Take Object</summary>
  67. AgentInventoryTake = 4,
  68. /// <summary></summary>
  69. ForceToGodInventory = 5,
  70. /// <summary>Delete Object</summary>
  71. TrashFolder = 6,
  72. /// <summary>Put an avatar attachment into agent inventory</summary>
  73. AttachmentToInventory = 7,
  74. /// <summary></summary>
  75. AttachmentExists = 8,
  76. /// <summary>Return an object back to the owner's inventory</summary>
  77. ReturnToOwner = 9,
  78. /// <summary>Return a deeded object back to the last owner's inventory</summary>
  79. ReturnToLastOwner = 10
  80. }
  81. /// <summary>
  82. /// Upper half of the Flags field for inventory items
  83. /// </summary>
  84. [Flags]
  85. public enum InventoryItemFlags : uint
  86. {
  87. None = 0,
  88. /// <summary>Indicates that the NextOwner permission will be set to the
  89. /// most restrictive set of permissions found in the object set
  90. /// (including linkset items and object inventory items) on next rez</summary>
  91. ObjectSlamPerm = 0x100,
  92. /// <summary>Indicates that the object sale information has been
  93. /// changed</summary>
  94. ObjectSlamSale = 0x1000,
  95. /// <summary>If set, and a slam bit is set, indicates BaseMask will be overwritten on Rez</summary>
  96. ObjectOverwriteBase = 0x010000,
  97. /// <summary>If set, and a slam bit is set, indicates OwnerMask will be overwritten on Rez</summary>
  98. ObjectOverwriteOwner = 0x020000,
  99. /// <summary>If set, and a slam bit is set, indicates GroupMask will be overwritten on Rez</summary>
  100. ObjectOverwriteGroup = 0x040000,
  101. /// <summary>If set, and a slam bit is set, indicates EveryoneMask will be overwritten on Rez</summary>
  102. ObjectOverwriteEveryone = 0x080000,
  103. /// <summary>If set, and a slam bit is set, indicates NextOwnerMask will be overwritten on Rez</summary>
  104. ObjectOverwriteNextOwner = 0x100000,
  105. /// <summary>Indicates whether this object is composed of multiple
  106. /// items or not</summary>
  107. ObjectHasMultipleItems = 0x200000,
  108. /// <summary>Indicates that the asset is only referenced by this
  109. /// inventory item. If this item is deleted or updated to reference a
  110. /// new assetID, the asset can be deleted</summary>
  111. SharedSingleReference = 0x40000000,
  112. }
  113. #endregion Enums
  114. #region Inventory Object Classes
  115. /// <summary>
  116. /// Base Class for Inventory Items
  117. /// </summary>
  118. [Serializable()]
  119. public abstract class InventoryBase : ISerializable
  120. {
  121. /// <summary><seealso cref="OpenMetaverse.UUID"/> of item/folder</summary>
  122. public UUID UUID;
  123. /// <summary><seealso cref="OpenMetaverse.UUID"/> of parent folder</summary>
  124. public UUID ParentUUID;
  125. /// <summary>Name of item/folder</summary>
  126. public string Name;
  127. /// <summary>Item/Folder Owners <seealso cref="OpenMetaverse.UUID"/></summary>
  128. public UUID OwnerID;
  129. /// <summary>
  130. /// Constructor, takes an itemID as a parameter
  131. /// </summary>
  132. /// <param name="itemID">The <seealso cref="OpenMetaverse.UUID"/> of the item</param>
  133. public InventoryBase(UUID itemID)
  134. {
  135. if (itemID == UUID.Zero)
  136. Logger.Log("Initializing an InventoryBase with UUID.Zero", Helpers.LogLevel.Warning);
  137. UUID = itemID;
  138. }
  139. /// <summary>
  140. ///
  141. /// </summary>
  142. /// <returns></returns>
  143. public virtual void GetObjectData(SerializationInfo info, StreamingContext ctxt)
  144. {
  145. info.AddValue("UUID", UUID);
  146. info.AddValue("ParentUUID", ParentUUID);
  147. info.AddValue("Name", Name);
  148. info.AddValue("OwnerID", OwnerID);
  149. }
  150. /// <summary>
  151. ///
  152. /// </summary>
  153. /// <returns></returns>
  154. public InventoryBase(SerializationInfo info, StreamingContext ctxt)
  155. {
  156. UUID = (UUID)info.GetValue("UUID", typeof(UUID));
  157. ParentUUID = (UUID)info.GetValue("ParentUUID", typeof(UUID));
  158. Name = (string)info.GetValue("Name", typeof(string));
  159. OwnerID = (UUID)info.GetValue("OwnerID", typeof(UUID));
  160. }
  161. /// <summary>
  162. /// Generates a number corresponding to the value of the object to support the use of a hash table,
  163. /// suitable for use in hashing algorithms and data structures such as a hash table
  164. /// </summary>
  165. /// <returns>A Hashcode of all the combined InventoryBase fields</returns>
  166. public override int GetHashCode()
  167. {
  168. return UUID.GetHashCode() ^ ParentUUID.GetHashCode() ^ Name.GetHashCode() ^ OwnerID.GetHashCode();
  169. }
  170. /// <summary>
  171. /// Determine whether the specified <seealso cref="OpenMetaverse.InventoryBase"/> object is equal to the current object
  172. /// </summary>
  173. /// <param name="o">InventoryBase object to compare against</param>
  174. /// <returns>true if objects are the same</returns>
  175. public override bool Equals(object o)
  176. {
  177. InventoryBase inv = o as InventoryBase;
  178. return inv != null && Equals(inv);
  179. }
  180. /// <summary>
  181. /// Determine whether the specified <seealso cref="OpenMetaverse.InventoryBase"/> object is equal to the current object
  182. /// </summary>
  183. /// <param name="o">InventoryBase object to compare against</param>
  184. /// <returns>true if objects are the same</returns>
  185. public virtual bool Equals(InventoryBase o)
  186. {
  187. return o.UUID == UUID
  188. && o.ParentUUID == ParentUUID
  189. && o.Name == Name
  190. && o.OwnerID == OwnerID;
  191. }
  192. }
  193. /// <summary>
  194. /// An Item in Inventory
  195. /// </summary>
  196. [Serializable()]
  197. public class InventoryItem : InventoryBase
  198. {
  199. public override string ToString()
  200. {
  201. return AssetType + " " + AssetUUID + " (" + InventoryType + " " + UUID + ") '" + Name + "'/'" +
  202. Description + "' " + Permissions;
  203. }
  204. /// <summary>The <seealso cref="OpenMetaverse.UUID"/> of this item</summary>
  205. public UUID AssetUUID;
  206. /// <summary>The combined <seealso cref="OpenMetaverse.Permissions"/> of this item</summary>
  207. public Permissions Permissions;
  208. /// <summary>The type of item from <seealso cref="OpenMetaverse.AssetType"/></summary>
  209. public AssetType AssetType;
  210. /// <summary>The type of item from the <seealso cref="OpenMetaverse.InventoryType"/> enum</summary>
  211. public InventoryType InventoryType;
  212. /// <summary>The <seealso cref="OpenMetaverse.UUID"/> of the creator of this item</summary>
  213. public UUID CreatorID;
  214. /// <summary>A Description of this item</summary>
  215. public string Description;
  216. /// <summary>The <seealso cref="OpenMetaverse.Group"/>s <seealso cref="OpenMetaverse.UUID"/> this item is set to or owned by</summary>
  217. public UUID GroupID;
  218. /// <summary>If true, item is owned by a group</summary>
  219. public bool GroupOwned;
  220. /// <summary>The price this item can be purchased for</summary>
  221. public int SalePrice;
  222. /// <summary>The type of sale from the <seealso cref="OpenMetaverse.SaleType"/> enum</summary>
  223. public SaleType SaleType;
  224. /// <summary>Combined flags from <seealso cref="OpenMetaverse.InventoryItemFlags"/></summary>
  225. public uint Flags;
  226. /// <summary>Time and date this inventory item was created, stored as
  227. /// UTC (Coordinated Universal Time)</summary>
  228. public DateTime CreationDate;
  229. /// <summary>Used to update the AssetID in requests sent to the server</summary>
  230. public UUID TransactionID;
  231. /// <summary>The <seealso cref="OpenMetaverse.UUID"/> of the previous owner of the item</summary>
  232. public UUID LastOwnerID;
  233. /// <summary>
  234. /// Construct a new InventoryItem object
  235. /// </summary>
  236. /// <param name="itemID">The <seealso cref="OpenMetaverse.UUID"/> of the item</param>
  237. public InventoryItem(UUID itemID)
  238. : base(itemID) { }
  239. /// <summary>
  240. /// Construct a new InventoryItem object of a specific Type
  241. /// </summary>
  242. /// <param name="type">The type of item from <seealso cref="OpenMetaverse.InventoryType"/></param>
  243. /// <param name="itemID"><seealso cref="OpenMetaverse.UUID"/> of the item</param>
  244. public InventoryItem(InventoryType type, UUID itemID) : base(itemID) { InventoryType = type; }
  245. /// <summary>
  246. /// Indicates inventory item is a link
  247. /// </summary>
  248. /// <returns>True if inventory item is a link to another inventory item</returns>
  249. public bool IsLink()
  250. {
  251. return AssetType == AssetType.Link || AssetType == AssetType.LinkFolder;
  252. }
  253. /// <summary>
  254. ///
  255. /// </summary>
  256. /// <returns></returns>
  257. override public void GetObjectData(SerializationInfo info, StreamingContext ctxt)
  258. {
  259. base.GetObjectData(info, ctxt);
  260. info.AddValue("AssetUUID", AssetUUID, typeof(UUID));
  261. info.AddValue("Permissions", Permissions, typeof(Permissions));
  262. info.AddValue("AssetType", AssetType);
  263. info.AddValue("InventoryType", InventoryType);
  264. info.AddValue("CreatorID", CreatorID);
  265. info.AddValue("Description", Description);
  266. info.AddValue("GroupID", GroupID);
  267. info.AddValue("GroupOwned", GroupOwned);
  268. info.AddValue("SalePrice", SalePrice);
  269. info.AddValue("SaleType", SaleType);
  270. info.AddValue("Flags", Flags);
  271. info.AddValue("CreationDate", CreationDate);
  272. info.AddValue("LastOwnerID", LastOwnerID);
  273. }
  274. /// <summary>
  275. ///
  276. /// </summary>
  277. /// <returns></returns>
  278. public InventoryItem(SerializationInfo info, StreamingContext ctxt)
  279. : base(info, ctxt)
  280. {
  281. AssetUUID = (UUID)info.GetValue("AssetUUID", typeof(UUID));
  282. Permissions = (Permissions)info.GetValue("Permissions", typeof(Permissions));
  283. AssetType = (AssetType)info.GetValue("AssetType", typeof(AssetType));
  284. InventoryType = (InventoryType)info.GetValue("InventoryType", typeof(InventoryType));
  285. CreatorID = (UUID)info.GetValue("CreatorID", typeof(UUID));
  286. Description = (string)info.GetValue("Description", typeof(string));
  287. GroupID = (UUID)info.GetValue("GroupID", typeof(UUID));
  288. GroupOwned = (bool)info.GetValue("GroupOwned", typeof(bool));
  289. SalePrice = (int)info.GetValue("SalePrice", typeof(int));
  290. SaleType = (SaleType)info.GetValue("SaleType", typeof(SaleType));
  291. Flags = (uint)info.GetValue("Flags", typeof(uint));
  292. CreationDate = (DateTime)info.GetValue("CreationDate", typeof(DateTime));
  293. LastOwnerID = (UUID)info.GetValue("LastOwnerID", typeof(UUID));
  294. }
  295. /// <summary>
  296. /// Generates a number corresponding to the value of the object to support the use of a hash table.
  297. /// Suitable for use in hashing algorithms and data structures such as a hash table
  298. /// </summary>
  299. /// <returns>A Hashcode of all the combined InventoryItem fields</returns>
  300. public override int GetHashCode()
  301. {
  302. return AssetUUID.GetHashCode() ^ Permissions.GetHashCode() ^ AssetType.GetHashCode() ^
  303. InventoryType.GetHashCode() ^ Description.GetHashCode() ^ GroupID.GetHashCode() ^
  304. GroupOwned.GetHashCode() ^ SalePrice.GetHashCode() ^ SaleType.GetHashCode() ^
  305. Flags.GetHashCode() ^ CreationDate.GetHashCode() ^ LastOwnerID.GetHashCode();
  306. }
  307. /// <summary>
  308. /// Compares an object
  309. /// </summary>
  310. /// <param name="o">The object to compare</param>
  311. /// <returns>true if comparison object matches</returns>
  312. public override bool Equals(object o)
  313. {
  314. InventoryItem item = o as InventoryItem;
  315. return item != null && Equals(item);
  316. }
  317. /// <summary>
  318. /// Determine whether the specified <seealso cref="OpenMetaverse.InventoryBase"/> object is equal to the current object
  319. /// </summary>
  320. /// <param name="o">The <seealso cref="OpenMetaverse.InventoryBase"/> object to compare against</param>
  321. /// <returns>true if objects are the same</returns>
  322. public override bool Equals(InventoryBase o)
  323. {
  324. InventoryItem item = o as InventoryItem;
  325. return item != null && Equals(item);
  326. }
  327. /// <summary>
  328. /// Determine whether the specified <seealso cref="OpenMetaverse.InventoryItem"/> object is equal to the current object
  329. /// </summary>
  330. /// <param name="o">The <seealso cref="OpenMetaverse.InventoryItem"/> object to compare against</param>
  331. /// <returns>true if objects are the same</returns>
  332. public bool Equals(InventoryItem o)
  333. {
  334. return base.Equals(o as InventoryBase)
  335. && o.AssetType == AssetType
  336. && o.AssetUUID == AssetUUID
  337. && o.CreationDate == CreationDate
  338. && o.Description == Description
  339. && o.Flags == Flags
  340. && o.GroupID == GroupID
  341. && o.GroupOwned == GroupOwned
  342. && o.InventoryType == InventoryType
  343. && o.Permissions.Equals(Permissions)
  344. && o.SalePrice == SalePrice
  345. && o.SaleType == SaleType
  346. && o.LastOwnerID == LastOwnerID;
  347. }
  348. }
  349. /// <summary>
  350. /// InventoryTexture Class representing a graphical image
  351. /// </summary>
  352. /// <seealso cref="ManagedImage"/>
  353. [Serializable()]
  354. public class InventoryTexture : InventoryItem
  355. {
  356. /// <summary>
  357. /// Construct an InventoryTexture object
  358. /// </summary>
  359. /// <param name="itemID">A <seealso cref="OpenMetaverse.UUID"/> which becomes the
  360. /// <seealso cref="OpenMetaverse.InventoryItem"/> objects AssetUUID</param>
  361. public InventoryTexture(UUID itemID)
  362. : base(itemID)
  363. {
  364. InventoryType = InventoryType.Texture;
  365. }
  366. /// <summary>
  367. /// Construct an InventoryTexture object from a serialization stream
  368. /// </summary>
  369. public InventoryTexture(SerializationInfo info, StreamingContext ctxt)
  370. : base(info, ctxt)
  371. {
  372. InventoryType = InventoryType.Texture;
  373. }
  374. }
  375. /// <summary>
  376. /// InventorySound Class representing a playable sound
  377. /// </summary>
  378. [Serializable()]
  379. public class InventorySound : InventoryItem
  380. {
  381. /// <summary>
  382. /// Construct an InventorySound object
  383. /// </summary>
  384. /// <param name="itemID">A <seealso cref="OpenMetaverse.UUID"/> which becomes the
  385. /// <seealso cref="OpenMetaverse.InventoryItem"/> objects AssetUUID</param>
  386. public InventorySound(UUID itemID)
  387. : base(itemID)
  388. {
  389. InventoryType = InventoryType.Sound;
  390. }
  391. /// <summary>
  392. /// Construct an InventorySound object from a serialization stream
  393. /// </summary>
  394. public InventorySound(SerializationInfo info, StreamingContext ctxt)
  395. : base(info, ctxt)
  396. {
  397. InventoryType = InventoryType.Sound;
  398. }
  399. }
  400. /// <summary>
  401. /// InventoryCallingCard Class, contains information on another avatar
  402. /// </summary>
  403. [Serializable()]
  404. public class InventoryCallingCard : InventoryItem
  405. {
  406. /// <summary>
  407. /// Construct an InventoryCallingCard object
  408. /// </summary>
  409. /// <param name="itemID">A <seealso cref="OpenMetaverse.UUID"/> which becomes the
  410. /// <seealso cref="OpenMetaverse.InventoryItem"/> objects AssetUUID</param>
  411. public InventoryCallingCard(UUID itemID)
  412. : base(itemID)
  413. {
  414. InventoryType = InventoryType.CallingCard;
  415. }
  416. /// <summary>
  417. /// Construct an InventoryCallingCard object from a serialization stream
  418. /// </summary>
  419. public InventoryCallingCard(SerializationInfo info, StreamingContext ctxt)
  420. : base(info, ctxt)
  421. {
  422. InventoryType = InventoryType.CallingCard;
  423. }
  424. }
  425. /// <summary>
  426. /// InventoryLandmark Class, contains details on a specific location
  427. /// </summary>
  428. [Serializable()]
  429. public class InventoryLandmark : InventoryItem
  430. {
  431. /// <summary>
  432. /// Construct an InventoryLandmark object
  433. /// </summary>
  434. /// <param name="itemID">A <seealso cref="OpenMetaverse.UUID"/> which becomes the
  435. /// <seealso cref="OpenMetaverse.InventoryItem"/> objects AssetUUID</param>
  436. public InventoryLandmark(UUID itemID)
  437. : base(itemID)
  438. {
  439. InventoryType = InventoryType.Landmark;
  440. }
  441. /// <summary>
  442. /// Construct an InventoryLandmark object from a serialization stream
  443. /// </summary>
  444. public InventoryLandmark(SerializationInfo info, StreamingContext ctxt)
  445. : base(info, ctxt)
  446. {
  447. InventoryType = InventoryType.Landmark;
  448. }
  449. /// <summary>
  450. /// Landmarks use the InventoryItemFlags struct and will have a flag of 1 set if they have been visited
  451. /// </summary>
  452. public bool LandmarkVisited
  453. {
  454. get { return (Flags & 1) != 0; }
  455. set
  456. {
  457. if (value) Flags |= 1;
  458. else Flags &= ~1u;
  459. }
  460. }
  461. }
  462. /// <summary>
  463. /// InventoryObject Class contains details on a primitive or coalesced set of primitives
  464. /// </summary>
  465. [Serializable()]
  466. public class InventoryObject : InventoryItem
  467. {
  468. /// <summary>
  469. /// Construct an InventoryObject object
  470. /// </summary>
  471. /// <param name="itemID">A <seealso cref="OpenMetaverse.UUID"/> which becomes the
  472. /// <seealso cref="OpenMetaverse.InventoryItem"/> objects AssetUUID</param>
  473. public InventoryObject(UUID itemID)
  474. : base(itemID)
  475. {
  476. InventoryType = InventoryType.Object;
  477. }
  478. /// <summary>
  479. /// Construct an InventoryObject object from a serialization stream
  480. /// </summary>
  481. public InventoryObject(SerializationInfo info, StreamingContext ctxt)
  482. : base(info, ctxt)
  483. {
  484. InventoryType = InventoryType.Object;
  485. }
  486. /// <summary>
  487. /// Gets or sets the upper byte of the Flags value
  488. /// </summary>
  489. public InventoryItemFlags ItemFlags
  490. {
  491. get { return (InventoryItemFlags)(Flags & ~0xFF); }
  492. set { Flags = (uint)value | (Flags & 0xFF); }
  493. }
  494. /// <summary>
  495. /// Gets or sets the object attachment point, the lower byte of the Flags value
  496. /// </summary>
  497. public AttachmentPoint AttachPoint
  498. {
  499. get { return (AttachmentPoint)(Flags & 0xFF); }
  500. set { Flags = (uint)value | (Flags & 0xFFFFFF00); }
  501. }
  502. }
  503. /// <summary>
  504. /// InventoryNotecard Class, contains details on an encoded text document
  505. /// </summary>
  506. [Serializable()]
  507. public class InventoryNotecard : InventoryItem
  508. {
  509. /// <summary>
  510. /// Construct an InventoryNotecard object
  511. /// </summary>
  512. /// <param name="itemID">A <seealso cref="OpenMetaverse.UUID"/> which becomes the
  513. /// <seealso cref="OpenMetaverse.InventoryItem"/> objects AssetUUID</param>
  514. public InventoryNotecard(UUID itemID)
  515. : base(itemID)
  516. {
  517. InventoryType = InventoryType.Notecard;
  518. }
  519. /// <summary>
  520. /// Construct an InventoryNotecard object from a serialization stream
  521. /// </summary>
  522. public InventoryNotecard(SerializationInfo info, StreamingContext ctxt)
  523. : base(info, ctxt)
  524. {
  525. InventoryType = InventoryType.Notecard;
  526. }
  527. }
  528. /// <summary>
  529. /// InventoryCategory Class
  530. /// </summary>
  531. /// <remarks>TODO: Is this even used for anything?</remarks>
  532. [Serializable()]
  533. public class InventoryCategory : InventoryItem
  534. {
  535. /// <summary>
  536. /// Construct an InventoryCategory object
  537. /// </summary>
  538. /// <param name="itemID">A <seealso cref="OpenMetaverse.UUID"/> which becomes the
  539. /// <seealso cref="OpenMetaverse.InventoryItem"/> objects AssetUUID</param>
  540. public InventoryCategory(UUID itemID)
  541. : base(itemID)
  542. {
  543. InventoryType = InventoryType.Category;
  544. }
  545. /// <summary>
  546. /// Construct an InventoryCategory object from a serialization stream
  547. /// </summary>
  548. public InventoryCategory(SerializationInfo info, StreamingContext ctxt)
  549. : base(info, ctxt)
  550. {
  551. InventoryType = InventoryType.Category;
  552. }
  553. }
  554. /// <summary>
  555. /// InventoryLSL Class, represents a Linden Scripting Language object
  556. /// </summary>
  557. [Serializable()]
  558. public class InventoryLSL : InventoryItem
  559. {
  560. /// <summary>
  561. /// Construct an InventoryLSL object
  562. /// </summary>
  563. /// <param name="itemID">A <seealso cref="OpenMetaverse.UUID"/> which becomes the
  564. /// <seealso cref="OpenMetaverse.InventoryItem"/> objects AssetUUID</param>
  565. public InventoryLSL(UUID itemID)
  566. : base(itemID)
  567. {
  568. InventoryType = InventoryType.LSL;
  569. }
  570. /// <summary>
  571. /// Construct an InventoryLSL object from a serialization stream
  572. /// </summary>
  573. public InventoryLSL(SerializationInfo info, StreamingContext ctxt)
  574. : base(info, ctxt)
  575. {
  576. InventoryType = InventoryType.LSL;
  577. }
  578. }
  579. /// <summary>
  580. /// InventorySnapshot Class, an image taken with the viewer
  581. /// </summary>
  582. [Serializable()]
  583. public class InventorySnapshot : InventoryItem
  584. {
  585. /// <summary>
  586. /// Construct an InventorySnapshot object
  587. /// </summary>
  588. /// <param name="itemID">A <seealso cref="OpenMetaverse.UUID"/> which becomes the
  589. /// <seealso cref="OpenMetaverse.InventoryItem"/> objects AssetUUID</param>
  590. public InventorySnapshot(UUID itemID)
  591. : base(itemID)
  592. {
  593. InventoryType = InventoryType.Snapshot;
  594. }
  595. /// <summary>
  596. /// Construct an InventorySnapshot object from a serialization stream
  597. /// </summary>
  598. public InventorySnapshot(SerializationInfo info, StreamingContext ctxt)
  599. : base(info, ctxt)
  600. {
  601. InventoryType = InventoryType.Snapshot;
  602. }
  603. }
  604. /// <summary>
  605. /// InventoryAttachment Class, contains details on an attachable object
  606. /// </summary>
  607. [Serializable()]
  608. public class InventoryAttachment : InventoryItem
  609. {
  610. /// <summary>
  611. /// Construct an InventoryAttachment object
  612. /// </summary>
  613. /// <param name="itemID">A <seealso cref="OpenMetaverse.UUID"/> which becomes the
  614. /// <seealso cref="OpenMetaverse.InventoryItem"/> objects AssetUUID</param>
  615. public InventoryAttachment(UUID itemID)
  616. : base(itemID)
  617. {
  618. InventoryType = InventoryType.Attachment;
  619. }
  620. /// <summary>
  621. /// Construct an InventoryAttachment object from a serialization stream
  622. /// </summary>
  623. public InventoryAttachment(SerializationInfo info, StreamingContext ctxt)
  624. : base(info, ctxt)
  625. {
  626. InventoryType = InventoryType.Attachment;
  627. }
  628. /// <summary>
  629. /// Get the last AttachmentPoint this object was attached to
  630. /// </summary>
  631. public AttachmentPoint AttachmentPoint
  632. {
  633. get { return (AttachmentPoint)Flags; }
  634. set { Flags = (uint)value; }
  635. }
  636. }
  637. /// <summary>
  638. /// InventoryWearable Class, details on a clothing item or body part
  639. /// </summary>
  640. [Serializable()]
  641. public class InventoryWearable : InventoryItem
  642. {
  643. /// <summary>
  644. /// Construct an InventoryWearable object
  645. /// </summary>
  646. /// <param name="itemID">A <seealso cref="OpenMetaverse.UUID"/> which becomes the
  647. /// <seealso cref="OpenMetaverse.InventoryItem"/> objects AssetUUID</param>
  648. public InventoryWearable(UUID itemID) : base(itemID) { InventoryType = InventoryType.Wearable; }
  649. /// <summary>
  650. /// Construct an InventoryWearable object from a serialization stream
  651. /// </summary>
  652. public InventoryWearable(SerializationInfo info, StreamingContext ctxt)
  653. : base(info, ctxt)
  654. {
  655. InventoryType = InventoryType.Wearable;
  656. }
  657. /// <summary>
  658. /// The <seealso cref="OpenMetaverse.WearableType"/>, Skin, Shape, Skirt, Etc
  659. /// </summary>
  660. public WearableType WearableType
  661. {
  662. get { return (WearableType)Flags; }
  663. set { Flags = (uint)value; }
  664. }
  665. }
  666. /// <summary>
  667. /// InventoryAnimation Class, A bvh encoded object which animates an avatar
  668. /// </summary>
  669. [Serializable()]
  670. public class InventoryAnimation : InventoryItem
  671. {
  672. /// <summary>
  673. /// Construct an InventoryAnimation object
  674. /// </summary>
  675. /// <param name="itemID">A <seealso cref="OpenMetaverse.UUID"/> which becomes the
  676. /// <seealso cref="OpenMetaverse.InventoryItem"/> objects AssetUUID</param>
  677. public InventoryAnimation(UUID itemID)
  678. : base(itemID)
  679. {
  680. InventoryType = InventoryType.Animation;
  681. }
  682. /// <summary>
  683. /// Construct an InventoryAnimation object from a serialization stream
  684. /// </summary>
  685. public InventoryAnimation(SerializationInfo info, StreamingContext ctxt)
  686. : base(info, ctxt)
  687. {
  688. InventoryType = InventoryType.Animation;
  689. }
  690. }
  691. /// <summary>
  692. /// InventoryGesture Class, details on a series of animations, sounds, and actions
  693. /// </summary>
  694. [Serializable()]
  695. public class InventoryGesture : InventoryItem
  696. {
  697. /// <summary>
  698. /// Construct an InventoryGesture object
  699. /// </summary>
  700. /// <param name="itemID">A <seealso cref="OpenMetaverse.UUID"/> which becomes the
  701. /// <seealso cref="OpenMetaverse.InventoryItem"/> objects AssetUUID</param>
  702. public InventoryGesture(UUID itemID)
  703. : base(itemID)
  704. {
  705. InventoryType = InventoryType.Gesture;
  706. }
  707. /// <summary>
  708. /// Construct an InventoryGesture object from a serialization stream
  709. /// </summary>
  710. public InventoryGesture(SerializationInfo info, StreamingContext ctxt)
  711. : base(info, ctxt)
  712. {
  713. InventoryType = InventoryType.Gesture;
  714. }
  715. }
  716. /// <summary>
  717. /// A folder contains <seealso cref="T:OpenMetaverse.InventoryItem"/>s and has certain attributes specific
  718. /// to itself
  719. /// </summary>
  720. [Serializable()]
  721. public class InventoryFolder : InventoryBase
  722. {
  723. /// <summary>The Preferred <seealso cref="T:OpenMetaverse.AssetType"/> for a folder.</summary>
  724. public AssetType PreferredType;
  725. /// <summary>The Version of this folder</summary>
  726. public int Version;
  727. /// <summary>Number of child items this folder contains.</summary>
  728. public int DescendentCount;
  729. /// <summary>
  730. /// Constructor
  731. /// </summary>
  732. /// <param name="itemID">UUID of the folder</param>
  733. public InventoryFolder(UUID itemID)
  734. : base(itemID)
  735. {
  736. PreferredType = AssetType.Unknown;
  737. Version = 1;
  738. DescendentCount = 0;
  739. }
  740. /// <summary>
  741. ///
  742. /// </summary>
  743. /// <returns></returns>
  744. public override string ToString()
  745. {
  746. return Name;
  747. }
  748. /// <summary>
  749. /// Get Serilization data for this InventoryFolder object
  750. /// </summary>
  751. override public void GetObjectData(SerializationInfo info, StreamingContext ctxt)
  752. {
  753. base.GetObjectData(info, ctxt);
  754. info.AddValue("PreferredType", PreferredType, typeof(AssetType));
  755. info.AddValue("Version", Version);
  756. info.AddValue("DescendentCount", DescendentCount);
  757. }
  758. /// <summary>
  759. /// Construct an InventoryFolder object from a serialization stream
  760. /// </summary>
  761. public InventoryFolder(SerializationInfo info, StreamingContext ctxt)
  762. : base(info, ctxt)
  763. {
  764. PreferredType = (AssetType)info.GetValue("PreferredType", typeof(AssetType));
  765. Version = (int)info.GetValue("Version", typeof(int));
  766. DescendentCount = (int)info.GetValue("DescendentCount", typeof(int));
  767. }
  768. /// <summary>
  769. ///
  770. /// </summary>
  771. /// <returns></returns>
  772. public override int GetHashCode()
  773. {
  774. return PreferredType.GetHashCode() ^ Version.GetHashCode() ^ DescendentCount.GetHashCode();
  775. }
  776. /// <summary>
  777. ///
  778. /// </summary>
  779. /// <param name="o"></param>
  780. /// <returns></returns>
  781. public override bool Equals(object o)
  782. {
  783. InventoryFolder folder = o as InventoryFolder;
  784. return folder != null && Equals(folder);
  785. }
  786. /// <summary>
  787. ///
  788. /// </summary>
  789. /// <param name="o"></param>
  790. /// <returns></returns>
  791. public override bool Equals(InventoryBase o)
  792. {
  793. InventoryFolder folder = o as InventoryFolder;
  794. return folder != null && Equals(folder);
  795. }
  796. /// <summary>
  797. ///
  798. /// </summary>
  799. /// <param name="o"></param>
  800. /// <returns></returns>
  801. public bool Equals(InventoryFolder o)
  802. {
  803. return base.Equals(o as InventoryBase)
  804. && o.DescendentCount == DescendentCount
  805. && o.PreferredType == PreferredType
  806. && o.Version == Version;
  807. }
  808. }
  809. #endregion Inventory Object Classes
  810. /// <summary>
  811. /// Tools for dealing with agents inventory
  812. /// </summary>
  813. [Serializable()]
  814. public class InventoryManager
  815. {
  816. /// <summary>Used for converting shadow_id to asset_id</summary>
  817. public static readonly UUID MAGIC_ID = new UUID("3c115e51-04f4-523c-9fa6-98aff1034730");
  818. protected struct InventorySearch
  819. {
  820. public UUID Folder;
  821. public UUID Owner;
  822. public string[] Path;
  823. public int Level;
  824. }
  825. #region Delegates
  826. /// <summary>
  827. /// Callback for inventory item creation finishing
  828. /// </summary>
  829. /// <param name="success">Whether the request to create an inventory
  830. /// item succeeded or not</param>
  831. /// <param name="item">Inventory item being created. If success is
  832. /// false this will be null</param>
  833. public delegate void ItemCreatedCallback(bool success, InventoryItem item);
  834. /// <summary>
  835. /// Callback for an inventory item being create from an uploaded asset
  836. /// </summary>
  837. /// <param name="success">true if inventory item creation was successful</param>
  838. /// <param name="status"></param>
  839. /// <param name="itemID"></param>
  840. /// <param name="assetID"></param>
  841. public delegate void ItemCreatedFromAssetCallback(bool success, string status, UUID itemID, UUID assetID);
  842. /// <summary>
  843. ///
  844. /// </summary>
  845. /// <param name="item"></param>
  846. public delegate void ItemCopiedCallback(InventoryBase item);
  847. /// <summary>The event subscribers, null of no subscribers</summary>
  848. private EventHandler<ItemReceivedEventArgs> m_ItemReceived;
  849. ///<summary>Raises the ItemReceived Event</summary>
  850. /// <param name="e">A ItemReceivedEventArgs object containing
  851. /// the data sent from the simulator</param>
  852. protected virtual void OnItemReceived(ItemReceivedEventArgs e)
  853. {
  854. EventHandler<ItemReceivedEventArgs> handler = m_ItemReceived;
  855. if (handler != null)
  856. handler(this, e);
  857. }
  858. /// <summary>Thread sync lock object</summary>
  859. private readonly object m_ItemReceivedLock = new object();
  860. /// <summary>Raised when the simulator sends us data containing
  861. /// ...</summary>
  862. public event EventHandler<ItemReceivedEventArgs> ItemReceived
  863. {
  864. add { lock (m_ItemReceivedLock) { m_ItemReceived += value; } }
  865. remove { lock (m_ItemReceivedLock) { m_ItemReceived -= value; } }
  866. }
  867. /// <summary>The event subscribers, null of no subscribers</summary>
  868. private EventHandler<FolderUpdatedEventArgs> m_FolderUpdated;
  869. ///<summary>Raises the FolderUpdated Event</summary>
  870. /// <param name="e">A FolderUpdatedEventArgs object containing
  871. /// the data sent from the simulator</param>
  872. protected virtual void OnFolderUpdated(FolderUpdatedEventArgs e)
  873. {
  874. EventHandler<FolderUpdatedEventArgs> handler = m_FolderUpdated;
  875. if (handler != null)
  876. handler(this, e);
  877. }
  878. /// <summary>Thread sync lock object</summary>
  879. private readonly object m_FolderUpdatedLock = new object();
  880. /// <summary>Raised when the simulator sends us data containing
  881. /// ...</summary>
  882. public event EventHandler<FolderUpdatedEventArgs> FolderUpdated
  883. {
  884. add { lock (m_FolderUpdatedLock) { m_FolderUpdated += value; } }
  885. remove { lock (m_FolderUpdatedLock) { m_FolderUpdated -= value; } }
  886. }
  887. /// <summary>The event subscribers, null of no subscribers</summary>
  888. private EventHandler<InventoryObjectOfferedEventArgs> m_InventoryObjectOffered;
  889. ///<summary>Raises the InventoryObjectOffered Event</summary>
  890. /// <param name="e">A InventoryObjectOfferedEventArgs object containing
  891. /// the data sent from the simulator</param>
  892. protected virtual void OnInventoryObjectOffered(InventoryObjectOfferedEventArgs e)
  893. {
  894. EventHandler<InventoryObjectOfferedEventArgs> handler = m_InventoryObjectOffered;
  895. if (handler != null)
  896. handler(this, e);
  897. }
  898. /// <summary>Thread sync lock object</summary>
  899. private readonly object m_InventoryObjectOfferedLock = new object();
  900. /// <summary>Raised when the simulator sends us data containing
  901. /// an inventory object sent by another avatar or primitive</summary>
  902. public event EventHandler<InventoryObjectOfferedEventArgs> InventoryObjectOffered
  903. {
  904. add { lock (m_InventoryObjectOfferedLock) { m_InventoryObjectOffered += value; } }
  905. remove { lock (m_InventoryObjectOfferedLock) { m_InventoryObjectOffered -= value; } }
  906. }
  907. /// <summary>The event subscribers, null of no subscribers</summary>
  908. private EventHandler<TaskItemReceivedEventArgs> m_TaskItemReceived;
  909. ///<summary>Raises the TaskItemReceived Event</summary>
  910. /// <param name="e">A TaskItemReceivedEventArgs object containing
  911. /// the data sent from the simulator</param>
  912. protected virtual void OnTaskItemReceived(TaskItemReceivedEventArgs e)
  913. {
  914. EventHandler<TaskItemReceivedEventArgs> handler = m_TaskItemReceived;
  915. if (handler != null)
  916. handler(this, e);
  917. }
  918. /// <summary>Thread sync lock object</summary>
  919. private readonly object m_TaskItemReceivedLock = new object();
  920. /// <summary>Raised when the simulator sends us data containing
  921. /// ...</summary>
  922. public event EventHandler<TaskItemReceivedEventArgs> TaskItemReceived
  923. {
  924. add { lock (m_TaskItemReceivedLock) { m_TaskItemReceived += value; } }
  925. remove { lock (m_TaskItemReceivedLock) { m_TaskItemReceived -= value; } }
  926. }
  927. /// <summary>The event subscribers, null of no subscribers</summary>
  928. private EventHandler<FindObjectByPathReplyEventArgs> m_FindObjectByPathReply;
  929. ///<summary>Raises the FindObjectByPath Event</summary>
  930. /// <param name="e">A FindObjectByPathEventArgs object containing
  931. /// the data sent from the simulator</param>
  932. protected virtual void OnFindObjectByPathReply(FindObjectByPathReplyEventArgs e)
  933. {
  934. EventHandler<FindObjectByPathReplyEventArgs> handler = m_FindObjectByPathReply;
  935. if (handler != null)
  936. handler(this, e);
  937. }
  938. /// <summary>Thread sync lock object</summary>
  939. private readonly object m_FindObjectByPathReplyLock = new object();
  940. /// <summary>Raised when the simulator sends us data containing
  941. /// ...</summary>
  942. public event EventHandler<FindObjectByPathReplyEventArgs> FindObjectByPathReply
  943. {
  944. add { lock (m_FindObjectByPathReplyLock) { m_FindObjectByPathReply += value; } }
  945. remove { lock (m_FindObjectByPathReplyLock) { m_FindObjectByPathReply -= value; } }
  946. }
  947. /// <summary>The event subscribers, null of no subscribers</summary>
  948. private EventHandler<TaskInventoryReplyEventArgs> m_TaskInventoryReply;
  949. ///<summary>Raises the TaskInventoryReply Event</summary>
  950. /// <param name="e">A TaskInventoryReplyEventArgs object containing
  951. /// the data sent from the simulator</param>
  952. protected virtual void OnTaskInventoryReply(TaskInventoryReplyEventArgs e)
  953. {
  954. EventHandler<TaskInventoryReplyEventArgs> handler = m_TaskInventoryReply;
  955. if (handler != null)
  956. handler(this, e);
  957. }
  958. /// <summary>Thread sync lock object</summary>
  959. private readonly object m_TaskInventoryReplyLock = new object();
  960. /// <summary>Raised when the simulator sends us data containing
  961. /// ...</summary>
  962. public event EventHandler<TaskInventoryReplyEventArgs> TaskInventoryReply
  963. {
  964. add { lock (m_TaskInventoryReplyLock) { m_TaskInventoryReply += value; } }
  965. remove { lock (m_TaskInventoryReplyLock) { m_TaskInventoryReply -= value; } }
  966. }
  967. /// <summary>
  968. /// Reply received when uploading an inventory asset
  969. /// </summary>
  970. /// <param name="success">Has upload been successful</param>
  971. /// <param name="status">Error message if upload failed</param>
  972. /// <param name="itemID">Inventory asset UUID</param>
  973. /// <param name="assetID">New asset UUID</param>
  974. public delegate void InventoryUploadedAssetCallback(bool success, string status, UUID itemID, UUID assetID);
  975. /// <summary>The event subscribers, null of no subscribers</summary>
  976. private EventHandler<SaveAssetToInventoryEventArgs> m_SaveAssetToInventory;
  977. ///<summary>Raises the SaveAssetToInventory Event</summary>
  978. /// <param name="e">A SaveAssetToInventoryEventArgs object containing
  979. /// the data sent from the simulator</param>
  980. protected virtual void OnSaveAssetToInventory(SaveAssetToInventoryEventArgs e)
  981. {
  982. EventHandler<SaveAssetToInventoryEventArgs> handler = m_SaveAssetToInventory;
  983. if (handler != null)
  984. handler(this, e);
  985. }
  986. /// <summary>Thread sync lock object</summary>
  987. private readonly object m_SaveAssetToInventoryLock = new object();
  988. /// <summary>Raised when the simulator sends us data containing
  989. /// ...</summary>
  990. public event EventHandler<SaveAssetToInventoryEventArgs> SaveAssetToInventory
  991. {
  992. add { lock (m_SaveAssetToInventoryLock) { m_SaveAssetToInventory += value; } }
  993. remove { lock (m_SaveAssetToInventoryLock) { m_SaveAssetToInventory -= value; } }
  994. }
  995. /// <summary>
  996. /// Delegate that is invoked when script upload is completed
  997. /// </summary>
  998. /// <param name="uploadSuccess">Has upload succeded (note, there still might be compile errors)</param>
  999. /// <param name="uploadStatus">Upload status message</param>
  1000. /// <param name="compileSuccess">Is compilation successful</param>
  1001. /// <param name="compileMessages">If compilation failed, list of error messages, null on compilation success</param>
  1002. /// <param name="itemID">Script inventory UUID</param>
  1003. /// <param name="assetID">Script's new asset UUID</param>
  1004. public delegate void ScriptUpdatedCallback(bool uploadSuccess, string uploadStatus, bool compileSuccess, List<string> compileMessages, UUID itemID, UUID assetID);
  1005. /// <summary>The event subscribers, null of no subscribers</summary>
  1006. private EventHandler<ScriptRunningReplyEventArgs> m_ScriptRunningReply;
  1007. ///<summary>Raises the ScriptRunningReply Event</summary>
  1008. /// <param name="e">A ScriptRunningReplyEventArgs object containing
  1009. /// the data sent from the simulator</param>
  1010. protected virtual void OnScriptRunningReply(ScriptRunningReplyEventArgs e)
  1011. {
  1012. EventHandler<ScriptRunningReplyEventArgs> handler = m_ScriptRunningReply;
  1013. if (handler != null)
  1014. handler(this, e);
  1015. }
  1016. /// <summary>Thread sync lock object</summary>
  1017. private readonly object m_ScriptRunningReplyLock = new object();
  1018. /// <summary>Raised when the simulator sends us data containing
  1019. /// ...</summary>
  1020. public event EventHandler<ScriptRunningReplyEventArgs> ScriptRunningReply
  1021. {
  1022. add { lock (m_ScriptRunningReplyLock) { m_ScriptRunningReply += value; } }
  1023. remove { lock (m_ScriptRunningReplyLock) { m_ScriptRunningReply -= value; } }
  1024. }
  1025. #endregion Delegates
  1026. #region String Arrays
  1027. /// <summary>Partial mapping of AssetTypes to folder names</summary>
  1028. private static readonly string[] _NewFolderNames = new string[]
  1029. {
  1030. "Textures",
  1031. "Sounds",
  1032. "Calling Cards",
  1033. "Landmarks",
  1034. "Scripts",
  1035. "Clothing",
  1036. "Objects",
  1037. "Notecards",
  1038. "New Folder",
  1039. "Inventory",
  1040. "Scripts",
  1041. "Scripts",
  1042. "Uncompressed Images",
  1043. "Body Parts",
  1044. "Trash",
  1045. "Photo Album",
  1046. "Lost And Found",
  1047. "Uncompressed Sounds",
  1048. "Uncompressed Images",
  1049. "Uncompressed Images",
  1050. "Animations",
  1051. "Gestures"
  1052. };
  1053. #endregion String Arrays
  1054. private GridClient Client;
  1055. private Inventory _Store;
  1056. //private Random _RandNumbers = new Random();
  1057. private object _CallbacksLock = new object();
  1058. private uint _CallbackPos;
  1059. private Dictionary<uint, ItemCreatedCallback> _ItemCreatedCallbacks = new Dictionary<uint, ItemCreatedCallback>();
  1060. private Dictionary<uint, ItemCopiedCallback> _ItemCopiedCallbacks = new Dictionary<uint, ItemCopiedCallback>();
  1061. private List<InventorySearch> _Searches = new List<InventorySearch>();
  1062. #region Properties
  1063. /// <summary>
  1064. /// Get this agents Inventory data
  1065. /// </summary>
  1066. public Inventory Store { get { return _Store; } }
  1067. #endregion Properties
  1068. /// <summary>
  1069. /// Default constructor
  1070. /// </summary>
  1071. /// <param name="client">Reference to the GridClient object</param>
  1072. public InventoryManager(GridClient client)
  1073. {
  1074. Client = client;
  1075. Client.Network.RegisterCallback(PacketType.UpdateCreateInventoryItem, UpdateCreateInventoryItemHandler);
  1076. Client.Network.RegisterCallback(PacketType.SaveAssetIntoInventory, SaveAssetIntoInventoryHandler);
  1077. Client.Network.RegisterCallback(PacketType.BulkUpdateInventory, BulkUpdateInventoryHandler);
  1078. Client.Network.RegisterEventCallback("BulkUpdateInventory", new Caps.EventQueueCallback(BulkUpdateInventoryCapHandler));
  1079. Client.Network.RegisterCallback(PacketType.MoveInventoryItem, MoveInventoryItemHandler);
  1080. Client.Network.RegisterCallback(PacketType.InventoryDescendents, InventoryDescendentsHandler);
  1081. Client.Network.RegisterCallback(PacketType.FetchInventoryReply, FetchInventoryReplyHandler);
  1082. Client.Network.RegisterCallback(PacketType.ReplyTaskInventory, ReplyTaskInventoryHandler);
  1083. Client.Network.RegisterEventCallback("ScriptRunningReply", new Caps.EventQueueCallback(ScriptRunningReplyMessageHandler));
  1084. // Watch for inventory given to us through instant message
  1085. Client.Self.IM += Self_IM;
  1086. // Register extra parameters with login and parse the inventory data that comes back
  1087. Client.Network.RegisterLoginResponseCallback(
  1088. new NetworkManager.LoginResponseCallback(Network_OnLoginResponse),
  1089. new string[] {
  1090. "inventory-root", "inventory-skeleton", "inventory-lib-root",
  1091. "inventory-lib-owner", "inventory-skel-lib"});
  1092. }
  1093. #region Fetch
  1094. /// <summary>
  1095. /// Fetch an inventory item from the dataserver
  1096. /// </summary>
  1097. /// <param name="itemID">The items <seealso cref="UUID"/></param>
  1098. /// <param name="ownerID">The item Owners <seealso cref="OpenMetaverse.UUID"/></param>
  1099. /// <param name="timeoutMS">a integer representing the number of milliseconds to wait for results</param>
  1100. /// <returns>An <seealso cref="InventoryItem"/> object on success, or null if no item was found</returns>
  1101. /// <remarks>Items will also be sent to the <seealso cref="InventoryManager.OnItemReceived"/> event</remarks>
  1102. public InventoryItem FetchItem(UUID itemID, UUID ownerID, int timeoutMS)
  1103. {
  1104. AutoResetEvent fetchEvent = new AutoResetEvent(false);
  1105. InventoryItem fetchedItem = null;
  1106. EventHandler<ItemReceivedEventArgs> callback =
  1107. delegate(object sender, ItemReceivedEventArgs e)
  1108. {
  1109. if (e.Item.UUID == itemID)
  1110. {
  1111. fetchedItem = e.Item;
  1112. fetchEvent.Set();
  1113. }
  1114. };
  1115. ItemReceived += callback;
  1116. RequestFetchInventory(itemID, ownerID);
  1117. fetchEvent.WaitOne(timeoutMS, false);
  1118. ItemReceived -= callback;
  1119. return fetchedItem;
  1120. }
  1121. /// <summary>
  1122. /// Request A single inventory item
  1123. /// </summary>
  1124. /// <param name="itemID">The item…

Large files files are truncated, but you can click here to view the full file