xref: /aoo41x/main/jvmfwk/source/fwkutil.hxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir #if !defined INCLUDED_JVMFWK_FWKUTIL_HXX
28*cdf0e10cSrcweir #define INCLUDED_JVMFWK_FWKUTIL_HXX
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir #include "sal/config.h"
31*cdf0e10cSrcweir #include "osl/mutex.hxx"
32*cdf0e10cSrcweir #include "rtl/bootstrap.hxx"
33*cdf0e10cSrcweir #include "rtl/instance.hxx"
34*cdf0e10cSrcweir #include "rtl/ustrbuf.hxx"
35*cdf0e10cSrcweir #include "rtl/byteseq.hxx"
36*cdf0e10cSrcweir #include "osl/thread.hxx"
37*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL >=2
38*cdf0e10cSrcweir #include <stdio.h>
39*cdf0e10cSrcweir #endif
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir 
42*cdf0e10cSrcweir namespace jfw
43*cdf0e10cSrcweir {
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir /** Returns the file URL of the directory where the framework library
46*cdf0e10cSrcweir     (this library) resides.
47*cdf0e10cSrcweir */
48*cdf0e10cSrcweir rtl::OUString getLibraryLocation();
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir /** provides a bootstrap class which already knows the values from the
51*cdf0e10cSrcweir     jvmfkwrc file.
52*cdf0e10cSrcweir */
53*cdf0e10cSrcweir struct Bootstrap :
54*cdf0e10cSrcweir 	public ::rtl::StaticWithInit< const rtl::Bootstrap *, Bootstrap > {
55*cdf0e10cSrcweir 		const rtl::Bootstrap * operator () () {
56*cdf0e10cSrcweir             ::rtl::OUStringBuffer buf(256);
57*cdf0e10cSrcweir             buf.append(getLibraryLocation());
58*cdf0e10cSrcweir             buf.appendAscii(SAL_CONFIGFILE("/jvmfwk3"));
59*cdf0e10cSrcweir             ::rtl::OUString sIni = buf.makeStringAndClear();
60*cdf0e10cSrcweir             ::rtl::Bootstrap *  bootstrap = new ::rtl::Bootstrap(sIni);
61*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL >=2
62*cdf0e10cSrcweir         rtl::OString o = rtl::OUStringToOString( sIni , osl_getThreadTextEncoding() );
63*cdf0e10cSrcweir         fprintf(stderr, "[Java framework] Using configuration file %s\n" , o.getStr() );
64*cdf0e10cSrcweir #endif
65*cdf0e10cSrcweir         return bootstrap;
66*cdf0e10cSrcweir     }
67*cdf0e10cSrcweir };
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir struct FwkMutex: public ::rtl::Static<osl::Mutex, FwkMutex> {};
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir //osl::Mutex * getFwkMutex();
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir rtl::ByteSequence encodeBase16(const rtl::ByteSequence& rawData);
74*cdf0e10cSrcweir rtl::ByteSequence decodeBase16(const rtl::ByteSequence& data);
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir rtl::OUString getPlatform();
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir //const rtl::Bootstrap& getBootstrap();
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir 
81*cdf0e10cSrcweir rtl::OUString getDirFromFile(const rtl::OUString& usFilePath);
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir /** Returns the file URL of the folder where the executable resides.
84*cdf0e10cSrcweir  */
85*cdf0e10cSrcweir rtl::OUString getExecutableDirectory();
86*cdf0e10cSrcweir /** Locates the plugin library and returns the file URL.
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir     First tries to locate plugin relative to baseUrl (if relative);
89*cdf0e10cSrcweir     vnd.sun.star.expand URLs are supported.  If that fails, tries to
90*cdf0e10cSrcweir     locate plugin relative to the executable.  If that fails, and plugin
91*cdf0e10cSrcweir     contains no slashes, tries to locate plugin in a platform-specific way
92*cdf0e10cSrcweir     (e.g., LD_LIBRARY_PATH).
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir     @param baseUrl
95*cdf0e10cSrcweir     The base file URL relative to which the plugin argument is interpreted.
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir     @param plugin
98*cdf0e10cSrcweir     The argument is an absolute or relative URL or just the name of the plugin.
99*cdf0e10cSrcweir  */
100*cdf0e10cSrcweir rtl::OUString findPlugin(
101*cdf0e10cSrcweir     const rtl::OUString & baseUrl, const rtl::OUString & plugin);
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir enum FileStatus
105*cdf0e10cSrcweir {
106*cdf0e10cSrcweir     FILE_OK,
107*cdf0e10cSrcweir     FILE_DOES_NOT_EXIST,
108*cdf0e10cSrcweir     FILE_INVALID
109*cdf0e10cSrcweir };
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir /** checks if the URL is a file.
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir     If it is a link to a file than
114*cdf0e10cSrcweir     it is resolved. Assuming that the argument
115*cdf0e10cSrcweir     represents a relative URL then FILE_INVALID
116*cdf0e10cSrcweir     is returned.
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir 
119*cdf0e10cSrcweir     @return
120*cdf0e10cSrcweir     one of the values of FileStatus.
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir     @exception
123*cdf0e10cSrcweir     Errors occured during determining if the file exists
124*cdf0e10cSrcweir  */
125*cdf0e10cSrcweir FileStatus checkFileURL(const rtl::OUString & path);
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir struct PluginLibrary;
129*cdf0e10cSrcweir class VersionInfo;
130*cdf0e10cSrcweir class CJavaInfo;
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir bool isAccessibilitySupportDesired();
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir rtl::OUString buildClassPathFromDirectory(const rtl::OUString & relPath);
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir rtl::OUString retrieveClassPath( ::rtl::OUString const & macro );
137*cdf0e10cSrcweir }
138*cdf0e10cSrcweir #endif
139