20#include <config_features.h>
31#include <rtl/ustrbuf.hxx>
32#include <rtl/string.hxx>
34#include <rtl/bootstrap.hxx>
38#include <osl/diagnose.h>
39#include <osl/file.hxx>
40#include <osl/security.hxx>
47#include <com/sun/star/lang/IllegalArgumentException.hpp>
48#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
49#include <com/sun/star/beans/UnknownPropertyException.hpp>
50#include <com/sun/star/logging/LogLevel.hpp>
51#include <com/sun/star/logging/FileHandler.hpp>
52#include <com/sun/star/logging/SimpleTextFormatter.hpp>
53#include <com/sun/star/logging/XLogger.hpp>
54#include <com/sun/star/util/XUpdatable.hpp>
55#include <com/sun/star/sdbc/XResultSet.hpp>
56#include <com/sun/star/sdbc/XRow.hpp>
57#include <com/sun/star/ucb/CommandAbortedException.hpp>
58#include <com/sun/star/ucb/CommandFailedException.hpp>
59#include <com/sun/star/ucb/ContentCreationException.hpp>
60#include <com/sun/star/ucb/XContentAccess.hpp>
61#include <com/sun/star/ucb/NameClash.hpp>
62#include <com/sun/star/deployment/DeploymentException.hpp>
63#include <com/sun/star/deployment/InvalidRemovedParameterException.hpp>
64#include <com/sun/star/deployment/Prerequisites.hpp>
65#include <com/sun/star/ucb/UnsupportedCommandException.hpp>
89 explicit MatchTempDir( OUString str ) :
m_str(
std::move( str )) {}
90 bool operator () ( ActivePackages::Entries::value_type
const & v )
const {
91 return v.second.temporaryName.equalsIgnoreAsciiCase(
m_str );
95OUString getExtensionFolder(OUString
const & parentFolder,
96 Reference<ucb::XCommandEnvironment>
const & xCmdEnv,
97 Reference<uno::XComponentContext>
const &
xContext)
100 Reference<sdbc::XResultSet> xResultSet(
101 StrTitle::createCursor (tempFolder, ::ucbhelper::INCLUDE_FOLDERS_ONLY ) );
104 if (xResultSet->next())
106 title = Reference<sdbc::XRow>(
107 xResultSet, UNO_QUERY_THROW )->getString(1 ) ;
114 Reference<XCommandEnvironment>
const & xCmdEnv )
126 Reference<sdbc::XResultSet> xResultSet(
127 StrTitle::createCursor (ucbContent, ::ucbhelper::INCLUDE_FOLDERS_AND_DOCUMENTS ) );
129 while (xResultSet->next())
131 Reference<sdbc::XRow> xRow( xResultSet, UNO_QUERY_THROW );
132 OUString title( xRow->getString( 1 ) );
134 if ( title ==
"this_is_a_dummy_stream_just_there_as_a_workaround_for_a_temporary_limitation_of_the_storage_api_implementation" )
136 if ( title ==
"META-INF" )
140 Reference<XContentAccess>(
141 xResultSet, UNO_QUERY_THROW )->queryContent(),
146 if (!mediaType.isEmpty())
150 Sequence<css::beans::NamedValue>(),mediaType, sourceContent,
189 Reference<sdbc::XResultSet> xResultSet(
190 StrTitle::createCursor (tempFolder,
191 ::ucbhelper::INCLUDE_DOCUMENTS_ONLY ) );
194 std::vector<OUString> tempEntries;
195 std::vector<OUString> removedEntries;
196 while (xResultSet->next())
199 Reference<sdbc::XRow>(
200 xResultSet, UNO_QUERY_THROW )->
getString(
202 if (title.endsWith(
"removed", &title))
205 removedEntries.push_back(::rtl::Uri::encode(
206 title, rtl_UriCharClassPchar,
207 rtl_UriEncodeIgnoreEscapes,
208 RTL_TEXTENCODING_UTF8 ) );
212 tempEntries.push_back( ::rtl::Uri::encode(
213 title, rtl_UriCharClassPchar,
214 rtl_UriEncodeIgnoreEscapes,
215 RTL_TEXTENCODING_UTF8 ) );
220 for (
const OUString & tempEntry : tempEntries)
222 const MatchTempDir
match( tempEntry );
223 if (std::none_of( id2temp.begin(), id2temp.end(),
match ))
232 if (std::find(removedEntries.begin(), removedEntries.end(), tempEntry) ==
233 removedEntries.end())
249 ::osl::Security aSecurity;
250 aSecurity.getUserName( aUserName );
254 std::string_view osData(
reinterpret_cast<const char*
>(data.data()),
256 OUString sData = OStringToOUString(
257 osData, RTL_TEXTENCODING_UTF8);
258 if (sData != aUserName)
264 Reference<XCommandEnvironment>(),
266 erase_path( url, Reference<XCommandEnvironment>(),
270 Reference<XCommandEnvironment>(),
false);
282 Reference<XCommandEnvironment>(),
false);
292 if (e != osl::FileBase::E_NOENT) {
296 if (!o.removeSegment()) {
297 return osl::FileBase::E_INVAL;
300 if (e != osl::FileBase::E_None && e != osl::FileBase::E_EXIST) {
306bool isMacroURLReadOnly(
const OUString &rMacro )
308 OUString aDirURL( rMacro );
309 ::rtl::Bootstrap::expandMacros( aDirURL );
312 if ( aErr == ::osl::FileBase::E_None )
314 if ( aErr != ::osl::FileBase::E_EXIST )
318 sal_uInt64 nWritten = 0;
319 OUString aFileURL( aDirURL +
"/stamp.sys" );
320 ::osl::File aFile( aFileURL );
322 bError = aFile.open( osl_File_OpenFlag_Read |
323 osl_File_OpenFlag_Write |
324 osl_File_OpenFlag_Create ) != ::osl::FileBase::E_None;
326 bError = aFile.write(
"1", 1, nWritten ) != ::osl::FileBase::E_None;
327 if (aFile.close() != ::osl::FileBase::E_None)
329 if (osl::File::remove( aFileURL ) != ::osl::FileBase::E_None)
333 "desktop.deployment",
334 "local url '" << rMacro <<
"' -> '" << aFileURL <<
"' "
335 << (bError ?
"is" :
"is not") <<
" readonly\n");
342 Reference<XComponentContext>
const & xComponentContext,
343 OUString
const & context )
346 xComponentContext, context );
348 OUString logFile, stamp;
349 if ( context ==
"user" ) {
350 that->m_activePackages =
"vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE/uno_packages";
351 that->m_registrationData =
"vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE";
352 that->m_registryCache =
"vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE/registry";
353 logFile =
"$UNO_USER_PACKAGES_CACHE/log.txt";
365 stamp =
"$UNO_USER_PACKAGES_CACHE";
367 else if ( context ==
"shared" ) {
368 that->m_activePackages =
"vnd.sun.star.expand:$UNO_SHARED_PACKAGES_CACHE/uno_packages";
369 that->m_registrationData =
"vnd.sun.star.expand:$SHARED_EXTENSIONS_USER";
370 that->m_registryCache =
"vnd.sun.star.expand:$SHARED_EXTENSIONS_USER/registry";
371 logFile =
"$SHARED_EXTENSIONS_USER/log.txt";
372#if !HAVE_FEATURE_READONLY_INSTALLSET
375 stamp =
"$UNO_SHARED_PACKAGES_CACHE";
378 else if ( context ==
"bundled" ) {
379 that->m_activePackages =
"vnd.sun.star.expand:$BUNDLED_EXTENSIONS";
380 that->m_registrationData =
"vnd.sun.star.expand:$BUNDLED_EXTENSIONS_USER";
381 that->m_registryCache =
"vnd.sun.star.expand:$BUNDLED_EXTENSIONS_USER/registry";
382 logFile =
"$BUNDLED_EXTENSIONS_USER/log.txt";
386 else if ( context ==
"tmp" ) {
387 that->m_activePackages =
"vnd.sun.star.expand:$TMP_EXTENSIONS/extensions";
388 that->m_registrationData =
"vnd.sun.star.expand:$TMP_EXTENSIONS";
389 that->m_registryCache =
"vnd.sun.star.expand:$TMP_EXTENSIONS/registry";
390 stamp =
"$TMP_EXTENSIONS";
392 else if (context ==
"bak") {
393 that->m_activePackages =
"vnd.sun.star.expand:$BAK_EXTENSIONS/extensions";
394 that->m_registrationData =
"vnd.sun.star.expand:$BAK_EXTENSIONS";
395 that->m_registryCache =
"vnd.sun.star.expand:$BAK_EXTENSIONS/registry";
396 stamp =
"$BAK_EXTENSIONS";
399 else if (! context.match(
"vnd.sun.star.tdoc:/")) {
400 throw lang::IllegalArgumentException(
401 "invalid context given: " + context,
402 Reference<XInterface>(),
static_cast<sal_Int16
>(-1) );
405 Reference<XCommandEnvironment> xCmdEnv;
409 if (!stamp.isEmpty())
410 that->m_readOnly = isMacroURLReadOnly( stamp );
412 if (!that->m_readOnly && !logFile.isEmpty())
415 rtl::Bootstrap::expandMacros(logFile);
417 const Reference<XLogger> xLogger(logger.
getLogger());
419 Sequence < beans::NamedValue > aSeq2 { {
"Formatter",
Any(xLogFormatter) }, {
"FileURL",
Any(logFile)} };
420 Reference<XLogHandler> xFileHandler(css::logging::FileHandler::createWithSettings(xComponentContext, aSeq2));
421 xFileHandler->setLevel(LogLevel::WARNING);
422 xLogger->addLogHandler(xFileHandler);
424 that->m_xLogFile.set(
425 that->m_xComponentContext->getServiceManager()
426 ->createInstanceWithArgumentsAndContext(
427 "com.sun.star.comp.deployment.ProgressLog",
429 that->m_xComponentContext ),
434 that->initRegistryBackends();
435 that->initActivationLayer( xCmdEnv );
444 Any exc( ::cppu::getCaughtException() );
445 throw lang::WrappedTargetRuntimeException(
446 (
"[context=\"" + context +
"\"] caught unexpected "
447 + exc.getValueType().getTypeName() +
": " + e.Message),
448 Reference<XInterface>(), exc );
462 if (pContainer !=
nullptr) {
463 pContainer->
forEach<util::XModifyListener>(
465 {
return xListener->modified(lang::EventObject(
static_cast<OWeakObject *
>(
this))); });
482 t_pm_helper::disposing();
489 Any exc( ::cppu::getCaughtException() );
490 throw lang::WrappedTargetRuntimeException(
491 "caught unexpected exception while disposing...",
492 static_cast<OWeakObject *
>(
this), exc );
502 WeakComponentImplHelperBase::dispose();
507 Reference<lang::XEventListener>
const & xListener )
511 WeakComponentImplHelperBase::addEventListener( xListener );
516 Reference<lang::XEventListener>
const & xListener )
520 WeakComponentImplHelperBase::removeEventListener( xListener );
532Sequence< Reference<deployment::XPackageTypeInfo> >
543 return new AbortChannel;
549 Reference<util::XModifyListener>
const & xListener )
552 rBHelper.addListener(
cppu::UnoType<
decltype(xListener)>::get(), xListener );
557 Reference<util::XModifyListener>
const & xListener )
560 rBHelper.removeListener(
cppu::UnoType<
decltype(xListener)>::get(), xListener );
568 OUString url( ucbContent.
getURL() );
570 if (url.match(
"vnd.sun.star.tdoc:" ) || url.match(
"vnd.sun.star.pkg:" ))
575 catch (
const beans::UnknownPropertyException &) {
577 OSL_ENSURE( !mediaType.isEmpty(),
"### no media-type?!" );
579 if (mediaType.isEmpty())
582 Reference<deployment::XPackage> xPackage(
585 const Reference<deployment::XPackageTypeInfo> xPackageType(
586 xPackage->getPackageType() );
587 OSL_ASSERT( xPackageType.is() );
588 if (xPackageType.is())
589 mediaType = xPackageType->getMediaType();
591 catch (
const lang::IllegalArgumentException &) {
603 Sequence<beans::NamedValue>
const &
properties,
608 Reference<XCommandEnvironment> xCmdEnv(
612 tempEntry = tempEntry.copy(tempEntry.lastIndexOf(
'/') + 1);
620 if (mediaType.matchIgnoreAsciiCase(
"application/vnd.sun.star.package-bundle") ||
622 mediaType.matchIgnoreAsciiCase(
"application/vnd.sun.star.legacy-package-bundle"))
628 buf.append(
"vnd.sun.star.zip://" );
629 buf.append( ::rtl::Uri::encode( sourceContent.
getURL(),
630 rtl_UriCharClassRegName,
631 rtl_UriEncodeIgnoreEscapes,
632 RTL_TEXTENCODING_UTF8 ) );
637 buf.append(sourceContent.
getURL());
645 title, NameClash::OVERWRITE );
653 DescriptionInfoset info =
658 dbData->
version = info.getVersion();
671 const ::osl::MutexGuard guard(
m_aMutex );
680 Reference<deployment::XPackage>
const &
package)
683 OUString fn(
package->getName());
684 bool bInstalled =
false;
695 Reference<deployment::XPackage>
const & extension,
696 Reference<task::XAbortChannel>
const & xAbortChannel,
697 Reference<XCommandEnvironment>
const & xCmdEnv_ )
699 return addPackage(extension->getURL(), Sequence<beans::NamedValue>(),
700 OUString(), xAbortChannel, xCmdEnv_);
707 OUString
const & url,
708 css::uno::Sequence<css::beans::NamedValue>
const &
properties,
709 OUString
const & mediaType_,
710 Reference<task::XAbortChannel>
const & xAbortChannel,
711 Reference<XCommandEnvironment>
const & xCmdEnv_ )
718 message =
"You need write permissions to install a shared extension!";
720 message =
"You need write permissions to install this extension!";
721 throw deployment::DeploymentException(
722 message,
static_cast<OWeakObject *
>(
this),
Any() );
724 Reference<XCommandEnvironment> xCmdEnv;
728 xCmdEnv.set( xCmdEnv_ );
733 const OUString title( StrTitle::getTitle( sourceContent ) );
734 const OUString title_enc( ::rtl::Uri::encode(
735 title, rtl_UriCharClassPchar,
736 rtl_UriEncodeIgnoreEscapes,
737 RTL_TEXTENCODING_UTF8 ) );
740 OUString mediaType(mediaType_);
741 if (mediaType.isEmpty())
744 Reference<deployment::XPackage> xPackage;
747 DpResId(RID_STR_COPYING_PACKAGE) + title, xCmdEnv );
770 catch (
const UnsupportedCommandException &) {
775 properties, mediaType, sourceContent, title, &dbData );
784 makeURL( destFolder, title_enc ), mediaType,
false, OUString(), xCmdEnv );
786 OSL_ASSERT( xPackage.is() );
789 bool install =
false;
821 catch (
const CommandFailedException & exc) {
825 catch (
const CommandAbortedException & exc) {
829 catch (
const deployment::DeploymentException & exc) {
834 Any exc( ::cppu::getCaughtException() );
836 throw deployment::DeploymentException(
837 DpResId(RID_STR_ERROR_WHILE_ADDING) + url,
838 static_cast<OWeakObject *
>(
this), exc );
842 Reference<deployment::XPackage>
const & xPackage,
843 OUString
const & destFolder)
849 erase_path( destFolder, Reference<XCommandEnvironment>(),
852 OUString url = destFolder.copy(0, destFolder.getLength() - 1);
853 erase_path( url, Reference<XCommandEnvironment>(),
859 OUString
const &
id, OUString
const & fileName,
860 Reference<task::XAbortChannel>
const & ,
861 Reference<XCommandEnvironment>
const & xCmdEnv_ )
865 Reference<XCommandEnvironment> xCmdEnv;
869 xCmdEnv.set( xCmdEnv_ );
872 Reference<deployment::XPackage> xPackage;
874 const ::osl::MutexGuard guard(
m_aMutex);
899 ::osl::Security aSecurity;
900 aSecurity.getUserName( aUserName );
903 Reference<css::io::XInputStream> xData(
904 ::xmlscript::createInputStream(
905 reinterpret_cast<sal_Int8 const *
>(stamp.getStr()),
906 stamp.getLength() ) );
911 m_xRegistry->packageRemoved(xPackage->getURL(), xPackage->getPackageType()->getMediaType());
920 catch (
const CommandFailedException & exc) {
924 catch (
const CommandAbortedException & exc) {
928 catch (
const deployment::DeploymentException & exc) {
933 Any exc( ::cppu::getCaughtException() );
935 throw deployment::DeploymentException(
936 DpResId(RID_STR_ERROR_WHILE_REMOVING) +
id,
937 static_cast<OWeakObject *
>(
this), exc );
951 + ::rtl::Uri::encode( data.
fileName, rtl_UriCharClassPchar,
952 rtl_UriEncodeIgnoreEscapes,
953 RTL_TEXTENCODING_UTF8 ) );
960 OUString
const &
id, OUString
const & fileName,
961 Reference<XCommandEnvironment>
const & xCmdEnv )
968 throw lang::IllegalArgumentException(
969 DpResId(RID_STR_NO_SUCH_PACKAGE) +
id,
970 static_cast<OWeakObject *
>(
this),
static_cast<sal_Int16
>(-1) );
975 std::u16string_view
id, ActivePackages::Data
const & data,
976 Reference<XCommandEnvironment>
const & xCmdEnv,
bool ignoreAlienPlatforms )
978 if (ignoreAlienPlatforms)
980 OUString
type, subType;
984 auto const iter = params.find(OString(
"platform"));
985 if (iter != params.end() && !
platform_fits(iter->second.m_sValue))
986 throw lang::IllegalArgumentException(
987 DpResId(RID_STR_NO_SUCH_PACKAGE) +
id,
988 static_cast<OWeakObject *
>(
this),
989 static_cast<sal_Int16
>(-1) );
992 Reference<deployment::XPackage> xExtension;
997 if (data.failedPrerequisites ==
"0")
1000 getDeployPath( data ), data.mediaType,
false, OUString(), xCmdEnv );
1003 catch (
const deployment::InvalidRemovedParameterException& e)
1005 xExtension = e.Extension;
1011Sequence< Reference<deployment::XPackage> >
1013 Reference<XCommandEnvironment>
const & xCmdEnv )
1015 std::vector< Reference<deployment::XPackage> > packages;
1017 for (
auto const& elem : id2temp)
1019 if (elem.second.failedPrerequisites !=
"0")
1024 elem.first, elem.second, xCmdEnv,
1028 catch (
const lang::IllegalArgumentException &) {
1032 catch (
const deployment::DeploymentException&) {
1042 OUString
const &
id, OUString
const & fileName,
1043 Reference<XCommandEnvironment>
const & xCmdEnv_ )
1046 Reference<XCommandEnvironment> xCmdEnv;
1050 xCmdEnv.set( xCmdEnv_ );
1053 const ::osl::MutexGuard guard(
m_aMutex );
1059 catch (
const CommandFailedException & exc) {
1063 catch (
const deployment::DeploymentException & exc) {
1068 Any exc( ::cppu::getCaughtException() );
1070 throw deployment::DeploymentException(
1072 "error while accessing deployed package: " +
id,
1073 static_cast<OWeakObject *
>(
this), exc );
1078Sequence< Reference<deployment::XPackage> >
1080 Reference<task::XAbortChannel>
const &,
1081 Reference<XCommandEnvironment>
const & xCmdEnv_ )
1084 Reference<XCommandEnvironment> xCmdEnv;
1088 xCmdEnv.set( xCmdEnv_ );
1091 const ::osl::MutexGuard guard(
m_aMutex );
1097 catch (
const CommandFailedException & exc) {
1101 catch (
const CommandAbortedException & exc) {
1105 catch (
const deployment::DeploymentException & exc) {
1110 Any exc( ::cppu::getCaughtException() );
1112 throw deployment::DeploymentException(
1114 "error while getting all deployed packages: " +
m_context,
1115 static_cast<OWeakObject *
>(
this), exc );
1123 sal_Bool force, Reference<task::XAbortChannel>
const & ,
1124 Reference<XCommandEnvironment>
const & xCmdEnv_ )
1129 "You must close any running Office process before reinstalling packages!",
1130 static_cast<OWeakObject *
>(
this) );
1132 Reference<XCommandEnvironment> xCmdEnv;
1136 xCmdEnv.set( xCmdEnv_ );
1139 ProgressLevel progress(
1140 xCmdEnv,
"Reinstalling all deployed packages..." );
1147 Reference<util::XUpdatable> xUpdatable(
m_xRegistry, UNO_QUERY );
1148 if (xUpdatable.is())
1149 xUpdatable->update();
1156 catch (
const CommandFailedException & exc) {
1160 catch (
const CommandAbortedException & exc) {
1164 catch (
const deployment::DeploymentException & exc) {
1169 Any exc( ::cppu::getCaughtException() );
1171 throw deployment::DeploymentException(
1172 "Error while reinstalling all previously deployed packages of context " +
m_context,
1173 static_cast<OWeakObject *
>(
this), exc );
1183 Reference<task::XAbortChannel>
const & xAbortChannel,
1184 Reference<css::ucb::XCommandEnvironment>
const & xCmdEnv)
1190 bool bModified =
false;
1195 for (
auto const& elem : id2temp)
1205 bool bRemoved =
false;
1210 &contentExtension, url,
1211 Reference<XCommandEnvironment>(),
false))
1220 if (!bRemoved && bShared)
1227 elem.second.temporaryName +
"removed",
1228 Reference<XCommandEnvironment>(),
false))
1240 "Extension Manager: bundled and shared extensions "
1241 "must have an identifier and a version");
1245 || elem.second.version != infoset.
getVersion()))
1253 Reference<deployment::XPackage> xPackage =
m_xRegistry->bindPackage(
1254 url, elem.second.mediaType,
true, elem.first, xCmdEnv );
1255 OSL_ASSERT(xPackage.is());
1256 xPackage->revokePackage(
true, xAbortChannel, xCmdEnv);
1257 removePackage(xPackage->getIdentifier().Value, xPackage->getName(),
1258 xAbortChannel, xCmdEnv);
1262 catch(
const uno::Exception & )
1272 Reference<task::XAbortChannel>
const & xAbortChannel,
1273 Reference<css::ucb::XCommandEnvironment>
const & xCmdEnv)
1275 bool bModified =
false;
1287 catch (
const css::ucb::ContentCreationException&)
1296 Reference<sdbc::XResultSet> xResultSet(
1297 StrTitle::createCursor( tempFolder,
1298 ::ucbhelper::INCLUDE_FOLDERS_ONLY ) );
1300 while (xResultSet->next())
1305 Reference<sdbc::XRow>(
1306 xResultSet, UNO_QUERY_THROW )->
getString(
1310 OUString title2 = title;
1314 OSL_ASSERT(title2.endsWith(
"_"));
1315 title2 = title2.copy(0, title2.getLength() -1);
1317 OUString titleEncoded = ::rtl::Uri::encode(
1318 title2, rtl_UriCharClassPchar,
1319 rtl_UriEncodeIgnoreEscapes,
1320 RTL_TEXTENCODING_UTF8);
1325 const MatchTempDir
match(titleEncoded);
1326 if (std::none_of( id2temp.begin(), id2temp.end(),
match ))
1332 OUString sExtFolder;
1339 Reference<XCommandEnvironment>(),
false))
1341 sExtFolder = getExtensionFolder(
1347 Reference<deployment::XPackage> xPackage =
m_xRegistry->bindPackage(
1348 url, OUString(),
false, OUString(), xCmdEnv );
1361 dbData.
mediaType = xPackage->getPackageType()->getMediaType();
1362 dbData.
version = xPackage->getVersion();
1364 dbData.
version.isEmpty(),
"desktop.deployment",
1365 "bundled/shared extension " <<
id <<
" at <" << url
1366 <<
"> has no explicit version");
1375 DescriptionInfoset info =
1377 ::std::optional<dp_misc::SimpleLicenseAttributes>
1378 attr = info.getSimpleLicenseAttributes();
1380 bool bNoLicense =
false;
1381 if (attr && attr->suppressIfRequired &&
props.isSuppressedLicense())
1384 Reference<ucb::XCommandEnvironment> licCmdEnv(
1387 sal_Int32 failedPrereq = xPackage->checkPrerequisites(
1388 xAbortChannel, licCmdEnv,
false);
1399 catch (
const uno::Exception &)
1409 Reference<task::XAbortChannel>
const & xAbortChannel,
1410 Reference<css::ucb::XCommandEnvironment>
const & xCmdEnv)
1413 bool bModified =
false;
1424 Reference<ucb::XCommandEnvironment>
const & xCmdEnv)
1426 std::vector<Reference<deployment::XPackage> > vec;
1430 const ::osl::MutexGuard guard(
m_aMutex );
1436 for (
auto const& elem : id2temp)
1443 if (failedPrereq ^ deployment::Prerequisites::LICENSE)
1451 Reference<deployment::XPackage>
p =
m_xRegistry->bindPackage(
1452 url, OUString(),
false, OUString(), xCmdEnv );
1458 return ::comphelper::containerToSequence(vec);
1460 catch (
const deployment::DeploymentException &)
1470 Any exc = ::cppu::getCaughtException();
1471 deployment::DeploymentException de(
1472 "PackageManagerImpl::getExtensionsWithUnacceptedLicenses",
1473 static_cast<OWeakObject*
>(
this), exc);
1475 ::cppu::throwException(exc);
1478 return ::comphelper::containerToSequence(vec);
1482 css::uno::Reference<css::deployment::XPackage>
const & extension,
1483 css::uno::Reference<css::task::XAbortChannel>
const & xAbortChannel,
1484 css::uno::Reference<css::ucb::XCommandEnvironment>
const & xCmdEnv )
1488 if (!extension.is())
1490 if (
m_context != extension->getRepositoryName())
1491 throw lang::IllegalArgumentException(
1492 "PackageManagerImpl::checkPrerequisites: extension is not from this repository.",
1499 throw lang::IllegalArgumentException(
1500 "PackageManagerImpl::checkPrerequisites: unknown extension",
1505 Reference<ucb::XCommandEnvironment> _xCmdEnv = xCmdEnv;
1507 if ( !(prereq & deployment::Prerequisites::LICENSE))
1510 sal_Int32 failedPrereq = extension->checkPrerequisites(
1511 xAbortChannel, _xCmdEnv,
false);
1516 catch (
const deployment::DeploymentException& ) {
1518 }
catch (
const ucb::CommandFailedException & ) {
1520 }
catch (
const ucb::CommandAbortedException & ) {
1522 }
catch (
const lang::IllegalArgumentException &) {
1524 }
catch (
const uno::RuntimeException &) {
1527 uno::Any excOccurred = ::cppu::getCaughtException();
1528 deployment::DeploymentException exc(
1529 "PackageManagerImpl::checkPrerequisites: exception ",
1530 static_cast<OWeakObject*
>(
this), excOccurred);
1542 Reference<XCommandEnvironment>
const & xUserCmdEnv,
1543 Reference<XProgressHandler>
const & xLogFile )
1546 if (xUserCmdEnv.is()) {
1554Reference<task::XInteractionHandler>
1557 return m_xUserInteractionHandler;
1561Reference<XProgressHandler>
1573 if (m_xUserProgress.is())
1574 m_xUserProgress->push(
Status );
1582 if (m_xUserProgress.is())
1583 m_xUserProgress->update(
Status );
1591 if (m_xUserProgress.is())
1592 m_xUserProgress->pop();
static bool parse(OUString const &rMediaType, OUString &rType, OUString &rSubType, INetContentTypeParameterList *pParameters=nullptr)
const css::uno::Reference< css::logging::XLogger > & getLogger() const
mutable::osl::Mutex m_aMutex
void forEach(FuncT const &func)
std::vector< std::pair< OUString, Data > > Entries
this class is for use in XPackageManager::synchronize.
this class is for use in XPackageManager::checkPrerequisites
virtual css::uno::Reference< css::task::XInteractionHandler > SAL_CALL getInteractionHandler() override
virtual css::uno::Reference< css::ucb::XProgressHandler > SAL_CALL getProgressHandler() override
virtual void SAL_CALL push(css::uno::Any const &Status) override
virtual void SAL_CALL update(css::uno::Any const &Status) override
css::uno::Reference< css::task::XInteractionHandler > m_xUserInteractionHandler
CmdEnvWrapperImpl(css::uno::Reference< css::ucb::XCommandEnvironment > const &xUserCmdEnv, css::uno::Reference< css::ucb::XProgressHandler > const &xLogFile)
virtual void SAL_CALL pop() override
css::uno::Reference< css::ucb::XProgressHandler > m_xUserProgress
virtual ~CmdEnvWrapperImpl() override
virtual css::uno::Reference< css::deployment::XPackage > SAL_CALL importExtension(css::uno::Reference< css::deployment::XPackage > const &extension, css::uno::Reference< css::task::XAbortChannel > const &xAbortChannel, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv) override
static void deletePackageFromCache(css::uno::Reference< css::deployment::XPackage > const &xPackage, OUString const &destFolder)
virtual void SAL_CALL reinstallDeployedPackages(sal_Bool force, css::uno::Reference< css::task::XAbortChannel > const &xAbortChannel, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv) override
OUString m_registrationData_expanded
virtual void SAL_CALL addModifyListener(css::uno::Reference< css::util::XModifyListener > const &xListener) override
virtual css::uno::Sequence< css::uno::Reference< css::deployment::XPackage > > SAL_CALL getDeployedPackages(css::uno::Reference< css::task::XAbortChannel > const &xAbortChannel, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv) override
virtual void SAL_CALL removeEventListener(css::uno::Reference< css::lang::XEventListener > const &xListener) override
bool synchronizeRemovedExtensions(css::uno::Reference< css::task::XAbortChannel > const &xAbortChannel, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv)
OUString m_activePackages
virtual void SAL_CALL addEventListener(css::uno::Reference< css::lang::XEventListener > const &xListener) override
css::uno::Reference< css::uno::XComponentContext > m_xComponentContext
OUString getDeployPath(ActivePackages::Data const &data)
void initRegistryBackends()
OUString m_registrationData
bool synchronizeAddedExtensions(css::uno::Reference< css::task::XAbortChannel > const &xAbortChannel, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv)
void insertToActivationLayerDB(OUString const &id, ActivePackages::Data const &dbData)
virtual void SAL_CALL removePackage(OUString const &id, OUString const &fileName, css::uno::Reference< css::task::XAbortChannel > const &xAbortChannel, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv) override
virtual css::uno::Sequence< css::uno::Reference< css::deployment::XPackageTypeInfo > > SAL_CALL getSupportedPackageTypes() override
virtual css::uno::Reference< css::deployment::XPackage > SAL_CALL getDeployedPackage(OUString const &id, OUString const &fileName, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv) override
virtual void SAL_CALL disposing() override
css::uno::Reference< css::deployment::XPackage > getDeployedPackage_(OUString const &id, OUString const &fileName, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv)
virtual css::uno::Sequence< css::uno::Reference< css::deployment::XPackage > > SAL_CALL getExtensionsWithUnacceptedLicenses(css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv) override
virtual ::sal_Bool SAL_CALL isReadOnly() override
std::unique_ptr< ActivePackages > m_activePackagesDB
OUString insertToActivationLayer(css::uno::Sequence< css::beans::NamedValue > const &properties, OUString const &mediaType, ::ucbhelper::Content const &sourceContent, OUString const &title, ActivePackages::Data *dbData)
virtual sal_Int32 SAL_CALL checkPrerequisites(css::uno::Reference< css::deployment::XPackage > const &extension, css::uno::Reference< css::task::XAbortChannel > const &xAbortChannel, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv) override
css::uno::Reference< css::ucb::XProgressHandler > m_xLogFile
virtual css::uno::Reference< css::deployment::XPackage > SAL_CALL addPackage(OUString const &url, css::uno::Sequence< css::beans::NamedValue > const &properties, OUString const &mediaType, css::uno::Reference< css::task::XAbortChannel > const &xAbortChannel, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv) override
virtual OUString SAL_CALL getContext() override
css::uno::Reference< css::deployment::XPackageRegistry > m_xRegistry
OUString detectMediaType(::ucbhelper::Content const &ucbContent, bool throw_exc=true)
virtual ::sal_Bool SAL_CALL synchronize(css::uno::Reference< css::task::XAbortChannel > const &xAbortChannel, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv) override
void initActivationLayer(css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv)
bool isInstalled(css::uno::Reference< css::deployment::XPackage > const &package)
OUString m_activePackages_expanded
css::uno::Sequence< css::uno::Reference< css::deployment::XPackage > > getDeployedPackages_(css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv)
void logIntern(css::uno::Any const &status)
virtual css::uno::Reference< css::task::XAbortChannel > SAL_CALL createAbortChannel() override
virtual ~PackageManagerImpl() override
static css::uno::Reference< css::deployment::XPackageManager > create(css::uno::Reference< css::uno::XComponentContext > const &xComponentContext, OUString const &context)
PackageManagerImpl(css::uno::Reference< css::uno::XComponentContext > xComponentContext, OUString context)
virtual void SAL_CALL removeModifyListener(css::uno::Reference< css::util::XModifyListener > const &xListener) override
virtual void SAL_CALL dispose() override
Access to the content of an XML description element.
bool hasDescription() const
::std::optional< OUString > getIdentifier() const
Return the identifier.
OUString getVersion() const
Return the textual version representation.
css::uno::Any setPropertyValue(const OUString &rPropertyName, const css::uno::Any &rValue)
const OUString & getURL() const
void transferContent(const Content &rSourceContent, InsertOperation eOperation, const OUString &rTitle, const sal_Int32 nNameClashAction, const OUString &rMimeType=OUString(), bool bMajorVersion=false, const OUString &rCommentVersion=OUString(), OUString *pResultURL=nullptr, const OUString &rDocumentId=OUString()) const
const css::uno::Reference< css::ucb::XCommandEnvironment > & getCommandEnvironment() const
css::uno::Any getPropertyValue(const OUString &rPropertyName)
css::uno::Any executeCommand(const OUString &rCommandName, const css::uno::Any &rCommandArgument)
void writeStream(const css::uno::Reference< css::io::XInputStream > &rStream, bool bReplaceExisting)
OString exceptionToString(const css::uno::Any &caught)
#define TOOLS_WARN_EXCEPTION(area, stream)
OUString DpResId(TranslateId aId)
std::unordered_map< OString, INetContentTypeParameter > INetContentTypeParameterList
static uno::Reference< css::uno::XComponentContext > xContext
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
OUString getString(const Any &_rAny)
bool match(const sal_Unicode *pWild, const sal_Unicode *pStr, const sal_Unicode cEscape)
Any SAL_CALL getCaughtException()
OUString makeURL(std::u16string_view baseURL, OUString const &relPath_)
appends a relative path to a url.
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC bool create_folder(::ucbhelper::Content *ucb_content, OUString const &url, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv, bool throw_exc=true)
OUString expandUnoRcUrl(OUString const &url)
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC bool erase_path(OUString const &url, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv, bool throw_exc=true)
void try_dispose(css::uno::Reference< css::uno::XInterface > const &x)
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC bool create_ucb_content(::ucbhelper::Content *ucb_content, OUString const &url, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv, bool throw_exc=true)
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC std::vector< sal_Int8 > readFile(::ucbhelper::Content &ucb_content)
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC bool platform_fits(std::u16string_view platform_string)
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC DescriptionInfoset getDescriptionInfoset(std::u16string_view sExtensionFolderURL)
creates a DescriptionInfoset object.
void progressUpdate(OUString const &status, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv)
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC OUString getIdentifier(css::uno::Reference< css::deployment::XPackage > const &package)
Gets the identifier of a package.
OUString makeURLAppendSysPathSegment(std::u16string_view baseURL, OUString const &segment)
appends a relative path to a url.
css::uno::Reference< css::deployment::XPackageRegistry > create(css::uno::Reference< css::deployment::XPackageRegistry > const &xRootRegistry, OUString const &context, OUString const &cachePath, css::uno::Reference< css::uno::XComponentContext > const &xComponentContext)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
OUString failedPrerequisites
bool createDirectory(std::u16string_view rURL)