예제 #1
0
        public void FinishStartup(Scene scene, IConfigSource source, ISimulationBase openSimBase)
        {
            IEstateConnector EstateConnector = DataManager.RequestPlugin <IEstateConnector>();

            if (EstateConnector != null)
            {
                EstateSettings ES;
                if (EstateConnector.LoadEstateSettings(scene.RegionInfo.RegionID, out ES) && ES == null)
                {
                    //It found the estate service, but found no estates for this region, make a new one
                    m_log.Warn("Your region " + scene.RegionInfo.RegionName + " is not part of an estate.");
                    ES = CreateEstateInfo(scene);
                }
                else if (ES != null)
                {
                    //It found the estate service and it found an estate for this region
                }
                else
                {
                    //It could not find the estate service, wait until it can find it
                    m_log.Warn("We could not find the estate service for this sim. Please make sure that your URLs are correct in grid mode.");
                    while (true)
                    {
                        MainConsole.Instance.CmdPrompt("Press enter to try again.");
                        if (EstateConnector.LoadEstateSettings(scene.RegionInfo.RegionID, out ES) && ES == null)
                        {
                            ES = CreateEstateInfo(scene);
                            break;
                        }
                        else if (ES != null)
                        {
                            break;
                        }
                    }
                }
                //Get the password from the database now that we have either created a new estate and saved it, joined a new estate, or just reloaded
                IGenericsConnector g = DataManager.RequestPlugin <IGenericsConnector>();
                EstatePassword     s = null;
                if (g != null)
                {
                    s = g.GetGeneric <EstatePassword>(scene.RegionInfo.RegionID, "EstatePassword", ES.EstateID.ToString(), new EstatePassword());
                }
                if (s != null)
                {
                    ES.EstatePass = s.Password;
                }

                scene.RegionInfo.EstateSettings = ES;
            }
        }
예제 #2
0
 /// <summary>
 /// Region side
 /// </summary>
 /// <param name="message"></param>
 /// <returns></returns>
 protected OSDMap OnMessageReceived(OSDMap message)
 {
     //We need to check and see if this is an AgentStatusChange
     if (message.ContainsKey("Method") && message["Method"] == "EstateUpdated")
     {
         OSDMap innerMessage = (OSDMap)message["Message"];
         //We got a message, deal with it
         uint         estateID = innerMessage["EstateID"].AsUInteger();
         UUID         regionID = innerMessage["RegionID"].AsUUID();
         SceneManager manager  = m_registry.RequestModuleInterface <SceneManager>();
         if (manager != null)
         {
             Scene s = null;
             if (manager.TryGetScene(regionID, out s))
             {
                 if (s.RegionInfo.EstateSettings.EstateID == estateID)
                 {
                     IEstateConnector estateConnector = Aurora.DataManager.DataManager.RequestPlugin <IEstateConnector>();
                     if (estateConnector != null)
                     {
                         EstateSettings es = null;
                         if (estateConnector.LoadEstateSettings(regionID, out es))
                         {
                             s.RegionInfo.EstateSettings = es;
                             m_log.Debug("[EstateProcessor]: Updated estate information.");
                         }
                     }
                 }
             }
         }
     }
     return(null);
 }
예제 #3
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);
        }