aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenGridServices/OpenGridServices.UserServer/Main.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenGridServices/OpenGridServices.UserServer/Main.cs216
1 files changed, 0 insertions, 216 deletions
diff --git a/OpenGridServices/OpenGridServices.UserServer/Main.cs b/OpenGridServices/OpenGridServices.UserServer/Main.cs
deleted file mode 100644
index bb20576..0000000
--- a/OpenGridServices/OpenGridServices.UserServer/Main.cs
+++ /dev/null
@@ -1,216 +0,0 @@
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 : BaseServer, 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; // Replaces below.
57
58 //private UserProfileManager m_userProfileManager; // Depreciated
59
60 public Dictionary<LLUUID, UserProfile> UserSessions = new Dictionary<LLUUID, UserProfile>();
61
62 ConsoleBase m_console;
63
64 [STAThread]
65 public static void Main(string[] args)
66 {
67 Console.WriteLine("Starting...\n");
68
69 OpenUser_Main userserver = new OpenUser_Main();
70
71 userserver.Startup();
72 userserver.Work();
73 }
74
75 private OpenUser_Main()
76 {
77 m_console = new ConsoleBase("opengrid-userserver-console.log", "OpenUser", this , false);
78 MainConsole.Instance = m_console;
79 }
80
81 private void Work()
82 {
83 m_console.Notice("Enter help for a list of commands\n");
84
85 while (true)
86 {
87 m_console.MainConsolePrompt();
88 }
89 }
90
91 public void Startup()
92 {
93 this.localXMLConfig = new XmlConfig("UserServerConfig.xml");
94 this.localXMLConfig.LoadData();
95 this.ConfigDB(this.localXMLConfig);
96 this.localXMLConfig.Close();
97
98 MainConsole.Instance.Verbose("Main.cs:Startup() - Loading configuration");
99 Cfg = this.LoadConfigDll(this.ConfigDll);
100 Cfg.InitConfig();
101
102 MainConsole.Instance.Verbose( "Main.cs:Startup() - Establishing data connection");
103 m_userManager = new UserManager();
104 m_userManager._config = Cfg;
105 m_userManager.AddPlugin(StorageDll);
106
107 MainConsole.Instance.Verbose("Main.cs:Startup() - Starting HTTP process");
108 BaseHttpServer httpServer = new BaseHttpServer(8002);
109
110 httpServer.AddXmlRPCHandler("login_to_simulator", m_userManager.XmlRpcLoginMethod);
111 httpServer.AddRestHandler("DELETE", "/usersessions/", m_userManager.RestDeleteUserSessionMethod);
112
113 httpServer.Start();
114 }
115
116
117 public void do_create(string what)
118 {
119 switch (what)
120 {
121 case "user":
122 string tempfirstname;
123 string templastname;
124 string tempMD5Passwd;
125 uint regX = 997;
126 uint regY = 996;
127
128 tempfirstname = m_console.CmdPrompt("First name");
129 templastname = m_console.CmdPrompt("Last name");
130 tempMD5Passwd = m_console.PasswdPrompt("Password");
131 regX = Convert.ToUInt32(m_console.CmdPrompt("Start Region X"));
132 regY = Convert.ToUInt32(m_console.CmdPrompt("Start Region Y"));
133
134 tempMD5Passwd = Util.Md5Hash(Util.Md5Hash(tempMD5Passwd) + ":" + "");
135
136 m_userManager.AddUserProfile(tempfirstname, templastname, tempMD5Passwd, regX, regY);
137 break;
138 }
139 }
140
141 public void RunCmd(string cmd, string[] cmdparams)
142 {
143 switch (cmd)
144 {
145 case "help":
146 m_console.Notice("create user - create a new user");
147 m_console.Notice("shutdown - shutdown the grid (USE CAUTION!)");
148 break;
149
150 case "create":
151 do_create(cmdparams[0]);
152 break;
153
154 case "shutdown":
155 m_console.Close();
156 Environment.Exit(0);
157 break;
158 }
159 }
160
161 private void ConfigDB(IGenericConfig configData)
162 {
163 try
164 {
165 string attri = "";
166 attri = configData.GetAttribute("DataBaseProvider");
167 if (attri == "")
168 {
169 StorageDll = "OpenGrid.Framework.Data.DB4o.dll";
170 configData.SetAttribute("DataBaseProvider", "OpenGrid.Framework.Data.DB4o.dll");
171 }
172 else
173 {
174 StorageDll = attri;
175 }
176 configData.Commit();
177 }
178 catch (Exception e)
179 {
180
181 }
182 }
183
184 private UserConfig LoadConfigDll(string dllName)
185 {
186 Assembly pluginAssembly = Assembly.LoadFrom(dllName);
187 UserConfig config = null;
188
189 foreach (Type pluginType in pluginAssembly.GetTypes())
190 {
191 if (pluginType.IsPublic)
192 {
193 if (!pluginType.IsAbstract)
194 {
195 Type typeInterface = pluginType.GetInterface("IUserConfig", true);
196
197 if (typeInterface != null)
198 {
199 IUserConfig plug = (IUserConfig)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
200 config = plug.GetConfigObject();
201 break;
202 }
203
204 typeInterface = null;
205 }
206 }
207 }
208 pluginAssembly = null;
209 return config;
210 }
211
212 public void Show(string ShowWhat)
213 {
214 }
215 }
216}