/// <summary> /// Link a region to an estate. /// </summary> /// <param name="scene">Scene.</param> /// <param name="cmd">Cmd.</param> void EstateLinkRegionCommand(IScene scene, string [] cmd) { IEstateConnector estateConnector = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector> (); IGridService gridService = m_registry.RequestModuleInterface <IGridService> (); string estateName = ""; string regionName = ""; // check for passed estate name estateName = (cmd.Length < 4) ? MainConsole.Instance.Prompt("Estate name", estateName) : cmd [3]; if (estateName == "") { return; } // verify that the estate does exist EstateSettings ES = estateConnector.GetEstateSettings(estateName); if (ES == null) { MainConsole.Instance.ErrorFormat("[EstateService]: The estate '{0}' does not exist!", estateName); return; } // check for passed region to link to if (scene != null) { regionName = scene.RegionInfo.RegionName; } regionName = (cmd.Length < 4) ? MainConsole.Instance.Prompt("Region to add to " + estateName, regionName) : cmd [4]; if (regionName == "") { return; } // verify that the region does exist var region = gridService.GetRegionByName(null, regionName); if (region == null) { MainConsole.Instance.ErrorFormat("[EstateService]: The requested region '{0}' does not exist!", regionName); return; } // have all details.. do it... regionName = region.RegionName; if (estateConnector.LinkRegion(region.RegionID, (int)ES.EstateID)) { // check for update.. var es = estateConnector.GetRegionEstateSettings(region.RegionID); if ((es == null) || (es.EstateID == 0)) { MainConsole.Instance.Warn("The region link failed, please try again soon."); } else { MainConsole.Instance.InfoFormat("Region '{0}' is now attached to estate '{1}'", regionName, estateName); UpdateConsoleRegionEstate(regionName, es); } } else { MainConsole.Instance.Warn("Joining the estate failed. Please try again."); } }
/// <summary> /// Un-link a region from an estate region. /// </summary> /// <param name="scene">Scene.</param> /// <param name="cmd">Cmd.</param> void EstateUnLinkRegionCommand(IScene scene, string [] cmd) { IEstateConnector estateConnector = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector> (); IGridService gridService = m_registry.RequestModuleInterface <IGridService> (); string estateName = ""; string regionName = ""; // check for passed estate name estateName = (cmd.Length < 4) ? MainConsole.Instance.Prompt("Estate name", estateName) : cmd [3]; if (estateName == "") { return; } // verify that the estate does exist EstateSettings ES = estateConnector.GetEstateSettings(estateName); if (ES == null) { MainConsole.Instance.ErrorFormat("[EstateService]: The estate '{0}' does not exist!", estateName); return; } // check for passed region to link to if (scene != null) { regionName = scene.RegionInfo.RegionName; } regionName = (cmd.Length < 4) ? MainConsole.Instance.Prompt("Region to remove", regionName) : cmd [4]; if (regionName == "") { return; } // verify that the region does exist var region = gridService.GetRegionByName(null, regionName); if (region == null) { MainConsole.Instance.ErrorFormat("[EstateService]: The requested region '{0}' does not exist!", regionName); return; } regionName = region.RegionName; // verify that the region is actually part of the estate if (!estateConnector.EstateRegionExists((int)ES.EstateID, region.RegionID)) { MainConsole.Instance.ErrorFormat("[EstateService]: The requested region '{0}' is not part of the '{1}' estate!", regionName, ES.EstateName); return; } // have all details.. do it... if (!estateConnector.DelinkRegion(region.RegionID)) { MainConsole.Instance.Warn("Unlinking the region failed. Please try again."); return; } // unlink was successful.. MainConsole.Instance.InfoFormat("Region '{0}' has been removed from estate '{1}'", regionName, estateName); //We really need to attach it to another estate though... ISystemEstateService sysEstateInfo = m_registry.RequestModuleInterface <ISystemEstateService> (); ES = estateConnector.GetEstateSettings(sysEstateInfo.SystemEstateName); if (ES != null) { if (estateConnector.LinkRegion(region.RegionID, (int)ES.EstateID)) { MainConsole.Instance.WarnFormat("'{0}' has been placed in the '{1}' estate until re-assigned", regionName, sysEstateInfo.SystemEstateName); UpdateConsoleRegionEstate(regionName, ES); } } }
protected void HandleResetSystemEstate(IScene scene, string [] cmd) { // delete and recreate the system estate IEstateConnector estateConnector = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector> (); ISystemAccountService sysAccounts = m_registry.RequestModuleInterface <ISystemAccountService> (); bool update = false; // verify that the estate does exist EstateSettings ES; ES = estateConnector.GetEstateSettings(Constants.SystemEstateName); if (ES == null) { ES = estateConnector.GetEstateSettings(SystemEstateName); if (ES == null) { MainConsole.Instance.ErrorFormat("[EstateService]: The estate '{0}' does not exist yet!", SystemEstateName); MainConsole.Instance.Warn("[EstateService]: It will be created when you link a region to the estate"); } } // A system Estate exists? if (ES != null) { if (ES.EstateName != SystemEstateName) { ES.EstateName = SystemEstateName; update = true; } if (ES.EstateOwner != sysAccounts.SystemEstateOwnerUUID) { ES.EstateOwner = sysAccounts.SystemEstateOwnerUUID; update = true; } // save any updates if (update) { estateConnector.SaveEstateSettings(ES); MainConsole.Instance.Warn("[EstateService]: Estate details have been updated"); } } // check the System estate owner details UserAccount uinfo; uinfo = m_accountService.GetUserAccount(null, UUID.Parse(Constants.RealEstateOwnerUUID)); if (uinfo == null) { MainConsole.Instance.Warn("[EstateService]: The system estate user does not exist yet!"); MainConsole.Instance.Warn("[EstateService]: This account will be created automatically"); } if ((uinfo != null) && (uinfo.Name != sysAccounts.SystemEstateOwnerName)) { //string[] name = uinfo.Name.Split (' '); //uinfo.FirstName = name [0]; //uinfo.LastName = name [1]; uinfo.Name = sysAccounts.SystemEstateOwnerName; m_accountService.StoreUserAccount(uinfo); update = true; } if (update) { MainConsole.Instance.InfoFormat("[EstateService]: The system Estate details have been reset"); } else { MainConsole.Instance.InfoFormat("[EstateService]: Estate details are correct as configured"); } }
/// <summary> /// Sets the estate owner. /// </summary> /// <param name="scene">Scene.</param> /// <param name="cmd">Cmd.</param> protected void SetEstateOwnerCommand(IScene scene, string [] cmd) { IEstateConnector estateConnector = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector> (); IUserAccountService accountService = m_registry.RequestModuleInterface <IUserAccountService> (); string estateName = ""; string estateOwner; UserAccount ownerAccount; // check for passed estate name estateName = (cmd.Length < 4) ? MainConsole.Instance.Prompt("Estate to be modified?", estateName) : cmd [3]; if (estateName == "") { return; } // verify that the estate does exist EstateSettings ES = estateConnector.GetEstateSettings(estateName); if (ES == null) { MainConsole.Instance.WarnFormat("[EstateService]: The estate '{0}' does not exist!", estateName); return; } // owner? if (cmd.Length < 5) { var newOwner = "Unknown"; UUID estateOwnerID = ES.EstateOwner; ownerAccount = accountService.GetUserAccount(null, estateOwnerID); if (ownerAccount != null) { newOwner = ownerAccount.Name; } estateOwner = MainConsole.Instance.Prompt("New owner for this estate", newOwner); } else { estateOwner = Util.CombineParams(cmd, 5); // in case of spaces in the name e.g. Allan Allard } if (estateOwner == "") { return; } // check to make sure the user exists ownerAccount = accountService.GetUserAccount(null, estateOwner); if (ownerAccount == null) { MainConsole.Instance.WarnFormat("[User Account Service]: The user, '{0}' was not found!", estateOwner); return; } // check for bogies... if (Utilities.IsSystemUser(ownerAccount.PrincipalID)) { MainConsole.Instance.Info("[EstateService]: Tsk, tsk. System users should not be used as estate managers!"); return; } // We have a valid Estate and user, send it off for processing. ES.EstateOwner = ownerAccount.PrincipalID; estateConnector.SaveEstateSettings(ES); MainConsole.Instance.InfoFormat("[EstateService]: Estate owner for '{0}' changed to '{1}'", estateName, estateOwner); }
/// <summary> /// Fixs missing region owners command. /// </summary> /// <param name="scene">Scene.</param> /// <param name="cmd">Cmd.</param> void FixMissingRegionOwners(IScene scene, string[] cmd) { QueryFilter filter = new QueryFilter(); filter.andFilters["OwnerUUID"] = UUID.Zero; List <GridRegion> borked = ParseQuery(null, GD.Query(new string[1] { "*" }, m_realm, filter, null, null, null)); if (borked.Count < 1) { MainConsole.Instance.Info("[Local Grid Connector] No regions found with missing owners."); return; } IEstateConnector estatePlugin = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector>(); if (estatePlugin == null) { MainConsole.Instance.Error("[Local Grid Connector] " + borked.Count + " regions found with missing owners, but could not get IEstateConnector plugin."); return; } MainConsole.Instance.Error("[Local Grid Connector] " + borked.Count + " regions found with missing owners, attempting fix."); Dictionary <int, List <GridRegion> > borkedByEstate = new Dictionary <int, List <GridRegion> >(); foreach (GridRegion region in borked) { int estateID = estatePlugin.GetEstateID(region.RegionID); if (!borkedByEstate.ContainsKey(estateID)) { borkedByEstate[estateID] = new List <GridRegion>(); } borkedByEstate[estateID].Add(region); } Dictionary <int, UUID> estateOwnerIDs = new Dictionary <int, UUID>(); uint estateFail = 0; foreach (int estateID in borkedByEstate.Keys) { EstateSettings es = estatePlugin.GetEstateSettings(estateID); if (es == null) { MainConsole.Instance.Error("[Local Grid Connector] Cannot fix missing owner for regions in Estate " + estateID + ", could not get estate settings."); } else if (es.EstateOwner == UUID.Zero) { MainConsole.Instance.Error("[Loca lGrid Connector] Cannot fix missing owner for regions in Estate " + estateID + ", Estate Owner is also missing."); } if (es == null || es.EstateOwner == UUID.Zero) { ++estateFail; continue; } estateOwnerIDs[estateID] = es.EstateOwner; } if (estateFail > 0) { if (estateFail == borkedByEstate.Count) { MainConsole.Instance.Error("[Local Grid Connector] " + borked.Count + " regions found with missing owners, could not locate any estate settings from IEstateConnector plugin."); return; } MainConsole.Instance.Error("[Local Grid Connector] " + borked.Count + " regions found with missing owners, could not locate estate settings for " + estateFail + " estates."); } uint storeSuccess = 0; uint storeFail = 0; int borkedCount = borked.Count; foreach (KeyValuePair <int, UUID> kvp in estateOwnerIDs) { List <GridRegion> regions = borkedByEstate[kvp.Key]; foreach (GridRegion region in regions) { region.EstateOwner = kvp.Value; if (!Store(region)) { MainConsole.Instance.Error("[Local Grid Connector] Failed to fix missing region for " + region.RegionName + " (" + region.RegionID + ")"); ++storeFail; } else { ++storeSuccess; borked.Remove(region); } } } if (storeFail > 0) { MainConsole.Instance.Error("[Local Grid Connector] " + borkedCount + " regions found with missing owners, fix failed on " + storeFail + " regions, fix attempted on " + storeSuccess + " regions."); } else if (storeSuccess != borked.Count) { MainConsole.Instance.Error("[Local Grid Connector] " + borkedCount + " regions found with missing owners, fix attempted on " + storeSuccess + " regions."); } else { MainConsole.Instance.Info( "[Local Grid Connector] All regions found with missing owners should have their owners restored."); } if (borked.Count > 0) { List <string> blurbs = new List <string>(borked.Count); foreach (GridRegion region in borked) { blurbs.Add(region.RegionName + " (" + region.RegionID + ")"); } MainConsole.Instance.Info("[Local Grid Connector] Failed to fix missing region owners for regions " + string.Join(", ", blurbs.ToArray())); } }
/// <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)); } }
public Dictionary <string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest, OSHttpResponse httpResponse, Dictionary <string, object> requestParameters, ITranslator translator, out string response) { response = null; var vars = new Dictionary <string, object>(); var gridService = webInterface.Registry.RequestModuleInterface <IGridService> (); if (requestParameters.ContainsKey("Submit")) { string RegionServerURL = requestParameters["RegionServerURL"].ToString(); // required if (RegionServerURL == "") { response = "<h3>" + translator.GetTranslatedString("RegionServerURLError") + "</h3>"; return(null); } string RegionName = requestParameters["RegionName"].ToString(); //string OwnerUUID = requestParameters["OwnerUUID"].ToString(); string RegionLocX = requestParameters["RegionLocX"].ToString(); string RegionLocY = requestParameters["RegionLocY"].ToString(); string RegionSizeX = requestParameters["RegionSizeX"].ToString(); string RegionSizeY = requestParameters["RegionSizeY"].ToString(); string RegionType = requestParameters["RegionType"].ToString(); string RegionPresetType = requestParameters["RegionPresetType"].ToString(); string RegionTerrain = requestParameters["RegionTerrain"].ToString(); string RegionLoadTerrain = requestParameters.ContainsKey("RegionLoadTerrain") ? requestParameters["RegionLoadTerrain"].ToString() : ""; //bool ToSAccept = requestParameters.ContainsKey("ToSAccept") && // requestParameters["ToSAccept"].ToString() == "Accepted"; // string UserType = requestParameters.ContainsKey("UserType") // only admins can set membership // ? requestParameters ["UserType"].ToString () // : "Resident"; // a bit of idiot proofing if (RegionName == "") { response = "<h3>" + translator.GetTranslatedString("RegionNameError") + "</h3>"; return(null); } if ((RegionLocX == "") || (RegionLocY == "")) { response = "<h3>" + translator.GetTranslatedString("RegionLocationError") + "</h3>"; return(null); } // so far so good... // build the new region details int RegionPort = int.Parse(requestParameters ["RegionPort"].ToString()); var newRegion = new RegionInfo(); newRegion.RegionName = RegionName; newRegion.RegionType = RegionType; newRegion.RegionLocX = int.Parse(RegionLocX); newRegion.RegionLocY = int.Parse(RegionLocY); newRegion.RegionSizeX = int.Parse(RegionSizeX); newRegion.RegionSizeY = int.Parse(RegionSizeY); newRegion.RegionPort = RegionPort; newRegion.SeeIntoThisSimFromNeighbor = true; newRegion.InfiniteRegion = false; newRegion.ObjectCapacity = 50000; newRegion.Startup = StartupType.Normal; var regionPreset = RegionPresetType.ToLower(); if (regionPreset.StartsWith("c")) { newRegion.RegionPort = int.Parse(requestParameters["RegionPort"].ToString()); newRegion.SeeIntoThisSimFromNeighbor = (requestParameters["RegionVisibility"].ToString().ToLower() == "yes"); newRegion.InfiniteRegion = (requestParameters["RegionInfinite"].ToString().ToLower() == "yes"); newRegion.ObjectCapacity = int.Parse(requestParameters["RegionCapacity"].ToString()); string delayStartup = requestParameters["RegionDelayStartup"].ToString(); newRegion.Startup = delayStartup.StartsWith("n") ? StartupType.Normal : StartupType.Medium; } if (regionPreset.StartsWith("w")) { // 'standard' setup newRegion.RegionType = newRegion.RegionType + "Whitecore"; //info.RegionPort; // use auto assigned port newRegion.RegionTerrain = "Flatland"; newRegion.Startup = StartupType.Normal; newRegion.SeeIntoThisSimFromNeighbor = true; newRegion.InfiniteRegion = false; newRegion.ObjectCapacity = 50000; newRegion.RegionPort = RegionPort; } if (regionPreset.StartsWith("o")) { // 'Openspace' setup newRegion.RegionType = newRegion.RegionType + "Openspace"; //newRegion.RegionPort; // use auto assigned port if (RegionTerrain.StartsWith("a")) { newRegion.RegionTerrain = "Aquatic"; } else { newRegion.RegionTerrain = "Grassland"; } newRegion.Startup = StartupType.Medium; newRegion.SeeIntoThisSimFromNeighbor = true; newRegion.InfiniteRegion = false; newRegion.ObjectCapacity = 750; newRegion.RegionSettings.AgentLimit = 10; newRegion.RegionSettings.AllowLandJoinDivide = false; newRegion.RegionSettings.AllowLandResell = false; } if (regionPreset.StartsWith("h")) { // 'Homestead' setup newRegion.RegionType = newRegion.RegionType + "Homestead"; //info.RegionPort; // use auto assigned port newRegion.RegionTerrain = "Homestead"; newRegion.Startup = StartupType.Medium; newRegion.SeeIntoThisSimFromNeighbor = true; newRegion.InfiniteRegion = false; newRegion.ObjectCapacity = 3750; newRegion.RegionSettings.AgentLimit = 20; newRegion.RegionSettings.AllowLandJoinDivide = false; newRegion.RegionSettings.AllowLandResell = false; } if (regionPreset.StartsWith("f")) { // 'Full Region' setup newRegion.RegionType = newRegion.RegionType + "Full Region"; //newRegion.RegionPort; // use auto assigned port newRegion.RegionTerrain = RegionTerrain; newRegion.Startup = StartupType.Normal; newRegion.SeeIntoThisSimFromNeighbor = true; newRegion.InfiniteRegion = false; newRegion.ObjectCapacity = 15000; newRegion.RegionSettings.AgentLimit = 100; if (newRegion.RegionType.StartsWith("M")) // defaults are 'true' { newRegion.RegionSettings.AllowLandJoinDivide = false; newRegion.RegionSettings.AllowLandResell = false; } } if (RegionLoadTerrain.Length > 0) { // we are loading terrain from a file... handled later newRegion.RegionTerrain = "Custom"; } /* Disabled as this is a worl=k in progress and will break with the current scenemanager (Dec 5 - greythane- * // TODO: !!! Assumes everything is local for now !!! * ISceneManager scenemanager = webInterface.Registry.RequestModuleInterface<ISceneManager> (); * if (scenemanager.CreateRegion(newRegion)) * { * IGridRegisterModule gridRegister = webInterface.Registry.RequestModuleInterface<IGridRegisterModule>(); * if( gridRegister.RegisterRegionWithGrid(null, true, false, null)) * { * * response = "<h3>Successfully created region, redirecting to main page</h3>" + * "<script language=\"javascript\">" + * "setTimeout(function() {window.location.href = \"index.html\";}, 3000);" + * "</script>"; * } * else * // response = "<h3>" + error + "</h3>"; * response = "<h3> Error registering region with grid</h3>"; * } * else */ response = "<h3>Error creating this region.</h3>"; return(null); } // we have or need data if (httpRequest.Query.ContainsKey("regionid")) { var region = gridService.GetRegionByUUID(null, UUID.Parse(httpRequest.Query ["regionid"].ToString())); IEstateConnector estateConnector = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector> (); EstateSettings estate = estateConnector.GetEstateSettings(region.RegionID); vars.Add("RegionName", region.RegionName); vars.Add("OwnerUUID", estate.EstateOwner); var estateOwnerAccount = webInterface.Registry.RequestModuleInterface <IUserAccountService> (). GetUserAccount(null, estate.EstateOwner); vars.Add("OwnerName", estateOwnerAccount == null ? "No account found" : estateOwnerAccount.Name); vars.Add("RegionLocX", region.RegionLocX / Constants.RegionSize); vars.Add("RegionLocY", region.RegionLocY / Constants.RegionSize); vars.Add("RegionSizeX", region.RegionSizeX); vars.Add("RegionSizeY", region.RegionSizeY); vars.Add("RegionType", region.RegionType); vars.Add("RegionTerrain", region.RegionTerrain); vars.Add("RegionOnline", (region.Flags & (int)RegionFlags.RegionOnline) == (int)RegionFlags.RegionOnline ? translator.GetTranslatedString("Online") : translator.GetTranslatedString("Offline")); IWebHttpTextureService webTextureService = webInterface.Registry. RequestModuleInterface <IWebHttpTextureService> (); if (webTextureService != null && region.TerrainMapImage != UUID.Zero) { vars.Add("RegionImageURL", webTextureService.GetTextureURL(region.TerrainMapImage)); } else { vars.Add("RegionImageURL", "images/icons/no_picture.jpg"); } } else { // default values // check for user name seed string[] m_regionNameSeed = null; /*IConfig regionConfig = * webInterface.Registry.RequestModuleInterface<ISimulationBase>().ConfigSource.Configs["LoginService"]; * * if (loginServerConfig != null) * { * string userNameSeed = loginServerConfig.GetString ("UserNameSeed", ""); * if (userNameSeed != "") * m_userNameSeed = userNameSeed.Split (','); * } */ Utilities.MarkovNameGenerator rNames = new Utilities.MarkovNameGenerator(); string regionName = rNames.FirstName(m_regionNameSeed == null ? Utilities.RegionNames: m_regionNameSeed, 3, 7); vars.Add("RegionName", regionName); //var scenemanager = webInterface.Registry.RequestModuleInterface<ISceneManager> (); var gconnector = Framework.Utilities.DataManager.RequestPlugin <IGenericsConnector>(); var settings = gconnector.GetGeneric <WebUISettings>(UUID.Zero, "WebUISettings", "Settings"); // get some current details //List<GridRegion> regions = gridService.GetRegionsByName(null, "", null,null); // var currentInfo = scenemanager.FindCurrentRegionInfo (); Dictionary <string, int> currentInfo = null; if (currentInfo != null) { vars.Add("RegionLocX", currentInfo ["minX"] > 0 ? currentInfo ["minX"] : settings.MapCenter.X); vars.Add("RegionLocY", currentInfo ["minY"] > 0 ? currentInfo ["minY"] : settings.MapCenter.Y); vars.Add("RegionPort", currentInfo ["port"] > 0 ? currentInfo ["port"] + 1 : 9000); } else { vars.Add("RegionLocX", settings.MapCenter.X); vars.Add("RegionLocY", settings.MapCenter.Y); vars.Add("RegionPort", 9000); } vars.Add("RegionSizeX", Constants.RegionSize); vars.Add("RegionSizeY", Constants.RegionSize); vars.Add("RegionType", webInterface.RegionTypeArgs(translator)); vars.Add("RegionPresetType", webInterface.RegionPresetArgs(translator)); vars.Add("RegionTerrain", webInterface.RegionTerrainArgs(translator)); } // Labels //vars.Add ("RegionInformationText", translator.GetTranslatedString ("RegionInformationText")); vars.Add("RegionNameText", translator.GetTranslatedString("RegionNameText")); vars.Add("RegionLocationText", translator.GetTranslatedString("RegionLocationText")); vars.Add("RegionSizeText", translator.GetTranslatedString("RegionSizeText")); vars.Add("RegionTypeText", translator.GetTranslatedString("RegionTypeText")); vars.Add("RegionPresetText", translator.GetTranslatedString("RegionPresetText")); vars.Add("RegionTerrainText", translator.GetTranslatedString("RegionTerrainText")); vars.Add("OwnerNameText", translator.GetTranslatedString("OwnerNameText")); vars.Add("RegionPortText", translator.GetTranslatedString("RegionPortText")); vars.Add("RegionDelayStartupText", translator.GetTranslatedString("RegionDelayStartupText")); vars.Add("RegionVisibilityText", translator.GetTranslatedString("RegionVisibilityText")); vars.Add("RegionInfiniteText", translator.GetTranslatedString("RegionInfiniteText")); vars.Add("RegionCapacityText", translator.GetTranslatedString("RegionCapacityText")); vars.Add("Yes", translator.GetTranslatedString("Yes")); vars.Add("No", translator.GetTranslatedString("No")); vars.Add("Accept", translator.GetTranslatedString("Accept")); vars.Add("Submit", translator.GetTranslatedString("Submit")); vars.Add("SubmitURL", "home.html"); vars.Add("ErrorMessage", ""); return(vars); }
public Dictionary <string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest, OSHttpResponse httpResponse, Dictionary <string, object> requestParameters, ITranslator translator, out string response) { response = null; var vars = new Dictionary <string, object> (); if (httpRequest.Query.ContainsKey("regionid")) { var regionService = webInterface.Registry.RequestModuleInterface <IGridService> (); var region = regionService.GetRegionByUUID(null, UUID.Parse(httpRequest.Query ["regionid"].ToString())); IEstateConnector estateConnector = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector> (); EstateSettings estate = null; if (estateConnector != null) { estate = estateConnector.GetEstateSettings(region.RegionID); } if (estate != null) { vars.Add("OwnerUUID", estate.EstateOwner); var estateOwnerAccount = webInterface.Registry.RequestModuleInterface <IUserAccountService> (). GetUserAccount(null, estate.EstateOwner); vars.Add("OwnerName", estateOwnerAccount == null ? "No account found" : estateOwnerAccount.Name); } else { vars.Add("OwnerUUID", "Unknown"); vars.Add("OwnerName", "Unknown"); } vars.Add("RegionName", region.RegionName); vars.Add("RegionLocX", region.RegionLocX / Constants.RegionSize); vars.Add("RegionLocY", region.RegionLocY / Constants.RegionSize); vars.Add("RegionSizeX", region.RegionSizeX); vars.Add("RegionSizeY", region.RegionSizeY); vars.Add("RegionType", region.RegionType); vars.Add("RegionTerrain", region.RegionTerrain); vars.Add("RegionMaturity", Utilities.GetRegionMaturity(region.Access)); bool regionIsOnline = (region.Flags & (int)RegionFlags.RegionOnline) == (int)RegionFlags.RegionOnline; vars.Add("RegionOnline", regionIsOnline ? translator.GetTranslatedString("Online") : translator.GetTranslatedString("Offline")); IAgentInfoService agentInfoService = webInterface.Registry.RequestModuleInterface <IAgentInfoService> (); IUserAccountService userService = webInterface.Registry.RequestModuleInterface <IUserAccountService> (); if (agentInfoService != null) { List <UserInfo> usersInRegion = agentInfoService.GetUserInfos(region.RegionID); vars.Add("NumberOfUsersInRegion", usersInRegion != null ? usersInRegion.Count : 0); List <Dictionary <string, object> > users = new List <Dictionary <string, object> > (); if (userService != null) { foreach (var client in usersInRegion) { UserAccount account = userService.GetUserAccount(null, (UUID)client.UserID); if (account == null) { continue; } Dictionary <string, object> user = new Dictionary <string, object> (); user.Add("UserNameText", translator.GetTranslatedString("UserNameText")); user.Add("UserUUID", client.UserID); user.Add("UserName", account.Name); users.Add(user); } } vars.Add("UsersInRegion", users); } else { vars.Add("NumberOfUsersInRegion", 0); vars.Add("UsersInRegion", new List <Dictionary <string, object> > ()); } IDirectoryServiceConnector directoryConnector = Framework.Utilities.DataManager.RequestPlugin <IDirectoryServiceConnector> (); if (directoryConnector != null) { List <LandData> parcelData = directoryConnector.GetParcelsByRegion(0, 10, region.RegionID, UUID.Zero, ParcelFlags.None, ParcelCategory.Any); /*List<Dictionary<string, object>> parcels = new List<Dictionary<string, object>>(); * foreach (var p in parcelData) * { * Dictionary<string, object> parcel = new Dictionary<string, object>(); * parcel.Add("ParcelNameText", translator.GetTranslatedString("ParcelNameText")); * parcel.Add("ParcelOwnerText", translator.GetTranslatedString("ParcelOwnerText")); * parcel.Add("ParcelUUID", p.GlobalID); * parcel.Add("ParcelName", p.Name); * parcel.Add("ParcelOwnerUUID", p.OwnerID); * IUserAccountService accountService = * webInterface.Registry.RequestModuleInterface<IUserAccountService>(); * if (accountService != null) * { * var account = accountService.GetUserAccount(null, p.OwnerID); * if (account == null) * parcel.Add("ParcelOwnerName", translator.GetTranslatedString("NoAccountFound")); * else * parcel.Add("ParcelOwnerName", account.Name); * } * parcels.Add(parcel); * } * * vars.Add("ParcelInRegion", parcels); */ if (parcelData != null) { vars.Add("NumberOfParcelsInRegion", parcelData.Count); } else { vars.Add("NumberOfParcelsInRegion", 0); } } IWebHttpTextureService webTextureService = webInterface.Registry. RequestModuleInterface <IWebHttpTextureService> (); var regionMapURL = "../images/icons/no_terrain.jpg"; if (webTextureService != null && region.TerrainMapImage != UUID.Zero) { regionMapURL = webTextureService.GetTextureURL(region.TerrainMapImage); } vars.Add("RegionImageURL", regionMapURL); // worldview IConfig worldViewConfig = webInterface.Registry.RequestModuleInterface <ISimulationBase> ().ConfigSource.Configs ["WorldViewModule"]; bool worldViewEnabled = false; if (worldViewConfig != null) { worldViewEnabled = worldViewConfig.GetBoolean("Enabled", true); } if (webTextureService != null && worldViewEnabled && regionIsOnline) { vars.Add("RegionWorldViewURL", webTextureService.GetRegionWorldViewURL(region.RegionID)); } else { vars.Add("RegionWorldViewURL", regionMapURL); } // Menu Region vars.Add("MenuRegionTitle", translator.GetTranslatedString("MenuRegionTitle")); vars.Add("TooltipsMenuRegion", translator.GetTranslatedString("TooltipsMenuRegion")); vars.Add("MenuParcelTitle", translator.GetTranslatedString("MenuParcelTitle")); vars.Add("TooltipsMenuParcel", translator.GetTranslatedString("TooltipsMenuParcel")); vars.Add("MenuOwnerTitle", translator.GetTranslatedString("MenuOwnerTitle")); vars.Add("TooltipsMenuOwner", translator.GetTranslatedString("TooltipsMenuOwner")); vars.Add("RegionInformationText", translator.GetTranslatedString("RegionInformationText")); vars.Add("OwnerNameText", translator.GetTranslatedString("OwnerNameText")); vars.Add("RegionLocationText", translator.GetTranslatedString("RegionLocationText")); vars.Add("RegionSizeText", translator.GetTranslatedString("RegionSizeText")); vars.Add("RegionNameText", translator.GetTranslatedString("RegionNameText")); vars.Add("RegionTypeText", translator.GetTranslatedString("RegionTypeText")); vars.Add("RegionMaturityText", translator.GetTranslatedString("RegionMaturityText")); vars.Add("RegionTerrainText", translator.GetTranslatedString("RegionTerrainText")); vars.Add("RegionInfoText", translator.GetTranslatedString("RegionInfoText")); vars.Add("RegionOnlineText", translator.GetTranslatedString("RegionOnlineText")); vars.Add("NumberOfUsersInRegionText", translator.GetTranslatedString("NumberOfUsersInRegionText")); vars.Add("ParcelsInRegionText", translator.GetTranslatedString("ParcelsInRegionText")); vars.Add("MainServerURL", webInterface.GridURL); } return(vars); }
/// <summary> /// Shows estate regions. /// </summary> /// <param name="scene">Scene.</param> /// <param name="cmd">Cmd.</param> void ShowEstateRegionsCommand(IScene scene, string [] cmd) { IEstateConnector estateConnector = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector> (); IGridService gridService = m_registry.RequestModuleInterface <IGridService> (); // check for passed estate name string estateName; if (cmd.Length < 4) { do { estateName = MainConsole.Instance.Prompt("Estate name (? for list)", ""); if (estateName == "?") { var estates = estateConnector.GetEstates(); MainConsole.Instance.CleanInfo(" Available estates are : "); foreach (string estate in estates) { MainConsole.Instance.CleanInfo(" " + estate); } } } while (estateName == "?"); if (estateName == "") { return; } } else { estateName = cmd [3]; } // verify that the estate does exist EstateSettings ES = estateConnector.GetEstateSettings(estateName); if (ES == null) { MainConsole.Instance.ErrorFormat("[EstateService]: The estate '{0}' does not exist!", estateName); return; } var estateregions = estateConnector.GetRegions((int)ES.EstateID); int estRegions = 0; float estateArea = 0; int offLine = 0; string regionInfo; regionInfo = string.Format("{0, -20}", "Region"); regionInfo += string.Format("{0, -12}", "Location"); regionInfo += string.Format("{0, -14}", "Size"); regionInfo += string.Format("{0, -12}", "Area"); regionInfo += string.Format("{0, -26}", "Type"); regionInfo += string.Format("{0, -10}", "Online"); MainConsole.Instance.CleanInfo(regionInfo); MainConsole.Instance.CleanInfo( "----------------------------------------------------------------------------------------------------"); foreach (UUID regionID in estateregions) { var region = gridService.GetRegionByUUID(null, regionID); if (region == null) // deleted?? { continue; } estRegions++; estateArea = estateArea + region.RegionArea; if (!region.IsOnline) { offLine++; } // TODO ... change hardcoded field sizes to public constants regionInfo = string.Format("{0, -20}", region.RegionName); regionInfo += string.Format("{0, -12}", region.RegionLocX / Constants.RegionSize + "," + region.RegionLocY / Constants.RegionSize); regionInfo += string.Format("{0, -14}", region.RegionSizeX + "x" + region.RegionSizeY); regionInfo += string.Format("{0, -12}", region.RegionArea < 1000000 ? region.RegionArea + " m2" : (region.RegionArea / 1000000) + " km2"); regionInfo += string.Format("{0, -26}", region.RegionType); regionInfo += string.Format("{0, -10}", region.IsOnline ? "yes" : "no"); MainConsole.Instance.CleanInfo(regionInfo); } MainConsole.Instance.CleanInfo(""); MainConsole.Instance.CleanInfo( "----------------------------------------------------------------------------------------------------"); MainConsole.Instance.CleanInfo("Regions : " + estRegions + " regions with an area of " + (estateArea / 1000000) + " km2"); MainConsole.Instance.CleanInfo("Offline : " + offLine); MainConsole.Instance.CleanInfo(string.Empty); MainConsole.Instance.CleanInfo( "----------------------------------------------------------------------------------------------------"); MainConsole.Instance.CleanInfo("\n"); }
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> /// Creates the estate info for a region. /// </summary> /// <returns>The estate info.</returns> /// <param name="scene">Scene.</param> private EstateSettings CreateEstateInfo(IScene scene) { // check for regionType to determine if this is 'Mainland' or an 'Estate' string regType = scene.RegionInfo.RegionType.ToLower(); if (regType.StartsWith("m")) { return(LinkMainlandEstate(scene.RegionInfo.RegionID)); } // we are linking to a user estate IEstateConnector estateConnector = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector>(); ISystemEstateService sysEstateInfo = m_registry.RequestModuleInterface <ISystemEstateService>(); string sysEstateOwnerName; var sysAccount = scene.UserAccountService.GetUserAccount(scene.RegionInfo.AllScopeIDs, (UUID)Constants.RealEstateOwnerUUID); if (sysAccount == null) { sysEstateOwnerName = sysEstateInfo.SystemEstateOwnerName; } else { sysEstateOwnerName = sysAccount.Name; } // This is an 'Estate' so get some details.... LastEstateOwner = sysEstateOwnerName; while (true) { UserAccount account; string estateOwner; estateOwner = MainConsole.Instance.Prompt("Estate owner name (" + sysEstateOwnerName + "/User Name)", LastEstateOwner); // we have a prospective estate owner... List <EstateSettings> ownerEstates = null; account = scene.UserAccountService.GetUserAccount(scene.RegionInfo.AllScopeIDs, estateOwner); if (account != null) { // we have a user account... LastEstateOwner = account.Name; ownerEstates = estateConnector.GetEstates(account.PrincipalID); } if (account == null || ownerEstates == null || ownerEstates.Count == 0) { if (account == null) { MainConsole.Instance.Warn("[Estate]: Unable to locate the user " + estateOwner); } else { MainConsole.Instance.WarnFormat("[Estate]: The user, {0}, has no estates currently.", account.Name); } string joinMainland = MainConsole.Instance.Prompt( "Do you want to 'park' the region with the system owner/estate? (yes/no)", "yes"); if (joinMainland.ToLower().StartsWith("y")) // joining 'mainland' { return(LinkMainlandEstate(scene.RegionInfo.RegionID)); } continue; } if (ownerEstates.Count > 1) { MainConsole.Instance.InfoFormat("[Estate]: User {0} has {1} estates currently. {2}", account.Name, ownerEstates.Count, "These estates are the following:"); foreach (EstateSettings t in ownerEstates) { MainConsole.Instance.CleanInfo(" " + t.EstateName); } LastEstateName = ownerEstates[0].EstateName; List <string> responses = ownerEstates.Select(settings => settings.EstateName).ToList(); responses.Add("Cancel"); do { //TODO: This could be a problem if we have a lot of estates string response = MainConsole.Instance.Prompt("Estate name to join", LastEstateName, responses); if (response == "None" || response == "Cancel") { LastEstateName = ""; break; } LastEstateName = response; } while (LastEstateName == ""); if (LastEstateName == "") { continue; } } else { LastEstateName = ownerEstates[0].EstateName; } // we should have a user account and estate name by now int estateID = estateConnector.GetEstate(account.PrincipalID, LastEstateName); if (estateID == 0) { MainConsole.Instance.Warn("[Estate]: The name you have entered matches no known estate. Please try again"); continue; } // link up the region EstateSettings ES; 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("[Estate]: The connection to the server was broken, please try again."); continue; } } else { MainConsole.Instance.WarnFormat("[Estate]: Joining the {0} estate failed. Please try again.", LastEstateName); continue; } MainConsole.Instance.InfoFormat("[Estate]: Successfully joined the {0} estate!", LastEstateName); return(ES); } }
/// <summary> /// Changes the region estate. /// </summary> /// <param name="scene">Scene.</param> /// <param name="cmd">Cmd parameters.</param> protected void ChangeRegionEstate(IScene scene, string [] cmd) { var conScenes = MainConsole.Instance.ConsoleScenes; IScene regScene = scene; IEstateConnector estateConnector = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector> (); if (estateConnector == null) { MainConsole.Instance.Error("[Estate]: Unable to obtain estate connector for update"); return; } string regionName; if (regScene == null) { regionName = cmd.Length > 2 ? cmd [2] : MainConsole.Instance.Prompt("The region you wish to change?"); if (string.IsNullOrEmpty(regionName)) { return; } // find the required region/scene regionName = regionName.ToLower(); foreach (IScene scn in conScenes) { if (scn.RegionInfo.RegionName.ToLower() == regionName) { regScene = scn; break; } } if (regScene == null) { MainConsole.Instance.Error("[Estate]: The region '" + regionName + "' could not be found."); return; } } else { regionName = regScene.RegionInfo.RegionName; } var regionID = regScene.RegionInfo.RegionID; var oldOwnerID = regScene.RegionInfo.EstateSettings.EstateOwner; // get the new estate name string estateName = cmd.Length > 3 ? cmd [3] : MainConsole.Instance.Prompt("The new estate for " + regionName + " (? for more options)"); if (string.IsNullOrEmpty(estateName)) { return; } int newEstateId = 0; if (estateName != "?") { newEstateId = estateConnector.GetEstateID(estateName); } if (newEstateId == 0) { if (estateName != "?") { MainConsole.Instance.Warn("[Estate]: The estate '" + estateName + "' matches no known estate."); } // try the long way... newEstateId = GetUserEstateID(regScene, estateConnector); if (newEstateId == 0) { return; } estateName = estateConnector.GetEstateSettings(newEstateId).EstateName; } // we have a region & estate name bool deLinkEstate = true; if (cmd.Length == 3) { var resp = MainConsole.Instance.Prompt( "Are you sure you want to change '" + regionName + "' to the '" + estateName + "' estate? (yes/no)", "yes"); deLinkEstate = (resp.StartsWith("y", System.StringComparison.Ordinal)); } if (!deLinkEstate) { return; } // good to go if (!estateConnector.DelinkRegion(regionID)) { MainConsole.Instance.Warn("[Estate]: Aborting - Unable to remove this region from the current estate."); return; } // check for'Mainland' string regType = regScene.RegionInfo.RegionType.ToLower(); if (regType.StartsWith("m", System.StringComparison.Ordinal)) { if (newEstateId == Constants.MainlandEstateID) { MainConsole.Instance.Info("[Estate]: This region is already part of the Mainland estate"); return; } // link this region to the mainland MainConsole.Instance.Info("[Estate]: Mainland type regions must be part of the Mainland estate"); LinkSystemEstate(regionID, Constants.MainlandEstateID); return; } var newEstate = LinkRegionEstate(regionID, newEstateId); if (newEstate != null) { regScene.RegionInfo.EstateSettings = newEstate; // Linking was successful, change any previously owned parcels to the new owner if (oldOwnerID != UUID.Zero) { IParcelManagementModule parcelManagement = regScene.RequestModuleInterface <IParcelManagementModule> (); if (parcelManagement != null) { parcelManagement.ReclaimParcels(oldOwnerID, newEstate.EstateOwner); } } } }
/// <summary> /// Creates the estate info for a region. /// </summary> /// <returns>The estate info.</returns> /// <param name="scene">Scene.</param> EstateSettings CreateEstateInfo(IScene scene) { // check for regionType to determine if this is 'Mainland' or an 'Estate' string regType = scene.RegionInfo.RegionType.ToLower(); if (regType.StartsWith("m", System.StringComparison.Ordinal)) { return(LinkSystemEstate(scene.RegionInfo.RegionID, Constants.MainlandEstateID)); } // we are linking to a user estate IEstateConnector estateConnector = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector> (); ISystemAccountService sysAccounts = m_registry.RequestModuleInterface <ISystemAccountService> (); string sysEstateOwnerName; var sysAccount = scene.UserAccountService.GetUserAccount(scene.RegionInfo.AllScopeIDs, sysAccounts.SystemEstateOwnerUUID); if (sysAccount == null) { sysEstateOwnerName = sysAccounts.SystemEstateOwnerName; } else { sysEstateOwnerName = sysAccount.Name; } // This is an 'Estate' so get some details.... var LastEstateOwner = sysEstateOwnerName; string LastEstateName; while (true) { UserAccount account; string estateOwner; estateOwner = MainConsole.Instance.Prompt("Estate owner name (" + sysEstateOwnerName + "/User Name)", LastEstateOwner); // we have a prospective estate owner... List <EstateSettings> ownerEstates = null; account = scene.UserAccountService.GetUserAccount(scene.RegionInfo.AllScopeIDs, estateOwner); if (account != null) { // we have a user account... LastEstateOwner = account.Name; ownerEstates = estateConnector.GetEstates(account.PrincipalID); } if (account == null || ownerEstates == null || ownerEstates.Count == 0) { if (account == null) { MainConsole.Instance.Warn("[Estate]: Unable to locate the user " + estateOwner); } else { MainConsole.Instance.WarnFormat("[Estate]: The user, {0}, has no estates currently.", account.Name); } string joinSystemland = MainConsole.Instance.Prompt( "Do you want to 'park' the region with the system owner/estate? (yes/no)", "yes"); if (joinSystemland.ToLower().StartsWith("y", System.StringComparison.Ordinal)) // joining 'Systemland' { return(LinkSystemEstate(scene.RegionInfo.RegionID, Constants.SystemEstateID)); } continue; } if (ownerEstates.Count > 1) { MainConsole.Instance.InfoFormat("[Estate]: User {0} has {1} estates currently. {2}", account.Name, ownerEstates.Count, "These estates are the following:"); foreach (EstateSettings t in ownerEstates) { MainConsole.Instance.CleanInfo(" " + t.EstateName); } LastEstateName = ownerEstates [0].EstateName; List <string> responses = ownerEstates.Select(settings => settings.EstateName).ToList(); responses.Add("Cancel"); do { //TODO: This could be a problem if we have a lot of estates string response = MainConsole.Instance.Prompt("Estate name to join", LastEstateName, responses); if (response == "None" || response == "Cancel") { LastEstateName = ""; break; } LastEstateName = response; } while (LastEstateName == ""); if (LastEstateName == "") { continue; } } else { LastEstateName = ownerEstates [0].EstateName; } // we should have a user account and estate name by now int estateID = estateConnector.GetEstate(account.PrincipalID, LastEstateName); if (estateID == 0) { MainConsole.Instance.Warn("[Estate]: The name you have entered matches no known estate. Please try again"); continue; } // link up the region EstateSettings ES; UUID oldOwnerID = UUID.Zero; if (scene.RegionInfo.EstateSettings != null) { oldOwnerID = scene.RegionInfo.EstateSettings.EstateOwner; } if (!estateConnector.LinkRegion(scene.RegionInfo.RegionID, estateID)) { MainConsole.Instance.WarnFormat("[Estate]: Joining the {0} estate failed. Please try again.", LastEstateName); continue; } // make sure that the region is fully set up if ((ES = estateConnector.GetEstateSettings(scene.RegionInfo.RegionID)) == null || ES.EstateID == 0) { MainConsole.Instance.Warn("[Estate]: Unable to verify region update (possible server connection error), please try again."); continue; } // Linking was successful, change any previously owned parcels to the new owner if (oldOwnerID != UUID.Zero) { IParcelManagementModule parcelManagement = scene.RequestModuleInterface <IParcelManagementModule> (); if (parcelManagement != null) { parcelManagement.ReclaimParcels(oldOwnerID, ES.EstateOwner); } } MainConsole.Instance.InfoFormat("[Estate]: Successfully joined the {0} estate!", LastEstateName); return(ES); } }
public Dictionary <string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest, OSHttpResponse httpResponse, Dictionary <string, object> requestParameters, ITranslator translator, out string response) { response = null; var vars = new Dictionary <string, object>(); if (httpRequest.Query.ContainsKey("regionid")) { var regionService = webInterface.Registry.RequestModuleInterface <IGridService> (); var region = regionService.GetRegionByUUID(null, UUID.Parse(httpRequest.Query["regionid"].ToString())); IEstateConnector estateConnector = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector>(); EstateSettings estate = estateConnector.GetEstateSettings(region.RegionID); vars.Add("RegionName", region.RegionName); vars.Add("OwnerUUID", estate.EstateOwner); var estateOwnerAccount = webInterface.Registry.RequestModuleInterface <IUserAccountService>(). GetUserAccount(null, estate.EstateOwner); vars.Add("OwnerName", estateOwnerAccount == null ? "No account found" : estateOwnerAccount.Name); vars.Add("RegionLocX", region.RegionLocX / Constants.RegionSize); vars.Add("RegionLocY", region.RegionLocY / Constants.RegionSize); vars.Add("RegionSizeX", region.RegionSizeX); vars.Add("RegionSizeY", region.RegionSizeY); vars.Add("RegionType", region.RegionType); vars.Add("RegionTerrain", region.RegionTerrain); vars.Add("RegionOnline", (region.Flags & (int)RegionFlags.RegionOnline) == (int)RegionFlags.RegionOnline ? translator.GetTranslatedString("Online") : translator.GetTranslatedString("Offline")); IAgentInfoService agentInfoService = webInterface.Registry.RequestModuleInterface <IAgentInfoService>(); IUserAccountService userService = webInterface.Registry.RequestModuleInterface <IUserAccountService>(); if (agentInfoService != null) { List <UserInfo> usersInRegion = agentInfoService.GetUserInfos(region.RegionID); vars.Add("NumberOfUsersInRegion", usersInRegion.Count); List <Dictionary <string, object> > users = new List <Dictionary <string, object> >(); foreach (var client in usersInRegion) { UserAccount account = userService.GetUserAccount(null, client.UserID); if (account == null) { continue; } Dictionary <string, object> user = new Dictionary <string, object>(); user.Add("UserNameText", translator.GetTranslatedString("UserNameText")); user.Add("UserUUID", client.UserID); user.Add("UserName", account.Name); users.Add(user); } vars.Add("UsersInRegion", users); } else { vars.Add("NumberOfUsersInRegion", 0); vars.Add("UsersInRegion", new List <Dictionary <string, object> >()); } IDirectoryServiceConnector directoryConnector = Framework.Utilities.DataManager.RequestPlugin <IDirectoryServiceConnector>(); if (directoryConnector != null) { List <LandData> data = directoryConnector.GetParcelsByRegion(0, 10, region.RegionID, UUID.Zero, ParcelFlags.None, ParcelCategory.Any); List <Dictionary <string, object> > parcels = new List <Dictionary <string, object> >(); foreach (var p in data) { Dictionary <string, object> parcel = new Dictionary <string, object>(); parcel.Add("ParcelNameText", translator.GetTranslatedString("ParcelNameText")); parcel.Add("ParcelOwnerText", translator.GetTranslatedString("ParcelOwnerText")); parcel.Add("ParcelUUID", p.GlobalID); parcel.Add("ParcelName", p.Name); parcel.Add("ParcelOwnerUUID", p.OwnerID); IUserAccountService accountService = webInterface.Registry.RequestModuleInterface <IUserAccountService>(); if (accountService != null) { var account = accountService.GetUserAccount(null, p.OwnerID); if (account == null) { parcel.Add("ParcelOwnerName", translator.GetTranslatedString("NoAccountFound")); } else { parcel.Add("ParcelOwnerName", account.Name); } } parcels.Add(parcel); } vars.Add("ParcelInRegion", parcels); vars.Add("NumberOfParcelsInRegion", parcels.Count); } IWebHttpTextureService webTextureService = webInterface.Registry. RequestModuleInterface <IWebHttpTextureService>(); if (webTextureService != null && region.TerrainMapImage != UUID.Zero) { vars.Add("RegionImageURL", webTextureService.GetTextureURL(region.TerrainMapImage)); } else { vars.Add("RegionImageURL", "images/icons/no_picture.jpg"); } // Menu Region vars.Add("MenuRegionTitle", translator.GetTranslatedString("MenuRegionTitle")); vars.Add("MenuParcelTitle", translator.GetTranslatedString("MenuParcelTitle")); vars.Add("MenuOwnerTitle", translator.GetTranslatedString("MenuOwnerTitle")); vars.Add("RegionInformationText", translator.GetTranslatedString("RegionInformationText")); vars.Add("OwnerNameText", translator.GetTranslatedString("OwnerNameText")); vars.Add("RegionLocationText", translator.GetTranslatedString("RegionLocationText")); vars.Add("RegionSizeText", translator.GetTranslatedString("RegionSizeText")); vars.Add("RegionNameText", translator.GetTranslatedString("RegionNameText")); vars.Add("RegionTypeText", translator.GetTranslatedString("RegionTypeText")); vars.Add("RegionTerrainText", translator.GetTranslatedString("RegionTerrainText")); vars.Add("RegionInfoText", translator.GetTranslatedString("RegionInfoText")); vars.Add("RegionOnlineText", translator.GetTranslatedString("RegionOnlineText")); vars.Add("NumberOfUsersInRegionText", translator.GetTranslatedString("NumberOfUsersInRegionText")); vars.Add("ParcelsInRegionText", translator.GetTranslatedString("ParcelsInRegionText")); // Style Switcher vars.Add("styles1", translator.GetTranslatedString("styles1")); vars.Add("styles2", translator.GetTranslatedString("styles2")); vars.Add("styles3", translator.GetTranslatedString("styles3")); vars.Add("styles4", translator.GetTranslatedString("styles4")); vars.Add("styles5", translator.GetTranslatedString("styles5")); vars.Add("StyleSwitcherStylesText", translator.GetTranslatedString("StyleSwitcherStylesText")); vars.Add("StyleSwitcherLanguagesText", translator.GetTranslatedString("StyleSwitcherLanguagesText")); vars.Add("StyleSwitcherChoiceText", translator.GetTranslatedString("StyleSwitcherChoiceText")); // Language Switcher vars.Add("en", translator.GetTranslatedString("en")); vars.Add("fr", translator.GetTranslatedString("fr")); vars.Add("de", translator.GetTranslatedString("de")); vars.Add("it", translator.GetTranslatedString("it")); vars.Add("es", translator.GetTranslatedString("es")); vars.Add("nl", translator.GetTranslatedString("nl")); var settings = webInterface.GetWebUISettings(); vars.Add("ShowLanguageTranslatorBar", !settings.HideLanguageTranslatorBar); vars.Add("ShowStyleBar", !settings.HideStyleBar); } return(vars); }
public Dictionary <string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest, OSHttpResponse httpResponse, Dictionary <string, object> requestParameters, ITranslator translator, out string response) { // under development //response = "<h3>Sorry! This feature is not available yet<</h3><br /> Redirecting to main page" + // "<script language=\"javascript\">" + // "setTimeout(function() {window.location.href = \"index.html\";}, 3000);" + // "</script>"; //return null; response = null; var vars = new Dictionary <string, object> (); if (httpRequest.Query.ContainsKey("regionid")) { var regionService = webInterface.Registry.RequestModuleInterface <IGridService> (); var region = regionService.GetRegionByUUID(null, UUID.Parse(httpRequest.Query ["regionid"].ToString())); IEstateConnector estateConnector = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector> (); var ownerUUID = UUID.Zero; string ownerName = "Unknown"; if (estateConnector != null) { EstateSettings estate = estateConnector.GetEstateSettings(region.RegionID); if (estate != null) { ownerUUID = estate.EstateOwner; UserAccount estateOwnerAccount = null; var accountService = webInterface.Registry.RequestModuleInterface <IUserAccountService> (); if (accountService != null) { estateOwnerAccount = accountService.GetUserAccount(null, estate.EstateOwner); } ownerName = estateOwnerAccount == null ? "No account found" : estateOwnerAccount.Name; } } else { ownerUUID = UUID.Zero; ownerName = "Unknown"; } vars.Add("OwnerUUID", ownerUUID); vars.Add("OwnerName", ownerName); vars.Add("RegionName", region.RegionName); vars.Add("RegionLocX", region.RegionLocX / Constants.RegionSize); vars.Add("RegionLocY", region.RegionLocY / Constants.RegionSize); vars.Add("RegionSizeX", region.RegionSizeX); vars.Add("RegionSizeY", region.RegionSizeY); vars.Add("RegionType", region.RegionType); vars.Add("RegionTerrain", region.RegionTerrain); vars.Add("RegionOnline", (region.Flags & (int)RegionFlags.RegionOnline) == (int)RegionFlags.RegionOnline ? translator.GetTranslatedString("Online") : translator.GetTranslatedString("Offline")); IDirectoryServiceConnector directoryConnector = Framework.Utilities.DataManager.RequestPlugin <IDirectoryServiceConnector> (); if (directoryConnector != null) { IUserAccountService accountService = webInterface.Registry.RequestModuleInterface <IUserAccountService> (); List <LandData> data = directoryConnector.GetParcelsByRegion(0, 10, region.RegionID, UUID.Zero, ParcelFlags.None, ParcelCategory.Any); List <Dictionary <string, object> > parcels = new List <Dictionary <string, object> > (); string url = "../images/icons/no_parcel.jpg"; if (data != null) { foreach (var p in data) { Dictionary <string, object> parcel = new Dictionary <string, object> (); parcel.Add("ParcelNameText", translator.GetTranslatedString("ParcelNameText")); parcel.Add("ParcelOwnerText", translator.GetTranslatedString("ParcelOwnerText")); parcel.Add("ParcelUUID", p.GlobalID); parcel.Add("ParcelName", p.Name); parcel.Add("ParcelOwnerUUID", p.OwnerID); parcel.Add("ParcelSnapshotURL", url); if (accountService != null) { var account = accountService.GetUserAccount(null, p.OwnerID); if (account != null) { parcel.Add("ParcelOwnerName", account.Name); } else { parcel.Add("ParcelOwnerName", translator.GetTranslatedString("NoAccountFound")); } } parcels.Add(parcel); } } vars.Add("ParcelInRegion", parcels); vars.Add("NumberOfParcelsInRegion", parcels.Count); } IWebHttpTextureService webTextureService = webInterface.Registry. RequestModuleInterface <IWebHttpTextureService> (); if (webTextureService != null && region.TerrainMapImage != UUID.Zero) { vars.Add("RegionImageURL", webTextureService.GetTextureURL(region.TerrainMapImage)); } else { vars.Add("RegionImageURL", "../images/icons/no_terrain.jpg"); } /* // Regionprofile Menus * vars.Add("MenuRegionTitle", translator.GetTranslatedString("MenuRegionTitle")); * vars.Add("TooltipsMenuRegion", translator.GetTranslatedString("TooltipsMenuRegion")); * vars.Add("MenuParcelTitle", translator.GetTranslatedString("MenuParcelTitle")); * vars.Add("TooltipsMenuParcel", translator.GetTranslatedString("TooltipsMenuParcel")); * vars.Add("MenuOwnerTitle", translator.GetTranslatedString("MenuOwnerTitle")); * vars.Add("TooltipsMenuOwner", translator.GetTranslatedString("TooltipsMenuOwner")); */ vars.Add("RegionInformationText", translator.GetTranslatedString("RegionInformationText")); vars.Add("OwnerNameText", translator.GetTranslatedString("OwnerNameText")); vars.Add("RegionLocationText", translator.GetTranslatedString("RegionLocationText")); vars.Add("RegionSizeText", translator.GetTranslatedString("RegionSizeText")); vars.Add("RegionNameText", translator.GetTranslatedString("RegionNameText")); vars.Add("RegionTypeText", translator.GetTranslatedString("RegionTypeText")); vars.Add("RegionTerrainText", translator.GetTranslatedString("RegionTerrainText")); vars.Add("RegionInfoText", translator.GetTranslatedString("RegionInfoText")); vars.Add("RegionOnlineText", translator.GetTranslatedString("RegionOnlineText")); vars.Add("NumberOfUsersInRegionText", translator.GetTranslatedString("NumberOfUsersInRegionText")); vars.Add("ParcelsInRegionText", translator.GetTranslatedString("ParcelsInRegionText")); vars.Add("MainServerURL", webInterface.GridURL); } return(vars); }