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 #if ! defined INCLUDED_DP_COMMANDENVIRONMENTS_HXX 29 #define INCLUDED_DP_COMMANDENVIRONMENTS_HXX 30 31 32 #include "cppuhelper/compbase3.hxx" 33 //#include "cppuhelper/implbase2.hxx" 34 #include "ucbhelper/content.hxx" 35 #include "com/sun/star/uno/Type.hxx" 36 37 38 namespace css = ::com::sun::star; 39 40 namespace dp_manager { 41 42 43 44 /** 45 This command environment is to be used when an extension is temporarily 46 stored in the "tmp" repository. It prevents all kind of user interaction. 47 */ 48 class BaseCommandEnv 49 : public ::cppu::WeakImplHelper3< css::ucb::XCommandEnvironment, 50 css::task::XInteractionHandler, 51 css::ucb::XProgressHandler > 52 { 53 protected: 54 css::uno::Reference< css::uno::XComponentContext > m_xContext; 55 css::uno::Reference< css::task::XInteractionHandler> m_forwardHandler; 56 57 void handle_(bool approve, bool abort, 58 css::uno::Reference< css::task::XInteractionRequest> const & xRequest ); 59 public: 60 virtual ~BaseCommandEnv(); 61 BaseCommandEnv(); 62 BaseCommandEnv( 63 css::uno::Reference< css::task::XInteractionHandler> const & handler); 64 65 // XCommandEnvironment 66 virtual css::uno::Reference<css::task::XInteractionHandler > SAL_CALL 67 getInteractionHandler() throw (css::uno::RuntimeException); 68 virtual css::uno::Reference<css::ucb::XProgressHandler > 69 SAL_CALL getProgressHandler() throw (css::uno::RuntimeException); 70 71 // XInteractionHandler 72 virtual void SAL_CALL handle( 73 css::uno::Reference<css::task::XInteractionRequest > const & xRequest ) 74 throw (css::uno::RuntimeException); 75 76 // XProgressHandler 77 virtual void SAL_CALL push( css::uno::Any const & Status ) 78 throw (css::uno::RuntimeException); 79 virtual void SAL_CALL update( css::uno::Any const & Status ) 80 throw (css::uno::RuntimeException); 81 virtual void SAL_CALL pop() throw (css::uno::RuntimeException); 82 }; 83 84 class TmpRepositoryCommandEnv : public BaseCommandEnv 85 { 86 public: 87 TmpRepositoryCommandEnv(); 88 TmpRepositoryCommandEnv(css::uno::Reference< css::task::XInteractionHandler> const & handler); 89 90 // XInteractionHandler 91 virtual void SAL_CALL handle( 92 css::uno::Reference<css::task::XInteractionRequest > const & xRequest ) 93 throw (css::uno::RuntimeException); 94 95 }; 96 97 /** this class is for use in XPackageManager::synchronize. 98 99 It handles particular license cases. 100 */ 101 class LicenseCommandEnv : public BaseCommandEnv 102 { 103 private: 104 ::rtl::OUString m_repository; 105 bool m_bSuppressLicense; 106 public: 107 LicenseCommandEnv(){}; 108 LicenseCommandEnv( 109 css::uno::Reference< css::task::XInteractionHandler> const & handler, 110 bool bSuppressLicense, 111 ::rtl::OUString const & repository); 112 113 // XInteractionHandler 114 virtual void SAL_CALL handle( 115 css::uno::Reference<css::task::XInteractionRequest > const & xRequest ) 116 throw (css::uno::RuntimeException); 117 118 }; 119 120 /** this class is for use in XPackageManager::checkPrerequisites 121 122 It always prohibits a license interaction 123 */ 124 class NoLicenseCommandEnv : public BaseCommandEnv 125 { 126 127 public: 128 NoLicenseCommandEnv(){}; 129 NoLicenseCommandEnv(css::uno::Reference< css::task::XInteractionHandler> const & handler); 130 131 // XInteractionHandler 132 virtual void SAL_CALL handle( 133 css::uno::Reference<css::task::XInteractionRequest > const & xRequest ) 134 throw (css::uno::RuntimeException); 135 136 }; 137 138 /* For use in XExtensionManager::addExtension in the call to 139 XPackage::checkPrerequisites 140 It prevents all user interactions. The license is always accepted. 141 It remembers if there was a platform or a dependency exception in 142 the member m_bException. if there was any other exception then m_bUnknownException 143 is set. 144 145 */ 146 class SilentCheckPrerequisitesCommandEnv : public BaseCommandEnv 147 { 148 public: 149 SilentCheckPrerequisitesCommandEnv(); 150 // XInteractionHandler 151 virtual void SAL_CALL handle( 152 css::uno::Reference<css::task::XInteractionRequest > const & xRequest ) 153 throw (css::uno::RuntimeException); 154 155 // Set to true if a PlatformException or a DependencyException were handled. 156 css::uno::Any m_Exception; 157 // Set to true if an unknown exception was handled. 158 css::uno::Any m_UnknownException; 159 }; 160 161 // class NoExceptionCommandEnv : public BaseCommandEnv 162 // { 163 // css::uno::Type m_type; 164 // public: 165 // NoExceptionCommandEnv::NoExceptionCommandEnv(){}; 166 // NoExceptionCommandEnv::NoExceptionCommandEnv( 167 // css::uno::Reference< css::task::XInteractionHandler> const & handler, 168 // css::uno::Type const & type); 169 170 // // XInteractionHandler 171 // virtual void SAL_CALL handle( 172 // css::uno::Reference<css::task::XInteractionRequest > const & xRequest ) 173 // throw (css::uno::RuntimeException); 174 175 // }; 176 177 } 178 179 180 181 182 #endif 183 184