LibreOffice Module comphelper (master) 1
simplefileaccessinteraction.cxx
Go to the documentation of this file.
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
11#include <com/sun/star/task/XInteractionAbort.hpp>
12#include <com/sun/star/task/XInteractionApprove.hpp>
13#include <com/sun/star/ucb/AuthenticationRequest.hpp>
14#include <com/sun/star/ucb/CertificateValidationRequest.hpp>
15#include <com/sun/star/ucb/InteractiveIOException.hpp>
16#include <com/sun/star/ucb/InteractiveNetworkException.hpp>
17#include <com/sun/star/ucb/UnsupportedDataSinkException.hpp>
18
19namespace comphelper
20{
28const sal_Int32 HANDLE_CERTIFICATEREQUEST = 3;
30const sal_Int32 HANDLE_AUTHENTICATIONREQUEST = 4;
31
33 const css::uno::Reference<css::task::XInteractionHandler>& xHandler)
34{
35 std::vector<::ucbhelper::InterceptedInteraction::InterceptedRequest> lInterceptions{
36 { //intercept standard IO error exception (local file and WebDAV)
37 css::uno::Any(css::ucb::InteractiveIOException()),
39 { //intercept internal error
40 css::uno::Any(css::ucb::UnsupportedDataSinkException()),
42 {
43 //intercept network error exception (WebDAV ucp provider)
44 css::uno::Any(css::ucb::InteractiveNetworkException()),
47 },
48 { //intercept certificate validation request (WebDAV ucp provider)
49 css::uno::Any(css::ucb::CertificateValidationRequest()),
51 { //intercept authentication request (WebDAV ucp provider)
52 css::uno::Any(css::ucb::AuthenticationRequest()),
54 };
55
56 setInterceptedHandler(xHandler);
57 setInterceptions(std::move(lInterceptions));
58}
59
61
63 const ::ucbhelper::InterceptedInteraction::InterceptedRequest& aRequest,
64 const css::uno::Reference<css::task::XInteractionRequest>& xRequest)
65{
66 bool bAbort = false;
67 switch (aRequest.Handle)
68 {
72 {
73 bAbort = true;
74 }
75 break;
76
78 {
79 // use default internal handler.
80 if (m_xInterceptedHandler.is())
81 {
82 m_xInterceptedHandler->handle(xRequest);
83 return ::ucbhelper::InterceptedInteraction::E_INTERCEPTED;
84 }
85 else
86 bAbort = true;
87 break;
88 }
89
91 {
92 // use default internal handler.
93 if (m_xInterceptedHandler.is())
94 {
95 m_xInterceptedHandler->handle(xRequest);
96 return ::ucbhelper::InterceptedInteraction::E_INTERCEPTED;
97 }
98 else //simply abort
99 bAbort = true;
100 }
101 break;
102 }
103
104 // handle interaction by ourself, by not doing
105 // any selection...
106 if (bAbort)
107 {
108 css::uno::Reference<css::task::XInteractionContinuation> xAbort
110 xRequest->getContinuations(), cppu::UnoType<css::task::XInteractionAbort>::get());
111 if (!xAbort.is())
112 return ::ucbhelper::InterceptedInteraction::E_NO_CONTINUATION_FOUND;
113 return ::ucbhelper::InterceptedInteraction::E_INTERCEPTED;
114 }
115
116 return ::ucbhelper::InterceptedInteraction::E_INTERCEPTED;
117}
118}
119
120/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual ucbhelper::InterceptedInteraction::EInterceptionState intercepted(const ::ucbhelper::InterceptedInteraction::InterceptedRequest &aRequest, const css::uno::Reference< css::task::XInteractionRequest > &xRequest) override
SimpleFileAccessInteraction(const css::uno::Reference< css::task::XInteractionHandler > &xHandler)
css::uno::Type const & get()
css::uno::Reference< css::task::XInteractionHandler > m_xInterceptedHandler
void setInterceptedHandler(const css::uno::Reference< css::task::XInteractionHandler > &xInterceptedHandler)
void setInterceptions(::std::vector< InterceptedRequest > &&lInterceptions)
static css::uno::Reference< css::task::XInteractionContinuation > extractContinuation(const css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > > &lContinuations, const css::uno::Type &aType)
const sal_Int32 HANDLE_INTERACTIVENETWORKEXCEPTION
Will handle com::sun::star::ucb::InteractiveNetworkException.
const sal_Int32 HANDLE_AUTHENTICATIONREQUEST
Will handle com::sun::star::ucb::AuthenticationRequest.
const sal_Int32 HANDLE_INTERACTIVEIOEXCEPTION
Will handle com::sun::star::ucb::InteractiveIOException and derived classes.
const sal_Int32 HANDLE_CERTIFICATEREQUEST
Will handle com::sun::star::ucb::CertificateValidationRequest.
const sal_Int32 HANDLE_UNSUPPORTEDDATASINKEXCEPTION
Will handle com::sun::star::ucb::UnsupportedDataSinkException.