741 |
10 Oct 06 |
olle |
1 |
/* |
1652 |
22 May 07 |
gregory |
$Id$ |
741 |
10 Oct 06 |
olle |
3 |
|
1916 |
31 Aug 07 |
jari |
Copyright (C) 2006 Olle Mansson |
1916 |
31 Aug 07 |
jari |
Copyright (C) 2007 Gregory Vincic |
741 |
10 Oct 06 |
olle |
6 |
|
1652 |
22 May 07 |
gregory |
This file is part of Proteios. |
1652 |
22 May 07 |
gregory |
Available at http://www.proteios.org/ |
741 |
10 Oct 06 |
olle |
9 |
|
1652 |
22 May 07 |
gregory |
Proteios is free software; you can redistribute it and/or modify it |
1652 |
22 May 07 |
gregory |
under the terms of the GNU General Public License as published by |
1652 |
22 May 07 |
gregory |
the Free Software Foundation; either version 2 of the License, or |
1652 |
22 May 07 |
gregory |
(at your option) any later version. |
741 |
10 Oct 06 |
olle |
14 |
|
1652 |
22 May 07 |
gregory |
Proteios is distributed in the hope that it will be useful, but |
1652 |
22 May 07 |
gregory |
WITHOUT ANY WARRANTY; without even the implied warranty of |
1652 |
22 May 07 |
gregory |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
1652 |
22 May 07 |
gregory |
General Public License for more details. |
741 |
10 Oct 06 |
olle |
19 |
|
1652 |
22 May 07 |
gregory |
You should have received a copy of the GNU General Public License |
1652 |
22 May 07 |
gregory |
along with this program; if not, write to the Free Software |
1652 |
22 May 07 |
gregory |
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
1652 |
22 May 07 |
gregory |
02111-1307, USA. |
1652 |
22 May 07 |
gregory |
24 |
*/ |
741 |
10 Oct 06 |
olle |
25 |
|
741 |
10 Oct 06 |
olle |
// Xerver Free Web Server |
741 |
10 Oct 06 |
olle |
// Copyright (C) 2002-2005 Omid Rouhani |
741 |
10 Oct 06 |
olle |
28 |
// |
741 |
10 Oct 06 |
olle |
29 |
// |
741 |
10 Oct 06 |
olle |
// This program is free software; you can redistribute it and/or |
741 |
10 Oct 06 |
olle |
// modify it under the terms of the GNU General Public License |
741 |
10 Oct 06 |
olle |
// as published by the Free Software Foundation; either version 2 |
741 |
10 Oct 06 |
olle |
// of the License, or (at your option) any later version. |
741 |
10 Oct 06 |
olle |
34 |
// |
741 |
10 Oct 06 |
olle |
// This program is distributed in the hope that it will be useful, |
741 |
10 Oct 06 |
olle |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
741 |
10 Oct 06 |
olle |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
741 |
10 Oct 06 |
olle |
// GNU General Public License for more details. |
741 |
10 Oct 06 |
olle |
39 |
// |
741 |
10 Oct 06 |
olle |
// You should have received a copy of the GNU General Public License |
741 |
10 Oct 06 |
olle |
// along with this program; if not, write to the Free Software |
741 |
10 Oct 06 |
olle |
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
741 |
10 Oct 06 |
olle |
43 |
// |
741 |
10 Oct 06 |
olle |
44 |
// |
741 |
10 Oct 06 |
olle |
45 |
// ############################################################# |
741 |
10 Oct 06 |
olle |
// ## YOU CAN CONTACT THE AUTHOR (OMID ROUHANI) AT: ## |
741 |
10 Oct 06 |
olle |
// ## HTTP://WWW.JAVASCRIPT.NU/XERVER/ ## |
741 |
10 Oct 06 |
olle |
48 |
// ## ## |
741 |
10 Oct 06 |
olle |
// ## IF YOUR SOFTWARE IS NOT RELEASED UNDER THE ## |
741 |
10 Oct 06 |
olle |
// ## GNU GENERAL PUBLIC LICENSE (GPL), ## |
741 |
10 Oct 06 |
olle |
// ## PLEASE DO NOT COPY ANYTHING FROM THIS SOURCE CODE!!! ## |
741 |
10 Oct 06 |
olle |
52 |
// ## ## |
741 |
10 Oct 06 |
olle |
// ## FOR FULL LICENSE, PLEASE READ "XERVER LICENSE". ## |
741 |
10 Oct 06 |
olle |
54 |
// ############################################################# |
741 |
10 Oct 06 |
olle |
55 |
|
1652 |
22 May 07 |
gregory |
56 |
package se.lu.thep.coreftpd.webserver; |
741 |
10 Oct 06 |
olle |
57 |
|
741 |
10 Oct 06 |
olle |
58 |
import java.io.BufferedReader; |
741 |
10 Oct 06 |
olle |
59 |
import java.io.File; |
741 |
10 Oct 06 |
olle |
60 |
import java.io.FileReader; |
741 |
10 Oct 06 |
olle |
61 |
|
741 |
10 Oct 06 |
olle |
62 |
/** |
1652 |
22 May 07 |
gregory |
63 |
* |
1652 |
22 May 07 |
gregory |
* <B>About this class:</B> <BR> |
1652 |
22 May 07 |
gregory |
* This class reads the config file and runs one of these lines: <BR> |
1652 |
22 May 07 |
gregory |
* <CODE>(new Thread(new XerverKernel(true,null))).start(); //no window</CODE> |
741 |
10 Oct 06 |
olle |
* <BR> |
1652 |
22 May 07 |
gregory |
* <CODE>(new Thread(new XerverKernel(false,null))).start(); //awt-window</CODE> |
741 |
10 Oct 06 |
olle |
* <BR> |
1652 |
22 May 07 |
gregory |
* <CODE>new ProgramWindow(); //Swing-window (NOT minimized at startup)</CODE> |
741 |
10 Oct 06 |
olle |
* <BR> |
1652 |
22 May 07 |
gregory |
* <CODE>new ProgramWindow(true); //Swing-window (minimized at startup)</CODE> |
1652 |
22 May 07 |
gregory |
73 |
* |
741 |
10 Oct 06 |
olle |
* @author <a href="http://www.JavaScript.nu/xerver/" TARGET="_top">Omid Rouhani</a> |
741 |
10 Oct 06 |
olle |
* @version 1.0 |
741 |
10 Oct 06 |
olle |
76 |
*/ |
741 |
10 Oct 06 |
olle |
77 |
|
741 |
10 Oct 06 |
olle |
78 |
final public class Start// extends JFrame implements ActionListener |
741 |
10 Oct 06 |
olle |
79 |
{ |
741 |
10 Oct 06 |
olle |
80 |
private int i_howToStartXerver; |
741 |
10 Oct 06 |
olle |
81 |
|
1652 |
22 May 07 |
gregory |
82 |
private String hiddenFolder = "data" + File.separator; |
1652 |
22 May 07 |
gregory |
83 |
|
1652 |
22 May 07 |
gregory |
84 |
private String errorFilesFolder = "errorHTML" + File.separator; |
1652 |
22 May 07 |
gregory |
85 |
|
1652 |
22 May 07 |
gregory |
86 |
private String s_configFile = hiddenFolder + "Xerver.cfg"; |
1652 |
22 May 07 |
gregory |
87 |
|
1652 |
22 May 07 |
gregory |
88 |
public static void main(String[] s) { |
1652 |
22 May 07 |
gregory |
89 |
/* |
1652 |
22 May 07 |
gregory |
* try { // UIManager.setLookAndFeel( // |
1652 |
22 May 07 |
gregory |
* UIManager.getCrossPlatformLookAndFeelClassName()); |
1652 |
22 May 07 |
gregory |
* UIManager.setLookAndFeel( |
1652 |
22 May 07 |
gregory |
* "com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); //Try to use |
1652 |
22 May 07 |
gregory |
* Windows interface } catch (Exception e) { } |
1652 |
22 May 07 |
gregory |
95 |
*/ |
741 |
10 Oct 06 |
olle |
96 |
new Start(); |
741 |
10 Oct 06 |
olle |
97 |
} |
741 |
10 Oct 06 |
olle |
98 |
|
1652 |
22 May 07 |
gregory |
99 |
public Start() { |
741 |
10 Oct 06 |
olle |
100 |
this(-1); |
741 |
10 Oct 06 |
olle |
101 |
} |
1652 |
22 May 07 |
gregory |
102 |
|
1652 |
22 May 07 |
gregory |
103 |
public Start(int choice) { |
741 |
10 Oct 06 |
olle |
104 |
getServerDefaults(); |
741 |
10 Oct 06 |
olle |
105 |
|
1652 |
22 May 07 |
gregory |
106 |
if (choice != -1) { |
1652 |
22 May 07 |
gregory |
107 |
if (choice == 0) |
1652 |
22 May 07 |
gregory |
108 |
(new Thread(new XerverKernel(true, null))).start(); // Start |
1652 |
22 May 07 |
gregory |
// with no |
1652 |
22 May 07 |
gregory |
// window |
1652 |
22 May 07 |
gregory |
111 |
else if (choice == 1) |
1652 |
22 May 07 |
gregory |
112 |
(new Thread(new XerverKernel(false, null))).start(); // Start |
1652 |
22 May 07 |
gregory |
// with |
1652 |
22 May 07 |
gregory |
// a |
1652 |
22 May 07 |
gregory |
// basic |
1652 |
22 May 07 |
gregory |
// AWT-window |
1652 |
22 May 07 |
gregory |
117 |
else if (choice == 2) |
1652 |
22 May 07 |
gregory |
118 |
new ProgramWindow(); // Start with an advanced Swing-window |
1652 |
22 May 07 |
gregory |
// (NOT minimized at startup) |
1652 |
22 May 07 |
gregory |
120 |
else if (choice == 3) |
1652 |
22 May 07 |
gregory |
121 |
new ProgramWindow(true); // Start with an advanced |
1652 |
22 May 07 |
gregory |
// Swing-window (minimized at |
1652 |
22 May 07 |
gregory |
// startup) |
1652 |
22 May 07 |
gregory |
124 |
} else { |
1652 |
22 May 07 |
gregory |
125 |
if (i_howToStartXerver == 0) |
1652 |
22 May 07 |
gregory |
126 |
(new Thread(new XerverKernel(true, null))).start(); // Start |
1652 |
22 May 07 |
gregory |
// with no |
1652 |
22 May 07 |
gregory |
// window |
1652 |
22 May 07 |
gregory |
129 |
else if (i_howToStartXerver == 1) |
1652 |
22 May 07 |
gregory |
130 |
(new Thread(new XerverKernel(false, null))).start(); // Start |
1652 |
22 May 07 |
gregory |
// with |
1652 |
22 May 07 |
gregory |
// a |
1652 |
22 May 07 |
gregory |
// basic |
1652 |
22 May 07 |
gregory |
// AWT-window |
1652 |
22 May 07 |
gregory |
135 |
else if (i_howToStartXerver == 2) |
1652 |
22 May 07 |
gregory |
136 |
new ProgramWindow(); // Start with an advanced Swing-window |
1652 |
22 May 07 |
gregory |
// (NOT minimized at startup) |
1652 |
22 May 07 |
gregory |
138 |
else if (i_howToStartXerver == 3) |
1652 |
22 May 07 |
gregory |
139 |
new ProgramWindow(true); // Start with an advanced |
1652 |
22 May 07 |
gregory |
// Swing-window (minimized at |
1652 |
22 May 07 |
gregory |
// startup) |
741 |
10 Oct 06 |
olle |
142 |
} |
741 |
10 Oct 06 |
olle |
143 |
} |
741 |
10 Oct 06 |
olle |
144 |
|
741 |
10 Oct 06 |
olle |
145 |
/** |
1652 |
22 May 07 |
gregory |
* Read line 12 in the "Xerver.cfg" file (<CODE>s_configFile</CODE>) and |
1652 |
22 May 07 |
gregory |
* put the (integer) value at that line into <CODE>i_howToStartXerver</CODE>. |
1652 |
22 May 07 |
gregory |
148 |
*/ |
1652 |
22 May 07 |
gregory |
149 |
public void getServerDefaults() { |
1652 |
22 May 07 |
gregory |
150 |
String tmpStr = ""; |
741 |
10 Oct 06 |
olle |
151 |
|
1652 |
22 May 07 |
gregory |
// *********READ SETTINGS FROM FILE!******* |
1652 |
22 May 07 |
gregory |
153 |
try { |
1652 |
22 May 07 |
gregory |
154 |
BufferedReader f_setupFileData = new BufferedReader(new FileReader( |
1652 |
22 May 07 |
gregory |
155 |
s_configFile)); |
741 |
10 Oct 06 |
olle |
156 |
|
1652 |
22 May 07 |
gregory |
157 |
for (int i = 1; i <= 12; i++) |
1652 |
22 May 07 |
gregory |
158 |
tmpStr = f_setupFileData.readLine(); // read line 12 (line |
1652 |
22 May 07 |
gregory |
// 12=information xerver |
1652 |
22 May 07 |
gregory |
// user interface) |
1652 |
22 May 07 |
gregory |
161 |
i_howToStartXerver = Integer.parseInt(tmpStr); |
741 |
10 Oct 06 |
olle |
162 |
|
741 |
10 Oct 06 |
olle |
163 |
f_setupFileData.close(); |
1652 |
22 May 07 |
gregory |
164 |
} catch (Exception e) { |
1652 |
22 May 07 |
gregory |
165 |
System.out.println("An error occured!\nPlease make sure that " |
1652 |
22 May 07 |
gregory |
166 |
+ s_configFile |
1652 |
22 May 07 |
gregory |
167 |
+ " is in the data-directory (in your Xerver folder).\n" |
1652 |
22 May 07 |
gregory |
168 |
+ e); |
741 |
10 Oct 06 |
olle |
169 |
System.exit(0); |
741 |
10 Oct 06 |
olle |
170 |
} |
741 |
10 Oct 06 |
olle |
171 |
} |
741 |
10 Oct 06 |
olle |
172 |
} |