1*ac9096f4SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*ac9096f4SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*ac9096f4SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*ac9096f4SAndrew Rist * distributed with this work for additional information 6*ac9096f4SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*ac9096f4SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*ac9096f4SAndrew Rist * "License"); you may not use this file except in compliance 9*ac9096f4SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*ac9096f4SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*ac9096f4SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*ac9096f4SAndrew Rist * software distributed under the License is distributed on an 15*ac9096f4SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*ac9096f4SAndrew Rist * KIND, either express or implied. See the License for the 17*ac9096f4SAndrew Rist * specific language governing permissions and limitations 18*ac9096f4SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*ac9096f4SAndrew Rist *************************************************************/ 21*ac9096f4SAndrew Rist 22*ac9096f4SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_ucbhelper.hxx" 26cdf0e10cSrcweir #include "ucbhelper/handleinteractionrequest.hxx" 27cdf0e10cSrcweir #include "com/sun/star/task/XInteractionAbort.hpp" 28cdf0e10cSrcweir #include "com/sun/star/task/XInteractionHandler.hpp" 29cdf0e10cSrcweir #include "com/sun/star/task/XInteractionRetry.hpp" 30cdf0e10cSrcweir #include "com/sun/star/ucb/CommandFailedException.hpp" 31cdf0e10cSrcweir #include "com/sun/star/ucb/XCommandEnvironment.hpp" 32cdf0e10cSrcweir #include "com/sun/star/uno/Reference.hxx" 33cdf0e10cSrcweir #include "com/sun/star/uno/RuntimeException.hpp" 34cdf0e10cSrcweir #include "cppuhelper/exc_hlp.hxx" 35cdf0e10cSrcweir #include "osl/diagnose.h" 36cdf0e10cSrcweir #include "rtl/ustring.hxx" 37cdf0e10cSrcweir #ifndef _UCBHELPER_INTERACTIONREQUEST_HXX 38cdf0e10cSrcweir #include "ucbhelper/interactionrequest.hxx" 39cdf0e10cSrcweir #endif 40cdf0e10cSrcweir #include "ucbhelper/simpleauthenticationrequest.hxx" 41cdf0e10cSrcweir #include "ucbhelper/simpleinteractionrequest.hxx" 42cdf0e10cSrcweir #include "ucbhelper/simplecertificatevalidationrequest.hxx" 43cdf0e10cSrcweir #ifndef INCLUDED_UTILITY 44cdf0e10cSrcweir #include <utility> 45cdf0e10cSrcweir #define INCLUDED_UTILITY 46cdf0e10cSrcweir #endif 47cdf0e10cSrcweir 48cdf0e10cSrcweir using namespace com::sun::star; 49cdf0e10cSrcweir 50cdf0e10cSrcweir namespace { 51cdf0e10cSrcweir 52cdf0e10cSrcweir void 53cdf0e10cSrcweir handle(uno::Reference< task::XInteractionRequest > const & rRequest, 54cdf0e10cSrcweir uno::Reference< ucb::XCommandEnvironment > const & rEnvironment) 55cdf0e10cSrcweir SAL_THROW((uno::Exception)) 56cdf0e10cSrcweir { 57cdf0e10cSrcweir OSL_ENSURE(rRequest.is(), "specification violation"); 58cdf0e10cSrcweir uno::Reference< task::XInteractionHandler > xHandler; 59cdf0e10cSrcweir if (rEnvironment.is()) 60cdf0e10cSrcweir xHandler = rEnvironment->getInteractionHandler(); 61cdf0e10cSrcweir if (!xHandler.is()) 62cdf0e10cSrcweir cppu::throwException(rRequest->getRequest()); 63cdf0e10cSrcweir xHandler->handle(rRequest.get()); 64cdf0e10cSrcweir } 65cdf0e10cSrcweir 66cdf0e10cSrcweir } 67cdf0e10cSrcweir 68cdf0e10cSrcweir namespace ucbhelper { 69cdf0e10cSrcweir 70cdf0e10cSrcweir sal_Int32 71cdf0e10cSrcweir handleInteractionRequest( 72cdf0e10cSrcweir rtl::Reference< ucbhelper::SimpleInteractionRequest > const & rRequest, 73cdf0e10cSrcweir uno::Reference< ucb::XCommandEnvironment > const & rEnvironment, 74cdf0e10cSrcweir bool bThrowOnAbort) 75cdf0e10cSrcweir SAL_THROW((uno::Exception)) 76cdf0e10cSrcweir { 77cdf0e10cSrcweir handle(rRequest.get(), rEnvironment); 78cdf0e10cSrcweir sal_Int32 nResponse = rRequest->getResponse(); 79cdf0e10cSrcweir switch (nResponse) 80cdf0e10cSrcweir { 81cdf0e10cSrcweir case ucbhelper::CONTINUATION_UNKNOWN: 82cdf0e10cSrcweir cppu::throwException(rRequest->getRequest()); 83cdf0e10cSrcweir break; 84cdf0e10cSrcweir 85cdf0e10cSrcweir case ucbhelper::CONTINUATION_ABORT: 86cdf0e10cSrcweir if (bThrowOnAbort) 87cdf0e10cSrcweir throw ucb::CommandFailedException( 88cdf0e10cSrcweir rtl::OUString(), 0, rRequest->getRequest()); 89cdf0e10cSrcweir break; 90cdf0e10cSrcweir } 91cdf0e10cSrcweir return nResponse; 92cdf0e10cSrcweir } 93cdf0e10cSrcweir 94cdf0e10cSrcweir std::pair< sal_Int32, 95cdf0e10cSrcweir rtl::Reference< ucbhelper::InteractionSupplyAuthentication > > 96cdf0e10cSrcweir handleInteractionRequest( 97cdf0e10cSrcweir rtl::Reference< ucbhelper::SimpleAuthenticationRequest > const & rRequest, 98cdf0e10cSrcweir uno::Reference< ucb::XCommandEnvironment > const & rEnvironment, 99cdf0e10cSrcweir bool bThrowOnAbort) 100cdf0e10cSrcweir SAL_THROW((uno::Exception)) 101cdf0e10cSrcweir { 102cdf0e10cSrcweir handle(rRequest.get(), rEnvironment); 103cdf0e10cSrcweir rtl::Reference< ucbhelper::InteractionContinuation > 104cdf0e10cSrcweir xContinuation(rRequest->getSelection()); 105cdf0e10cSrcweir if (uno::Reference< task::XInteractionAbort >( 106cdf0e10cSrcweir xContinuation.get(), uno::UNO_QUERY). 107cdf0e10cSrcweir is()) 108cdf0e10cSrcweir if (bThrowOnAbort) 109cdf0e10cSrcweir throw ucb::CommandFailedException( 110cdf0e10cSrcweir rtl::OUString(), 0, rRequest->getRequest()); 111cdf0e10cSrcweir else 112cdf0e10cSrcweir return std::make_pair( 113cdf0e10cSrcweir ucbhelper::CONTINUATION_ABORT, 114cdf0e10cSrcweir rtl::Reference< 115cdf0e10cSrcweir ucbhelper::InteractionSupplyAuthentication >()); 116cdf0e10cSrcweir else if (uno::Reference< task::XInteractionRetry >( 117cdf0e10cSrcweir xContinuation.get(), uno::UNO_QUERY). 118cdf0e10cSrcweir is()) 119cdf0e10cSrcweir return std::make_pair( 120cdf0e10cSrcweir ucbhelper::CONTINUATION_ABORT, 121cdf0e10cSrcweir rtl::Reference< 122cdf0e10cSrcweir ucbhelper::InteractionSupplyAuthentication >()); 123cdf0e10cSrcweir else 124cdf0e10cSrcweir return std::make_pair( 125cdf0e10cSrcweir ucbhelper::CONTINUATION_UNKNOWN, 126cdf0e10cSrcweir rtl::Reference< 127cdf0e10cSrcweir ucbhelper::InteractionSupplyAuthentication >( 128cdf0e10cSrcweir rRequest->getAuthenticationSupplier())); 129cdf0e10cSrcweir } 130cdf0e10cSrcweir 131cdf0e10cSrcweir } 132cdf0e10cSrcweir 133cdf0e10cSrcweir namespace ucbhelper { 134cdf0e10cSrcweir 135cdf0e10cSrcweir sal_Int32 136cdf0e10cSrcweir handleInteractionRequest( 137cdf0e10cSrcweir rtl::Reference< ucbhelper::SimpleCertificateValidationRequest > const & rRequest, 138cdf0e10cSrcweir uno::Reference< ucb::XCommandEnvironment > const & rEnvironment, 139cdf0e10cSrcweir bool bThrowOnAbort) 140cdf0e10cSrcweir SAL_THROW((uno::Exception)) 141cdf0e10cSrcweir { 142cdf0e10cSrcweir handle(rRequest.get(), rEnvironment); 143cdf0e10cSrcweir sal_Int32 nResponse = rRequest->getResponse(); 144cdf0e10cSrcweir switch (nResponse) 145cdf0e10cSrcweir { 146cdf0e10cSrcweir case ucbhelper::CONTINUATION_UNKNOWN: 147cdf0e10cSrcweir cppu::throwException(rRequest->getRequest()); 148cdf0e10cSrcweir break; 149cdf0e10cSrcweir 150cdf0e10cSrcweir case ucbhelper::CONTINUATION_ABORT: 151cdf0e10cSrcweir if (bThrowOnAbort) 152cdf0e10cSrcweir throw ucb::CommandFailedException( 153cdf0e10cSrcweir rtl::OUString(), 0, rRequest->getRequest()); 154cdf0e10cSrcweir break; 155cdf0e10cSrcweir } 156cdf0e10cSrcweir return nResponse; 157cdf0e10cSrcweir } 158cdf0e10cSrcweir 159cdf0e10cSrcweir } 160cdf0e10cSrcweir 161