diff options
author | Jeff Ames | 2008-05-01 17:07:58 +0000 |
---|---|---|
committer | Jeff Ames | 2008-05-01 17:07:58 +0000 |
commit | e38ee199b9dca255d3f3806ed7f0894754a7065c (patch) | |
tree | 9340a9d35691722abc8884f631947f6be4756085 /OpenSim | |
parent | * Cleaning code still. (diff) | |
download | opensim-SC_OLD-e38ee199b9dca255d3f3806ed7f0894754a7065c.zip opensim-SC_OLD-e38ee199b9dca255d3f3806ed7f0894754a7065c.tar.gz opensim-SC_OLD-e38ee199b9dca255d3f3806ed7f0894754a7065c.tar.bz2 opensim-SC_OLD-e38ee199b9dca255d3f3806ed7f0894754a7065c.tar.xz |
Refactor machine-dependent configuration in LaunchSLClient.
Diffstat (limited to 'OpenSim')
6 files changed, 226 insertions, 82 deletions
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 | |||
44 | { | 44 | { |
45 | const string deepGridUrl = "http://user.deepgrid.com:8002/"; | 45 | const string deepGridUrl = "http://user.deepgrid.com:8002/"; |
46 | const string osGridUrl = "http://www.osgrid.org:8002/"; | 46 | const string osGridUrl = "http://www.osgrid.org:8002/"; |
47 | const string openLifeGridUrl = "http://logingrid.net:8002"; | 47 | const string openLifeGridUrl = "http://logingrid.net:8002/"; |
48 | 48 | ||
49 | string gridUrl = ""; | 49 | string gridUrl = ""; |
50 | string sandboxUrl = ""; | 50 | string sandboxUrl = ""; |
@@ -53,6 +53,47 @@ namespace LaunchSLClient | |||
53 | string exeFlags = ""; | 53 | string exeFlags = ""; |
54 | string exePath = ""; | 54 | string exePath = ""; |
55 | 55 | ||
56 | private MachineConfig m_machineConfig; | ||
57 | |||
58 | public Form1() | ||
59 | { | ||
60 | InitializeComponent(); | ||
61 | ArrayList menuItems = new ArrayList(); | ||
62 | |||
63 | m_machineConfig = getMachineConfig(); | ||
64 | m_machineConfig.GetClient(ref exePath, ref runLine, ref exeFlags); | ||
65 | |||
66 | menuItems.Add("Please select one:"); | ||
67 | |||
68 | addLocalSims(ref menuItems); | ||
69 | |||
70 | menuItems.Add("OSGrid - www.osgrid.org"); | ||
71 | menuItems.Add("DeepGrid - www.deepgrid.com"); | ||
72 | menuItems.Add("OpenlifeGrid - www.openlifegrid.com"); | ||
73 | menuItems.Add("Linden Labs - www.secondlife.com"); | ||
74 | |||
75 | comboBox1.DataSource = menuItems; | ||
76 | } | ||
77 | |||
78 | private MachineConfig getMachineConfig() | ||
79 | { | ||
80 | if (Environment.OSVersion.Platform == PlatformID.Unix) | ||
81 | { | ||
82 | if (File.Exists("/System/Library/Frameworks/Cocoa.framework/Cocoa")) | ||
83 | { | ||
84 | return new OSXConfig(); | ||
85 | } | ||
86 | else | ||
87 | { | ||
88 | return new UnixConfig(); | ||
89 | } | ||
90 | } | ||
91 | else | ||
92 | { | ||
93 | return new WindowsConfig(); | ||
94 | } | ||
95 | } | ||
96 | |||
56 | private void addLocalSandbox(ref ArrayList menuItems) | 97 | private void addLocalSandbox(ref ArrayList menuItems) |
57 | { | 98 | { |
58 | // build sandbox URL from Regions\default.xml | 99 | // build sandbox URL from Regions\default.xml |
@@ -140,83 +181,6 @@ namespace LaunchSLClient | |||
140 | } | 181 | } |
141 | } | 182 | } |
142 | 183 | ||
143 | private void getClientWindows(ref string exePath, ref string runLine, ref string exeFlags) | ||
144 | { | ||
145 | // get executable path from registry | ||
146 | RegistryKey regKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Linden Research, Inc.\SecondLife"); | ||
147 | if (regKey == null) | ||
148 | { | ||
149 | regKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Wow6432Node\Linden Research, Inc.\SecondLife"); | ||
150 | if (regKey == null) | ||
151 | { | ||
152 | throw new LauncherException("Can't find Second Life. Are you sure it is installed?", "LauncherException.Form1"); | ||
153 | } | ||
154 | } | ||
155 | string exe = regKey.GetValue("Exe").ToString(); | ||
156 | exeFlags = regKey.GetValue("Flags").ToString(); | ||
157 | exePath = regKey.GetValue("").ToString(); | ||
158 | runLine = exePath + "\\" + exe; | ||
159 | Registry.LocalMachine.Flush(); | ||
160 | Registry.LocalMachine.Close(); | ||
161 | } | ||
162 | |||
163 | private void getClientMacOSX(ref string exePath, ref string runLine, ref string exeFlags) | ||
164 | { | ||
165 | if (Directory.Exists("/Applications/Second Life.app")) | ||
166 | { | ||
167 | exePath = "/Applications/Second Life.app/Contents/MacOS"; | ||
168 | } | ||
169 | |||
170 | runLine = exePath + "/Second Life"; | ||
171 | exeFlags = ""; | ||
172 | } | ||
173 | |||
174 | private void getClientUnix(ref string exePath, ref string runLine, ref string exeFlags) | ||
175 | { | ||
176 | } | ||
177 | |||
178 | private void getClient(ref string exePath, ref string runLine, ref string exeFlags) | ||
179 | { | ||
180 | if (Environment.OSVersion.Platform == PlatformID.Unix) | ||
181 | { | ||
182 | if (File.Exists("/System/Library/Frameworks/Cocoa.framework/Cocoa")) | ||
183 | { | ||
184 | getClientMacOSX(ref exePath, ref runLine, ref exeFlags); | ||
185 | } | ||
186 | else | ||
187 | { | ||
188 | getClientUnix(ref exePath, ref runLine, ref exeFlags); | ||
189 | } | ||
190 | } | ||
191 | else | ||
192 | { | ||
193 | getClientWindows(ref exePath, ref runLine, ref exeFlags); | ||
194 | } | ||
195 | } | ||
196 | |||
197 | public Form1() | ||
198 | { | ||
199 | InitializeComponent(); | ||
200 | ArrayList menuItems = new ArrayList(); | ||
201 | |||
202 | getClient(ref exePath, ref runLine, ref exeFlags); | ||
203 | |||
204 | menuItems.Add("Please select one:"); | ||
205 | |||
206 | addLocalSims(ref menuItems); | ||
207 | |||
208 | menuItems.Add("OSGrid - www.osgrid.org"); | ||
209 | menuItems.Add("DeepGrid - www.deepgrid.com"); | ||
210 | menuItems.Add("OpenlifeGrid - www.openlifegrid.com"); | ||
211 | menuItems.Add("Linden Labs - www.secondlife.com"); | ||
212 | |||
213 | comboBox1.DataSource = menuItems; | ||
214 | } | ||
215 | |||
216 | private void radioButton1_CheckedChanged(object sender, EventArgs e) | ||
217 | { | ||
218 | } | ||
219 | |||
220 | private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) | 184 | private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) |
221 | { | 185 | { |
222 | if (comboBox1.Text == "Please select one:") { return; } | 186 | 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 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.IO; | ||
30 | |||
31 | namespace LaunchSLClient | ||
32 | { | ||
33 | public abstract class MachineConfig | ||
34 | { | ||
35 | public abstract void GetClient(ref string exePath, ref string runLine, ref string exeFlags); | ||
36 | } | ||
37 | } | ||
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 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.IO; | ||
30 | |||
31 | namespace LaunchSLClient | ||
32 | { | ||
33 | public class OSXConfig : UnixConfig | ||
34 | { | ||
35 | public override void GetClient(ref string exePath, ref string runLine, ref string exeFlags) | ||
36 | { | ||
37 | if (Directory.Exists("/Applications/Second Life.app")) | ||
38 | { | ||
39 | exePath = "/Applications/Second Life.app/Contents/MacOS"; | ||
40 | } | ||
41 | else if (Directory.Exists("/Applications/Second Life Release Candidate.app")) | ||
42 | { | ||
43 | exePath = "/Applications/Second Life Release Candidate.app/Contents/MacOS"; | ||
44 | } | ||
45 | |||
46 | runLine = exePath + "/Second Life"; | ||
47 | exeFlags = ""; | ||
48 | } | ||
49 | } | ||
50 | } | ||
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 | |||
33 | { | 33 | { |
34 | static class Program | 34 | static class Program |
35 | { | 35 | { |
36 | /// <summary> | ||
37 | /// The main entry point for the application. | ||
38 | /// </summary> | ||
39 | [STAThread] | 36 | [STAThread] |
40 | static void Main() | 37 | static void Main() |
41 | { | 38 | { |
@@ -47,7 +44,6 @@ namespace LaunchSLClient | |||
47 | } | 44 | } |
48 | catch (Exception ex) | 45 | catch (Exception ex) |
49 | { | 46 | { |
50 | // Handles all unhandled errors | ||
51 | MessageBox.Show(ex.Message,"Unhandled Error"); | 47 | MessageBox.Show(ex.Message,"Unhandled Error"); |
52 | } | 48 | } |
53 | } | 49 | } |
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 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.IO; | ||
30 | |||
31 | namespace LaunchSLClient | ||
32 | { | ||
33 | public class UnixConfig : MachineConfig | ||
34 | { | ||
35 | public override void GetClient(ref string exePath, ref string runLine, ref string exeFlags) | ||
36 | { | ||
37 | exePath = ""; | ||
38 | runLine = "secondlife"; | ||
39 | exeFlags = ""; | ||
40 | } | ||
41 | } | ||
42 | } | ||
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 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.IO; | ||
30 | using Microsoft.Win32; | ||
31 | |||
32 | namespace LaunchSLClient | ||
33 | { | ||
34 | public class WindowsConfig : MachineConfig | ||
35 | { | ||
36 | public override void GetClient(ref string exePath, ref string runLine, ref string exeFlags) | ||
37 | { | ||
38 | RegistryKey regKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Linden Research, Inc.\SecondLife"); | ||
39 | if (regKey == null) | ||
40 | { | ||
41 | regKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Wow6432Node\Linden Research, Inc.\SecondLife"); | ||
42 | if (regKey == null) | ||
43 | { | ||
44 | throw new LauncherException("Can't find Second Life. Are you sure it is installed?", "LauncherException.Form1"); | ||
45 | } | ||
46 | } | ||
47 | string exe = regKey.GetValue("Exe").ToString(); | ||
48 | exeFlags = regKey.GetValue("Flags").ToString(); | ||
49 | exePath = regKey.GetValue("").ToString(); | ||
50 | runLine = exePath + "\\" + exe; | ||
51 | Registry.LocalMachine.Flush(); | ||
52 | Registry.LocalMachine.Close(); | ||
53 | } | ||
54 | } | ||
55 | } | ||