2001-07-06 06:17:45 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
|
|
|
* $RCSfile: bootstrap.cxx,v $
|
|
|
|
*
|
2003-04-15 16:20:15 +00:00
|
|
|
* $Revision: 1.14 $
|
2001-07-06 06:17:45 +00:00
|
|
|
*
|
2003-04-15 16:20:15 +00:00
|
|
|
* last change: $Author: vg $ $Date: 2003-04-15 17:20:15 $
|
2001-07-06 06:17:45 +00:00
|
|
|
*
|
|
|
|
* The Contents of this file are made available subject to the terms of
|
|
|
|
* either of the following licenses
|
|
|
|
*
|
|
|
|
* - GNU Lesser General Public License Version 2.1
|
|
|
|
* - Sun Industry Standards Source License Version 1.1
|
|
|
|
*
|
|
|
|
* Sun Microsystems Inc., October, 2000
|
|
|
|
*
|
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
* =============================================
|
|
|
|
* Copyright 2000 by Sun Microsystems, Inc.
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License version 2.1, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Sun Industry Standards Source License Version 1.1
|
|
|
|
* =================================================
|
|
|
|
* The contents of this file are subject to the Sun Industry Standards
|
|
|
|
* Source License Version 1.1 (the "License"); You may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of the
|
|
|
|
* License at http://www.openoffice.org/license.html.
|
|
|
|
*
|
|
|
|
* Software provided under this License is provided on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
|
|
|
|
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
|
|
|
|
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
|
|
|
|
* See the License for the specific provisions governing your rights and
|
|
|
|
* obligations concerning the Software.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
|
|
|
|
*
|
|
|
|
* Copyright: 2000 by Sun Microsystems, Inc.
|
|
|
|
*
|
|
|
|
* All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s): _______________________________________
|
|
|
|
*
|
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "unotools/bootstrap.hxx"
|
|
|
|
|
2001-08-02 09:30:29 +00:00
|
|
|
// ---------------------------------------------------------------------------------------
|
2001-07-06 06:17:45 +00:00
|
|
|
#ifndef _RTL_USTRING_HXX_
|
|
|
|
#include <rtl/ustring.hxx>
|
|
|
|
#endif
|
2001-08-02 09:30:29 +00:00
|
|
|
#ifndef _RTL_USTRBUF_HXX_
|
|
|
|
#include <rtl/ustrbuf.hxx>
|
2001-07-06 06:17:45 +00:00
|
|
|
#endif
|
2001-08-02 09:30:29 +00:00
|
|
|
|
2001-07-06 06:17:45 +00:00
|
|
|
#ifndef _OSL_FILE_HXX_
|
|
|
|
#include <osl/file.hxx>
|
|
|
|
#endif
|
2001-08-02 09:30:29 +00:00
|
|
|
#ifndef _OSL_MUTEX_HXX_
|
|
|
|
#include <osl/mutex.hxx>
|
|
|
|
#endif
|
|
|
|
|
2001-07-06 06:17:45 +00:00
|
|
|
#ifndef _OSL_DIAGNOSE_H_
|
|
|
|
#include <osl/diagnose.h>
|
|
|
|
#endif
|
2001-08-02 09:30:29 +00:00
|
|
|
// ---------------------------------------------------------------------------------------
|
2001-09-14 11:08:46 +00:00
|
|
|
|
2001-11-02 11:15:30 +00:00
|
|
|
#ifndef _RTL_BOOTSTRAP_HXX_
|
|
|
|
#include <rtl/bootstrap.hxx>
|
2001-07-06 06:17:45 +00:00
|
|
|
#endif
|
2001-08-02 09:30:29 +00:00
|
|
|
#ifndef _OSL_PROCESS_H_
|
|
|
|
#include <osl/process.h> // for osl_getExecutableFile
|
2001-07-06 06:17:45 +00:00
|
|
|
#endif
|
2001-11-02 11:15:30 +00:00
|
|
|
|
2001-08-02 09:30:29 +00:00
|
|
|
// ---------------------------------------------------------------------------------------
|
2001-11-02 11:15:30 +00:00
|
|
|
// #define this to a non-zero value, if remembering defaults is not supported properly
|
|
|
|
#define RTL_BOOTSTRAP_DEFAULTS_BROKEN 1
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------------------
|
|
|
|
#define BOOTSTRAP_DATA_NAME SAL_CONFIGFILE("bootstrap")
|
2001-07-06 06:17:45 +00:00
|
|
|
|
|
|
|
#define BOOTSTRAP_ITEM_PRODUCT_KEY "ProductKey"
|
2001-11-20 13:35:52 +00:00
|
|
|
#define BOOTSTRAP_ITEM_VERSIONFILE "Location"
|
2001-07-06 06:17:45 +00:00
|
|
|
#define BOOTSTRAP_ITEM_LOGO "Logo"
|
2001-11-19 15:10:54 +00:00
|
|
|
#define BOOTSTRAP_ITEM_BUILDID "buildid"
|
2001-12-06 08:59:43 +00:00
|
|
|
#define BOOTSTRAP_ITEM_INSTALLMODE "InstallMode"
|
2001-07-06 06:17:45 +00:00
|
|
|
|
2001-11-02 11:15:30 +00:00
|
|
|
#define BOOTSTRAP_ITEM_BASEINSTALLATION "BaseInstallation"
|
|
|
|
#define BOOTSTRAP_ITEM_USERINSTALLATION "UserInstallation"
|
|
|
|
|
|
|
|
#define BOOTSTRAP_ITEM_SHAREDIR "SharedDataDir"
|
|
|
|
#define BOOTSTRAP_ITEM_USERDIR "UserDataDir"
|
|
|
|
|
2002-06-04 09:31:45 +00:00
|
|
|
#define BOOTSTRAP_ITEM_PRODUCT_PATCH_LEVEL "ProductPatch"
|
|
|
|
|
2001-11-02 11:15:30 +00:00
|
|
|
#define BOOTSTRAP_DEFAULT_BASEINSTALL "$SYSBINDIR/.."
|
|
|
|
|
|
|
|
#define BOOTSTRAP_DIRNAME_SHAREDIR "share"
|
|
|
|
#define BOOTSTRAP_DIRNAME_USERDIR "user"
|
|
|
|
|
|
|
|
#define VERSIONFILE_SECTION "Versions"
|
2001-08-02 09:30:29 +00:00
|
|
|
// ---------------------------------------------------------------------------------------
|
|
|
|
typedef char const * AsciiString;
|
|
|
|
// ---------------------------------------------------------------------------------------
|
2001-07-06 06:17:45 +00:00
|
|
|
|
2001-08-02 09:30:29 +00:00
|
|
|
namespace utl
|
|
|
|
{
|
|
|
|
// ---------------------------------------------------------------------------------------
|
|
|
|
using ::rtl::OUString;
|
|
|
|
using ::rtl::OUStringBuffer;
|
|
|
|
using ::rtl::OString;
|
2001-07-06 06:17:45 +00:00
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------------------
|
2001-08-02 09:30:29 +00:00
|
|
|
// Implementation class: Bootstrap::Impl
|
|
|
|
// ---------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class Bootstrap::Impl
|
|
|
|
{
|
2001-11-02 11:15:30 +00:00
|
|
|
OUString const m_aImplName;
|
2001-08-02 09:30:29 +00:00
|
|
|
public: // struct to cache the result of a path lookup
|
|
|
|
struct PathData
|
|
|
|
{
|
|
|
|
OUString path;
|
|
|
|
PathStatus status;
|
|
|
|
|
|
|
|
PathData()
|
|
|
|
: path()
|
|
|
|
, status(DATA_UNKNOWN)
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
public: // data members
|
|
|
|
// base install data
|
|
|
|
PathData aBaseInstall_;
|
|
|
|
|
|
|
|
// user install data
|
|
|
|
PathData aUserInstall_;
|
|
|
|
|
2001-11-02 11:15:30 +00:00
|
|
|
// INI files
|
|
|
|
PathData aBootstrapINI_;
|
|
|
|
PathData aVersionINI_;
|
|
|
|
|
2001-08-02 09:30:29 +00:00
|
|
|
// overall status
|
|
|
|
Status status_;
|
|
|
|
|
|
|
|
public: // construction and initialization
|
2001-11-02 11:15:30 +00:00
|
|
|
explicit
|
|
|
|
Impl(OUString const& _aImplName)
|
|
|
|
: m_aImplName(_aImplName)
|
2001-08-02 09:30:29 +00:00
|
|
|
{
|
|
|
|
status_ = initialize();
|
|
|
|
}
|
|
|
|
|
|
|
|
Status initialize();
|
2001-07-06 06:17:45 +00:00
|
|
|
|
2001-11-02 11:15:30 +00:00
|
|
|
// access helper
|
|
|
|
OUString getBootstrapValue(OUString const& _sName, OUString const& _sDefault) const;
|
|
|
|
|
|
|
|
OUString getImplName() const { return m_aImplName; }
|
2001-07-06 06:17:45 +00:00
|
|
|
|
2001-08-02 09:30:29 +00:00
|
|
|
private: // implementation
|
2001-11-02 11:15:30 +00:00
|
|
|
bool initBaseInstallationData(rtl::Bootstrap& _rData);
|
|
|
|
bool initUserInstallationData(rtl::Bootstrap& _rData);
|
2001-08-02 09:30:29 +00:00
|
|
|
};
|
2001-11-06 14:44:11 +00:00
|
|
|
// ---------------------------------------------------------------------------------------
|
|
|
|
static OUString getExecutableDirectory();
|
2001-07-06 06:17:45 +00:00
|
|
|
// ---------------------------------------------------------------------------------------
|
2001-08-02 09:30:29 +00:00
|
|
|
Bootstrap::Impl const& Bootstrap::data()
|
|
|
|
{
|
|
|
|
static Impl* s_pData = NULL;
|
|
|
|
|
|
|
|
if (!s_pData)
|
|
|
|
{
|
|
|
|
using namespace osl;
|
|
|
|
MutexGuard aGuard( Mutex::getGlobalMutex() );
|
|
|
|
|
2001-11-06 14:44:11 +00:00
|
|
|
static Impl s_theData(getExecutableDirectory() + OUString(RTL_CONSTASCII_USTRINGPARAM("/"BOOTSTRAP_DATA_NAME)));
|
2001-07-06 06:17:45 +00:00
|
|
|
|
2001-08-02 09:30:29 +00:00
|
|
|
s_pData = &s_theData;
|
|
|
|
}
|
|
|
|
return *s_pData;
|
|
|
|
}
|
2001-07-06 06:17:45 +00:00
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------------------
|
2001-08-02 09:30:29 +00:00
|
|
|
// helper
|
|
|
|
// ---------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
typedef Bootstrap::PathStatus PathStatus;
|
2001-07-06 06:17:45 +00:00
|
|
|
|
2001-08-02 09:30:29 +00:00
|
|
|
sal_Unicode const cURLSeparator = '/';
|
2001-07-06 06:17:45 +00:00
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------------------
|
2001-08-02 09:30:29 +00:00
|
|
|
static
|
|
|
|
inline
|
|
|
|
OUString getURLSeparator()
|
2001-07-06 06:17:45 +00:00
|
|
|
{
|
2001-08-02 09:30:29 +00:00
|
|
|
static OUString theSep(&cURLSeparator,1);
|
|
|
|
return theSep;
|
|
|
|
}
|
2001-07-06 06:17:45 +00:00
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------------------
|
2001-08-02 09:30:29 +00:00
|
|
|
// path status utility function
|
|
|
|
static
|
2001-09-25 09:27:16 +00:00
|
|
|
PathStatus implCheckStatusOfURL(OUString const& _sURL, osl::DirectoryItem& aDirItem)
|
2001-07-06 06:17:45 +00:00
|
|
|
{
|
2001-08-02 09:30:29 +00:00
|
|
|
using namespace osl;
|
|
|
|
|
|
|
|
PathStatus eStatus = Bootstrap::DATA_UNKNOWN;
|
|
|
|
|
|
|
|
if (_sURL.getLength() != 0)
|
2001-07-06 06:17:45 +00:00
|
|
|
{
|
2001-09-25 09:27:16 +00:00
|
|
|
switch( DirectoryItem::get(_sURL, aDirItem) )
|
2001-08-02 09:30:29 +00:00
|
|
|
{
|
|
|
|
case DirectoryItem::E_None: // Success
|
|
|
|
eStatus = Bootstrap::PATH_EXISTS;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DirectoryItem::E_NOENT: // No such file or directory<br>
|
|
|
|
eStatus = Bootstrap::PATH_VALID;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DirectoryItem::E_INVAL: // the format of the parameters was not valid<br>
|
|
|
|
case DirectoryItem::E_NAMETOOLONG: // File name too long<br>
|
|
|
|
case DirectoryItem::E_NOTDIR: // A component of the path prefix of path is not a directory<p>
|
|
|
|
eStatus = Bootstrap::DATA_INVALID;
|
|
|
|
break;
|
|
|
|
|
|
|
|
// how to handle these ?
|
|
|
|
case DirectoryItem::E_LOOP: // Too many symbolic links encountered<br>
|
|
|
|
case DirectoryItem::E_ACCES: // permission denied<br>
|
|
|
|
// any other error - what to do ?
|
|
|
|
default:
|
|
|
|
eStatus = Bootstrap::DATA_UNKNOWN;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
eStatus = Bootstrap::DATA_MISSING;
|
2001-07-06 06:17:45 +00:00
|
|
|
|
2001-08-02 09:30:29 +00:00
|
|
|
return eStatus;
|
2001-07-06 06:17:45 +00:00
|
|
|
}
|
2001-09-25 09:27:16 +00:00
|
|
|
// ---------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
static
|
|
|
|
bool implNormalizeURL(OUString & _sURL, osl::DirectoryItem& aDirItem)
|
|
|
|
{
|
|
|
|
using namespace osl;
|
|
|
|
|
|
|
|
OSL_PRECOND(aDirItem.is(), "Opened DirItem required");
|
|
|
|
|
|
|
|
static const sal_uInt32 cFileStatusMask = FileStatusMask_FileURL;
|
|
|
|
|
|
|
|
FileStatus aFileStatus(cFileStatusMask);
|
|
|
|
|
|
|
|
if (aDirItem.getFileStatus(aFileStatus) != DirectoryItem::E_None)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
OUString aNormalizedURL = aFileStatus.getFileURL();
|
|
|
|
|
|
|
|
if (aNormalizedURL.getLength() == 0)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
_sURL = aNormalizedURL;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------------------
|
2001-11-02 11:15:30 +00:00
|
|
|
static
|
|
|
|
bool implEnsureAbsolute(OUString & _rsURL) // also strips embedded dots !!
|
|
|
|
{
|
|
|
|
using osl::File;
|
|
|
|
|
|
|
|
OUString sBasePath = _rsURL;
|
|
|
|
OSL_VERIFY(osl_Process_E_None == osl_getProcessWorkingDir(&sBasePath.pData));
|
|
|
|
|
|
|
|
OUString sAbsolute;
|
|
|
|
if ( File::E_None == File::getAbsoluteFileURL(sBasePath, _rsURL, sAbsolute))
|
|
|
|
{
|
|
|
|
_rsURL = sAbsolute;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
OSL_ENSURE(false, "Could not get absolute file URL for URL");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* old code to strip embedded dots
|
|
|
|
static OUString const sDots(RTL_CONSTASCII_USTRINGPARAM("/.."));
|
|
|
|
|
|
|
|
sal_Int32 nDotsIndex = _rsURL.indexOf(sDots);
|
|
|
|
while (nDotsIndex >= 0)
|
|
|
|
{
|
|
|
|
OSL_ASSERT(_rsURL.indexOf(sDots) == nDotsIndex);
|
|
|
|
|
|
|
|
sal_Int32 nStripIndex = _rsURL.lastIndexOf(cURLSeparator,nDotsIndex);
|
|
|
|
if (nStripIndex < 0 || nStripIndex+1 == nDotsIndex)
|
|
|
|
{
|
|
|
|
OSL_TRACE("Invalid use of dots in bootstrap URL");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
_rsURL = _rsURL.copy(0,nStripIndex) + _rsURL.copy(nDotsIndex + sDots.getLength());
|
|
|
|
|
|
|
|
nDotsIndex = _rsURL.indexOf(sDots,nStripIndex);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
*/
|
|
|
|
// ---------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
static
|
|
|
|
bool implMakeAbsoluteURL(OUString & _rsPathOrURL)
|
|
|
|
{
|
|
|
|
using namespace osl;
|
|
|
|
|
|
|
|
bool bURL;
|
|
|
|
|
|
|
|
OUString sOther;
|
|
|
|
// check if it already was normalized
|
|
|
|
if ( File::E_None == File::getSystemPathFromFileURL(_rsPathOrURL, sOther) )
|
|
|
|
{
|
|
|
|
bURL = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
else if ( File::E_None == File::getFileURLFromSystemPath(_rsPathOrURL, sOther) )
|
|
|
|
{
|
|
|
|
_rsPathOrURL = sOther;
|
|
|
|
bURL = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
bURL = false;
|
|
|
|
|
|
|
|
return bURL && implEnsureAbsolute(_rsPathOrURL);
|
|
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------------------
|
2003-04-15 16:20:15 +00:00
|
|
|
#if OSL_DEBUG_LEVEL > 0
|
2001-09-25 09:27:16 +00:00
|
|
|
static
|
|
|
|
PathStatus dbgCheckStatusOfURL(OUString const& _sURL)
|
|
|
|
{
|
|
|
|
using namespace osl;
|
|
|
|
|
|
|
|
DirectoryItem aDirItem;
|
|
|
|
|
|
|
|
return implCheckStatusOfURL(_sURL,aDirItem);
|
|
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------------------
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static
|
|
|
|
bool normalizeURL(OUString & _sURL)
|
|
|
|
{
|
|
|
|
using namespace osl;
|
|
|
|
|
|
|
|
DirectoryItem aDirItem;
|
|
|
|
|
|
|
|
bool bResult = DirectoryItem::get(_sURL, aDirItem) == DirectoryItem::E_None;
|
|
|
|
|
|
|
|
if ( bResult )
|
|
|
|
bResult = implNormalizeURL(_sURL,aDirItem);
|
|
|
|
|
|
|
|
return bResult;
|
|
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
static
|
|
|
|
PathStatus checkStatusAndNormalizeURL(OUString & _sURL)
|
|
|
|
{
|
|
|
|
using namespace osl;
|
|
|
|
|
2001-11-02 11:15:30 +00:00
|
|
|
PathStatus eStatus = Bootstrap::DATA_UNKNOWN;
|
|
|
|
|
|
|
|
if (_sURL.getLength() == 0)
|
|
|
|
eStatus = Bootstrap::DATA_MISSING;
|
2001-09-25 09:27:16 +00:00
|
|
|
|
2001-11-02 11:15:30 +00:00
|
|
|
else if ( !implMakeAbsoluteURL(_sURL) )
|
|
|
|
eStatus = Bootstrap::DATA_INVALID;
|
2001-09-25 09:27:16 +00:00
|
|
|
|
2001-11-02 11:15:30 +00:00
|
|
|
else
|
2001-09-25 09:27:16 +00:00
|
|
|
{
|
2001-11-02 11:15:30 +00:00
|
|
|
DirectoryItem aDirItem;
|
|
|
|
|
|
|
|
eStatus = implCheckStatusOfURL(_sURL,aDirItem);
|
|
|
|
|
|
|
|
if (eStatus == Bootstrap::PATH_EXISTS)
|
|
|
|
{
|
|
|
|
if (!implNormalizeURL(_sURL,aDirItem))
|
|
|
|
OSL_ENSURE(false,"Unexpected failure getting actual URL for existing object");
|
|
|
|
}
|
2001-09-25 09:27:16 +00:00
|
|
|
}
|
|
|
|
return eStatus;
|
|
|
|
}
|
|
|
|
|
2001-07-06 06:17:45 +00:00
|
|
|
|
2001-08-02 09:30:29 +00:00
|
|
|
// ----------------------------------------------------------------------------------
|
|
|
|
// helpers to build and check a nested URL
|
|
|
|
static
|
2001-11-02 11:15:30 +00:00
|
|
|
PathStatus getDerivedPath(
|
|
|
|
OUString& _rURL,
|
|
|
|
OUString const& _aBaseURL, PathStatus _aBaseStatus,
|
|
|
|
OUString const& _sRelativeURL,
|
|
|
|
rtl::Bootstrap& _rData, OUString const& _sBootstrapParameter
|
|
|
|
)
|
2001-07-06 06:17:45 +00:00
|
|
|
{
|
2001-11-02 11:15:30 +00:00
|
|
|
OUString sDerivedURL;
|
|
|
|
|
|
|
|
OSL_PRECOND(!_rData.getFrom(_sBootstrapParameter,sDerivedURL),"Setting for derived path is already defined");
|
|
|
|
OSL_PRECOND(_sRelativeURL.getLength() != 0 && _sRelativeURL[0] != cURLSeparator,"Invalid Relative URL");
|
2001-07-06 06:17:45 +00:00
|
|
|
|
2001-08-02 09:30:29 +00:00
|
|
|
PathStatus aStatus = _aBaseStatus;
|
2001-07-06 06:17:45 +00:00
|
|
|
|
2001-08-02 09:30:29 +00:00
|
|
|
// do we have a base path ?
|
|
|
|
if (_aBaseURL.getLength())
|
2001-07-06 06:17:45 +00:00
|
|
|
{
|
2001-08-02 09:30:29 +00:00
|
|
|
OSL_PRECOND(_aBaseURL[_aBaseURL.getLength()-1] != cURLSeparator,"Unexpected: base URL ends in slash");
|
2001-07-06 06:17:45 +00:00
|
|
|
|
2001-11-02 11:15:30 +00:00
|
|
|
sDerivedURL = _aBaseURL + getURLSeparator() + _sRelativeURL;
|
2001-08-02 09:30:29 +00:00
|
|
|
|
|
|
|
// a derived (nested) URL can only exist or have a lesser status, if the parent exists
|
|
|
|
if (aStatus == Bootstrap::PATH_EXISTS)
|
2001-11-02 11:15:30 +00:00
|
|
|
aStatus = checkStatusAndNormalizeURL(sDerivedURL);
|
2001-07-06 06:17:45 +00:00
|
|
|
|
2001-08-02 09:30:29 +00:00
|
|
|
else // the relative appendix must be valid
|
2001-11-02 11:15:30 +00:00
|
|
|
OSL_ASSERT(aStatus != Bootstrap::PATH_VALID || dbgCheckStatusOfURL(sDerivedURL) == Bootstrap::PATH_VALID);
|
|
|
|
|
|
|
|
_rData.getFrom(_sBootstrapParameter, _rURL, sDerivedURL);
|
|
|
|
|
|
|
|
OSL_ENSURE(sDerivedURL == _rURL,"Could not set derived URL via Bootstrap default parameter");
|
|
|
|
OSL_POSTCOND(RTL_BOOTSTRAP_DEFAULTS_BROKEN ||
|
|
|
|
_rData.getFrom(_sBootstrapParameter,sDerivedURL) && sDerivedURL==_rURL,"Use of default did not affect bootstrap value");
|
2001-08-02 09:30:29 +00:00
|
|
|
}
|
|
|
|
else
|
2001-07-06 06:17:45 +00:00
|
|
|
{
|
2001-08-02 09:30:29 +00:00
|
|
|
// clear the result
|
|
|
|
_rURL = _aBaseURL;
|
|
|
|
|
|
|
|
// if we have no data it can't be a valid path
|
|
|
|
OSL_ASSERT( aStatus > Bootstrap::PATH_VALID );
|
2001-07-06 06:17:45 +00:00
|
|
|
}
|
|
|
|
|
2001-11-02 11:15:30 +00:00
|
|
|
|
2001-08-02 09:30:29 +00:00
|
|
|
return aStatus;
|
2001-07-06 06:17:45 +00:00
|
|
|
}
|
|
|
|
|
2001-08-02 09:30:29 +00:00
|
|
|
// ----------------------------------------------------------------------------------
|
|
|
|
static
|
|
|
|
inline
|
2001-11-02 11:15:30 +00:00
|
|
|
PathStatus getDerivedPath(
|
|
|
|
OUString& _rURL,
|
|
|
|
Bootstrap::Impl::PathData const& _aBaseData,
|
|
|
|
OUString const& _sRelativeURL,
|
|
|
|
rtl::Bootstrap& _rData, OUString const& _sBootstrapParameter
|
|
|
|
)
|
2001-08-02 09:30:29 +00:00
|
|
|
{
|
2001-11-02 11:15:30 +00:00
|
|
|
return getDerivedPath(_rURL,_aBaseData.path,_aBaseData.status,_sRelativeURL,_rData,_sBootstrapParameter);
|
2001-08-02 09:30:29 +00:00
|
|
|
}
|
2001-07-06 06:17:45 +00:00
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------------------
|
|
|
|
|
2001-11-02 11:15:30 +00:00
|
|
|
static
|
|
|
|
OUString getExecutableBaseName()
|
|
|
|
{
|
|
|
|
OUString sExecutable;
|
2001-07-06 06:17:45 +00:00
|
|
|
|
2001-11-02 11:15:30 +00:00
|
|
|
if (osl_Process_E_None == osl_getExecutableFile(&sExecutable.pData))
|
2001-07-06 06:17:45 +00:00
|
|
|
{
|
2001-11-02 11:15:30 +00:00
|
|
|
// split the executable name
|
|
|
|
sal_Int32 nSepIndex = sExecutable.lastIndexOf(cURLSeparator);
|
2001-07-06 06:17:45 +00:00
|
|
|
|
2001-11-02 11:15:30 +00:00
|
|
|
sExecutable = sExecutable.copy(nSepIndex + 1);
|
2001-07-06 06:17:45 +00:00
|
|
|
|
2001-11-02 11:15:30 +00:00
|
|
|
// ... and get the basename (strip the extension)
|
|
|
|
sal_Unicode const cExtensionSep = '.';
|
2001-07-06 06:17:45 +00:00
|
|
|
|
2001-11-02 11:15:30 +00:00
|
|
|
sal_Int32 const nExtIndex = sExecutable.lastIndexOf(cExtensionSep);
|
|
|
|
sal_Int32 const nExtLength = sExecutable.getLength() - nExtIndex - 1;
|
|
|
|
if (0 < nExtIndex && nExtLength < 4)
|
|
|
|
sExecutable = sExecutable.copy(0,nExtIndex);
|
2001-08-02 09:30:29 +00:00
|
|
|
}
|
2001-11-02 11:15:30 +00:00
|
|
|
else
|
|
|
|
OSL_TRACE("Cannot get executable name: osl_getExecutableFile failed\n");
|
2001-08-02 09:30:29 +00:00
|
|
|
|
2001-11-02 11:15:30 +00:00
|
|
|
return sExecutable;
|
2001-08-02 09:30:29 +00:00
|
|
|
}
|
|
|
|
|
2001-11-02 11:15:30 +00:00
|
|
|
// ---------------------------------------------------------------------------------------
|
2001-11-06 14:44:11 +00:00
|
|
|
static
|
|
|
|
OUString getExecutableDirectory()
|
|
|
|
{
|
|
|
|
OUString sFileName;
|
|
|
|
OSL_VERIFY(osl_Process_E_None == osl_getExecutableFile(&sFileName.pData));
|
|
|
|
|
|
|
|
sal_Int32 nDirEnd = sFileName.lastIndexOf(cURLSeparator);
|
|
|
|
|
|
|
|
OSL_ENSURE(nDirEnd >= 0, "Cannot locate executable directory");
|
|
|
|
|
|
|
|
return sFileName.copy(0,nDirEnd);
|
|
|
|
}
|
|
|
|
|
2001-08-02 09:30:29 +00:00
|
|
|
// ----------------------------------------------------------------------------------
|
2001-11-02 11:15:30 +00:00
|
|
|
|
2001-08-02 09:30:29 +00:00
|
|
|
static
|
2001-11-02 11:15:30 +00:00
|
|
|
inline
|
|
|
|
Bootstrap::PathStatus updateStatus(Bootstrap::Impl::PathData & _rResult)
|
2001-08-02 09:30:29 +00:00
|
|
|
{
|
2001-11-02 11:15:30 +00:00
|
|
|
return _rResult.status = checkStatusAndNormalizeURL(_rResult.path);
|
|
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------------------
|
2001-08-02 09:30:29 +00:00
|
|
|
|
2001-11-02 11:15:30 +00:00
|
|
|
static
|
|
|
|
Bootstrap::PathStatus implGetBootstrapFile(rtl::Bootstrap& _rData, Bootstrap::Impl::PathData & _rBootstrapFile)
|
|
|
|
{
|
|
|
|
_rData.getIniName(_rBootstrapFile.path);
|
2001-08-02 09:30:29 +00:00
|
|
|
|
2001-11-02 11:15:30 +00:00
|
|
|
return updateStatus(_rBootstrapFile);
|
|
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------------------
|
2001-08-02 09:30:29 +00:00
|
|
|
|
2001-11-02 11:15:30 +00:00
|
|
|
static
|
|
|
|
Bootstrap::PathStatus implGetVersionFile(rtl::Bootstrap& _rData, Bootstrap::Impl::PathData & _rVersionFile)
|
|
|
|
{
|
|
|
|
OUString const csVersionFileItem(RTL_CONSTASCII_USTRINGPARAM(BOOTSTRAP_ITEM_VERSIONFILE));
|
2001-08-02 09:30:29 +00:00
|
|
|
|
2001-11-02 11:15:30 +00:00
|
|
|
_rData.getFrom(csVersionFileItem,_rVersionFile.path);
|
2001-08-02 09:30:29 +00:00
|
|
|
|
2001-11-02 11:15:30 +00:00
|
|
|
return updateStatus(_rVersionFile);
|
2001-08-02 09:30:29 +00:00
|
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------------------
|
2001-08-09 11:22:27 +00:00
|
|
|
// Error reporting
|
2001-08-02 09:30:29 +00:00
|
|
|
|
2001-08-09 11:22:27 +00:00
|
|
|
static char const IS_MISSING[] = "is missing";
|
|
|
|
static char const IS_INVALID[] = "is corrupt";
|
|
|
|
static char const PERIOD[] = ". ";
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------------------
|
2001-08-02 09:30:29 +00:00
|
|
|
static void addFileError(OUStringBuffer& _rBuf, OUString const& _aPath, AsciiString _sWhat)
|
|
|
|
{
|
|
|
|
OUString sSimpleFileName = _aPath.copy(1 +_aPath.lastIndexOf(cURLSeparator));
|
|
|
|
|
2001-08-09 11:22:27 +00:00
|
|
|
_rBuf.appendAscii("The configuration file");
|
|
|
|
_rBuf.appendAscii(" '").append(sSimpleFileName).appendAscii("' ");
|
|
|
|
_rBuf.appendAscii(_sWhat).appendAscii(PERIOD);
|
2001-08-02 09:30:29 +00:00
|
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------------------
|
|
|
|
|
2001-08-09 11:22:27 +00:00
|
|
|
static void addMissingDirectoryError(OUStringBuffer& _rBuf, OUString const& _aPath)
|
2001-08-02 09:30:29 +00:00
|
|
|
{
|
2001-08-09 11:22:27 +00:00
|
|
|
_rBuf.appendAscii("The configuration directory");
|
|
|
|
_rBuf.appendAscii(" '").append(_aPath).appendAscii("' ");
|
|
|
|
_rBuf.appendAscii(IS_MISSING).appendAscii(PERIOD);
|
2001-08-02 09:30:29 +00:00
|
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------------------
|
|
|
|
|
2001-08-09 11:22:27 +00:00
|
|
|
static void addUnexpectedError(OUStringBuffer& _rBuf, AsciiString _sExtraInfo = NULL)
|
2001-08-02 09:30:29 +00:00
|
|
|
{
|
2001-08-09 11:22:27 +00:00
|
|
|
if (NULL == _sExtraInfo)
|
|
|
|
_sExtraInfo = "An internal failure occurred";
|
|
|
|
|
|
|
|
_rBuf.appendAscii(_sExtraInfo).appendAscii(PERIOD);
|
2001-08-02 09:30:29 +00:00
|
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------------------
|
|
|
|
|
2001-09-25 09:27:16 +00:00
|
|
|
static Bootstrap::FailureCode describeError(OUStringBuffer& _rBuf, Bootstrap::Impl const& _rData)
|
2001-08-02 09:30:29 +00:00
|
|
|
{
|
2001-09-25 09:27:16 +00:00
|
|
|
Bootstrap::FailureCode eErrCode = Bootstrap::INVALID_BOOTSTRAP_DATA;
|
|
|
|
|
2001-08-09 11:22:27 +00:00
|
|
|
_rBuf.appendAscii("The program cannot be started. ");
|
2001-09-25 09:27:16 +00:00
|
|
|
|
2001-08-02 09:30:29 +00:00
|
|
|
switch (_rData.aUserInstall_.status)
|
|
|
|
{
|
|
|
|
case Bootstrap::PATH_EXISTS:
|
|
|
|
switch (_rData.aBaseInstall_.status)
|
|
|
|
{
|
|
|
|
case Bootstrap::PATH_VALID:
|
2001-08-09 11:22:27 +00:00
|
|
|
addMissingDirectoryError(_rBuf, _rData.aBaseInstall_.path);
|
2001-09-25 09:27:16 +00:00
|
|
|
eErrCode = Bootstrap::MISSING_INSTALL_DIRECTORY;
|
2001-08-02 09:30:29 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Bootstrap::DATA_INVALID:
|
2001-08-09 11:22:27 +00:00
|
|
|
addUnexpectedError(_rBuf,"The installation path is invalid");
|
2001-08-02 09:30:29 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Bootstrap::DATA_MISSING:
|
2001-08-09 11:22:27 +00:00
|
|
|
addUnexpectedError(_rBuf,"The installation path is not available");
|
2001-08-02 09:30:29 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Bootstrap::PATH_EXISTS: // seems to be all fine (?)
|
2001-08-09 11:22:27 +00:00
|
|
|
addUnexpectedError(_rBuf,"");
|
2001-08-02 09:30:29 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default: OSL_ASSERT(false);
|
2001-08-09 11:22:27 +00:00
|
|
|
addUnexpectedError(_rBuf);
|
2001-08-02 09:30:29 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Bootstrap::PATH_VALID:
|
2001-08-09 11:22:27 +00:00
|
|
|
addMissingDirectoryError(_rBuf, _rData.aUserInstall_.path);
|
2001-09-25 09:27:16 +00:00
|
|
|
eErrCode = Bootstrap::MISSING_USER_DIRECTORY;
|
2001-08-02 09:30:29 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
// else fall through
|
|
|
|
case Bootstrap::DATA_INVALID:
|
|
|
|
if (_rData.aVersionINI_.status == Bootstrap::PATH_EXISTS)
|
|
|
|
{
|
2001-08-09 11:22:27 +00:00
|
|
|
addFileError(_rBuf, _rData.aVersionINI_.path, IS_INVALID);
|
2001-09-25 09:27:16 +00:00
|
|
|
eErrCode = Bootstrap::INVALID_VERSION_FILE_ENTRY;
|
2001-08-02 09:30:29 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
// else fall through
|
|
|
|
|
|
|
|
case Bootstrap::DATA_MISSING:
|
|
|
|
switch (_rData.aVersionINI_.status)
|
|
|
|
{
|
|
|
|
case Bootstrap::PATH_EXISTS:
|
2001-08-09 11:22:27 +00:00
|
|
|
addFileError(_rBuf, _rData.aVersionINI_.path, "does not support the current version");
|
2001-09-25 09:27:16 +00:00
|
|
|
eErrCode = Bootstrap::MISSING_VERSION_FILE_ENTRY;
|
2001-08-02 09:30:29 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Bootstrap::PATH_VALID:
|
2001-08-09 11:22:27 +00:00
|
|
|
addFileError(_rBuf, _rData.aVersionINI_.path, IS_MISSING);
|
2001-09-25 09:27:16 +00:00
|
|
|
eErrCode = Bootstrap::MISSING_VERSION_FILE;
|
2001-08-02 09:30:29 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
switch (_rData.aBootstrapINI_.status)
|
|
|
|
{
|
|
|
|
case Bootstrap::PATH_EXISTS:
|
2001-08-09 11:22:27 +00:00
|
|
|
addFileError(_rBuf, _rData.aBootstrapINI_.path, IS_INVALID);
|
2001-09-25 09:27:16 +00:00
|
|
|
|
|
|
|
if (_rData.aVersionINI_.status == Bootstrap::DATA_MISSING)
|
|
|
|
eErrCode = Bootstrap::MISSING_BOOTSTRAP_FILE_ENTRY;
|
|
|
|
else
|
|
|
|
eErrCode = Bootstrap::INVALID_BOOTSTRAP_FILE_ENTRY;
|
2001-08-02 09:30:29 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Bootstrap::DATA_INVALID: OSL_ASSERT(false);
|
|
|
|
case Bootstrap::PATH_VALID:
|
2001-08-09 11:22:27 +00:00
|
|
|
addFileError(_rBuf, _rData.aBootstrapINI_.path, IS_MISSING);
|
2001-09-25 09:27:16 +00:00
|
|
|
eErrCode = Bootstrap::MISSING_BOOTSTRAP_FILE;
|
2001-08-02 09:30:29 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2001-08-09 11:22:27 +00:00
|
|
|
addUnexpectedError(_rBuf);
|
2001-08-02 09:30:29 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default: OSL_ASSERT(false);
|
2001-08-09 11:22:27 +00:00
|
|
|
addUnexpectedError(_rBuf);
|
2001-08-02 09:30:29 +00:00
|
|
|
break;
|
2001-07-06 06:17:45 +00:00
|
|
|
}
|
2001-09-25 09:27:16 +00:00
|
|
|
|
|
|
|
return eErrCode;
|
2001-08-02 09:30:29 +00:00
|
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------------------
|
|
|
|
// ---------------------------------------------------------------------------------------
|
|
|
|
// class Bootstrap
|
|
|
|
// ---------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
OUString Bootstrap::getProductKey()
|
|
|
|
{
|
2001-11-02 11:15:30 +00:00
|
|
|
OUString const csProductKeyItem(RTL_CONSTASCII_USTRINGPARAM(BOOTSTRAP_ITEM_PRODUCT_KEY));
|
2001-08-02 09:30:29 +00:00
|
|
|
|
2001-11-02 11:15:30 +00:00
|
|
|
OUString const sDefaultProductKey = getExecutableBaseName();
|
2001-08-02 09:30:29 +00:00
|
|
|
|
2001-11-02 11:15:30 +00:00
|
|
|
return data().getBootstrapValue( csProductKeyItem, sDefaultProductKey );
|
2001-08-02 09:30:29 +00:00
|
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
OUString Bootstrap::getProductKey(OUString const& _sDefault)
|
|
|
|
{
|
2001-11-02 11:15:30 +00:00
|
|
|
OUString const csProductKeyItem(RTL_CONSTASCII_USTRINGPARAM(BOOTSTRAP_ITEM_PRODUCT_KEY));
|
2001-08-02 09:30:29 +00:00
|
|
|
|
2001-11-02 11:15:30 +00:00
|
|
|
return data().getBootstrapValue( csProductKeyItem, _sDefault );
|
2001-08-02 09:30:29 +00:00
|
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
OUString Bootstrap::getLogoData(OUString const& _sDefault)
|
|
|
|
{
|
2001-11-02 11:15:30 +00:00
|
|
|
OUString const csLogoItem(RTL_CONSTASCII_USTRINGPARAM(BOOTSTRAP_ITEM_LOGO));
|
2001-08-02 09:30:29 +00:00
|
|
|
|
2001-11-02 11:15:30 +00:00
|
|
|
return data().getBootstrapValue( csLogoItem, _sDefault );
|
2001-08-02 09:30:29 +00:00
|
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------------------
|
|
|
|
|
2001-11-19 15:10:54 +00:00
|
|
|
OUString Bootstrap::getBuildIdData(OUString const& _sDefault)
|
|
|
|
{
|
|
|
|
OUString const csBuildIdItem(RTL_CONSTASCII_USTRINGPARAM(BOOTSTRAP_ITEM_BUILDID));
|
|
|
|
|
|
|
|
return data().getBootstrapValue( csBuildIdItem, _sDefault );
|
|
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------------------
|
|
|
|
|
2001-12-06 08:59:43 +00:00
|
|
|
/// retrieve the installation mode information item; uses the given default, if not found
|
|
|
|
OUString Bootstrap::getInstallMode(rtl::OUString const& _sDefault)
|
|
|
|
{
|
|
|
|
OUString const csInstallModeItem(RTL_CONSTASCII_USTRINGPARAM(BOOTSTRAP_ITEM_INSTALLMODE));
|
|
|
|
|
|
|
|
return data().getBootstrapValue( csInstallModeItem, _sDefault );
|
|
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------------------
|
|
|
|
|
2002-06-04 09:31:45 +00:00
|
|
|
OUString Bootstrap::getProductPatchLevel(OUString const& _sDefault)
|
|
|
|
{
|
|
|
|
OUString const csBuildIdItem(RTL_CONSTASCII_USTRINGPARAM(BOOTSTRAP_ITEM_PRODUCT_PATCH_LEVEL));
|
|
|
|
|
|
|
|
return data().getBootstrapValue( csBuildIdItem, _sDefault );
|
|
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------------------
|
|
|
|
|
2001-08-02 09:30:29 +00:00
|
|
|
Bootstrap::PathStatus Bootstrap::locateBaseInstallation(OUString& _rURL)
|
|
|
|
{
|
|
|
|
Impl::PathData const& aPathData = data().aBaseInstall_;
|
|
|
|
|
|
|
|
_rURL = aPathData.path;
|
|
|
|
return aPathData.status;
|
|
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
PathStatus Bootstrap::locateUserInstallation(OUString& _rURL)
|
|
|
|
{
|
|
|
|
Impl::PathData const& aPathData = data().aUserInstall_;
|
|
|
|
|
|
|
|
_rURL = aPathData.path;
|
|
|
|
return aPathData.status;
|
|
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
PathStatus Bootstrap::locateSharedData(OUString& _rURL)
|
|
|
|
{
|
2001-11-02 11:15:30 +00:00
|
|
|
OUString const csShareDirItem(RTL_CONSTASCII_USTRINGPARAM(BOOTSTRAP_ITEM_SHAREDIR));
|
|
|
|
|
|
|
|
rtl::Bootstrap aData( data().getImplName() );
|
2001-08-02 09:30:29 +00:00
|
|
|
|
2001-11-02 11:15:30 +00:00
|
|
|
if ( aData.getFrom(csShareDirItem, _rURL) )
|
|
|
|
{
|
|
|
|
return checkStatusAndNormalizeURL(_rURL);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
OUString const csShareDir(RTL_CONSTASCII_USTRINGPARAM(BOOTSTRAP_DIRNAME_SHAREDIR));
|
|
|
|
return getDerivedPath(_rURL, data().aBaseInstall_, csShareDir, aData, csShareDirItem);
|
|
|
|
}
|
2001-08-02 09:30:29 +00:00
|
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
PathStatus Bootstrap::locateUserData(OUString& _rURL)
|
|
|
|
{
|
2001-11-02 11:15:30 +00:00
|
|
|
OUString const csUserDirItem(RTL_CONSTASCII_USTRINGPARAM(BOOTSTRAP_ITEM_USERDIR));
|
2001-08-02 09:30:29 +00:00
|
|
|
|
2001-11-02 11:15:30 +00:00
|
|
|
rtl::Bootstrap aData( data().getImplName() );
|
|
|
|
|
|
|
|
if ( aData.getFrom(csUserDirItem, _rURL) )
|
|
|
|
{
|
|
|
|
return checkStatusAndNormalizeURL(_rURL);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
OUString const csUserDir(RTL_CONSTASCII_USTRINGPARAM(BOOTSTRAP_DIRNAME_USERDIR));
|
|
|
|
return getDerivedPath(_rURL, data().aUserInstall_ ,csUserDir, aData, csUserDirItem);
|
|
|
|
}
|
2001-08-02 09:30:29 +00:00
|
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
PathStatus Bootstrap::locateBootstrapFile(OUString& _rURL)
|
|
|
|
{
|
|
|
|
Impl::PathData const& aPathData = data().aBootstrapINI_;
|
|
|
|
|
|
|
|
_rURL = aPathData.path;
|
|
|
|
return aPathData.status;
|
|
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
PathStatus Bootstrap::locateVersionFile(OUString& _rURL)
|
|
|
|
{
|
|
|
|
Impl::PathData const& aPathData = data().aVersionINI_;
|
|
|
|
|
|
|
|
_rURL = aPathData.path;
|
|
|
|
return aPathData.status;
|
|
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
Bootstrap::Status Bootstrap::checkBootstrapStatus(OUString& _rDiagnosticMessage)
|
2001-09-25 09:27:16 +00:00
|
|
|
{
|
|
|
|
FailureCode eDummyCode(NO_FAILURE);
|
|
|
|
|
|
|
|
return checkBootstrapStatus(_rDiagnosticMessage,eDummyCode);
|
|
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
Bootstrap::Status Bootstrap::checkBootstrapStatus(rtl::OUString& _rDiagnosticMessage, FailureCode& _rErrCode)
|
2001-08-02 09:30:29 +00:00
|
|
|
{
|
|
|
|
Impl const& aData = data();
|
|
|
|
|
|
|
|
Status result = aData.status_;
|
|
|
|
|
|
|
|
// maybe do further checks here
|
|
|
|
|
|
|
|
OUStringBuffer sErrorBuffer;
|
|
|
|
if (result != DATA_OK)
|
2001-09-25 09:27:16 +00:00
|
|
|
_rErrCode = describeError(sErrorBuffer,aData);
|
|
|
|
|
|
|
|
else
|
|
|
|
_rErrCode = NO_FAILURE;
|
|
|
|
|
2001-08-02 09:30:29 +00:00
|
|
|
_rDiagnosticMessage = sErrorBuffer.makeStringAndClear();
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------------------
|
|
|
|
// class Bootstrap::Impl
|
|
|
|
// ---------------------------------------------------------------------------------------
|
|
|
|
|
2001-11-02 11:15:30 +00:00
|
|
|
bool Bootstrap::Impl::initBaseInstallationData(rtl::Bootstrap& _rData)
|
2001-08-02 09:30:29 +00:00
|
|
|
{
|
2001-11-02 11:15:30 +00:00
|
|
|
OUString const csBaseInstallItem( RTL_CONSTASCII_USTRINGPARAM(BOOTSTRAP_ITEM_BASEINSTALLATION) );
|
|
|
|
OUString const csBaseInstallDefault( RTL_CONSTASCII_USTRINGPARAM(BOOTSTRAP_DEFAULT_BASEINSTALL) );
|
2001-08-02 09:30:29 +00:00
|
|
|
|
2001-11-02 11:15:30 +00:00
|
|
|
_rData.getFrom(csBaseInstallItem, aBaseInstall_.path, csBaseInstallDefault);
|
2001-08-02 09:30:29 +00:00
|
|
|
|
2001-11-02 11:15:30 +00:00
|
|
|
bool bResult = (PATH_EXISTS == updateStatus(aBaseInstall_));
|
2001-07-06 06:17:45 +00:00
|
|
|
|
2001-11-02 11:15:30 +00:00
|
|
|
implGetBootstrapFile(_rData, aBootstrapINI_);
|
2001-07-06 06:17:45 +00:00
|
|
|
|
2001-11-02 11:15:30 +00:00
|
|
|
return bResult;
|
2001-07-06 06:17:45 +00:00
|
|
|
}
|
2001-08-02 09:30:29 +00:00
|
|
|
// ---------------------------------------------------------------------------------------
|
|
|
|
|
2001-11-02 11:15:30 +00:00
|
|
|
bool Bootstrap::Impl::initUserInstallationData(rtl::Bootstrap& _rData)
|
2001-08-02 09:30:29 +00:00
|
|
|
{
|
2001-11-02 11:15:30 +00:00
|
|
|
OUString const csUserInstallItem( RTL_CONSTASCII_USTRINGPARAM(BOOTSTRAP_ITEM_USERINSTALLATION) );
|
2001-08-02 09:30:29 +00:00
|
|
|
|
2001-11-02 11:15:30 +00:00
|
|
|
if (_rData.getFrom(csUserInstallItem, aUserInstall_.path))
|
2001-08-02 09:30:29 +00:00
|
|
|
{
|
2001-11-02 11:15:30 +00:00
|
|
|
updateStatus(aUserInstall_);
|
2001-08-02 09:30:29 +00:00
|
|
|
}
|
2001-11-02 11:15:30 +00:00
|
|
|
else
|
2001-08-02 09:30:29 +00:00
|
|
|
{
|
2001-11-02 11:15:30 +00:00
|
|
|
// should we do just this
|
2001-08-02 09:30:29 +00:00
|
|
|
aUserInstall_.status = DATA_MISSING;
|
|
|
|
|
2001-11-02 11:15:30 +00:00
|
|
|
// .. or this - look for a single-user user directory ?
|
|
|
|
OUString const csUserDirItem(RTL_CONSTASCII_USTRINGPARAM(BOOTSTRAP_ITEM_USERDIR));
|
|
|
|
OUString sDummy;
|
|
|
|
// look for $BASEINSTALLATION/user only if default UserDir setting is used
|
|
|
|
if (! _rData.getFrom(csUserDirItem, sDummy))
|
2001-08-02 09:30:29 +00:00
|
|
|
{
|
2001-11-02 11:15:30 +00:00
|
|
|
OUString const csUserDir(RTL_CONSTASCII_USTRINGPARAM(BOOTSTRAP_DIRNAME_USERDIR));
|
2001-08-02 09:30:29 +00:00
|
|
|
|
2001-11-02 11:15:30 +00:00
|
|
|
if ( PATH_EXISTS == getDerivedPath(sDummy, aBaseInstall_, csUserDir, _rData, csUserDirItem) )
|
|
|
|
aUserInstall_ = aBaseInstall_;
|
2001-08-02 09:30:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-11-02 11:15:30 +00:00
|
|
|
bool bResult = (PATH_EXISTS == aUserInstall_.status);
|
|
|
|
|
|
|
|
implGetVersionFile(_rData, aVersionINI_);
|
|
|
|
|
|
|
|
return bResult;
|
2001-08-02 09:30:29 +00:00
|
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
Bootstrap::Status Bootstrap::Impl::initialize()
|
|
|
|
{
|
|
|
|
Bootstrap::Status result;
|
|
|
|
|
2001-11-02 11:15:30 +00:00
|
|
|
rtl::Bootstrap aData( m_aImplName );
|
|
|
|
|
|
|
|
if (!initBaseInstallationData(aData))
|
2001-08-02 09:30:29 +00:00
|
|
|
{
|
|
|
|
result = INVALID_BASE_INSTALL;
|
|
|
|
}
|
2001-11-02 11:15:30 +00:00
|
|
|
else if (!initUserInstallationData(aData))
|
2001-08-02 09:30:29 +00:00
|
|
|
{
|
|
|
|
result = INVALID_USER_INSTALL;
|
|
|
|
|
|
|
|
if (aUserInstall_.status >= DATA_MISSING)
|
|
|
|
{
|
|
|
|
switch (aVersionINI_.status)
|
|
|
|
{
|
|
|
|
case PATH_EXISTS:
|
|
|
|
case PATH_VALID:
|
|
|
|
result = MISSING_USER_INSTALL;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DATA_INVALID:
|
|
|
|
case DATA_MISSING:
|
|
|
|
result = INVALID_BASE_INSTALL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
result = DATA_OK;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------------------
|
|
|
|
|
2001-11-02 11:15:30 +00:00
|
|
|
OUString Bootstrap::Impl::getBootstrapValue(OUString const& _sName, OUString const& _sDefault) const
|
2001-08-02 09:30:29 +00:00
|
|
|
{
|
2001-11-02 11:15:30 +00:00
|
|
|
rtl::Bootstrap aData( m_aImplName );
|
2001-08-02 09:30:29 +00:00
|
|
|
|
2001-11-02 11:15:30 +00:00
|
|
|
OUString sResult;
|
|
|
|
aData.getFrom(_sName,sResult,_sDefault);
|
|
|
|
return sResult;
|
2001-08-02 09:30:29 +00:00
|
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------------------
|
|
|
|
|
2001-07-06 06:17:45 +00:00
|
|
|
} // namespace utl
|
|
|
|
|