diff options
author | Justin Clark-Casey (justincc) | 2011-09-16 00:24:23 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2011-09-16 00:24:23 +0100 |
commit | 4ae4b14b5da9b828bbb7c4e5b05693ad8528556a (patch) | |
tree | c33b3b79b081e9b43bb4dfccda3fd3a7e43272d5 /OpenSim | |
parent | Correctly create a freshly created estate owner's default items and avatar en... (diff) | |
download | opensim-SC-4ae4b14b5da9b828bbb7c4e5b05693ad8528556a.zip opensim-SC-4ae4b14b5da9b828bbb7c4e5b05693ad8528556a.tar.gz opensim-SC-4ae4b14b5da9b828bbb7c4e5b05693ad8528556a.tar.bz2 opensim-SC-4ae4b14b5da9b828bbb7c4e5b05693ad8528556a.tar.xz |
refactor: move estate owner setup code into separate method
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Region/Application/OpenSimBase.cs | 95 | ||||
-rw-r--r-- | OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs | 2 |
2 files changed, 52 insertions, 45 deletions
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index 3060169..8662ea8 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs | |||
@@ -365,52 +365,8 @@ namespace OpenSim | |||
365 | 365 | ||
366 | scene.SetModuleInterfaces(); | 366 | scene.SetModuleInterfaces(); |
367 | 367 | ||
368 | // FIXME: Put me into a separate method! | ||
369 | while (regionInfo.EstateSettings.EstateOwner == UUID.Zero && MainConsole.Instance != null) | 368 | while (regionInfo.EstateSettings.EstateOwner == UUID.Zero && MainConsole.Instance != null) |
370 | { | 369 | SetUpEstateOwner(scene); |
371 | MainConsole.Instance.OutputFormat("Estate {0} has no owner set.", regionInfo.EstateSettings.EstateName); | ||
372 | List<char> excluded = new List<char>(new char[1]{' '}); | ||
373 | string first = MainConsole.Instance.CmdPrompt("Estate owner first name", "Test", excluded); | ||
374 | string last = MainConsole.Instance.CmdPrompt("Estate owner last name", "User", excluded); | ||
375 | |||
376 | UserAccount account = scene.UserAccountService.GetUserAccount(regionInfo.ScopeID, first, last); | ||
377 | |||
378 | if (account == null) | ||
379 | { | ||
380 | m_log.DebugFormat("A {0}", scene.UserAccountService.GetType()); | ||
381 | |||
382 | // if (scene.UserAccountService is LocalUserAccountServicesConnector) | ||
383 | // { | ||
384 | // IUserAccountService innerUas | ||
385 | // = ((LocalUserAccountServicesConnector)scene.UserAccountService).UserAccountService; | ||
386 | // | ||
387 | // m_log.DebugFormat("B {0}", innerUas.GetType()); | ||
388 | // | ||
389 | // if (innerUas is UserAccountService) | ||
390 | // { | ||
391 | |||
392 | if (scene.UserAccountService is UserAccountService) | ||
393 | { | ||
394 | string password = MainConsole.Instance.PasswdPrompt("Password"); | ||
395 | string email = MainConsole.Instance.CmdPrompt("Email", ""); | ||
396 | |||
397 | // TODO: Where do we put m_regInfo.ScopeID? | ||
398 | account = ((UserAccountService)scene.UserAccountService).CreateUser(first, last, password, email); | ||
399 | } | ||
400 | // } | ||
401 | } | ||
402 | |||
403 | if (account == null) | ||
404 | { | ||
405 | m_log.ErrorFormat( | ||
406 | "[OPENSIM]: Unable to store account. If this simulator is connected to a grid, you must create the estate owner account first."); | ||
407 | } | ||
408 | else | ||
409 | { | ||
410 | regionInfo.EstateSettings.EstateOwner = account.PrincipalID; | ||
411 | regionInfo.EstateSettings.Save(); | ||
412 | } | ||
413 | } | ||
414 | 370 | ||
415 | // Prims have to be loaded after module configuration since some modules may be invoked during the load | 371 | // Prims have to be loaded after module configuration since some modules may be invoked during the load |
416 | scene.LoadPrimsFromStorage(regionInfo.originRegionID); | 372 | scene.LoadPrimsFromStorage(regionInfo.originRegionID); |
@@ -466,6 +422,55 @@ namespace OpenSim | |||
466 | return clientServer; | 422 | return clientServer; |
467 | } | 423 | } |
468 | 424 | ||
425 | private void SetUpEstateOwner(Scene scene) | ||
426 | { | ||
427 | RegionInfo regionInfo = scene.RegionInfo; | ||
428 | |||
429 | MainConsole.Instance.OutputFormat("Estate {0} has no owner set.", regionInfo.EstateSettings.EstateName); | ||
430 | List<char> excluded = new List<char>(new char[1]{' '}); | ||
431 | string first = MainConsole.Instance.CmdPrompt("Estate owner first name", "Test", excluded); | ||
432 | string last = MainConsole.Instance.CmdPrompt("Estate owner last name", "User", excluded); | ||
433 | |||
434 | UserAccount account = scene.UserAccountService.GetUserAccount(regionInfo.ScopeID, first, last); | ||
435 | |||
436 | if (account == null) | ||
437 | { | ||
438 | |||
439 | // XXX: The LocalUserAccountServicesConnector is currently registering its inner service rather than | ||
440 | // itself! | ||
441 | // if (scene.UserAccountService is LocalUserAccountServicesConnector) | ||
442 | // { | ||
443 | // IUserAccountService innerUas | ||
444 | // = ((LocalUserAccountServicesConnector)scene.UserAccountService).UserAccountService; | ||
445 | // | ||
446 | // m_log.DebugFormat("B {0}", innerUas.GetType()); | ||
447 | // | ||
448 | // if (innerUas is UserAccountService) | ||
449 | // { | ||
450 | |||
451 | if (scene.UserAccountService is UserAccountService) | ||
452 | { | ||
453 | string password = MainConsole.Instance.PasswdPrompt("Password"); | ||
454 | string email = MainConsole.Instance.CmdPrompt("Email", ""); | ||
455 | |||
456 | // TODO: Where do we put m_regInfo.ScopeID? | ||
457 | account = ((UserAccountService)scene.UserAccountService).CreateUser(first, last, password, email); | ||
458 | } | ||
459 | // } | ||
460 | } | ||
461 | |||
462 | if (account == null) | ||
463 | { | ||
464 | m_log.ErrorFormat( | ||
465 | "[OPENSIM]: Unable to store account. If this simulator is connected to a grid, you must create the estate owner account first."); | ||
466 | } | ||
467 | else | ||
468 | { | ||
469 | regionInfo.EstateSettings.EstateOwner = account.PrincipalID; | ||
470 | regionInfo.EstateSettings.Save(); | ||
471 | } | ||
472 | } | ||
473 | |||
469 | private void ShutdownRegion(Scene scene) | 474 | private void ShutdownRegion(Scene scene) |
470 | { | 475 | { |
471 | m_log.DebugFormat("[SHUTDOWN]: Shutting down region {0}", scene.RegionInfo.RegionName); | 476 | m_log.DebugFormat("[SHUTDOWN]: Shutting down region {0}", scene.RegionInfo.RegionName); |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs index 546fe88..0a0ce3c 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs | |||
@@ -124,6 +124,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts | |||
124 | if (!m_Enabled) | 124 | if (!m_Enabled) |
125 | return; | 125 | return; |
126 | 126 | ||
127 | // FIXME: Why do we bother setting this module and caching up if we just end up registering the inner | ||
128 | // user account service?! | ||
127 | scene.RegisterModuleInterface<IUserAccountService>(UserAccountService); | 129 | scene.RegisterModuleInterface<IUserAccountService>(UserAccountService); |
128 | } | 130 | } |
129 | 131 | ||