Stop leaking all ScPostIt instances.
[LibreOffice.git] / ucb / source / ucp / cmis / auth_provider.cxx
blobbd00986a18b0e6c925305a08f669118fc0a6e98f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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 */
10 #define OUSTR_TO_STDSTR(s) string( OUStringToOString( s, RTL_TEXTENCODING_UTF8 ).getStr() )
11 #define STD_TO_OUSTR( str ) OUString( str.c_str(), str.length( ), RTL_TEXTENCODING_UTF8 )
13 #include <com/sun/star/task/XInteractionHandler.hpp>
15 #include <ucbhelper/simpleauthenticationrequest.hxx>
17 #include "auth_provider.hxx"
19 using namespace com::sun::star;
20 using namespace std;
22 namespace cmis
24 bool AuthProvider::authenticationQuery( string& username, string& password )
26 if ( m_xEnv.is() )
28 uno::Reference< task::XInteractionHandler > xIH
29 = m_xEnv->getInteractionHandler();
31 if ( xIH.is() )
33 rtl::Reference< ucbhelper::SimpleAuthenticationRequest > xRequest
34 = new ucbhelper::SimpleAuthenticationRequest(
35 m_sUrl, m_sBindingUrl, OUString(),
36 STD_TO_OUSTR( username ),
37 STD_TO_OUSTR( password ),
38 OUString(), true, false );
39 xIH->handle( xRequest.get() );
41 rtl::Reference< ucbhelper::InteractionContinuation > xSelection
42 = xRequest->getSelection();
44 if ( xSelection.is() )
46 // Handler handled the request.
47 uno::Reference< task::XInteractionAbort > xAbort(
48 xSelection.get(), uno::UNO_QUERY );
49 if ( !xAbort.is() )
51 const rtl::Reference<
52 ucbhelper::InteractionSupplyAuthentication > & xSupp
53 = xRequest->getAuthenticationSupplier();
55 username = OUSTR_TO_STDSTR( xSupp->getUserName() );
56 password = OUSTR_TO_STDSTR( xSupp->getPassword() );
58 return true;
63 return false;
67 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */