UserConfig.cs 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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. namespace OpenSim.Framework
  30. {
  31. /// <summary>
  32. /// UserConfig -- For User Server Configuration
  33. /// </summary>
  34. public class UserConfig
  35. {
  36. public static uint DefaultHttpPort = 8002;
  37. public static bool DefaultHttpSSL = false;
  38. private ConfigurationMember configMember;
  39. public string DatabaseProvider = String.Empty;
  40. public string DatabaseConnect = String.Empty;
  41. public string DefaultStartupMsg = String.Empty;
  42. public uint DefaultX = 1000;
  43. public uint DefaultY = 1000;
  44. public string GridRecvKey = String.Empty;
  45. public string GridSendKey = String.Empty;
  46. public uint HttpPort = DefaultHttpPort;
  47. public bool HttpSSL = DefaultHttpSSL;
  48. public uint DefaultUserLevel = 0;
  49. public string LibraryXmlfile = "";
  50. private Uri m_inventoryUrl;
  51. public Uri InventoryUrl
  52. {
  53. get
  54. {
  55. return m_inventoryUrl;
  56. }
  57. set
  58. {
  59. m_inventoryUrl = value;
  60. }
  61. }
  62. private Uri m_gridServerURL;
  63. public Uri GridServerURL
  64. {
  65. get
  66. {
  67. return m_gridServerURL;
  68. }
  69. set
  70. {
  71. m_gridServerURL = value;
  72. }
  73. }
  74. public bool EnableLLSDLogin = true;
  75. public UserConfig()
  76. {
  77. // weird, but UserManagerBase needs this.
  78. }
  79. public UserConfig(string description, string filename)
  80. {
  81. configMember =
  82. new ConfigurationMember(filename, description, loadConfigurationOptions, handleIncomingConfiguration, true);
  83. configMember.performConfigurationRetrieve();
  84. }
  85. public void loadConfigurationOptions()
  86. {
  87. configMember.addConfigurationOption("default_startup_message",
  88. ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
  89. "Default Startup Message", "Welcome to OGS", false);
  90. configMember.addConfigurationOption("default_grid_server",
  91. ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
  92. "Default Grid Server URI",
  93. "http://127.0.0.1:" + GridConfig.DefaultHttpPort + "/", false);
  94. configMember.addConfigurationOption("grid_send_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING,
  95. "Key to send to grid server", "null", false);
  96. configMember.addConfigurationOption("grid_recv_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING,
  97. "Key to expect from grid server", "null", false);
  98. configMember.addConfigurationOption("default_inventory_server",
  99. ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
  100. "Default Inventory Server URI",
  101. "http://127.0.0.1:" + InventoryConfig.DefaultHttpPort + "/",
  102. false);
  103. configMember.addConfigurationOption("library_location",
  104. ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
  105. "Path to library control file",
  106. string.Format(".{0}inventory{0}Libraries.xml", Path.DirectorySeparatorChar), false);
  107. configMember.addConfigurationOption("database_provider", ConfigurationOption.ConfigurationTypes.TYPE_STRING,
  108. "DLL for database provider", "OpenSim.Data.MySQL.dll", false);
  109. configMember.addConfigurationOption("database_connect", ConfigurationOption.ConfigurationTypes.TYPE_STRING,
  110. "Connection String for Database", "", false);
  111. configMember.addConfigurationOption("http_port", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
  112. "Http Listener port", DefaultHttpPort.ToString(), false);
  113. configMember.addConfigurationOption("http_ssl", ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN,
  114. "Use SSL? true/false", DefaultHttpSSL.ToString(), false);
  115. configMember.addConfigurationOption("default_X", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
  116. "Known good region X", "1000", false);
  117. configMember.addConfigurationOption("default_Y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
  118. "Known good region Y", "1000", false);
  119. configMember.addConfigurationOption("enable_llsd_login", ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN,
  120. "Enable LLSD login support [Currently used by libsl based clients/bots]? true/false", true.ToString(), false);
  121. configMember.addConfigurationOption("default_loginLevel", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
  122. "Minimum Level a user should have to login [0 default]", "0", false);
  123. }
  124. public bool handleIncomingConfiguration(string configuration_key, object configuration_result)
  125. {
  126. switch (configuration_key)
  127. {
  128. case "default_startup_message":
  129. DefaultStartupMsg = (string) configuration_result;
  130. break;
  131. case "default_grid_server":
  132. GridServerURL = new Uri( (string) configuration_result );
  133. break;
  134. case "grid_send_key":
  135. GridSendKey = (string) configuration_result;
  136. break;
  137. case "grid_recv_key":
  138. GridRecvKey = (string) configuration_result;
  139. break;
  140. case "default_inventory_server":
  141. InventoryUrl = new Uri((string) configuration_result);
  142. break;
  143. case "database_provider":
  144. DatabaseProvider = (string) configuration_result;
  145. break;
  146. case "database_connect":
  147. DatabaseConnect = (string) configuration_result;
  148. break;
  149. case "http_port":
  150. HttpPort = (uint) configuration_result;
  151. break;
  152. case "http_ssl":
  153. HttpSSL = (bool) configuration_result;
  154. break;
  155. case "default_X":
  156. DefaultX = (uint) configuration_result;
  157. break;
  158. case "default_Y":
  159. DefaultY = (uint) configuration_result;
  160. break;
  161. case "enable_llsd_login":
  162. EnableLLSDLogin = (bool)configuration_result;
  163. break;
  164. case "default_loginLevel":
  165. DefaultUserLevel = (uint)configuration_result;
  166. break;
  167. case "library_location":
  168. LibraryXmlfile = (string)configuration_result;
  169. break;
  170. }
  171. return true;
  172. }
  173. }
  174. }