aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/UserServer
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Grid/UserServer')
-rw-r--r--OpenSim/Grid/UserServer/Main.cs330
-rw-r--r--OpenSim/Grid/UserServer/Properties/AssemblyInfo.cs63
-rw-r--r--OpenSim/Grid/UserServer/UserServerCommandModule.cs375
-rw-r--r--OpenSim/Grid/UserServer/UserServerCommsManager.cs40
-rw-r--r--OpenSim/Grid/UserServer/UserServerEventDispatchModule.cs142
5 files changed, 0 insertions, 950 deletions
diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs
deleted file mode 100644
index 286076d7..0000000
--- a/OpenSim/Grid/UserServer/Main.cs
+++ /dev/null
@@ -1,330 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.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 OpenSimulator 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
28using System;
29using System.Collections.Generic;
30using System.IO;
31using System.Reflection;
32using log4net;
33using log4net.Config;
34using OpenMetaverse;
35using OpenSim.Data;
36using OpenSim.Framework;
37using OpenSim.Framework.Communications;
38using OpenSim.Framework.Communications.Cache;
39using OpenSim.Framework.Console;
40using OpenSim.Framework.Servers;
41using OpenSim.Framework.Servers.HttpServer;
42using OpenSim.Framework.Statistics;
43using OpenSim.Grid.Communications.OGS1;
44using OpenSim.Grid.Framework;
45using OpenSim.Grid.UserServer.Modules;
46using Nini.Config;
47
48namespace OpenSim.Grid.UserServer
49{
50 /// <summary>
51 /// Grid user server main class
52 /// </summary>
53 public class OpenUser_Main : BaseOpenSimServer, IGridServiceCore
54 {
55 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
56
57 protected UserConfig Cfg;
58
59 protected UserDataBaseService m_userDataBaseService;
60
61 public UserManager m_userManager;
62
63 protected UserServerAvatarAppearanceModule m_avatarAppearanceModule;
64 protected UserServerFriendsModule m_friendsModule;
65
66 public UserLoginService m_loginService;
67 public UserLoginAuthService m_loginAuthService;
68 public MessageServersConnector m_messagesService;
69
70 protected GridInfoServiceModule m_gridInfoService;
71
72 protected UserServerCommandModule m_consoleCommandModule;
73 protected UserServerEventDispatchModule m_eventDispatcher;
74
75 protected AvatarCreationModule m_appearanceModule;
76
77 protected static string m_consoleType = "local";
78 protected static IConfigSource m_config = null;
79 protected static string m_configFile = "UserServer_Config.xml";
80
81 public static void Main(string[] args)
82 {
83 ArgvConfigSource argvSource = new ArgvConfigSource(args);
84 argvSource.AddSwitch("Startup", "console", "c");
85 argvSource.AddSwitch("Startup", "xmlfile", "x");
86
87 IConfig startupConfig = argvSource.Configs["Startup"];
88 if (startupConfig != null)
89 {
90 m_consoleType = startupConfig.GetString("console", "local");
91 m_configFile = startupConfig.GetString("xmlfile", "UserServer_Config.xml");
92 }
93
94 m_config = argvSource;
95
96 XmlConfigurator.Configure();
97
98 m_log.Info("Launching UserServer...");
99
100 OpenUser_Main userserver = new OpenUser_Main();
101
102 userserver.Startup();
103 userserver.Work();
104 }
105
106 public OpenUser_Main()
107 {
108 switch (m_consoleType)
109 {
110 case "rest":
111 m_console = new RemoteConsole("User");
112 break;
113 case "basic":
114 m_console = new CommandConsole("User");
115 break;
116 default:
117 m_console = new LocalConsole("User");
118 break;
119 }
120 MainConsole.Instance = m_console;
121 }
122
123 public void Work()
124 {
125 m_console.Output("Enter help for a list of commands\n");
126
127 while (true)
128 {
129 m_console.Prompt();
130 }
131 }
132
133 protected override void StartupSpecific()
134 {
135 IInterServiceInventoryServices inventoryService = StartupCoreComponents();
136
137 m_stats = StatsManager.StartCollectingUserStats();
138
139 //setup services/modules
140 StartupUserServerModules();
141
142 StartOtherComponents(inventoryService);
143
144 //PostInitialise the modules
145 PostInitialiseModules();
146
147 //register http handlers and start http server
148 m_log.Info("[STARTUP]: Starting HTTP process");
149 RegisterHttpHandlers();
150 m_httpServer.Start();
151
152 base.StartupSpecific();
153 }
154
155 protected virtual IInterServiceInventoryServices StartupCoreComponents()
156 {
157 Cfg = new UserConfig("USER SERVER", (Path.Combine(Util.configDir(), m_configFile)));
158
159 m_httpServer = new BaseHttpServer(Cfg.HttpPort);
160
161 if (m_console is RemoteConsole)
162 {
163 RemoteConsole c = (RemoteConsole)m_console;
164 c.SetServer(m_httpServer);
165 IConfig netConfig = m_config.AddConfig("Network");
166 netConfig.Set("ConsoleUser", Cfg.ConsoleUser);
167 netConfig.Set("ConsolePass", Cfg.ConsolePass);
168 c.ReadConfig(m_config);
169 }
170
171 RegisterInterface<CommandConsole>(m_console);
172 RegisterInterface<UserConfig>(Cfg);
173
174 //Should be in modules?
175 IInterServiceInventoryServices inventoryService = new OGS1InterServiceInventoryService(Cfg.InventoryUrl);
176 // IRegionProfileRouter regionProfileService = new RegionProfileServiceProxy();
177
178 RegisterInterface<IInterServiceInventoryServices>(inventoryService);
179 // RegisterInterface<IRegionProfileRouter>(regionProfileService);
180
181 return inventoryService;
182 }
183
184 /// <summary>
185 /// Start up the user manager
186 /// </summary>
187 /// <param name="inventoryService"></param>
188 protected virtual void StartupUserServerModules()
189 {
190 m_log.Info("[STARTUP]: Establishing data connection");
191
192 //we only need core components so we can request them from here
193 IInterServiceInventoryServices inventoryService;
194 TryGet<IInterServiceInventoryServices>(out inventoryService);
195
196 CommunicationsManager commsManager = new UserServerCommsManager(inventoryService);
197
198 //setup database access service, for now this has to be created before the other modules.
199 m_userDataBaseService = new UserDataBaseService(commsManager);
200 m_userDataBaseService.Initialise(this);
201
202 //TODO: change these modules so they fetch the databaseService class in the PostInitialise method
203 m_userManager = new UserManager(m_userDataBaseService);
204 m_userManager.Initialise(this);
205
206 m_avatarAppearanceModule = new UserServerAvatarAppearanceModule(m_userDataBaseService);
207 m_avatarAppearanceModule.Initialise(this);
208
209 m_friendsModule = new UserServerFriendsModule(m_userDataBaseService);
210 m_friendsModule.Initialise(this);
211
212 m_consoleCommandModule = new UserServerCommandModule();
213 m_consoleCommandModule.Initialise(this);
214
215 m_messagesService = new MessageServersConnector();
216 m_messagesService.Initialise(this);
217
218 m_gridInfoService = new GridInfoServiceModule();
219 m_gridInfoService.Initialise(this);
220 }
221
222 protected virtual void StartOtherComponents(IInterServiceInventoryServices inventoryService)
223 {
224 m_appearanceModule = new AvatarCreationModule(m_userDataBaseService, Cfg, inventoryService);
225 m_appearanceModule.Initialise(this);
226
227 StartupLoginService(inventoryService);
228 //
229 // Get the minimum defaultLevel to access to the grid
230 //
231 m_loginService.setloginlevel((int)Cfg.DefaultUserLevel);
232
233 RegisterInterface<UserLoginService>(m_loginService); //TODO: should be done in the login service
234
235 m_eventDispatcher = new UserServerEventDispatchModule(m_userManager, m_messagesService, m_loginService);
236 m_eventDispatcher.Initialise(this);
237 }
238
239 /// <summary>
240 /// Start up the login service
241 /// </summary>
242 /// <param name="inventoryService"></param>
243 protected virtual void StartupLoginService(IInterServiceInventoryServices inventoryService)
244 {
245 m_loginService = new UserLoginService(
246 m_userDataBaseService, inventoryService, new LibraryRootFolder(Cfg.LibraryXmlfile), Cfg, Cfg.DefaultStartupMsg, new RegionProfileServiceProxy());
247
248 if (Cfg.EnableHGLogin)
249 m_loginAuthService = new UserLoginAuthService(m_userDataBaseService, inventoryService, new LibraryRootFolder(Cfg.LibraryXmlfile),
250 Cfg, Cfg.DefaultStartupMsg, new RegionProfileServiceProxy());
251 }
252
253 protected virtual void PostInitialiseModules()
254 {
255 m_consoleCommandModule.PostInitialise(); //it will register its Console command handlers in here
256 m_userDataBaseService.PostInitialise();
257 m_messagesService.PostInitialise();
258 m_eventDispatcher.PostInitialise(); //it will register event handlers in here
259 m_gridInfoService.PostInitialise();
260 m_userManager.PostInitialise();
261 m_avatarAppearanceModule.PostInitialise();
262 m_friendsModule.PostInitialise();
263 }
264
265 protected virtual void RegisterHttpHandlers()
266 {
267 m_loginService.RegisterHandlers(m_httpServer, Cfg.EnableLLSDLogin, true);
268
269 if (m_loginAuthService != null)
270 m_loginAuthService.RegisterHandlers(m_httpServer);
271
272 m_userManager.RegisterHandlers(m_httpServer);
273 m_friendsModule.RegisterHandlers(m_httpServer);
274 m_avatarAppearanceModule.RegisterHandlers(m_httpServer);
275 m_messagesService.RegisterHandlers(m_httpServer);
276 m_gridInfoService.RegisterHandlers(m_httpServer);
277 }
278
279 public override void ShutdownSpecific()
280 {
281 m_eventDispatcher.Close();
282 }
283
284 #region IUGAIMCore
285 protected Dictionary<Type, object> m_moduleInterfaces = new Dictionary<Type, object>();
286
287 /// <summary>
288 /// Register an Module interface.
289 /// </summary>
290 /// <typeparam name="T"></typeparam>
291 /// <param name="iface"></param>
292 public void RegisterInterface<T>(T iface)
293 {
294 lock (m_moduleInterfaces)
295 {
296 if (!m_moduleInterfaces.ContainsKey(typeof(T)))
297 {
298 m_moduleInterfaces.Add(typeof(T), iface);
299 }
300 }
301 }
302
303 public bool TryGet<T>(out T iface)
304 {
305 if (m_moduleInterfaces.ContainsKey(typeof(T)))
306 {
307 iface = (T)m_moduleInterfaces[typeof(T)];
308 return true;
309 }
310 iface = default(T);
311 return false;
312 }
313
314 public T Get<T>()
315 {
316 return (T)m_moduleInterfaces[typeof(T)];
317 }
318
319 public BaseHttpServer GetHttpServer()
320 {
321 return m_httpServer;
322 }
323 #endregion
324
325 public void TestResponse(List<InventoryFolderBase> resp)
326 {
327 m_console.Output("response got");
328 }
329 }
330}
diff --git a/OpenSim/Grid/UserServer/Properties/AssemblyInfo.cs b/OpenSim/Grid/UserServer/Properties/AssemblyInfo.cs
deleted file mode 100644
index ba79a55..0000000
--- a/OpenSim/Grid/UserServer/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,63 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.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 OpenSimulator 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
28using System.Reflection;
29using System.Runtime.InteropServices;
30
31// General information about an assembly is controlled through the following
32// set of attributes. Change these attribute values to modify the information
33// associated with an assembly.
34
35[assembly : AssemblyTitle("OGS-UserServer")]
36[assembly : AssemblyDescription("")]
37[assembly : AssemblyConfiguration("")]
38[assembly : AssemblyCompany("http://opensimulator.org")]
39[assembly : AssemblyProduct("OGS-UserServer")]
40[assembly : AssemblyCopyright("Copyright (c) OpenSimulator.org Developers 2007-2009")]
41[assembly : AssemblyTrademark("")]
42[assembly : AssemblyCulture("")]
43
44// Setting ComVisible to false makes the types in this assembly not visible
45// to COM components. If you need to access a type in this assembly from
46// COM, set the ComVisible attribute to true on that type.
47
48[assembly : ComVisible(false)]
49
50// The following GUID is for the ID of the typelib if this project is exposed to COM
51
52[assembly : Guid("e266513a-090b-4d38-80f6-8599eef68c8c")]
53
54// Version information for an assembly consists of the following four values:
55//
56// Major Version
57// Minor Version
58// Build Number
59// Revision
60//
61
62[assembly : AssemblyVersion("0.6.5.*")]
63[assembly : AssemblyFileVersion("0.6.5.0")]
diff --git a/OpenSim/Grid/UserServer/UserServerCommandModule.cs b/OpenSim/Grid/UserServer/UserServerCommandModule.cs
deleted file mode 100644
index cca410e..0000000
--- a/OpenSim/Grid/UserServer/UserServerCommandModule.cs
+++ /dev/null
@@ -1,375 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.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 OpenSimulator 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
28using System;
29using System.Collections.Generic;
30using System.IO;
31using System.Reflection;
32using log4net;
33using log4net.Config;
34using OpenMetaverse;
35using OpenSim.Data;
36using OpenSim.Framework;
37using OpenSim.Framework.Communications;
38using OpenSim.Framework.Communications.Cache;
39using OpenSim.Framework.Console;
40using OpenSim.Framework.Servers;
41using OpenSim.Framework.Servers.HttpServer;
42using OpenSim.Framework.Statistics;
43using OpenSim.Grid.Communications.OGS1;
44using OpenSim.Grid.Framework;
45using OpenSim.Grid.UserServer.Modules;
46
47namespace OpenSim.Grid.UserServer
48{
49 public class UserServerCommandModule
50 {
51 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
52
53 protected CommandConsole m_console;
54 protected UserConfig m_cfg;
55
56 protected UserDataBaseService m_userDataBaseService;
57 protected UserLoginService m_loginService;
58
59 protected UUID m_lastCreatedUser = UUID.Random();
60
61 protected IGridServiceCore m_core;
62
63 public UserServerCommandModule()
64 {
65 }
66
67 public void Initialise(IGridServiceCore core)
68 {
69 m_core = core;
70 }
71
72 public void PostInitialise()
73 {
74 UserConfig cfg;
75 if (m_core.TryGet<UserConfig>(out cfg))
76 {
77 m_cfg = cfg;
78 }
79
80 UserDataBaseService userDBservice;
81 if (m_core.TryGet<UserDataBaseService>(out userDBservice))
82 {
83 m_userDataBaseService = userDBservice;
84 }
85
86 UserLoginService loginService;
87 if (m_core.TryGet<UserLoginService>(out loginService))
88 {
89 m_loginService = loginService;
90 }
91
92 CommandConsole console;
93 if ((m_core.TryGet<CommandConsole>(out console)) && (m_cfg != null)
94 && (m_userDataBaseService != null) && (m_loginService != null))
95 {
96 RegisterConsoleCommands(console);
97 }
98 }
99
100 public void RegisterHandlers(BaseHttpServer httpServer)
101 {
102
103 }
104
105 private void RegisterConsoleCommands(CommandConsole console)
106 {
107 m_console = console;
108 m_console.Commands.AddCommand("userserver", false, "create user",
109 "create user [<first> [<last> [<x> <y> [email]]]]",
110 "Create a new user account", RunCommand);
111
112 m_console.Commands.AddCommand("userserver", false, "reset user password",
113 "reset user password [<first> [<last> [<new password>]]]",
114 "Reset a user's password", RunCommand);
115
116 m_console.Commands.AddCommand("userserver", false, "login level",
117 "login level <level>",
118 "Set the minimum user level to log in", HandleLoginCommand);
119
120 m_console.Commands.AddCommand("userserver", false, "login reset",
121 "login reset",
122 "Reset the login level to allow all users",
123 HandleLoginCommand);
124
125 m_console.Commands.AddCommand("userserver", false, "login text",
126 "login text <text>",
127 "Set the text users will see on login", HandleLoginCommand);
128
129 m_console.Commands.AddCommand("userserver", false, "test-inventory",
130 "test-inventory",
131 "Perform a test inventory transaction", RunCommand);
132
133 m_console.Commands.AddCommand("userserver", false, "logoff-user",
134 "logoff-user <first> <last> <message>",
135 "Log off a named user", RunCommand);
136 }
137
138 #region Console Command Handlers
139 public void do_create(string[] args)
140 {
141 switch (args[0])
142 {
143 case "user":
144 CreateUser(args);
145 break;
146 }
147 }
148
149 /// <summary>
150 /// Execute switch for some of the reset commands
151 /// </summary>
152 /// <param name="args"></param>
153 protected void Reset(string[] args)
154 {
155 if (args.Length == 0)
156 return;
157
158 switch (args[0])
159 {
160 case "user":
161
162 switch (args[1])
163 {
164 case "password":
165 ResetUserPassword(args);
166 break;
167 }
168
169 break;
170 }
171 }
172
173 /// <summary>
174 /// Create a new user
175 /// </summary>
176 /// <param name="cmdparams">string array with parameters: firstname, lastname, password, locationX, locationY, email</param>
177 protected void CreateUser(string[] cmdparams)
178 {
179 string firstName;
180 string lastName;
181 string password;
182 string email;
183 uint regX = 1000;
184 uint regY = 1000;
185
186 if (cmdparams.Length < 2)
187 firstName = MainConsole.Instance.CmdPrompt("First name", "Default");
188 else firstName = cmdparams[1];
189
190 if (cmdparams.Length < 3)
191 lastName = MainConsole.Instance.CmdPrompt("Last name", "User");
192 else lastName = cmdparams[2];
193
194 if (cmdparams.Length < 4)
195 password = MainConsole.Instance.PasswdPrompt("Password");
196 else password = cmdparams[3];
197
198 if (cmdparams.Length < 5)
199 regX = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region X", regX.ToString()));
200 else regX = Convert.ToUInt32(cmdparams[4]);
201
202 if (cmdparams.Length < 6)
203 regY = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region Y", regY.ToString()));
204 else regY = Convert.ToUInt32(cmdparams[5]);
205
206 if (cmdparams.Length < 7)
207 email = MainConsole.Instance.CmdPrompt("Email", "");
208 else email = cmdparams[6];
209
210 if (null == m_userDataBaseService.GetUserProfile(firstName, lastName))
211 {
212 m_lastCreatedUser = m_userDataBaseService.AddUser(firstName, lastName, password, email, regX, regY);
213 }
214 else
215 {
216 m_log.ErrorFormat("[USERS]: A user with the name {0} {1} already exists!", firstName, lastName);
217 }
218 }
219
220 /// <summary>
221 /// Reset a user password.
222 /// </summary>
223 /// <param name="cmdparams"></param>
224 private void ResetUserPassword(string[] cmdparams)
225 {
226 string firstName;
227 string lastName;
228 string newPassword;
229
230 if (cmdparams.Length < 3)
231 firstName = MainConsole.Instance.CmdPrompt("First name");
232 else firstName = cmdparams[2];
233
234 if (cmdparams.Length < 4)
235 lastName = MainConsole.Instance.CmdPrompt("Last name");
236 else lastName = cmdparams[3];
237
238 if (cmdparams.Length < 5)
239 newPassword = MainConsole.Instance.PasswdPrompt("New password");
240 else newPassword = cmdparams[4];
241
242 m_userDataBaseService.ResetUserPassword(firstName, lastName, newPassword);
243 }
244
245 /*
246 private void HandleTestCommand(string module, string[] cmd)
247 {
248 m_log.Info("test command received");
249 }
250 */
251
252 private void HandleLoginCommand(string module, string[] cmd)
253 {
254 string subcommand = cmd[1];
255
256 switch (subcommand)
257 {
258 case "level":
259 // Set the minimal level to allow login
260 // Useful to allow grid update without worrying about users.
261 // or fixing critical issues
262 //
263 if (cmd.Length > 2)
264 {
265 int level = Convert.ToInt32(cmd[2]);
266 m_loginService.setloginlevel(level);
267 }
268 break;
269 case "reset":
270 m_loginService.setloginlevel(0);
271 break;
272 case "text":
273 if (cmd.Length > 2)
274 {
275 m_loginService.setwelcometext(cmd[2]);
276 }
277 break;
278 }
279 }
280
281 public void RunCommand(string module, string[] cmd)
282 {
283 List<string> args = new List<string>(cmd);
284 string command = cmd[0];
285
286 args.RemoveAt(0);
287
288 string[] cmdparams = args.ToArray();
289
290 switch (command)
291 {
292 case "create":
293 do_create(cmdparams);
294 break;
295
296 case "reset":
297 Reset(cmdparams);
298 break;
299
300
301 case "test-inventory":
302 // RestObjectPosterResponse<List<InventoryFolderBase>> requester = new RestObjectPosterResponse<List<InventoryFolderBase>>();
303 // requester.ReturnResponseVal = TestResponse;
304 // requester.BeginPostObject<UUID>(m_userManager._config.InventoryUrl + "RootFolders/", m_lastCreatedUser);
305 SynchronousRestObjectPoster.BeginPostObject<UUID, List<InventoryFolderBase>>(
306 "POST", m_cfg.InventoryUrl + "RootFolders/", m_lastCreatedUser);
307 break;
308
309 case "logoff-user":
310 if (cmdparams.Length >= 3)
311 {
312 string firstname = cmdparams[0];
313 string lastname = cmdparams[1];
314 string message = "";
315
316 for (int i = 2; i < cmdparams.Length; i++)
317 message += " " + cmdparams[i];
318
319 UserProfileData theUser = null;
320 try
321 {
322 theUser = m_loginService.GetTheUser(firstname, lastname);
323 }
324 catch (Exception)
325 {
326 m_log.Error("[LOGOFF]: Error getting user data from the database.");
327 }
328
329 if (theUser != null)
330 {
331 if (theUser.CurrentAgent != null)
332 {
333 if (theUser.CurrentAgent.AgentOnline)
334 {
335 m_log.Info("[LOGOFF]: Logging off requested user!");
336 m_loginService.LogOffUser(theUser, message);
337
338 theUser.CurrentAgent.AgentOnline = false;
339
340 m_loginService.CommitAgent(ref theUser);
341 }
342 else
343 {
344 m_log.Info(
345 "[LOGOFF]: User Doesn't appear to be online, sending the logoff message anyway.");
346 m_loginService.LogOffUser(theUser, message);
347
348 theUser.CurrentAgent.AgentOnline = false;
349
350 m_loginService.CommitAgent(ref theUser);
351 }
352 }
353 else
354 {
355 m_log.Error(
356 "[LOGOFF]: Unable to logoff-user. User doesn't have an agent record so I can't find the simulator to notify");
357 }
358 }
359 else
360 {
361 m_log.Info("[LOGOFF]: User doesn't exist in the database");
362 }
363 }
364 else
365 {
366 m_log.Error(
367 "[LOGOFF]: Invalid amount of parameters. logoff-user takes at least three. Firstname, Lastname, and message");
368 }
369
370 break;
371 }
372 }
373 }
374 #endregion
375}
diff --git a/OpenSim/Grid/UserServer/UserServerCommsManager.cs b/OpenSim/Grid/UserServer/UserServerCommsManager.cs
deleted file mode 100644
index 8ef693b..0000000
--- a/OpenSim/Grid/UserServer/UserServerCommsManager.cs
+++ /dev/null
@@ -1,40 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.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 OpenSimulator 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
28using OpenSim.Framework.Communications;
29
30namespace OpenSim.Grid.UserServer
31{
32 public class UserServerCommsManager : CommunicationsManager
33 {
34 public UserServerCommsManager(IInterServiceInventoryServices interServiceInventoryService)
35 : base(null, null)
36 {
37 m_interServiceInventoryService = interServiceInventoryService;
38 }
39 }
40}
diff --git a/OpenSim/Grid/UserServer/UserServerEventDispatchModule.cs b/OpenSim/Grid/UserServer/UserServerEventDispatchModule.cs
deleted file mode 100644
index 0ad2f02..0000000
--- a/OpenSim/Grid/UserServer/UserServerEventDispatchModule.cs
+++ /dev/null
@@ -1,142 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.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 OpenSimulator 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
28using System;
29using System.Collections.Generic;
30using System.IO;
31using System.Reflection;
32using log4net;
33using log4net.Config;
34using OpenMetaverse;
35using OpenSim.Data;
36using OpenSim.Framework;
37using OpenSim.Framework.Communications;
38using OpenSim.Framework.Communications.Cache;
39using OpenSim.Framework.Console;
40using OpenSim.Framework.Servers;
41using OpenSim.Framework.Servers.HttpServer;
42using OpenSim.Framework.Statistics;
43using OpenSim.Grid.Communications.OGS1;
44using OpenSim.Grid.Framework;
45using OpenSim.Grid.UserServer.Modules;
46
47namespace OpenSim.Grid.UserServer
48{
49 //Do we actually need these event dispatchers?
50 //shouldn't the other modules just directly register event handlers to each other?
51 public class UserServerEventDispatchModule
52 {
53 protected UserManager m_userManager;
54 protected MessageServersConnector m_messagesService;
55 protected UserLoginService m_loginService;
56
57 public UserServerEventDispatchModule(UserManager userManager, MessageServersConnector messagesService, UserLoginService loginService)
58 {
59 m_userManager = userManager;
60 m_messagesService = messagesService;
61 m_loginService = loginService;
62 }
63
64 public void Initialise(IGridServiceCore core)
65 {
66 }
67
68 public void PostInitialise()
69 {
70 m_loginService.OnUserLoggedInAtLocation += NotifyMessageServersUserLoggedInToLocation;
71 m_userManager.OnLogOffUser += NotifyMessageServersUserLoggOff;
72
73 m_messagesService.OnAgentLocation += HandleAgentLocation;
74 m_messagesService.OnAgentLeaving += HandleAgentLeaving;
75 m_messagesService.OnRegionStartup += HandleRegionStartup;
76 m_messagesService.OnRegionShutdown += HandleRegionShutdown;
77 }
78
79 public void RegisterHandlers(BaseHttpServer httpServer)
80 {
81
82 }
83
84 public void Close()
85 {
86 m_loginService.OnUserLoggedInAtLocation -= NotifyMessageServersUserLoggedInToLocation;
87 }
88
89 #region Event Handlers
90 public void NotifyMessageServersUserLoggOff(UUID agentID)
91 {
92 m_messagesService.TellMessageServersAboutUserLogoff(agentID);
93 }
94
95 public void NotifyMessageServersUserLoggedInToLocation(UUID agentID, UUID sessionID, UUID RegionID,
96 ulong regionhandle, float positionX, float positionY,
97 float positionZ, string firstname, string lastname)
98 {
99 m_messagesService.TellMessageServersAboutUser(agentID, sessionID, RegionID, regionhandle, positionX,
100 positionY, positionZ, firstname, lastname);
101 }
102
103 public void HandleAgentLocation(UUID agentID, UUID regionID, ulong regionHandle)
104 {
105 m_userManager.HandleAgentLocation(agentID, regionID, regionHandle);
106 }
107
108 public void HandleAgentLeaving(UUID agentID, UUID regionID, ulong regionHandle)
109 {
110 m_userManager.HandleAgentLeaving(agentID, regionID, regionHandle);
111 }
112
113 public void HandleRegionStartup(UUID regionID)
114 {
115 // This might seem strange, that we send this back to the
116 // server it came from. But there is method to the madness.
117 // There can be multiple user servers on the same database,
118 // and each can have multiple messaging servers. So, we send
119 // it to all known user servers, who send it to all known
120 // message servers. That way, we should be able to finally
121 // update presence to all regions and thereby all friends
122 //
123 m_userManager.HandleRegionStartup(regionID);
124 m_messagesService.TellMessageServersAboutRegionShutdown(regionID);
125 }
126
127 public void HandleRegionShutdown(UUID regionID)
128 {
129 // This might seem strange, that we send this back to the
130 // server it came from. But there is method to the madness.
131 // There can be multiple user servers on the same database,
132 // and each can have multiple messaging servers. So, we send
133 // it to all known user servers, who send it to all known
134 // message servers. That way, we should be able to finally
135 // update presence to all regions and thereby all friends
136 //
137 m_userManager.HandleRegionShutdown(regionID);
138 m_messagesService.TellMessageServersAboutRegionShutdown(regionID);
139 }
140 #endregion
141 }
142}