1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <com/sun/star/lang/XTypeProvider.hpp>
22 #include <com/sun/star/task/DocumentPasswordRequest.hpp>
23 #include <com/sun/star/task/XInteractionPassword.hpp>
25 #include <cppuhelper/queryinterface.hxx>
26 #include <cppuhelper/typeprovider.hxx>
27 #include <ucbhelper/interactionrequest.hxx>
29 #include "tdoc_passwordrequest.hxx"
33 using namespace com::sun::star
;
34 using namespace tdoc_ucp
;
40 using InteractionSupplyPassword_BASE
= cppu::ImplInheritanceHelper
<ucbhelper::InteractionContinuation
,
41 task::XInteractionPassword
>;
42 class InteractionSupplyPassword
: public InteractionSupplyPassword_BASE
45 explicit InteractionSupplyPassword( ucbhelper::InteractionRequest
* pRequest
)
46 : InteractionSupplyPassword_BASE( pRequest
) {}
48 // XInteractionContinuation
49 virtual void SAL_CALL
select() override
;
51 // XInteractionPassword
52 virtual void SAL_CALL
setPassword( const OUString
& aPasswd
) override
;
53 virtual OUString SAL_CALL
getPassword() override
;
61 } // namespace tdoc_ucp
64 // InteractionSupplyPassword Implementation.
67 // XInteractionContinuation methods.
71 void SAL_CALL
InteractionSupplyPassword::select()
77 // XInteractionPassword methods.
82 InteractionSupplyPassword::setPassword( const OUString
& aPasswd
)
84 std::scoped_lock
aGuard( m_aMutex
);
85 m_aPassword
= aPasswd
;
89 OUString SAL_CALL
InteractionSupplyPassword::getPassword()
91 std::scoped_lock
aGuard( m_aMutex
);
96 // DocumentPasswordRequest Implementation.
99 DocumentPasswordRequest::DocumentPasswordRequest(
100 task::PasswordRequestMode eMode
,
101 const OUString
& rDocumentName
)
104 task::DocumentPasswordRequest aRequest
;
105 // aRequest.Message = // OUString
106 // aRequest.Context = // XInterface
107 aRequest
.Classification
= task::InteractionClassification_ERROR
;
108 aRequest
.Mode
= eMode
;
109 aRequest
.Name
= rDocumentName
;
111 setRequest( uno::Any( aRequest
) );
113 // Fill continuations...
115 uno::Reference
< task::XInteractionContinuation
> > aContinuations
{
116 new ucbhelper::InteractionAbort( this ),
117 new ucbhelper::InteractionRetry( this ),
118 new InteractionSupplyPassword( this )
121 setContinuations( aContinuations
);
124 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */