1*36f55ffcSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*36f55ffcSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*36f55ffcSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*36f55ffcSAndrew Rist  * distributed with this work for additional information
6*36f55ffcSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*36f55ffcSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*36f55ffcSAndrew Rist  * "License"); you may not use this file except in compliance
9*36f55ffcSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*36f55ffcSAndrew Rist  *
11*36f55ffcSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*36f55ffcSAndrew Rist  *
13*36f55ffcSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*36f55ffcSAndrew Rist  * software distributed under the License is distributed on an
15*36f55ffcSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*36f55ffcSAndrew Rist  * KIND, either express or implied.  See the License for the
17*36f55ffcSAndrew Rist  * specific language governing permissions and limitations
18*36f55ffcSAndrew Rist  * under the License.
19*36f55ffcSAndrew Rist  *
20*36f55ffcSAndrew Rist  *************************************************************/
21*36f55ffcSAndrew Rist 
22*36f55ffcSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_jvmfwk.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "osl/thread.h"
28cdf0e10cSrcweir #include "sunjre.hxx"
29cdf0e10cSrcweir #include "sunversion.hxx"
30cdf0e10cSrcweir #include "diagnostics.h"
31cdf0e10cSrcweir 
32cdf0e10cSrcweir using namespace rtl;
33cdf0e10cSrcweir using namespace std;
34cdf0e10cSrcweir 
35cdf0e10cSrcweir #define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
36cdf0e10cSrcweir namespace jfw_plugin
37cdf0e10cSrcweir {
38cdf0e10cSrcweir 
39cdf0e10cSrcweir Reference<VendorBase> SunInfo::createInstance()
40cdf0e10cSrcweir {
41cdf0e10cSrcweir     return new SunInfo;
42cdf0e10cSrcweir }
43cdf0e10cSrcweir 
44cdf0e10cSrcweir char const* const* SunInfo::getJavaExePaths(int * size)
45cdf0e10cSrcweir {
46cdf0e10cSrcweir     static char const * ar[] = {
47cdf0e10cSrcweir #if defined(WNT) || defined(OS2)
48cdf0e10cSrcweir         "java.exe",
49cdf0e10cSrcweir         "bin/java.exe",
50cdf0e10cSrcweir         "jre/bin/java.exe"
51cdf0e10cSrcweir #elif UNX
52cdf0e10cSrcweir         "java",
53cdf0e10cSrcweir         "bin/java",
54cdf0e10cSrcweir         "jre/bin/java"
55cdf0e10cSrcweir #endif
56cdf0e10cSrcweir     };
57cdf0e10cSrcweir         *size = sizeof (ar) / sizeof (char*);
58cdf0e10cSrcweir     return ar;
59cdf0e10cSrcweir }
60cdf0e10cSrcweir 
61cdf0e10cSrcweir char const* const* SunInfo::getRuntimePaths(int * size)
62cdf0e10cSrcweir {
63cdf0e10cSrcweir     static char const* ar[]= {
64cdf0e10cSrcweir #if defined(WNT)
65cdf0e10cSrcweir         "/bin/client/jvm.dll",
66cdf0e10cSrcweir         "/bin/hotspot/jvm.dll",
67cdf0e10cSrcweir         "/bin/classic/jvm.dll"
68cdf0e10cSrcweir #elif defined(OS2)
69cdf0e10cSrcweir         "/bin/classic/jvm.dll",
70cdf0e10cSrcweir #elif UNX
71cdf0e10cSrcweir         "/lib/" JFW_PLUGIN_ARCH "/client/libjvm.so",
72cdf0e10cSrcweir         "/lib/" JFW_PLUGIN_ARCH "/server/libjvm.so",
73cdf0e10cSrcweir         "/lib/" JFW_PLUGIN_ARCH "/classic/libjvm.so"
74cdf0e10cSrcweir #endif
75cdf0e10cSrcweir 
76cdf0e10cSrcweir     };
77cdf0e10cSrcweir     *size = sizeof(ar) / sizeof (char*);
78cdf0e10cSrcweir     return ar;
79cdf0e10cSrcweir }
80cdf0e10cSrcweir 
81cdf0e10cSrcweir char const* const* SunInfo::getLibraryPaths(int* size)
82cdf0e10cSrcweir {
83cdf0e10cSrcweir #ifdef UNX
84cdf0e10cSrcweir     static char const * ar[] = {
85cdf0e10cSrcweir 
86cdf0e10cSrcweir         "/lib/" JFW_PLUGIN_ARCH "/client",
87cdf0e10cSrcweir         "/lib/" JFW_PLUGIN_ARCH "/native_threads",
88cdf0e10cSrcweir         "/lib/" JFW_PLUGIN_ARCH
89cdf0e10cSrcweir 
90cdf0e10cSrcweir     };
91cdf0e10cSrcweir     *size = sizeof(ar) / sizeof (char*);
92cdf0e10cSrcweir     return ar;
93cdf0e10cSrcweir #else
94cdf0e10cSrcweir     size = 0;
95cdf0e10cSrcweir     return NULL;
96cdf0e10cSrcweir #endif
97cdf0e10cSrcweir }
98cdf0e10cSrcweir 
99cdf0e10cSrcweir int SunInfo::compareVersions(const rtl::OUString& sSecond) const
100cdf0e10cSrcweir {
101cdf0e10cSrcweir     OUString sFirst = getVersion();
102cdf0e10cSrcweir 
103cdf0e10cSrcweir     SunVersion version1(sFirst);
104cdf0e10cSrcweir     JFW_ENSURE(version1, OUSTR("[Java framework] sunjavaplugin"SAL_DLLEXTENSION
105cdf0e10cSrcweir                                " does not know the version: ")
106cdf0e10cSrcweir                + sFirst + OUSTR(" as valid for a SUN JRE."));
107cdf0e10cSrcweir     SunVersion version2(sSecond);
108cdf0e10cSrcweir     if ( ! version2)
109cdf0e10cSrcweir         throw MalformedVersionException();
110cdf0e10cSrcweir 
111cdf0e10cSrcweir     if(version1 == version2)
112cdf0e10cSrcweir         return 0;
113cdf0e10cSrcweir     if(version1 > version2)
114cdf0e10cSrcweir         return 1;
115cdf0e10cSrcweir     else
116cdf0e10cSrcweir         return -1;
117cdf0e10cSrcweir }
118cdf0e10cSrcweir 
119cdf0e10cSrcweir 
120cdf0e10cSrcweir }
121