OpenSimExport.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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;
  28. using System.IO;
  29. using Nini.Config;
  30. using OpenSim.Framework;
  31. using OpenSim.Framework.Console;
  32. using OpenSim.Region.Environment;
  33. using OpenSim.Region.Environment.Scenes;
  34. namespace OpenSim.Tools.Export
  35. {
  36. public class OpenSimExport
  37. {
  38. public IniConfigSource config;
  39. public StorageManager sman;
  40. public OpenSimExport(IniConfigSource config)
  41. {
  42. this.config = config;
  43. IConfig startup = config.Configs["Startup"];
  44. // AddinManager.Initialize(".");
  45. // AddinManager.Registry.Update(null);
  46. MainConsole.Instance = CreateConsole();
  47. sman = new StorageManager(
  48. startup.GetString("storage_plugin", "OpenSim.DataStore.NullStorage.dll"),
  49. startup.GetString("storage_connection_string", String.Empty),
  50. false
  51. );
  52. }
  53. public static void Main(string[] args)
  54. {
  55. log4net.Config.XmlConfigurator.Configure();
  56. OpenSimExport export = new OpenSimExport(InitConfig(args));
  57. RegionInfo reg = new RegionInfo("Sara Jane", "Regions/1000-1000.xml",false);
  58. Console.WriteLine("This application does nothing useful yet: " + reg.RegionID);
  59. foreach (SceneObjectGroup group in export.sman.DataStore.LoadObjects(reg.RegionID))
  60. {
  61. Console.WriteLine("{0} -> {1}", reg.RegionID, group.UUID);
  62. }
  63. }
  64. protected ConsoleBase CreateConsole()
  65. {
  66. return new ConsoleBase("Export", null);
  67. }
  68. private static IniConfigSource InitConfig(string[] args)
  69. {
  70. Console.WriteLine("Good");
  71. ArgvConfigSource configSource = new ArgvConfigSource(args);
  72. configSource.AddSwitch("Startup", "inifile");
  73. IConfig startupConfig = configSource.Configs["Startup"];
  74. string iniFilePath = startupConfig.GetString("inifile", "OpenSim.ini");
  75. Console.WriteLine(iniFilePath);
  76. IniConfigSource config = new IniConfigSource();
  77. //check for .INI file (either default or name passed in command line)
  78. if (! File.Exists(iniFilePath))
  79. {
  80. iniFilePath = Path.Combine(Util.configDir(), iniFilePath);
  81. }
  82. if (File.Exists(iniFilePath))
  83. {
  84. config.Merge(new IniConfigSource(iniFilePath));
  85. config.Merge(configSource);
  86. }
  87. else
  88. {
  89. // no default config files, so set default values, and save it
  90. Console.WriteLine("We didn't find a config!");
  91. config.Merge(OpenSimMain.DefaultConfig());
  92. config.Merge(configSource);
  93. }
  94. return config;
  95. }
  96. }
  97. }