diff options
author | Sean Dague | 2008-05-02 18:59:12 +0000 |
---|---|---|
committer | Sean Dague | 2008-05-02 18:59:12 +0000 |
commit | 1b7f1c956c86458bc0cee341ea95ee593be76703 (patch) | |
tree | ba16a52f1020567f61d8da08dd5b6e4c99697aa5 | |
parent | added user appearance mapping in nhibernate (diff) | |
download | opensim-SC-1b7f1c956c86458bc0cee341ea95ee593be76703.zip opensim-SC-1b7f1c956c86458bc0cee341ea95ee593be76703.tar.gz opensim-SC-1b7f1c956c86458bc0cee341ea95ee593be76703.tar.bz2 opensim-SC-1b7f1c956c86458bc0cee341ea95ee593be76703.tar.xz |
plumb in connection string to the user database paths. mysql and mssql
just ignore this for now, but it lets us get connect strings to sqlite
and nhibernate.
-rw-r--r-- | OpenSim/Data/MSSQL/MSSQLUserData.cs | 7 | ||||
-rw-r--r-- | OpenSim/Data/MySQL/MySQLUserData.cs | 6 | ||||
-rw-r--r-- | OpenSim/Data/NHibernate/NHibernateUserData.cs | 18 | ||||
-rw-r--r-- | OpenSim/Data/SQLite/SQLiteUserData.cs | 8 | ||||
-rw-r--r-- | OpenSim/Data/UserDataBase.cs | 2 | ||||
-rw-r--r-- | OpenSim/Framework/Communications/UserManagerBase.cs | 8 | ||||
-rw-r--r-- | OpenSim/Framework/IUserData.cs | 2 | ||||
-rw-r--r-- | OpenSim/Framework/UserConfig.cs | 6 | ||||
-rw-r--r-- | OpenSim/Grid/UserServer/Main.cs | 2 | ||||
-rw-r--r-- | OpenSim/Region/Application/OpenSimMain.cs | 2 |
10 files changed, 39 insertions, 22 deletions
diff --git a/OpenSim/Data/MSSQL/MSSQLUserData.cs b/OpenSim/Data/MSSQL/MSSQLUserData.cs index a4c5068..d54af82 100644 --- a/OpenSim/Data/MSSQL/MSSQLUserData.cs +++ b/OpenSim/Data/MSSQL/MSSQLUserData.cs | |||
@@ -55,10 +55,11 @@ namespace OpenSim.Data.MSSQL | |||
55 | /// <summary> | 55 | /// <summary> |
56 | /// Loads and initialises the MySQL storage plugin | 56 | /// Loads and initialises the MySQL storage plugin |
57 | /// </summary> | 57 | /// </summary> |
58 | override public void Initialise() | 58 | override public void Initialise(string connect) |
59 | { | 59 | { |
60 | // Load from an INI file connection details | 60 | // TODO: do something with the connect string instead of |
61 | // TODO: move this to XML? | 61 | // ignoring it. |
62 | |||
62 | IniFile iniFile = new IniFile("mssql_connection.ini"); | 63 | IniFile iniFile = new IniFile("mssql_connection.ini"); |
63 | string settingDataSource = iniFile.ParseFileReadValue("data_source"); | 64 | string settingDataSource = iniFile.ParseFileReadValue("data_source"); |
64 | string settingInitialCatalog = iniFile.ParseFileReadValue("initial_catalog"); | 65 | string settingInitialCatalog = iniFile.ParseFileReadValue("initial_catalog"); |
diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index c374bf2..b448715 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs | |||
@@ -55,10 +55,10 @@ namespace OpenSim.Data.MySQL | |||
55 | /// <summary> | 55 | /// <summary> |
56 | /// Loads and initialises the MySQL storage plugin | 56 | /// Loads and initialises the MySQL storage plugin |
57 | /// </summary> | 57 | /// </summary> |
58 | override public void Initialise() | 58 | override public void Initialise(string connect) |
59 | { | 59 | { |
60 | // Load from an INI file connection details | 60 | // TODO: actually do something with our connect string |
61 | // TODO: move this to XML? Yes, PLEASE! | 61 | // instead of loading the second config |
62 | 62 | ||
63 | IniFile iniFile = new IniFile("mysql_connection.ini"); | 63 | IniFile iniFile = new IniFile("mysql_connection.ini"); |
64 | string settingHostname = iniFile.ParseFileReadValue("hostname"); | 64 | string settingHostname = iniFile.ParseFileReadValue("hostname"); |
diff --git a/OpenSim/Data/NHibernate/NHibernateUserData.cs b/OpenSim/Data/NHibernate/NHibernateUserData.cs index 2e55e03..6a830f6 100644 --- a/OpenSim/Data/NHibernate/NHibernateUserData.cs +++ b/OpenSim/Data/NHibernate/NHibernateUserData.cs | |||
@@ -25,6 +25,7 @@ | |||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | ||
28 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
29 | using System.IO; | 30 | using System.IO; |
30 | using System.Reflection; | 31 | using System.Reflection; |
@@ -35,6 +36,7 @@ using NHibernate.Cfg; | |||
35 | using NHibernate.Expression; | 36 | using NHibernate.Expression; |
36 | using NHibernate.Mapping.Attributes; | 37 | using NHibernate.Mapping.Attributes; |
37 | using OpenSim.Framework; | 38 | using OpenSim.Framework; |
39 | using Environment=NHibernate.Cfg.Environment; | ||
38 | 40 | ||
39 | namespace OpenSim.Data.NHibernate | 41 | namespace OpenSim.Data.NHibernate |
40 | { | 42 | { |
@@ -48,20 +50,24 @@ namespace OpenSim.Data.NHibernate | |||
48 | private Configuration cfg; | 50 | private Configuration cfg; |
49 | private ISessionFactory factory; | 51 | private ISessionFactory factory; |
50 | 52 | ||
51 | public override void Initialise() | 53 | public override void Initialise(string connect) |
52 | { | 54 | { |
53 | // TODO: hard coding for sqlite based stuff to begin with, just making it easier to test | 55 | char[] split = {';'}; |
56 | string[] parts = connect.Split(split, 3); | ||
57 | if (parts.Length != 3) { | ||
58 | // TODO: make this a real exception type | ||
59 | throw new Exception("Malformed Inventory connection string '" + connect + "'"); | ||
60 | } | ||
54 | 61 | ||
55 | // This is stubbing for now, it will become dynamic later and support different db backends | 62 | // This is stubbing for now, it will become dynamic later and support different db backends |
56 | cfg = new Configuration(); | 63 | cfg = new Configuration(); |
57 | cfg.SetProperty(Environment.ConnectionProvider, | 64 | cfg.SetProperty(Environment.ConnectionProvider, |
58 | "NHibernate.Connection.DriverConnectionProvider"); | 65 | "NHibernate.Connection.DriverConnectionProvider"); |
59 | cfg.SetProperty(Environment.Dialect, | 66 | cfg.SetProperty(Environment.Dialect, |
60 | "NHibernate.Dialect.SQLiteDialect"); | 67 | "NHibernate.Dialect." + parts[0]); |
61 | cfg.SetProperty(Environment.ConnectionDriver, | 68 | cfg.SetProperty(Environment.ConnectionDriver, |
62 | "NHibernate.Driver.SqliteClientDriver"); | 69 | "NHibernate.Driver." + parts[1]); |
63 | cfg.SetProperty(Environment.ConnectionString, | 70 | cfg.SetProperty(Environment.ConnectionString, parts[2]); |
64 | "URI=file:User.db,version=3"); | ||
65 | cfg.AddAssembly("OpenSim.Data.NHibernate"); | 71 | cfg.AddAssembly("OpenSim.Data.NHibernate"); |
66 | 72 | ||
67 | HbmSerializer.Default.Validate = true; | 73 | HbmSerializer.Default.Validate = true; |
diff --git a/OpenSim/Data/SQLite/SQLiteUserData.cs b/OpenSim/Data/SQLite/SQLiteUserData.cs index bca5401..aa7a849 100644 --- a/OpenSim/Data/SQLite/SQLiteUserData.cs +++ b/OpenSim/Data/SQLite/SQLiteUserData.cs | |||
@@ -64,9 +64,13 @@ namespace OpenSim.Data.SQLite | |||
64 | private SqliteDataAdapter daf; | 64 | private SqliteDataAdapter daf; |
65 | SqliteConnection g_conn; | 65 | SqliteConnection g_conn; |
66 | 66 | ||
67 | override public void Initialise() | 67 | override public void Initialise(string connect) |
68 | { | 68 | { |
69 | SqliteConnection conn = new SqliteConnection("URI=file:userprofiles.db,version=3"); | 69 | // default to something sensible |
70 | if (connect == "") | ||
71 | connect = "URI=file:userprofiles.db,version=3"; | ||
72 | |||
73 | SqliteConnection conn = new SqliteConnection(connect); | ||
70 | TestTables(conn); | 74 | TestTables(conn); |
71 | 75 | ||
72 | // This sucks, but It doesn't seem to work with the dataset Syncing :P | 76 | // This sucks, but It doesn't seem to work with the dataset Syncing :P |
diff --git a/OpenSim/Data/UserDataBase.cs b/OpenSim/Data/UserDataBase.cs index fc33376..2ddeccf 100644 --- a/OpenSim/Data/UserDataBase.cs +++ b/OpenSim/Data/UserDataBase.cs | |||
@@ -51,7 +51,7 @@ namespace OpenSim.Data | |||
51 | public abstract bool InventoryTransferRequest(LLUUID from, LLUUID to, LLUUID inventory); | 51 | public abstract bool InventoryTransferRequest(LLUUID from, LLUUID to, LLUUID inventory); |
52 | public abstract string Version {get;} | 52 | public abstract string Version {get;} |
53 | public abstract string Name {get;} | 53 | public abstract string Name {get;} |
54 | public abstract void Initialise(); | 54 | public abstract void Initialise(string connect); |
55 | public abstract List<AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query); | 55 | public abstract List<AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query); |
56 | public abstract UserAppearance GetUserAppearance(LLUUID user); | 56 | public abstract UserAppearance GetUserAppearance(LLUUID user); |
57 | public abstract void UpdateUserAppearance(LLUUID user, UserAppearance appearance); | 57 | public abstract void UpdateUserAppearance(LLUUID user, UserAppearance appearance); |
diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 29bfe22..51a5036 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs | |||
@@ -53,7 +53,7 @@ namespace OpenSim.Framework.Communications | |||
53 | /// Adds a new user server plugin - user servers will be requested in the order they were loaded. | 53 | /// Adds a new user server plugin - user servers will be requested in the order they were loaded. |
54 | /// </summary> | 54 | /// </summary> |
55 | /// <param name="FileName">The filename to the user server plugin DLL</param> | 55 | /// <param name="FileName">The filename to the user server plugin DLL</param> |
56 | public void AddPlugin(string FileName) | 56 | public void AddPlugin(string FileName, string connect) |
57 | { | 57 | { |
58 | if (!String.IsNullOrEmpty(FileName)) | 58 | if (!String.IsNullOrEmpty(FileName)) |
59 | { | 59 | { |
@@ -71,16 +71,16 @@ namespace OpenSim.Framework.Communications | |||
71 | { | 71 | { |
72 | IUserData plug = | 72 | IUserData plug = |
73 | (IUserData) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); | 73 | (IUserData) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); |
74 | AddPlugin(plug); | 74 | AddPlugin(plug, connect); |
75 | } | 75 | } |
76 | } | 76 | } |
77 | } | 77 | } |
78 | } | 78 | } |
79 | } | 79 | } |
80 | 80 | ||
81 | public void AddPlugin(IUserData plug) | 81 | public void AddPlugin(IUserData plug, string connect) |
82 | { | 82 | { |
83 | plug.Initialise(); | 83 | plug.Initialise(connect); |
84 | _plugins.Add(plug.Name, plug); | 84 | _plugins.Add(plug.Name, plug); |
85 | m_log.Info("[USERSTORAGE]: Added IUserData Interface"); | 85 | m_log.Info("[USERSTORAGE]: Added IUserData Interface"); |
86 | } | 86 | } |
diff --git a/OpenSim/Framework/IUserData.cs b/OpenSim/Framework/IUserData.cs index b75a229..1e557d3 100644 --- a/OpenSim/Framework/IUserData.cs +++ b/OpenSim/Framework/IUserData.cs | |||
@@ -173,7 +173,7 @@ namespace OpenSim.Framework | |||
173 | /// <summary> | 173 | /// <summary> |
174 | /// Initialises the plugin (artificial constructor) | 174 | /// Initialises the plugin (artificial constructor) |
175 | /// </summary> | 175 | /// </summary> |
176 | void Initialise(); | 176 | void Initialise(string connect); |
177 | 177 | ||
178 | /// <summary> | 178 | /// <summary> |
179 | /// Gets the user appearance | 179 | /// Gets the user appearance |
diff --git a/OpenSim/Framework/UserConfig.cs b/OpenSim/Framework/UserConfig.cs index c176bbf..3c0bdfa 100644 --- a/OpenSim/Framework/UserConfig.cs +++ b/OpenSim/Framework/UserConfig.cs | |||
@@ -38,6 +38,7 @@ namespace OpenSim.Framework | |||
38 | public static bool DefaultHttpSSL = false; | 38 | public static bool DefaultHttpSSL = false; |
39 | private ConfigurationMember configMember; | 39 | private ConfigurationMember configMember; |
40 | public string DatabaseProvider = String.Empty; | 40 | public string DatabaseProvider = String.Empty; |
41 | public string DatabaseConnect = String.Empty; | ||
41 | public string DefaultStartupMsg = String.Empty; | 42 | public string DefaultStartupMsg = String.Empty; |
42 | public uint DefaultX = 1000; | 43 | public uint DefaultX = 1000; |
43 | public uint DefaultY = 1000; | 44 | public uint DefaultY = 1000; |
@@ -77,6 +78,8 @@ namespace OpenSim.Framework | |||
77 | false); | 78 | false); |
78 | configMember.addConfigurationOption("database_provider", ConfigurationOption.ConfigurationTypes.TYPE_STRING, | 79 | configMember.addConfigurationOption("database_provider", ConfigurationOption.ConfigurationTypes.TYPE_STRING, |
79 | "DLL for database provider", "OpenSim.Data.MySQL.dll", false); | 80 | "DLL for database provider", "OpenSim.Data.MySQL.dll", false); |
81 | configMember.addConfigurationOption("database_connect", ConfigurationOption.ConfigurationTypes.TYPE_STRING, | ||
82 | "Connection String for Database", "", false); | ||
80 | 83 | ||
81 | configMember.addConfigurationOption("http_port", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, | 84 | configMember.addConfigurationOption("http_port", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, |
82 | "Http Listener port", DefaultHttpPort.ToString(), false); | 85 | "Http Listener port", DefaultHttpPort.ToString(), false); |
@@ -110,6 +113,9 @@ namespace OpenSim.Framework | |||
110 | case "database_provider": | 113 | case "database_provider": |
111 | DatabaseProvider = (string) configuration_result; | 114 | DatabaseProvider = (string) configuration_result; |
112 | break; | 115 | break; |
116 | case "database_connect": | ||
117 | DatabaseConnect = (string) configuration_result; | ||
118 | break; | ||
113 | case "http_port": | 119 | case "http_port": |
114 | HttpPort = (uint) configuration_result; | 120 | HttpPort = (uint) configuration_result; |
115 | break; | 121 | break; |
diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs index 0534e3b..8e6559c 100644 --- a/OpenSim/Grid/UserServer/Main.cs +++ b/OpenSim/Grid/UserServer/Main.cs | |||
@@ -93,7 +93,7 @@ namespace OpenSim.Grid.UserServer | |||
93 | m_log.Info("[REGION]: Establishing data connection"); | 93 | m_log.Info("[REGION]: Establishing data connection"); |
94 | m_userManager = new UserManager(); | 94 | m_userManager = new UserManager(); |
95 | m_userManager._config = Cfg; | 95 | m_userManager._config = Cfg; |
96 | m_userManager.AddPlugin(Cfg.DatabaseProvider); | 96 | m_userManager.AddPlugin(Cfg.DatabaseProvider, Cfg.DatabaseConnect); |
97 | 97 | ||
98 | m_loginService = new UserLoginService( | 98 | m_loginService = new UserLoginService( |
99 | m_userManager, new LibraryRootFolder(), Cfg, Cfg.DefaultStartupMsg); | 99 | m_userManager, new LibraryRootFolder(), Cfg, Cfg.DefaultStartupMsg); |
diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs index 5b44813..43f7375 100644 --- a/OpenSim/Region/Application/OpenSimMain.cs +++ b/OpenSim/Region/Application/OpenSimMain.cs | |||
@@ -362,7 +362,7 @@ namespace OpenSim | |||
362 | LocalUserServices userService = | 362 | LocalUserServices userService = |
363 | new LocalUserServices(m_networkServersInfo, m_networkServersInfo.DefaultHomeLocX, | 363 | new LocalUserServices(m_networkServersInfo, m_networkServersInfo.DefaultHomeLocX, |
364 | m_networkServersInfo.DefaultHomeLocY, inventoryService); | 364 | m_networkServersInfo.DefaultHomeLocY, inventoryService); |
365 | userService.AddPlugin(m_standaloneUserPlugin); | 365 | userService.AddPlugin(m_standaloneUserPlugin, m_standaloneUserSource); |
366 | 366 | ||
367 | LocalBackEndServices backendService = new LocalBackEndServices(); | 367 | LocalBackEndServices backendService = new LocalBackEndServices(); |
368 | 368 | ||