InventoryManager.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*
  2. * Copyright (c) Contributors, http://www.openmetaverse.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. */
  28. using System;
  29. using System.Collections;
  30. using System.Collections.Generic;
  31. using System.Text;
  32. using OpenGrid.Framework.Data;
  33. using libsecondlife;
  34. using System.Reflection;
  35. using System.Xml;
  36. using Nwc.XmlRpc;
  37. using OpenSim.Framework.Sims;
  38. using OpenSim.Framework.Inventory;
  39. using OpenSim.Framework.Utilities;
  40. using System.Security.Cryptography;
  41. namespace OpenGridServices.InventoryServer
  42. {
  43. class InventoryManager
  44. {
  45. Dictionary<string, IInventoryData> _plugins = new Dictionary<string, IInventoryData>();
  46. /// <summary>
  47. /// Adds a new inventory server plugin - user servers will be requested in the order they were loaded.
  48. /// </summary>
  49. /// <param name="FileName">The filename to the inventory server plugin DLL</param>
  50. public void AddPlugin(string FileName)
  51. {
  52. OpenSim.Framework.Console.MainConsole.Instance.Verbose( "Invenstorage: Attempting to load " + FileName);
  53. Assembly pluginAssembly = Assembly.LoadFrom(FileName);
  54. OpenSim.Framework.Console.MainConsole.Instance.Verbose( "Invenstorage: Found " + pluginAssembly.GetTypes().Length + " interfaces.");
  55. foreach (Type pluginType in pluginAssembly.GetTypes())
  56. {
  57. if (!pluginType.IsAbstract)
  58. {
  59. Type typeInterface = pluginType.GetInterface("IInventoryData", true);
  60. if (typeInterface != null)
  61. {
  62. IInventoryData plug = (IInventoryData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
  63. plug.Initialise();
  64. this._plugins.Add(plug.getName(), plug);
  65. OpenSim.Framework.Console.MainConsole.Instance.Verbose( "Invenstorage: Added IUserData Interface");
  66. }
  67. typeInterface = null;
  68. }
  69. }
  70. pluginAssembly = null;
  71. }
  72. public List<InventoryFolderBase> getRootFolders(LLUUID user)
  73. {
  74. foreach (KeyValuePair<string, IInventoryData> kvp in _plugins)
  75. {
  76. try
  77. {
  78. return kvp.Value.getUserRootFolders(user);
  79. }
  80. catch (Exception e)
  81. {
  82. OpenSim.Framework.Console.MainConsole.Instance.Notice("Unable to get root folders via " + kvp.Key + " (" + e.ToString() + ")");
  83. }
  84. }
  85. return null;
  86. }
  87. public XmlRpcResponse XmlRpcInventoryRequest(XmlRpcRequest request)
  88. {
  89. XmlRpcResponse response = new XmlRpcResponse();
  90. Hashtable requestData = (Hashtable)request.Params[0];
  91. Hashtable responseData = new Hashtable();
  92. // Stuff happens here
  93. if (requestData.ContainsKey("Access-type"))
  94. {
  95. if (requestData["access-type"] == "rootfolders")
  96. {
  97. // responseData["rootfolders"] =
  98. }
  99. }
  100. else
  101. {
  102. responseData["error"] = "No access-type specified.";
  103. }
  104. // Stuff stops happening here
  105. response.Value = responseData;
  106. return response;
  107. }
  108. }
  109. }