Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 : #ifndef INCLUDED_JVMFWK_PLUGINS_SUNMAJOR_PLUGINLIB_UTIL_HXX
20 : #define INCLUDED_JVMFWK_PLUGINS_SUNMAJOR_PLUGINLIB_UTIL_HXX
21 :
22 : #include "rtl/ustring.hxx"
23 : #include "rtl/bootstrap.hxx"
24 : #include <vector>
25 : #include "vendorbase.hxx"
26 :
27 : namespace jfw_plugin
28 : {
29 :
30 : class VendorBase;
31 : std::vector<OUString> getVectorFromCharArray(char const * const * ar, int size);
32 :
33 : /* The function uses the relative paths, such as "bin/java.exe" and the provided
34 : path to derive the home directory. The home directory is then used as
35 : argument to getJREInfoByPath. For example usBinDir is
36 : file:///c:/j2sdk/jre/bin then file:///c:/j2sdk/jre would be derived.
37 : */
38 : bool getJREInfoFromBinPath(
39 : const OUString& path, std::vector<rtl::Reference<VendorBase> > & vecInfos);
40 : inline OUString getDirFromFile(const OUString& usFilePath);
41 : void createJavaInfoFromPath(std::vector<rtl::Reference<VendorBase> >& vecInfos);
42 : void createJavaInfoFromJavaHome(std::vector<rtl::Reference<VendorBase> > &vecInfos);
43 : void createJavaInfoDirScan(std::vector<rtl::Reference<VendorBase> >& vecInfos);
44 : #ifdef WNT
45 : void createJavaInfoFromWinReg(std::vector<rtl::Reference<VendorBase> >& vecInfos);
46 : #endif
47 :
48 : bool makeDriveLetterSame(OUString * fileURL);
49 :
50 :
51 : /* for std::find_if
52 : Used to find a JavaInfo::Impl object in a std::vector<Impl*> which has a member usJavaHome
53 : as the specified string in the constructor.
54 : */
55 4032 : struct InfoFindSame
56 : {
57 : OUString sJava;
58 448 : InfoFindSame(const OUString& sJavaHome):sJava(sJavaHome){}
59 :
60 420 : bool operator () (const rtl::Reference<VendorBase> & aVendorInfo)
61 : {
62 420 : return aVendorInfo->getHome().equals(sJava);
63 : }
64 : };
65 :
66 14436 : struct SameOrSubDirJREMap
67 : {
68 : OUString s1;
69 1604 : SameOrSubDirJREMap(const OUString& s):s1(s){
70 1604 : }
71 :
72 4008 : bool operator () (const std::pair<const OUString, rtl::Reference<VendorBase> > & s2)
73 : {
74 4008 : if (s1 == s2.first)
75 298 : return true;
76 3710 : OUString sSub;
77 3710 : sSub = s2.first + OUString("/");
78 3710 : if (s1.match(sSub))
79 168 : return true;
80 3542 : return false;
81 : }
82 : };
83 :
84 :
85 : /* Creates a VendorBase object if a JRE could be found at the specified path.
86 :
87 : This depends if there is a JRE at all and if it is from a vendor that
88 : is supported by this plugin.
89 : */
90 : rtl::Reference<VendorBase> getJREInfoByPath(const OUString& path);
91 :
92 : /* Creates a VendorBase object if a JRE could be found at the specified path.
93 :
94 : The difference to the other getJREInfoByPath is that this function checks
95 : first if the path corresponds to one of the VendorBase::getHome path already
96 : contained in vecInfo. Only if there is no such entry, then the other
97 : getJREInfoByPath is called. Again the created VendorBase is compared to
98 : those contained in vecInfos. If it it not in there then it's added.
99 :
100 : @return
101 : true a VendorBase was created and added to the end of vecInfos.
102 : false - no VendorBase has been created. Either the path did not represent a
103 : supported JRE installation or there was already a VendorBase in vecInfos.
104 : */
105 : bool getJREInfoByPath(const OUString& path,
106 : std::vector<rtl::Reference<VendorBase> > & vecInfos);
107 :
108 : std::vector<rtl::Reference<VendorBase> > getAllJREInfos();
109 :
110 : bool getJavaProps(
111 : const OUString & exePath,
112 : #ifdef JVM_ONE_PATH_CHECK
113 : const OUString & homePath,
114 : #endif
115 : std::vector<std::pair<OUString, OUString> >& props,
116 : bool * bProcessRun);
117 :
118 : void createJavaInfoFromWinReg(std::vector<rtl::Reference<VendorBase> > & vecInfos);
119 :
120 : void bubbleSortVersion(std::vector<rtl::Reference<VendorBase> >& vec);
121 :
122 : rtl::Bootstrap* getBootstrap();
123 : }
124 :
125 : #endif
126 :
127 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|