25#include <rtl/bootstrap.hxx>
26#include <com/sun/star/deployment/DeploymentException.hpp>
27#include <com/sun/star/deployment/XExtensionManager.hpp>
28#include <com/sun/star/deployment/thePackageManagerFactory.hpp>
29#include <com/sun/star/deployment/XPackageManager.hpp>
30#include <com/sun/star/deployment/XPackage.hpp>
31#include <com/sun/star/deployment/InstallException.hpp>
32#include <com/sun/star/deployment/VersionException.hpp>
33#include <com/sun/star/lang/IllegalArgumentException.hpp>
34#include <com/sun/star/lang/XServiceInfo.hpp>
35#include <com/sun/star/beans/Optional.hpp>
36#include <com/sun/star/task/XInteractionApprove.hpp>
37#include <com/sun/star/beans/Ambiguous.hpp>
38#include <com/sun/star/ucb/CommandAbortedException.hpp>
39#include <com/sun/star/ucb/CommandFailedException.hpp>
40#include <com/sun/star/uno/XComponentContext.hpp>
41#include <com/sun/star/io/XInputStream.hpp>
42#include <com/sun/star/util/XModifyBroadcaster.hpp>
46#include <osl/diagnose.h>
68using ::com::sun::star::uno::Reference;
74 bool operator() (std::vector<Reference<css::deployment::XPackage> >
const & a,
75 std::vector<Reference<css::deployment::XPackage> >
const & b)
77 return getName(a).compareTo(getName(b)) < 0;
80 static OUString getName(std::vector<Reference<css::deployment::XPackage> >
const & a);
83OUString CompIdentifiers::getName(std::vector<Reference<css::deployment::XPackage> >
const & a)
85 OSL_ASSERT(
a.size() == 3);
87 Reference<css::deployment::XPackage> extension;
88 for (
auto const& elem : a)
96 OSL_ASSERT(extension.is());
97 return extension->getDisplayName();
104 ::rtl::Bootstrap::expandMacros(url);
108 Reference<css::io::XInputStream> xData(
109 ::xmlscript::createInputStream(
110 reinterpret_cast<sal_Int8 const *
>(stamp.getStr()),
111 stamp.getLength() ) );
112 ucbStamp.writeStream( xData,
true );
116 uno::Any exc(::cppu::getCaughtException());
117 throw css::deployment::DeploymentException(
"Failed to update" + url,
nullptr, exc);
121class ExtensionRemoveGuard
123 css::uno::Reference<css::deployment::XPackage>
m_extension;
124 css::uno::Reference<css::deployment::XPackageManager> m_xPackageManager;
127 ExtensionRemoveGuard(){};
128 ExtensionRemoveGuard(
129 css::uno::Reference<css::deployment::XPackage> extension,
130 css::uno::Reference<css::deployment::XPackageManager> xPackageManager):
131 m_extension(
std::move(extension)), m_xPackageManager(
std::move(xPackageManager)) {}
132 ~ExtensionRemoveGuard();
134 void set(css::uno::Reference<css::deployment::XPackage>
const & extension,
135 css::uno::Reference<css::deployment::XPackageManager>
const & xPackageManager) {
137 m_xPackageManager = xPackageManager;
141ExtensionRemoveGuard::~ExtensionRemoveGuard()
144 OSL_ASSERT(!(
m_extension.is() && !m_xPackageManager.is()));
146 m_xPackageManager->removePackage(
148 css::uno::Reference<css::task::XAbortChannel>(),
149 css::uno::Reference<css::ucb::XCommandEnvironment>());
179 return "com.sun.star.comp.deployment.ExtensionManager";
190 return {
"com.sun.star.comp.deployment.ExtensionManager" };
216 return new dp_misc::AbortChannel;
219css::uno::Reference<css::deployment::XPackageManager>
222 Reference<css::deployment::XPackageManager> xPackageManager;
223 if (repository ==
u"user")
225 else if (repository ==
u"shared")
227 else if (repository ==
u"bundled")
229 else if (repository ==
u"tmp")
231 else if (repository ==
u"bak")
234 throw lang::IllegalArgumentException(
235 "No valid repository name provided.",
237 return xPackageManager;
249 uno::Sequence<Reference<css::deployment::XPackage> >
const & seqExt,
250 std::u16string_view repository)
257 if (repositoryName == repository)
262 for (
const Reference<css::deployment::XPackage>& xExtension : seqExt)
265 id2extensions::iterator ivec = mapExt.find(
id);
266 if (ivec == mapExt.end())
268 std::vector<Reference<css::deployment::XPackage> > vec(3);
269 vec[
index] = xExtension;
274 ivec->second[
index] = xExtension;
291std::vector<Reference<css::deployment::XPackage> >
293 OUString
const & identifier, OUString
const & fileName)
296 std::vector<Reference<css::deployment::XPackage> > extensionList;
297 Reference<css::deployment::XPackageManager> lRepos[] = {
299 for (std::size_t
i(0);
i != std::size(lRepos); ++
i)
301 Reference<css::deployment::XPackage> xPackage;
304 xPackage = lRepos[
i]->getDeployedPackage(
305 identifier, fileName, Reference<ucb::XCommandEnvironment>());
307 catch(
const lang::IllegalArgumentException &)
311 extensionList.push_back(xPackage);
313 OSL_ASSERT(extensionList.size() == 3);
314 return extensionList;
319 OUString
const & identifier,
320 OUString
const & fileName,
321 Reference< ucb::XCommandEnvironment>
const & )
325 std::vector<Reference<css::deployment::XPackage> > listExtensions =
327 bool bHasExtension =
false;
330 for (
auto const& extension : listExtensions)
331 bHasExtension |= extension.is();
333 throw lang::IllegalArgumentException(
334 "Could not find extension: " +
identifier +
", " + fileName,
339 catch (
const css::deployment::DeploymentException & )
343 catch (
const ucb::CommandFailedException & )
347 catch (css::uno::RuntimeException &)
353 uno::Any exc = ::cppu::getCaughtException();
354 throw css::deployment::DeploymentException(
355 "Extension Manager: exception during getExtensionsWithSameIdentifier",
356 static_cast<OWeakObject*
>(
this), exc);
361 OUString
const & identifier, OUString
const & fileName)
363 std::vector<Reference<css::deployment::XPackage> > listExtensions;
367 }
catch (
const lang::IllegalArgumentException & ) {
369 OSL_ASSERT(listExtensions.size() == 3);
371 return isUserDisabled( ::comphelper::containerToSequence(listExtensions) );
375 uno::Sequence<Reference<css::deployment::XPackage> >
const & seqExtSameId)
377 OSL_ASSERT(seqExtSameId.getLength() == 3);
378 Reference<css::deployment::XPackage>
const & userExtension = seqExtSameId[0];
379 if (userExtension.is())
381 beans::Optional<beans::Ambiguous<sal_Bool> > reg =
382 userExtension->isRegistered(Reference<task::XAbortChannel>(),
383 Reference<ucb::XCommandEnvironment>());
388 ! reg.Value.IsAmbiguous && ! reg.Value.Value)
410 OUString
const & identifier, OUString
const & fileName,
413 Reference<task::XAbortChannel>
const & xAbortChannel,
414 Reference<ucb::XCommandEnvironment>
const & xCmdEnv )
416 std::vector<Reference<css::deployment::XPackage> > listExtensions;
419 }
catch (
const lang::IllegalArgumentException &) {
421 OSL_ASSERT(listExtensions.size() == 3);
424 ::comphelper::containerToSequence(listExtensions),
425 bUserDisabled, bStartup, xAbortChannel, xCmdEnv);
431 uno::Sequence<Reference<css::deployment::XPackage> >
const & seqExt,
434 Reference<task::XAbortChannel>
const & xAbortChannel,
435 Reference<ucb::XCommandEnvironment>
const & xCmdEnv )
437 bool bActive =
false;
438 sal_Int32 len = seqExt.getLength();
439 for (sal_Int32 i = 0;
i < len;
i++)
441 Reference<css::deployment::XPackage>
const & aExt = seqExt[
i];
445 beans::Optional<beans::Ambiguous<sal_Bool> > optReg =
446 aExt->isRegistered(xAbortChannel, xCmdEnv);
448 if (!optReg.IsPresent)
452 if (i == 0 && bUserDisabled)
454 aExt->revokePackage(bStartup, xAbortChannel, xCmdEnv);
463 aExt->revokePackage(bStartup, xAbortChannel, xCmdEnv);
473 aExt->registerPackage(bStartup, xAbortChannel, xCmdEnv);
480 OUString
const & identifier, OUString
const & fileName,
481 Reference<css::deployment::XPackageManager>
const & xPackageManager,
482 Reference<ucb::XCommandEnvironment>
const & xCmdEnv )
484 Reference<css::deployment::XPackage> xBackup;
485 Reference<ucb::XCommandEnvironment> tmpCmdEnv(
487 Reference<css::deployment::XPackage> xOldExtension = xPackageManager->getDeployedPackage(
490 if (xOldExtension.is())
494 OUString(), Reference<task::XAbortChannel>(), tmpCmdEnv);
496 OSL_ENSURE(xBackup.is(),
"Failed to backup extension");
520 Reference<css::deployment::XPackageManager>
const & xPackageMgr,
522 css::uno::Reference<css::deployment::XPackage>
const & xTmpExtension,
523 Reference<task::XAbortChannel>
const & xAbortChannel,
524 Reference<ucb::XCommandEnvironment>
const & xCmdEnv,
525 Reference<css::deployment::XPackage> & out_existingExtension )
529 Reference<css::deployment::XPackage> xOldExtension;
531 const OUString sFileName = xTmpExtension->getName();
532 const OUString
sDisplayName = xTmpExtension->getDisplayName();
533 const OUString sVersion = xTmpExtension->getVersion();
537 xOldExtension = xPackageMgr->getDeployedPackage(
538 sIdentifier, sFileName, xCmdEnv);
539 out_existingExtension = xOldExtension;
541 catch (
const lang::IllegalArgumentException &)
544 bool bCanInstall =
false;
558 if (xOldExtension.is())
571 Reference<ucb::XCommandEnvironment> _xCmdEnv(xCmdEnv);
575 const ::std::optional<dp_misc::SimpleLicenseAttributes> licenseAttributes =
578 if (licenseAttributes && licenseAttributes->suppressIfRequired
579 &&
props.isSuppressedLicense())
582 bCanInstall = xTmpExtension->checkPrerequisites(
583 xAbortChannel, _xCmdEnv, xOldExtension.is() ||
props.isExtensionUpdate()) == 0;
587 catch (
const css::deployment::DeploymentException& ) {
589 }
catch (
const ucb::CommandFailedException & ) {
591 }
catch (
const ucb::CommandAbortedException & ) {
593 }
catch (
const lang::IllegalArgumentException &) {
595 }
catch (
const uno::RuntimeException &) {
597 }
catch (
const uno::Exception &) {
598 uno::Any excOccurred = ::cppu::getCaughtException();
599 css::deployment::DeploymentException exc(
600 "Extension Manager: exception in doChecksForAddExtension",
601 static_cast<OWeakObject*
>(
this), excOccurred);
604 throw uno::RuntimeException(
605 "Extension Manager: unexpected exception in doChecksForAddExtension",
606 static_cast<OWeakObject*
>(
this));
613 OUString
const & repository,
614 Reference<task::XAbortChannel>
const & xAbortChannel,
615 Reference<ucb::XCommandEnvironment>
const & xCmdEnv )
617 Reference<css::deployment::XPackage> xNewExtension;
619 Reference<css::deployment::XPackageManager> xPackageManager;
620 if (repository ==
"user")
622 else if (repository ==
"shared")
625 throw lang::IllegalArgumentException(
626 "No valid repository name provided.",
632 Reference<css::deployment::XPackageManager> xTmpRepository(
getTmpRepository());
637 Reference<css::deployment::XPackage> xTmpExtension(
638 xTmpRepository->addPackage(
641 if (!xTmpExtension.is()) {
642 throw css::deployment::DeploymentException(
643 (
"Extension Manager: Failed to create temporary XPackage for url: "
645 static_cast<OWeakObject*
>(
this),
uno::Any());
650 ExtensionRemoveGuard tmpExtensionRemoveGuard(xTmpExtension,
getTmpRepository());
651 ExtensionRemoveGuard bakExtensionRemoveGuard;
653 const OUString sFileName = xTmpExtension->getName();
654 Reference<css::deployment::XPackage> xOldExtension;
655 Reference<css::deployment::XPackage> xExtensionBackup;
667 bool bUserDisabled =
false;
681 if (xOldExtension.is())
685 xOldExtension->revokePackage(
686 false, xAbortChannel, Reference<ucb::XCommandEnvironment>());
689 xOldExtension, Reference<task::XAbortChannel>(),
690 Reference<ucb::XCommandEnvironment>());
693 catch (
const lang::DisposedException &)
704 sal_Int32 failedPrereq = xTmpExtension->checkPrerequisites(
705 xAbortChannel, pSilentCommandEnv,
true);
706 if (failedPrereq == 0)
708 xNewExtension = xPackageManager->addPackage(
710 Reference<ucb::XCommandEnvironment>());
715 bool bUserDisabled2 = bUserDisabled;
716 if (repository ==
"user")
717 bUserDisabled2 =
false;
721 OUString sNewExtensionFileName = xNewExtension->getName();
724 sNewExtensionIdentifier, sNewExtensionFileName,
725 bUserDisabled2,
false, xAbortChannel,
726 Reference<ucb::XCommandEnvironment>());
737 }
catch (
const css::deployment::DeploymentException& ) {
739 }
catch (
const ucb::CommandFailedException & ) {
741 }
catch (
const ucb::CommandAbortedException & ) {
743 }
catch (
const lang::IllegalArgumentException &) {
745 }
catch (
const uno::RuntimeException &) {
747 }
catch (
const uno::Exception &) {
748 uno::Any excOccurred = ::cppu::getCaughtException();
749 css::deployment::DeploymentException exc(
750 "Extension Manager: Exception on fireModified() "
751 "in the scope of 'if (failedPrereq == 0)'",
752 static_cast<OWeakObject*
>(
this), excOccurred);
755 throw uno::RuntimeException(
756 "Extension Manager: RuntimeException on fireModified() "
757 "in the scope of 'if (failedPrereq == 0)'",
758 static_cast<OWeakObject*
>(
this));
763 if (pSilentCommandEnv->m_Exception.hasValue())
764 ::cppu::throwException(pSilentCommandEnv->m_Exception);
765 else if ( pSilentCommandEnv->m_UnknownException.hasValue())
766 ::cppu::throwException(pSilentCommandEnv->m_UnknownException);
768 throw css::deployment::DeploymentException (
769 "Extension Manager: exception during addExtension, ckeckPrerequisites failed",
770 static_cast<OWeakObject*
>(
this),
uno::Any());
773 catch (
const css::deployment::DeploymentException& ) {
774 excOccurred2 = ::cppu::getCaughtException();
775 }
catch (
const ucb::CommandFailedException & ) {
776 excOccurred2 = ::cppu::getCaughtException();
777 }
catch (
const ucb::CommandAbortedException & ) {
778 excOccurred2 = ::cppu::getCaughtException();
779 }
catch (
const lang::IllegalArgumentException &) {
780 excOccurred2 = ::cppu::getCaughtException();
781 }
catch (
const uno::RuntimeException &) {
782 excOccurred2 = ::cppu::getCaughtException();
784 excOccurred2 = ::cppu::getCaughtException();
785 css::deployment::DeploymentException exc(
786 "Extension Manager: exception during addExtension, url: "
787 + url,
static_cast<OWeakObject*
>(
this), excOccurred2);
788 excOccurred2 <<= exc;
801 if (xExtensionBackup.is())
803 xPackageManager->importExtension(
804 xExtensionBackup, Reference<task::XAbortChannel>(),
805 Reference<ucb::XCommandEnvironment>());
808 sIdentifier, sFileName, bUserDisabled,
false,
809 Reference<task::XAbortChannel>(), Reference<ucb::XCommandEnvironment>());
814 ::cppu::throwException(excOccurred2);
818 return xNewExtension;
822 OUString
const & identifier, OUString
const & fileName,
823 OUString
const & repository,
824 Reference<task::XAbortChannel>
const & xAbortChannel,
825 Reference<ucb::XCommandEnvironment>
const & xCmdEnv )
828 Reference<css::deployment::XPackage> xExtensionBackup;
829 Reference<css::deployment::XPackageManager> xPackageManager;
830 bool bUserDisabled =
false;
835 if (repository ==
"user")
837 else if (repository ==
"shared")
840 throw lang::IllegalArgumentException(
841 "No valid repository name provided.",
847 identifier, fileName, xPackageManager, xCmdEnv);
850 Reference<css::deployment::XPackage> xOldExtension =
851 xPackageManager->getDeployedPackage(
853 xOldExtension->revokePackage(
false, xAbortChannel, xCmdEnv);
855 xPackageManager->removePackage(
856 identifier, fileName, xAbortChannel, xCmdEnv);
858 xAbortChannel, xCmdEnv);
861 catch (
const css::deployment::DeploymentException& ) {
862 excOccurred1 = ::cppu::getCaughtException();
863 }
catch (
const ucb::CommandFailedException & ) {
864 excOccurred1 = ::cppu::getCaughtException();
865 }
catch (
const ucb::CommandAbortedException & ) {
866 excOccurred1 = ::cppu::getCaughtException();
867 }
catch (
const lang::IllegalArgumentException &) {
868 excOccurred1 = ::cppu::getCaughtException();
869 }
catch (
const uno::RuntimeException &) {
870 excOccurred1 = ::cppu::getCaughtException();
872 excOccurred1 = ::cppu::getCaughtException();
873 css::deployment::DeploymentException exc(
874 "Extension Manager: exception during removeExtension",
875 static_cast<OWeakObject*
>(
this), excOccurred1);
876 excOccurred1 <<= exc;
885 Reference<ucb::XCommandEnvironment> tmpCmdEnv(
887 if (xExtensionBackup.is())
889 xPackageManager->importExtension(
890 xExtensionBackup, Reference<task::XAbortChannel>(),
894 Reference<task::XAbortChannel>(),
899 xExtensionBackup->getName(), xAbortChannel, xCmdEnv);
906 ::cppu::throwException(excOccurred1);
909 if (xExtensionBackup.is())
912 xExtensionBackup->getName(), xAbortChannel, xCmdEnv);
917 Reference<css::deployment::XPackage>
const & extension,
918 Reference<task::XAbortChannel>
const & xAbortChannel,
919 Reference<ucb::XCommandEnvironment>
const & xCmdEnv)
922 bool bUserDisabled =
false;
928 OUString repository = extension->getRepositoryName();
929 if (repository !=
"user")
930 throw lang::IllegalArgumentException(
931 "No valid repository name provided.",
935 extension->getName());
938 extension->getName(),
false,
false,
939 xAbortChannel, xCmdEnv);
941 catch (
const css::deployment::DeploymentException& ) {
942 excOccurred = ::cppu::getCaughtException();
943 }
catch (
const ucb::CommandFailedException & ) {
944 excOccurred = ::cppu::getCaughtException();
945 }
catch (
const ucb::CommandAbortedException & ) {
946 excOccurred = ::cppu::getCaughtException();
947 }
catch (
const lang::IllegalArgumentException &) {
948 excOccurred = ::cppu::getCaughtException();
949 }
catch (
const uno::RuntimeException &) {
950 excOccurred = ::cppu::getCaughtException();
952 excOccurred = ::cppu::getCaughtException();
953 css::deployment::DeploymentException exc(
954 "Extension Manager: exception during enableExtension",
955 static_cast<OWeakObject*
>(
this), excOccurred);
965 extension->getName(), bUserDisabled,
false,
966 xAbortChannel, xCmdEnv);
971 ::cppu::throwException(excOccurred);
975 Reference<css::deployment::XPackage>
const & extension,
976 Reference<task::XAbortChannel>
const & xAbortChannel,
977 Reference<ucb::XCommandEnvironment>
const & xCmdEnv)
985 Reference<css::deployment::XPackageManager> mgr =
987 ret = mgr->checkPrerequisites(extension, xAbortChannel, xCmdEnv);
991 extension->revokePackage(
false, xAbortChannel, xCmdEnv);
996 xAbortChannel, xCmdEnv);
999 catch (
const css::deployment::DeploymentException& ) {
1001 }
catch (
const ucb::CommandFailedException & ) {
1003 }
catch (
const ucb::CommandAbortedException & ) {
1005 }
catch (
const lang::IllegalArgumentException &) {
1007 }
catch (
const uno::RuntimeException &) {
1010 uno::Any excOccurred = ::cppu::getCaughtException();
1011 css::deployment::DeploymentException exc(
1012 "Extension Manager: exception during disableExtension",
1013 static_cast<OWeakObject*
>(
this), excOccurred);
1019 Reference<css::deployment::XPackage>
const & extension,
1020 Reference<task::XAbortChannel>
const & xAbortChannel,
1021 Reference<ucb::XCommandEnvironment>
const & xCmdEnv )
1025 bool bUserDisabled =
false;
1028 if (!extension.is())
1030 const OUString repository( extension->getRepositoryName());
1031 if (repository !=
"user")
1032 throw lang::IllegalArgumentException(
1033 "No valid repository name provided.",
1040 xAbortChannel, xCmdEnv);
1042 catch (
const css::deployment::DeploymentException& ) {
1043 excOccurred = ::cppu::getCaughtException();
1044 }
catch (
const ucb::CommandFailedException & ) {
1045 excOccurred = ::cppu::getCaughtException();
1046 }
catch (
const ucb::CommandAbortedException & ) {
1047 excOccurred = ::cppu::getCaughtException();
1048 }
catch (
const lang::IllegalArgumentException &) {
1049 excOccurred = ::cppu::getCaughtException();
1050 }
catch (
const uno::RuntimeException &) {
1051 excOccurred = ::cppu::getCaughtException();
1053 excOccurred = ::cppu::getCaughtException();
1054 css::deployment::DeploymentException exc(
1055 "Extension Manager: exception during disableExtension",
1056 static_cast<OWeakObject*
>(
this), excOccurred);
1057 excOccurred <<= exc;
1066 extension->getName(), bUserDisabled,
false,
1067 xAbortChannel, xCmdEnv);
1072 ::cppu::throwException(excOccurred);
1077 OUString
const & repository,
1078 Reference<task::XAbortChannel>
const &xAbort,
1079 Reference<ucb::XCommandEnvironment>
const & xCmdEnv )
1085Reference<css::deployment::XPackage>
1087 OUString
const & repository,
1088 OUString
const & identifier,
1089 OUString
const & filename,
1090 Reference<ucb::XCommandEnvironment>
const & xCmdEnv )
1098 Reference<task::XAbortChannel>
const & xAbort,
1099 Reference<ucb::XCommandEnvironment>
const & xCmdEnv )
1120 std::vector< std::vector<Reference<css::deployment::XPackage> > >
1122 for (
auto const& elem : mapExt)
1123 vecExtensions.push_back(elem.second);
1126 std::sort(vecExtensions.begin(), vecExtensions.end(), CompIdentifiers());
1130 auto seqSeqRange = asNonConstRange(seqSeq);
1131 for (
auto const& elem : vecExtensions)
1137 }
catch (
const css::deployment::DeploymentException& ) {
1139 }
catch (
const ucb::CommandFailedException & ) {
1141 }
catch (
const ucb::CommandAbortedException & ) {
1143 }
catch (
const lang::IllegalArgumentException &) {
1145 }
catch (
const uno::RuntimeException &) {
1148 uno::Any exc = ::cppu::getCaughtException();
1149 throw css::deployment::DeploymentException(
1150 "Extension Manager: exception during enableExtension",
1151 static_cast<OWeakObject*
>(
this), exc);
1158 sal_Bool force, OUString
const & repository,
1159 Reference<task::XAbortChannel>
const & xAbortChannel,
1160 Reference<ucb::XCommandEnvironment>
const & xCmdEnv )
1164 Reference<css::deployment::XPackageManager>
1167 std::set< OUString > disabledExts;
1170 xPackageManager->getDeployedPackages(xAbortChannel, xCmdEnv));
1175 beans::Optional< beans::Ambiguous< sal_Bool > > registered(
1176 package->isRegistered(xAbortChannel, xCmdEnv));
1177 if (registered.IsPresent &&
1178 !(registered.Value.IsAmbiguous ||
1179 registered.Value.Value))
1182 OSL_ASSERT(!
id.isEmpty());
1183 disabledExts.insert(
id);
1186 catch (
const lang::DisposedException &)
1193 xPackageManager->reinstallDeployedPackages(
1194 force, xAbortChannel, xCmdEnv);
1199 xPackageManager->getDeployedPackages(xAbortChannel, xCmdEnv));
1206 const OUString fileName =
package->getName();
1207 OSL_ASSERT(!
id.isEmpty());
1209 id, fileName, disabledExts.find(
id) != disabledExts.end(),
1210 true, xAbortChannel, xCmdEnv );
1212 catch (
const lang::DisposedException &)
1216 }
catch (
const css::deployment::DeploymentException& ) {
1218 }
catch (
const ucb::CommandFailedException & ) {
1220 }
catch (
const ucb::CommandAbortedException & ) {
1222 }
catch (
const lang::IllegalArgumentException &) {
1224 }
catch (
const uno::RuntimeException &) {
1227 uno::Any exc = ::cppu::getCaughtException();
1228 throw css::deployment::DeploymentException(
1229 "Extension Manager: exception during enableExtension",
1230 static_cast<OWeakObject*
>(
this), exc);
1235 Reference<task::XAbortChannel>
const & xAbortChannel,
1236 Reference<ucb::XCommandEnvironment>
const & xCmdEnv )
1242 sSynchronizingShared = sSynchronizingShared.replaceAll(
"%NAME",
"shared");
1245 progressShared.
update(
"\n\n");
1248 sSynchronizingBundled = sSynchronizingBundled.replaceAll(
"%NAME",
"bundled");
1251 progressBundled.
update(
"\n\n");
1266 for (
uno::Sequence<Reference<css::deployment::XPackage> >
const & seqExt : seqSeqExt)
1269 xAbortChannel, xCmdEnv);
1276 OSL_FAIL(
"Extensions Manager: synchronize");
1278 OUString lastSyncBundled(
"$BUNDLED_EXTENSIONS_USER/lastsynchronized");
1279 writeLastModified(lastSyncBundled, xCmdEnv,
m_xContext);
1280 OUString lastSyncShared(
"$SHARED_EXTENSIONS_USER/lastsynchronized");
1281 writeLastModified(lastSyncShared, xCmdEnv,
m_xContext);
1283 }
catch (
const css::deployment::DeploymentException& ) {
1285 }
catch (
const ucb::CommandFailedException & ) {
1287 }
catch (
const ucb::CommandAbortedException & ) {
1289 }
catch (
const lang::IllegalArgumentException &) {
1291 }
catch (
const uno::RuntimeException &) {
1294 uno::Any exc = ::cppu::getCaughtException();
1295 throw css::deployment::DeploymentException(
1296 "Extension Manager: exception in synchronize",
1297 static_cast<OWeakObject*
>(
this), exc);
1309 OUString
const & displayName,
1310 Reference<ucb::XCommandEnvironment>
const & cmdEnv)
1313 css::deployment::InstallException(
1314 "Extension " + displayName +
1315 " is about to be installed.",
1316 static_cast<OWeakObject *
>(
this), displayName));
1317 bool approve =
false, abort =
false;
1320 cmdEnv, &approve, &abort ))
1322 OSL_ASSERT( !approve && !abort );
1323 throw css::deployment::DeploymentException(
1324 DpResId(RID_STR_ERROR_WHILE_ADDING) + displayName,
1325 static_cast<OWeakObject *
>(
this), request );
1327 if (abort || !approve)
1328 throw ucb::CommandFailedException(
1329 DpResId(RID_STR_ERROR_WHILE_ADDING) + displayName,
1330 static_cast<OWeakObject *
>(
this), request );
1338 OUString
const & newVersion,
1339 OUString
const & newDisplayName,
1340 Reference<css::deployment::XPackage>
const & oldExtension,
1341 Reference<ucb::XCommandEnvironment>
const & xCmdEnv )
1345 (css::deployment::VersionException(
1347 RID_STR_PACKAGE_ALREADY_ADDED ) + newDisplayName,
1348 static_cast<OWeakObject *
>(
this), newVersion, newDisplayName,
1350 bool replace =
false, abort =
false;
1353 xCmdEnv, &replace, &abort )) {
1354 OSL_ASSERT( !replace && !abort );
1355 throw css::deployment::DeploymentException(
1357 RID_STR_ERROR_WHILE_ADDING) + newDisplayName,
1358 static_cast<OWeakObject *
>(
this), request );
1360 if (abort || !replace)
1361 throw ucb::CommandFailedException(
1363 RID_STR_PACKAGE_ALREADY_ADDED) + newDisplayName,
1364 static_cast<OWeakObject *
>(
this), request );
1369 OUString
const & repository,
1370 Reference<ucb::XCommandEnvironment>
const & xCmdEnv)
1372 Reference<css::deployment::XPackageManager>
1375 return xPackageManager->getExtensionsWithUnacceptedLicenses(xCmdEnv);
1387 Reference<util::XModifyListener>
const & xListener )
1390 rBHelper.addListener(
cppu::UnoType<
decltype(xListener)>::get(), xListener );
1395 Reference<util::XModifyListener>
const & xListener )
1398 rBHelper.removeListener(
cppu::UnoType<
decltype(xListener)>::get(), xListener );
1403 ::osl::MutexGuard guard(
m_aMutex );
1404 if (rBHelper.bInDispose || rBHelper.bDisposed) {
1405 throw lang::DisposedException(
1406 "ExtensionManager instance has already been disposed!",
1407 static_cast<OWeakObject *
>(
this) );
1415 if (pContainer !=
nullptr) {
1416 pContainer->
forEach<util::XModifyListener>(
1418 {
return xListener->modified(lang::EventObject(
static_cast<OWeakObject *
>(
this))); });
1425extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
1427 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any>
const& )
mutable::osl::Mutex m_aMutex
void forEach(FuncT const &func)
virtual css::uno::Sequence< css::uno::Sequence< css::uno::Reference< css::deployment::XPackage > > > SAL_CALL getAllExtensions(css::uno::Reference< css::task::XAbortChannel > const &, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv) override
virtual void SAL_CALL removeExtension(OUString const &identifier, OUString const &filename, OUString const &repository, css::uno::Reference< css::task::XAbortChannel > const &xAbortChannel, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv) override
virtual css::uno::Reference< css::task::XAbortChannel > SAL_CALL createAbortChannel() override
virtual css::uno::Sequence< css::uno::Reference< css::deployment::XPackage > > SAL_CALL getExtensionsWithSameIdentifier(OUString const &identifier, OUString const &filename, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv) override
virtual sal_Bool SAL_CALL synchronize(css::uno::Reference< css::task::XAbortChannel > const &xAbortChannel, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv) override
virtual css::uno::Reference< css::deployment::XPackage > SAL_CALL getDeployedExtension(OUString const &repository, OUString const &identifier, OUString const &filename, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv) override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
css::uno::Reference< css::uno::XComponentContext > m_xContext
css::uno::Reference< css::deployment::XPackageManager > getTmpRepository()
virtual sal_Bool SAL_CALL isReadOnlyRepository(OUString const &repository) override
css::uno::Reference< css::deployment::XPackageManagerFactory > m_xPackageManagerFactory
css::uno::Reference< css::deployment::XPackageManager > getSharedRepository()
void checkUpdate(OUString const &newVersion, OUString const &newDisplayName, css::uno::Reference< css::deployment::XPackage > const &oldExtension, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv)
virtual void SAL_CALL disableExtension(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
virtual OUString SAL_CALL getImplementationName() override
css::uno::Reference< css::deployment::XPackageManager > getBundledRepository()
void addExtensionsToMap(id2extensions &mapExt, css::uno::Sequence< css::uno::Reference< css::deployment::XPackage > > const &seqExt, std::u16string_view repository)
css::uno::Reference< css::deployment::XPackageManager > getUserRepository()
bool doChecksForAddExtension(css::uno::Reference< css::deployment::XPackageManager > const &xPackageMgr, css::uno::Sequence< css::beans::NamedValue > const &properties, css::uno::Reference< css::deployment::XPackage > const &xTmpExtension, css::uno::Reference< css::task::XAbortChannel > const &xAbortChannel, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv, css::uno::Reference< css::deployment::XPackage > &out_existingExtension)
virtual css::uno::Sequence< css::uno::Reference< css::deployment::XPackage > > SAL_CALL getExtensionsWithUnacceptedLicenses(OUString const &repository, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv) override
css::uno::Reference< css::deployment::XPackageManager > getBakRepository()
css::uno::Reference< css::deployment::XPackage > backupExtension(OUString const &identifier, OUString const &fileName, css::uno::Reference< css::deployment::XPackageManager > const &xPackageManager, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv)
std::vector< css::uno::Reference< css::deployment::XPackage > > getExtensionsWithSameId(OUString const &identifier, OUString const &fileName)
bool isUserDisabled(OUString const &identifier, OUString const &filename)
void activateExtension(OUString const &identifier, OUString const &fileName, bool bUserDisabled, bool bStartup, css::uno::Reference< css::task::XAbortChannel > const &xAbortChannel, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv)
virtual void SAL_CALL addModifyListener(css::uno::Reference< css::util::XModifyListener > const &xListener) override
css::uno::Reference< css::deployment::XPackageManager > getPackageManager(std::u16string_view repository)
virtual void SAL_CALL enableExtension(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
virtual ~ExtensionManager() override
virtual css::uno::Sequence< css::uno::Reference< css::deployment::XPackageTypeInfo > > SAL_CALL getSupportedPackageTypes() override
virtual void SAL_CALL removeModifyListener(css::uno::Reference< css::util::XModifyListener > const &xListener) override
virtual css::uno::Sequence< css::uno::Reference< css::deployment::XPackage > > SAL_CALL getDeployedExtensions(OUString const &repository, css::uno::Reference< css::task::XAbortChannel > const &, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv) override
ExtensionManager(css::uno::Reference< css::uno::XComponentContext >const &xContext)
std::vector< OUString > m_repositoryNames
virtual sal_Int32 SAL_CALL checkPrerequisitesAndEnable(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
void checkInstall(OUString const &displayName, css::uno::Reference< css::ucb::XCommandEnvironment > const &cmdEnv)
virtual css::uno::Reference< css::deployment::XPackage > SAL_CALL addExtension(OUString const &url, css::uno::Sequence< css::beans::NamedValue > const &properties, OUString const &repository, css::uno::Reference< css::task::XAbortChannel > const &xAbortChannel, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv) override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
static OUString StrSyncRepository()
virtual void SAL_CALL reinstallDeployedExtensions(sal_Bool force, OUString const &repository, css::uno::Reference< css::task::XAbortChannel > const &xAbortChannel, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv) override
this class is for use in XPackageManager::checkPrerequisites
Access to the content of an XML description element.
::std::optional< SimpleLicenseAttributes > getSimpleLicenseAttributes() const
returns the attributes of the simple-license element
void update(OUString const &status) const
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_deployment_ExtensionManager_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
uno::Reference< uno::XComponentContext > m_xContext
const uno::Reference< deployment::XPackage > m_extension
OUString DpResId(TranslateId aId)
static uno::Reference< css::uno::XComponentContext > xContext
void set(css::uno::UnoInterfaceReference const &value)
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
std::unordered_map< OUString, std::vector< css::uno::Reference< css::deployment::XPackage > > > id2extensions
void syncRepositories(bool force, Reference< ucb::XCommandEnvironment > const &xCmdEnv)
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC bool interactContinuation(css::uno::Any const &request, css::uno::Type const &continuation, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv, bool *pcont, bool *pabort)
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC bool erase_path(OUString const &url, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv, bool throw_exc=true)
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC DescriptionInfoset getDescriptionInfoset(std::u16string_view sExtensionFolderURL)
creates a DescriptionInfoset object.
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC OUString getIdentifier(css::uno::Reference< css::deployment::XPackage > const &package)
Gets the identifier of a package.
::boost::spirit::classic::rule< ScannerT > identifier