aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/UserServer/Main.cs
diff options
context:
space:
mode:
authorMW2007-06-27 15:28:52 +0000
committerMW2007-06-27 15:28:52 +0000
commit646bbbc84b8010e0dacbeed5342cdb045f46cc49 (patch)
tree770b34d19855363c3c113ab9a0af9a56d821d887 /OpenSim/Grid/UserServer/Main.cs
downloadopensim-SC-646bbbc84b8010e0dacbeed5342cdb045f46cc49.zip
opensim-SC-646bbbc84b8010e0dacbeed5342cdb045f46cc49.tar.gz
opensim-SC-646bbbc84b8010e0dacbeed5342cdb045f46cc49.tar.bz2
opensim-SC-646bbbc84b8010e0dacbeed5342cdb045f46cc49.tar.xz
Some work on restructuring the namespaces / project names. Note this doesn't compile yet as not all the code has been changed to use the new namespaces. Am committing it now for feedback on the namespaces.
Diffstat (limited to 'OpenSim/Grid/UserServer/Main.cs')
-rw-r--r--OpenSim/Grid/UserServer/Main.cs219
1 files changed, 219 insertions, 0 deletions
diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs
new file mode 100644
index 0000000..5c27d57
--- /dev/null
+++ b/OpenSim/Grid/UserServer/Main.cs
@@ -0,0 +1,219 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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*/
28
29using System;
30using System.Collections;
31using System.Collections.Generic;
32using System.Reflection;
33using System.IO;
34using System.Text;
35using libsecondlife;
36using OpenSim.Framework.User;
37using OpenSim.Framework.Sims;
38using OpenSim.Framework.Inventory;
39using OpenSim.Framework.Interfaces;
40using OpenSim.Framework.Console;
41using OpenSim.Servers;
42using OpenSim.Framework.Utilities;
43using OpenSim.GenericConfig;
44
45namespace OpenGridServices.UserServer
46{
47 /// <summary>
48 /// </summary>
49 public class OpenUser_Main : conscmd_callback
50 {
51 private string ConfigDll = "OpenUser.Config.UserConfigDb4o.dll";
52 private string StorageDll = "OpenGrid.Framework.Data.MySQL.dll";
53 private UserConfig Cfg;
54 protected IGenericConfig localXMLConfig;
55
56 public UserManager m_userManager;
57
58 public Dictionary<LLUUID, UserProfile> UserSessions = new Dictionary<LLUUID, UserProfile>();
59
60 LogBase m_console;
61
62 [STAThread]
63 public static void Main(string[] args)
64 {
65 Console.WriteLine("Launching UserServer...");
66
67 OpenUser_Main userserver = new OpenUser_Main();
68
69 userserver.Startup();
70 userserver.Work();
71 }
72
73 private OpenUser_Main()
74 {
75 m_console = new LogBase("opengrid-userserver-console.log", "OpenUser", this , false);
76 OpenSim.Framework.Console.MainLog.Instance = m_console;
77 }
78
79 private void Work()
80 {
81 m_console.Notice("Enter help for a list of commands\n");
82
83 while (true)
84 {
85 m_console.MainLogPrompt();
86 }
87 }
88
89 public void Startup()
90 {
91 this.localXMLConfig = new XmlConfig("UserServerConfig.xml");
92 this.localXMLConfig.LoadData();
93 this.ConfigDB(this.localXMLConfig);
94 this.localXMLConfig.Close();
95
96 OpenSim.Framework.Console.MainLog.Instance.Verbose("Main.cs:Startup() - Loading configuration");
97 Cfg = this.LoadConfigDll(this.ConfigDll);
98 Cfg.InitConfig();
99
100 OpenSim.Framework.Console.MainLog.Instance.Verbose("Main.cs:Startup() - Establishing data connection");
101 m_userManager = new UserManager();
102 m_userManager._config = Cfg;
103 m_userManager.AddPlugin(StorageDll);
104
105 OpenSim.Framework.Console.MainLog.Instance.Verbose("Main.cs:Startup() - Starting HTTP process");
106 BaseHttpServer httpServer = new BaseHttpServer(8002);
107
108 httpServer.AddXmlRPCHandler("login_to_simulator", m_userManager.XmlRpcLoginMethod);
109
110 httpServer.AddRestHandler("GET", "/user/name/", m_userManager.RestGetUserMethodName);
111 httpServer.AddRestHandler("GET", "/user/uuid/", m_userManager.RestGetUserMethodUUID);
112
113 httpServer.AddRestHandler("DELETE", "/usersessions/", m_userManager.RestDeleteUserSessionMethod);
114
115 httpServer.Start();
116 m_console.Status("Userserver 0.3 - Startup complete");
117 }
118
119
120 public void do_create(string what)
121 {
122 switch (what)
123 {
124 case "user":
125 string tempfirstname;
126 string templastname;
127 string tempMD5Passwd;
128 uint regX = 997;
129 uint regY = 996;
130
131 tempfirstname = m_console.CmdPrompt("First name");
132 templastname = m_console.CmdPrompt("Last name");
133 tempMD5Passwd = m_console.PasswdPrompt("Password");
134 regX = Convert.ToUInt32(m_console.CmdPrompt("Start Region X"));
135 regY = Convert.ToUInt32(m_console.CmdPrompt("Start Region Y"));
136
137 tempMD5Passwd = Util.Md5Hash(Util.Md5Hash(tempMD5Passwd) + ":" + "");
138
139 m_userManager.AddUserProfile(tempfirstname, templastname, tempMD5Passwd, regX, regY);
140 break;
141 }
142 }
143
144 public void RunCmd(string cmd, string[] cmdparams)
145 {
146 switch (cmd)
147 {
148 case "help":
149 m_console.Notice("create user - create a new user");
150 m_console.Notice("shutdown - shutdown the grid (USE CAUTION!)");
151 break;
152
153 case "create":
154 do_create(cmdparams[0]);
155 break;
156
157 case "shutdown":
158 m_console.Close();
159 Environment.Exit(0);
160 break;
161 }
162 }
163
164 private void ConfigDB(IGenericConfig configData)
165 {
166 try
167 {
168 string attri = "";
169 attri = configData.GetAttribute("DataBaseProvider");
170 if (attri == "")
171 {
172 StorageDll = "OpenGrid.Framework.Data.DB4o.dll";
173 configData.SetAttribute("DataBaseProvider", "OpenGrid.Framework.Data.DB4o.dll");
174 }
175 else
176 {
177 StorageDll = attri;
178 }
179 configData.Commit();
180 }
181 catch (Exception e)
182 {
183
184 }
185 }
186
187 private UserConfig LoadConfigDll(string dllName)
188 {
189 Assembly pluginAssembly = Assembly.LoadFrom(dllName);
190 UserConfig config = null;
191
192 foreach (Type pluginType in pluginAssembly.GetTypes())
193 {
194 if (pluginType.IsPublic)
195 {
196 if (!pluginType.IsAbstract)
197 {
198 Type typeInterface = pluginType.GetInterface("IUserConfig", true);
199
200 if (typeInterface != null)
201 {
202 IUserConfig plug = (IUserConfig)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
203 config = plug.GetConfigObject();
204 break;
205 }
206
207 typeInterface = null;
208 }
209 }
210 }
211 pluginAssembly = null;
212 return config;
213 }
214
215 public void Show(string ShowWhat)
216 {
217 }
218 }
219}