1 /* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is Sun Microsystems.
18 * Portions created by the Initial Developer are Copyright (C) 2003
19 * the Initial Developer. All Rights Reserved.
22 * Pete Zha <pete.zha@sun.com> (original author)
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
38 #ifndef nsJVMConfigManagerUnix_h___
39 #define nsJVMConfigManagerUnix_h___
41 #include "nsJVMConfigManager.h"
43 #include "nsILineInputStream.h"
44 #include "nsHashtable.h"
46 #include "nsILocalFile.h"
47 #include "nsIFileStreams.h"
49 class nsJVMConfigManagerUnix
: public nsIJVMConfigManager
53 NS_DECL_NSIJVMCONFIGMANAGER
55 nsJVMConfigManagerUnix();
56 virtual ~nsJVMConfigManagerUnix();
59 nsresult
InitJVMConfigList();
61 void ClearJVMConfigList();
63 nsresult
InitJVMConfigList(nsILineInputStream
* aGlobal
,
64 nsILineInputStream
* aPrivate
);
67 * Parse a stream for information about Java installation(s).
69 nsresult
ParseStream(nsILineInputStream
* aStream
);
72 * Parse a line for information about a Java installation, and ensure its
73 * JVMConfig is in our JVMConfigList."
74 * A line looks like this:
75 * "version=1.4.2 | type=jre | os=linux | arch=i386 | ......"
78 nsresult
ParseLine(nsAString
& aLine
);
81 * Search for Java installations in the default location.
83 nsresult
SearchDefault();
86 * Search a specific directory to see if there are Java installations.
88 nsresult
SearchDirectory(nsAString
& aDirName
);
91 * Add a directory to the Java configuration list if
92 * it contains a java installation.
94 nsresult
AddDirectory(nsIFile
* aHomeDir
);
96 nsresult
AddDirectory(nsAString
& aHomeDirName
);
99 * Get a value by specific key from the line. A line should look like this:
100 * key=value | key2=value2 | key3=value3
101 * Please see the proposal in bug 185000 for more detail about the format.
103 static PRBool
GetValueFromLine(nsAString
& aLine
, const char* aKey
,
106 static nsresult
GetLineInputStream(nsIFile
* aFile
,
107 nsILineInputStream
** _retval
);
110 * Get value of mozilla<version>.plugin.path from a line
112 static nsresult
GetMozillaPluginPath(nsAString
& aLine
, nsAString
& _retval
);
115 * Get agent version by string
117 static nsresult
GetAgentVersion(nsCAutoString
& _retval
);
120 * Get agent version by float
122 static nsresult
GetAgentVersion(float* _retval
);
124 static nsresult
GetNSVersion(nsAString
& _retval
);
127 * Check for existing arch directory.
129 static PRBool
TestArch(nsILocalFile
* aPluginPath
, nsAString
& aArch
);
132 * Check for existing NS version directory.
134 static PRBool
TestNSVersion(nsILocalFile
* aArchPath
, nsAString
& aNSVersion
);
137 * Test if a specific node in the base directory exists.
139 static PRBool
TestExists(nsILocalFile
* aBaseDir
, nsAString
& aSubName
);
142 * The table to store the config list.
144 nsHashtable mJVMConfigList
;
147 #endif // nsJVMConfigManagerUnix_h___