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