diff options
author | gareth | 2007-04-02 09:38:29 +0000 |
---|---|---|
committer | gareth | 2007-04-02 09:38:29 +0000 |
commit | 6a5adf3571dea98c17b91d08094086ec18fe71c7 (patch) | |
tree | e4c3d4afde42b6977d41c77e33e1c225dbe81265 /OpenUser.Config/UserConfigDb4o/DbUserConfig.cs | |
parent | Renamed GridConfigDb4o (diff) | |
download | opensim-SC_OLD-6a5adf3571dea98c17b91d08094086ec18fe71c7.zip opensim-SC_OLD-6a5adf3571dea98c17b91d08094086ec18fe71c7.tar.gz opensim-SC_OLD-6a5adf3571dea98c17b91d08094086ec18fe71c7.tar.bz2 opensim-SC_OLD-6a5adf3571dea98c17b91d08094086ec18fe71c7.tar.xz |
More renaming
Diffstat (limited to 'OpenUser.Config/UserConfigDb4o/DbUserConfig.cs')
-rw-r--r-- | OpenUser.Config/UserConfigDb4o/DbUserConfig.cs | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/OpenUser.Config/UserConfigDb4o/DbUserConfig.cs b/OpenUser.Config/UserConfigDb4o/DbUserConfig.cs new file mode 100644 index 0000000..1084467 --- /dev/null +++ b/OpenUser.Config/UserConfigDb4o/DbUserConfig.cs | |||
@@ -0,0 +1,112 @@ | |||
1 | /* | ||
2 | * Copyright (c) OpenSim project, http://sim.opensecondlife.org/ | ||
3 | * | ||
4 | * Redistribution and use in source and binary forms, with or without | ||
5 | * modification, are permitted provided that the following conditions are met: | ||
6 | * * Redistributions of source code must retain the above copyright | ||
7 | * notice, this list of conditions and the following disclaimer. | ||
8 | * * Redistributions in binary form must reproduce the above copyright | ||
9 | * notice, this list of conditions and the following disclaimer in the | ||
10 | * documentation and/or other materials provided with the distribution. | ||
11 | * * Neither the name of the <organization> nor the | ||
12 | * names of its contributors may be used to endorse or promote products | ||
13 | * derived from this software without specific prior written permission. | ||
14 | * | ||
15 | * THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY | ||
16 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
18 | * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY | ||
19 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
20 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
21 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
22 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
24 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
25 | * | ||
26 | */ | ||
27 | using System; | ||
28 | using System.Collections.Generic; | ||
29 | using OpenSim.Framework.Console; | ||
30 | using OpenSim.Framework.Interfaces; | ||
31 | using Db4objects.Db4o; | ||
32 | |||
33 | namespace OpenGrid.Config.GridConfigDb4o | ||
34 | { | ||
35 | public class Db40ConfigPlugin: IGridConfig | ||
36 | { | ||
37 | public GridConfig GetConfigObject() | ||
38 | { | ||
39 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Loading Db40Config dll"); | ||
40 | return ( new DbGridConfig()); | ||
41 | } | ||
42 | } | ||
43 | |||
44 | public class DbGridConfig : GridConfig | ||
45 | { | ||
46 | private IObjectContainer db; | ||
47 | |||
48 | public void LoadDefaults() { | ||
49 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Config.cs:LoadDefaults() - Please press enter to retain default or enter new settings"); | ||
50 | |||
51 | this.GridOwner = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Grid owner [OGS development team]: ", "OGS development team"); | ||
52 | |||
53 | this.DefaultAssetServer = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Default asset server [no default]: "); | ||
54 | this.AssetSendKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to send to asset server: "); | ||
55 | this.AssetRecvKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to expect from asset server: "); | ||
56 | |||
57 | this.DefaultUserServer = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Default user server [no default]: "); | ||
58 | this.UserSendKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to send to user server: "); | ||
59 | this.UserRecvKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to expect from user server: "); | ||
60 | |||
61 | this.SimSendKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to send to sims: "); | ||
62 | this.SimRecvKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to expect from sims: "); | ||
63 | } | ||
64 | |||
65 | public override void InitConfig() { | ||
66 | try { | ||
67 | db = Db4oFactory.OpenFile("opengrid.yap"); | ||
68 | IObjectSet result = db.Get(typeof(DbGridConfig)); | ||
69 | if(result.Count==1) { | ||
70 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Config.cs:InitConfig() - Found a GridConfig object in the local database, loading"); | ||
71 | foreach (DbGridConfig cfg in result) { | ||
72 | this.GridOwner=cfg.GridOwner; | ||
73 | this.DefaultAssetServer=cfg.DefaultAssetServer; | ||
74 | this.AssetSendKey=cfg.AssetSendKey; | ||
75 | this.AssetRecvKey=cfg.AssetRecvKey; | ||
76 | this.DefaultUserServer=cfg.DefaultUserServer; | ||
77 | this.UserSendKey=cfg.UserSendKey; | ||
78 | this.UserRecvKey=cfg.UserRecvKey; | ||
79 | this.SimSendKey=cfg.SimSendKey; | ||
80 | this.SimRecvKey=cfg.SimRecvKey; | ||
81 | } | ||
82 | } else { | ||
83 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Config.cs:InitConfig() - Could not find object in database, loading precompiled defaults"); | ||
84 | LoadDefaults(); | ||
85 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Writing out default settings to local database"); | ||
86 | db.Set(this); | ||
87 | db.Close(); | ||
88 | } | ||
89 | } catch(Exception e) { | ||
90 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Config.cs:InitConfig() - Exception occured"); | ||
91 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine(e.ToString()); | ||
92 | } | ||
93 | |||
94 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Grid settings loaded:"); | ||
95 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Grid owner: " + this.GridOwner); | ||
96 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Default asset server: " + this.DefaultAssetServer); | ||
97 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Key to send to asset server: " + this.AssetSendKey); | ||
98 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Key to expect from asset server: " + this.AssetRecvKey); | ||
99 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Default user server: " + this.DefaultUserServer); | ||
100 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Key to send to user server: " + this.UserSendKey); | ||
101 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Key to expect from user server: " + this.UserRecvKey); | ||
102 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Key to send to sims: " + this.SimSendKey); | ||
103 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Key to expect from sims: " + this.SimRecvKey); | ||
104 | } | ||
105 | |||
106 | |||
107 | public void Shutdown() { | ||
108 | db.Close(); | ||
109 | } | ||
110 | } | ||
111 | |||
112 | } | ||