Example #1
0
        //creates a config file in the specified base path
        public Config(string base_path)
        {
            if (!Directory.Exists (base_path))
                Directory.CreateDirectory (base_path);

            string path = System.IO.Path.Combine (base_path, "fuse_settings.ini");

            if (!File.Exists (path))
                File.WriteAllText (path, "");

            source =  new IniConfigSource (path);

            bool addWindow = true;
            bool addMediaControls = true;

            foreach (IConfig config in source.Configs)
            {
                if (config.Name == "Window")
                    addWindow = false;
                else if (config.Name == "Media Controls")
                    addMediaControls = false;
            }

            if (addWindow)
                source.AddConfig ("Window");
            if (addMediaControls)
                source.AddConfig ("Media Controls");
        }
        private void AddScriptingConfig(IConfigSource config, XEngine.XEngine xEngine, List<object> modules)
        {
            IConfig startupConfig = config.AddConfig("Startup");
            startupConfig.Set("DefaultScriptEngine", "XEngine");

            IConfig xEngineConfig = config.AddConfig("XEngine");
            xEngineConfig.Set("Enabled", "true");
            xEngineConfig.Set("StartDelay", "0");

            // These tests will not run with AppDomainLoading = true, at least on mono.  For unknown reasons, the call
            // to AssemblyResolver.OnAssemblyResolve fails.
            xEngineConfig.Set("AppDomainLoading", "false");

            modules.Add(xEngine);
        }
        private void AddCommonConfig(IConfigSource config, List<object> modules)
        {
            config.AddConfig("Modules");
            config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule");

            AttachmentsModule attMod = new AttachmentsModule();
            attMod.DebugLevel = 1;
            modules.Add(attMod);
            modules.Add(new BasicInventoryAccessModule());
        }
Example #4
0
        //creates a config file in the specified base path
        public Config(string base_path)
        {
            if (!Directory.Exists (base_path))
                Directory.CreateDirectory (base_path);

            string path = System.IO.Path.Combine (base_path, "library_settings.ini");

            if (!File.Exists (path))
                File.WriteAllText (path, "");

            source =  new IniConfigSource (path);

            bool addWindow = true;
            bool addOptions = true;
            bool addColumns = true;
            bool addSorting = true;
            bool addScrobbler = true;

            foreach (IConfig config in source.Configs)
            {
                if (config.Name == "Window")
                    addWindow = false;
                else if (config.Name == "Options")
                    addOptions = false;
                else if (config.Name == "Tree Columns")
                    addColumns = false;
                else if (config.Name == "Sorting")
                    addSorting = false;
                else if (config.Name == "AudioScrobbler")
                    addScrobbler = false;
            }

            if (addWindow)
                source.AddConfig ("Window");
            if (addOptions)
                source.AddConfig ("Options");
            if (addColumns)
                source.AddConfig ("Tree Columns");
            if (addSorting)
                source.AddConfig ("Sorting");
            if (addScrobbler)
                source.AddConfig ("AudioScrobbler");
        }
Example #5
0
 /// <summary>
 /// update the node
 /// </summary>
 /// <param name="node">name of node</param>
 public void Update(string node)
 {
     source = new IniConfigSource(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory,"user.ini"));
     config = source.Configs[node];
     if (config == null)
     {
         source.AddConfig(node);
         config = source.Configs[node];
     }
     RemoveKeys();
 }
Example #6
0
        private void WriteNiniConfig(IConfigSource source)
        {
            IConfig config = source.Configs[RegionName];

            if (config != null)
                source.Configs.Remove(config);

            config = source.AddConfig(RegionName);

            config.Set("RegionUUID", RegionID.ToString());

            string location = String.Format("{0},{1}", m_regionLocX, m_regionLocY);
            config.Set("Location", location);

            config.Set("InternalAddress", m_internalEndPoint.Address.ToString());
            config.Set("InternalPort", m_internalEndPoint.Port);

            config.Set("AllowAlternatePorts", m_allow_alternate_ports.ToString());

            config.Set("ExternalHostName", m_externalHostName);

            if (m_nonphysPrimMax != 0)
                config.Set("NonphysicalPrimMax", m_nonphysPrimMax);
            if (m_physPrimMax != 0)
                config.Set("PhysicalPrimMax", m_physPrimMax);
            config.Set("ClampPrimSize", m_clampPrimSize.ToString());

            if (m_objectCapacity != 0)
                config.Set("MaxPrims", m_objectCapacity);

            if (m_agentCapacity != 0)
                config.Set("MaxAgents", m_agentCapacity);

            if (ScopeID != UUID.Zero)
                config.Set("ScopeID", ScopeID.ToString());

            if (RegionType != String.Empty)
                config.Set("RegionType", RegionType);
        }
Example #7
0
        private void ReadNiniConfig(IConfigSource source, string name)
        {
//            bool creatingNew = false;

            if (source.Configs.Count == 0)
            {
                MainConsole.Instance.Output("=====================================\n");
                MainConsole.Instance.Output("We are now going to ask a couple of questions about your region.\n");
                MainConsole.Instance.Output("You can press 'enter' without typing anything to use the default\n");
                MainConsole.Instance.Output("the default is displayed between [ ] brackets.\n");
                MainConsole.Instance.Output("=====================================\n");

                if (name == String.Empty)
                    name = MainConsole.Instance.CmdPrompt("New region name", name);
                if (name == String.Empty)
                    throw new Exception("Cannot interactively create region with no name");

                source.AddConfig(name);

//                creatingNew = true;
            }

            if (name == String.Empty)
                name = source.Configs[0].Name;

            if (source.Configs[name] == null)
            {
                source.AddConfig(name);

//                creatingNew = true;
            }

            IConfig config = source.Configs[name];

            // UUID
            //
            string regionUUID = config.GetString("RegionUUID", string.Empty);

            if (regionUUID == String.Empty)
            {
                UUID newID = UUID.Random();

                regionUUID = MainConsole.Instance.CmdPrompt("Region UUID", newID.ToString());
                config.Set("RegionUUID", regionUUID);
            }

            RegionID = new UUID(regionUUID);
            originRegionID = RegionID; // What IS this?!

            RegionName = name;
            string location = config.GetString("Location", String.Empty);

            if (location == String.Empty)
            {
                location = MainConsole.Instance.CmdPrompt("Region Location", "1000,1000");
                config.Set("Location", location);
            }

            string[] locationElements = location.Split(new char[] {','});

            m_regionLocX = Convert.ToUInt32(locationElements[0]);
            m_regionLocY = Convert.ToUInt32(locationElements[1]);

            // Internal IP
            IPAddress address;

            if (config.Contains("InternalAddress"))
            {
                address = IPAddress.Parse(config.GetString("InternalAddress", String.Empty));
            }
            else
            {
                address = IPAddress.Parse(MainConsole.Instance.CmdPrompt("Internal IP address", "0.0.0.0"));
                config.Set("InternalAddress", address.ToString());
            }

            int port;

            if (config.Contains("InternalPort"))
            {
                port = config.GetInt("InternalPort", 9000);
            }
            else
            {
                port = Convert.ToInt32(MainConsole.Instance.CmdPrompt("Internal port", "9000"));
                config.Set("InternalPort", port);
            }

            m_internalEndPoint = new IPEndPoint(address, port);

            if (config.Contains("AllowAlternatePorts"))
            {
                m_allow_alternate_ports = config.GetBoolean("AllowAlternatePorts", true);
            }
            else
            {
                m_allow_alternate_ports = Convert.ToBoolean(MainConsole.Instance.CmdPrompt("Allow alternate ports", "False"));

                config.Set("AllowAlternatePorts", m_allow_alternate_ports.ToString());
            }

            // External IP
            //
            string externalName;

            if (config.Contains("ExternalHostName"))
            {
                externalName = config.GetString("ExternalHostName", "SYSTEMIP");
            }
            else
            {
                externalName = MainConsole.Instance.CmdPrompt("External host name", "SYSTEMIP");
                config.Set("ExternalHostName", externalName);
            }

            if (externalName == "SYSTEMIP")
            {
                m_externalHostName = Util.GetLocalHost().ToString();
                m_log.InfoFormat(
                    "[REGIONINFO]: Resolving SYSTEMIP to {0} for external hostname of region {1}",
                    m_externalHostName, name);
            }
            else
            {
                m_externalHostName = externalName;
            }

            m_regionType = config.GetString("RegionType", String.Empty);

            // Prim stuff
            //
            m_nonphysPrimMax = config.GetInt("NonphysicalPrimMax", 256);

            m_physPrimMax = config.GetInt("PhysicalPrimMax", 10);

            m_clampPrimSize = config.GetBoolean("ClampPrimSize", false);

            m_objectCapacity = config.GetInt("MaxPrims", 15000);

            m_agentCapacity = config.GetInt("MaxAgents", 100);


            // Multi-tenancy
            //
            ScopeID = new UUID(config.GetString("ScopeID", UUID.Zero.ToString()));
        }
        //Returns true if the source should be updated. Returns false if it does not.
        public bool ReadNiniConfig(RegionInfo region, IConfigSource source, string name)
        {
            //            bool creatingNew = false;

            if (name == String.Empty || source.Configs.Count == 0)
            {
                MainConsole.Instance.Output("=====================================\n");
                MainConsole.Instance.Output("We are now going to ask a couple of questions about your region.\n");
                MainConsole.Instance.Output("You can press 'enter' without typing anything to use the default\n");
                MainConsole.Instance.Output("the default is displayed between [ ] brackets.\n");
                MainConsole.Instance.Output("=====================================\n");
            }

            bool NeedsUpdate = false;
            if (name == String.Empty)
                name = MainConsole.Instance.CmdPrompt("New region name", name);
            if (name == String.Empty)
                throw new Exception("Cannot interactively create region with no name");

            if (source.Configs.Count == 0)
            {
                source.AddConfig(name);

                //                creatingNew = true;
                NeedsUpdate = true;
            }

            if (source.Configs[name] == null)
            {
                source.AddConfig(name);
                NeedsUpdate = true;
                //                creatingNew = true;
            }

            IConfig config = source.Configs[name];

            // UUID
            //
            string regionUUID = config.GetString("RegionUUID", string.Empty);

            if (regionUUID == String.Empty)
            {
                NeedsUpdate = true;
                UUID newID = UUID.Random();

                regionUUID = MainConsole.Instance.CmdPrompt("Region UUID for region " + name, newID.ToString());
                config.Set("RegionUUID", regionUUID);
            }

            region.RegionID = new UUID(regionUUID);

            region.RegionName = name;
            string location = config.GetString("Location", String.Empty);

            if (location == String.Empty)
            {
                NeedsUpdate = true;
                location = MainConsole.Instance.CmdPrompt("Region Location for region " + name, "1000,1000");
                config.Set("Location", location);
            }

            string[] locationElements = location.Split(new char[] { ',' });

            region.RegionLocX = Convert.ToInt32(locationElements[0]) * Constants.RegionSize;
            region.RegionLocY = Convert.ToInt32(locationElements[1]) * Constants.RegionSize;

            int regionSizeX = config.GetInt("RegionSizeX", 0);
            if (regionSizeX == 0 || ((region.RegionSizeX % Constants.MinRegionSize) != 0))
            {
                NeedsUpdate = true;
                while (true)
                {
                    if (int.TryParse(MainConsole.Instance.CmdPrompt("Region X Size for region " + name, "256"), out regionSizeX))
                        break;
                }
                config.Set("RegionSizeX", regionSizeX);
            }
            region.RegionSizeX = Convert.ToInt32(regionSizeX);

            int regionSizeY = config.GetInt("RegionSizeY", 0);
            if (regionSizeY == 0 || ((region.RegionSizeY % Constants.MinRegionSize) != 0))
            {
                NeedsUpdate = true;
                while(true)
                {
                    if(int.TryParse(MainConsole.Instance.CmdPrompt("Region Y Size for region " + name, "256"), out regionSizeY))
                        break;
                }
                config.Set("RegionSizeY", regionSizeY);
            }
            region.RegionSizeY = regionSizeY;

            int regionSizeZ = config.GetInt("RegionSizeZ", 1024);
            //if (regionSizeZ == String.Empty)
            //{
            //    NeedsUpdate = true;
            //    regionSizeZ = MainConsole.Instance.CmdPrompt("Region Z Size for region " + name, "1024");
            //    config.Set("RegionSizeZ", regionSizeZ);
            //}
            region.RegionSizeZ = regionSizeZ;

            // Internal IP
            IPAddress address;

            if (config.Contains("InternalAddress"))
            {
                address = IPAddress.Parse(config.GetString("InternalAddress", String.Empty));
            }
            else
            {
                NeedsUpdate = true;
                address = IPAddress.Parse(MainConsole.Instance.CmdPrompt("Internal IP address for region " + name, "0.0.0.0"));
                config.Set("InternalAddress", address.ToString());
            }

            int port;

            if (config.Contains("InternalPort"))
            {
                port = config.GetInt("InternalPort", 9000);
            }
            else
            {
                NeedsUpdate = true;
                port = Convert.ToInt32(MainConsole.Instance.CmdPrompt("Internal port for region " + name, "9000"));
                config.Set("InternalPort", port);
            }

            region.InternalEndPoint = new IPEndPoint(address, port);

            if (config.Contains("AllowAlternatePorts"))
            {
                region.m_allow_alternate_ports = config.GetBoolean("AllowAlternatePorts", true);
            }
            else
            {
                NeedsUpdate = true;
                region.m_allow_alternate_ports = Convert.ToBoolean(MainConsole.Instance.CmdPrompt("Allow alternate ports", "False"));

                config.Set("AllowAlternatePorts", region.m_allow_alternate_ports.ToString());
            }

            // External IP
            //
            string externalName;
            //Let's know our external IP (by Enrico Nirvana)
            WebClient client = new WebClient();
            string myIP = client.DownloadString("http://www.whatismyip.com/automation/n09230945.asp");
            MainConsole.Instance.Output("Your External ip is:" + myIP);
            //ended here (by Enrico Nirvana)
            if (config.Contains("ExternalHostName"))
            {
                externalName = config.GetString("ExternalHostName", "SYSTEMIP");
            }
            else
            {
                NeedsUpdate = true;
                externalName = MainConsole.Instance.CmdPrompt("External host name for region " + name, "SYSTEMIP");
                config.Set("ExternalHostName", externalName);
            }

            if (externalName == "SYSTEMIP")
            {
                region.ExternalHostName = Util.GetLocalHost().ToString();
                m_log.InfoFormat(
                    "[REGIONINFO]: Resolving SYSTEMIP to {0} for external hostname of region {1}",
                    region.ExternalHostName, name);
            }
            else
            {
                region.ExternalHostName = Util.ResolveEndPoint(externalName, port).Address.ToString();
            }

            region.RegionType = config.GetString("RegionType", region.RegionType);

            if (region.RegionType == String.Empty)
            {
                NeedsUpdate = true;
                region.RegionType = MainConsole.Instance.CmdPrompt("Region Type for region " + name, "Mainland");
                config.Set("RegionType", region.RegionType);
            }

            region.AllowPhysicalPrims = config.GetBoolean("AllowPhysicalPrims", region.AllowPhysicalPrims);

            region.AllowScriptCrossing = config.GetBoolean("AllowScriptCrossing", region.AllowScriptCrossing);

            region.TrustBinariesFromForeignSims = config.GetBoolean("TrustBinariesFromForeignSims", region.TrustBinariesFromForeignSims);

            region.SeeIntoThisSimFromNeighbor = config.GetBoolean("SeeIntoThisSimFromNeighbor", region.SeeIntoThisSimFromNeighbor);

            region.ObjectCapacity = config.GetInt("MaxPrims", region.ObjectCapacity);


            // Multi-tenancy
            //
            region.ScopeID = new UUID(config.GetString("ScopeID", region.ScopeID.ToString()));

            //Do this last so that we can save the password immediately if it doesn't exist
            UUID password = region.Password; //Save the pass as this TryParse will wipe it out
            if (!UUID.TryParse(config.GetString("NeighborPassword", ""), out region.Password))
            {
                region.Password = password;
                config.Set("NeighborPassword", password);
                region.WriteNiniConfig(source);
            }

            return NeedsUpdate;
        }
Example #9
0
        private void ReadNiniConfig(IConfigSource source, string name)
        {
//            bool creatingNew = false;

            if (source.Configs.Count == 0)
            {
                MainConsole.Instance.Output("=====================================\n");
                MainConsole.Instance.Output("We are now going to ask a couple of questions about your region.\n");
                MainConsole.Instance.Output("You can press 'enter' without typing anything to use the default\n");
                MainConsole.Instance.Output("the default is displayed between [ ] brackets.\n");
                MainConsole.Instance.Output("=====================================\n");

                if (name == String.Empty)
                {
                    while (name.Trim() == string.Empty)
                    {
                        name = MainConsole.Instance.CmdPrompt("New region name", name);
                        if (name.Trim() == string.Empty)
                        {
                            MainConsole.Instance.Output("Cannot interactively create region with no name");
                        }
                    }
                }

                source.AddConfig(name);

//                creatingNew = true;
            }

            if (name == String.Empty)
                name = source.Configs[0].Name;

            if (source.Configs[name] == null)
            {
                source.AddConfig(name);
            }

            RegionName = name;
            IConfig config = source.Configs[name];

            // Track all of the keys in this config and remove as they are processed
            // The remaining keys will be added to generic key-value storage for
            // whoever might need it
            HashSet<String> allKeys = new HashSet<String>();
            foreach (string s in config.GetKeys())
            {
                allKeys.Add(s);
            }

            // RegionUUID
            //
            allKeys.Remove("RegionUUID");
            string regionUUID = config.GetString("RegionUUID", string.Empty);
            if (!UUID.TryParse(regionUUID.Trim(), out RegionID))
            {
                UUID newID = UUID.Random();
                while (RegionID == UUID.Zero)
                {
                    regionUUID = MainConsole.Instance.CmdPrompt("RegionUUID", newID.ToString());
                    if (!UUID.TryParse(regionUUID.Trim(), out RegionID))
                    {
                        MainConsole.Instance.Output("RegionUUID must be a valid UUID");
                    }
                }
                config.Set("RegionUUID", regionUUID);
            }

            originRegionID = RegionID; // What IS this?! (Needed for RegionCombinerModule?)

            // Location
            //
            allKeys.Remove("Location");
            string location = config.GetString("Location", String.Empty);
            if (location == String.Empty)
            {
                location = MainConsole.Instance.CmdPrompt("Region Location", "1000,1000");
                config.Set("Location", location);
            }

            string[] locationElements = location.Split(new char[] {','});

            RegionLocX = Convert.ToUInt32(locationElements[0]);
            RegionLocY = Convert.ToUInt32(locationElements[1]);

            // Region size
            // Default to legacy region size if not specified.
            allKeys.Remove("SizeX");
            string configSizeX = config.GetString("SizeX", Constants.RegionSize.ToString());
            config.Set("SizeX", configSizeX);
            RegionSizeX = Convert.ToUInt32(configSizeX);
            allKeys.Remove("SizeY");
            string configSizeY = config.GetString("SizeY", Constants.RegionSize.ToString());
            config.Set("SizeY", configSizeX);
            RegionSizeY = Convert.ToUInt32(configSizeY);
            allKeys.Remove("SizeZ");
            string configSizeZ = config.GetString("SizeZ", Constants.RegionHeight.ToString());
            config.Set("SizeZ", configSizeX);
            RegionSizeZ = Convert.ToUInt32(configSizeZ);

            DoRegionSizeSanityChecks();

            // InternalAddress
            //
            IPAddress address;
            allKeys.Remove("InternalAddress");
            if (config.Contains("InternalAddress"))
            {
                address = IPAddress.Parse(config.GetString("InternalAddress", String.Empty));
            }
            else
            {
                address = IPAddress.Parse(MainConsole.Instance.CmdPrompt("Internal IP address", "0.0.0.0"));
                config.Set("InternalAddress", address.ToString());
            }

            // InternalPort
            //
            int port;
            allKeys.Remove("InternalPort");
            if (config.Contains("InternalPort"))
            {
                port = config.GetInt("InternalPort", 9000);
            }
            else
            {
                port = Convert.ToInt32(MainConsole.Instance.CmdPrompt("Internal port", "9000"));
                config.Set("InternalPort", port);
            }
            m_internalEndPoint = new IPEndPoint(address, port);

            // AllowAlternatePorts
            //
            allKeys.Remove("AllowAlternatePorts");
            if (config.Contains("AllowAlternatePorts"))
            {
                m_allow_alternate_ports = config.GetBoolean("AllowAlternatePorts", true);
            }
            else
            {
                m_allow_alternate_ports = Convert.ToBoolean(MainConsole.Instance.CmdPrompt("Allow alternate ports", "False"));

                config.Set("AllowAlternatePorts", m_allow_alternate_ports.ToString());
            }

            // ExternalHostName
            //
            allKeys.Remove("ExternalHostName");
            string externalName;
            if (config.Contains("ExternalHostName"))
            {
                externalName = config.GetString("ExternalHostName", "SYSTEMIP");
            }
            else
            {
                externalName = MainConsole.Instance.CmdPrompt("External host name", "SYSTEMIP");
                config.Set("ExternalHostName", externalName);
            }
            if (externalName == "SYSTEMIP")
            {
                m_externalHostName = Util.GetLocalHost().ToString();
                m_log.InfoFormat(
                    "[REGIONINFO]: Resolving SYSTEMIP to {0} for external hostname of region {1}",
                    m_externalHostName, name);
            }
            else
            {
                m_externalHostName = externalName;
            }

            // RegionType
            m_regionType = config.GetString("RegionType", String.Empty);
            allKeys.Remove("RegionType");

            #region Prim and map stuff

            m_nonphysPrimMin = config.GetFloat("NonPhysicalPrimMin", 0);
            allKeys.Remove("NonPhysicalPrimMin");

            m_nonphysPrimMax = config.GetInt("NonPhysicalPrimMax", 0);
            allKeys.Remove("NonPhysicalPrimMax");

            m_physPrimMin = config.GetFloat("PhysicalPrimMin", 0);
            allKeys.Remove("PhysicalPrimMin");

            m_physPrimMax = config.GetInt("PhysicalPrimMax", 0);
            allKeys.Remove("PhysicalPrimMax");
            
            m_clampPrimSize = config.GetBoolean("ClampPrimSize", false);
            allKeys.Remove("ClampPrimSize");
            
            m_objectCapacity = config.GetInt("MaxPrims", 15000);
            allKeys.Remove("MaxPrims");

            m_linksetCapacity = config.GetInt("LinksetPrims", 0);
            allKeys.Remove("LinksetPrims");

            allKeys.Remove("MaptileStaticUUID");
            string mapTileStaticUUID = config.GetString("MaptileStaticUUID", UUID.Zero.ToString());
            if (UUID.TryParse(mapTileStaticUUID.Trim(), out m_maptileStaticUUID))
            {
                config.Set("MaptileStaticUUID", m_maptileStaticUUID.ToString()); 
            }
            
            #endregion

            m_agentCapacity = config.GetInt("MaxAgents", 100);
            allKeys.Remove("MaxAgents");

            // Multi-tenancy
            //
            ScopeID = new UUID(config.GetString("ScopeID", UUID.Zero.ToString()));
            allKeys.Remove("ScopeID");

            foreach (String s in allKeys)
            {
                SetOtherSetting(s, config.GetString(s));
            }
        }
Example #10
0
		public FormMain()
		{
			// Set the resize event handler.
			resizeEventHandler = new EventHandler(FormMain_Resize);
			Resize += resizeEventHandler;

			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			// Get the window handle.
			Capture = true;
			hwnd = OpenNETCF.Win32.Win32Window.GetCapture();
			Capture = false;

			// Add a message filter.
			ApplicationEx.AddMessageFilter(this);

			// Load the configuration.
			executablePath = ApplicationEx.StartupPath;
			extensionPath = Path.Combine(executablePath, "Extensions");
			string iniFileName = Path.Combine(executablePath, "GPSProxy.ini");
			if (! File.Exists(iniFileName))
			{
				try
				{
					File.Copy(Path.Combine(executablePath, "GPSProxy.ini.default"), iniFileName, false);
				}
				catch
				{
				}
			}
			if (! File.Exists(iniFileName))
				using (File.Create(iniFileName))
				{
				}
			configSource = new IniConfigSource(iniFileName);
			configSource.Alias.AddAlias("On", true);
			configSource.Alias.AddAlias("Off", false);
			configSource.Alias.AddAlias("True", true);
			configSource.Alias.AddAlias("False", false);
			if (configSource.Configs["Settings"] == null)
				configSource.AddConfig("Settings");

			configSettings = configSource.Configs["Settings"];
			settings["autoStart"].Value = configSettings.GetBoolean("Start Proxy Automatically on Launch", (bool)settings["autoStart"].Value);
			settings["runExternalApp"].Value = configSettings.GetBoolean("Run External App after Proxy Startup", (bool)settings["runExternalApp"].Value);
			settings["externalApp"].Value = configSettings.GetString("External Application", (string)settings["externalApp"].Value);
			settings["autoReconnect"].Value = configSettings.GetBoolean("Reconnect after Power-on", (bool)settings["autoReconnect"].Value);
			settings["reconnectDelay"].Value = configSettings.GetInt("Power-on Reconnect Delay", (int)settings["reconnectDelay"].Value);

			// Create the main and page menu panels.
			mainMenuPanel = new ScrollablePanel();
			mainMenuPanel.Visible = false;
			Controls.Add(mainMenuPanel);
			mainMenuPanel.Size = pluginPanel.ClientSize;
			mainMenuPanel.BringToFront();

			pageMenuPanel = new ScrollablePanel();
			pageMenuPanel.Visible = false;
			Controls.Add(pageMenuPanel);
			pageMenuPanel.Size = pluginPanel.ClientSize;
			pageMenuPanel.BringToFront();

			// Add the main menu buttons.
			AboutButton = AddMenuButton(mainMenuPanel, "About...",
				new EventHandler(AboutButton_Click));
			SettingsButton = AddMenuButton(mainMenuPanel, "Settings...",
				new EventHandler(SettingsButton_Click), true);
			ExtensionsButton = AddMenuButton(mainMenuPanel, "Extensions...",
				new EventHandler(ExtensionsButton_Click));
			VirtualComPortsButton = AddMenuButton(mainMenuPanel, "Virtual COM Ports...",
				new EventHandler(VirtualComPortsButton_Click));
			ExitButton = AddMenuButton(mainMenuPanel, "Exit",
				new EventHandler(ExitButton_Click), true);

			// Load the extension DLLs.
			LoadExtensions();

			// Activate extensions according to the configuration file.
			ActivateExtensions();

			// NOTE: do not attempt to show an message boxes before this point, as this triggers
			// other form events that expect the activeExtensions array to have been created.

			// Load the virtual COM port drivers.
			virtualComPortRootKey = Registry.LocalMachine.CreateSubKey(@"Drivers\GPSProxyVirtualCOMPorts");
			if (virtualComPortRootKey == null)
			{
				MessageBox.Show(@"Unable to open/create registry key: " + virtualComPortRootKey.Name,
					"Error", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
			}
			else
			{
				LoadVirtualComPortDrivers();
			}

			// Create and populate the extensions dialog.
			extensionsDialog = new FormExtensions();
			extensionsDialog.ComboBoxProvider.SelectedIndexChanged += new EventHandler(ComboBoxProvider_SelectedIndexChanged);
			extensionsDialog.ListBoxExtensions.SelectedIndexChanged += new EventHandler(ListBoxExtensions_SelectedIndexChanged);
			extensionsDialog.ButtonConfigureProvider.Click += new EventHandler(ButtonConfigureProvider_Click);
			extensionsDialog.ButtonAddExtension.Click += new EventHandler(ButtonAddExtension_Click);
			extensionsDialog.ButtonRemoveExtension.Click += new EventHandler(ButtonRemoveExtension_Click);
			extensionsDialog.ButtonConfigureExtension.Click += new EventHandler(ButtonConfigureExtension_Click);
			RepopulateExtensionsDialog();

			// Create and populate the virtual COM port dialog.
			virtualComPortsDialog = new FormVirtualComPorts();
			virtualComPortsDialog.VirtualComPortListBox.SelectedIndexChanged += new EventHandler(VirtualComPortListBox_SelectedIndexChanged);
			virtualComPortsDialog.ButtonAdd.Click += new EventHandler(ButtonAddVirtualComPort_Click);
			virtualComPortsDialog.ButtonRemove.Click += new EventHandler(ButtonRemoveVirtualComPort_Click);
			RepopulateVirtualComPortsDialog();
		}
Example #11
0
        //Returns true if the source should be updated. Returns false if it does not.
        private bool ReadNiniConfig(IConfigSource source, string name)
        {
//            bool creatingNew = false;

            if (name == String.Empty || source.Configs.Count == 0)
            {
                MainConsole.Instance.Output("=====================================\n");
                MainConsole.Instance.Output("We are now going to ask a couple of questions about your region.\n");
                MainConsole.Instance.Output("You can press 'enter' without typing anything to use the default\n");
                MainConsole.Instance.Output("the default is displayed between [ ] brackets.\n");
                MainConsole.Instance.Output("=====================================\n");
            }

            bool NeedsUpdate = false;
            if (name == String.Empty)
                name = MainConsole.Instance.CmdPrompt("New region name", name);
            if (name == String.Empty)
                throw new Exception("Cannot interactively create region with no name");

            if (source.Configs.Count == 0)
            {
                source.AddConfig(name);

//                creatingNew = true;
                NeedsUpdate = true;
            }

            if (source.Configs[name] == null)
            {
                source.AddConfig(name);
                NeedsUpdate = true;
//                creatingNew = true;
            }

            IConfig config = source.Configs[name];

            // UUID
            //
            string regionUUID = config.GetString("RegionUUID", string.Empty);

            if (regionUUID == String.Empty)
            {
                NeedsUpdate = true;
                UUID newID = UUID.Random();

                regionUUID = MainConsole.Instance.CmdPrompt("Region UUID", newID.ToString());
                config.Set("RegionUUID", regionUUID);
            }

            RegionID = new UUID(regionUUID);
            
            RegionName = name;
            string location = config.GetString("Location", String.Empty);

            if (location == String.Empty)
            {
                NeedsUpdate = true;
                location = MainConsole.Instance.CmdPrompt("Region Location", "1000,1000");
                config.Set("Location", location);
            }

            string[] locationElements = location.Split(new char[] {','});

            m_regionLocX = Convert.ToUInt32(locationElements[0]);
            m_regionLocY = Convert.ToUInt32(locationElements[1]);

            // Internal IP
            IPAddress address;

            if (config.Contains("InternalAddress"))
            {
                address = IPAddress.Parse(config.GetString("InternalAddress", String.Empty));
            }
            else
            {
                NeedsUpdate = true;
                address = IPAddress.Parse(MainConsole.Instance.CmdPrompt("Internal IP address", "0.0.0.0"));
                config.Set("InternalAddress", address.ToString());
            }

            int port;

            if (config.Contains("InternalPort"))
            {
                port = config.GetInt("InternalPort", 9000);
            }
            else
            {
                NeedsUpdate = true;
                port = Convert.ToInt32(MainConsole.Instance.CmdPrompt("Internal port", "9000"));
                config.Set("InternalPort", port);
            }

            m_internalEndPoint = new IPEndPoint(address, port);

            if (config.Contains("AllowAlternatePorts"))
            {
                m_allow_alternate_ports = config.GetBoolean("AllowAlternatePorts", true);
            }
            else
            {
                NeedsUpdate = true;
                m_allow_alternate_ports = Convert.ToBoolean(MainConsole.Instance.CmdPrompt("Allow alternate ports", "False"));

                config.Set("AllowAlternatePorts", m_allow_alternate_ports.ToString());
            }

            // External IP
            //
            string externalName;

            if (config.Contains("ExternalHostName"))
            {
                externalName = config.GetString("ExternalHostName", "SYSTEMIP");
            }
            else
            {
                NeedsUpdate = true;
                externalName = MainConsole.Instance.CmdPrompt("External host name", "SYSTEMIP");
                config.Set("ExternalHostName", externalName);
            }

            if (externalName == "SYSTEMIP")
            {
                m_externalHostName = Util.GetLocalHost().ToString();
                m_log.InfoFormat(
                    "[REGIONINFO]: Resolving SYSTEMIP to {0} for external hostname of region {1}",
                    m_externalHostName, name);
            }
            else
            {
                m_externalHostName = externalName;
            }

            m_regionType = config.GetString("RegionType", String.Empty);
            GridSecureSessionID = UUID.Parse(config.GetString("GridSessionID", GridSecureSessionID.ToString()));
            EstateSettings.EstatePass = config.GetString("EstatePass", "");

            if (m_regionType == String.Empty)
            {
                NeedsUpdate = true;
                m_regionType = MainConsole.Instance.CmdPrompt("Region Type", "Mainland");
                config.Set("RegionType", m_regionType);
            }

            m_allowPhysicalPrims = config.GetBoolean("AllowPhysicalPrims", m_allowPhysicalPrims);

            m_allowScriptCrossing = config.GetBoolean("AllowScriptCrossing", m_allowScriptCrossing);

            m_trustBinariesFromForeignSims = config.GetBoolean("TrustBinariesFromForeignSims", m_trustBinariesFromForeignSims);

            m_seeIntoThisSimFromNeighbor = config.GetBoolean("SeeIntoThisSimFromNeighbor", m_seeIntoThisSimFromNeighbor);

            m_objectCapacity = config.GetInt("MaxPrims", m_objectCapacity);


            // Multi-tenancy
            //
            ScopeID = new UUID(config.GetString("ScopeID", ScopeID.ToString()));
            return NeedsUpdate;
        }
Example #12
0
        private void WriteNiniConfig(IConfigSource source)
        {
            IConfig config = source.Configs[RegionName];

            if (config != null)
                source.Configs.Remove(RegionName);

            config = source.AddConfig(RegionName);

            config.Set("RegionUUID", RegionID.ToString());

            string location = String.Format("{0},{1}", m_regionLocX, m_regionLocY);
            config.Set("Location", location);

            if (DataStore != String.Empty)
                config.Set("Datastore", DataStore);

            config.Set("InternalAddress", m_internalEndPoint.Address.ToString());
            config.Set("InternalPort", m_internalEndPoint.Port);

            config.Set("AllowAlternatePorts", m_allow_alternate_ports.ToString());

            config.Set("ExternalHostName", m_externalHostName);

            if (MasterAvatarAssignedUUID != UUID.Zero)
            {
                config.Set("MasterAvatarUUID", MasterAvatarAssignedUUID.ToString());
            }
            else if (MasterAvatarFirstName != String.Empty && MasterAvatarLastName != String.Empty)
            {
                config.Set("MasterAvatarFirstName", MasterAvatarFirstName);
                config.Set("MasterAvatarLastName", MasterAvatarLastName);
            }
            if (MasterAvatarSandboxPassword != String.Empty)
            {
                config.Set("MasterAvatarSandboxPassword", MasterAvatarSandboxPassword);
            }

            if (m_nonphysPrimMax != 0)
                config.Set("NonphysicalPrimMax", m_nonphysPrimMax);
            if (m_physPrimMax != 0)
                config.Set("PhysicalPrimMax", m_physPrimMax);
            config.Set("ClampPrimSize", m_clampPrimSize.ToString());

            if (m_objectCapacity != 0)
                config.Set("MaxPrims", m_objectCapacity);

            if (ScopeID != UUID.Zero)
                config.Set("ScopeID", ScopeID.ToString());

            if (RegionType != String.Empty)
                config.Set("RegionType", RegionType);
        }
Example #13
0
        private void ReadNiniConfig(IConfigSource source, string name)
        {
            bool creatingNew = false;

            if (source.Configs.Count == 0)
            {
                MainConsole.Instance.Output("=====================================\n");
                MainConsole.Instance.Output("We are now going to ask a couple of questions about your region.\n");
                MainConsole.Instance.Output("You can press 'enter' without typing anything to use the default\n");
                MainConsole.Instance.Output("the default is displayed between [ ] brackets.\n");
                MainConsole.Instance.Output("=====================================\n");

                if (name == String.Empty)
                    name = MainConsole.Instance.CmdPrompt("New region name", name);
                if (name == String.Empty)
                    throw new Exception("Cannot interactively create region with no name");

                source.AddConfig(name);

                creatingNew = true;
            }

            if (name == String.Empty)
                name = source.Configs[0].Name;

            if (source.Configs[name] == null)
            {
                source.AddConfig(name);

                creatingNew = true;
            }

            IConfig config = source.Configs[name];

            // UUID
            //
            string regionUUID = config.GetString("RegionUUID", string.Empty);

            if (regionUUID == String.Empty)
            {
                UUID newID = UUID.Random();

                regionUUID = MainConsole.Instance.CmdPrompt("Region UUID", newID.ToString());
                config.Set("RegionUUID", regionUUID);
            }

            RegionID = new UUID(regionUUID);
            originRegionID = RegionID; // What IS this?!

            
            // Region name
            //
            RegionName = name;

            
            // Region location
            //
            string location = config.GetString("Location", String.Empty);

            if (location == String.Empty)
            {
                location = MainConsole.Instance.CmdPrompt("Region Location", "1000,1000");
                config.Set("Location", location);
            }

            string[] locationElements = location.Split(new char[] {','});

            m_regionLocX = Convert.ToUInt32(locationElements[0]);
            m_regionLocY = Convert.ToUInt32(locationElements[1]);


            // Datastore (is this implemented? Omitted from example!)
            //
            DataStore = config.GetString("Datastore", String.Empty);


            // Internal IP
            //
            IPAddress address;
            
            if (config.Contains("InternalAddress"))
            {
                address = IPAddress.Parse(config.GetString("InternalAddress", String.Empty));
            }
            else
            {
                address = IPAddress.Parse(MainConsole.Instance.CmdPrompt("Internal IP address", "0.0.0.0"));
                config.Set("InternalAddress", address.ToString());
            }

            int port;

            if (config.Contains("InternalPort"))
            {
                port = config.GetInt("InternalPort", 9000);
            }
            else
            {
                port = Convert.ToInt32(MainConsole.Instance.CmdPrompt("Internal port", "9000"));
                config.Set("InternalPort", port);
            }

            m_internalEndPoint = new IPEndPoint(address, port);

            if (config.Contains("AllowAlternatePorts"))
            {
                m_allow_alternate_ports = config.GetBoolean("AllowAlternatePorts", true);
            }
            else
            {
                m_allow_alternate_ports = Convert.ToBoolean(MainConsole.Instance.CmdPrompt("Allow alternate ports", "False"));

                config.Set("AllowAlternatePorts", m_allow_alternate_ports.ToString());
            }

            // External IP
            //
            string externalName;

            if (config.Contains("ExternalHostName"))
            {
                externalName = config.GetString("ExternalHostName", "SYSTEMIP");
            }
            else
            {
                externalName = MainConsole.Instance.CmdPrompt("External host name", "SYSTEMIP");
                config.Set("ExternalHostName", externalName);
            }

            if (externalName == "SYSTEMIP")
                m_externalHostName = Util.GetLocalHost().ToString();
            else
                m_externalHostName = externalName;


            // Master avatar cruft
            //
            string masterAvatarUUID;
            if (!creatingNew)
            {
                masterAvatarUUID = config.GetString("MasterAvatarUUID", UUID.Zero.ToString());
                MasterAvatarFirstName = config.GetString("MasterAvatarFirstName", String.Empty);
                MasterAvatarLastName = config.GetString("MasterAvatarLastName", String.Empty);
                MasterAvatarSandboxPassword = config.GetString("MasterAvatarSandboxPassword", String.Empty);
            }
            else
            {
                masterAvatarUUID = MainConsole.Instance.CmdPrompt("Master Avatar UUID", UUID.Zero.ToString());
                if (masterAvatarUUID != UUID.Zero.ToString())
                {
                    config.Set("MasterAvatarUUID", masterAvatarUUID);
                }
                else
                {
                    MasterAvatarFirstName = MainConsole.Instance.CmdPrompt("Master Avatar first name (enter for no master avatar)", String.Empty);
                    if (MasterAvatarFirstName != String.Empty)
                    {
                        MasterAvatarLastName = MainConsole.Instance.CmdPrompt("Master Avatar last name", String.Empty);
                        MasterAvatarSandboxPassword = MainConsole.Instance.CmdPrompt("Master Avatar sandbox password", String.Empty);
                        
                        config.Set("MasterAvatarFirstName", MasterAvatarFirstName);
                        config.Set("MasterAvatarLastName", MasterAvatarLastName);
                        config.Set("MasterAvatarSandboxPassword", MasterAvatarSandboxPassword);
                    }
                }
            }

            MasterAvatarAssignedUUID = new UUID(masterAvatarUUID);

            m_regionType = config.GetString("RegionType", String.Empty);

            // Prim stuff
            //
            m_nonphysPrimMax = config.GetInt("NonphysicalPrimMax", 256);

            m_physPrimMax = config.GetInt("PhysicalPrimMax", 10);

            m_clampPrimSize = config.GetBoolean("ClampPrimSize", false);

            m_objectCapacity = config.GetInt("MaxPrims", 15000);


            // Multi-tenancy
            //
            ScopeID = new UUID(config.GetString("ScopeID", UUID.Zero.ToString()));
        }
Example #14
0
        public void CreateIConfig(IConfigSource source)
        {
            IConfig config = source.Configs[RegionName];

            if (config != null)
                source.Configs.Remove(config);

            config = source.AddConfig(RegionName);

            config.Set("RegionUUID", RegionID.ToString());

            string location = String.Format("{0},{1}", m_regionLocX / 256, m_regionLocY / 256);
            config.Set("Location", location);

            config.Set("InternalAddress", m_internalEndPoint.Address.ToString());
            config.Set("InternalPort", m_internalEndPoint.Port);

            config.Set("AllowAlternatePorts", m_allow_alternate_ports.ToString());

            config.Set("ExternalHostName", m_externalHostName);

            if (m_objectCapacity != 0)
                config.Set("MaxPrims", m_objectCapacity);

            if (ScopeID != UUID.Zero)
                config.Set("ScopeID", ScopeID.ToString());

            if (RegionType != String.Empty)
                config.Set("RegionType", RegionType);

            config.Set("AllowPhysicalPrims", AllowPhysicalPrims);
            config.Set("AllowScriptCrossing", AllowScriptCrossing);
            config.Set("TrustBinariesFromForeignSims", TrustBinariesFromForeignSims);
            config.Set("SeeIntoThisSimFromNeighbor", SeeIntoThisSimFromNeighbor);
            config.Set("RegionSizeX", RegionSizeX);
            config.Set ("RegionSizeY", RegionSizeY);
            config.Set ("RegionSizeZ", RegionSizeZ);

            config.Set ("StartupType", Startup.ToString());

            config.Set("NeighborPassword", Password.ToString());
        }
        private void AddScriptingConfig(IConfigSource config, List<object> modules)
        {
            IConfig startupConfig = config.AddConfig("Startup");
            startupConfig.Set("DefaultScriptEngine", "XEngine");

            IConfig xEngineConfig = config.AddConfig("XEngine");
            xEngineConfig.Set("Enabled", "true");
            xEngineConfig.Set("StartDelay", "0");

            // These tests will not run with AppDomainLoading = true, at least on mono.  For unknown reasons, the call
            // to AssemblyResolver.OnAssemblyResolve fails.
            xEngineConfig.Set("AppDomainLoading", "false");

            modules.Add(new XEngine());

            // Necessary to stop serialization complaining
            // FIXME: Stop this being necessary if at all possible
//            modules.Add(new WorldCommModule());
        }
Example #16
0
        public frmMain()
        {
            #if (DEBUG_1||DEBUG_2||DEBUG_3)
            debugLogger = new DebugLogger("frmMain.log");
            #endif
            debugLogger.WriteDebug_3("Begin Method: frmMain.frmMain()");

            InitializeComponent();

            Directory.SetCurrentDirectory(Directory.GetParent(Application.ExecutablePath).FullName);
            debugLogger.WriteDebug_2("Set Current Directory to " + Directory.GetParent(Application.ExecutablePath).FullName);

            // TODO: Determine why this is a double nested try/catch to load some INI settings
            try
            {
                inifile = new IniConfigSource(Directory.GetCurrentDirectory() + "\\settings.ini");
                DBString = inifile.Configs["Files"].GetString("dbfile","");
                LogFile = inifile.Configs["Files"].GetString("logfile","");
                OutputDirectory = inifile.Configs["Files"].GetString("outdir","");
                DKPTax = inifile.Configs["Other"].GetDouble("tax",0.0);
                MinDKP = inifile.Configs["Other"].GetDouble("mindkp", 0);
                TierAPct = inifile.Configs["Other"].GetDouble("tierapct", 0.6);
                TierBPct = inifile.Configs["Other"].GetDouble("tierbpct", 0.3);
                TierCPct = inifile.Configs["Other"].GetDouble("tiercpct", 0.0);
                GuildNames = inifile.Configs["Other"].GetString("GuildNames", "Eternal Sovereign");
                debugLogger.WriteDebug_1("Read settings from INI: DBFile=" + DBString + ", LogFile=" + LogFile + ", OutputDirectory="
                    + OutputDirectory + ", DKPTax=" + DKPTax + ", GuildNames=" + GuildNames);

                StatusMessage ="Read settings from INI...";
                try
                {
                    parser = new LogParser(this,LogFile);
                    debugLogger.WriteDebug_3("Created log parser");
                }
                catch (Exception ex) {
                    debugLogger.WriteDebug_1("Failed to create log parser: " + ex.Message);
                }
            }
            catch (FileNotFoundException ex)
            {
                debugLogger.WriteDebug_3("settings.ini not found, creating");

                FileStream a = File.Create(Directory.GetCurrentDirectory() + "\\settings.ini");
                a.Close();
                sbpMessage.Text = "settings.ini not found... Loading defaults";
                try
                {
                    inifile = new IniConfigSource(Directory.GetCurrentDirectory() + "\\settings.ini");
                    inifile.AddConfig("Files");
                    inifile.AddConfig("Other");
                    LogFile = inifile.Configs["Files"].GetString("logfile","");
                    DBString = inifile.Configs["Files"].GetString("dbfile","");
                    OutputDirectory = inifile.Configs["Files"].GetString("outdir","");
                    DKPTax = inifile.Configs["Other"].GetDouble("tax",0.0);
                    MinDKP = inifile.Configs["Other"].GetDouble("mindkp", 0);
                    TierAPct = inifile.Configs["Other"].GetDouble("tierapct", 0.6);
                    TierBPct = inifile.Configs["Other"].GetDouble("tierbpct", 0.3);
                    TierCPct = inifile.Configs["Other"].GetDouble("tiercpct", 0.0);
                    GuildNames = inifile.Configs["Other"].GetString("GuildNames", "Eternal Sovereign");
                    inifile.Save();
                    debugLogger.WriteDebug_1("Read settings from INI: dbFile=" + DBString + ", logFile=" + LogFile
                        + ", outDir=" + OutputDirectory + ", tax=" + DKPTax + ", mindkp=" + MinDKP + ", GuildNames=" + GuildNames);
                }
                catch (Exception exc)
                {
                    debugLogger.WriteDebug_1("Failed to create new settings.ini: " + exc.Message);
                    MessageBox.Show("Error opening settings.ini","Error");
                    Environment.Exit(1);
                }
            }
            catch (Exception ex)
            {
                debugLogger.WriteDebug_1("Failed to load settings.ini: " + ex.Message);
                MessageBox.Show("Error opening settings.ini","Error");
                Environment.Exit(1);
            }
            UITimer = new Timer();
            UITimer.Interval = 100;
            UITimer.Tick += new EventHandler(UITimer_Tick);
            UITimer.Start();

            debugLogger.WriteDebug_3("End Method: frmMain.frmMain()");
        }