Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
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 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
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 .
18 : : */
19 : :
20 : :
21 : : #include "osl/mutex.hxx"
22 : :
23 : : #include "com/sun/star/lang/XTypeProvider.hpp"
24 : : #include "com/sun/star/task/DocumentPasswordRequest.hpp"
25 : :
26 : : #include "cppuhelper/typeprovider.hxx"
27 : : #include "ucbhelper/interactionrequest.hxx"
28 : :
29 : : #include "tdoc_passwordrequest.hxx"
30 : :
31 : : using namespace com::sun::star;
32 : : using namespace tdoc_ucp;
33 : :
34 : : namespace tdoc_ucp
35 : : {
36 [ # # ][ # # ]: 0 : class InteractionSupplyPassword :
37 : : public ucbhelper::InteractionContinuation,
38 : : public lang::XTypeProvider,
39 : : public task::XInteractionPassword
40 : : {
41 : : public:
42 : 0 : InteractionSupplyPassword( ucbhelper::InteractionRequest * pRequest )
43 [ # # ]: 0 : : InteractionContinuation( pRequest ) {}
44 : :
45 : : // XInterface
46 : : virtual uno::Any SAL_CALL queryInterface( const uno::Type & rType )
47 : : throw ( uno::RuntimeException );
48 : : virtual void SAL_CALL acquire()
49 : : throw ();
50 : : virtual void SAL_CALL release()
51 : : throw ();
52 : :
53 : : // XTypeProvider
54 : : virtual uno::Sequence< uno::Type > SAL_CALL getTypes()
55 : : throw ( uno::RuntimeException );
56 : : virtual uno::Sequence< sal_Int8 > SAL_CALL getImplementationId()
57 : : throw ( uno::RuntimeException );
58 : :
59 : : // XInteractionContinuation
60 : : virtual void SAL_CALL select()
61 : : throw ( uno::RuntimeException );
62 : :
63 : : // XInteractionPassword
64 : : virtual void SAL_CALL setPassword( const rtl::OUString & aPasswd )
65 : : throw ( uno::RuntimeException );
66 : : virtual rtl::OUString SAL_CALL getPassword()
67 : : throw ( uno::RuntimeException );
68 : :
69 : : private:
70 : : osl::Mutex m_aMutex;
71 : : rtl::OUString m_aPassword;
72 : : };
73 : : } // namespace tdoc_ucp
74 : :
75 : : //=========================================================================
76 : : //=========================================================================
77 : : //
78 : : // InteractionSupplyPassword Implementation.
79 : : //
80 : : //=========================================================================
81 : : //=========================================================================
82 : :
83 : : //=========================================================================
84 : : //
85 : : // XInterface methods.
86 : : //
87 : : //=========================================================================
88 : :
89 : : // virtual
90 : 0 : void SAL_CALL InteractionSupplyPassword::acquire()
91 : : throw()
92 : : {
93 : 0 : OWeakObject::acquire();
94 : 0 : }
95 : :
96 : : //=========================================================================
97 : : // virtual
98 : 0 : void SAL_CALL InteractionSupplyPassword::release()
99 : : throw()
100 : : {
101 : 0 : OWeakObject::release();
102 : 0 : }
103 : :
104 : : //=========================================================================
105 : : // virtual
106 : : uno::Any SAL_CALL
107 : 0 : InteractionSupplyPassword::queryInterface( const uno::Type & rType )
108 : : throw ( uno::RuntimeException )
109 : : {
110 : : uno::Any aRet = cppu::queryInterface( rType,
111 : : static_cast< lang::XTypeProvider * >( this ),
112 : : static_cast< task::XInteractionContinuation * >( this ),
113 [ # # ]: 0 : static_cast< task::XInteractionPassword * >( this ) );
114 : :
115 : 0 : return aRet.hasValue()
116 [ # # ][ # # ]: 0 : ? aRet : InteractionContinuation::queryInterface( rType );
117 : : }
118 : :
119 : : //=========================================================================
120 : : //
121 : : // XTypeProvider methods.
122 : : //
123 : : //=========================================================================
124 : :
125 : : // virtual
126 : : uno::Sequence< sal_Int8 > SAL_CALL
127 : 0 : InteractionSupplyPassword::getImplementationId()
128 : : throw( uno::RuntimeException )
129 : : {
130 : : static cppu::OImplementationId * pId = 0;
131 [ # # ]: 0 : if ( !pId )
132 : : {
133 [ # # ][ # # ]: 0 : osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
134 [ # # ]: 0 : if ( !pId )
135 : : {
136 [ # # ][ # # ]: 0 : static cppu::OImplementationId id( sal_False );
137 : 0 : pId = &id;
138 [ # # ]: 0 : }
139 : : }
140 : 0 : return (*pId).getImplementationId();
141 : : }
142 : :
143 : : //=========================================================================
144 : : // virtual
145 : 0 : uno::Sequence< uno::Type > SAL_CALL InteractionSupplyPassword::getTypes()
146 : : throw( uno::RuntimeException )
147 : : {
148 : : static cppu::OTypeCollection * pCollection = 0;
149 [ # # ]: 0 : if ( !pCollection )
150 : : {
151 [ # # ][ # # ]: 0 : osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
152 [ # # ]: 0 : if ( !pCollection )
153 : : {
154 : : static cppu::OTypeCollection collection(
155 : : getCppuType( static_cast<
156 [ # # ]: 0 : uno::Reference< lang::XTypeProvider > * >( 0 ) ),
157 : : getCppuType( static_cast<
158 [ # # ][ # # ]: 0 : uno::Reference< task::XInteractionPassword > * >( 0 ) ) );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
159 : 0 : pCollection = &collection;
160 [ # # ]: 0 : }
161 : : }
162 : 0 : return (*pCollection).getTypes();
163 : : }
164 : :
165 : : //=========================================================================
166 : : //
167 : : // XInteractionContinuation methods.
168 : : //
169 : : //=========================================================================
170 : :
171 : : // virtual
172 : 0 : void SAL_CALL InteractionSupplyPassword::select()
173 : : throw( uno::RuntimeException )
174 : : {
175 : 0 : recordSelection();
176 : 0 : }
177 : :
178 : : //=========================================================================
179 : : //
180 : : // XInteractionPassword methods.
181 : : //
182 : : //=========================================================================
183 : :
184 : : // virtual
185 : : void SAL_CALL
186 : 0 : InteractionSupplyPassword::setPassword( const ::rtl::OUString& aPasswd )
187 : : throw ( uno::RuntimeException )
188 : : {
189 [ # # ]: 0 : osl::MutexGuard aGuard( m_aMutex );
190 [ # # ]: 0 : m_aPassword = aPasswd;
191 : 0 : }
192 : :
193 : : // virtual
194 : 0 : rtl::OUString SAL_CALL InteractionSupplyPassword::getPassword()
195 : : throw ( uno::RuntimeException )
196 : : {
197 [ # # ]: 0 : osl::MutexGuard aGuard( m_aMutex );
198 [ # # ]: 0 : return m_aPassword;
199 : : }
200 : :
201 : : //=========================================================================
202 : : //=========================================================================
203 : : //
204 : : // DocumentPasswordRequest Implementation.
205 : : //
206 : : //=========================================================================
207 : : //=========================================================================
208 : :
209 : 0 : DocumentPasswordRequest::DocumentPasswordRequest(
210 : : task::PasswordRequestMode eMode,
211 : 0 : const rtl::OUString & rDocumentName )
212 : : {
213 : : // Fill request...
214 [ # # ]: 0 : task::DocumentPasswordRequest aRequest;
215 : : // aRequest.Message = // OUString
216 : : // aRequest.Context = // XInterface
217 : 0 : aRequest.Classification = task::InteractionClassification_ERROR;
218 : 0 : aRequest.Mode = eMode;
219 : 0 : aRequest.Name = rDocumentName;
220 : :
221 [ # # ][ # # ]: 0 : setRequest( uno::makeAny( aRequest ) );
222 : :
223 : : // Fill continuations...
224 : : uno::Sequence<
225 [ # # ]: 0 : uno::Reference< task::XInteractionContinuation > > aContinuations( 3 );
226 [ # # ][ # # ]: 0 : aContinuations[ 0 ] = new ucbhelper::InteractionAbort( this );
[ # # ][ # # ]
227 [ # # ][ # # ]: 0 : aContinuations[ 1 ] = new ucbhelper::InteractionRetry( this );
[ # # ][ # # ]
228 [ # # ][ # # ]: 0 : aContinuations[ 2 ] = new InteractionSupplyPassword( this );
[ # # ][ # # ]
229 : :
230 [ # # ][ # # ]: 0 : setContinuations( aContinuations );
[ # # ]
231 : 0 : }
232 : :
233 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|