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