xref: /trunk/main/desktop/source/deployment/manager/dp_commandenvironments.hxx (revision 91144cd0085a7583d2099b982122deb2184ab956)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #if ! defined INCLUDED_DP_COMMANDENVIRONMENTS_HXX
25 #define INCLUDED_DP_COMMANDENVIRONMENTS_HXX
26 
27 
28 #include "cppuhelper/compbase3.hxx"
29 //#include "cppuhelper/implbase2.hxx"
30 #include "ucbhelper/content.hxx"
31 #include "com/sun/star/uno/Type.hxx"
32 
33 
34 namespace css = ::com::sun::star;
35 
36 namespace dp_manager {
37 
38 
39 
40 /**
41    This command environment is to be used when an extension is temporarily
42    stored in the "tmp" repository. It prevents all kind of user interaction.
43  */
44 class BaseCommandEnv
45     : public ::cppu::WeakImplHelper3< css::ucb::XCommandEnvironment,
46                                       css::task::XInteractionHandler,
47                                       css::ucb::XProgressHandler >
48 {
49 protected:
50     css::uno::Reference< css::uno::XComponentContext > m_xContext;
51     css::uno::Reference< css::task::XInteractionHandler> m_forwardHandler;
52 
53     void handle_(bool approve, bool abort,
54                  css::uno::Reference< css::task::XInteractionRequest> const & xRequest );
55 public:
56     virtual ~BaseCommandEnv();
57     BaseCommandEnv();
58     BaseCommandEnv(
59         css::uno::Reference< css::task::XInteractionHandler> const & handler);
60 
61     // XCommandEnvironment
62     virtual css::uno::Reference<css::task::XInteractionHandler > SAL_CALL
63     getInteractionHandler();
64     virtual css::uno::Reference<css::ucb::XProgressHandler >
65     SAL_CALL getProgressHandler();
66 
67     // XInteractionHandler
68     virtual void SAL_CALL handle(
69         css::uno::Reference<css::task::XInteractionRequest > const & xRequest );
70 
71     // XProgressHandler
72     virtual void SAL_CALL push( css::uno::Any const & Status );
73     virtual void SAL_CALL update( css::uno::Any const & Status );
74     virtual void SAL_CALL pop();
75 };
76 
77 class TmpRepositoryCommandEnv : public BaseCommandEnv
78 {
79 public:
80     TmpRepositoryCommandEnv();
81     TmpRepositoryCommandEnv(css::uno::Reference< css::task::XInteractionHandler> const & handler);
82 
83 // XInteractionHandler
84     virtual void SAL_CALL handle(
85         css::uno::Reference<css::task::XInteractionRequest > const & xRequest );
86 
87 };
88 
89 /** this class is for use in XPackageManager::synchronize.
90 
91     It handles particular license cases.
92  */
93 class LicenseCommandEnv : public BaseCommandEnv
94 {
95 private:
96     ::rtl::OUString m_repository;
97     bool m_bSuppressLicense;
98 public:
LicenseCommandEnv()99     LicenseCommandEnv(){};
100     LicenseCommandEnv(
101         css::uno::Reference< css::task::XInteractionHandler> const & handler,
102         bool bSuppressLicense,
103         ::rtl::OUString const & repository);
104 
105 // XInteractionHandler
106     virtual void SAL_CALL handle(
107         css::uno::Reference<css::task::XInteractionRequest > const & xRequest );
108 
109 };
110 
111 /** this class is for use in XPackageManager::checkPrerequisites
112 
113     It always prohibits a license interaction
114  */
115 class NoLicenseCommandEnv : public BaseCommandEnv
116 {
117 
118 public:
NoLicenseCommandEnv()119     NoLicenseCommandEnv(){};
120     NoLicenseCommandEnv(css::uno::Reference< css::task::XInteractionHandler> const & handler);
121 
122 // XInteractionHandler
123     virtual void SAL_CALL handle(
124         css::uno::Reference<css::task::XInteractionRequest > const & xRequest );
125 
126 };
127 
128 /* For use in XExtensionManager::addExtension in the call to
129    XPackage::checkPrerequisites
130    It prevents all user interactions. The license is always accepted.
131    It remembers if there was a platform or a dependency exception in
132    the member m_bException. if there was any other exception then m_bUnknownException
133    is set.
134 
135  */
136 class SilentCheckPrerequisitesCommandEnv : public BaseCommandEnv
137 {
138 public:
139     SilentCheckPrerequisitesCommandEnv();
140     // XInteractionHandler
141     virtual void SAL_CALL handle(
142         css::uno::Reference<css::task::XInteractionRequest > const & xRequest );
143 
144     // Set to true if a PlatformException or a DependencyException were handled.
145     css::uno::Any m_Exception;
146     // Set to true if an unknown exception was handled.
147     css::uno::Any m_UnknownException;
148 };
149 
150 // class NoExceptionCommandEnv : public BaseCommandEnv
151 // {
152 //     css::uno::Type m_type;
153 // public:
154 //     NoExceptionCommandEnv::NoExceptionCommandEnv(){};
155 //     NoExceptionCommandEnv::NoExceptionCommandEnv(
156 //         css::uno::Reference< css::task::XInteractionHandler> const & handler,
157 //         css::uno::Type const & type);
158 
159 // // XInteractionHandler
160 //     virtual void SAL_CALL handle(
161 //         css::uno::Reference<css::task::XInteractionRequest > const & xRequest )
162 //         throw (css::uno::RuntimeException);
163 
164 // };
165 
166 }
167 
168 
169 
170 
171 #endif
172