diff options
author | Stephan Bergmann <sb@openoffice.org> | 2001-07-13 11:51:23 +0000 |
---|---|---|
committer | Stephan Bergmann <sb@openoffice.org> | 2001-07-13 11:51:23 +0000 |
commit | 2fe3e15eb9cb90c14b34180b4dfd8567db9ba13d (patch) | |
tree | 6e356eceddd9faabdaf74b680846cc4ecc261679 /ucbhelper | |
parent | a49b997c0cf3e39d3b6fcf3329713fc9ccd784e3 (diff) |
#88969#
Diffstat (limited to 'ucbhelper')
-rw-r--r-- | ucbhelper/inc/ucbhelper/handleinteractionrequest.hxx | 203 | ||||
-rw-r--r-- | ucbhelper/source/provider/handleinteractionrequest.cxx | 200 |
2 files changed, 403 insertions, 0 deletions
diff --git a/ucbhelper/inc/ucbhelper/handleinteractionrequest.hxx b/ucbhelper/inc/ucbhelper/handleinteractionrequest.hxx new file mode 100644 index 000000000000..22eccd58a6ca --- /dev/null +++ b/ucbhelper/inc/ucbhelper/handleinteractionrequest.hxx @@ -0,0 +1,203 @@ +/************************************************************************* + * + * $RCSfile: handleinteractionrequest.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: sb $ $Date: 2001-07-13 12:45:24 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef INCLUDED_UCBHELPER_HANDLEINTERACTIONREQUEST_HXX +#define INCLUDED_UCBHELPER_HANDLEINTERACTIONREQUEST_HXX + +#ifndef _COM_SUN_STAR_UNO_EXCEPTION_HPP_ +#include "com/sun/star/uno/Exception.hpp" +#endif +#ifndef _COM_SUN_STAR_UNO_REFERENCE_HXX_ +#include "com/sun/star/uno/Reference.hxx" +#endif +#ifndef _RTL_REF_HXX_ +#include "rtl/ref.hxx" +#endif +#ifndef _SAL_TYPES_H_ +#include "sal/types.h" +#endif + +#ifndef INCLUDED_UTILITY +#include <utility> +#define INCLUDED_UTILITY +#endif + +namespace com { namespace sun { namespace star { namespace ucb { + class XCommandEnvironment; +} } } } +namespace ucbhelper { + class InteractionSupplyAuthentication; + class SimpleAuthenticationRequest; + class SimpleInteractionRequest; +} + +/** Pass a <type scope="ucbhelper">SimpleInteractionRequest</type> to an + <type scope="com::sun::star::task">XInteractionHandler</type>, and handle + (by throwing the request as an exception) those cases where an interaction + handler is either not available or does not handle the request. + + @param rRequest + a <type scope="ucbhelper">SimpleInteractionRequest</type>. Must not be + <NULL/>. + + @param rEnvironment + At the moment, only the + <type scope="com::sun::star::task">XInteractionHandler</type> part is + used. May be <NULL/>. + + @param bThrowOnAbort + determines what is done if the interaction handler selects a + <const scope="ucbhelper">CONTINUATION_ABORT</const> continuation: If + <TRUE/>, an appropriate + <type scope="com::sun::star::ucb">CommandFailedException</type> is thrown. + If <FALSE/>, <const scope="ucbhelper">CONTINUATION_ABORT</const> is passed + to the caller of this function. + + @returns + the constant (defined in ucbhelper/simpelinteractionrequest.hxx) that + corresponds to the continuation selected by the interaction handler. + The constant <const scope="ucbhelper">CONTINUATION_UNKNOWN</const> will + never be returned. + + @throws + <ul> + <li>the exception specified by the request, if an interaction handler is + either not available or does not handle the request;</li> + <li>a <type scope="com::sun::star::ucb">CommandFailedException</type> if + the interaction handler selects a + <const scope="ucbhelper">CONTINUATION_ABORT</const> continuation and + <code>bThrowOnAbort</code> is <TRUE/>;</li> + <li>a <type scope="com::sun::star::uno">RuntimeException</type> if such an + exception is thrown by code called from within this function.</li> + </ul> + */ +namespace ucbhelper { + +sal_Int32 +handleInteractionRequest( + rtl::Reference< ucbhelper::SimpleInteractionRequest > const & rRequest, + com::sun::star::uno::Reference< + com::sun::star::ucb::XCommandEnvironment > const & + rEnvironment, + bool bThrowOnAbort = true) + SAL_THROW((com::sun::star::uno::Exception)); + +} + +/** Pass a <type scope="ucbhelper">SimpleAuthenticationRequest</type> to an + <type scope="com::sun::star::task">XInteractionHandler</type>, and handle + (by throwing the request as an exception) those cases where an interaction + handler is either not available or does not handle the request. + + @param rRequest + a <type scope="ucbhelper">SimpleAuthenticationRequest</type>. Must not be + <NULL/>. + + @param rEnvironment + At the moment, only the + <type scope="com::sun::star::task">XInteractionHandler</type> part is + used. May be <NULL/>. + + @param bThrowOnAbort + determines what is done if the interaction handler selects a + <const scope="ucbhelper">CONTINUATION_ABORT</const> continuation: If + <TRUE/>, an appropriate + <type scope="com::sun::star::ucb">CommandFailedException</type> is thrown. + If <FALSE/>, <const scope="ucbhelper">CONTINUATION_ABORT</const> is passed + to the caller of this function. + + @returns + either a pair consisting of one of the constants + <const scope="ucbhelper">CONTINUATION_ABORT</const> or + <const scope="ucbhelper">CONTINUATION_RETRY</const> (defined in + ucbhelper/simpelinteractionrequest.hxx) and an empty reference, or a pair + consisting of the constant + <const scope="ucbhelper">CONTINUATION_UNKNOWN</const> and a reference to + an <type scope="ucbhelper">InteractionSupplyAuthentication</type> that + contains the supplied data. + + @throws + <ul> + <li>the exception specified by the request, if an interaction handler is + either not available or does not handle the request;</li> + <li>a <type scope="com::sun::star::ucb">CommandFailedException</type> if + the interaction handler selects a + <const scope="ucbhelper">CONTINUATION_ABORT</const> continuation and + <code>bThrowOnAbort</code> is <TRUE/>;</li> + <li>a <type scope="com::sun::star::uno">RuntimeException</type> if such an + exception is thrown by code called from within this function.</li> + </ul> + */ +namespace ucbhelper { + +std::pair< sal_Int32, + rtl::Reference< ucbhelper::InteractionSupplyAuthentication > > +handleInteractionRequest( + rtl::Reference< ucbhelper::SimpleAuthenticationRequest > const & rRequest, + com::sun::star::uno::Reference< + com::sun::star::ucb::XCommandEnvironment > const & + rEnvironment, + bool bThrowOnAbort = true) + SAL_THROW((com::sun::star::uno::Exception)); + +} + +#endif // INCLUDED_UCBHELPER_HANDLEINTERACTIONREQUEST_HXX diff --git a/ucbhelper/source/provider/handleinteractionrequest.cxx b/ucbhelper/source/provider/handleinteractionrequest.cxx new file mode 100644 index 000000000000..960bb174f985 --- /dev/null +++ b/ucbhelper/source/provider/handleinteractionrequest.cxx @@ -0,0 +1,200 @@ +/************************************************************************* + * + * $RCSfile: handleinteractionrequest.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: sb $ $Date: 2001-07-13 12:48:52 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef INCLUDED_UCBHELPER_HANDLEINTERACTIONREQUEST_HXX +#include "ucbhelper/handleinteractionrequest.hxx" +#endif + +#ifndef _COM_SUN_STAR_TASK_XINTERACTIONABORT_HPP_ +#include "com/sun/star/task/XInteractionAbort.hpp" +#endif +#ifndef _COM_SUN_STAR_TASK_XINTERACTIONHANDLER_HPP_ +#include "com/sun/star/task/XInteractionHandler.hpp" +#endif +#ifndef _COM_SUN_STAR_TASK_XINTERACTIONRETRY_HPP_ +#include "com/sun/star/task/XInteractionRetry.hpp" +#endif +#ifndef _COM_SUN_STAR_UCB_COMMANDFAILEDEXCEPTION_HPP_ +#include "com/sun/star/ucb/CommandFailedException.hpp" +#endif +#ifndef _COM_SUN_STAR_UCB_XCOMMANDENVIRONMENT_HPP_ +#include "com/sun/star/ucb/XCommandEnvironment.hpp" +#endif +#ifndef _COM_SUN_STAR_UNO_REFERENCE_HXX_ +#include "com/sun/star/uno/Reference.hxx" +#endif +#ifndef _COM_SUN_STAR_UNO_RUNTIMEEXCEPTION_HPP_ +#include "com/sun/star/uno/RuntimeException.hpp" +#endif +#ifndef _CPPUHELPER_EXC_HLP_HXX_ +#include "cppuhelper/exc_hlp.hxx" +#endif +#ifndef _OSL_DIAGNOSE_H_ +#include "osl/diagnose.h" +#endif +#ifndef _RTL_USTRING_HXX_ +#include "rtl/ustring.hxx" +#endif +#ifndef _UCBHELPER_INTERACTIONREQUEST_HXX +#include "ucbhelper/interactionrequest.hxx" +#endif +#ifndef _UCBHELPER_SIMPLEAUTHENTICATIONREQUEST_HXX +#include "ucbhelper/simpleauthenticationrequest.hxx" +#endif +#ifndef _UCBHELPER_SIMPLEINTERACTIONREQUEST_HXX +#include "ucbhelper/simpleinteractionrequest.hxx" +#endif + +#ifndef INCLUDED_UTILITY +#include <utility> +#define INCLUDED_UTILITY +#endif + +using namespace com::sun; + +namespace { + +void +handle(star::uno::Reference< star::task::XInteractionRequest > const & + rRequest, + star::uno::Reference< star::ucb::XCommandEnvironment > const & + rEnvironment) + SAL_THROW((star::uno::Exception)) +{ + OSL_ENSURE(rRequest.is(), "specification violation"); + star::uno::Reference< star::task::XInteractionHandler > xHandler; + if (rEnvironment.is()) + xHandler = rEnvironment->getInteractionHandler(); + if (!xHandler.is()) + cppu::throwException(rRequest->getRequest()); + xHandler->handle(rRequest.get()); +} + +} + +namespace ucbhelper { + +sal_Int32 +handleInteractionRequest( + rtl::Reference< ucbhelper::SimpleInteractionRequest > const & + rRequest, + star::uno::Reference< star::ucb::XCommandEnvironment > const & + rEnvironment, + bool bThrowOnAbort) + SAL_THROW((star::uno::Exception)) +{ + handle(rRequest.get(), rEnvironment); + sal_Int32 nResponse = rRequest->getResponse(); + switch (nResponse) + { + case ucbhelper::CONTINUATION_UNKNOWN: + cppu::throwException(rRequest->getRequest()); + break; + + case ucbhelper::CONTINUATION_ABORT: + if (bThrowOnAbort) + throw star::ucb::CommandFailedException( + rtl::OUString(), 0, rRequest->getRequest()); + break; + } + return nResponse; +} + +std::pair< sal_Int32, + rtl::Reference< ucbhelper::InteractionSupplyAuthentication > > +handleInteractionRequest( + rtl::Reference< ucbhelper::SimpleAuthenticationRequest > const & rRequest, + com::sun::star::uno::Reference< + com::sun::star::ucb::XCommandEnvironment > const & + rEnvironment, + bool bThrowOnAbort) + SAL_THROW((com::sun::star::uno::Exception)) +{ + handle(rRequest.get(), rEnvironment); + rtl::Reference< ucbhelper::InteractionContinuation > + xContinuation(rRequest->getSelection()); + if (star::uno::Reference< star::task::XInteractionAbort >( + xContinuation.get(), star::uno::UNO_QUERY). + is()) + if (bThrowOnAbort) + throw star::ucb::CommandFailedException( + rtl::OUString(), 0, rRequest->getRequest()); + else + return std::make_pair( + ucbhelper::CONTINUATION_ABORT, + rtl::Reference< + ucbhelper::InteractionSupplyAuthentication >()); + else if (star::uno::Reference< star::task::XInteractionRetry >( + xContinuation.get(), star::uno::UNO_QUERY). + is()) + return std::make_pair( + ucbhelper::CONTINUATION_ABORT, + rtl::Reference< + ucbhelper::InteractionSupplyAuthentication >()); + else + return std::make_pair( + ucbhelper::CONTINUATION_UNKNOWN, + rtl::Reference< + ucbhelper::InteractionSupplyAuthentication >( + rRequest->getAuthenticationSupplier())); +} + +} |