1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
*/
#include <config_folders.h>
#include <stdio.h>
#include <unotools/bootstrap.hxx>
#include <rtl/ustring.hxx>
#include <rtl/ustrbuf.hxx>
#include <sal/log.hxx>
#include <osl/file.hxx>
#include <osl/mutex.hxx>
#include <osl/diagnose.h>
#include <rtl/bootstrap.hxx>
#include <rtl/instance.hxx>
#include <osl/process.h>
#include <tools/getprocessworkingdir.hxx>
// #define this to true, if remembering defaults is not supported properly
#define RTL_BOOTSTRAP_DEFAULTS_BROKEN true
#define BOOTSTRAP_ITEM_PRODUCT_KEY "ProductKey"
#define BOOTSTRAP_ITEM_VERSIONFILE "Location"
#define BOOTSTRAP_ITEM_BUILDID "buildid"
#define BOOTSTRAP_ITEM_BUILDVERSION "BuildVersion"
#define BOOTSTRAP_ITEM_BASEINSTALLATION "BRAND_BASE_DIR"
#define BOOTSTRAP_ITEM_USERINSTALLATION "UserInstallation"
#define BOOTSTRAP_ITEM_USERDIR "UserDataDir"
#define BOOTSTRAP_DEFAULT_BASEINSTALL "$SYSBINDIR/.."
#define BOOTSTRAP_DIRNAME_USERDIR "user"
typedef char const * AsciiString;
namespace utl
{
// Implementation class: Bootstrap::Impl
namespace
{
OUString makeImplName()
{
OUString uri;
rtl::Bootstrap::get( "BRAND_BASE_DIR", uri);
return uri + "/" LIBO_ETC_FOLDER "/" SAL_CONFIGFILE("bootstrap");
}
}
class Bootstrap::Impl
{
const OUString m_aImplName;
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_;
// INI files
PathData aBootstrapINI_;
PathData aVersionINI_;
// overall status
Status status_;
public: // construction and initialization
Impl() : m_aImplName(makeImplName())
{
initialize();
}
void initialize();
// access helper
OUString getBootstrapValue(OUString const& _sName, OUString const& _sDefault) const;
static bool getVersionValue(OUString const& _sName, OUString& _rValue, OUString const& _sDefault);
const OUString& getImplName() const { return m_aImplName; }
private: // implementation
bool initBaseInstallationData(rtl::Bootstrap& _rData);
bool initUserInstallationData(rtl::Bootstrap& _rData);
};
namespace
{
class theImpl : public rtl::Static<Bootstrap::Impl, theImpl> {};
}
const Bootstrap::Impl& Bootstrap::data()
{
return theImpl::get();
}
void Bootstrap::reloadData()
{
theImpl::get().initialize();
}
// helper
typedef Bootstrap::PathStatus PathStatus;
sal_Unicode const cURLSeparator = '/';
// path status utility function
static
PathStatus implCheckStatusOfURL(OUString const& _sURL, osl::DirectoryItem& aDirItem)
{
using namespace osl;
PathStatus eStatus = Bootstrap::DATA_UNKNOWN;
if (!_sURL.isEmpty())
{
switch( DirectoryItem::get(_sURL, aDirItem) )
{
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;
return eStatus;
}
static
bool implNormalizeURL(OUString & _sURL, osl::DirectoryItem& aDirItem)
{
using namespace osl;
OSL_PRECOND(aDirItem.is(), "Opened DirItem required");
static const sal_uInt32 cosl_FileStatus_Mask = osl_FileStatus_Mask_FileURL;
FileStatus aFileStatus(cosl_FileStatus_Mask);
if (aDirItem.getFileStatus(aFileStatus) != DirectoryItem::E_None)
return false;
OUString aNormalizedURL = aFileStatus.getFileURL();
if (aNormalizedURL.isEmpty())
return false;
// #109863# sal/osl returns final slash for file URLs contradicting
// the URL/URI RFCs.
if ( !aNormalizedURL.endsWith(OUStringLiteral1<cURLSeparator>()) )
_sURL = aNormalizedURL;
else
_sURL = aNormalizedURL.copy( 0, aNormalizedURL.getLength()-1 );
return true;
}
static
bool implEnsureAbsolute(OUString & _rsURL) // also strips embedded dots !!
{
using osl::File;
OUString sBasePath;
OSL_VERIFY(tools::getProcessWorkingDir(sBasePath));
OUString sAbsolute;
if ( File::E_None == File::getAbsoluteFileURL(sBasePath, _rsURL, sAbsolute))
{
_rsURL = sAbsolute;
return true;
}
else
{
OSL_FAIL("Could not get absolute file URL for URL");
return false;
}
}
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);
}
static
PathStatus dbgCheckStatusOfURL(OUString const& _sURL)
{
using namespace osl;
DirectoryItem aDirItem;
return implCheckStatusOfURL(_sURL,aDirItem);
}
static
PathStatus checkStatusAndNormalizeURL(OUString & _sURL)
{
using namespace osl;
PathStatus eStatus = Bootstrap::DATA_UNKNOWN;
if (_sURL.isEmpty())
eStatus = Bootstrap::DATA_MISSING;
else if ( !implMakeAbsoluteURL(_sURL) )
eStatus = Bootstrap::DATA_INVALID;
else
{
DirectoryItem aDirItem;
eStatus = implCheckStatusOfURL(_sURL,aDirItem);
if (eStatus == Bootstrap::PATH_EXISTS)
{
if (!implNormalizeURL(_sURL,aDirItem))
OSL_FAIL("Unexpected failure getting actual URL for existing object");
}
}
return eStatus;
}
// helpers to build and check a nested URL
static
PathStatus getDerivedPath(
OUString& _rURL,
OUString const& _aBaseURL, PathStatus _aBaseStatus,
OUString const& _sRelativeURL,
rtl::Bootstrap& _rData, OUString const& _sBootstrapParameter
)
{
OUString sDerivedURL;
OSL_PRECOND(!_rData.getFrom(_sBootstrapParameter,sDerivedURL),"Setting for derived path is already defined");
OSL_PRECOND(!_sRelativeURL.isEmpty() && _sRelativeURL[0] != cURLSeparator,"Invalid Relative URL");
PathStatus aStatus = _aBaseStatus;
// do we have a base path ?
if (!_aBaseURL.isEmpty())
{
OSL_PRECOND(!_aBaseURL.endsWith(OUStringLiteral1<cURLSeparator>()), "Unexpected: base URL ends in slash");
sDerivedURL = OUStringBuffer(_aBaseURL).append(cURLSeparator).append(_sRelativeURL).makeStringAndClear();
// a derived (nested) URL can only exist or have a lesser status, if the parent exists
if (aStatus == Bootstrap::PATH_EXISTS)
aStatus = checkStatusAndNormalizeURL(sDerivedURL);
else // the relative appendix must be valid
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");
SAL_WARN_IF( !(RTL_BOOTSTRAP_DEFAULTS_BROKEN || (_rData.getFrom(_sBootstrapParameter,sDerivedURL) && sDerivedURL==_rURL)),
"unotools.config",
"Use of default did not affect bootstrap value");
}
else
{
// clear the result
_rURL = _aBaseURL;
// if we have no data it can't be a valid path
OSL_ASSERT( aStatus > Bootstrap::PATH_VALID );
}
return aStatus;
}
static
inline
PathStatus getDerivedPath(
OUString& _rURL,
Bootstrap::Impl::PathData const& _aBaseData,
OUString const& _sRelativeURL,
rtl::Bootstrap& _rData, OUString const& _sBootstrapParameter
)
{
return getDerivedPath(_rURL,_aBaseData.path,_aBaseData.status,_sRelativeURL,_rData,_sBootstrapParameter);
}
static
OUString getExecutableBaseName()
{
OUString sExecutable;
if (osl_Process_E_None == osl_getExecutableFile(&sExecutable.pData))
{
// split the executable name
sal_Int32 nSepIndex = sExecutable.lastIndexOf(cURLSeparator);
sExecutable = sExecutable.copy(nSepIndex + 1);
// ... and get the basename (strip the extension)
sal_Unicode const cExtensionSep = '.';
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);
}
else
OSL_TRACE("Cannot get executable name: osl_getExecutableFile failed");
return sExecutable;
}
static
inline
Bootstrap::PathStatus updateStatus(Bootstrap::Impl::PathData & _rResult)
{
return _rResult.status = checkStatusAndNormalizeURL(_rResult.path);
}
static
Bootstrap::PathStatus implGetBootstrapFile(rtl::Bootstrap& _rData, Bootstrap::Impl::PathData & _rBootstrapFile)
{
_rData.getIniName(_rBootstrapFile.path);
return updateStatus(_rBootstrapFile);
}
static
Bootstrap::PathStatus implGetVersionFile(rtl::Bootstrap& _rData, Bootstrap::Impl::PathData & _rVersionFile)
{
_rData.getFrom(BOOTSTRAP_ITEM_VERSIONFILE, _rVersionFile.path);
return updateStatus(_rVersionFile);
}
// Error reporting
static char const IS_MISSING[] = "is missing";
static char const IS_INVALID[] = "is corrupt";
static char const PERIOD[] = ". ";
static void addFileError(OUStringBuffer& _rBuf, OUString const& _aPath, AsciiString _sWhat)
{
OUString sSimpleFileName = _aPath.copy(1 +_aPath.lastIndexOf(cURLSeparator));
_rBuf.append("The configuration file");
_rBuf.append(" '").append(sSimpleFileName).append("' ");
_rBuf.appendAscii(_sWhat).append(PERIOD);
}
static void addMissingDirectoryError(OUStringBuffer& _rBuf, OUString const& _aPath)
{
_rBuf.append("The configuration directory");
_rBuf.append(" '").append(_aPath).append("' ");
_rBuf.append(IS_MISSING).append(PERIOD);
}
static void addUnexpectedError(OUStringBuffer& _rBuf, AsciiString _sExtraInfo = nullptr)
{
if (nullptr == _sExtraInfo)
_sExtraInfo = "An internal failure occurred";
_rBuf.appendAscii(_sExtraInfo).append(PERIOD);
}
static Bootstrap::FailureCode describeError(OUStringBuffer& _rBuf, Bootstrap::Impl const& _rData)
{
Bootstrap::FailureCode eErrCode = Bootstrap::INVALID_BOOTSTRAP_DATA;
_rBuf.append("The program cannot be started. ");
switch (_rData.aUserInstall_.status)
{
case Bootstrap::PATH_EXISTS:
switch (_rData.aBaseInstall_.status)
{
case Bootstrap::PATH_VALID:
addMissingDirectoryError(_rBuf, _rData.aBaseInstall_.path);
eErrCode = Bootstrap::MISSING_INSTALL_DIRECTORY;
break;
case Bootstrap::DATA_INVALID:
addUnexpectedError(_rBuf,"The installation path is invalid");
break;
case Bootstrap::DATA_MISSING:
addUnexpectedError(_rBuf,"The installation path is not available");
break;
case Bootstrap::PATH_EXISTS: // seems to be all fine (?)
addUnexpectedError(_rBuf,"");
break;
default: OSL_ASSERT(false);
addUnexpectedError(_rBuf);
break;
}
break;
case Bootstrap::PATH_VALID:
addMissingDirectoryError(_rBuf, _rData.aUserInstall_.path);
eErrCode = Bootstrap::MISSING_USER_DIRECTORY;
break;
// else fall through
case Bootstrap::DATA_INVALID:
if (_rData.aVersionINI_.status == Bootstrap::PATH_EXISTS)
{
addFileError(_rBuf, _rData.aVersionINI_.path, IS_INVALID);
eErrCode = Bootstrap::INVALID_VERSION_FILE_ENTRY;
break;
}
SAL_FALLTHROUGH;
case Bootstrap::DATA_MISSING:
switch (_rData.aVersionINI_.status)
{
case Bootstrap::PATH_EXISTS:
addFileError(_rBuf, _rData.aVersionINI_.path, "does not support the current version");
eErrCode = Bootstrap::MISSING_VERSION_FILE_ENTRY;
break;
case Bootstrap::PATH_VALID:
addFileError(_rBuf, _rData.aVersionINI_.path, IS_MISSING);
eErrCode = Bootstrap::MISSING_VERSION_FILE;
break;
default:
switch (_rData.aBootstrapINI_.status)
{
case Bootstrap::PATH_EXISTS:
addFileError(_rBuf, _rData.aBootstrapINI_.path, IS_INVALID);
if (_rData.aVersionINI_.status == Bootstrap::DATA_MISSING)
eErrCode = Bootstrap::MISSING_BOOTSTRAP_FILE_ENTRY;
else
eErrCode = Bootstrap::INVALID_BOOTSTRAP_FILE_ENTRY;
break;
case Bootstrap::DATA_INVALID: OSL_ASSERT(false); SAL_FALLTHROUGH;
case Bootstrap::PATH_VALID:
addFileError(_rBuf, _rData.aBootstrapINI_.path, IS_MISSING);
eErrCode = Bootstrap::MISSING_BOOTSTRAP_FILE;
break;
default:
addUnexpectedError(_rBuf);
break;
}
break;
}
break;
default: OSL_ASSERT(false);
addUnexpectedError(_rBuf);
break;
}
return eErrCode;
}
// class Bootstrap
OUString Bootstrap::getProductKey()
{
OUString const csProductKeyItem(BOOTSTRAP_ITEM_PRODUCT_KEY);
OUString const sDefaultProductKey = getExecutableBaseName();
return data().getBootstrapValue( csProductKeyItem, sDefaultProductKey );
}
OUString Bootstrap::getProductKey(OUString const& _sDefault)
{
OUString const csProductKeyItem(BOOTSTRAP_ITEM_PRODUCT_KEY);
return data().getBootstrapValue( csProductKeyItem, _sDefault );
}
OUString Bootstrap::getBuildVersion(OUString const& _sDefault)
{
OUString const csBuildVersionItem(BOOTSTRAP_ITEM_BUILDVERSION);
OUString sBuildVersion;
// read BuildVersion from version.ini (versionrc)
utl::Bootstrap::Impl::getVersionValue( csBuildVersionItem, sBuildVersion, _sDefault );
return sBuildVersion;
}
OUString Bootstrap::getBuildIdData(OUString const& _sDefault)
{
OUString const csBuildIdItem(BOOTSTRAP_ITEM_BUILDID);
OUString sBuildId;
// read buildid from version.ini (versionrc), if it doesn't exist or buildid is empty
if ( !utl::Bootstrap::Impl::getVersionValue( csBuildIdItem, sBuildId, _sDefault ) ||
sBuildId.isEmpty() )
// read buildid from bootstrap.ini (bootstraprc)
sBuildId = data().getBootstrapValue( csBuildIdItem, _sDefault );
return sBuildId;
}
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::locateUserData(OUString& _rURL)
{
OUString const csUserDirItem(BOOTSTRAP_ITEM_USERDIR);
rtl::Bootstrap aData( data().getImplName() );
if ( aData.getFrom(csUserDirItem, _rURL) )
{
return checkStatusAndNormalizeURL(_rURL);
}
else
{
OUString const csUserDir(BOOTSTRAP_DIRNAME_USERDIR);
return getDerivedPath(_rURL, data().aUserInstall_ ,csUserDir, aData, csUserDirItem);
}
}
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, FailureCode& _rErrCode)
{
Impl const& aData = data();
Status result = aData.status_;
// maybe do further checks here
OUStringBuffer sErrorBuffer;
if (result != DATA_OK)
_rErrCode = describeError(sErrorBuffer,aData);
else
_rErrCode = NO_FAILURE;
_rDiagnosticMessage = sErrorBuffer.makeStringAndClear();
return result;
}
// class Bootstrap::Impl
bool Bootstrap::Impl::initBaseInstallationData(rtl::Bootstrap& _rData)
{
OUString const csBaseInstallItem( BOOTSTRAP_ITEM_BASEINSTALLATION );
OUString const csBaseInstallDefault( BOOTSTRAP_DEFAULT_BASEINSTALL );
_rData.getFrom(csBaseInstallItem, aBaseInstall_.path, csBaseInstallDefault);
bool bResult = (PATH_EXISTS == updateStatus(aBaseInstall_));
implGetBootstrapFile(_rData, aBootstrapINI_);
return bResult;
}
bool Bootstrap::Impl::initUserInstallationData(rtl::Bootstrap& _rData)
{
OUString const csUserInstallItem( BOOTSTRAP_ITEM_USERINSTALLATION );
if (_rData.getFrom(csUserInstallItem, aUserInstall_.path))
{
updateStatus(aUserInstall_);
}
else
{
// should we do just this
aUserInstall_.status = DATA_MISSING;
// ... or this - look for a single-user user directory ?
OUString const csUserDirItem(BOOTSTRAP_ITEM_USERDIR);
OUString sDummy;
// look for $BASEINSTALLATION/user only if default UserDir setting is used
if (! _rData.getFrom(csUserDirItem, sDummy))
{
OUString const csUserDir(BOOTSTRAP_DIRNAME_USERDIR);
if ( PATH_EXISTS == getDerivedPath(sDummy, aBaseInstall_, csUserDir, _rData, csUserDirItem) )
aUserInstall_ = aBaseInstall_;
}
}
bool bResult = (PATH_EXISTS == aUserInstall_.status);
implGetVersionFile(_rData, aVersionINI_);
return bResult;
}
void Bootstrap::Impl::initialize()
{
rtl::Bootstrap aData( m_aImplName );
if (!initBaseInstallationData(aData))
{
status_ = INVALID_BASE_INSTALL;
}
else if (!initUserInstallationData(aData))
{
status_ = INVALID_USER_INSTALL;
if (aUserInstall_.status >= DATA_MISSING)
{
switch (aVersionINI_.status)
{
case PATH_EXISTS:
case PATH_VALID:
status_ = MISSING_USER_INSTALL;
break;
case DATA_INVALID:
case DATA_MISSING:
status_ = INVALID_BASE_INSTALL;
break;
default:
break;
}
}
}
else
{
status_ = DATA_OK;
}
}
OUString Bootstrap::Impl::getBootstrapValue(OUString const& _sName, OUString const& _sDefault) const
{
rtl::Bootstrap aData( m_aImplName );
OUString sResult;
aData.getFrom(_sName,sResult,_sDefault);
return sResult;
}
bool Bootstrap::Impl::getVersionValue(OUString const& _sName, OUString& _rValue, OUString const& _sDefault)
{
// try to open version.ini (versionrc)
OUString uri;
rtl::Bootstrap::get( "BRAND_BASE_DIR", uri);
rtl::Bootstrap aData( uri + "/" LIBO_ETC_FOLDER "/" SAL_CONFIGFILE("version") );
if ( aData.getHandle() == nullptr )
// version.ini (versionrc) doesn't exist
return false;
// read value
aData.getFrom(_sName,_rValue,_sDefault);
return true;
}
} // namespace utl
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|