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