1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: handleinteractionrequest.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_ucbhelper.hxx"
33 #include "ucbhelper/handleinteractionrequest.hxx"
34 #include "com/sun/star/task/XInteractionAbort.hpp"
35 #include "com/sun/star/task/XInteractionHandler.hpp"
36 #include "com/sun/star/task/XInteractionRetry.hpp"
37 #include "com/sun/star/ucb/CommandFailedException.hpp"
38 #include "com/sun/star/ucb/XCommandEnvironment.hpp"
39 #include "com/sun/star/uno/Reference.hxx"
40 #include "com/sun/star/uno/RuntimeException.hpp"
41 #include "cppuhelper/exc_hlp.hxx"
42 #include "osl/diagnose.h"
43 #include "rtl/ustring.hxx"
44 #ifndef _UCBHELPER_INTERACTIONREQUEST_HXX
45 #include "ucbhelper/interactionrequest.hxx"
47 #include "ucbhelper/simpleauthenticationrequest.hxx"
48 #include "ucbhelper/simpleinteractionrequest.hxx"
49 #include "ucbhelper/simplecertificatevalidationrequest.hxx"
50 #ifndef INCLUDED_UTILITY
52 #define INCLUDED_UTILITY
55 using namespace com::sun::star
;
60 handle(uno::Reference
< task::XInteractionRequest
> const & rRequest
,
61 uno::Reference
< ucb::XCommandEnvironment
> const & rEnvironment
)
62 SAL_THROW((uno::Exception
))
64 OSL_ENSURE(rRequest
.is(), "specification violation");
65 uno::Reference
< task::XInteractionHandler
> xHandler
;
66 if (rEnvironment
.is())
67 xHandler
= rEnvironment
->getInteractionHandler();
69 cppu::throwException(rRequest
->getRequest());
70 xHandler
->handle(rRequest
.get());
78 handleInteractionRequest(
79 rtl::Reference
< ucbhelper::SimpleInteractionRequest
> const & rRequest
,
80 uno::Reference
< ucb::XCommandEnvironment
> const & rEnvironment
,
82 SAL_THROW((uno::Exception
))
84 handle(rRequest
.get(), rEnvironment
);
85 sal_Int32 nResponse
= rRequest
->getResponse();
88 case ucbhelper::CONTINUATION_UNKNOWN
:
89 cppu::throwException(rRequest
->getRequest());
92 case ucbhelper::CONTINUATION_ABORT
:
94 throw ucb::CommandFailedException(
95 rtl::OUString(), 0, rRequest
->getRequest());
101 std::pair
< sal_Int32
,
102 rtl::Reference
< ucbhelper::InteractionSupplyAuthentication
> >
103 handleInteractionRequest(
104 rtl::Reference
< ucbhelper::SimpleAuthenticationRequest
> const & rRequest
,
105 uno::Reference
< ucb::XCommandEnvironment
> const & rEnvironment
,
107 SAL_THROW((uno::Exception
))
109 handle(rRequest
.get(), rEnvironment
);
110 rtl::Reference
< ucbhelper::InteractionContinuation
>
111 xContinuation(rRequest
->getSelection());
112 if (uno::Reference
< task::XInteractionAbort
>(
113 xContinuation
.get(), uno::UNO_QUERY
).
116 throw ucb::CommandFailedException(
117 rtl::OUString(), 0, rRequest
->getRequest());
119 return std::make_pair(
120 ucbhelper::CONTINUATION_ABORT
,
122 ucbhelper::InteractionSupplyAuthentication
>());
123 else if (uno::Reference
< task::XInteractionRetry
>(
124 xContinuation
.get(), uno::UNO_QUERY
).
126 return std::make_pair(
127 ucbhelper::CONTINUATION_ABORT
,
129 ucbhelper::InteractionSupplyAuthentication
>());
131 return std::make_pair(
132 ucbhelper::CONTINUATION_UNKNOWN
,
134 ucbhelper::InteractionSupplyAuthentication
>(
135 rRequest
->getAuthenticationSupplier()));
140 namespace ucbhelper
{
143 handleInteractionRequest(
144 rtl::Reference
< ucbhelper::SimpleCertificateValidationRequest
> const & rRequest
,
145 uno::Reference
< ucb::XCommandEnvironment
> const & rEnvironment
,
147 SAL_THROW((uno::Exception
))
149 handle(rRequest
.get(), rEnvironment
);
150 sal_Int32 nResponse
= rRequest
->getResponse();
153 case ucbhelper::CONTINUATION_UNKNOWN
:
154 cppu::throwException(rRequest
->getRequest());
157 case ucbhelper::CONTINUATION_ABORT
:
159 throw ucb::CommandFailedException(
160 rtl::OUString(), 0, rRequest
->getRequest());