Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
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/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
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 .
18 : : */
19 : : #ifndef INCLUDED_JVMFWK_FWKUTIL_HXX
20 : : #define INCLUDED_JVMFWK_FWKUTIL_HXX
21 : :
22 : : #include "sal/config.h"
23 : : #include "osl/mutex.hxx"
24 : : #include "rtl/bootstrap.hxx"
25 : : #include "rtl/instance.hxx"
26 : : #include "rtl/ustrbuf.hxx"
27 : : #include "rtl/byteseq.hxx"
28 : : #include "osl/thread.hxx"
29 : : #if OSL_DEBUG_LEVEL >=2
30 : : #include <stdio.h>
31 : : #endif
32 : :
33 : :
34 : : namespace jfw
35 : : {
36 : :
37 : : /** Returns the file URL of the directory where the framework library
38 : : (this library) resides.
39 : : */
40 : : rtl::OUString getLibraryLocation();
41 : :
42 : : /** provides a bootstrap class which already knows the values from the
43 : : jvmfkwrc file.
44 : : */
45 : : struct Bootstrap :
46 : : public ::rtl::StaticWithInit< const rtl::Bootstrap *, Bootstrap > {
47 : 105 : const rtl::Bootstrap * operator () () {
48 : 105 : ::rtl::OUStringBuffer buf(256);
49 [ + - ][ + - ]: 105 : buf.append(getLibraryLocation());
50 [ + - ]: 105 : buf.appendAscii(SAL_CONFIGFILE("/jvmfwk3"));
51 [ + - ]: 105 : ::rtl::OUString sIni = buf.makeStringAndClear();
52 [ + - ]: 105 : ::rtl::Bootstrap * bootstrap = new ::rtl::Bootstrap(sIni);
53 : : #if OSL_DEBUG_LEVEL >=2
54 : : rtl::OString o = rtl::OUStringToOString( sIni , osl_getThreadTextEncoding() );
55 : : fprintf(stderr, "[Java framework] Using configuration file %s\n" , o.getStr() );
56 : : #endif
57 : 105 : return bootstrap;
58 : : }
59 : : };
60 : :
61 : : struct FwkMutex: public ::rtl::Static<osl::Mutex, FwkMutex> {};
62 : :
63 : : rtl::ByteSequence encodeBase16(const rtl::ByteSequence& rawData);
64 : : rtl::ByteSequence decodeBase16(const rtl::ByteSequence& data);
65 : :
66 : : rtl::OUString getPlatform();
67 : :
68 : :
69 : : rtl::OUString getDirFromFile(const rtl::OUString& usFilePath);
70 : :
71 : : /** Returns the file URL of the folder where the executable resides.
72 : : */
73 : : rtl::OUString getExecutableDirectory();
74 : : /** Locates the plugin library and returns the file URL.
75 : :
76 : : First tries to locate plugin relative to baseUrl (if relative);
77 : : vnd.sun.star.expand URLs are supported. If that fails, tries to
78 : : locate plugin relative to the executable. If that fails, and plugin
79 : : contains no slashes, tries to locate plugin in a platform-specific way
80 : : (e.g., LD_LIBRARY_PATH).
81 : :
82 : : @param baseUrl
83 : : The base file URL relative to which the plugin argument is interpreted.
84 : :
85 : : @param plugin
86 : : The argument is an absolute or relative URL or just the name of the plugin.
87 : : */
88 : : rtl::OUString findPlugin(
89 : : const rtl::OUString & baseUrl, const rtl::OUString & plugin);
90 : :
91 : :
92 : : enum FileStatus
93 : : {
94 : : FILE_OK,
95 : : FILE_DOES_NOT_EXIST,
96 : : FILE_INVALID
97 : : };
98 : :
99 : : /** checks if the URL is a file.
100 : :
101 : : If it is a link to a file than
102 : : it is resolved. Assuming that the argument
103 : : represents a relative URL then FILE_INVALID
104 : : is returned.
105 : :
106 : :
107 : : @return
108 : : one of the values of FileStatus.
109 : :
110 : : @exception
111 : : Errors occurred during determining if the file exists
112 : : */
113 : : FileStatus checkFileURL(const rtl::OUString & path);
114 : :
115 : : bool isAccessibilitySupportDesired();
116 : :
117 : : rtl::OUString buildClassPathFromDirectory(const rtl::OUString & relPath);
118 : :
119 : : rtl::OUString retrieveClassPath( ::rtl::OUString const & macro );
120 : : }
121 : : #endif
122 : :
123 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|