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 .
20 #ifndef INCLUDED_UCB_SOURCE_UCP_TDOC_TDOC_PASSWORDREQUEST_HXX
21 #define INCLUDED_UCB_SOURCE_UCP_TDOC_TDOC_PASSWORDREQUEST_HXX
23 #include "com/sun/star/task/PasswordRequestMode.hpp"
24 #include "com/sun/star/task/XInteractionPassword.hpp"
26 #include "ucbhelper/interactionrequest.hxx"
33 uno::Reference< ucb::XCommandEnvironment > Environment = ...;
35 if ( Environment.is() )
37 uno::Reference< task::XInteractionHandler > xIH
38 = Environment->getInteractionHandler();
41 rtl::Reference< DocumentPasswordRequest > xRequest
42 = new DocumentPasswordRequest(
43 task::PasswordRequestMode_PASSWORD_ENTER,
44 m_xIdentifier->getContentIdentifier() );
45 xIH->handle( xRequest.get() );
47 rtl::Reference< ucbhelper::InteractionContinuation > xSelection
48 = xRequest->getSelection();
50 if ( xSelection.is() )
52 // Handler handled the request.
53 uno::Reference< task::XInteractionAbort > xAbort(
54 xSelection.get(), uno::UNO_QUERY );
60 uno::Reference< task::XInteractionRetry > xRetry(
61 xSelection.get(), uno::UNO_QUERY );
67 uno::Reference< task::XInteractionPassword > xPassword(
68 xSelection.get(), uno::UNO_QUERY );
71 OUString aPassword = xPassword->getPassword();
81 class DocumentPasswordRequest
: public ucbhelper::InteractionRequest
84 DocumentPasswordRequest(
85 com::sun::star::task::PasswordRequestMode eMode
,
86 const OUString
& rDocumentName
);
89 } // namespace tdoc_ucp
91 #endif // INCLUDED_UCB_SOURCE_UCP_TDOC_TDOC_PASSWORDREQUEST_HXX
93 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */