OpenSimExport.cs 4.4 KB

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