diff options
author | Mihai Varga <mihai.mv13@gmail.com> | 2014-07-31 11:33:02 +0300 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-12-15 11:23:26 +0100 |
commit | 4998e6a361252529cabcaac37b0f03bbed173544 (patch) | |
tree | 6cd097acb1ed449939c71f07002f475fca8c693f | |
parent | fc79b871ecfa351c5ac2587d95d8f65bae811621 (diff) |
Authentication fallback request for the OneDrive connection
To fix build, also squashed in:
Author: Mihai Varga <mihai.mv13@gmail.com>
Date: Fri Aug 1 12:50:23 2014 +0300
OneDrive auth fallback dialog interaction continuation
Change-Id: Id37f502217da3fde55ae93a6e1c01409509d657c
-rw-r--r-- | include/ucbhelper/authenticationfallback.hxx | 52 | ||||
-rw-r--r-- | include/ucbhelper/interactionrequest.hxx | 34 | ||||
-rw-r--r-- | offapi/UnoApi_offapi.mk | 1 | ||||
-rw-r--r-- | offapi/com/sun/star/ucb/XInteractionAuthFallback.idl | 32 | ||||
-rw-r--r-- | ucbhelper/Library_ucbhelper.mk | 1 | ||||
-rw-r--r-- | ucbhelper/source/provider/authenticationfallback.cxx | 35 | ||||
-rw-r--r-- | ucbhelper/source/provider/interactionrequest.cxx | 56 |
7 files changed, 211 insertions, 0 deletions
diff --git a/include/ucbhelper/authenticationfallback.hxx b/include/ucbhelper/authenticationfallback.hxx new file mode 100644 index 000000000000..5e7bb4732e2f --- /dev/null +++ b/include/ucbhelper/authenticationfallback.hxx @@ -0,0 +1,52 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_UCBHELPER_AUTHENTICATIONFALLBACK_HXX +#define INCLUDED_UCBHELPER_AUTHENTICATIONFALLBACK_HXX + +#include <rtl/ref.hxx> +#include <ucbhelper/interactionrequest.hxx> +#include <ucbhelper/ucbhelperdllapi.h> +#include <com/sun/star/ucb/AuthenticationFallbackRequest.hpp> + + +namespace ucbhelper { + +/** + * This class implements a simple authentication interaction request used + * when programmatically authentication cannot succeed. + * + * Read-only values : instructions, url + * Read-write values: code + */ +class UCBHELPER_DLLPUBLIC AuthenticationFallbackRequest : public ucbhelper::InteractionRequest +{ +private: + rtl::Reference< ucbhelper::InteractionAuthFallback > m_xAuthFallback; + +public: + /** + * Constructor. + * + * @param rInstructions instructions to be followed by the user + * @param rURL contains a URL for which authentication is requested. + */ + AuthenticationFallbackRequest( const OUString & rInstructions, + const OUString & rURL ); + + const rtl::Reference< ucbhelper::InteractionAuthFallback >& + getAuthFallbackInter( ) const { return m_xAuthFallback; } + +}; + +} // namespace ucbhelper + +#endif /* ! INCLUDED_UCBHELPER_AUTHENTICATIONFALLBACK_HXX*/ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/ucbhelper/interactionrequest.hxx b/include/ucbhelper/interactionrequest.hxx index 84e0ca5f4694..213898353d12 100644 --- a/include/ucbhelper/interactionrequest.hxx +++ b/include/ucbhelper/interactionrequest.hxx @@ -26,6 +26,7 @@ #include <com/sun/star/task/XInteractionRetry.hpp> #include <com/sun/star/task/XInteractionApprove.hpp> #include <com/sun/star/task/XInteractionDisapprove.hpp> +#include <com/sun/star/ucb/XInteractionAuthFallback.hpp> #include <com/sun/star/ucb/XInteractionReplaceExistingData.hpp> #include <com/sun/star/ucb/XInteractionSupplyAuthentication2.hpp> #include <rtl/ref.hxx> @@ -660,6 +661,39 @@ public: throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE; }; +class UCBHELPER_DLLPUBLIC InteractionAuthFallback: + public InteractionContinuation, + public com::sun::star::ucb::XInteractionAuthFallback +{ + OUString m_aCode; + +public: + InteractionAuthFallback( InteractionRequest * pRequest ) + : InteractionContinuation( pRequest ) {} + + // XInterface + virtual com::sun::star::uno::Any SAL_CALL + queryInterface( const com::sun::star::uno::Type & rType ) + throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE; + virtual void SAL_CALL acquire() + throw() SAL_OVERRIDE; + virtual void SAL_CALL release() + throw() SAL_OVERRIDE; + + // XInteractionContinuation + virtual void SAL_CALL select() + throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE; + + // XAuthFallback + virtual void SAL_CALL setCode( const OUString& code ) + throw (::css::uno::RuntimeException, ::std::exception); + virtual OUString SAL_CALL getCode() + throw (::css::uno::RuntimeException, ::std::exception); + + +}; + + } // namespace ucbhelper #endif /* ! INCLUDED_UCBHELPER_INTERACTIONREQUEST_HXX */ diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk index 680a69251876..0028b46c997e 100644 --- a/offapi/UnoApi_offapi.mk +++ b/offapi/UnoApi_offapi.mk @@ -3938,6 +3938,7 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/ucb,\ XFetchProvider \ XFetchProviderForContentAccess \ XFileIdentifierConverter \ + XInteractionAuthFallback \ XInteractionHandlerSupplier \ XInteractionReplaceExistingData \ XInteractionSupplyAuthentication \ diff --git a/offapi/com/sun/star/ucb/XInteractionAuthFallback.idl b/offapi/com/sun/star/ucb/XInteractionAuthFallback.idl new file mode 100644 index 000000000000..cf0f2ecfb841 --- /dev/null +++ b/offapi/com/sun/star/ucb/XInteractionAuthFallback.idl @@ -0,0 +1,32 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +#ifndef __com_sun_star_task_XInteractionApprove_idl__ +#define __com_sun_star_task_XInteractionApprove_idl__ + +#include <com/sun/star/task/XInteractionContinuation.idl> + + + + module com { module sun { module star { module ucb { + +/** An interaction continuation specifying authentication success. + */ +published interface XInteractionAuthFallback: com::sun::star::task::XInteractionContinuation +{ + /* Authentication code submited by the user */ + void setCode( [in] string code ); + string getCode( ); +}; + + +}; }; }; }; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/ucbhelper/Library_ucbhelper.mk b/ucbhelper/Library_ucbhelper.mk index 8d1d80523c10..6787db13c4a6 100644 --- a/ucbhelper/Library_ucbhelper.mk +++ b/ucbhelper/Library_ucbhelper.mk @@ -33,6 +33,7 @@ $(eval $(call gb_Library_add_exception_objects,ucbhelper,\ ucbhelper/source/client/fileidentifierconverter \ ucbhelper/source/client/interceptedinteraction \ ucbhelper/source/client/proxydecider \ + ucbhelper/source/provider/authenticationfallback \ ucbhelper/source/provider/cancelcommandexecution \ ucbhelper/source/provider/contenthelper \ ucbhelper/source/provider/contentidentifier \ diff --git a/ucbhelper/source/provider/authenticationfallback.cxx b/ucbhelper/source/provider/authenticationfallback.cxx new file mode 100644 index 000000000000..5d8d0e275894 --- /dev/null +++ b/ucbhelper/source/provider/authenticationfallback.cxx @@ -0,0 +1,35 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <ucbhelper/authenticationfallback.hxx> + +using namespace com::sun::star; +using namespace ucbhelper; + +AuthenticationFallbackRequest::AuthenticationFallbackRequest( + const OUString & rInstructions, + const OUString & rURL ) +{ + + ucb::AuthenticationFallbackRequest aRequest; + aRequest.instructions = rInstructions; + aRequest.url = rURL; + + setRequest( uno::makeAny( aRequest ) ); + m_xAuthFallback = new InteractionAuthFallback( this ); + + uno::Sequence< + uno::Reference< task::XInteractionContinuation > > aContinuations( 2 ); + aContinuations[ 0 ] = new InteractionAbort( this ); + aContinuations[ 1 ] = m_xAuthFallback.get( ); + + setContinuations( aContinuations ); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/ucbhelper/source/provider/interactionrequest.cxx b/ucbhelper/source/provider/interactionrequest.cxx index 8e3b68ae36c8..c36c2a68ff6f 100644 --- a/ucbhelper/source/provider/interactionrequest.cxx +++ b/ucbhelper/source/provider/interactionrequest.cxx @@ -940,4 +940,60 @@ void SAL_CALL InteractionReplaceExistingData::select() recordSelection(); } +// InteractionAuthFallback Implementation + +// XInterface methods. + +// virtual +void SAL_CALL InteractionAuthFallback::acquire() + throw() +{ + OWeakObject::acquire(); +} + +// virtual +void SAL_CALL InteractionAuthFallback::release() + throw() +{ + OWeakObject::release(); +} + +// virtual +uno::Any SAL_CALL +InteractionAuthFallback::queryInterface( const uno::Type & rType ) + throw ( uno::RuntimeException, std::exception ) +{ + uno::Any aRet = cppu::queryInterface( rType, + static_cast< task::XInteractionContinuation * >( this ), + static_cast< ucb::XInteractionAuthFallback * >( this )); + + return aRet.hasValue() + ? aRet : InteractionContinuation::queryInterface( rType ); +} + +// XInteractionContinuation methods. + +// virtual +void SAL_CALL InteractionAuthFallback::select() + throw( uno::RuntimeException, std::exception ) +{ + recordSelection(); +} + +// XInteractionAuthFallback methods + +// virtual +void SAL_CALL InteractionAuthFallback::setCode( const OUString& code ) + throw ( uno::RuntimeException, std::exception ) +{ + m_aCode = code; +} + +// virtual +OUString SAL_CALL InteractionAuthFallback::getCode( ) + throw ( uno::RuntimeException, std::exception ) +{ + return m_aCode; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |