Refactor machine-dependent configuration in LaunchSLClient.

This commit is contained in:
Jeff Ames
2008-05-01 17:07:58 +00:00
parent fc6c4dc399
commit e38ee199b9
6 changed files with 226 additions and 82 deletions

View File

@@ -44,7 +44,7 @@ namespace LaunchSLClient
{
const string deepGridUrl = "http://user.deepgrid.com:8002/";
const string osGridUrl = "http://www.osgrid.org:8002/";
const string openLifeGridUrl = "http://logingrid.net:8002";
const string openLifeGridUrl = "http://logingrid.net:8002/";
string gridUrl = "";
string sandboxUrl = "";
@@ -53,6 +53,47 @@ namespace LaunchSLClient
string exeFlags = "";
string exePath = "";
private MachineConfig m_machineConfig;
public Form1()
{
InitializeComponent();
ArrayList menuItems = new ArrayList();
m_machineConfig = getMachineConfig();
m_machineConfig.GetClient(ref exePath, ref runLine, ref exeFlags);
menuItems.Add("Please select one:");
addLocalSims(ref menuItems);
menuItems.Add("OSGrid - www.osgrid.org");
menuItems.Add("DeepGrid - www.deepgrid.com");
menuItems.Add("OpenlifeGrid - www.openlifegrid.com");
menuItems.Add("Linden Labs - www.secondlife.com");
comboBox1.DataSource = menuItems;
}
private MachineConfig getMachineConfig()
{
if (Environment.OSVersion.Platform == PlatformID.Unix)
{
if (File.Exists("/System/Library/Frameworks/Cocoa.framework/Cocoa"))
{
return new OSXConfig();
}
else
{
return new UnixConfig();
}
}
else
{
return new WindowsConfig();
}
}
private void addLocalSandbox(ref ArrayList menuItems)
{
// build sandbox URL from Regions\default.xml
@@ -140,83 +181,6 @@ namespace LaunchSLClient
}
}
private void getClientWindows(ref string exePath, ref string runLine, ref string exeFlags)
{
// get executable path from registry
RegistryKey regKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Linden Research, Inc.\SecondLife");
if (regKey == null)
{
regKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Wow6432Node\Linden Research, Inc.\SecondLife");
if (regKey == null)
{
throw new LauncherException("Can't find Second Life. Are you sure it is installed?", "LauncherException.Form1");
}
}
string exe = regKey.GetValue("Exe").ToString();
exeFlags = regKey.GetValue("Flags").ToString();
exePath = regKey.GetValue("").ToString();
runLine = exePath + "\\" + exe;
Registry.LocalMachine.Flush();
Registry.LocalMachine.Close();
}
private void getClientMacOSX(ref string exePath, ref string runLine, ref string exeFlags)
{
if (Directory.Exists("/Applications/Second Life.app"))
{
exePath = "/Applications/Second Life.app/Contents/MacOS";
}
runLine = exePath + "/Second Life";
exeFlags = "";
}
private void getClientUnix(ref string exePath, ref string runLine, ref string exeFlags)
{
}
private void getClient(ref string exePath, ref string runLine, ref string exeFlags)
{
if (Environment.OSVersion.Platform == PlatformID.Unix)
{
if (File.Exists("/System/Library/Frameworks/Cocoa.framework/Cocoa"))
{
getClientMacOSX(ref exePath, ref runLine, ref exeFlags);
}
else
{
getClientUnix(ref exePath, ref runLine, ref exeFlags);
}
}
else
{
getClientWindows(ref exePath, ref runLine, ref exeFlags);
}
}
public Form1()
{
InitializeComponent();
ArrayList menuItems = new ArrayList();
getClient(ref exePath, ref runLine, ref exeFlags);
menuItems.Add("Please select one:");
addLocalSims(ref menuItems);
menuItems.Add("OSGrid - www.osgrid.org");
menuItems.Add("DeepGrid - www.deepgrid.com");
menuItems.Add("OpenlifeGrid - www.openlifegrid.com");
menuItems.Add("Linden Labs - www.secondlife.com");
comboBox1.DataSource = menuItems;
}
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (comboBox1.Text == "Please select one:") { return; }