HGScene.Inventory.cs 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /**
  2. * Copyright (c) 2008, Contributors. All rights reserved.
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without modification,
  6. * are permitted provided that the following conditions are met:
  7. *
  8. * * Redistributions of source code must retain the above copyright notice,
  9. * this list of conditions and the following disclaimer.
  10. * * Redistributions in binary form must reproduce the above copyright notice,
  11. * this list of conditions and the following disclaimer in the documentation
  12. * and/or other materials provided with the distribution.
  13. * * Neither the name of the Organizations nor the names of Individual
  14. * Contributors may be used to endorse or promote products derived from
  15. * this software without specific prior written permission.
  16. *
  17. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  18. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  19. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
  20. * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  21. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  22. * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  23. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  24. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
  25. * OF THE POSSIBILITY OF SUCH DAMAGE.
  26. *
  27. */
  28. using System.Reflection;
  29. using log4net;
  30. using Nini.Config;
  31. using OpenMetaverse;
  32. using OpenSim.Framework;
  33. using OpenSim.Framework.Communications;
  34. using OpenSim.Framework.Communications.Cache;
  35. namespace OpenSim.Region.Framework.Scenes.Hypergrid
  36. {
  37. public partial class HGScene : Scene
  38. {
  39. #region Fields
  40. private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  41. private HGAssetMapper m_assMapper;
  42. #endregion
  43. #region Constructors
  44. public HGScene(RegionInfo regInfo, AgentCircuitManager authen,
  45. CommunicationsManager commsMan, SceneCommunicationService sceneGridService,
  46. StorageManager storeManager,
  47. ModuleLoader moduleLoader, bool dumpAssetsToFile, bool physicalPrim,
  48. bool SeeIntoRegionFromNeighbor, IConfigSource config, string simulatorVersion)
  49. : base(regInfo, authen, commsMan, sceneGridService, storeManager, moduleLoader,
  50. dumpAssetsToFile, physicalPrim, SeeIntoRegionFromNeighbor, config, simulatorVersion)
  51. {
  52. m_log.Info("[HGScene]: Starting HGScene.");
  53. m_assMapper = new HGAssetMapper(this);
  54. EventManager.OnNewInventoryItemUploadComplete += UploadInventoryItem;
  55. }
  56. #endregion
  57. #region Event handlers
  58. public void UploadInventoryItem(UUID avatarID, UUID assetID, string name, int userlevel)
  59. {
  60. CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(avatarID);
  61. if (userInfo != null)
  62. {
  63. m_assMapper.Post(assetID, avatarID);
  64. }
  65. }
  66. #endregion
  67. #region Overrides of Scene.Inventory methods
  68. ///
  69. /// CapsUpdateInventoryItemAsset
  70. ///
  71. public override UUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, UUID itemID, byte[] data)
  72. {
  73. UUID newAssetID = base.CapsUpdateInventoryItemAsset(remoteClient, itemID, data);
  74. UploadInventoryItem(remoteClient.AgentId, newAssetID, "", 0);
  75. return newAssetID;
  76. }
  77. ///
  78. /// DeleteToInventory
  79. ///
  80. public override UUID DeleteToInventory(DeRezAction action, UUID folderID, SceneObjectGroup objectGroup, IClientAPI remoteClient)
  81. {
  82. UUID assetID = base.DeleteToInventory(action, folderID, objectGroup, remoteClient);
  83. if (!assetID.Equals(UUID.Zero))
  84. {
  85. UploadInventoryItem(remoteClient.AgentId, assetID, "", 0);
  86. }
  87. else
  88. m_log.Debug("[HGScene]: Scene.Inventory did not create asset");
  89. return assetID;
  90. }
  91. ///
  92. /// RezObject
  93. ///
  94. public override SceneObjectGroup RezObject(IClientAPI remoteClient, UUID itemID, Vector3 RayEnd, Vector3 RayStart,
  95. UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection,
  96. bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment)
  97. {
  98. CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
  99. if (userInfo != null)
  100. {
  101. if (userInfo.RootFolder != null)
  102. {
  103. InventoryItemBase item = userInfo.RootFolder.FindItem(itemID);
  104. if (item != null)
  105. {
  106. m_assMapper.Get(item.AssetID, remoteClient.AgentId);
  107. }
  108. }
  109. }
  110. // OK, we're done fetching. Pass it up to the default RezObject
  111. return base.RezObject(remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection,
  112. RezSelected, RemoveItem, fromTaskID, attachment);
  113. }
  114. #endregion
  115. }
  116. }