Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include "com/sun/star/deployment/VersionException.hpp"
31 : : #include "com/sun/star/deployment/LicenseException.hpp"
32 : : #include "com/sun/star/deployment/InstallException.hpp"
33 : : #include "com/sun/star/deployment/DependencyException.hpp"
34 : : #include "com/sun/star/deployment/PlatformException.hpp"
35 : : #include "com/sun/star/task/XInteractionApprove.hpp"
36 : : #include "com/sun/star/task/XInteractionAbort.hpp"
37 : : #include "com/sun/star/task/XInteractionHandler.hpp"
38 : : #include "com/sun/star/ucb/XCommandEnvironment.hpp"
39 : : #include "com/sun/star/uno/XComponentContext.hpp"
40 : : #include "dp_commandenvironments.hxx"
41 : :
42 : : namespace deployment = com::sun::star::deployment;
43 : : namespace task = com::sun::star::task;
44 : : namespace ucb = com::sun::star::ucb;
45 : : namespace uno = com::sun::star::uno;
46 : : namespace css = com::sun::star;
47 : :
48 : : #define OUSTR(s) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s))
49 : :
50 : : using ::com::sun::star::uno::Reference;
51 : : using ::rtl::OUString;
52 : :
53 : : namespace dp_manager {
54 : :
55 : 4 : BaseCommandEnv::BaseCommandEnv()
56 : : {
57 : 4 : }
58 : :
59 : 498 : BaseCommandEnv::BaseCommandEnv(
60 : : Reference< task::XInteractionHandler> const & handler)
61 : 498 : : m_forwardHandler(handler)
62 : : {
63 : 498 : }
64 : :
65 : 502 : BaseCommandEnv::~BaseCommandEnv()
66 : : {
67 [ - + ]: 502 : }
68 : : // XCommandEnvironment
69 : : //______________________________________________________________________________
70 : 6 : Reference<task::XInteractionHandler> BaseCommandEnv::getInteractionHandler()
71 : : throw (uno::RuntimeException)
72 : : {
73 : 6 : return this;
74 : : }
75 : :
76 : : //______________________________________________________________________________
77 : 10 : Reference<ucb::XProgressHandler> BaseCommandEnv::getProgressHandler()
78 : : throw (uno::RuntimeException)
79 : : {
80 : 10 : return this;
81 : : }
82 : :
83 : 0 : void BaseCommandEnv::handle(
84 : : Reference< task::XInteractionRequest> const & /*xRequest*/ )
85 : : throw (uno::RuntimeException)
86 : : {
87 : 0 : }
88 : :
89 : 0 : void BaseCommandEnv::handle_(bool approve, bool abort,
90 : : Reference< task::XInteractionRequest> const & xRequest )
91 : : {
92 [ # # ][ # # ]: 0 : if (approve == false && abort == false)
93 : : {
94 : : //not handled so far -> forwarding
95 [ # # ]: 0 : if (m_forwardHandler.is())
96 : 0 : m_forwardHandler->handle(xRequest);
97 : : else
98 : 0 : return; //cannot handle
99 : : }
100 : : else
101 : : {
102 : : // select:
103 : : uno::Sequence< Reference< task::XInteractionContinuation > > conts(
104 [ # # ][ # # ]: 0 : xRequest->getContinuations() );
105 : : Reference< task::XInteractionContinuation > const * pConts =
106 : 0 : conts.getConstArray();
107 : 0 : sal_Int32 len = conts.getLength();
108 [ # # ]: 0 : for ( sal_Int32 pos = 0; pos < len; ++pos )
109 : : {
110 [ # # ]: 0 : if (approve) {
111 : : Reference< task::XInteractionApprove > xInteractionApprove(
112 [ # # ]: 0 : pConts[ pos ], uno::UNO_QUERY );
113 [ # # ]: 0 : if (xInteractionApprove.is()) {
114 [ # # ][ # # ]: 0 : xInteractionApprove->select();
115 : : // don't query again for ongoing continuations:
116 : 0 : approve = false;
117 : 0 : }
118 : : }
119 [ # # ]: 0 : else if (abort) {
120 : : Reference< task::XInteractionAbort > xInteractionAbort(
121 [ # # ]: 0 : pConts[ pos ], uno::UNO_QUERY );
122 [ # # ]: 0 : if (xInteractionAbort.is()) {
123 [ # # ][ # # ]: 0 : xInteractionAbort->select();
124 : : // don't query again for ongoing continuations:
125 : 0 : abort = false;
126 : 0 : }
127 : : }
128 [ # # ]: 0 : }
129 : : }
130 : :
131 : : }
132 : :
133 : : // XProgressHandler
134 : 0 : void BaseCommandEnv::push( uno::Any const & /*Status*/ )
135 : : throw (uno::RuntimeException)
136 : : {
137 : 0 : }
138 : :
139 : 4 : void BaseCommandEnv::update( uno::Any const & /*Status */)
140 : : throw (uno::RuntimeException)
141 : : {
142 : 4 : }
143 : :
144 : 0 : void BaseCommandEnv::pop() throw (uno::RuntimeException)
145 : : {
146 : 0 : }
147 : : //==============================================================================
148 : :
149 : 2 : TmpRepositoryCommandEnv::TmpRepositoryCommandEnv()
150 : : {
151 : 2 : }
152 : :
153 : 2 : TmpRepositoryCommandEnv::TmpRepositoryCommandEnv(
154 : : css::uno::Reference< css::task::XInteractionHandler> const & handler):
155 : 2 : BaseCommandEnv(handler)
156 : : {
157 : 2 : }
158 : : // XInteractionHandler
159 : 0 : void TmpRepositoryCommandEnv::handle(
160 : : Reference< task::XInteractionRequest> const & xRequest )
161 : : throw (uno::RuntimeException)
162 : : {
163 [ # # ][ # # ]: 0 : uno::Any request( xRequest->getRequest() );
164 : : OSL_ASSERT( request.getValueTypeClass() == uno::TypeClass_EXCEPTION );
165 : :
166 [ # # ]: 0 : deployment::VersionException verExc;
167 [ # # ]: 0 : deployment::LicenseException licExc;
168 [ # # ]: 0 : deployment::InstallException instExc;
169 : :
170 : 0 : bool approve = false;
171 : 0 : bool abort = false;
172 : :
173 [ # # ][ # # ]: 0 : if ((request >>= verExc)
[ # # ][ # # ]
[ # # ]
174 [ # # ]: 0 : || (request >>= licExc)
175 [ # # ]: 0 : || (request >>= instExc))
176 : : {
177 : 0 : approve = true;
178 : : }
179 : :
180 [ # # ][ # # ]: 0 : handle_(approve, abort, xRequest);
[ # # ][ # # ]
181 : 0 : }
182 : : //================================================================================
183 : :
184 : 496 : LicenseCommandEnv::LicenseCommandEnv(
185 : : css::uno::Reference< css::task::XInteractionHandler> const & handler,
186 : : bool bSuppressLicense,
187 : : OUString const & repository):
188 : : BaseCommandEnv(handler), m_repository(repository),
189 : 496 : m_bSuppressLicense(bSuppressLicense)
190 : : {
191 : 496 : }
192 : : // XInteractionHandler
193 : 0 : void LicenseCommandEnv::handle(
194 : : Reference< task::XInteractionRequest> const & xRequest )
195 : : throw (uno::RuntimeException)
196 : : {
197 [ # # ][ # # ]: 0 : uno::Any request( xRequest->getRequest() );
198 : : OSL_ASSERT( request.getValueTypeClass() == uno::TypeClass_EXCEPTION );
199 : :
200 [ # # ]: 0 : deployment::LicenseException licExc;
201 : :
202 : 0 : bool approve = false;
203 : 0 : bool abort = false;
204 : :
205 [ # # ][ # # ]: 0 : if (request >>= licExc)
206 : : {
207 [ # # # # : 0 : if (m_bSuppressLicense
# # ][ # # ]
208 [ # # ][ # # ]: 0 : || m_repository.equals(OUSTR("bundled"))
[ # # ]
209 [ # # ][ # # ]: 0 : || licExc.AcceptBy.equals(OUSTR("admin")))
[ # # ]
210 : : {
211 : : //always approve in bundled case, because we do not support
212 : : //showing licenses anyway.
213 : : //The "admin" already accepted the license when installing the
214 : : // shared extension
215 : 0 : approve = true;
216 : : }
217 : : }
218 : :
219 [ # # ][ # # ]: 0 : handle_(approve, abort, xRequest);
220 : 0 : }
221 : :
222 : : //================================================================================
223 : :
224 : 0 : NoLicenseCommandEnv::NoLicenseCommandEnv(
225 : : css::uno::Reference< css::task::XInteractionHandler> const & handler):
226 : 0 : BaseCommandEnv(handler)
227 : : {
228 : 0 : }
229 : : // XInteractionHandler
230 : 0 : void NoLicenseCommandEnv::handle(
231 : : Reference< task::XInteractionRequest> const & xRequest )
232 : : throw (uno::RuntimeException)
233 : : {
234 [ # # ][ # # ]: 0 : uno::Any request( xRequest->getRequest() );
235 : : OSL_ASSERT( request.getValueTypeClass() == uno::TypeClass_EXCEPTION );
236 : :
237 [ # # ]: 0 : deployment::LicenseException licExc;
238 : :
239 : 0 : bool approve = false;
240 : 0 : bool abort = false;
241 : :
242 [ # # ][ # # ]: 0 : if (request >>= licExc)
243 : : {
244 : 0 : approve = true;
245 : : }
246 [ # # ][ # # ]: 0 : handle_(approve, abort, xRequest);
247 : 0 : }
248 : :
249 : 2 : SilentCheckPrerequisitesCommandEnv::SilentCheckPrerequisitesCommandEnv()
250 : : {
251 : 2 : }
252 : :
253 : 0 : void SilentCheckPrerequisitesCommandEnv::handle(
254 : : Reference< task::XInteractionRequest> const & xRequest )
255 : : throw (uno::RuntimeException)
256 : : {
257 [ # # ][ # # ]: 0 : uno::Any request( xRequest->getRequest() );
258 : : OSL_ASSERT( request.getValueTypeClass() == uno::TypeClass_EXCEPTION );
259 : :
260 [ # # ]: 0 : deployment::LicenseException licExc;
261 [ # # ]: 0 : deployment::PlatformException platformExc;
262 [ # # ]: 0 : deployment::DependencyException depExc;
263 : 0 : bool approve = false;
264 : 0 : bool abort = false;
265 : :
266 [ # # ][ # # ]: 0 : if (request >>= licExc)
267 : : {
268 : 0 : approve = true;
269 [ # # ]: 0 : handle_(approve, abort, xRequest);
270 : : }
271 [ # # ][ # # ]: 0 : else if ((request >>= platformExc)
[ # # ][ # # ]
272 [ # # ]: 0 : || (request >>= depExc))
273 : : {
274 : 0 : m_Exception = request;
275 : : }
276 : : else
277 : : {
278 : 0 : m_UnknownException = request;
279 [ # # ][ # # ]: 0 : }
[ # # ]
280 : 0 : }
281 : :
282 : : }
283 : :
284 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|