1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include "osl/file.hxx"
23 #include "vendorbase.hxx"
34 MalformedVersionException::MalformedVersionException()
37 MalformedVersionException::MalformedVersionException(
38 const MalformedVersionException
& )
41 MalformedVersionException::~MalformedVersionException()
44 MalformedVersionException
&
45 MalformedVersionException::operator =(
46 const MalformedVersionException
&)
53 VendorBase::VendorBase(): m_bAccessibility(false)
57 bool VendorBase::initialize(vector
<pair
<OUString
, OUString
> > props
)
59 //get java.vendor, java.version, java.home,
60 //javax.accessibility.assistive_technologies from system properties
62 typedef vector
<pair
<OUString
, OUString
> >::const_iterator it_prop
;
63 OUString
sVendorProperty("java.vendor");
64 OUString
sVersionProperty("java.version");
65 OUString
sHomeProperty("java.home");
66 OUString
sAccessProperty("javax.accessibility.assistive_technologies");
68 bool bVersion
= false;
73 typedef vector
<pair
<OUString
, OUString
> >::const_iterator it_prop
;
74 for (it_prop i
= props
.begin(); i
!= props
.end(); ++i
)
76 if(! bVendor
&& sVendorProperty
.equals(i
->first
))
78 m_sVendor
= i
->second
;
81 else if (!bVersion
&& sVersionProperty
.equals(i
->first
))
83 m_sVersion
= i
->second
;
86 else if (!bHome
&& sHomeProperty
.equals(i
->first
))
88 #ifndef JVM_ONE_PATH_CHECK
90 if (osl_getFileURLFromSystemPath(i
->second
.pData
,& fileURL
.pData
) ==
93 //make sure that the drive letter have all the same case
94 //otherwise file:///c:/jre and file:///C:/jre produce two
95 //different objects!!!
96 if (makeDriveLetterSame( & fileURL
))
107 else if (!bAccess
&& sAccessProperty
.equals(i
->first
))
109 if (!i
->second
.isEmpty())
111 m_bAccessibility
= true;
115 // the javax.accessibility.xxx property may not be set. Therefore we
116 //must search through all properties.
119 if (!bVersion
|| !bVendor
|| !bHome
)
122 // init m_sRuntimeLibrary
123 OSL_ASSERT(!m_sHome
.isEmpty());
124 //call virtual function to get the possible paths to the runtime library.
127 char const* const* arRtPaths
= getRuntimePaths( & size
);
128 vector
<OUString
> libpaths
= getVectorFromCharArray(arRtPaths
, size
);
131 typedef vector
<OUString
>::const_iterator i_path
;
132 for(i_path ip
= libpaths
.begin(); ip
!= libpaths
.end(); ++ip
)
134 //Construct an absolute path to the possible runtime
135 OUString usRt
= m_sHome
+ *ip
;
137 if(DirectoryItem::get(usRt
, item
) == File::E_None
)
140 m_sRuntimeLibrary
= usRt
;
148 // init m_sLD_LIBRARY_PATH
149 OSL_ASSERT(!m_sHome
.isEmpty());
151 char const * const * arLDPaths
= getLibraryPaths( & size
);
152 vector
<OUString
> ld_paths
= getVectorFromCharArray(arLDPaths
, size
);
154 char arSep
[]= {SAL_PATHSEPARATOR
, 0};
155 OUString sPathSep
= OUString::createFromAscii(arSep
);
158 for(i_path il
= ld_paths
.begin(); il
!= ld_paths
.end(); ++il
, ++c
)
160 OUString usAbsUrl
= m_sHome
+ *il
;
161 // convert to system path
163 if(File::getSystemPathFromFileURL(usAbsUrl
, usSysPath
) == File::E_None
)
167 m_sLD_LIBRARY_PATH
+= sPathSep
;
168 m_sLD_LIBRARY_PATH
+= usSysPath
;
182 const OUString
& VendorBase::getVendor() const
186 const OUString
& VendorBase::getVersion() const
191 const OUString
& VendorBase::getHome() const
196 const OUString
& VendorBase::getLibraryPath() const
198 return m_sLD_LIBRARY_PATH
;
201 const OUString
& VendorBase::getRuntimeLibrary() const
203 return m_sRuntimeLibrary
;
205 bool VendorBase::supportsAccessibility() const
207 return m_bAccessibility
;
210 bool VendorBase::needsRestart() const
212 if (!getLibraryPath().isEmpty())
219 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */