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() throw (css::uno::RuntimeException);
64     virtual css::uno::Reference<css::ucb::XProgressHandler >
65     SAL_CALL getProgressHandler() throw (css::uno::RuntimeException);
66 
67     // XInteractionHandler
68     virtual void SAL_CALL handle(
69         css::uno::Reference<css::task::XInteractionRequest > const & xRequest )
70         throw (css::uno::RuntimeException);
71 
72     // XProgressHandler
73     virtual void SAL_CALL push( css::uno::Any const & Status )
74         throw (css::uno::RuntimeException);
75     virtual void SAL_CALL update( css::uno::Any const & Status )
76         throw (css::uno::RuntimeException);
77     virtual void SAL_CALL pop() throw (css::uno::RuntimeException);
78 };
79 
80 class TmpRepositoryCommandEnv : public BaseCommandEnv
81 {
82 public:
83     TmpRepositoryCommandEnv();
84     TmpRepositoryCommandEnv(css::uno::Reference< css::task::XInteractionHandler> const & handler);
85 
86 // XInteractionHandler
87     virtual void SAL_CALL handle(
88         css::uno::Reference<css::task::XInteractionRequest > const & xRequest )
89         throw (css::uno::RuntimeException);
90 
91 };
92 
93 /** this class is for use in XPackageManager::synchronize.
94 
95     It handles particular license cases.
96  */
97 class LicenseCommandEnv : public BaseCommandEnv
98 {
99 private:
100     ::rtl::OUString m_repository;
101     bool m_bSuppressLicense;
102 public:
LicenseCommandEnv()103     LicenseCommandEnv(){};
104     LicenseCommandEnv(
105         css::uno::Reference< css::task::XInteractionHandler> const & handler,
106         bool bSuppressLicense,
107         ::rtl::OUString const & repository);
108 
109 // XInteractionHandler
110     virtual void SAL_CALL handle(
111         css::uno::Reference<css::task::XInteractionRequest > const & xRequest )
112         throw (css::uno::RuntimeException);
113 
114 };
115 
116 /** this class is for use in XPackageManager::checkPrerequisites
117 
118     It always prohibits a license interaction
119  */
120 class NoLicenseCommandEnv : public BaseCommandEnv
121 {
122 
123 public:
NoLicenseCommandEnv()124     NoLicenseCommandEnv(){};
125     NoLicenseCommandEnv(css::uno::Reference< css::task::XInteractionHandler> const & handler);
126 
127 // XInteractionHandler
128     virtual void SAL_CALL handle(
129         css::uno::Reference<css::task::XInteractionRequest > const & xRequest )
130         throw (css::uno::RuntimeException);
131 
132 };
133 
134 /* For use in XExtensionManager::addExtension in the call to
135    XPackage::checkPrerequisites
136    It prevents all user interactions. The license is always accepted.
137    It remembers if there was a platform or a dependency exception in
138    the member m_bException. if there was any other exception then m_bUnknownException
139    is set.
140 
141  */
142 class SilentCheckPrerequisitesCommandEnv : public BaseCommandEnv
143 {
144 public:
145     SilentCheckPrerequisitesCommandEnv();
146     // XInteractionHandler
147     virtual void SAL_CALL handle(
148         css::uno::Reference<css::task::XInteractionRequest > const & xRequest )
149         throw (css::uno::RuntimeException);
150 
151     // Set to true if a PlatformException or a DependencyException were handled.
152     css::uno::Any m_Exception;
153     // Set to true if an unknown exception was handled.
154     css::uno::Any m_UnknownException;
155 };
156 
157 // class NoExceptionCommandEnv : public BaseCommandEnv
158 // {
159 //     css::uno::Type m_type;
160 // public:
161 //     NoExceptionCommandEnv::NoExceptionCommandEnv(){};
162 //     NoExceptionCommandEnv::NoExceptionCommandEnv(
163 //         css::uno::Reference< css::task::XInteractionHandler> const & handler,
164 //         css::uno::Type const & type);
165 
166 // // XInteractionHandler
167 //     virtual void SAL_CALL handle(
168 //         css::uno::Reference<css::task::XInteractionRequest > const & xRequest )
169 //         throw (css::uno::RuntimeException);
170 
171 // };
172 
173 }
174 
175 
176 
177 
178 #endif
179 
180