From e38ee199b9dca255d3f3806ed7f0894754a7065c Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Thu, 1 May 2008 17:07:58 +0000 Subject: Refactor machine-dependent configuration in LaunchSLClient. --- .../Tools/LaunchSLClient/LaunchSLClient/Form1.cs | 120 ++++++++------------- .../LaunchSLClient/LaunchSLClient/MachineConfig.cs | 37 +++++++ .../LaunchSLClient/LaunchSLClient/OSXConfig.cs | 50 +++++++++ .../Tools/LaunchSLClient/LaunchSLClient/Program.cs | 4 - .../LaunchSLClient/LaunchSLClient/UnixConfig.cs | 42 ++++++++ .../LaunchSLClient/LaunchSLClient/WindowsConfig.cs | 55 ++++++++++ 6 files changed, 226 insertions(+), 82 deletions(-) create mode 100644 OpenSim/Tools/LaunchSLClient/LaunchSLClient/MachineConfig.cs create mode 100644 OpenSim/Tools/LaunchSLClient/LaunchSLClient/OSXConfig.cs create mode 100644 OpenSim/Tools/LaunchSLClient/LaunchSLClient/UnixConfig.cs create mode 100644 OpenSim/Tools/LaunchSLClient/LaunchSLClient/WindowsConfig.cs (limited to 'OpenSim') diff --git a/OpenSim/Tools/LaunchSLClient/LaunchSLClient/Form1.cs b/OpenSim/Tools/LaunchSLClient/LaunchSLClient/Form1.cs index 1cddb2b..700c004 100644 --- a/OpenSim/Tools/LaunchSLClient/LaunchSLClient/Form1.cs +++ b/OpenSim/Tools/LaunchSLClient/LaunchSLClient/Form1.cs @@ -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; } diff --git a/OpenSim/Tools/LaunchSLClient/LaunchSLClient/MachineConfig.cs b/OpenSim/Tools/LaunchSLClient/LaunchSLClient/MachineConfig.cs new file mode 100644 index 0000000..68a86c4 --- /dev/null +++ b/OpenSim/Tools/LaunchSLClient/LaunchSLClient/MachineConfig.cs @@ -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); + } +} diff --git a/OpenSim/Tools/LaunchSLClient/LaunchSLClient/OSXConfig.cs b/OpenSim/Tools/LaunchSLClient/LaunchSLClient/OSXConfig.cs new file mode 100644 index 0000000..60e5e48 --- /dev/null +++ b/OpenSim/Tools/LaunchSLClient/LaunchSLClient/OSXConfig.cs @@ -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 = ""; + } + } +} diff --git a/OpenSim/Tools/LaunchSLClient/LaunchSLClient/Program.cs b/OpenSim/Tools/LaunchSLClient/LaunchSLClient/Program.cs index 822611c..1d715a5 100644 --- a/OpenSim/Tools/LaunchSLClient/LaunchSLClient/Program.cs +++ b/OpenSim/Tools/LaunchSLClient/LaunchSLClient/Program.cs @@ -33,9 +33,6 @@ namespace LaunchSLClient { static class Program { - /// - /// The main entry point for the application. - /// [STAThread] static void Main() { @@ -47,7 +44,6 @@ namespace LaunchSLClient } catch (Exception ex) { - // Handles all unhandled errors MessageBox.Show(ex.Message,"Unhandled Error"); } } diff --git a/OpenSim/Tools/LaunchSLClient/LaunchSLClient/UnixConfig.cs b/OpenSim/Tools/LaunchSLClient/LaunchSLClient/UnixConfig.cs new file mode 100644 index 0000000..eb5342f --- /dev/null +++ b/OpenSim/Tools/LaunchSLClient/LaunchSLClient/UnixConfig.cs @@ -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 = ""; + } + } +} diff --git a/OpenSim/Tools/LaunchSLClient/LaunchSLClient/WindowsConfig.cs b/OpenSim/Tools/LaunchSLClient/LaunchSLClient/WindowsConfig.cs new file mode 100644 index 0000000..f3b797c --- /dev/null +++ b/OpenSim/Tools/LaunchSLClient/LaunchSLClient/WindowsConfig.cs @@ -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(); + } + } +} -- cgit v1.1