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