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