Line data Source code
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 : #ifndef INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_MANAGER_DP_COMMANDENVIRONMENTS_HXX
21 : #define INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_MANAGER_DP_COMMANDENVIRONMENTS_HXX
22 :
23 : #include <cppuhelper/compbase3.hxx>
24 : #include <ucbhelper/content.hxx>
25 : #include <com/sun/star/uno/Type.hxx>
26 :
27 : namespace dp_manager {
28 :
29 : /**
30 : This command environment is to be used when an extension is temporarily
31 : stored in the "tmp" repository. It prevents all kind of user interaction.
32 : */
33 : class BaseCommandEnv
34 : : public ::cppu::WeakImplHelper3< css::ucb::XCommandEnvironment,
35 : css::task::XInteractionHandler,
36 : css::ucb::XProgressHandler >
37 : {
38 : protected:
39 : css::uno::Reference< css::uno::XComponentContext > m_xContext;
40 : css::uno::Reference< css::task::XInteractionHandler> m_forwardHandler;
41 :
42 : void handle_(bool approve, bool abort,
43 : css::uno::Reference< css::task::XInteractionRequest> const & xRequest );
44 : public:
45 : virtual ~BaseCommandEnv();
46 : BaseCommandEnv();
47 : 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() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
53 : virtual css::uno::Reference<css::ucb::XProgressHandler >
54 : SAL_CALL getProgressHandler() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
55 :
56 : // XInteractionHandler
57 : virtual void SAL_CALL handle(
58 : css::uno::Reference<css::task::XInteractionRequest > const & xRequest )
59 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
60 :
61 : // XProgressHandler
62 : virtual void SAL_CALL push( css::uno::Any const & Status )
63 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
64 : virtual void SAL_CALL update( css::uno::Any const & Status )
65 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
66 : virtual void SAL_CALL pop() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
67 : };
68 :
69 4 : class TmpRepositoryCommandEnv : public BaseCommandEnv
70 : {
71 : public:
72 : TmpRepositoryCommandEnv();
73 : TmpRepositoryCommandEnv(css::uno::Reference< css::task::XInteractionHandler> const & handler);
74 :
75 : // XInteractionHandler
76 : virtual void SAL_CALL handle(
77 : css::uno::Reference<css::task::XInteractionRequest > const & xRequest )
78 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
79 :
80 : };
81 :
82 : /** this class is for use in XPackageManager::synchronize.
83 :
84 : It handles particular license cases.
85 : */
86 0 : class LicenseCommandEnv : public BaseCommandEnv
87 : {
88 : private:
89 : OUString m_repository;
90 : bool m_bSuppressLicense;
91 : public:
92 : LicenseCommandEnv() : m_bSuppressLicense(false) {};
93 : LicenseCommandEnv(
94 : css::uno::Reference< css::task::XInteractionHandler> const & handler,
95 : bool bSuppressLicense,
96 : OUString const & repository);
97 :
98 : // XInteractionHandler
99 : virtual void SAL_CALL handle(
100 : css::uno::Reference<css::task::XInteractionRequest > const & xRequest )
101 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
102 :
103 : };
104 :
105 : /** this class is for use in XPackageManager::checkPrerequisites
106 :
107 : It always prohibits a license interaction
108 : */
109 0 : class NoLicenseCommandEnv : public BaseCommandEnv
110 : {
111 :
112 : public:
113 : NoLicenseCommandEnv(){};
114 : NoLicenseCommandEnv(css::uno::Reference< css::task::XInteractionHandler> const & handler);
115 :
116 : // XInteractionHandler
117 : virtual void SAL_CALL handle(
118 : css::uno::Reference<css::task::XInteractionRequest > const & xRequest )
119 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
120 :
121 : };
122 :
123 : /* For use in XExtensionManager::addExtension in the call to
124 : XPackage::checkPrerequisites
125 : It prevents all user interactions. The license is always accepted.
126 : It remembers if there was a platform or a dependency exception in
127 : the member m_bException. if there was any other exception then m_bUnknownException
128 : is set.
129 :
130 : */
131 2 : class SilentCheckPrerequisitesCommandEnv : public BaseCommandEnv
132 : {
133 : public:
134 : SilentCheckPrerequisitesCommandEnv();
135 : // XInteractionHandler
136 : virtual void SAL_CALL handle(
137 : css::uno::Reference<css::task::XInteractionRequest > const & xRequest )
138 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
139 :
140 : // Set to true if a PlatformException or a DependencyException were handled.
141 : css::uno::Any m_Exception;
142 : // Set to true if an unknown exception was handled.
143 : css::uno::Any m_UnknownException;
144 : };
145 :
146 : }
147 :
148 : #endif
149 :
150 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|