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