Esempio n. 1
0
        public Dictionary <string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest,
                                                OSHttpResponse httpResponse, Dictionary <string, object> requestParameters, ITranslator translator)
        {
            var vars = new Dictionary <string, object>();
            IGenericsConnector connector = Aurora.DataManager.DataManager.RequestPlugin <IGenericsConnector>();

            bool changed = false;

            if (requestParameters.ContainsKey("Submit"))
            {
                changed = true;
                GridWelcomeScreen submittedInfo = new GridWelcomeScreen();
                submittedInfo.SpecialWindowMessageTitle = requestParameters["SpecialWindowTitle"].ToString();
                submittedInfo.SpecialWindowMessageText  = requestParameters["SpecialWindowText"].ToString();
                submittedInfo.SpecialWindowMessageColor = requestParameters["SpecialWindowColor"].ToString();
                submittedInfo.SpecialWindowActive       = requestParameters["SpecialWindowStatus"].ToString() == "1";
                submittedInfo.GridStatus = requestParameters["GridStatus"].ToString() == "1";

                connector.AddGeneric(UUID.Zero, "GridWelcomeScreen", "GridWelcomeScreen", submittedInfo.ToOSD());
            }

            GridWelcomeScreen welcomeInfo = connector.GetGeneric <GridWelcomeScreen>(UUID.Zero, "GridWelcomeScreen", "GridWelcomeScreen");

            if (welcomeInfo == null)
            {
                welcomeInfo = GridWelcomeScreen.Default;
            }
            vars.Add("OpenNewsManager", translator.GetTranslatedString("OpenNewsManager"));
            vars.Add("SpecialWindowTitleText", translator.GetTranslatedString("SpecialWindowTitleText"));
            vars.Add("SpecialWindowTextText", translator.GetTranslatedString("SpecialWindowTextText"));
            vars.Add("SpecialWindowColorText", translator.GetTranslatedString("SpecialWindowColorText"));
            vars.Add("SpecialWindowStatusText", translator.GetTranslatedString("SpecialWindowStatusText"));
            vars.Add("WelcomeScreenManagerFor", translator.GetTranslatedString("WelcomeScreenManagerFor"));
            vars.Add("GridStatus", translator.GetTranslatedString("GridStatus"));
            vars.Add("Online", translator.GetTranslatedString("Online"));
            vars.Add("Offline", translator.GetTranslatedString("Offline"));
            vars.Add("Enabled", translator.GetTranslatedString("Enabled"));
            vars.Add("Disabled", translator.GetTranslatedString("Disabled"));

            vars.Add("SpecialWindowTitle", welcomeInfo.SpecialWindowMessageTitle);
            vars.Add("SpecialWindowMessage", welcomeInfo.SpecialWindowMessageText);
            vars.Add("SpecialWindowActive", welcomeInfo.SpecialWindowActive ? "selected" : "");
            vars.Add("SpecialWindowInactive", welcomeInfo.SpecialWindowActive ? "" : "selected");
            vars.Add("GridActive", welcomeInfo.GridStatus ? "selected" : "");
            vars.Add("GridInactive", welcomeInfo.GridStatus ? "" : "selected");
            vars.Add("SpecialWindowColorRed", welcomeInfo.SpecialWindowMessageColor == "red" ? "selected" : "");
            vars.Add("SpecialWindowColorYellow", welcomeInfo.SpecialWindowMessageColor == "yellow" ? "selected" : "");
            vars.Add("SpecialWindowColorGreen", welcomeInfo.SpecialWindowMessageColor == "green" ? "selected" : "");
            vars.Add("SpecialWindowColorWhite", welcomeInfo.SpecialWindowMessageColor == "white" ? "selected" : "");
            vars.Add("Submit", translator.GetTranslatedString("Submit"));
            vars.Add("ChangesSavedSuccessfully", changed ? translator.GetTranslatedString("ChangesSavedSuccessfully") : "");

            return(vars);
        }
Esempio n. 2
0
        private Hashtable DispatchOpenRegionSettings(Hashtable m_dhttpMethod, UUID agentID)
        {
            Hashtable responsedata = new Hashtable();

            responsedata["int_response_code"]   = 200; //501; //410; //404;
            responsedata["content_type"]        = "text/plain";
            responsedata["keepalive"]           = false;
            responsedata["str_response_string"] = "";

            IScenePresence SP = m_scene.GetScenePresence(agentID);

            if (SP == null)
            {
                return(responsedata); //They don't exist
            }
            if (!((Scene)SP.Scene).Permissions.CanIssueEstateCommand(SP.UUID, false))
            {
                return(responsedata); // No permissions
            }
            OSDMap rm = (OSDMap)OSDParser.DeserializeLLSDXml((string)m_dhttpMethod["requestbody"]);

            m_settings.DefaultDrawDistance           = rm["draw_distance"].AsInteger();
            m_settings.ForceDrawDistance             = rm["force_draw_distance"].AsBoolean();
            m_settings.DisplayMinimap                = rm["allow_minimap"].AsBoolean();
            m_settings.AllowPhysicalPrims            = rm["allow_physical_prims"].AsBoolean();
            m_settings.MaxDragDistance               = (float)rm["max_drag_distance"].AsReal();
            m_settings.MinimumHoleSize               = (float)rm["min_hole_size"].AsReal();
            m_settings.MaximumHollowSize             = (float)rm["max_hollow_size"].AsReal();
            m_settings.MaximumInventoryItemsTransfer = rm["max_inventory_items_transfer"].AsInteger();
            m_settings.MaximumLinkCount              = (int)rm["max_link_count"].AsReal();
            m_settings.MaximumLinkCountPhys          = (int)rm["max_link_count_phys"].AsReal();
            m_settings.MaximumPhysPrimScale          = (float)rm["max_phys_prim_scale"].AsReal();
            m_settings.MaximumPrimScale              = (float)rm["max_prim_scale"].AsReal();
            m_settings.MinimumPrimScale              = (float)rm["min_prim_scale"].AsReal();
            m_settings.RenderWater          = rm["render_water"].AsBoolean();
            m_settings.ShowTags             = (int)rm["show_tags"].AsReal();
            m_settings.MaxGroups            = (int)rm["max_groups"].AsReal();
            m_settings.AllowParcelWindLight = rm["allow_parcel_windlight"].AsBoolean();
            m_settings.EnableTeenMode       = rm["enable_teen_mode"].AsBoolean();
            m_settings.ClampPrimSizes       = rm["enforce_max_build"].AsBoolean();

            IGenericsConnector connector = Aurora.DataManager.DataManager.RequestPlugin <IGenericsConnector>();

            //Update the database
            if (connector != null)
            {
                connector.AddGeneric(SP.Scene.RegionInfo.RegionID, "OpenRegionSettings", "OpenRegionSettings", m_settings.ToOSD());
            }

            //Update all clients about changes
            SendToAllClients();

            return(responsedata);
        }
        public void AddUser(UUID uuid, string firstName, string lastName, Dictionary <string, object> serviceUrls)
        {
            UserData ud = new UserData();

            ud.FirstName  = firstName;
            ud.Id         = uuid;
            ud.LastName   = lastName;
            ud.ServerURLs = serviceUrls;
            if (ud.ServerURLs != null && ud.ServerURLs.ContainsKey(GetHandlers.Helpers_HomeURI))
            {
                ud.HomeURL = ud.ServerURLs[GetHandlers.Helpers_HomeURI].ToString();
            }
            else
            {
                ud.HomeURL = "";
            }
            if (ud.ServerURLs == null)
            {
                ud.ServerURLs = new Dictionary <string, object>();
            }

            m_generics.AddGeneric(UUID.Zero, "ForeignUsers", uuid.ToString(), ud.ToOSD());
        }
Esempio n. 4
0
        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>();
            IGenericsConnector connector = Framework.Utilities.DataManager.RequestPlugin <IGenericsConnector>();
            GridNewsItem       news;

            if (requestParameters.ContainsKey("Submit"))
            {
                string title = requestParameters["NewsTitle"].ToString();
                string text  = requestParameters["NewsText"].ToString();
                string id    = requestParameters["NewsID"].ToString();
                news = connector.GetGeneric <GridNewsItem>(UUID.Zero, "WebGridNews", id);

                if (news != null)
                {
                    connector.RemoveGeneric(UUID.Zero, "WebGridNews", id);
                    GridNewsItem item = new GridNewsItem {
                        Text = text, Time = news.Time, Title = title, ID = int.Parse(id)
                    };
                    connector.AddGeneric(UUID.Zero, "WebGridNews", id, item.ToOSD());
                    response = "<h3>News item editted successfully, redirecting to main page</h3>" +
                               "<script language=\"javascript\">" +
                               "setTimeout(function() {window.location.href = \"index.html?page=news_manager\";}, 0);" +
                               "</script>";
                }

                return(null);
            }

            news = connector.GetGeneric <GridNewsItem>(UUID.Zero, "WebGridNews", httpRequest.Query["newsid"].ToString());

            if (news != null)
            {
                vars.Add("NewsTitle", news.Title);
                vars.Add("NewsText", news.Text);
                vars.Add("NewsID", news.ID.ToString());

                vars.Add("NewsItemTitle", translator.GetTranslatedString("NewsItemTitle"));
                vars.Add("NewsItemText", translator.GetTranslatedString("NewsItemText"));
                vars.Add("EditNewsText", translator.GetTranslatedString("EditNewsText"));
                vars.Add("Submit", translator.GetTranslatedString("Submit"));
            }

            return(vars);
        }
Esempio n. 5
0
        private byte[] SetEnvironment(Stream request, UUID agentID)
        {
            IScenePresence SP = m_scene.GetScenePresence(agentID);

            if (SP == null)
            {
                return(new byte[0]); //They don't exist
            }
            bool   success     = false;
            string fail_reason = "";

            if (SP.Scene.Permissions.CanIssueEstateCommand(agentID, false))
            {
                m_info = OSDParser.DeserializeLLSDXml(request);
                IGenericsConnector gc = DataManager.DataManager.RequestPlugin <IGenericsConnector>();
                if (gc != null)
                {
                    gc.AddGeneric(m_scene.RegionInfo.RegionID, "EnvironmentSettings", "",
                                  (new OSDWrapper {
                        Info = m_info
                    }).ToOSD());
                }
                success = true;

                //Tell everyone about the changes
                TriggerWindlightUpdate(1);
            }
            else
            {
                fail_reason = "You don't have permissions to set the windlight settings here.";
                SP.ControllingClient.SendAlertMessage(
                    "You don't have the correct permissions to set the Windlight Settings");
            }
            OSDMap result = new OSDMap()
            {
                new KeyValuePair <string, OSD>("success", success),
                new KeyValuePair <string, OSD>("regionID", SP.Scene.RegionInfo.RegionID)
            };

            if (fail_reason != "")
            {
                result["fail_reason"] = fail_reason;
            }

            return(OSDParser.SerializeLLSDXmlBytes(result));
        }
Esempio n. 6
0
        /// <summary>
        /// Promotes a user to allow API access.
        /// </summary>
        /// <param name="scene">Scene.</param>
        /// <param name="cmd">Cmd.</param>
        void PromoteAPIUser(IScene scene, string [] cmd)
        {
            var userName = MainConsole.Instance.Prompt("Name of user <First> <Last>");
            var userAcct = m_registry.RequestModuleInterface <IUserAccountService> ().GetUserAccount(null, userName);

            if (!userAcct.Valid)
            {
                MainConsole.Instance.Error("Sorry! Unable to locate this user.");
                return;
            }

            var authKey = UUID.Random().ToString();

            var apiItem = new APIAuthItem {
                Username = userAcct.Name, KeyDate = DateTime.Now, APIKey = authKey
            };

            apiItem.KeyID = generics.GetGenericCount((UUID)Constants.GovernorUUID, "APIKey") + 1;
            generics.AddGeneric((UUID)Constants.GovernorUUID, "APIKey", authKey, apiItem.ToOSD());

            MainConsole.Instance.InfoFormat("[API]: User {0} {1} - API key : {2}", userAcct.FirstName, userAcct.LastName, authKey);
        }
Esempio n. 7
0
        public Dictionary <string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest,
                                                OSHttpResponse httpResponse, Dictionary <string, object> requestParameters, ITranslator translator)
        {
            var vars = new Dictionary <string, object>();
            IGenericsConnector connector = Aurora.DataManager.DataManager.RequestPlugin <IGenericsConnector>();
            GridNewsItem       news;

            if (requestParameters.ContainsKey("Submit"))
            {
                string title = requestParameters["NewsTitle"].ToString();
                string text  = requestParameters["NewsText"].ToString();
                string id    = requestParameters["NewsID"].ToString();
                news = connector.GetGeneric <GridNewsItem>(UUID.Zero, "WebGridNews", id);
                connector.RemoveGeneric(UUID.Zero, "WebGridNews", id);
                GridNewsItem item = new GridNewsItem {
                    Text = text, Time = news.Time, Title = title, ID = int.Parse(id)
                };
                connector.AddGeneric(UUID.Zero, "WebGridNews", id, item.ToOSD());
                vars["ErrorMessage"] = "News item edit successfully";
                webInterface.Redirect(httpResponse, "index.html?page=news_manager", filename);
                return(vars);
            }
            else
            {
                vars["ErrorMessage"] = "";
            }


            news = connector.GetGeneric <GridNewsItem>(UUID.Zero, "WebGridNews", httpRequest.Query["newsid"].ToString());
            vars.Add("NewsTitle", news.Title);
            vars.Add("NewsText", news.Text);
            vars.Add("NewsID", news.ID.ToString());

            vars.Add("NewsItemTitle", translator.GetTranslatedString("NewsItemTitle"));
            vars.Add("NewsItemText", translator.GetTranslatedString("NewsItemText"));
            vars.Add("EditNewsText", translator.GetTranslatedString("EditNewsText"));
            vars.Add("Submit", translator.GetTranslatedString("Submit"));
            return(vars);
        }
Esempio n. 8
0
        private void AddConnection(IWCCertificate c)
        {
            IWCCertificate old = null;

            foreach (IWCCertificate cert in Connections)
            {
                if (cert.Connection.UserName == c.Connection.UserName)
                {
                    old = cert;
                }
            }
            if (old != null)
            {
                Connections.Remove(old);
            }

            Connections.Add(c);
            IGenericsConnector genericsConnector = DataManager.DataManager.RequestPlugin <IGenericsConnector> ();

            if (genericsConnector != null)
            {
                genericsConnector.AddGeneric(UUID.Zero, "InterWorldConnections", c.Connection.RecieverURL, c.ToOSD());
            }
        }
Esempio n. 9
0
        private EstateSettings CreateEstateInfo(Scene scene)
        {
            EstateSettings ES = new EstateSettings();

            while (true)
            {
                IEstateConnector EstateConnector = DataManager.RequestPlugin <IEstateConnector>();

                string      name    = MainConsole.Instance.CmdPrompt("Estate owner name", LastEstateOwner);
                UserAccount account = scene.UserAccountService.GetUserAccount(scene.RegionInfo.ScopeID, name);

                if (account == null)
                {
                    string createNewUser = MainConsole.Instance.CmdPrompt("Could not find user " + name + ". Would you like to create this user?", "yes");

                    if (createNewUser == "yes")
                    {
                        // Create a new account
                        string password = MainConsole.Instance.PasswdPrompt(name + "'s password");
                        string email    = MainConsole.Instance.CmdPrompt(name + "'s email", "");

                        scene.UserAccountService.CreateUser(name, Util.Md5Hash(password), email);
                        account = scene.UserAccountService.GetUserAccount(scene.RegionInfo.ScopeID, name);

                        if (account == null)
                        {
                            m_log.ErrorFormat("[EstateService]: Unable to store account. If this simulator is connected to a grid, you must create the estate owner account first.");
                            continue;
                        }
                    }
                    else
                    {
                        continue;
                    }
                }

                LastEstateOwner = account.Name;

                string response = "no";
                List <EstateSettings> ownerEstates = EstateConnector.GetEstates(account.PrincipalID);
                if (ownerEstates != null)
                {
                    m_log.WarnFormat("Found user. {0} has {1} estates currently. {2}", account.Name, ownerEstates.Count,
                                     "These estates are the following:");
                    for (int i = 0; i < ownerEstates.Count; i++)
                    {
                        m_log.Warn(ownerEstates[i].EstateName);
                    }
                    response = MainConsole.Instance.CmdPrompt("Do you wish to join one of these existing estates? (Options are {yes, no})", LastEstateChoise, new List <string>()
                    {
                        "yes", "no"
                    });
                }
                else
                {
                    m_log.WarnFormat("Found user. {0} has no estates currently. Creating a new estate.", account.Name);
                }
                LastEstateChoise = response;
                if (response == "no")
                {
                    // Create a new estate
                    ES.EstateName = MainConsole.Instance.CmdPrompt("New estate name", scene.RegionInfo.EstateSettings.EstateName);

                    //Set to auto connect to this region next
                    LastEstateName   = ES.EstateName;
                    LastEstateChoise = "yes";

                    string Password = Util.Md5Hash(Util.Md5Hash(MainConsole.Instance.CmdPrompt("New estate password (to keep others from joining your estate, blank to have no pass)", ES.EstatePass)));
                    ES.EstatePass  = Password;
                    ES.EstateOwner = account.PrincipalID;

                    ES = EstateConnector.CreateEstate(ES, scene.RegionInfo.RegionID);
                    if (ES == null)
                    {
                        m_log.Warn("The connection to the server was broken, please try again soon.");
                        continue;
                    }
                    else if (ES.EstateID == 0)
                    {
                        m_log.Warn("There was an error in creating this estate: " + ES.EstateName); //EstateName holds the error. See LocalEstateConnector for more info.
                        continue;
                    }
                    //We set this back if there wasn't an error because the EstateService will NOT send it back
                    IGenericsConnector g = DataManager.RequestPlugin <IGenericsConnector>();
                    EstatePassword     s = new EstatePassword()
                    {
                        Password = Password
                    };
                    if (g != null) //Save the pass to the database
                    {
                        g.AddGeneric(scene.RegionInfo.RegionID, "EstatePassword", ES.EstateID.ToString(), s.ToOSD());
                    }
                    break;
                }
                else if (response == "yes")
                {
                    if (ownerEstates.Count != 1)
                    {
                        response = MainConsole.Instance.CmdPrompt("Estate name to join", LastEstateName);
                        if (response == "None")
                        {
                            continue;
                        }
                        LastEstateName = response;
                    }
                    else
                    {
                        LastEstateName = ownerEstates[0].EstateName;
                    }

                    List <int> estateIDs = EstateConnector.GetEstates(LastEstateName);
                    if (estateIDs == null)
                    {
                        m_log.Warn("The connection to the server was broken, please try again soon.");
                        continue;
                    }
                    if (estateIDs.Count < 1)
                    {
                        m_log.Warn("The name you have entered matches no known estate. Please try again");
                        continue;
                    }

                    int estateID = estateIDs[0];

                    string Password = Util.Md5Hash(Util.Md5Hash(MainConsole.Instance.CmdPrompt("Password for the estate", "")));
                    //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, Password))
                    {
                        if (EstateConnector.LoadEstateSettings(scene.RegionInfo.RegionID, out ES)) //We could do by EstateID now, but we need to completely make sure that it fully is set up
                        {
                            if (ES == null)
                            {
                                m_log.Warn("The connection to the server was broken, please try again soon.");
                                continue;
                            }
                            //Reset the pass and save it to the database
                            IGenericsConnector g = DataManager.RequestPlugin <IGenericsConnector>();
                            EstatePassword     s = new EstatePassword()
                            {
                                Password = Password
                            };
                            if (g != null) //Save the pass to the database
                            {
                                g.AddGeneric(scene.RegionInfo.RegionID, "EstatePassword", ES.EstateID.ToString(), s.ToOSD());
                            }
                        }
                        else
                        {
                            m_log.Warn("The connection to the server was broken, please try again soon.");
                            continue;
                        }
                        m_log.Warn("Successfully joined the estate!");
                        break;
                    }

                    m_log.Warn("Joining the estate failed. Please try again.");
                    continue;
                }
            }
            return(ES);
        }
        /// <summary>
        ///   Register this region with the grid service
        /// </summary>
        /// <param name = "scene"></param>
        /// <param name = "returnResponseFirstTime">Should we try to walk the user through what went wrong?</param>
        /// <param name="continueTrying"> </param>
        /// <param name="password"> </param>
        public bool RegisterRegionWithGrid(IScene scene, bool returnResponseFirstTime, bool continueTrying, string password)
        {
            GridRegion region = BuildGridRegion(scene.RegionInfo);

            IGenericsConnector g           = DataManager.DataManager.RequestPlugin <IGenericsConnector>();
            GridSessionID      s           = null;
            IGridService       GridService = scene.RequestModuleInterface <IGridService>();

            if (g != null) //Get the sessionID from the database if possible
            {
                s = g.GetGeneric <GridSessionID>(scene.RegionInfo.RegionID, "GridSessionID", "GridSessionID");
            }

            if (s == null)
            {
                s = new GridSessionID {
                    SessionID = scene.RegionInfo.GridSecureSessionID
                };
                //Set it from the regionInfo if it knows anything
            }

            scene.RequestModuleInterface <ISimulationBase>().EventManager.FireGenericEventHandler("PreRegisterRegion", region);

            //Tell the grid service about us
            RegisterRegion error = GridService.RegisterRegion(region, s.SessionID, password);

            if (error.Error == String.Empty)
            {
                s.SessionID = error.SessionID;
                //If it registered ok, we save the sessionID to the database and tlel the neighbor service about it
                scene.RegionInfo.GridSecureSessionID = error.SessionID;
                //Update our local copy of what our region flags are
                scene.RegionInfo.RegionFlags = error.RegionFlags;
                scene.RegionInfo.ScopeID     = error.Region.ScopeID;
                scene.RegionInfo.AllScopeIDs = error.Region.AllScopeIDs;

                //Save the new SessionID to the database
                if (g != null)
                {
                    g.AddGeneric(scene.RegionInfo.RegionID, "GridSessionID", "GridSessionID", s.ToOSD());
                }

                m_knownNeighbors[scene.RegionInfo.RegionID] = error.Neighbors;
                return(true); //Success
            }
            if (returnResponseFirstTime && !continueTrying)
            {
                MainConsole.Instance.Error("[RegisterRegionWithGrid]: Registration of region with grid failed again - " + error.Error);
                return(false);
            }

            //Parse the error and try to do something about it if at all possible
            if (error.Error == "Region location is reserved")
            {
                MainConsole.Instance.Error(
                    "[RegisterRegionWithGrid]: Registration of region with grid failed - The region location you specified is reserved. You must move your region.");
                int X = 0, Y = 0;
                int.TryParse(MainConsole.Instance.Prompt("New Region Location X", "1000"), out X);
                int.TryParse(MainConsole.Instance.Prompt("New Region Location Y", "1000"), out Y);

                scene.RegionInfo.RegionLocX = X * Constants.RegionSize;
                scene.RegionInfo.RegionLocY = Y * Constants.RegionSize;

                IRegionLoader[] loaders = scene.RequestModuleInterfaces <IRegionLoader>();
                foreach (IRegionLoader loader in loaders)
                {
                    loader.UpdateRegionInfo(scene.RegionInfo.RegionName, scene.RegionInfo);
                }
            }
            else if (error.Error == "Region overlaps another region")
            {
                MainConsole.Instance.Error("[RegisterRegionWithGrid]: Registration of region " + scene.RegionInfo.RegionName +
                                           " with the grid failed - The region location you specified is already in use. You must move your region.");
                int X = 0, Y = 0;
                int.TryParse(
                    MainConsole.Instance.Prompt("New Region Location X",
                                                (scene.RegionInfo.RegionLocX / 256).ToString()), out X);
                int.TryParse(
                    MainConsole.Instance.Prompt("New Region Location Y",
                                                (scene.RegionInfo.RegionLocY / 256).ToString()), out Y);

                scene.RegionInfo.RegionLocX = X * Constants.RegionSize;
                scene.RegionInfo.RegionLocY = Y * Constants.RegionSize;

                IRegionLoader[] loaders = scene.RequestModuleInterfaces <IRegionLoader>();
                foreach (IRegionLoader loader in loaders)
                {
                    loader.UpdateRegionInfo(scene.RegionInfo.RegionName, scene.RegionInfo);
                }
            }
            else if (error.Error.Contains("Can't move this region"))
            {
                MainConsole.Instance.Error("[RegisterRegionWithGrid]: Registration of region " + scene.RegionInfo.RegionName +
                                           " with the grid failed - You can not move this region. Moving it back to its original position.");
                //Opensim Grid Servers don't have this functionality.
                try
                {
                    string[] position = error.Error.Split(',');

                    scene.RegionInfo.RegionLocX = int.Parse(position[1]) * Constants.RegionSize;
                    scene.RegionInfo.RegionLocY = int.Parse(position[2]) * Constants.RegionSize;

                    IRegionLoader[] loaders = scene.RequestModuleInterfaces <IRegionLoader>();
                    foreach (IRegionLoader loader in loaders)
                    {
                        loader.UpdateRegionInfo(scene.RegionInfo.RegionName, scene.RegionInfo);
                    }
                }
                catch (Exception e)
                {
                    MainConsole.Instance.Error(
                        "Unable to move the region back to its original position, is this an opensim server? Please manually move the region back.");
                    throw e;
                }
            }
            else if (error.Error == "Duplicate region name")
            {
                MainConsole.Instance.Error("[RegisterRegionWithGrid]: Registration of region " + scene.RegionInfo.RegionName +
                                           " with the grid failed - The region name you specified is already in use. Please change the name.");
                string oldRegionName = scene.RegionInfo.RegionName;
                scene.RegionInfo.RegionName = MainConsole.Instance.Prompt("New Region Name", "");

                IRegionLoader[] loaders = scene.RequestModuleInterfaces <IRegionLoader>();
                foreach (IRegionLoader loader in loaders)
                {
                    loader.UpdateRegionInfo(oldRegionName, scene.RegionInfo);
                }
            }
            else if (error.Error == "Region locked out")
            {
                MainConsole.Instance.Error("[RegisterRegionWithGrid]: Registration of region " + scene.RegionInfo.RegionName +
                                           " with the grid the failed - The region you are attempting to join has been blocked from connecting. Please connect another region.");
                MainConsole.Instance.Prompt("Press enter when you are ready to exit");
                Environment.Exit(0);
            }
            else if (error.Error == "Could not reach grid service")
            {
                MainConsole.Instance.Error("[RegisterRegionWithGrid]: Registration of region " + scene.RegionInfo.RegionName +
                                           " with the grid failed - The grid service can not be found! Please make sure that you can connect to the grid server and that the grid server is on.");
                MainConsole.Instance.Error(
                    "You should also make sure you've provided the correct address and port of the grid service.");
                string input =
                    MainConsole.Instance.Prompt(
                        "Press enter when you are ready to proceed, or type cancel to exit");
                if (input == "cancel")
                {
                    Environment.Exit(0);
                }
            }
            else if (error.Error == "Wrong Session ID")
            {
                MainConsole.Instance.Error("[RegisterRegionWithGrid]: Registration of region " + scene.RegionInfo.RegionName +
                                           " with the grid failed - Wrong Session ID for this region!");
                MainConsole.Instance.Error(
                    "This means that this region has failed to connect to the grid server and needs removed from it before it can connect again.");
                MainConsole.Instance.Error(
                    "If you are running the Aurora.Server instance this region is connecting to, type \"clear grid region <RegionName>\" and then press enter on this console and it will work");
                MainConsole.Instance.Error(
                    "If you are not running the Aurora.Server instance this region is connecting to, please contact your grid operator so that he can fix it");

                string input =
                    MainConsole.Instance.Prompt(
                        "Press enter when you are ready to proceed, or type cancel to exit");
                if (input == "cancel")
                {
                    Environment.Exit(0);
                }
            }
            else
            {
                MainConsole.Instance.Error("[RegisterRegionWithGrid]: Registration of region " + scene.RegionInfo.RegionName +
                                           " with the grid failed - " + error.Error + "!");
                string input =
                    MainConsole.Instance.Prompt(
                        "Press enter when you are ready to proceed, or type cancel to exit");
                if (input == "cancel")
                {
                    Environment.Exit(0);
                }
            }
            return(RegisterRegionWithGrid(scene, true, continueTrying, password));
        }
Esempio n. 11
0
        public Dictionary <string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest,
                                                OSHttpResponse httpResponse, Dictionary <string, object> requestParameters, ITranslator translator)
        {
            var vars = new Dictionary <string, object>();

            #region Find pages

            List <Dictionary <string, object> > pages = new List <Dictionary <string, object> >();

            IGenericsConnector generics = Aurora.DataManager.DataManager.RequestPlugin <IGenericsConnector>();
            GridPage           rootPage = generics.GetGeneric <GridPage>(UUID.Zero, "WebPages", "Root");
            rootPage.Children.Sort((a, b) => a.MenuPosition.CompareTo(b.MenuPosition));
            List <GridPage> allPages = new List <GridPage>(rootPage.Children);
            foreach (GridPage page in rootPage.Children)
            {
                allPages.AddRange(page.Children);
            }
            allPages.RemoveAll((a) => !a.ShowInMenu);

            string MenuItem = requestParameters.ContainsKey("MenuItem") ?
                              requestParameters["MenuItem"].ToString() : "";
            foreach (GridPage page in allPages)
            {
                pages.Add(new Dictionary <string, object> {
                    { "Value", page.Location },
                    { "Name", page.Location }, { "PageSelected", MenuItem == page.Location ?
                                                 "selected=\"selected\"" : "" }
                });
            }
            vars.Add("PagesList", pages);

            #endregion

            bool   changed = false;
            string error   = translator.GetTranslatedString("ChangesSavedSuccessfully");
            if (requestParameters.ContainsKey("DeleteItem"))
            {
                rootPage.RemovePageByLocation(MenuItem, null);
                generics.AddGeneric(UUID.Zero, "WebPages", "Root", rootPage.ToOSD());
                webInterface.Redirect(httpResponse, "index.html?page=page_manager", filename);
            }
            if (requestParameters.ContainsKey("AddItem"))
            {
                //generics.AddGeneric(UUID.Zero, "WebPages", "Root", rootPage.ToOSD());
                vars.Add("EdittingPageID", -2);
                vars.Add("DisplayEdit", true);
            }
            if (requestParameters.ContainsKey("SelectItem"))
            {
                GridPage page = rootPage.GetPageByLocation(MenuItem);

                vars.Add("PageTitle", page.MenuTitle);
                vars.Add("PageTooltip", page.MenuToolTip);
                vars.Add("PageID", page.MenuID);
                vars.Add("PagePosition", page.MenuPosition);
                vars.Add("PageLocation", page.Location);
                vars.Add("EdittingPageID", page.MenuID);
                vars.Add("RequiresLoginYes", page.LoggedInRequired ? "selected=\"selected\"" : "");
                vars.Add("RequiresLoginNo", !page.LoggedInRequired ? "selected=\"selected\"" : "");
                vars.Add("RequiresLogoutYes", page.LoggedOutRequired ? "selected=\"selected\"" : "");
                vars.Add("RequiresLogoutNo", !page.LoggedOutRequired ? "selected=\"selected\"" : "");
                vars.Add("RequiresAdminYes", page.AdminRequired ? "selected=\"selected\"" : "");
                vars.Add("RequiresAdminNo", !page.AdminRequired ? "selected=\"selected\"" : "");
                vars.Add("RequiresAdminLevel", page.AdminLevelRequired);
                vars.Add("DisplayInMenuYes", page.ShowInMenu ? "selected=\"selected\"" : "");
                vars.Add("DisplayInMenuNo", !page.ShowInMenu ? "selected=\"selected\"" : "");
                vars.Add("DisplayEdit", true);

                pages = new List <Dictionary <string, object> > {
                    new Dictionary <string, object> {
                        { "Value", "Top Level" },
                        { "Name", translator.GetTranslatedString("TopLevel") }, { "PageSelected", "" }
                    }
                };
                GridPage parent = rootPage.GetParent(page);
                foreach (GridPage p in allPages)
                {
                    pages.Add(new Dictionary <string, object> {
                        { "Value", p.Location },
                        { "Name", p.Location }, { "PageSelected", parent.Location == p.Location ?
                                                  "selected=\"selected\"" : "" }
                    });
                }
                vars.Add("ParentPagesList", pages);
            }
            else
            {
                vars.Add("PageTitle", "");
                vars.Add("PageTooltip", "");
                vars.Add("PageID", "");
                vars.Add("PagePosition", "");
                vars.Add("PageLocation", "");
                if (!vars.ContainsKey("EdittingPageID"))
                {
                    vars.Add("EdittingPageID", "");
                }
                vars.Add("RequiresLoginYes", "");
                vars.Add("RequiresLoginNo", "");
                vars.Add("RequiresLogoutYes", "");
                vars.Add("RequiresLogoutNo", "");
                vars.Add("RequiresAdminYes", "");
                vars.Add("RequiresAdminNo", "");
                vars.Add("RequiresAdminLevel", "1");

                pages = new List <Dictionary <string, object> > {
                    new Dictionary <string, object> {
                        { "Value", "Top Level" },
                        { "Name", translator.GetTranslatedString("TopLevel") }, { "PageSelected", "" }
                    }
                };
                foreach (GridPage p in allPages)
                {
                    pages.Add(new Dictionary <string, object> {
                        { "Value", p.Location },
                        { "Name", p.Location }, { "PageSelected", "" }
                    });
                }
                vars.Add("ParentPagesList", pages);
            }
            if (requestParameters.ContainsKey("SaveMenuItem"))
            {
                changed = true;
                string   edittingPageID     = requestParameters["EdittingPageID"].ToString();
                string   PageTitle          = requestParameters["PageTitle"].ToString();
                string   PageTooltip        = requestParameters["PageTooltip"].ToString();
                string   PagePosition       = requestParameters["PagePosition"].ToString();
                string   PageID             = requestParameters["PageID"].ToString();
                string   PageLocation       = requestParameters["PageLocation"].ToString();
                bool     RequiresLogin      = bool.Parse(requestParameters["RequiresLogin"].ToString());
                bool     RequiresLogout     = bool.Parse(requestParameters["RequiresLogout"].ToString());
                bool     RequiresAdmin      = bool.Parse(requestParameters["RequiresAdmin"].ToString());
                bool     DisplayInMenu      = bool.Parse(requestParameters["DisplayInMenu"].ToString());
                string   ParentMenuItem     = requestParameters["ParentMenuItem"].ToString();
                int      RequiredAdminLevel = int.Parse(requestParameters["RequiredAdminLevel"].ToString());
                GridPage page = rootPage.GetPage(edittingPageID);
                bool     add  = page == null;
                if (page == null)
                {
                    page = new GridPage {
                        MenuID = PageLocation, ShowInMenu = true
                    }
                }
                ;

                page.Location           = PageLocation;
                page.MenuID             = PageID;
                page.MenuPosition       = int.Parse(PagePosition);
                page.MenuTitle          = PageTitle;
                page.MenuToolTip        = PageTooltip;
                page.LoggedInRequired   = RequiresLogin;
                page.LoggedOutRequired  = RequiresLogout;
                page.AdminRequired      = RequiresAdmin;
                page.AdminLevelRequired = RequiredAdminLevel;
                page.ShowInMenu         = DisplayInMenu;

                GridPage parent = rootPage.GetPageByLocation(ParentMenuItem);

                if (parent != page)
                {
                    if (!add)
                    {
                        rootPage.RemovePage(edittingPageID, page);
                    }

                    if (parent != null)
                    {
                        parent.Children.Add(page);
                    }
                    else //Top Level
                    {
                        rootPage.Children.Add(page);
                    }
                }
                else
                {
                    error = translator.GetTranslatedString("CannotSetParentToChild");
                }

                generics.AddGeneric(UUID.Zero, "WebPages", "Root", rootPage.ToOSD());
                webInterface.Redirect(httpResponse, "index.html?page=page_manager", filename);
            }

            vars.Add("PageTitleText", translator.GetTranslatedString("PageTitleText"));
            vars.Add("PageTooltipText", translator.GetTranslatedString("PageTooltipText"));
            vars.Add("PagePositionText", translator.GetTranslatedString("PagePositionText"));
            vars.Add("PageIDText", translator.GetTranslatedString("PageIDText"));
            vars.Add("PageLocationText", translator.GetTranslatedString("PageLocationText"));
            vars.Add("SaveMenuItemChanges", translator.GetTranslatedString("SaveMenuItemChanges"));
            vars.Add("RequiresLoginText", translator.GetTranslatedString("RequiresLoginText"));
            vars.Add("RequiresLogoutText", translator.GetTranslatedString("RequiresLogoutText"));
            vars.Add("RequiresAdminText", translator.GetTranslatedString("RequiresAdminText"));
            vars.Add("RequiresAdminLevelText", translator.GetTranslatedString("RequiresAdminLevelText"));
            vars.Add("DisplayInMenu", translator.GetTranslatedString("DisplayInMenu"));
            vars.Add("SelectItem", translator.GetTranslatedString("SelectItem"));
            vars.Add("DeleteItem", translator.GetTranslatedString("DeleteItem"));
            vars.Add("AddItem", translator.GetTranslatedString("AddItem"));
            vars.Add("PageManager", translator.GetTranslatedString("PageManager"));
            vars.Add("ParentText", translator.GetTranslatedString("ParentText"));
            vars.Add("Yes", translator.GetTranslatedString("Yes"));
            vars.Add("No", translator.GetTranslatedString("No"));

            vars.Add("ChangesSavedSuccessfully", changed ? error : "");

            return(vars);
        }
Esempio n. 12
0
        /// <summary>
        /// Register this region with the grid service
        /// </summary>
        /// <param name="scene"></param>
        public void RegisterRegionWithGrid(IScene scene)
        {
            GridRegion region = BuildGridRegion(scene.RegionInfo);

            IGenericsConnector g           = Aurora.DataManager.DataManager.RequestPlugin <IGenericsConnector>();
            GridSessionID      s           = null;
            IGridService       GridService = scene.RequestModuleInterface <IGridService>();

            if (g != null) //Get the sessionID from the database if possible
            {
                s = g.GetGeneric <GridSessionID>(scene.RegionInfo.RegionID, "GridSessionID", "GridSessionID", new GridSessionID());
            }

            if (s == null)
            {
                s = new GridSessionID();
                //Set it from the regionInfo if it knows anything
                s.SessionID = scene.RegionInfo.GridSecureSessionID;
            }

            scene.RequestModuleInterface <ISimulationBase>().EventManager.FireGenericEventHandler("PreRegisterRegion", region);

            //Tell the grid service about us
            string error = GridService.RegisterRegion(region, s.SessionID, out s.SessionID);

            if (error == String.Empty)
            {
                //If it registered ok, we save the sessionID to the database and tlel the neighbor service about it
                scene.RegionInfo.GridSecureSessionID = s.SessionID;

                //Save the new SessionID to the database
                g.AddGeneric(scene.RegionInfo.RegionID, "GridSessionID", "GridSessionID", s.ToOSD());
            }
            else
            {
                //Parse the error and try to do something about it if at all possible
                if (error == "Region location is reserved")
                {
                    m_log.Error("[RegisterRegionWithGrid]: Registration of region with grid failed - The region location you specified is reserved. You must move your region.");
                    int X = 0, Y = 0;
                    int.TryParse(MainConsole.Instance.CmdPrompt("New Region Location X", "1000"), out X);
                    int.TryParse(MainConsole.Instance.CmdPrompt("New Region Location Y", "1000"), out Y);

                    scene.RegionInfo.RegionLocX = X * Constants.RegionSize;
                    scene.RegionInfo.RegionLocY = Y * Constants.RegionSize;

                    IRegionLoader[] loaders = scene.RequestModuleInterfaces <IRegionLoader>();
                    foreach (IRegionLoader loader in loaders)
                    {
                        loader.UpdateRegionInfo(scene.RegionInfo.RegionName, scene.RegionInfo);
                    }
                }
                if (error == "Region overlaps another region")
                {
                    m_log.Error("[RegisterRegionWithGrid]: Registration of region " + scene.RegionInfo.RegionName + " with the grid failed - The region location you specified is already in use. You must move your region.");
                    int X = 0, Y = 0;
                    int.TryParse(MainConsole.Instance.CmdPrompt("New Region Location X", "1000"), out X);
                    int.TryParse(MainConsole.Instance.CmdPrompt("New Region Location Y", "1000"), out Y);

                    scene.RegionInfo.RegionLocX = X * Constants.RegionSize;
                    scene.RegionInfo.RegionLocY = Y * Constants.RegionSize;

                    IRegionLoader[] loaders = scene.RequestModuleInterfaces <IRegionLoader>();
                    foreach (IRegionLoader loader in loaders)
                    {
                        loader.UpdateRegionInfo(scene.RegionInfo.RegionName, scene.RegionInfo);
                    }
                }
                if (error.Contains("Can't move this region"))
                {
                    m_log.Error("[RegisterRegionWithGrid]: Registration of region " + scene.RegionInfo.RegionName + " with the grid failed - You can not move this region. Moving it back to its original position.");
                    //Opensim Grid Servers don't have this functionality.
                    try
                    {
                        string[] position = error.Split(',');

                        scene.RegionInfo.RegionLocX = int.Parse(position[1]) * Constants.RegionSize;
                        scene.RegionInfo.RegionLocY = int.Parse(position[2]) * Constants.RegionSize;

                        IRegionLoader[] loaders = scene.RequestModuleInterfaces <IRegionLoader>();
                        foreach (IRegionLoader loader in loaders)
                        {
                            loader.UpdateRegionInfo(scene.RegionInfo.RegionName, scene.RegionInfo);
                        }
                    }
                    catch (Exception e)
                    {
                        m_log.Error("Unable to move the region back to its original position, is this an opensim server? Please manually move the region back.");
                        throw e;
                    }
                }
                if (error == "Duplicate region name")
                {
                    m_log.Error("[RegisterRegionWithGrid]: Registration of region " + scene.RegionInfo.RegionName + " with the grid failed - The region name you specified is already in use. Please change the name.");
                    string oldRegionName = scene.RegionInfo.RegionName;
                    scene.RegionInfo.RegionName = MainConsole.Instance.CmdPrompt("New Region Name", "");

                    IRegionLoader[] loaders = scene.RequestModuleInterfaces <IRegionLoader>();
                    foreach (IRegionLoader loader in loaders)
                    {
                        loader.UpdateRegionInfo(oldRegionName, scene.RegionInfo);
                    }
                }
                if (error == "Region locked out")
                {
                    m_log.Error("[RegisterRegionWithGrid]: Registration of region " + scene.RegionInfo.RegionName + " with the grid the failed - The region you are attempting to join has been blocked from connecting. Please connect another region.");
                    MainConsole.Instance.CmdPrompt("Press enter when you are ready to exit");
                    Environment.Exit(0);
                }
                if (error == "Error communicating with grid service")
                {
                    m_log.Error("[RegisterRegionWithGrid]: Registration of region " + scene.RegionInfo.RegionName + " with the grid failed - The grid service can not be found! Please make sure that you can connect to the grid server and that the grid server is on.");
                    string input = MainConsole.Instance.CmdPrompt("Press enter when you are ready to proceed, or type cancel to exit");
                    if (input == "cancel")
                    {
                        Environment.Exit(0);
                    }
                }
                if (error == "Wrong Session ID")
                {
                    m_log.Error("[RegisterRegionWithGrid]: Registration of region " + scene.RegionInfo.RegionName + " with the grid failed - Wrong Session ID for this region!");
                    string input = MainConsole.Instance.CmdPrompt("Press enter when you are ready to proceed, or type cancel to exit");
                    if (input == "cancel")
                    {
                        Environment.Exit(0);
                    }
                }
                else
                {
                    m_log.Error("[RegisterRegionWithGrid]: Registration of region " + scene.RegionInfo.RegionName + " with the grid failed - " + error + "!");
                    string input = MainConsole.Instance.CmdPrompt("Press enter when you are ready to proceed, or type cancel to exit");
                    if (input == "cancel")
                    {
                        Environment.Exit(0);
                    }
                }
                RegisterRegionWithGrid(scene);
            }
        }