public bool CreateNewEstate(UUID regionID, string estateName, string ownerName) { object remoteValue = InternalDoRemote(regionID, estateName, ownerName); if (remoteValue != null || m_doRemoteOnly) { return(remoteValue == null ? false : (bool)remoteValue); } IEstateConnector conn = Aurora.DataManager.DataManager.RequestPlugin <IEstateConnector>(); if (conn != null) { var account = m_registry.RequestModuleInterface <IUserAccountService>().GetUserAccount(null, ownerName); if (account != null) { UUID userID = account.PrincipalID; conn.DelinkRegion(regionID); return(conn.CreateNewEstate(new EstateSettings() { EstateName = estateName, EstateOwner = userID }, regionID) != 0); } } return(false); }
/// <summary> /// Correct the system estate ID and update any linked regions. /// </summary> /// <param name="estateConnector">Estate connector.</param> /// <param name="eS">E s.</param> /// <param name="newEstateID">New estate I.</param> static void UpdateSystemEstates(IEstateConnector estateConnector, EstateSettings eS, int newEstateID) { // this may be an ID correction or just an estate name change uint oldEstateID = eS.EstateID; // get existing linked regions var regions = estateConnector.GetRegions((int)oldEstateID); // recreate the correct estate? if (oldEstateID != newEstateID) { estateConnector.DeleteEstate((int)oldEstateID); newEstateID = estateConnector.CreateNewEstate(eS); MainConsole.Instance.Info("System estate '" + eS.EstateName + "' is present but the ID was corrected."); } // re-link regions foreach (UUID regID in regions) { estateConnector.LinkRegion(regID, newEstateID); } if (regions.Count > 0) { MainConsole.Instance.InfoFormat("Relinked {0} regions", regions.Count); } }
/// <summary> /// Checks for a valid system estate. Adds or corrects if required /// </summary> /// <param name="estateConnector">Estate connector.</param> private void CheckSystemEstateInfo() { // these should have already been checked but just make sure... if (m_estateConnector == null) { return; } if (m_estateConnector.RemoteCalls()) { return; } EstateSettings ES; // ES = estateConnector.GetEstateSettings (Constants.SystemEstateName); //ES = m_estateConnector.GetEstateSettings (SystemEstateName); ES = m_estateConnector.GetEstateSettings(Constants.SystemEstateID); if (ES != null) { // ensure correct ID if (ES.EstateID != Constants.SystemEstateID) { UpdateSystemEstates(m_estateConnector, ES); } // in case of configuration changes if (ES.EstateName != SystemEstateName) { ES.EstateName = SystemEstateName; m_estateConnector.SaveEstateSettings(ES); MainConsole.Instance.Info("[EstateService]: The system Estate name has been updated to " + SystemEstateName); } return; } // Create a new estate ES = new EstateSettings(); ES.EstateName = SystemEstateName; ES.EstateOwner = (UUID)Constants.RealEstateOwnerUUID; ES.EstateID = (uint)m_estateConnector.CreateNewEstate(ES); if (ES.EstateID == 0) { MainConsole.Instance.Warn("There was an error in creating the system estate: " + ES.EstateName); //EstateName holds the error. See LocalEstateConnector for more info. } else { MainConsole.Instance.InfoFormat("[EstateService]: The estate '{0}' owned by '{1}' has been created.", SystemEstateName, SystemEstateOwnerName); } }
/// <summary> /// Creates a new estate. /// </summary> /// <param name="scene">Scene.</param> /// <param name="cmd">Cmd.</param> protected void CreateEstateCommand(IScene scene, string [] cmd) { IEstateConnector estateConnector = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector> (); IUserAccountService accountService = m_registry.RequestModuleInterface <IUserAccountService> (); ISystemAccountService sysAccounts = m_registry.RequestModuleInterface <ISystemAccountService> (); string estateName = ""; string estateOwner = sysAccounts.SystemEstateOwnerName; // check for passed estate name estateName = (cmd.Length < 3) ? MainConsole.Instance.Prompt("Estate name", estateName) : cmd [2]; if (estateName == "") { return; } // verify that the estate does not already exist if (estateConnector.EstateExists(estateName)) { MainConsole.Instance.ErrorFormat("[EstateService]: The estate '{0}' already exists!", estateName); return; } // owner? estateOwner = (cmd.Length > 3) ? Util.CombineParams(cmd, 4) // in case of spaces in the name eg Allan Allard : MainConsole.Instance.Prompt("Estate owner: ", estateOwner); if (estateOwner == "") { return; } // check to make sure the user exists UserAccount account = accountService.GetUserAccount(null, estateOwner); if (account == null) { MainConsole.Instance.WarnFormat("[User account service]: The user, '{0}' was not found!", estateOwner); // temporary fix until remote user creation can be implemented if (accountService.IsLocalConnector) { string createUser = MainConsole.Instance.Prompt("Do you wish to create this user? (yes/no)", "yes").ToLower(); if (!createUser.StartsWith("y", StringComparison.Ordinal)) { return; } // Create a new account string password = MainConsole.Instance.PasswordPrompt(estateOwner + "'s password"); string email = MainConsole.Instance.Prompt(estateOwner + "'s email", ""); accountService.CreateUser(estateOwner, Util.Md5Hash(password), email); // CreateUser will tell us success or problem account = accountService.GetUserAccount(null, estateOwner); if (account == null) { MainConsole.Instance.ErrorFormat( "[EstateService]: Unable to store account details.\n If this simulator is connected to a grid, create the estate owner account first at the grid level."); return; } } else { MainConsole.Instance.WarnFormat("[User account service]: The user must be created on the Grid before assigning an estate!"); MainConsole.Instance.WarnFormat("[User account service]: Regions should be assigned to the system user estate until this can be corrected"); return; } } // check for bogies... if (Utilities.IsSystemUser(account.PrincipalID)) { MainConsole.Instance.Info("[EstateService]: Tsk, tsk. System users should not be used as estate managers!"); return; } // we have an estate name and a user // Create a new estate var ES = new EstateSettings(); ES.EstateName = estateName; ES.EstateOwner = account.PrincipalID; ES.EstateID = (uint)estateConnector.CreateNewEstate(ES); if (ES.EstateID == 0) { MainConsole.Instance.Warn("There was an error in creating this estate: " + ES.EstateName); //EstateName holds the error. See LocalEstateConnector for more info. } else { MainConsole.Instance.InfoFormat("[EstateService]: The estate '{0}' owned by '{1}' has been created.", estateName, estateOwner); } }
/// <summary> /// Checks for a valid system estate. Adds or corrects if required /// </summary> /// <param name="estateID">Estate I.</param> /// <param name="estateName">Estate name.</param> /// <param name="ownerUUID">Owner UUI.</param> void CheckSystemEstateInfo(int estateID, string estateName, UUID ownerUUID) { // these should have already been checked but just make sure... if (m_estateConnector == null) { return; } if (m_estateConnector.RemoteCalls()) { return; } ISystemAccountService sysAccounts = m_registry.RequestModuleInterface <ISystemAccountService> (); EstateSettings ES; // check for existing estate name in case of estate ID change ES = m_estateConnector.GetEstateSettings(estateName); if (ES != null) { // ensure correct ID if (ES.EstateID != estateID) { UpdateSystemEstates(m_estateConnector, ES, estateID); } } ES = m_estateConnector.GetEstateIDSettings(estateID); if ((ES != null) && (ES.EstateID != 0)) { // ensure correct owner if (ES.EstateOwner != ownerUUID) { ES.EstateOwner = ownerUUID; m_estateConnector.SaveEstateSettings(ES); MainConsole.Instance.Info("[EstateService]: The system Estate owner has been updated to " + sysAccounts.GetSystemEstateOwnerName(estateID)); } // in case of configuration changes if (ES.EstateName != estateName) { ES.EstateName = estateName; m_estateConnector.SaveEstateSettings(ES); MainConsole.Instance.Info("[EstateService]: The system Estate name has been updated to " + estateName); } return; } // Create a new estate ES = new EstateSettings(); ES.EstateName = estateName; ES.EstateOwner = ownerUUID; ES.EstateID = (uint)m_estateConnector.CreateNewEstate(ES); if (ES.EstateID == 0) { MainConsole.Instance.Warn("There was an error in creating the system estate: " + ES.EstateName); //EstateName holds the error. See LocalEstateConnector for more info. } else { MainConsole.Instance.InfoFormat("[EstateService]: The estate '{0}' owned by '{1}' has been created.", ES.EstateName, sysAccounts.GetSystemEstateOwnerName(estateID)); } }
private EstateSettings CreateEstateInfo(IScene scene) { EstateSettings ES = new EstateSettings(); while (true) { IEstateConnector EstateConnector = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector>(); string name = MainConsole.Instance.Prompt("Estate owner name", LastEstateOwner); UserAccount account = scene.UserAccountService.GetUserAccount(scene.RegionInfo.AllScopeIDs, name); if (account == null) { string createNewUser = MainConsole.Instance.Prompt( "Could not find user " + name + ". Would you like to create this user?", "yes"); if (createNewUser == "yes") { // Create a new account string password = MainConsole.Instance.PasswordPrompt(name + "'s password"); string email = MainConsole.Instance.Prompt(name + "'s email", ""); scene.UserAccountService.CreateUser(name, Util.Md5Hash(password), email); account = scene.UserAccountService.GetUserAccount(scene.RegionInfo.AllScopeIDs, name); if (account == null) { MainConsole.Instance.ErrorFormat( "[EstateService]: Unable to store account. If this simulator is connected to a grid, you must create the estate owner account first at the grid level."); continue; } } else { continue; } } LastEstateOwner = account.Name; List <EstateSettings> ownerEstates = EstateConnector.GetEstates(account.PrincipalID); string response = (ownerEstates != null && ownerEstates.Count > 0) ? "yes" : "no"; if (ownerEstates != null && ownerEstates.Count > 0) { MainConsole.Instance.WarnFormat("Found user. {0} has {1} estates currently. {2}", account.Name, ownerEstates.Count, "These estates are the following:"); foreach (EstateSettings t in ownerEstates) { MainConsole.Instance.Warn(t.EstateName); } response = MainConsole.Instance.Prompt( "Do you wish to join one of these existing estates? (Options are {yes, no, cancel})", response, new List <string> { "yes", "no", "cancel" }); } else { MainConsole.Instance.WarnFormat("Found user. {0} has no estates currently. Creating a new estate.", account.Name); } if (response == "no") { // Create a new estate // ES could be null ES.EstateName = MainConsole.Instance.Prompt("New estate name (or cancel to go back)", "My Estate"); if (ES.EstateName == "cancel") { continue; } //Set to auto connect to this region next LastEstateName = ES.EstateName; ES.EstateOwner = account.PrincipalID; ES.EstateID = (uint)EstateConnector.CreateNewEstate(ES, scene.RegionInfo.RegionID); if (ES.EstateID == 0) { MainConsole.Instance.Warn("There was an error in creating this estate: " + ES.EstateName); //EstateName holds the error. See LocalEstateConnector for more info. continue; } break; } if (response == "yes") { if (ownerEstates != null && ownerEstates.Count != 1) { if (LastEstateName == "") { LastEstateName = ownerEstates[0].EstateName; } List <string> responses = ownerEstates.Select(settings => settings.EstateName).ToList(); responses.Add("None"); responses.Add("Cancel"); response = MainConsole.Instance.Prompt("Estate name to join", LastEstateName, responses); if (response == "None" || response == "Cancel") { continue; } LastEstateName = response; } else if (ownerEstates != null) { LastEstateName = ownerEstates[0].EstateName; } int estateID = EstateConnector.GetEstate(account.PrincipalID, LastEstateName); if (estateID == 0) { MainConsole.Instance.Warn("The name you have entered matches no known estate. Please try again"); continue; } //We save the Password because we have to reset it after we tell the EstateService about it, as it clears it for security reasons if (EstateConnector.LinkRegion(scene.RegionInfo.RegionID, estateID)) { if ((ES = EstateConnector.GetEstateSettings(scene.RegionInfo.RegionID)) == null || ES.EstateID == 0) //We could do by EstateID now, but we need to completely make sure that it fully is set up { MainConsole.Instance.Warn("The connection to the server was broken, please try again soon."); continue; } MainConsole.Instance.Warn("Successfully joined the estate!"); break; } MainConsole.Instance.Warn("Joining the estate failed. Please try again."); continue; } } return(ES); }
/// <summary> /// Correct the system estate ID and update any linked regions. /// </summary> /// <param name="estateConnector">Estate connector.</param> /// <param name="eS">E s.</param> /// <param name="newEstateID">New estate I.</param> static void UpdateSystemEstates (IEstateConnector estateConnector, EstateSettings eS, int newEstateID) { // this may be an ID correction or just an estate name change uint oldEstateID = eS.EstateID; // get existing linked regions var regions = estateConnector.GetRegions ((int)oldEstateID); // recreate the correct estate? if (oldEstateID != newEstateID) { estateConnector.DeleteEstate ((int)oldEstateID); newEstateID = estateConnector.CreateNewEstate (eS); MainConsole.Instance.Info ("System estate '" + eS.EstateName + "' is present but the ID was corrected."); } // re-link regions foreach (UUID regID in regions) { estateConnector.LinkRegion (regID, newEstateID); } if (regions.Count > 0) MainConsole.Instance.InfoFormat ("Relinked {0} regions", regions.Count); }
private void CheckSystemEstateInfo(IEstateConnector estateConnector) { // these should have already been checked but just make sure... if (estateConnector == null) return; if (estateConnector.RemoteCalls ()) return; if (estateConnector.EstateExists (Constants.SystemEstateName)) return; // Create a new estate EstateSettings ES = new EstateSettings(); ES.EstateName = Constants.SystemEstateName; ES.EstateOwner = (UUID) Constants.RealEstateOwnerUUID; ES.EstateID = (uint) estateConnector.CreateNewEstate(ES); if (ES.EstateID == 0) { MainConsole.Instance.Warn("There was an error in creating the system estate: " + ES.EstateName); //EstateName holds the error. See LocalEstateConnector for more info. } else { MainConsole.Instance.InfoFormat("[EstateService]: The estate '{0}' owned by '{1}' has been created.", Constants.SystemEstateName, Constants.RealEstateOwnerName); } }