From 522d6261f11ffaf8320c3f0775beb5d0608ce226 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Fri, 16 Sep 2011 00:12:12 +0100 Subject: [PATCH] Correctly create a freshly created estate owner's default items and avatar entries on standalone if applicable. --- OpenSim/Region/Application/OpenSimBase.cs | 50 +++++++++++ .../LocalUserAccountServiceConnector.cs | 26 +++--- OpenSim/Region/Framework/Scenes/Scene.cs | 82 ------------------- .../UserAccountService/UserAccountService.cs | 4 +- prebuild.xml | 2 + 5 files changed, 70 insertions(+), 94 deletions(-) diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index 92e8ed1d49..30601696d5 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs @@ -41,11 +41,14 @@ using OpenSim.Framework.Servers; using OpenSim.Framework.Servers.HttpServer; using OpenSim.Framework.Statistics; using OpenSim.Region.ClientStack; +using OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts; using OpenSim.Region.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Physics.Manager; using OpenSim.Server.Base; +using OpenSim.Services.Interfaces; +using OpenSim.Services.UserAccountService; namespace OpenSim { @@ -362,6 +365,53 @@ namespace OpenSim scene.SetModuleInterfaces(); + // FIXME: Put me into a separate method! + while (regionInfo.EstateSettings.EstateOwner == UUID.Zero && MainConsole.Instance != null) + { + MainConsole.Instance.OutputFormat("Estate {0} has no owner set.", regionInfo.EstateSettings.EstateName); + List excluded = new List(new char[1]{' '}); + string first = MainConsole.Instance.CmdPrompt("Estate owner first name", "Test", excluded); + string last = MainConsole.Instance.CmdPrompt("Estate owner last name", "User", excluded); + + UserAccount account = scene.UserAccountService.GetUserAccount(regionInfo.ScopeID, first, last); + + if (account == null) + { + m_log.DebugFormat("A {0}", scene.UserAccountService.GetType()); + +// if (scene.UserAccountService is LocalUserAccountServicesConnector) +// { +// IUserAccountService innerUas +// = ((LocalUserAccountServicesConnector)scene.UserAccountService).UserAccountService; +// +// m_log.DebugFormat("B {0}", innerUas.GetType()); +// +// if (innerUas is UserAccountService) +// { + + if (scene.UserAccountService is UserAccountService) + { + string password = MainConsole.Instance.PasswdPrompt("Password"); + string email = MainConsole.Instance.CmdPrompt("Email", ""); + + // TODO: Where do we put m_regInfo.ScopeID? + account = ((UserAccountService)scene.UserAccountService).CreateUser(first, last, password, email); + } +// } + } + + if (account == null) + { + m_log.ErrorFormat( + "[OPENSIM]: Unable to store account. If this simulator is connected to a grid, you must create the estate owner account first."); + } + else + { + regionInfo.EstateSettings.EstateOwner = account.PrincipalID; + regionInfo.EstateSettings.Save(); + } + } + // Prims have to be loaded after module configuration since some modules may be invoked during the load scene.LoadPrimsFromStorage(regionInfo.originRegionID); diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs index 30ebb2147b..546fe8856e 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs @@ -45,7 +45,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType); - private IUserAccountService m_UserService; + /// + /// This is not on the IUserAccountService. It's only being used so that standalone scenes can punch through + /// to a local UserAccountService when setting up an estate manager. + /// + public IUserAccountService UserAccountService { get; private set; } + private UserAccountCache m_Cache; private bool m_Enabled = false; @@ -86,9 +91,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts } Object[] args = new Object[] { source }; - m_UserService = ServerUtils.LoadPlugin(serviceDll, args); + UserAccountService = ServerUtils.LoadPlugin(serviceDll, args); - if (m_UserService == null) + if (UserAccountService == null) { m_log.ErrorFormat( "[LOCAL USER ACCOUNT SERVICE CONNECTOR]: Cannot load user account service specified as {0}", serviceDll); @@ -119,7 +124,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts if (!m_Enabled) return; - scene.RegisterModuleInterface(m_UserService); + scene.RegisterModuleInterface(UserAccountService); } public void RemoveRegion(Scene scene) @@ -147,7 +152,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts if (inCache) return account; - account = m_UserService.GetUserAccount(scopeID, userID); + account = UserAccountService.GetUserAccount(scopeID, userID); m_Cache.Cache(userID, account); return account; @@ -160,7 +165,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts if (inCache) return account; - account = m_UserService.GetUserAccount(scopeID, firstName, lastName); + account = UserAccountService.GetUserAccount(scopeID, firstName, lastName); if (account != null) m_Cache.Cache(account.PrincipalID, account); @@ -169,22 +174,21 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts public UserAccount GetUserAccount(UUID scopeID, string Email) { - return m_UserService.GetUserAccount(scopeID, Email); + return UserAccountService.GetUserAccount(scopeID, Email); } public List GetUserAccounts(UUID scopeID, string query) { - return m_UserService.GetUserAccounts(scopeID, query); + return UserAccountService.GetUserAccounts(scopeID, query); } // Update all updatable fields // public bool StoreUserAccount(UserAccount data) { - return m_UserService.StoreUserAccount(data); + return UserAccountService.StoreUserAccount(data); } #endregion - } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index f394a956cf..976e001a60 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1170,88 +1170,6 @@ namespace OpenSim.Region.Framework.Scenes m_dialogModule = RequestModuleInterface(); m_capsModule = RequestModuleInterface(); m_teleportModule = RequestModuleInterface(); - - // Shoving this in here for now, because we have the needed - // interfaces at this point - // - // TODO: Find a better place for this - // - while (m_regInfo.EstateSettings.EstateOwner == UUID.Zero && MainConsole.Instance != null) - { - MainConsole.Instance.OutputFormat("Estate {0} has no owner set.", m_regInfo.EstateSettings.EstateName); - List excluded = new List(new char[1]{' '}); - string first = MainConsole.Instance.CmdPrompt("Estate owner first name", "Test", excluded); - string last = MainConsole.Instance.CmdPrompt("Estate owner last name", "User", excluded); - - UserAccount account = UserAccountService.GetUserAccount(m_regInfo.ScopeID, first, last); - - if (account == null) - { - // Create a new account - account = new UserAccount(m_regInfo.ScopeID, first, last, String.Empty); - if (account.ServiceURLs == null || (account.ServiceURLs != null && account.ServiceURLs.Count == 0)) - { - account.ServiceURLs = new Dictionary(); - account.ServiceURLs["HomeURI"] = string.Empty; - account.ServiceURLs["GatekeeperURI"] = string.Empty; - account.ServiceURLs["InventoryServerURI"] = string.Empty; - account.ServiceURLs["AssetServerURI"] = string.Empty; - } - - if (UserAccountService.StoreUserAccount(account)) - { - string password = MainConsole.Instance.PasswdPrompt("Password"); - string email = MainConsole.Instance.CmdPrompt("Email", ""); - - account.Email = email; - UserAccountService.StoreUserAccount(account); - - bool success = false; - success = AuthenticationService.SetPassword(account.PrincipalID, password); - if (!success) - m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to set password for account {0} {1}.", - first, last); - - GridRegion home = null; - if (GridService != null) - { - List defaultRegions = GridService.GetDefaultRegions(UUID.Zero); - if (defaultRegions != null && defaultRegions.Count >= 1) - home = defaultRegions[0]; - - if (GridUserService != null && home != null) - GridUserService.SetHome(account.PrincipalID.ToString(), home.RegionID, new Vector3(128, 128, 0), new Vector3(0, 1, 0)); - else - m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to set home for account {0} {1}.", - first, last); - - } - else - m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to retrieve home region for account {0} {1}.", - first, last); - - if (InventoryService != null) - success = InventoryService.CreateUserInventory(account.PrincipalID); - if (!success) - m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to create inventory for account {0} {1}.", - first, last); - - - - m_log.InfoFormat("[USER ACCOUNT SERVICE]: Account {0} {1} created successfully", first, last); - - m_regInfo.EstateSettings.EstateOwner = account.PrincipalID; - m_regInfo.EstateSettings.Save(); - } - else - m_log.ErrorFormat("[SCENE]: Unable to store account. If this simulator is connected to a grid, you must create the estate owner account first."); - } - else - { - m_regInfo.EstateSettings.EstateOwner = account.PrincipalID; - m_regInfo.EstateSettings.Save(); - } - } } #endregion diff --git a/OpenSim/Services/UserAccountService/UserAccountService.cs b/OpenSim/Services/UserAccountService/UserAccountService.cs index 21ce86ceb0..0acfdcf70a 100644 --- a/OpenSim/Services/UserAccountService/UserAccountService.cs +++ b/OpenSim/Services/UserAccountService/UserAccountService.cs @@ -456,7 +456,7 @@ namespace OpenSim.Services.UserAccountService /// /// /// - private void CreateUser(string firstName, string lastName, string password, string email) + public UserAccount CreateUser(string firstName, string lastName, string password, string email) { UserAccount account = GetUserAccount(UUID.Zero, firstName, lastName); if (null == account) @@ -524,6 +524,8 @@ namespace OpenSim.Services.UserAccountService { m_log.ErrorFormat("[USER ACCOUNT SERVICE]: A user with the name {0} {1} already exists!", firstName, lastName); } + + return account; } private void CreateDefaultAppearanceEntries(UUID principalID) diff --git a/prebuild.xml b/prebuild.xml index 392fbdcf64..91308a4c6a 100644 --- a/prebuild.xml +++ b/prebuild.xml @@ -1840,6 +1840,8 @@ + +