More config cleanup in LaunchSLClient.

0.6.0-stable
Jeff Ames 2008-05-01 17:26:35 +00:00
parent a0ccb1235a
commit 138e612300
5 changed files with 29 additions and 14 deletions

View File

@ -36,7 +36,6 @@ using System.Drawing;
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Windows.Forms; using System.Windows.Forms;
using Microsoft.Win32;
namespace LaunchSLClient namespace LaunchSLClient
{ {
@ -96,9 +95,9 @@ namespace LaunchSLClient
private void addLocalSandbox(ref ArrayList menuItems) private void addLocalSandbox(ref ArrayList menuItems)
{ {
// build sandbox URL from Regions\default.xml // build sandbox URL from Regions/default.xml
// this is highly dependant on a standard default.xml // this is highly dependant on a standard default.xml
if (File.Exists(@"Regions\default.xml")) if (File.Exists("Regions/default.xml"))
{ {
string sandboxHostName = ""; string sandboxHostName = "";
string sandboxPort = ""; string sandboxPort = "";
@ -106,7 +105,7 @@ namespace LaunchSLClient
Regex myRegex = new Regex(".*internal_ip_port=\\\"(?<port>.*?)\\\".*external_host_name=\\\"(?<name>.*?)\\\".*"); Regex myRegex = new Regex(".*internal_ip_port=\\\"(?<port>.*?)\\\".*external_host_name=\\\"(?<name>.*?)\\\".*");
FileInfo defaultFile = new FileInfo(@"Regions\default.xml"); FileInfo defaultFile = new FileInfo("Regions/default.xml");
StreamReader stream = defaultFile.OpenText(); StreamReader stream = defaultFile.OpenText();
do do
{ {
@ -136,10 +135,10 @@ namespace LaunchSLClient
{ {
//build local grid URL from network_servers_information.xml //build local grid URL from network_servers_information.xml
// this is highly dependant on a standard default.xml // this is highly dependant on a standard default.xml
if (File.Exists(@"network_servers_information.xml")) if (File.Exists("network_servers_information.xml"))
{ {
string text; string text;
FileInfo defaultFile = new FileInfo(@"network_servers_information.xml"); FileInfo defaultFile = new FileInfo("network_servers_information.xml");
Regex myRegex = new Regex(".*UserServerURL=\\\"(?<url>.*?)\\\".*"); Regex myRegex = new Regex(".*UserServerURL=\\\"(?<url>.*?)\\\".*");
StreamReader stream = defaultFile.OpenText(); StreamReader stream = defaultFile.OpenText();
@ -168,13 +167,11 @@ namespace LaunchSLClient
private void addLocalSims(ref ArrayList menuItems) private void addLocalSims(ref ArrayList menuItems)
{ {
// find opensim directory string configDir = m_machineConfig.GetConfigDir();
RegistryKey exeKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\OpenSim\OpenSim");
if (exeKey != null)
{
Object simPath = exeKey.GetValue("Path");
Directory.SetCurrentDirectory(simPath.ToString()); //this should be set to wherever we decide to put the binaries if (!string.IsNullOrEmpty(configDir))
{
Directory.SetCurrentDirectory(configDir);
addLocalSandbox(ref menuItems); addLocalSandbox(ref menuItems);
addLocalGrid(ref menuItems); addLocalGrid(ref menuItems);
@ -193,10 +190,10 @@ namespace LaunchSLClient
System.Diagnostics.Process proc = new System.Diagnostics.Process(); System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.FileName = runLine; proc.StartInfo.FileName = runLine;
proc.StartInfo.Arguments = exeFlags.ToString() + " " + runUrl; proc.StartInfo.Arguments = exeFlags + " " + runUrl;
proc.StartInfo.UseShellExecute = false; proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardOutput = false; proc.StartInfo.RedirectStandardOutput = false;
proc.StartInfo.WorkingDirectory = exePath.ToString(); proc.StartInfo.WorkingDirectory = exePath;
proc.Start(); proc.Start();
proc.WaitForExit(); proc.WaitForExit();
} }

View File

@ -33,5 +33,6 @@ namespace LaunchSLClient
public abstract class MachineConfig public abstract class MachineConfig
{ {
public abstract void GetClient(ref string exePath, ref string runLine, ref string exeFlags); public abstract void GetClient(ref string exePath, ref string runLine, ref string exeFlags);
public abstract string GetConfigDir();
} }
} }

View File

@ -46,5 +46,10 @@ namespace LaunchSLClient
runLine = exePath + "/Second Life"; runLine = exePath + "/Second Life";
exeFlags = ""; exeFlags = "";
} }
public override string GetConfigDir()
{
return "";
}
} }
} }

View File

@ -38,5 +38,10 @@ namespace LaunchSLClient
runLine = "secondlife"; runLine = "secondlife";
exeFlags = ""; exeFlags = "";
} }
public override string GetConfigDir()
{
return "";
}
} }
} }

View File

@ -51,5 +51,12 @@ namespace LaunchSLClient
Registry.LocalMachine.Flush(); Registry.LocalMachine.Flush();
Registry.LocalMachine.Close(); Registry.LocalMachine.Close();
} }
public override string GetConfigDir()
{
RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\OpenSim\OpenSim");
return key == null ? "" : key.GetValue("Path").ToString();
}
} }
} }