IAssetServer.cs 4.8 KB

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