OspInventoryWrapperPlugin.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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.Collections.Generic;
  28. using OpenSim.Data;
  29. using OpenMetaverse;
  30. using OpenSim.Services.Interfaces;
  31. namespace OpenSim.Framework.Communications.Osp
  32. {
  33. /// <summary>
  34. /// Wrap other inventory data plugins so that we can perform OSP related post processing for items
  35. /// </summary>
  36. public class OspInventoryWrapperPlugin : IInventoryDataPlugin
  37. {
  38. protected IInventoryDataPlugin m_wrappedPlugin;
  39. //protected CommunicationsManager m_commsManager;
  40. protected IUserAccountService m_userAccountService;
  41. public OspInventoryWrapperPlugin(IInventoryDataPlugin wrappedPlugin, IUserAccountService userService)
  42. {
  43. m_wrappedPlugin = wrappedPlugin;
  44. m_userAccountService = userService;
  45. }
  46. public string Name { get { return "OspInventoryWrapperPlugin"; } }
  47. public string Version { get { return "0.1"; } }
  48. public void Initialise() {}
  49. public void Initialise(string connect) {}
  50. public void Dispose() {}
  51. public InventoryItemBase getInventoryItem(UUID item)
  52. {
  53. return PostProcessItem(m_wrappedPlugin.getInventoryItem(item));
  54. }
  55. // XXX: Why on earth does this exist as it appears to duplicate getInventoryItem?
  56. public InventoryItemBase queryInventoryItem(UUID item)
  57. {
  58. return PostProcessItem(m_wrappedPlugin.queryInventoryItem(item));
  59. }
  60. public List<InventoryItemBase> getInventoryInFolder(UUID folderID)
  61. {
  62. List<InventoryItemBase> items = m_wrappedPlugin.getInventoryInFolder(folderID);
  63. foreach (InventoryItemBase item in items)
  64. PostProcessItem(item);
  65. return items;
  66. }
  67. public List<InventoryItemBase> fetchActiveGestures(UUID avatarID)
  68. {
  69. return m_wrappedPlugin.fetchActiveGestures(avatarID);
  70. // Presuming that no post processing is needed here as gestures don't refer to creator information (?)
  71. }
  72. protected InventoryItemBase PostProcessItem(InventoryItemBase item)
  73. {
  74. item.CreatorIdAsUuid = OspResolver.ResolveOspa(item.CreatorId, m_userAccountService);
  75. return item;
  76. }
  77. public List<InventoryFolderBase> getFolderHierarchy(UUID parentID) { return m_wrappedPlugin.getFolderHierarchy(parentID); }
  78. public List<InventoryFolderBase> getUserRootFolders(UUID user) { return m_wrappedPlugin.getUserRootFolders(user); }
  79. public InventoryFolderBase getUserRootFolder(UUID user) { return m_wrappedPlugin.getUserRootFolder(user); }
  80. public List<InventoryFolderBase> getInventoryFolders(UUID parentID) { return m_wrappedPlugin.getInventoryFolders(parentID); }
  81. public InventoryFolderBase getInventoryFolder(UUID folder) { return m_wrappedPlugin.getInventoryFolder(folder); }
  82. public void addInventoryItem(InventoryItemBase item) { m_wrappedPlugin.addInventoryItem(item); }
  83. public void updateInventoryItem(InventoryItemBase item) { m_wrappedPlugin.updateInventoryItem(item); }
  84. public void deleteInventoryItem(UUID item) { m_wrappedPlugin.deleteInventoryItem(item); }
  85. public InventoryFolderBase queryInventoryFolder(UUID folder) { return m_wrappedPlugin.queryInventoryFolder(folder); }
  86. public void addInventoryFolder(InventoryFolderBase folder) { m_wrappedPlugin.addInventoryFolder(folder); }
  87. public void updateInventoryFolder(InventoryFolderBase folder) { m_wrappedPlugin.updateInventoryFolder(folder); }
  88. public void moveInventoryFolder(InventoryFolderBase folder) { m_wrappedPlugin.moveInventoryFolder(folder); }
  89. public void deleteInventoryFolder(UUID folder) { m_wrappedPlugin.deleteInventoryFolder(folder); }
  90. }
  91. }