From 843f547684ef8a084e336361a440b72090370dd1 Mon Sep 17 00:00:00 2001 From: gareth Date: Mon, 2 Apr 2007 02:11:51 +0000 Subject: Moved grid configuration to Db4o database --- OpenGridServices.GridServer/Main.cs | 50 ++++++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 15 deletions(-) (limited to 'OpenGridServices.GridServer/Main.cs') diff --git a/OpenGridServices.GridServer/Main.cs b/OpenGridServices.GridServer/Main.cs index ce24d72..5b7f921 100644 --- a/OpenGridServices.GridServer/Main.cs +++ b/OpenGridServices.GridServer/Main.cs @@ -32,10 +32,12 @@ using System.IO; using System.Text; using System.Timers; using System.Net; +using System.Reflection; using libsecondlife; using OpenSim.Framework; using OpenSim.Framework.Sims; using OpenSim.Framework.Console; +using OpenSim.Framework.Interfaces; namespace OpenGridServices.GridServer { @@ -43,6 +45,8 @@ namespace OpenGridServices.GridServer /// public class OpenGrid_Main : conscmd_callback { + private string ConfigDll = "OpenGrid.Config.GridConfigDb4o.dll"; + private GridConfig Cfg; public static OpenGrid_Main thegrid; public string GridOwner; public string DefaultStartupMsg; @@ -91,22 +95,10 @@ namespace OpenGridServices.GridServer public void Startup() { - m_console.WriteLine("Main.cs:Startup() - Please press enter to retain default settings"); + m_console.WriteLine("Main.cs:Startup() - Loading configuration"); + Cfg = this.LoadConfigDll(this.ConfigDll); + Cfg.InitConfig(); - this.GridOwner = m_console.CmdPrompt("Grid owner [OGS development team]: ", "OGS development team"); - this.DefaultStartupMsg = m_console.CmdPrompt("Default startup message for clients [Welcome to OGS!]: ", "Welcome to OGS!"); - - this.DefaultAssetServer = m_console.CmdPrompt("Default asset server [no default]: "); - this.AssetSendKey = m_console.CmdPrompt("Key to send to asset server: "); - this.AssetRecvKey = m_console.CmdPrompt("Key to expect from asset server: "); - - this.DefaultUserServer = m_console.CmdPrompt("Default user server [no default]: "); - this.UserSendKey = m_console.CmdPrompt("Key to send to user server: "); - this.UserRecvKey = m_console.CmdPrompt("Key to expect from user server: "); - - this.SimSendKey = m_console.CmdPrompt("Key to send to sims: "); - this.SimRecvKey = m_console.CmdPrompt("Key to expect from sims: "); - m_console.WriteLine("Main.cs:Startup() - Loading sim profiles from database"); this._regionmanager = new SimProfileManager(); _regionmanager.LoadProfiles(); @@ -121,6 +113,34 @@ namespace OpenGridServices.GridServer SimCheckTimer.Enabled=true; } + private GridConfig LoadConfigDll(string dllName) + { + Assembly pluginAssembly = Assembly.LoadFrom(dllName); + GridConfig config = null; + + foreach (Type pluginType in pluginAssembly.GetTypes()) + { + if (pluginType.IsPublic) + { + if (!pluginType.IsAbstract) + { + Type typeInterface = pluginType.GetInterface("IGridConfig", true); + + if (typeInterface != null) + { + IGridConfig plug = (IGridConfig)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + config = plug.GetConfigObject(); + break; + } + + typeInterface = null; + } + } + } + pluginAssembly = null; + return config; + } + public void CheckSims(object sender, ElapsedEventArgs e) { foreach(SimProfileBase sim in _regionmanager.SimProfiles.Values) { string SimResponse=""; -- cgit v1.1