1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 /* 3 * This file is part of the LibreOffice project. 4 * 5 * This Source Code Form is subject to the terms of the Mozilla Public 6 * License, v. 2.0. If a copy of the MPL was not distributed with this 7 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 * 9 * This file incorporates work covered by the following license notice: 10 * 11 * Licensed to the Apache Software Foundation (ASF) under one or more 12 * contributor license agreements. See the NOTICE file distributed 13 * with this work for additional information regarding copyright 14 * ownership. The ASF licenses this file to you under the Apache 15 * License, Version 2.0 (the "License"); you may not use this file 16 * except in compliance with the License. You may obtain a copy of 17 * the License at http://www.apache.org/licenses/LICENSE-2.0 . 18 */ 19 20 #pragma once 21 22 #include <cppuhelper/implbase.hxx> 23 #include <com/sun/star/task/XInteractionHandler.hpp> 24 #include <com/sun/star/task/XInteractionRequest.hpp> 25 #include <com/sun/star/ucb/XProgressHandler.hpp> 26 #include <com/sun/star/ucb/XCommandEnvironment.hpp> 27 28 29 namespace dp_manager { 30 31 /** 32 This command environment is to be used when an extension is temporarily 33 stored in the "tmp" repository. It prevents all kind of user interaction. 34 */ 35 class BaseCommandEnv 36 : public ::cppu::WeakImplHelper< css::ucb::XCommandEnvironment, 37 css::task::XInteractionHandler, 38 css::ucb::XProgressHandler > 39 { 40 css::uno::Reference< css::task::XInteractionHandler> m_forwardHandler; 41 protected: 42 void handle_(bool approve, 43 css::uno::Reference< css::task::XInteractionRequest> const & xRequest ); 44 public: 45 virtual ~BaseCommandEnv() override; 46 BaseCommandEnv(); 47 explicit BaseCommandEnv( 48 css::uno::Reference< css::task::XInteractionHandler> const & handler); 49 50 // XCommandEnvironment 51 virtual css::uno::Reference<css::task::XInteractionHandler > SAL_CALL 52 getInteractionHandler() override; 53 virtual css::uno::Reference<css::ucb::XProgressHandler > 54 SAL_CALL getProgressHandler() override; 55 56 // XInteractionHandler 57 virtual void SAL_CALL handle( 58 css::uno::Reference<css::task::XInteractionRequest > const & xRequest ) override; 59 60 // XProgressHandler 61 virtual void SAL_CALL push( css::uno::Any const & Status ) override; 62 virtual void SAL_CALL update( css::uno::Any const & Status ) override; 63 virtual void SAL_CALL pop() override; 64 }; 65 66 class TmpRepositoryCommandEnv : public BaseCommandEnv 67 { 68 public: 69 TmpRepositoryCommandEnv(); 70 explicit TmpRepositoryCommandEnv(css::uno::Reference< css::task::XInteractionHandler> const & handler); 71 72 // XInteractionHandler 73 virtual void SAL_CALL handle( 74 css::uno::Reference<css::task::XInteractionRequest > const & xRequest ) override; 75 76 }; 77 78 /** this class is for use in XPackageManager::synchronize. 79 80 It handles particular license cases. 81 */ 82 class LicenseCommandEnv : public BaseCommandEnv 83 { 84 private: 85 OUString m_repository; 86 bool m_bSuppressLicense; 87 public: 88 LicenseCommandEnv( 89 css::uno::Reference< css::task::XInteractionHandler> const & handler, 90 bool bSuppressLicense, 91 OUString const & repository); 92 93 // XInteractionHandler 94 virtual void SAL_CALL handle( 95 css::uno::Reference<css::task::XInteractionRequest > const & xRequest ) override; 96 97 }; 98 99 /** this class is for use in XPackageManager::checkPrerequisites 100 101 It always prohibits a license interaction 102 */ 103 class NoLicenseCommandEnv : public BaseCommandEnv 104 { 105 106 public: 107 explicit NoLicenseCommandEnv(css::uno::Reference< css::task::XInteractionHandler> const & handler); 108 109 // XInteractionHandler 110 virtual void SAL_CALL handle( 111 css::uno::Reference<css::task::XInteractionRequest > const & xRequest ) override; 112 113 }; 114 115 /* For use in XExtensionManager::addExtension in the call to 116 XPackage::checkPrerequisites 117 It prevents all user interactions. The license is always accepted. 118 It remembers if there was a platform or a dependency exception in 119 the member m_bException. if there was any other exception then m_bUnknownException 120 is set. 121 122 */ 123 class SilentCheckPrerequisitesCommandEnv : public BaseCommandEnv 124 { 125 public: 126 SilentCheckPrerequisitesCommandEnv(); 127 // XInteractionHandler 128 virtual void SAL_CALL handle( 129 css::uno::Reference<css::task::XInteractionRequest > const & xRequest ) override; 130 131 // Set to true if a PlatformException or a DependencyException were handled. 132 css::uno::Any m_Exception; 133 // Set to true if an unknown exception was handled. 134 css::uno::Any m_UnknownException; 135 }; 136 137 } 138 139 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 140