/// <summary>
 /// Creates a new region based on the parameters specified.   This will ask the user questions on the console
 /// </summary>
 /// <param name="cmd">0,1,region name, region XML file</param>
 public void AddRegion(string[] cmd)
 {
     try
     {
         if (m_noGUI)
         {
             RegionLoaderFileSystem system = new RegionLoaderFileSystem();
             system.Initialise(m_configSource, m_openSim);
             system.AddRegion(new string[0]);
         }
         else
         {
             bool   done = false, errored = false;
             Thread t = new Thread(delegate()
             {
                 try
                 {
                     RegionManager manager = new RegionManager(false, true, m_openSim);
                     Application.Run(manager);
                     done = true;
                 }
                 catch
                 {
                     errored = true;
                 }
             });
             t.SetApartmentState(ApartmentState.STA);
             t.Start();
             while (!done)
             {
                 if (errored)
                 {
                     throw new Exception();
                 }
             }
             Thread.Sleep(100);
         }
     }
     catch
     {
         //Probably no winforms
         RegionLoaderFileSystem system = new RegionLoaderFileSystem();
         system.Initialise(m_configSource, m_openSim);
         system.AddRegion(new string[0]);
     }
 }
Пример #2
0
        public RegionInfo[] LoadRegions()
        {
            IConfig RegionStartupConfig = m_configSource.Configs["RegionStartup"];

            if (RegionStartupConfig != null)
            {
                string url = RegionStartupConfig.GetString("WebServerURL", String.Empty).Trim();
                if (url == String.Empty)
                {
                    //m_log.Error("[WEBLOADER]: Unable to load webserver URL - URL was empty.");
                    return(null);
                }
                else
                {
                    HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
                    webRequest.Timeout = 30000; //30 Second Timeout

                    m_log.Debug("[WEBLOADER]: Sending Download Request...");
                    HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse();

                    m_log.Info("[WEBLOADER]: Downloading Region Information From Remote Server...");
                    StreamReader reader = new StreamReader(webResponse.GetResponseStream());

                    m_log.Debug("[WEBLOADER]: Done downloading region information from server.");

                    List <RegionInfo> regionInfos = new List <RegionInfo>();

                    IConfigSource source = new IniConfigSource(new Nini.Ini.IniDocument(reader.BaseStream, Nini.Ini.IniFileType.AuroraStyle));

                    int i = 0;
                    foreach (IConfig config in source.Configs)
                    {
                        RegionInfo region = new RegionInfo();
                        //Use this to load the config from the file
                        RegionLoaderFileSystem system = new RegionLoaderFileSystem();
                        system.LoadRegionFromFile("REGION CONFIG #" + (i + 1), "", false, m_configSource, config.Name);
                        regionInfos.Add(region);
                        i++;
                    }
                    return(regionInfos.ToArray());
                }
            }
            return(null);
        }
Пример #3
0
        private void FindOldRegionFiles()
        {
            try
            {
                //Load the file loader and set it up and make sure that we pull any regions from it
                RegionLoaderFileSystem system = new RegionLoaderFileSystem();
                system.Initialise(m_configSource, m_openSim);
                RegionInfo[] regionsToConvert = system.LoadRegions();
                if (regionsToConvert == null)
                {
                    return;
                }

                //Now load all the regions into the database
                IRegionInfoConnector conn = DataManager.RequestPlugin <IRegionInfoConnector>();
                foreach (RegionInfo info in regionsToConvert)
                {
                    conn.UpdateRegionInfo(info);
                }

                //Make sure all the regions got saved
                bool foundAll = true;
                foreach (RegionInfo info in regionsToConvert)
                {
                    if (conn.GetRegionInfo(info.RegionID) == null)
                    {
                        foundAll = false;
                    }
                }
                //Something went really wrong here... so lets not destroy anything
                if (foundAll && regionsToConvert.Length != 0)
                {
                    MessageBox.Show("All region .ini and .xml files have been successfully converted to the new region loader style.");
                }
            }
            catch
            {
            }
        }
Пример #4
0
 public void CreateRegion()
 {
     try
     {
         if (m_noGUI)
         {
             RegionLoaderFileSystem system = new RegionLoaderFileSystem();
             system.Initialise(m_configSource, m_openSim);
             system.AddRegion(new string[0]);
         }
         else
         {
             RegionManager.StartSynchronously(true, RegionManagerPage.CreateRegion,
                                              m_openSim.ConfigSource, m_openSim.ApplicationRegistry.RequestModuleInterface <IRegionManagement>());
         }
     }
     catch
     {
         //Probably no winforms
         RegionLoaderFileSystem system = new RegionLoaderFileSystem();
         system.Initialise(m_configSource, m_openSim);
         system.AddRegion(new string[0]);
     }
 }
        public RegionInfo[] LoadRegions()
        {
            IConfig RegionStartupConfig = m_configSource.Configs["RegionStartup"];
            if (RegionStartupConfig != null)
            {
                string url = RegionStartupConfig.GetString("WebServerURL", String.Empty).Trim();
                if (url == String.Empty)
                {
                    //m_log.Error("[WEBLOADER]: Unable to load webserver URL - URL was empty.");
                    return null;
                }
                else
                {
                    HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
                    webRequest.Timeout = 30000; //30 Second Timeout

                    m_log.Debug("[WEBLOADER]: Sending Download Request...");
                    HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse();

                    m_log.Info("[WEBLOADER]: Downloading Region Information From Remote Server...");
                    StreamReader reader = new StreamReader(webResponse.GetResponseStream());

                    m_log.Debug("[WEBLOADER]: Done downloading region information from server.");

                    List<RegionInfo> regionInfos = new List<RegionInfo>();

                    IConfigSource source = new IniConfigSource(new Nini.Ini.IniDocument(reader.BaseStream, Nini.Ini.IniFileType.AuroraStyle));

                    int i = 0;
                    foreach (IConfig config in source.Configs)
                    {
                        RegionInfo region = new RegionInfo();
                        //Use this to load the config from the file
                        RegionLoaderFileSystem system = new RegionLoaderFileSystem();
                        system.LoadRegionFromFile("REGION CONFIG #" + (i + 1), "", false, m_configSource, config.Name);
                        regionInfos.Add(region);
                        i++;
                    }
                    return regionInfos.ToArray();
                }
            }
            return null;
        }
        public RegionInfo[] LoadRegions()
        {
            //Grab old region files
            if(m_default)
                FindOldRegionFiles();

            IRegionInfoConnector conn = DataManager.RequestPlugin<IRegionInfoConnector>();
            if (conn == null)
                return null;
            RegionInfo[] infos = conn.GetRegionInfos(true);
            if (infos.Length == 0 && m_default)
            {
                //Load up the GUI to make a new region
                try
                {
                    if(m_noGUI)
                    {
                        RegionLoaderFileSystem system = new RegionLoaderFileSystem ();
                        system.Initialise (m_configSource, m_openSim);
                        system.AddRegion (new string[0]);
                    }
                    else
                    {
                        bool done = false, errored = false;
                        Thread t = new Thread(delegate()
                            {
                                try
                                {
                                    RegionManager manager = new RegionManager(true, true, m_openSim);
                                    Application.Run(manager);
                                    done = true;
                                }
                                catch
                                {
                                    errored = true;
                                }
                            });
                        t.SetApartmentState(ApartmentState.STA);
                        t.Start();
                        while (!done)
                            if (errored)
                                throw new Exception();
                            Thread.Sleep(100);
                    }
                }
                catch
                {
                    //Probably no winforms
                    RegionLoaderFileSystem system = new RegionLoaderFileSystem ();
                    system.Initialise (m_configSource, m_openSim);
                    system.AddRegion (new string[0]);
                }
                return LoadRegions();
            }
            return infos.Length == 0 ? null : infos;
        }
        private void FindOldRegionFiles()
        {
            try
            {
                //Load the file loader and set it up and make sure that we pull any regions from it
                RegionLoaderFileSystem system = new RegionLoaderFileSystem();
                system.Initialise(m_configSource, m_openSim);
                RegionInfo[] regionsToConvert = system.InternalLoadRegions(true);
                if (regionsToConvert == null)
                    return;

                bool changed = false;
                //Now load all the regions into the database
                IRegionInfoConnector conn = DataManager.RequestPlugin<IRegionInfoConnector>();
                foreach (RegionInfo info in regionsToConvert)
                {
                    RegionInfo alreadyExists;
                    if ((alreadyExists = conn.GetRegionInfo (info.RegionID)) == null)
                    {
                        changed = true;
                        if (!info.UDPPorts.Contains (info.InternalEndPoint.Port))
                            info.UDPPorts.Add (info.InternalEndPoint.Port);
                        info.Disabled = false;
                        conn.UpdateRegionInfo (info);
                    }
                    else
                    {
                        //Update some atributes...
                        alreadyExists.RegionName = info.RegionName;
                        alreadyExists.RegionLocX = info.RegionLocX;
                        alreadyExists.RegionLocY = info.RegionLocY;
                        alreadyExists.RegionSizeX = info.RegionSizeX;
                        alreadyExists.RegionSizeY = info.RegionSizeY;
                        alreadyExists.Disabled = false;
                        if (!alreadyExists.UDPPorts.Contains (info.InternalEndPoint.Port))
                            alreadyExists.UDPPorts.Add (info.InternalEndPoint.Port);
                        conn.UpdateRegionInfo (alreadyExists);
                    }
                }

                //Make sure all the regions got saved
                bool foundAll = true;
                foreach (RegionInfo info in regionsToConvert)
                {
                    if (conn.GetRegionInfo(info.RegionID) == null)
                        foundAll = false;
                }
                //We found some new ones, they are all loaded
                if (foundAll && regionsToConvert.Length != 0 && changed)
                {
                    try
                    {
                        MessageBox.Show ("All region .ini and .xml files have been successfully converted to the new region loader style.");
                        MessageBox.Show ("To change your region settings, type 'open region manager' on the console, and a GUI will pop up for you to use.");
                        DialogResult t = Utilities.InputBox ("Remove .ini files", "Do you want to remove your old .ini files?");
                        if (t == DialogResult.OK)
                            system.DeleteAllRegionFiles ();
                    }
                    catch
                    {
                        //For people who only have consoles, no winforms
                        MainConsole.Instance.Output ("All region .ini and .xml files have been successfully converted to the new region loader style.");
                        MainConsole.Instance.Output ("To change your region settings, well, you don't have Mono-Winforms installed. Get that, stick with just modifying the .ini files, or get something to modify the region database that isn't a GUI.");
                    }
                }
            }
            catch
            {
            }
        }
 /// <summary>
 /// Creates a new region based on the parameters specified.   This will ask the user questions on the console
 /// </summary>
 /// <param name="cmd">0,1,region name, region XML file</param>
 public void AddRegion(string[] cmd)
 {
     try
     {
         if(m_noGUI)
         {
             RegionLoaderFileSystem system = new RegionLoaderFileSystem ();
             system.Initialise (m_configSource, m_openSim);
             system.AddRegion (new string[0]);
         }
         else
         {
             bool done = false, errored = false;
             Thread t = new Thread(delegate()
             {
                 try
                 {
                     RegionManager manager = new RegionManager(false, true, m_openSim);
                     Application.Run(manager);
                     done = true;
                 }
                 catch
                 {
                     errored = true;
                 }
             });
             t.SetApartmentState(ApartmentState.STA);
             t.Start();
             while (!done)
                 if (errored)
                     throw new Exception();
                 Thread.Sleep(100);
         }
     }
     catch
     {
         //Probably no winforms
         RegionLoaderFileSystem system = new RegionLoaderFileSystem ();
         system.Initialise (m_configSource, m_openSim);
         system.AddRegion (new string[0]);
     }
 }
 /// <summary>
 /// Creates a new region based on the parameters specified.   This will ask the user questions on the console
 /// </summary>
 /// <param name="module"></param>
 /// <param name="cmd">0,1,region name, region XML file</param>
 public void AddRegion(string[] cmd)
 {
     try
     {
         if(m_noGUI)
         {
             RegionLoaderFileSystem system = new RegionLoaderFileSystem ();
             system.Initialise (m_configSource, m_openSim);
             system.AddRegion (new string[0]);
         }
         else
         {
             RegionManager manager = new RegionManager (false, true, m_openSim);
             System.Windows.Forms.Application.Run (manager);
         }
     }
     catch
     {
         //Probably no winforms
         RegionLoaderFileSystem system = new RegionLoaderFileSystem ();
         system.Initialise (m_configSource, m_openSim);
         system.AddRegion (new string[0]);
     }
 }
        public RegionInfo[] LoadRegions()
        {
            //Grab old region files
            if(m_default)
                FindOldRegionFiles();

            IRegionInfoConnector conn = DataManager.RequestPlugin<IRegionInfoConnector>();
            if (conn == null)
                return null;
            RegionInfo[] infos = conn.GetRegionInfos(true);
            if (infos.Length == 0 && m_default)
            {
                //Load up the GUI to make a new region
                try
                {
                    if(m_noGUI)
                    {
                        RegionLoaderFileSystem system = new RegionLoaderFileSystem ();
                        system.Initialise (m_configSource, m_openSim);
                        system.AddRegion (new string[0]);
                    }
                    else
                    {
                        RegionManager manager = new RegionManager (true, false, m_openSim);
                        System.Windows.Forms.Application.Run (manager);
                    }
                }
                catch
                {
                    //Probably no winforms
                    RegionLoaderFileSystem system = new RegionLoaderFileSystem ();
                    system.Initialise (m_configSource, m_openSim);
                    system.AddRegion (new string[0]);
                }
                return LoadRegions();
            }
            else if (infos.Length == 0)
                return null;
            else
                return infos;
        }
 /// <summary>
 /// Creates a new region based on the parameters specified.   This will ask the user questions on the console
 /// </summary>
 /// <param name="cmd">0,1,region name, region XML file</param>
 public void AddRegion(string[] cmd)
 {
     try
     {
         if(m_noGUI)
         {
             RegionLoaderFileSystem system = new RegionLoaderFileSystem ();
             system.Initialise (m_configSource, m_openSim);
             system.AddRegion (new string[0]);
         }
         else
         {
             RegionManager.StartSynchronously(true, true, m_openSim.ConfigSource, m_openSim.ApplicationRegistry.RequestModuleInterface<IRegionManagement>());
         }
     }
     catch
     {
         //Probably no winforms
         RegionLoaderFileSystem system = new RegionLoaderFileSystem ();
         system.Initialise (m_configSource, m_openSim);
         system.AddRegion (new string[0]);
     }
 }
        private void FindOldRegionFiles()
        {
            try
            {
                //Load the file loader and set it up and make sure that we pull any regions from it
                RegionLoaderFileSystem system = new RegionLoaderFileSystem();
                system.Initialise(m_configSource, m_openSim);
                RegionInfo[] regionsToConvert = system.InternalLoadRegions(true);
                if (regionsToConvert == null)
                {
                    return;
                }

                bool changed = false;
                //Now load all the regions into the database
                IRegionInfoConnector conn = DataManager.RequestPlugin <IRegionInfoConnector>();
                foreach (RegionInfo info in regionsToConvert)
                {
                    RegionInfo alreadyExists;
                    if ((alreadyExists = conn.GetRegionInfo(info.RegionID)) == null)
                    {
                        changed = true;
                        if (!info.UDPPorts.Contains(info.InternalEndPoint.Port))
                        {
                            info.UDPPorts.Add(info.InternalEndPoint.Port);
                        }
                        info.Disabled = false;
                        conn.UpdateRegionInfo(info);
                    }
                    else
                    {
                        //Update some atributes...
                        alreadyExists.RegionName  = info.RegionName;
                        alreadyExists.RegionLocX  = info.RegionLocX;
                        alreadyExists.RegionLocY  = info.RegionLocY;
                        alreadyExists.RegionSizeX = info.RegionSizeX;
                        alreadyExists.RegionSizeY = info.RegionSizeY;
                        alreadyExists.Disabled    = false;
                        if (!alreadyExists.UDPPorts.Contains(info.InternalEndPoint.Port))
                        {
                            alreadyExists.UDPPorts.Add(info.InternalEndPoint.Port);
                        }
                        conn.UpdateRegionInfo(alreadyExists);
                    }
                }

                //Make sure all the regions got saved
                bool foundAll = true;
                foreach (RegionInfo info in regionsToConvert)
                {
                    if (conn.GetRegionInfo(info.RegionID) == null)
                    {
                        foundAll = false;
                    }
                }
                //We found some new ones, they are all loaded
                if (foundAll && regionsToConvert.Length != 0 && changed)
                {
                    try
                    {
                        MessageBox.Show("All region .ini and .xml files have been successfully converted to the new region loader style.");
                        MessageBox.Show("To change your region settings, type 'open region manager' on the console, and a GUI will pop up for you to use.");
                        DialogResult t = Utilities.InputBox("Remove .ini files", "Do you want to remove your old .ini files?");
                        if (t == DialogResult.OK)
                        {
                            system.DeleteAllRegionFiles();
                        }
                    }
                    catch
                    {
                        //For people who only have consoles, no winforms
                        MainConsole.Instance.Output("All region .ini and .xml files have been successfully converted to the new region loader style.");
                        MainConsole.Instance.Output("To change your region settings, well, you don't have Mono-Winforms installed. Get that, stick with just modifying the .ini files, or get something to modify the region database that isn't a GUI.");
                    }
                }
            }
            catch
            {
            }
        }
        public RegionInfo[] LoadRegions()
        {
            //Grab old region files
            if (m_default)
            {
                FindOldRegionFiles();
            }

            IRegionInfoConnector conn = DataManager.RequestPlugin <IRegionInfoConnector>();

            if (conn == null)
            {
                return(null);
            }
            RegionInfo[] infos = conn.GetRegionInfos(true);
            if (infos.Length == 0 && m_default)
            {
                //Load up the GUI to make a new region
                try
                {
                    if (m_noGUI)
                    {
                        RegionLoaderFileSystem system = new RegionLoaderFileSystem();
                        system.Initialise(m_configSource, m_openSim);
                        system.AddRegion(new string[0]);
                    }
                    else
                    {
                        bool   done = false, errored = false;
                        Thread t = new Thread(delegate()
                        {
                            try
                            {
                                RegionManager manager = new RegionManager(true, true, m_openSim);
                                Application.Run(manager);
                                done = true;
                            }
                            catch
                            {
                                errored = true;
                            }
                        });
                        t.SetApartmentState(ApartmentState.STA);
                        t.Start();
                        while (!done)
                        {
                            if (errored)
                            {
                                throw new Exception();
                            }
                        }
                        Thread.Sleep(100);
                    }
                }
                catch
                {
                    //Probably no winforms
                    RegionLoaderFileSystem system = new RegionLoaderFileSystem();
                    system.Initialise(m_configSource, m_openSim);
                    system.AddRegion(new string[0]);
                }
                return(LoadRegions());
            }
            return(infos.Length == 0 ? null : infos);
        }
        private void FindOldRegionFiles()
        {
            try
            {
                //Load the file loader and set it up and make sure that we pull any regions from it
                RegionLoaderFileSystem system = new RegionLoaderFileSystem();
                system.Initialise(m_configSource, m_openSim);
                RegionInfo[] regionsToConvert = system.LoadRegions();
                if (regionsToConvert == null)
                    return;

                //Now load all the regions into the database
                IRegionInfoConnector conn = DataManager.RequestPlugin<IRegionInfoConnector>();
                foreach (RegionInfo info in regionsToConvert)
                {
                    conn.UpdateRegionInfo(info);
                }

                //Make sure all the regions got saved
                bool foundAll = true;
                foreach (RegionInfo info in regionsToConvert)
                {
                    if (conn.GetRegionInfo(info.RegionID) == null)
                        foundAll = false;
                }
                //Something went really wrong here... so lets not destroy anything
                if (foundAll && regionsToConvert.Length != 0)
                {
                    MessageBox.Show("All region .ini and .xml files have been successfully converted to the new region loader style.");
                }
            }
            catch
            {
            }
        }