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