OspInventoryWrapperPlugin.cs 5.2 KB

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