1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_plugin.hxx"
26 
27 #include "vendorlist.hxx"
28 #include "gnujre.hxx"
29 #include "sunjre.hxx"
30 #include "otherjre.hxx"
31 #include "osl/thread.h"
32 #include <stdio.h>
33 
34 using namespace com::sun::star::uno;
35 using namespace rtl;
36 
37 namespace jfw_plugin
38 {
39 
40 /* Note: The vendor strings must be UTF-8. For example, if
41    the string contains an a umlaut then it must be expressed
42    by "\xXX\xXX"
43  */
44 BEGIN_VENDOR_MAP()
45     VENDOR_MAP_ENTRY("Oracle Corporation", SunInfo)
46     VENDOR_MAP_ENTRY("Sun Microsystems Inc.", SunInfo)
47     VENDOR_MAP_ENTRY("IBM Corporation", OtherInfo)
48     VENDOR_MAP_ENTRY("Blackdown Java-Linux Team", OtherInfo)
49     VENDOR_MAP_ENTRY("Apple Inc.", OtherInfo)
50     VENDOR_MAP_ENTRY("Apple Computer, Inc.", OtherInfo)
51     VENDOR_MAP_ENTRY("BEA Systems, Inc.", OtherInfo)
52     VENDOR_MAP_ENTRY("Free Software Foundation, Inc.", GnuInfo)
53     VENDOR_MAP_ENTRY("The FreeBSD Foundation", OtherInfo)
54     VENDOR_MAP_ENTRY("AdoptOpenJDK", OtherInfo)
55     VENDOR_MAP_ENTRY("OpenJDK", SunInfo)
END_VENDOR_MAP()56 END_VENDOR_MAP()
57 
58 
59 Sequence<OUString> getVendorNames()
60 {
61     const size_t count = sizeof(gVendorMap) / sizeof (VendorSupportMapEntry) - 1;
62     OUString arNames[count];
63     for ( size_t pos = 0; pos < count; ++pos )
64     {
65         OString sVendor(gVendorMap[pos].sVendorName);
66         arNames[pos] = OStringToOUString(sVendor, RTL_TEXTENCODING_UTF8);
67     }
68     return Sequence<OUString>(arNames, count);
69 }
70 
isVendorSupported(const rtl::OUString & sVendor)71 bool isVendorSupported(const rtl::OUString& sVendor)
72 {
73     Sequence<OUString> seqNames = getVendorNames();
74     const OUString * arNames = seqNames.getConstArray();
75     sal_Int32 count = seqNames.getLength();
76 
77     for (int i = 0; i < count; i++)
78     {
79         if (sVendor.equals(arNames[i]))
80             return true;
81     }
82 #if OSL_DEBUG_LEVEL >= 2
83     OString sVendorName = OUStringToOString(sVendor, osl_getThreadTextEncoding());
84     fprintf(stderr, "[Java frameworksunjavaplugin.so]sunjavaplugin does not support vendor: %s.\n",
85             sVendorName.getStr());
86 #endif
87     return false;
88 }
89 
90 }
91