IAssetServer.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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 OpenMetaverse;
  28. namespace OpenSim.Framework
  29. {
  30. /// <summary>
  31. /// Description of IAssetServer.
  32. /// </summary>
  33. public interface IAssetServer : IPlugin
  34. {
  35. void Initialise(ConfigSettings settings);
  36. void Initialise(ConfigSettings settings, string url, string dir, bool test);
  37. void Initialise(ConfigSettings settings, string url);
  38. void SetReceiver(IAssetReceiver receiver);
  39. void RequestAsset(UUID assetID, bool isTexture);
  40. void StoreAsset(AssetBase asset);
  41. void UpdateAsset(AssetBase asset);
  42. void Close();
  43. }
  44. /// <summary>
  45. /// Implemented by classes which with to asynchronously receive asset data from the asset service
  46. /// </summary>
  47. /// <remarks>could change to delegate?</remarks>
  48. public interface IAssetReceiver
  49. {
  50. /// <summary>
  51. /// Call back made when a requested asset has been retrieved by an asset server
  52. /// </summary>
  53. /// <param name="asset"></param>
  54. /// <param name="IsTexture"></param>
  55. void AssetReceived(AssetBase asset, bool IsTexture);
  56. /// <summary>
  57. /// Call back made when an asset server could not retrieve a requested asset
  58. /// </summary>
  59. /// <param name="assetID"></param>
  60. /// <param name="IsTexture"></param>
  61. void AssetNotFound(UUID assetID, bool IsTexture);
  62. }
  63. public class AssetClientPluginInitialiser : PluginInitialiserBase
  64. {
  65. private ConfigSettings config;
  66. public AssetClientPluginInitialiser (ConfigSettings p_sv)
  67. {
  68. config = p_sv;
  69. }
  70. public override void Initialise (IPlugin plugin)
  71. {
  72. IAssetServer p = plugin as IAssetServer;
  73. p.Initialise (config);
  74. }
  75. }
  76. public class LegacyAssetClientPluginInitialiser : PluginInitialiserBase
  77. {
  78. private ConfigSettings config;
  79. private string assetURL;
  80. public LegacyAssetClientPluginInitialiser (ConfigSettings p_sv, string p_url)
  81. {
  82. config = p_sv;
  83. assetURL = p_url;
  84. }
  85. public override void Initialise (IPlugin plugin)
  86. {
  87. IAssetServer p = plugin as IAssetServer;
  88. p.Initialise (config, assetURL);
  89. }
  90. }
  91. public class CryptoAssetClientPluginInitialiser : PluginInitialiserBase
  92. {
  93. private ConfigSettings config;
  94. private string assetURL;
  95. private string currdir;
  96. private bool test;
  97. public CryptoAssetClientPluginInitialiser (ConfigSettings p_sv, string p_url, string p_dir, bool p_test)
  98. {
  99. config = p_sv;
  100. assetURL = p_url;
  101. currdir = p_dir;
  102. test = p_test;
  103. }
  104. public override void Initialise (IPlugin plugin)
  105. {
  106. IAssetServer p = plugin as IAssetServer;
  107. p.Initialise (config, assetURL, currdir, test);
  108. }
  109. }
  110. public interface IAssetPlugin
  111. {
  112. IAssetServer GetAssetServer();
  113. }
  114. }