Update ooo320-m1
[ooovba.git] / jvmfwk / plugins / sunmajor / pluginlib / util.hxx
blobffd0b72f2030d96b82f2cb0c39fcdcb60da283aa
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: util.hxx,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #if !defined INCLUDED_JFW_PLUGIN_UTIL_HXX
31 #define INCLUDED_JFW_PLUGIN_UTIL_HXX
33 #include "rtl/ustring.hxx"
34 #include "rtl/bootstrap.hxx"
35 #include <vector>
36 #include "vendorbase.hxx"
38 namespace jfw_plugin
41 class VendorBase;
42 std::vector<rtl::OUString> getVectorFromCharArray(char const * const * ar, int size);
44 /* The function uses the relative paths, such as "bin/java.exe" as provided by
45 VendorBase::getJavaExePaths and the provided path to derive the the home directory.
46 The home directory is then used as argument to getJREInfoByPath. For example
47 usBinDir is file:///c:/j2sdk/jre/bin then file:///c:/j2sdk/jre would be derived.
49 bool getJREInfoFromBinPath(
50 const rtl::OUString& path, std::vector<rtl::Reference<VendorBase> > & vecInfos);
51 inline rtl::OUString getDirFromFile(const rtl::OUString& usFilePath);
52 void createJavaInfoFromPath(std::vector<rtl::Reference<VendorBase> >& vecInfos);
53 void createJavaInfoFromJavaHome(std::vector<rtl::Reference<VendorBase> > &vecInfos);
54 void createJavaInfoDirScan(std::vector<rtl::Reference<VendorBase> >& vecInfos);
55 #ifdef WNT
56 void createJavaInfoFromWinReg(std::vector<rtl::Reference<VendorBase> >& vecInfos);
57 #endif
59 bool makeDriveLetterSame(rtl::OUString * fileURL);
62 /* for std::find_if
63 Used to find a JavaInfo::Impl object in a std::vector<Impl*> which has a member usJavaHome
64 as the specified string in the constructor.
66 struct InfoFindSame
68 rtl::OUString sJava;
69 InfoFindSame(const rtl::OUString& sJavaHome):sJava(sJavaHome){}
71 bool operator () (const rtl::Reference<VendorBase> & aVendorInfo)
73 return aVendorInfo->getHome().equals(sJava) == sal_True ? true : false;
77 struct SameOrSubDirJREMap
79 rtl::OUString s1;
80 SameOrSubDirJREMap(const rtl::OUString& s):s1(s){
83 bool operator () (const std::pair<const rtl::OUString, rtl::Reference<VendorBase> > & s2)
85 if (s1 == s2.first)
86 return true;
87 rtl::OUString sSub;
88 sSub = s2.first + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/"));
89 if (s1.match(sSub) == sal_True)
90 return true;
91 return false;
96 /* Creates a VendorBase object if a JRE could be found at the specified path.
98 This depends if there is a JRE at all and if it is from a vendor that
99 is supported by this plugin.
101 rtl::Reference<VendorBase> getJREInfoByPath(const rtl::OUString& path);
103 /* Creates a VendorBase object if a JRE could be found at the specified path.
105 The difference to the other getJREInfoByPath is that this function checks
106 first if the path corresponds to one of the VendorBase::getHome path already
107 contained in vecInfo. Only if there is no such entry, then the other
108 getJREInfoByPath is called. Again the created VendorBase is compared to
109 those contained in vecInfos. If it it not in there then it's added.
111 @return
112 true a VendorBase was created and added to the end of vecInfos.
113 false - no VendorBase has been created. Either the path did not represent a
114 supported JRE installation or there was already a VendorBase in vecInfos.
116 bool getJREInfoByPath(const rtl::OUString& path,
117 std::vector<rtl::Reference<VendorBase> > & vecInfos);
119 std::vector<rtl::Reference<VendorBase> > getAllJREInfos();
121 bool getJavaProps(
122 const rtl::OUString & exePath,
123 std::vector<std::pair<rtl::OUString, rtl::OUString> >& props,
124 bool * bProcessRun);
126 void createJavaInfoFromWinReg(std::vector<rtl::Reference<VendorBase> > & vecInfos);
128 void bubbleSortVersion(std::vector<rtl::Reference<VendorBase> >& vec);
130 rtl::Bootstrap* getBootstrap();
133 #endif