1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir 29*cdf0e10cSrcweir #if ! defined INCLUDED_DP_EXTENSIONMANAGER_H 30*cdf0e10cSrcweir #define INCLUDED_DP_EXTENSIONMANAGER_H 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir #include "dp_manager.hrc" 33*cdf0e10cSrcweir #include "dp_misc.h" 34*cdf0e10cSrcweir #include "dp_interact.h" 35*cdf0e10cSrcweir #include "dp_activepackages.hxx" 36*cdf0e10cSrcweir #include "rtl/ref.hxx" 37*cdf0e10cSrcweir #include "cppuhelper/compbase1.hxx" 38*cdf0e10cSrcweir #include "ucbhelper/content.hxx" 39*cdf0e10cSrcweir #include "com/sun/star/deployment/XPackageRegistry.hpp" 40*cdf0e10cSrcweir #include "com/sun/star/deployment/XPackageManager.hpp" 41*cdf0e10cSrcweir #include "osl/mutex.hxx" 42*cdf0e10cSrcweir #include <list> 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir namespace css = ::com::sun::star; 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir namespace dp_manager { 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir typedef ::std::hash_map< 50*cdf0e10cSrcweir ::rtl::OUString, 51*cdf0e10cSrcweir ::std::vector<css::uno::Reference<css::deployment::XPackage> >, 52*cdf0e10cSrcweir ::rtl::OUStringHash > id2extensions; 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir class ExtensionManager : private ::dp_misc::MutexHolder, 56*cdf0e10cSrcweir public ::cppu::WeakComponentImplHelper1< css::deployment::XExtensionManager > 57*cdf0e10cSrcweir { 58*cdf0e10cSrcweir public: 59*cdf0e10cSrcweir ExtensionManager( css::uno::Reference< css::uno::XComponentContext >const& xContext); 60*cdf0e10cSrcweir virtual ~ExtensionManager(); 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir static css::uno::Sequence< ::rtl::OUString > getServiceNames(); 63*cdf0e10cSrcweir static ::rtl::OUString getImplName(); 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir void check(); 66*cdf0e10cSrcweir void fireModified(); 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir public: 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir // XModifyBroadcaster 71*cdf0e10cSrcweir virtual void SAL_CALL addModifyListener( 72*cdf0e10cSrcweir css::uno::Reference<css::util::XModifyListener> const & xListener ) 73*cdf0e10cSrcweir throw (css::uno::RuntimeException); 74*cdf0e10cSrcweir virtual void SAL_CALL removeModifyListener( 75*cdf0e10cSrcweir css::uno::Reference<css::util::XModifyListener> const & xListener ) 76*cdf0e10cSrcweir throw (css::uno::RuntimeException); 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir //XExtensionManager 79*cdf0e10cSrcweir virtual css::uno::Sequence< 80*cdf0e10cSrcweir css::uno::Reference<css::deployment::XPackageTypeInfo> > SAL_CALL 81*cdf0e10cSrcweir getSupportedPackageTypes() 82*cdf0e10cSrcweir throw (css::uno::RuntimeException); 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir virtual css::uno::Reference<css::task::XAbortChannel> SAL_CALL 85*cdf0e10cSrcweir createAbortChannel() throw (css::uno::RuntimeException); 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir virtual css::uno::Reference<css::deployment::XPackage> SAL_CALL addExtension( 88*cdf0e10cSrcweir ::rtl::OUString const & url, 89*cdf0e10cSrcweir css::uno::Sequence<css::beans::NamedValue> const & properties, 90*cdf0e10cSrcweir ::rtl::OUString const & repository, 91*cdf0e10cSrcweir css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel, 92*cdf0e10cSrcweir css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv ) 93*cdf0e10cSrcweir throw (css::deployment::DeploymentException, 94*cdf0e10cSrcweir css::ucb::CommandFailedException, 95*cdf0e10cSrcweir css::ucb::CommandAbortedException, 96*cdf0e10cSrcweir css::lang::IllegalArgumentException, 97*cdf0e10cSrcweir css::uno::RuntimeException); 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir virtual void SAL_CALL removeExtension( 100*cdf0e10cSrcweir ::rtl::OUString const & identifier, 101*cdf0e10cSrcweir ::rtl::OUString const & filename, 102*cdf0e10cSrcweir ::rtl::OUString const & repository, 103*cdf0e10cSrcweir css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel, 104*cdf0e10cSrcweir css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv ) 105*cdf0e10cSrcweir throw (css::deployment::DeploymentException, 106*cdf0e10cSrcweir css::ucb::CommandFailedException, 107*cdf0e10cSrcweir css::ucb::CommandAbortedException, 108*cdf0e10cSrcweir css::lang::IllegalArgumentException, 109*cdf0e10cSrcweir css::uno::RuntimeException); 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir virtual void SAL_CALL enableExtension( 112*cdf0e10cSrcweir css::uno::Reference<css::deployment::XPackage> const & extension, 113*cdf0e10cSrcweir css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel, 114*cdf0e10cSrcweir css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv ) 115*cdf0e10cSrcweir throw (css::deployment::DeploymentException, 116*cdf0e10cSrcweir css::ucb::CommandFailedException, 117*cdf0e10cSrcweir css::ucb::CommandAbortedException, 118*cdf0e10cSrcweir css::lang::IllegalArgumentException, 119*cdf0e10cSrcweir css::uno::RuntimeException); 120*cdf0e10cSrcweir 121*cdf0e10cSrcweir virtual void SAL_CALL disableExtension( 122*cdf0e10cSrcweir css::uno::Reference<css::deployment::XPackage> const & extension, 123*cdf0e10cSrcweir css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel, 124*cdf0e10cSrcweir css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv ) 125*cdf0e10cSrcweir throw (css::deployment::DeploymentException, 126*cdf0e10cSrcweir css::ucb::CommandFailedException, 127*cdf0e10cSrcweir css::ucb::CommandAbortedException, 128*cdf0e10cSrcweir css::lang::IllegalArgumentException, 129*cdf0e10cSrcweir css::uno::RuntimeException); 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir virtual sal_Int32 SAL_CALL checkPrerequisitesAndEnable( 133*cdf0e10cSrcweir css::uno::Reference<css::deployment::XPackage> const & extension, 134*cdf0e10cSrcweir css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel, 135*cdf0e10cSrcweir css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv ) 136*cdf0e10cSrcweir throw (css::deployment::DeploymentException, 137*cdf0e10cSrcweir css::ucb::CommandFailedException, 138*cdf0e10cSrcweir css::ucb::CommandAbortedException, 139*cdf0e10cSrcweir css::lang::IllegalArgumentException, 140*cdf0e10cSrcweir css::uno::RuntimeException); 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir virtual css::uno::Sequence< css::uno::Reference<css::deployment::XPackage> > 144*cdf0e10cSrcweir SAL_CALL getDeployedExtensions( 145*cdf0e10cSrcweir ::rtl::OUString const & repository, 146*cdf0e10cSrcweir css::uno::Reference<css::task::XAbortChannel> const &, 147*cdf0e10cSrcweir css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv ) 148*cdf0e10cSrcweir throw (css::deployment::DeploymentException, 149*cdf0e10cSrcweir css::ucb::CommandFailedException, 150*cdf0e10cSrcweir css::ucb::CommandAbortedException, 151*cdf0e10cSrcweir css::lang::IllegalArgumentException, 152*cdf0e10cSrcweir css::uno::RuntimeException); 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir virtual css::uno::Reference< css::deployment::XPackage> 155*cdf0e10cSrcweir SAL_CALL getDeployedExtension( 156*cdf0e10cSrcweir ::rtl::OUString const & repository, 157*cdf0e10cSrcweir ::rtl::OUString const & identifier, 158*cdf0e10cSrcweir ::rtl::OUString const & filename, 159*cdf0e10cSrcweir css::uno::Reference< css::ucb::XCommandEnvironment> const & xCmdEnv ) 160*cdf0e10cSrcweir throw ( 161*cdf0e10cSrcweir css::deployment::DeploymentException, 162*cdf0e10cSrcweir css::ucb::CommandFailedException, 163*cdf0e10cSrcweir css::lang::IllegalArgumentException, 164*cdf0e10cSrcweir css::uno::RuntimeException); 165*cdf0e10cSrcweir 166*cdf0e10cSrcweir virtual css::uno::Sequence<css::uno::Reference<css::deployment::XPackage> > 167*cdf0e10cSrcweir SAL_CALL getExtensionsWithSameIdentifier( 168*cdf0e10cSrcweir ::rtl::OUString const & identifier, 169*cdf0e10cSrcweir ::rtl::OUString const & filename, 170*cdf0e10cSrcweir css::uno::Reference< css::ucb::XCommandEnvironment> const & xCmdEnv ) 171*cdf0e10cSrcweir throw ( 172*cdf0e10cSrcweir css::deployment::DeploymentException, 173*cdf0e10cSrcweir css::ucb::CommandFailedException, 174*cdf0e10cSrcweir css::lang::IllegalArgumentException, 175*cdf0e10cSrcweir css::uno::RuntimeException); 176*cdf0e10cSrcweir 177*cdf0e10cSrcweir virtual css::uno::Sequence< css::uno::Sequence<css::uno::Reference<css::deployment::XPackage> > > 178*cdf0e10cSrcweir SAL_CALL getAllExtensions( 179*cdf0e10cSrcweir css::uno::Reference<css::task::XAbortChannel> const &, 180*cdf0e10cSrcweir css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv ) 181*cdf0e10cSrcweir throw (css::deployment::DeploymentException, 182*cdf0e10cSrcweir css::ucb::CommandFailedException, 183*cdf0e10cSrcweir css::ucb::CommandAbortedException, 184*cdf0e10cSrcweir css::lang::IllegalArgumentException, 185*cdf0e10cSrcweir css::uno::RuntimeException); 186*cdf0e10cSrcweir 187*cdf0e10cSrcweir 188*cdf0e10cSrcweir virtual void SAL_CALL reinstallDeployedExtensions( 189*cdf0e10cSrcweir ::rtl::OUString const & repository, 190*cdf0e10cSrcweir css::uno::Reference< css::task::XAbortChannel> const & xAbortChannel, 191*cdf0e10cSrcweir css::uno::Reference< css::ucb::XCommandEnvironment> const & xCmdEnv ) 192*cdf0e10cSrcweir throw ( 193*cdf0e10cSrcweir css::deployment::DeploymentException, 194*cdf0e10cSrcweir css::ucb::CommandFailedException, 195*cdf0e10cSrcweir css::ucb::CommandAbortedException, 196*cdf0e10cSrcweir css::lang::IllegalArgumentException, 197*cdf0e10cSrcweir css::uno::RuntimeException); 198*cdf0e10cSrcweir 199*cdf0e10cSrcweir virtual sal_Bool SAL_CALL synchronize( 200*cdf0e10cSrcweir css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel, 201*cdf0e10cSrcweir css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv ) 202*cdf0e10cSrcweir throw (css::deployment::DeploymentException, 203*cdf0e10cSrcweir css::ucb::CommandFailedException, 204*cdf0e10cSrcweir css::ucb::CommandAbortedException, 205*cdf0e10cSrcweir css::lang::IllegalArgumentException, 206*cdf0e10cSrcweir css::uno::RuntimeException); 207*cdf0e10cSrcweir 208*cdf0e10cSrcweir virtual void SAL_CALL synchronizeBundledPrereg( 209*cdf0e10cSrcweir css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel, 210*cdf0e10cSrcweir css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv ) 211*cdf0e10cSrcweir throw (css::deployment::DeploymentException, 212*cdf0e10cSrcweir css::uno::RuntimeException); 213*cdf0e10cSrcweir 214*cdf0e10cSrcweir virtual css::uno::Sequence<css::uno::Reference<css::deployment::XPackage> > SAL_CALL 215*cdf0e10cSrcweir getExtensionsWithUnacceptedLicenses( 216*cdf0e10cSrcweir ::rtl::OUString const & repository, 217*cdf0e10cSrcweir css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv) 218*cdf0e10cSrcweir throw (css::deployment::DeploymentException, 219*cdf0e10cSrcweir css::uno::RuntimeException); 220*cdf0e10cSrcweir 221*cdf0e10cSrcweir virtual sal_Bool SAL_CALL isReadOnlyRepository(::rtl::OUString const & repository) 222*cdf0e10cSrcweir throw (css::uno::RuntimeException); 223*cdf0e10cSrcweir 224*cdf0e10cSrcweir private: 225*cdf0e10cSrcweir 226*cdf0e10cSrcweir struct StrSyncRepository : public ::dp_misc::StaticResourceString< 227*cdf0e10cSrcweir StrSyncRepository, RID_STR_SYNCHRONIZING_REPOSITORY> {}; 228*cdf0e10cSrcweir 229*cdf0e10cSrcweir struct ExtensionInfos 230*cdf0e10cSrcweir { 231*cdf0e10cSrcweir ::rtl::OUString identifier; 232*cdf0e10cSrcweir ::rtl::OUString fileName; 233*cdf0e10cSrcweir ::rtl::OUString displayName; 234*cdf0e10cSrcweir ::rtl::OUString version; 235*cdf0e10cSrcweir }; 236*cdf0e10cSrcweir 237*cdf0e10cSrcweir css::uno::Reference< css::uno::XComponentContext> m_xContext; 238*cdf0e10cSrcweir css::uno::Reference<css::deployment::XPackageManagerFactory> m_xPackageManagerFactory; 239*cdf0e10cSrcweir 240*cdf0e10cSrcweir //only to be used within addExtension 241*cdf0e10cSrcweir ::osl::Mutex m_addMutex; 242*cdf0e10cSrcweir /* contains the names of all repositories (except tmp) in order of there 243*cdf0e10cSrcweir priority. That is, the first element is "user" follod by "shared" and 244*cdf0e10cSrcweir then "bundled" 245*cdf0e10cSrcweir */ 246*cdf0e10cSrcweir ::std::list< ::rtl::OUString > m_repositoryNames; 247*cdf0e10cSrcweir 248*cdf0e10cSrcweir css::uno::Reference<css::deployment::XPackageManager> getUserRepository(); 249*cdf0e10cSrcweir css::uno::Reference<css::deployment::XPackageManager> getSharedRepository(); 250*cdf0e10cSrcweir css::uno::Reference<css::deployment::XPackageManager> getBundledRepository(); 251*cdf0e10cSrcweir css::uno::Reference<css::deployment::XPackageManager> getTmpRepository(); 252*cdf0e10cSrcweir 253*cdf0e10cSrcweir bool isUserDisabled(::rtl::OUString const & identifier, 254*cdf0e10cSrcweir ::rtl::OUString const & filename); 255*cdf0e10cSrcweir 256*cdf0e10cSrcweir bool isUserDisabled( 257*cdf0e10cSrcweir css::uno::Sequence<css::uno::Reference<css::deployment::XPackage> > const & seqExtSameId); 258*cdf0e10cSrcweir 259*cdf0e10cSrcweir void activateExtension( 260*cdf0e10cSrcweir ::rtl::OUString const & identifier, 261*cdf0e10cSrcweir ::rtl::OUString const & fileName, 262*cdf0e10cSrcweir bool bUserDisabled, bool bStartup, 263*cdf0e10cSrcweir css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel, 264*cdf0e10cSrcweir css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv); 265*cdf0e10cSrcweir 266*cdf0e10cSrcweir void activateExtension( 267*cdf0e10cSrcweir css::uno::Sequence<css::uno::Reference<css::deployment::XPackage> > const & seqExt, 268*cdf0e10cSrcweir bool bUserDisabled, bool bStartup, 269*cdf0e10cSrcweir css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel, 270*cdf0e10cSrcweir css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv ); 271*cdf0e10cSrcweir 272*cdf0e10cSrcweir 273*cdf0e10cSrcweir ::std::list<css::uno::Reference<css::deployment::XPackage> > 274*cdf0e10cSrcweir getExtensionsWithSameId(::rtl::OUString const & identifier, 275*cdf0e10cSrcweir ::rtl::OUString const & fileName, 276*cdf0e10cSrcweir css::uno::Reference< css::ucb::XCommandEnvironment> const & xCmdEnv = 277*cdf0e10cSrcweir css::uno::Reference< css::ucb::XCommandEnvironment>()); 278*cdf0e10cSrcweir 279*cdf0e10cSrcweir css::uno::Reference<css::deployment::XPackage> backupExtension( 280*cdf0e10cSrcweir ::rtl::OUString const & identifier, ::rtl::OUString const & fileName, 281*cdf0e10cSrcweir css::uno::Reference<css::deployment::XPackageManager> const & xPackageManager, 282*cdf0e10cSrcweir css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv); 283*cdf0e10cSrcweir 284*cdf0e10cSrcweir void checkInstall( 285*cdf0e10cSrcweir ::rtl::OUString const & displayName, 286*cdf0e10cSrcweir css::uno::Reference<css::ucb::XCommandEnvironment> const & cmdEnv); 287*cdf0e10cSrcweir 288*cdf0e10cSrcweir void checkUpdate( 289*cdf0e10cSrcweir ::rtl::OUString const & newVersion, 290*cdf0e10cSrcweir ::rtl::OUString const & newDisplayName, 291*cdf0e10cSrcweir css::uno::Reference<css::deployment::XPackage> const & oldExtension, 292*cdf0e10cSrcweir css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv); 293*cdf0e10cSrcweir 294*cdf0e10cSrcweir css::uno::Reference<css::deployment::XPackage> getTempExtension( 295*cdf0e10cSrcweir ::rtl::OUString const & url, 296*cdf0e10cSrcweir css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel, 297*cdf0e10cSrcweir css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv); 298*cdf0e10cSrcweir 299*cdf0e10cSrcweir 300*cdf0e10cSrcweir void addExtensionsToMap( 301*cdf0e10cSrcweir id2extensions & mapExt, 302*cdf0e10cSrcweir css::uno::Sequence<css::uno::Reference<css::deployment::XPackage> > const & seqExt, 303*cdf0e10cSrcweir ::rtl::OUString const & repository); 304*cdf0e10cSrcweir 305*cdf0e10cSrcweir css::uno::Reference<css::deployment::XPackageManager> 306*cdf0e10cSrcweir getPackageManager(::rtl::OUString const & repository) 307*cdf0e10cSrcweir throw (css::lang::IllegalArgumentException); 308*cdf0e10cSrcweir 309*cdf0e10cSrcweir bool doChecksForAddExtension( 310*cdf0e10cSrcweir css::uno::Reference<css::deployment::XPackageManager> const & xPackageMgr, 311*cdf0e10cSrcweir css::uno::Sequence<css::beans::NamedValue> const & properties, 312*cdf0e10cSrcweir css::uno::Reference<css::deployment::XPackage> const & xTmpExtension, 313*cdf0e10cSrcweir css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel, 314*cdf0e10cSrcweir css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv, 315*cdf0e10cSrcweir css::uno::Reference<css::deployment::XPackage> & out_existingExtension ) 316*cdf0e10cSrcweir throw (css::deployment::DeploymentException, 317*cdf0e10cSrcweir css::ucb::CommandFailedException, 318*cdf0e10cSrcweir css::ucb::CommandAbortedException, 319*cdf0e10cSrcweir css::lang::IllegalArgumentException, 320*cdf0e10cSrcweir css::uno::RuntimeException); 321*cdf0e10cSrcweir 322*cdf0e10cSrcweir 323*cdf0e10cSrcweir }; 324*cdf0e10cSrcweir 325*cdf0e10cSrcweir } 326*cdf0e10cSrcweir 327*cdf0e10cSrcweir 328*cdf0e10cSrcweir 329*cdf0e10cSrcweir 330*cdf0e10cSrcweir #endif 331*cdf0e10cSrcweir 332