aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Tools/LaunchSLClient/Form1.cs
diff options
context:
space:
mode:
authorJeff Ames2008-02-15 03:30:15 +0000
committerJeff Ames2008-02-15 03:30:15 +0000
commite16f9a16c77aca017ddd3413d6ff84d3a3ee7364 (patch)
tree8cae2a7880b784ee80fc7c836136c785045e366e /OpenSim/Tools/LaunchSLClient/Form1.cs
parentMove pCampBot prebuild.xml into main prebuild.xml to fix reference errors. U... (diff)
downloadopensim-SC-e16f9a16c77aca017ddd3413d6ff84d3a3ee7364.zip
opensim-SC-e16f9a16c77aca017ddd3413d6ff84d3a3ee7364.tar.gz
opensim-SC-e16f9a16c77aca017ddd3413d6ff84d3a3ee7364.tar.bz2
opensim-SC-e16f9a16c77aca017ddd3413d6ff84d3a3ee7364.tar.xz
Moved LaunchSLClient prebuild.xml into main prebuild.xml
Diffstat (limited to 'OpenSim/Tools/LaunchSLClient/Form1.cs')
-rw-r--r--OpenSim/Tools/LaunchSLClient/Form1.cs211
1 files changed, 211 insertions, 0 deletions
diff --git a/OpenSim/Tools/LaunchSLClient/Form1.cs b/OpenSim/Tools/LaunchSLClient/Form1.cs
new file mode 100644
index 0000000..183a104
--- /dev/null
+++ b/OpenSim/Tools/LaunchSLClient/Form1.cs
@@ -0,0 +1,211 @@
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
29using System;
30using System.IO;
31using System.Collections;
32using System.Collections.Generic;
33using System.ComponentModel;
34using System.Data;
35using System.Diagnostics;
36using System.Drawing;
37using System.Text;
38using System.Text.RegularExpressions;
39using System.Windows.Forms;
40using Microsoft.Win32;
41
42namespace LaunchSLClient
43{
44 public partial class Form1 : Form
45 {
46 const string deepGridUrl = "http://user.deepgrid.com:8002/";
47 const string osGridUrl = "http://www.osgrid.org:8002/";
48 const string openLifeGridUrl = "http://logingrid.net:8002";
49
50 string gridUrl = "";
51 string sandboxUrl = "";
52 string runUrl = "";
53 string runLine = "";
54 string exeFlags = "";
55 string exePath = "";
56
57 private void addLocalSandbox(ref ArrayList menuItems)
58 {
59 // build sandbox URL from Regions\default.xml
60 // this is highly dependant on a standard default.xml
61 if (File.Exists(@"Regions\default.xml"))
62 {
63 string sandboxHostName = "";
64 string sandboxPort = "";
65 string text;
66
67 Regex myRegex = new Regex(".*internal_ip_port=\\\"(?<port>.*?)\\\".*external_host_name=\\\"(?<name>.*?)\\\".*");
68
69 FileInfo defaultFile = new FileInfo(@"Regions\default.xml");
70 StreamReader stream = defaultFile.OpenText();
71 do
72 {
73 text = stream.ReadLine();
74 if (text == null)
75 {
76 break;
77 }
78 MatchCollection theMatches = myRegex.Matches(text);
79 foreach (Match theMatch in theMatches)
80 {
81 if (theMatch.Length != 0)
82 {
83 sandboxHostName = theMatch.Groups["name"].ToString();
84 sandboxPort = theMatch.Groups["port"].ToString();
85 }
86 }
87 } while (text != null);
88
89 stream.Close();
90 sandboxUrl = "http:\\" + sandboxHostName + ":" + sandboxPort;
91 menuItems.Add("Local Sandbox");
92 }
93 }
94
95 private void addLocalGrid(ref ArrayList menuItems)
96 {
97 //build local grid URL from network_servers_information.xml
98 // this is highly dependant on a standard default.xml
99 if (File.Exists(@"network_servers_information.xml"))
100 {
101 string text;
102 FileInfo defaultFile = new FileInfo(@"network_servers_information.xml");
103 Regex myRegex = new Regex(".*UserServerURL=\\\"(?<url>.*?)\\\".*");
104 StreamReader stream = defaultFile.OpenText();
105
106 do
107 {
108 text = stream.ReadLine();
109 if (text == null)
110 {
111 break;
112 }
113 foreach (Match theMatch in myRegex.Matches(text))
114 {
115 if (theMatch.Length != 0)
116 {
117 gridUrl = theMatch.Groups["url"].ToString();
118 }
119 }
120 } while (text != null);
121 stream.Close();
122 if (gridUrl != null)
123 {
124 menuItems.Add("Local Grid Server");
125 }
126 }
127 }
128
129 private void addLocalSims(ref ArrayList menuItems)
130 {
131 // find opensim directory
132 RegistryKey exeKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\OpenSim\OpenSim");
133 if (exeKey != null)
134 {
135 Object simPath = exeKey.GetValue("Path");
136
137 Directory.SetCurrentDirectory(simPath.ToString()); //this should be set to wherever we decide to put the binaries
138
139 addLocalSandbox(ref menuItems);
140 addLocalGrid(ref menuItems);
141 }
142 else
143 {
144 MessageBox.Show("No OpenSim installed. Showing public grids only", "No OpenSim");
145 }
146 }
147
148 private void getClient(ref string exePath, ref string runLine, ref string exeFlags)
149 {
150 // get executable path from registry
151 RegistryKey regKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Linden Research, Inc.\SecondLife");
152 if (regKey == null)
153 {
154 regKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Wow6432Node\Linden Research, Inc.\SecondLife");
155 if (regKey == null)
156 {
157 throw new LauncherException("Can't find Second Life. Are you sure it is installed?", "LauncherException.Form1");
158 }
159 }
160 string exe = regKey.GetValue("Exe").ToString();
161 exeFlags = regKey.GetValue("Flags").ToString();
162 exePath = regKey.GetValue("").ToString();
163 runLine = exePath + "\\" + exe;
164 Registry.LocalMachine.Flush();
165 Registry.LocalMachine.Close();
166 }
167
168 public Form1()
169 {
170 InitializeComponent();
171 ArrayList menuItems = new ArrayList();
172
173 getClient(ref exePath, ref runLine, ref exeFlags);
174
175 menuItems.Add("Please select one:");
176
177 addLocalSims(ref menuItems);
178
179 menuItems.Add("OSGrid - www.osgrid.org");
180 menuItems.Add("DeepGrid - www.deepgrid.com");
181 menuItems.Add("OpenlifeGrid - www.openlifegrid.com");
182 menuItems.Add("Linden Labs - www.secondlife.com");
183
184 comboBox1.DataSource = menuItems;
185 }
186
187 private void radioButton1_CheckedChanged(object sender, EventArgs e)
188 {
189 }
190
191 private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
192 {
193 if (comboBox1.Text == "Please select one:") { return; }
194 if (comboBox1.Text == "Local Sandbox") { runUrl=" -loginuri " + sandboxUrl;}
195 if (comboBox1.Text == "Local Grid Server") { runUrl = " -loginuri " + gridUrl; }
196 if (comboBox1.Text == "DeepGrid - www.deepgrid.com") { runUrl = " -loginuri " + deepGridUrl; }
197 if (comboBox1.Text == "OSGrid - www.osgrid.org") { runUrl = " -loginuri " + osGridUrl; }
198 if (comboBox1.Text == "OpenlifeGrid - www.openlifegrid.com") { runUrl = " -loginuri " + openLifeGridUrl; }
199 if (comboBox1.Text == "Linden Labs - www.secondlife.com") { runUrl = ""; }
200
201 System.Diagnostics.Process proc = new System.Diagnostics.Process();
202 proc.StartInfo.FileName = runLine;
203 proc.StartInfo.Arguments = exeFlags.ToString() + " " + runUrl;
204 proc.StartInfo.UseShellExecute = false;
205 proc.StartInfo.RedirectStandardOutput = false;
206 proc.StartInfo.WorkingDirectory = exePath.ToString();
207 proc.Start();
208 proc.WaitForExit();
209 }
210 }
211}