22 #include <com/sun/star/beans/XPropertySet.hpp>
23 #include <com/sun/star/configuration/theDefaultProvider.hpp>
24 #include <com/sun/star/deployment/DeploymentException.hpp>
25 #include <com/sun/star/deployment/ExtensionManager.hpp>
26 #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
27 #include <com/sun/star/frame/Desktop.hpp>
28 #include <com/sun/star/frame/TerminationVetoException.hpp>
29 #include <com/sun/star/ucb/CommandAbortedException.hpp>
30 #include <com/sun/star/ucb/CommandFailedException.hpp>
33 #include <osl/diagnose.h>
57 const uno::Reference< uno::XComponentContext > &
xContext ) :
61 m_bExtMgrDialogExecuting(
false)
66 uno::Reference< lang::XMultiServiceFactory > xConfig(
67 configuration::theDefaultProvider::get(xContext));
70 {
"nodepath",
uno::Any(OUString(
"/org.openoffice.Office.OptionsDialog/Nodes"))}
73 xConfig->createInstanceWithArguments(
"com.sun.star.configuration.ConfigurationAccess", args),
74 uno::UNO_QUERY_THROW);
79 {
"nodepath",
uno::Any(OUString(
"/org.openoffice.Office.ExtensionManager/ExtensionRepositories"))}
81 uno::Reference< container::XNameAccess > xNameAccessRepositories;
82 xNameAccessRepositories.set(
83 xConfig->createInstanceWithArguments(
"com.sun.star.configuration.ConfigurationAccess", args2),
84 uno::UNO_QUERY_THROW);
87 uno::Any value = xNameAccessRepositories->getByName(
"WebsiteLink");
90 catch (
const uno::Exception& )
152 xExtMgrDialog->Close();
205 std::vector< uno::Reference< deployment::XPackage > > vEntries;
206 uno::Sequence< uno::Sequence< uno::Reference< deployment::XPackage > > > xAllPackages;
209 xAllPackages =
m_xExtensionManager->getAllExtensions( uno::Reference< task::XAbortChannel >(),
210 uno::Reference< ucb::XCommandEnvironment >() );
211 }
catch (
const deployment::DeploymentException & ) {
213 }
catch (
const ucb::CommandFailedException & ) {
215 }
catch (
const ucb::CommandAbortedException & ) {
217 }
catch (
const lang::IllegalArgumentException & e ) {
219 throw css::lang::WrappedTargetRuntimeException( e.Message,
223 for (
auto const &
i : std::as_const(xAllPackages) )
226 OSL_ASSERT(xPackage.is());
229 vEntries.push_back( xPackage );
239 if ( rPackageURL.isEmpty() )
244 bool bInstall =
true;
245 bool bInstallForAll =
false;
254 if ( bInstallForAll )
289 uno::Sequence< uno::Sequence< uno::Reference< deployment::XPackage > > > xAllPackages;
292 xAllPackages =
m_xExtensionManager->getAllExtensions( uno::Reference< task::XAbortChannel >(),
293 uno::Reference< ucb::XCommandEnvironment >() );
294 }
catch (
const deployment::DeploymentException & ) {
296 }
catch (
const ucb::CommandFailedException & ) {
298 }
catch (
const ucb::CommandAbortedException & ) {
300 }
catch (
const lang::IllegalArgumentException & e ) {
302 throw css::lang::WrappedTargetRuntimeException( e.Message,
306 for ( uno::Sequence< uno::Reference< deployment::XPackage > >
const & xPackageList : std::as_const(xAllPackages) )
308 for ( uno::Reference< deployment::XPackage >
const & xPackage : xPackageList )
323 uno::Reference< ucb::XCommandEnvironment >() );
324 for ( uno::Reference< deployment::XPackage >
const & xPackage : xNoLicPackages )
337 beans::Optional< beans::Ambiguous< sal_Bool > >
option(
338 xPackage->isRegistered( uno::Reference< task::XAbortChannel >(),
339 uno::Reference< ucb::XCommandEnvironment >() ) );
342 ::beans::Ambiguous< sal_Bool >
const & reg =
option.Value;
343 if ( reg.IsAmbiguous )
351 catch (
const uno::RuntimeException & ) {
354 catch (
const uno::Exception &) {
375 bool bOptions =
false;
377 if ( ! xPackage->isBundle() )
380 beans::Optional< OUString >
aId = xPackage->getIdentifier();
383 OSL_ASSERT( aId.IsPresent );
388 for ( OUString
const & nodeName : seqNames )
392 uno::Reference< XInterface> xIntNode = anyNode.get< uno::Reference< XInterface > >();
393 uno::Reference< container::XNameAccess > xNode( xIntNode, uno::UNO_QUERY_THROW );
395 uno::Any anyLeaves = xNode->getByName(
"Leaves");
396 uno::Reference< XInterface > xIntLeaves = anyLeaves.get< uno::Reference< XInterface > >();
397 uno::Reference< container::XNameAccess > xLeaves( xIntLeaves, uno::UNO_QUERY_THROW );
400 const uno::Sequence< OUString > seqLeafNames = xLeaves->getElementNames();
401 for ( OUString
const & leafName : seqLeafNames )
403 uno::Any anyLeaf = xLeaves->getByName( leafName );
404 uno::Reference< XInterface > xIntLeaf = anyLeaf.get< uno::Reference< XInterface > >();
405 uno::Reference< beans::XPropertySet > xLeaf( xIntLeaf, uno::UNO_QUERY_THROW );
408 uno::Any anyValue = xLeaf->getPropertyValue(
"Id");
410 OUString
sId = anyValue.get< OUString >();
411 if ( sId == aId.Value )
467 throw frame::TerminationVetoException(
468 "The office cannot be closed while the Extension Manager is running",
469 static_cast<frame::XTerminateListener*>(
this));
505 const uno::Reference< awt::XWindow > &xParent,
506 const OUString & extensionURL )
510 OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
511 if ( !extensionURL.isEmpty() )
512 s_ExtMgr->installPackage( extensionURL,
true );
521 OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
525 if ( !extensionURL.isEmpty() )
526 s_ExtMgr->installPackage( extensionURL,
true );
constexpr OUStringLiteral SHARED_PACKAGE_MANAGER
constexpr OUStringLiteral USER_PACKAGE_MANAGER
weld::Window * getDialog()
css::uno::Reference< css::awt::XWindow > m_xParent
void SetText(const OUString &rTitle)
OUString m_sGetExtensionsURL
virtual void SAL_CALL disposing(css::lang::EventObject const &evt) override
virtual void addPackageToList(const css::uno::Reference< css::deployment::XPackage > &xPackage, bool bLicenseMissing=false)=0
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)
virtual void checkEntries()=0
static::rtl::Reference< TheExtensionManager > get(css::uno::Reference< css::uno::XComponentContext > const &xContext, css::uno::Reference< css::awt::XWindow > const &xParent=nullptr, OUString const &view=OUString())
static bool runAsync(const std::shared_ptr< DialogController > &rController, const std::function< void(sal_Int32)> &)
TheExtensionManager(const css::uno::Reference< css::awt::XWindow > &xParent, const css::uno::Reference< css::uno::XComponentContext > &xContext)
virtual void SAL_CALL queryTermination(css::lang::EventObject const &evt) override
virtual void prepareChecking()=0
virtual void SAL_CALL modified(css::lang::EventObject const &evt) override
Any SAL_CALL getCaughtException()
constexpr OUStringLiteral USER_PACKAGE_MANAGER
virtual void SAL_CALL notifyTermination(css::lang::EventObject const &evt) override
constexpr OUStringLiteral SHARED_PACKAGE_MANAGER
std::unique_ptr< UpdateRequiredDialog > m_xUpdReqDialog
#define TOOLS_WARN_EXCEPTION(area, stream)
static::rtl::Reference< TheExtensionManager > s_ExtMgr
css::uno::Sequence< css::uno::Any > InitAnyPropertySequence(::std::initializer_list< ::std::pair< OUString, css::uno::Any > > vInit)
bool isReadOnly(const css::uno::Reference< css::deployment::XPackage > &xPackage) const
std::unique_ptr< ExtensionCmdQueue > m_xExecuteCmdQueue
static weld::Window * GetFrameWeld(const css::uno::Reference< css::awt::XWindow > &rWindow)
css::uno::Reference< css::uno::XComponentContext > m_xContext
DialogHelper * getDialogHelper()
bool m_bExtMgrDialogExecuting
bool supportsOptions(const css::uno::Reference< css::deployment::XPackage > &xPackage) const
virtual void set_title(const OUString &rTitle)=0
bool installPackage(const OUString &rPackageURL, bool bWarnUser=false)
std::shared_ptr< ExtMgrDialog > m_xExtMgrDialog
css::uno::Reference< css::deployment::XExtensionManager > m_xExtensionManager
static uno::Reference< css::uno::XComponentContext > xContext
virtual ~TheExtensionManager() override
bool installForAllUsers(bool &bInstallForAll)
static PackageState getPackageState(const css::uno::Reference< css::deployment::XPackage > &xPackage)
css::uno::Reference< css::container::XNameAccess > m_xNameAccessNodes
css::uno::Reference< css::frame::XDesktop2 > m_xDesktop
void createDialog(const bool bCreateUpdDlg)
Manages installing of extensions in the GUI mode.
uno::Reference< uno::XComponentContext > m_xContext
bool m_bDetectedRangeSegmentation false
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC css::uno::Reference< css::deployment::XPackage > getExtensionWithHighestVersion(css::uno::Sequence< css::uno::Reference< css::deployment::XPackage > > const &seqExtensionsWithSameId)