aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/UserServer
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Grid/UserServer')
-rw-r--r--OpenSim/Grid/UserServer/Main.cs316
-rw-r--r--OpenSim/Grid/UserServer/Properties/AssemblyInfo.cs63
-rw-r--r--OpenSim/Grid/UserServer/UserServerCommandModule.cs375
-rw-r--r--OpenSim/Grid/UserServer/UserServerCommsManager.cs39
-rw-r--r--OpenSim/Grid/UserServer/UserServerEventDispatchModule.cs142
5 files changed, 0 insertions, 935 deletions
diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs
deleted file mode 100644
index d598728..0000000
--- a/OpenSim/Grid/UserServer/Main.cs
+++ /dev/null
@@ -1,316 +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 MessageServersConnector m_messagesService;
68
69 protected UserServerCommandModule m_consoleCommandModule;
70 protected UserServerEventDispatchModule m_eventDispatcher;
71
72 protected AvatarCreationModule m_appearanceModule;
73
74 protected static string m_consoleType = "local";
75 protected static IConfigSource m_config = null;
76 protected static string m_configFile = "UserServer_Config.xml";
77
78 public static void Main(string[] args)
79 {
80 ArgvConfigSource argvSource = new ArgvConfigSource(args);
81 argvSource.AddSwitch("Startup", "console", "c");
82 argvSource.AddSwitch("Startup", "xmlfile", "x");
83
84 IConfig startupConfig = argvSource.Configs["Startup"];
85 if (startupConfig != null)
86 {
87 m_consoleType = startupConfig.GetString("console", "local");
88 m_configFile = startupConfig.GetString("xmlfile", "UserServer_Config.xml");
89 }
90
91 m_config = argvSource;
92
93 XmlConfigurator.Configure();
94
95 m_log.Info("Launching UserServer...");
96
97 OpenUser_Main userserver = new OpenUser_Main();
98
99 userserver.Startup();
100 userserver.Work();
101 }
102
103 public OpenUser_Main()
104 {
105 switch (m_consoleType)
106 {
107 case "rest":
108 m_console = new RemoteConsole("User");
109 break;
110 case "basic":
111 m_console = new CommandConsole("User");
112 break;
113 default:
114 m_console = new LocalConsole("User");
115 break;
116 }
117 MainConsole.Instance = m_console;
118 }
119
120 public void Work()
121 {
122 m_console.Output("Enter help for a list of commands\n");
123
124 while (true)
125 {
126 m_console.Prompt();
127 }
128 }
129
130 protected override void StartupSpecific()
131 {
132 IInterServiceInventoryServices inventoryService = StartupCoreComponents();
133
134 m_stats = StatsManager.StartCollectingUserStats();
135
136 //setup services/modules
137 StartupUserServerModules();
138
139 StartOtherComponents(inventoryService);
140
141 //PostInitialise the modules
142 PostInitialiseModules();
143
144 //register http handlers and start http server
145 m_log.Info("[STARTUP]: Starting HTTP process");
146 RegisterHttpHandlers();
147 m_httpServer.Start();
148
149 base.StartupSpecific();
150 }
151
152 protected virtual IInterServiceInventoryServices StartupCoreComponents()
153 {
154 Cfg = new UserConfig("USER SERVER", (Path.Combine(Util.configDir(), m_configFile)));
155
156 m_httpServer = new BaseHttpServer(Cfg.HttpPort);
157
158 if (m_console is RemoteConsole)
159 {
160 RemoteConsole c = (RemoteConsole)m_console;
161 c.SetServer(m_httpServer);
162 IConfig netConfig = m_config.AddConfig("Network");
163 netConfig.Set("ConsoleUser", Cfg.ConsoleUser);
164 netConfig.Set("ConsolePass", Cfg.ConsolePass);
165 c.ReadConfig(m_config);
166 }
167
168 RegisterInterface<CommandConsole>(m_console);
169 RegisterInterface<UserConfig>(Cfg);
170
171 //Should be in modules?
172 IInterServiceInventoryServices inventoryService = new OGS1InterServiceInventoryService(Cfg.InventoryUrl);
173 // IRegionProfileRouter regionProfileService = new RegionProfileServiceProxy();
174
175 RegisterInterface<IInterServiceInventoryServices>(inventoryService);
176 // RegisterInterface<IRegionProfileRouter>(regionProfileService);
177
178 return inventoryService;
179 }
180
181 /// <summary>
182 /// Start up the user manager
183 /// </summary>
184 /// <param name="inventoryService"></param>
185 protected virtual void StartupUserServerModules()
186 {
187 m_log.Info("[STARTUP]: Establishing data connection");
188
189 //we only need core components so we can request them from here
190 IInterServiceInventoryServices inventoryService;
191 TryGet<IInterServiceInventoryServices>(out inventoryService);
192
193 CommunicationsManager commsManager = new UserServerCommsManager(inventoryService);
194
195 //setup database access service, for now this has to be created before the other modules.
196 m_userDataBaseService = new UserDataBaseService(commsManager);
197 m_userDataBaseService.Initialise(this);
198
199 //TODO: change these modules so they fetch the databaseService class in the PostInitialise method
200 m_userManager = new UserManager(m_userDataBaseService);
201 m_userManager.Initialise(this);
202
203 m_avatarAppearanceModule = new UserServerAvatarAppearanceModule(m_userDataBaseService);
204 m_avatarAppearanceModule.Initialise(this);
205
206 m_friendsModule = new UserServerFriendsModule(m_userDataBaseService);
207 m_friendsModule.Initialise(this);
208
209 m_consoleCommandModule = new UserServerCommandModule();
210 m_consoleCommandModule.Initialise(this);
211
212 m_messagesService = new MessageServersConnector();
213 m_messagesService.Initialise(this);
214 }
215
216 protected virtual void StartOtherComponents(IInterServiceInventoryServices inventoryService)
217 {
218 m_appearanceModule = new AvatarCreationModule(m_userDataBaseService, Cfg, inventoryService);
219 m_appearanceModule.Initialise(this);
220
221 StartupLoginService(inventoryService);
222 //
223 // Get the minimum defaultLevel to access to the grid
224 //
225 m_loginService.setloginlevel((int)Cfg.DefaultUserLevel);
226
227 RegisterInterface<UserLoginService>(m_loginService); //TODO: should be done in the login service
228
229 m_eventDispatcher = new UserServerEventDispatchModule(m_userManager, m_messagesService, m_loginService);
230 m_eventDispatcher.Initialise(this);
231 }
232
233 /// <summary>
234 /// Start up the login service
235 /// </summary>
236 /// <param name="inventoryService"></param>
237 protected virtual void StartupLoginService(IInterServiceInventoryServices inventoryService)
238 {
239 m_loginService = new UserLoginService(
240 m_userDataBaseService, inventoryService, new LibraryRootFolder(Cfg.LibraryXmlfile), Cfg, Cfg.DefaultStartupMsg, new RegionProfileServiceProxy());
241
242 }
243
244 protected virtual void PostInitialiseModules()
245 {
246 m_consoleCommandModule.PostInitialise(); //it will register its Console command handlers in here
247 m_userDataBaseService.PostInitialise();
248 m_messagesService.PostInitialise();
249 m_eventDispatcher.PostInitialise(); //it will register event handlers in here
250 m_userManager.PostInitialise();
251 m_avatarAppearanceModule.PostInitialise();
252 m_friendsModule.PostInitialise();
253 }
254
255 protected virtual void RegisterHttpHandlers()
256 {
257 m_loginService.RegisterHandlers(m_httpServer, Cfg.EnableLLSDLogin, true);
258
259 m_userManager.RegisterHandlers(m_httpServer);
260 m_friendsModule.RegisterHandlers(m_httpServer);
261 m_avatarAppearanceModule.RegisterHandlers(m_httpServer);
262 m_messagesService.RegisterHandlers(m_httpServer);
263 }
264
265 public override void ShutdownSpecific()
266 {
267 m_eventDispatcher.Close();
268 }
269
270 #region IUGAIMCore
271 protected Dictionary<Type, object> m_moduleInterfaces = new Dictionary<Type, object>();
272
273 /// <summary>
274 /// Register an Module interface.
275 /// </summary>
276 /// <typeparam name="T"></typeparam>
277 /// <param name="iface"></param>
278 public void RegisterInterface<T>(T iface)
279 {
280 lock (m_moduleInterfaces)
281 {
282 if (!m_moduleInterfaces.ContainsKey(typeof(T)))
283 {
284 m_moduleInterfaces.Add(typeof(T), iface);
285 }
286 }
287 }
288
289 public bool TryGet<T>(out T iface)
290 {
291 if (m_moduleInterfaces.ContainsKey(typeof(T)))
292 {
293 iface = (T)m_moduleInterfaces[typeof(T)];
294 return true;
295 }
296 iface = default(T);
297 return false;
298 }
299
300 public T Get<T>()
301 {
302 return (T)m_moduleInterfaces[typeof(T)];
303 }
304
305 public BaseHttpServer GetHttpServer()
306 {
307 return m_httpServer;
308 }
309 #endregion
310
311 public void TestResponse(List<InventoryFolderBase> resp)
312 {
313 m_console.Output("response got");
314 }
315 }
316}
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 7dc514c..0000000
--- a/OpenSim/Grid/UserServer/UserServerCommsManager.cs
+++ /dev/null
@@ -1,39 +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 }
38 }
39}
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}