Refactor machine-dependent configuration in LaunchSLClient.
parent
fc6c4dc399
commit
e38ee199b9
|
@ -44,7 +44,7 @@ namespace LaunchSLClient
|
||||||
{
|
{
|
||||||
const string deepGridUrl = "http://user.deepgrid.com:8002/";
|
const string deepGridUrl = "http://user.deepgrid.com:8002/";
|
||||||
const string osGridUrl = "http://www.osgrid.org: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 gridUrl = "";
|
||||||
string sandboxUrl = "";
|
string sandboxUrl = "";
|
||||||
|
@ -53,6 +53,47 @@ namespace LaunchSLClient
|
||||||
string exeFlags = "";
|
string exeFlags = "";
|
||||||
string exePath = "";
|
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)
|
private void addLocalSandbox(ref ArrayList menuItems)
|
||||||
{
|
{
|
||||||
// build sandbox URL from Regions\default.xml
|
// 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)
|
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (comboBox1.Text == "Please select one:") { return; }
|
if (comboBox1.Text == "Please select one:") { return; }
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://opensimulator.org/
|
||||||
|
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the OpenSim Project nor the
|
||||||
|
* names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace LaunchSLClient
|
||||||
|
{
|
||||||
|
public abstract class MachineConfig
|
||||||
|
{
|
||||||
|
public abstract void GetClient(ref string exePath, ref string runLine, ref string exeFlags);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,50 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://opensimulator.org/
|
||||||
|
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the OpenSim Project nor the
|
||||||
|
* names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace LaunchSLClient
|
||||||
|
{
|
||||||
|
public class OSXConfig : UnixConfig
|
||||||
|
{
|
||||||
|
public override void GetClient(ref string exePath, ref string runLine, ref string exeFlags)
|
||||||
|
{
|
||||||
|
if (Directory.Exists("/Applications/Second Life.app"))
|
||||||
|
{
|
||||||
|
exePath = "/Applications/Second Life.app/Contents/MacOS";
|
||||||
|
}
|
||||||
|
else if (Directory.Exists("/Applications/Second Life Release Candidate.app"))
|
||||||
|
{
|
||||||
|
exePath = "/Applications/Second Life Release Candidate.app/Contents/MacOS";
|
||||||
|
}
|
||||||
|
|
||||||
|
runLine = exePath + "/Second Life";
|
||||||
|
exeFlags = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -33,9 +33,6 @@ namespace LaunchSLClient
|
||||||
{
|
{
|
||||||
static class Program
|
static class Program
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// The main entry point for the application.
|
|
||||||
/// </summary>
|
|
||||||
[STAThread]
|
[STAThread]
|
||||||
static void Main()
|
static void Main()
|
||||||
{
|
{
|
||||||
|
@ -47,7 +44,6 @@ namespace LaunchSLClient
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
// Handles all unhandled errors
|
|
||||||
MessageBox.Show(ex.Message,"Unhandled Error");
|
MessageBox.Show(ex.Message,"Unhandled Error");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://opensimulator.org/
|
||||||
|
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the OpenSim Project nor the
|
||||||
|
* names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace LaunchSLClient
|
||||||
|
{
|
||||||
|
public class UnixConfig : MachineConfig
|
||||||
|
{
|
||||||
|
public override void GetClient(ref string exePath, ref string runLine, ref string exeFlags)
|
||||||
|
{
|
||||||
|
exePath = "";
|
||||||
|
runLine = "secondlife";
|
||||||
|
exeFlags = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,55 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://opensimulator.org/
|
||||||
|
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the OpenSim Project nor the
|
||||||
|
* names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using Microsoft.Win32;
|
||||||
|
|
||||||
|
namespace LaunchSLClient
|
||||||
|
{
|
||||||
|
public class WindowsConfig : MachineConfig
|
||||||
|
{
|
||||||
|
public override void GetClient(ref string exePath, ref string runLine, ref string exeFlags)
|
||||||
|
{
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue