xref: /aoo41x/main/jvmfwk/source/fwkutil.hxx (revision 5ac42e1f)
1*5ac42e1fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*5ac42e1fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*5ac42e1fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*5ac42e1fSAndrew Rist  * distributed with this work for additional information
6*5ac42e1fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*5ac42e1fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*5ac42e1fSAndrew Rist  * "License"); you may not use this file except in compliance
9*5ac42e1fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*5ac42e1fSAndrew Rist  *
11*5ac42e1fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*5ac42e1fSAndrew Rist  *
13*5ac42e1fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*5ac42e1fSAndrew Rist  * software distributed under the License is distributed on an
15*5ac42e1fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*5ac42e1fSAndrew Rist  * KIND, either express or implied.  See the License for the
17*5ac42e1fSAndrew Rist  * specific language governing permissions and limitations
18*5ac42e1fSAndrew Rist  * under the License.
19*5ac42e1fSAndrew Rist  *
20*5ac42e1fSAndrew Rist  *************************************************************/
21*5ac42e1fSAndrew Rist 
22*5ac42e1fSAndrew Rist 
23cdf0e10cSrcweir #if !defined INCLUDED_JVMFWK_FWKUTIL_HXX
24cdf0e10cSrcweir #define INCLUDED_JVMFWK_FWKUTIL_HXX
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include "sal/config.h"
27cdf0e10cSrcweir #include "osl/mutex.hxx"
28cdf0e10cSrcweir #include "rtl/bootstrap.hxx"
29cdf0e10cSrcweir #include "rtl/instance.hxx"
30cdf0e10cSrcweir #include "rtl/ustrbuf.hxx"
31cdf0e10cSrcweir #include "rtl/byteseq.hxx"
32cdf0e10cSrcweir #include "osl/thread.hxx"
33cdf0e10cSrcweir #if OSL_DEBUG_LEVEL >=2
34cdf0e10cSrcweir #include <stdio.h>
35cdf0e10cSrcweir #endif
36cdf0e10cSrcweir 
37cdf0e10cSrcweir 
38cdf0e10cSrcweir namespace jfw
39cdf0e10cSrcweir {
40cdf0e10cSrcweir 
41cdf0e10cSrcweir /** Returns the file URL of the directory where the framework library
42cdf0e10cSrcweir     (this library) resides.
43cdf0e10cSrcweir */
44cdf0e10cSrcweir rtl::OUString getLibraryLocation();
45cdf0e10cSrcweir 
46cdf0e10cSrcweir /** provides a bootstrap class which already knows the values from the
47cdf0e10cSrcweir     jvmfkwrc file.
48cdf0e10cSrcweir */
49cdf0e10cSrcweir struct Bootstrap :
50cdf0e10cSrcweir 	public ::rtl::StaticWithInit< const rtl::Bootstrap *, Bootstrap > {
operator ()jfw::Bootstrap51cdf0e10cSrcweir 		const rtl::Bootstrap * operator () () {
52cdf0e10cSrcweir             ::rtl::OUStringBuffer buf(256);
53cdf0e10cSrcweir             buf.append(getLibraryLocation());
54cdf0e10cSrcweir             buf.appendAscii(SAL_CONFIGFILE("/jvmfwk3"));
55cdf0e10cSrcweir             ::rtl::OUString sIni = buf.makeStringAndClear();
56cdf0e10cSrcweir             ::rtl::Bootstrap *  bootstrap = new ::rtl::Bootstrap(sIni);
57cdf0e10cSrcweir #if OSL_DEBUG_LEVEL >=2
58cdf0e10cSrcweir         rtl::OString o = rtl::OUStringToOString( sIni , osl_getThreadTextEncoding() );
59cdf0e10cSrcweir         fprintf(stderr, "[Java framework] Using configuration file %s\n" , o.getStr() );
60cdf0e10cSrcweir #endif
61cdf0e10cSrcweir         return bootstrap;
62cdf0e10cSrcweir     }
63cdf0e10cSrcweir };
64cdf0e10cSrcweir 
65cdf0e10cSrcweir struct FwkMutex: public ::rtl::Static<osl::Mutex, FwkMutex> {};
66cdf0e10cSrcweir 
67cdf0e10cSrcweir //osl::Mutex * getFwkMutex();
68cdf0e10cSrcweir 
69cdf0e10cSrcweir rtl::ByteSequence encodeBase16(const rtl::ByteSequence& rawData);
70cdf0e10cSrcweir rtl::ByteSequence decodeBase16(const rtl::ByteSequence& data);
71cdf0e10cSrcweir 
72cdf0e10cSrcweir rtl::OUString getPlatform();
73cdf0e10cSrcweir 
74cdf0e10cSrcweir //const rtl::Bootstrap& getBootstrap();
75cdf0e10cSrcweir 
76cdf0e10cSrcweir 
77cdf0e10cSrcweir rtl::OUString getDirFromFile(const rtl::OUString& usFilePath);
78cdf0e10cSrcweir 
79cdf0e10cSrcweir /** Returns the file URL of the folder where the executable resides.
80cdf0e10cSrcweir  */
81cdf0e10cSrcweir rtl::OUString getExecutableDirectory();
82cdf0e10cSrcweir /** Locates the plugin library and returns the file URL.
83cdf0e10cSrcweir 
84cdf0e10cSrcweir     First tries to locate plugin relative to baseUrl (if relative);
85cdf0e10cSrcweir     vnd.sun.star.expand URLs are supported.  If that fails, tries to
86cdf0e10cSrcweir     locate plugin relative to the executable.  If that fails, and plugin
87cdf0e10cSrcweir     contains no slashes, tries to locate plugin in a platform-specific way
88cdf0e10cSrcweir     (e.g., LD_LIBRARY_PATH).
89cdf0e10cSrcweir 
90cdf0e10cSrcweir     @param baseUrl
91cdf0e10cSrcweir     The base file URL relative to which the plugin argument is interpreted.
92cdf0e10cSrcweir 
93cdf0e10cSrcweir     @param plugin
94cdf0e10cSrcweir     The argument is an absolute or relative URL or just the name of the plugin.
95cdf0e10cSrcweir  */
96cdf0e10cSrcweir rtl::OUString findPlugin(
97cdf0e10cSrcweir     const rtl::OUString & baseUrl, const rtl::OUString & plugin);
98cdf0e10cSrcweir 
99cdf0e10cSrcweir 
100cdf0e10cSrcweir enum FileStatus
101cdf0e10cSrcweir {
102cdf0e10cSrcweir     FILE_OK,
103cdf0e10cSrcweir     FILE_DOES_NOT_EXIST,
104cdf0e10cSrcweir     FILE_INVALID
105cdf0e10cSrcweir };
106cdf0e10cSrcweir 
107cdf0e10cSrcweir /** checks if the URL is a file.
108cdf0e10cSrcweir 
109cdf0e10cSrcweir     If it is a link to a file than
110cdf0e10cSrcweir     it is resolved. Assuming that the argument
111cdf0e10cSrcweir     represents a relative URL then FILE_INVALID
112cdf0e10cSrcweir     is returned.
113cdf0e10cSrcweir 
114cdf0e10cSrcweir 
115cdf0e10cSrcweir     @return
116cdf0e10cSrcweir     one of the values of FileStatus.
117cdf0e10cSrcweir 
118cdf0e10cSrcweir     @exception
119cdf0e10cSrcweir     Errors occured during determining if the file exists
120cdf0e10cSrcweir  */
121cdf0e10cSrcweir FileStatus checkFileURL(const rtl::OUString & path);
122cdf0e10cSrcweir 
123cdf0e10cSrcweir 
124cdf0e10cSrcweir struct PluginLibrary;
125cdf0e10cSrcweir class VersionInfo;
126cdf0e10cSrcweir class CJavaInfo;
127cdf0e10cSrcweir 
128cdf0e10cSrcweir bool isAccessibilitySupportDesired();
129cdf0e10cSrcweir 
130cdf0e10cSrcweir rtl::OUString buildClassPathFromDirectory(const rtl::OUString & relPath);
131cdf0e10cSrcweir 
132cdf0e10cSrcweir rtl::OUString retrieveClassPath( ::rtl::OUString const & macro );
133cdf0e10cSrcweir }
134cdf0e10cSrcweir #endif
135