bump product version to 4.1.6.2
[LibreOffice.git] / desktop / source / deployment / manager / dp_commandenvironments.cxx
bloba57c531d82c6b0dc89f8cb55fb3cd6f2e6f86f03
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include "com/sun/star/deployment/VersionException.hpp"
22 #include "com/sun/star/deployment/LicenseException.hpp"
23 #include "com/sun/star/deployment/InstallException.hpp"
24 #include "com/sun/star/deployment/DependencyException.hpp"
25 #include "com/sun/star/deployment/PlatformException.hpp"
26 #include "com/sun/star/task/XInteractionApprove.hpp"
27 #include "com/sun/star/task/XInteractionAbort.hpp"
28 #include "com/sun/star/task/XInteractionHandler.hpp"
29 #include "com/sun/star/ucb/XCommandEnvironment.hpp"
30 #include "com/sun/star/uno/XComponentContext.hpp"
31 #include "dp_commandenvironments.hxx"
33 namespace deployment = com::sun::star::deployment;
34 namespace task = com::sun::star::task;
35 namespace ucb = com::sun::star::ucb;
36 namespace uno = com::sun::star::uno;
38 using ::com::sun::star::uno::Reference;
40 namespace dp_manager {
42 BaseCommandEnv::BaseCommandEnv()
46 BaseCommandEnv::BaseCommandEnv(
47 Reference< task::XInteractionHandler> const & handler)
48 : m_forwardHandler(handler)
52 BaseCommandEnv::~BaseCommandEnv()
55 // XCommandEnvironment
56 //______________________________________________________________________________
57 Reference<task::XInteractionHandler> BaseCommandEnv::getInteractionHandler()
58 throw (uno::RuntimeException)
60 return this;
63 //______________________________________________________________________________
64 Reference<ucb::XProgressHandler> BaseCommandEnv::getProgressHandler()
65 throw (uno::RuntimeException)
67 return this;
70 void BaseCommandEnv::handle(
71 Reference< task::XInteractionRequest> const & /*xRequest*/ )
72 throw (uno::RuntimeException)
76 void BaseCommandEnv::handle_(bool approve, bool abort,
77 Reference< task::XInteractionRequest> const & xRequest )
79 if (approve == false && abort == false)
81 //not handled so far -> forwarding
82 if (m_forwardHandler.is())
83 m_forwardHandler->handle(xRequest);
84 else
85 return; //cannot handle
87 else
89 // select:
90 uno::Sequence< Reference< task::XInteractionContinuation > > conts(
91 xRequest->getContinuations() );
92 Reference< task::XInteractionContinuation > const * pConts =
93 conts.getConstArray();
94 sal_Int32 len = conts.getLength();
95 for ( sal_Int32 pos = 0; pos < len; ++pos )
97 if (approve) {
98 Reference< task::XInteractionApprove > xInteractionApprove(
99 pConts[ pos ], uno::UNO_QUERY );
100 if (xInteractionApprove.is()) {
101 xInteractionApprove->select();
102 // don't query again for ongoing continuations:
103 approve = false;
106 else if (abort) {
107 Reference< task::XInteractionAbort > xInteractionAbort(
108 pConts[ pos ], uno::UNO_QUERY );
109 if (xInteractionAbort.is()) {
110 xInteractionAbort->select();
111 // don't query again for ongoing continuations:
112 abort = false;
120 // XProgressHandler
121 void BaseCommandEnv::push( uno::Any const & /*Status*/ )
122 throw (uno::RuntimeException)
126 void BaseCommandEnv::update( uno::Any const & /*Status */)
127 throw (uno::RuntimeException)
131 void BaseCommandEnv::pop() throw (uno::RuntimeException)
134 //==============================================================================
136 TmpRepositoryCommandEnv::TmpRepositoryCommandEnv()
140 TmpRepositoryCommandEnv::TmpRepositoryCommandEnv(
141 css::uno::Reference< css::task::XInteractionHandler> const & handler):
142 BaseCommandEnv(handler)
145 // XInteractionHandler
146 void TmpRepositoryCommandEnv::handle(
147 Reference< task::XInteractionRequest> const & xRequest )
148 throw (uno::RuntimeException)
150 uno::Any request( xRequest->getRequest() );
151 OSL_ASSERT( request.getValueTypeClass() == uno::TypeClass_EXCEPTION );
153 deployment::VersionException verExc;
154 deployment::LicenseException licExc;
155 deployment::InstallException instExc;
157 bool approve = false;
158 bool abort = false;
160 if ((request >>= verExc)
161 || (request >>= licExc)
162 || (request >>= instExc))
164 approve = true;
167 handle_(approve, abort, xRequest);
169 //================================================================================
171 LicenseCommandEnv::LicenseCommandEnv(
172 css::uno::Reference< css::task::XInteractionHandler> const & handler,
173 bool bSuppressLicense,
174 OUString const & repository):
175 BaseCommandEnv(handler), m_repository(repository),
176 m_bSuppressLicense(bSuppressLicense)
179 // XInteractionHandler
180 void LicenseCommandEnv::handle(
181 Reference< task::XInteractionRequest> const & xRequest )
182 throw (uno::RuntimeException)
184 uno::Any request( xRequest->getRequest() );
185 OSL_ASSERT( request.getValueTypeClass() == uno::TypeClass_EXCEPTION );
187 deployment::LicenseException licExc;
189 bool approve = false;
190 bool abort = false;
192 if (request >>= licExc)
194 if (m_bSuppressLicense
195 || m_repository == "bundled"
196 || licExc.AcceptBy == "admin")
198 //always approve in bundled case, because we do not support
199 //showing licenses anyway.
200 //The "admin" already accepted the license when installing the
201 // shared extension
202 approve = true;
206 handle_(approve, abort, xRequest);
209 //================================================================================
211 NoLicenseCommandEnv::NoLicenseCommandEnv(
212 css::uno::Reference< css::task::XInteractionHandler> const & handler):
213 BaseCommandEnv(handler)
216 // XInteractionHandler
217 void NoLicenseCommandEnv::handle(
218 Reference< task::XInteractionRequest> const & xRequest )
219 throw (uno::RuntimeException)
221 uno::Any request( xRequest->getRequest() );
222 OSL_ASSERT( request.getValueTypeClass() == uno::TypeClass_EXCEPTION );
224 deployment::LicenseException licExc;
226 bool approve = false;
227 bool abort = false;
229 if (request >>= licExc)
231 approve = true;
233 handle_(approve, abort, xRequest);
236 SilentCheckPrerequisitesCommandEnv::SilentCheckPrerequisitesCommandEnv()
240 void SilentCheckPrerequisitesCommandEnv::handle(
241 Reference< task::XInteractionRequest> const & xRequest )
242 throw (uno::RuntimeException)
244 uno::Any request( xRequest->getRequest() );
245 OSL_ASSERT( request.getValueTypeClass() == uno::TypeClass_EXCEPTION );
247 deployment::LicenseException licExc;
248 deployment::PlatformException platformExc;
249 deployment::DependencyException depExc;
251 if (request >>= licExc)
253 handle_(true, false, xRequest); // approve = true, abort = false
255 else if ((request >>= platformExc)
256 || (request >>= depExc))
258 m_Exception = request;
260 else
262 m_UnknownException = request;
268 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */