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 /**************************************************************************
23 **************************************************************************
25 *************************************************************************/
26 #include <ucbhelper/interactionrequest.hxx>
28 #include <rtl/ref.hxx>
29 #include <osl/diagnose.h>
30 #include <cppuhelper/typeprovider.hxx>
31 #include <cppuhelper/queryinterface.hxx>
33 using namespace com::sun::star
;
34 using namespace ucbhelper
;
37 // InteractionRequest Implementation.
43 struct InteractionRequest_Impl
45 rtl::Reference
< InteractionContinuation
> m_xSelection
;
46 css::uno::Any m_aRequest
;
49 css::task::XInteractionContinuation
> > m_aContinuations
;
51 InteractionRequest_Impl() {}
52 explicit InteractionRequest_Impl( const uno::Any
& rRequest
)
53 : m_aRequest( rRequest
) {}
59 InteractionRequest::InteractionRequest()
60 : m_pImpl( new InteractionRequest_Impl
)
65 InteractionRequest::InteractionRequest( const uno::Any
& rRequest
)
66 : m_pImpl( new InteractionRequest_Impl( rRequest
) )
72 InteractionRequest::~InteractionRequest()
77 void InteractionRequest::setRequest( const uno::Any
& rRequest
)
79 m_pImpl
->m_aRequest
= rRequest
;
83 void InteractionRequest::setContinuations(
84 const uno::Sequence
< uno::Reference
<
85 task::XInteractionContinuation
> > & rContinuations
)
87 m_pImpl
->m_aContinuations
= rContinuations
;
91 rtl::Reference
< InteractionContinuation
> const &
92 InteractionRequest::getSelection() const
94 return m_pImpl
->m_xSelection
;
98 void InteractionRequest::setSelection(
99 const rtl::Reference
< InteractionContinuation
> & rxSelection
)
101 m_pImpl
->m_xSelection
= rxSelection
;
105 // XInterface methods.
109 void SAL_CALL
InteractionRequest::acquire()
112 OWeakObject::acquire();
117 void SAL_CALL
InteractionRequest::release()
120 OWeakObject::release();
126 InteractionRequest::queryInterface( const uno::Type
& rType
)
128 uno::Any aRet
= cppu::queryInterface( rType
,
129 static_cast< lang::XTypeProvider
* >( this ),
130 static_cast< task::XInteractionRequest
* >( this ) );
132 return aRet
.hasValue() ? aRet
: OWeakObject::queryInterface( rType
);
136 // XTypeProvider methods.
140 uno::Sequence
< sal_Int8
> SAL_CALL
InteractionRequest::getImplementationId()
142 return css::uno::Sequence
<sal_Int8
>();
147 uno::Sequence
< uno::Type
> SAL_CALL
InteractionRequest::getTypes()
149 static cppu::OTypeCollection
s_aCollection(
150 cppu::UnoType
<lang::XTypeProvider
>::get(),
151 cppu::UnoType
<task::XInteractionRequest
>::get() );
153 return s_aCollection
.getTypes();
157 // XInteractionRequest methods.
161 uno::Any SAL_CALL
InteractionRequest::getRequest()
163 return m_pImpl
->m_aRequest
;
168 uno::Sequence
< uno::Reference
< task::XInteractionContinuation
> > SAL_CALL
169 InteractionRequest::getContinuations()
171 return m_pImpl
->m_aContinuations
;
175 // InteractionContinuation Implementation.
178 InteractionContinuation::InteractionContinuation(
179 InteractionRequest
* pRequest
)
180 : m_pRequest( pRequest
)
186 InteractionContinuation::~InteractionContinuation()
191 void InteractionContinuation::recordSelection()
193 m_pRequest
->setSelection( this );
197 // InteractionAbort Implementation.
200 // XInterface methods.
204 void SAL_CALL
InteractionAbort::acquire()
207 OWeakObject::acquire();
212 void SAL_CALL
InteractionAbort::release()
215 OWeakObject::release();
221 InteractionAbort::queryInterface( const uno::Type
& rType
)
223 uno::Any aRet
= cppu::queryInterface( rType
,
224 static_cast< lang::XTypeProvider
* >( this ),
225 static_cast< task::XInteractionContinuation
* >( this ),
226 static_cast< task::XInteractionAbort
* >( this ) );
228 return aRet
.hasValue()
229 ? aRet
: InteractionContinuation::queryInterface( rType
);
233 // XTypeProvider methods.
237 uno::Sequence
< sal_Int8
> SAL_CALL
InteractionAbort::getImplementationId()
239 return css::uno::Sequence
<sal_Int8
>();
244 uno::Sequence
< uno::Type
> SAL_CALL
InteractionAbort::getTypes()
246 static cppu::OTypeCollection
s_aCollection(
247 cppu::UnoType
<lang::XTypeProvider
>::get(),
248 cppu::UnoType
<task::XInteractionAbort
>::get() );
250 return s_aCollection
.getTypes();
254 // XInteractionContinuation methods.
258 void SAL_CALL
InteractionAbort::select()
264 // InteractionRetry Implementation.
267 // XInterface methods.
271 void SAL_CALL
InteractionRetry::acquire()
274 OWeakObject::acquire();
279 void SAL_CALL
InteractionRetry::release()
282 OWeakObject::release();
288 InteractionRetry::queryInterface( const uno::Type
& rType
)
290 uno::Any aRet
= cppu::queryInterface( rType
,
291 static_cast< lang::XTypeProvider
* >( this ),
292 static_cast< task::XInteractionContinuation
* >( this ),
293 static_cast< task::XInteractionRetry
* >( this ) );
295 return aRet
.hasValue()
296 ? aRet
: InteractionContinuation::queryInterface( rType
);
300 // XTypeProvider methods.
304 uno::Sequence
< sal_Int8
> SAL_CALL
InteractionRetry::getImplementationId()
306 return css::uno::Sequence
<sal_Int8
>();
311 uno::Sequence
< uno::Type
> SAL_CALL
InteractionRetry::getTypes()
313 static cppu::OTypeCollection
s_aCollection(
314 cppu::UnoType
<lang::XTypeProvider
>::get(),
315 cppu::UnoType
<task::XInteractionRetry
>::get() );
317 return s_aCollection
.getTypes();
321 // XInteractionContinuation methods.
325 void SAL_CALL
InteractionRetry::select()
331 // InteractionApprove Implementation.
334 // XInterface methods.
338 void SAL_CALL
InteractionApprove::acquire()
341 OWeakObject::acquire();
346 void SAL_CALL
InteractionApprove::release()
349 OWeakObject::release();
355 InteractionApprove::queryInterface( const uno::Type
& rType
)
357 uno::Any aRet
= cppu::queryInterface( rType
,
358 static_cast< lang::XTypeProvider
* >( this ),
359 static_cast< task::XInteractionContinuation
* >( this ),
360 static_cast< task::XInteractionApprove
* >( this ) );
362 return aRet
.hasValue()
363 ? aRet
: InteractionContinuation::queryInterface( rType
);
367 // XTypeProvider methods.
371 uno::Sequence
< sal_Int8
> SAL_CALL
InteractionApprove::getImplementationId()
373 return css::uno::Sequence
<sal_Int8
>();
378 uno::Sequence
< uno::Type
> SAL_CALL
InteractionApprove::getTypes()
380 static cppu::OTypeCollection
s_aCollection(
381 cppu::UnoType
<lang::XTypeProvider
>::get(),
382 cppu::UnoType
<task::XInteractionApprove
>::get() );
384 return s_aCollection
.getTypes();
388 // XInteractionContinuation methods.
392 void SAL_CALL
InteractionApprove::select()
398 // InteractionDisapprove Implementation.
401 // XInterface methods.
405 void SAL_CALL
InteractionDisapprove::acquire()
408 OWeakObject::acquire();
413 void SAL_CALL
InteractionDisapprove::release()
416 OWeakObject::release();
422 InteractionDisapprove::queryInterface( const uno::Type
& rType
)
424 uno::Any aRet
= cppu::queryInterface( rType
,
425 static_cast< lang::XTypeProvider
* >( this ),
426 static_cast< task::XInteractionContinuation
* >( this ),
427 static_cast< task::XInteractionDisapprove
* >( this ) );
429 return aRet
.hasValue()
430 ? aRet
: InteractionContinuation::queryInterface( rType
);
434 // XTypeProvider methods.
438 uno::Sequence
< sal_Int8
> SAL_CALL
InteractionDisapprove::getImplementationId()
440 return css::uno::Sequence
<sal_Int8
>();
445 uno::Sequence
< uno::Type
> SAL_CALL
InteractionDisapprove::getTypes()
447 static cppu::OTypeCollection
s_aCollection(
448 cppu::UnoType
<lang::XTypeProvider
>::get(),
449 cppu::UnoType
<task::XInteractionDisapprove
>::get() );
451 return s_aCollection
.getTypes();
455 // XInteractionContinuation methods.
459 void SAL_CALL
InteractionDisapprove::select()
465 // InteractionSupplyAuthentication Implementation.
468 // XInterface methods.
472 void SAL_CALL
InteractionSupplyAuthentication::acquire()
475 OWeakObject::acquire();
480 void SAL_CALL
InteractionSupplyAuthentication::release()
483 OWeakObject::release();
489 InteractionSupplyAuthentication::queryInterface( const uno::Type
& rType
)
491 uno::Any aRet
= cppu::queryInterface( rType
,
492 static_cast< lang::XTypeProvider
* >( this ),
493 static_cast< task::XInteractionContinuation
* >( this ),
494 static_cast< ucb::XInteractionSupplyAuthentication
* >( this ),
495 static_cast< ucb::XInteractionSupplyAuthentication2
* >( this ));
497 return aRet
.hasValue()
498 ? aRet
: InteractionContinuation::queryInterface( rType
);
502 // XTypeProvider methods.
506 uno::Sequence
< sal_Int8
> SAL_CALL
507 InteractionSupplyAuthentication::getImplementationId()
509 return css::uno::Sequence
<sal_Int8
>();
514 uno::Sequence
< uno::Type
> SAL_CALL
InteractionSupplyAuthentication::getTypes()
516 static cppu::OTypeCollection
s_aCollection(
517 cppu::UnoType
<lang::XTypeProvider
>::get(),
518 cppu::UnoType
<ucb::XInteractionSupplyAuthentication2
>::get() );
520 return s_aCollection
.getTypes();
524 // XInteractionContinuation methods.
528 void SAL_CALL
InteractionSupplyAuthentication::select()
534 // XInteractionSupplyAuthentication methods.
539 InteractionSupplyAuthentication::canSetRealm()
541 return m_bCanSetRealm
;
547 InteractionSupplyAuthentication::setRealm( const OUString
& Realm
)
549 OSL_ENSURE( m_bCanSetPassword
,
550 "InteractionSupplyAuthentication::setRealm - Not supported!" );
552 if ( m_bCanSetRealm
)
559 InteractionSupplyAuthentication::canSetUserName()
561 return m_bCanSetUserName
;
567 InteractionSupplyAuthentication::setUserName( const OUString
& UserName
)
569 OSL_ENSURE( m_bCanSetUserName
,
570 "InteractionSupplyAuthentication::setUserName - Not supported!" );
572 if ( m_bCanSetUserName
)
573 m_aUserName
= UserName
;
579 InteractionSupplyAuthentication::canSetPassword()
581 return m_bCanSetPassword
;
587 InteractionSupplyAuthentication::setPassword( const OUString
& Password
)
589 OSL_ENSURE( m_bCanSetPassword
,
590 "InteractionSupplyAuthentication::setPassword - Not supported!" );
592 if ( m_bCanSetPassword
)
593 m_aPassword
= Password
;
598 uno::Sequence
< ucb::RememberAuthentication
> SAL_CALL
599 InteractionSupplyAuthentication::getRememberPasswordModes(
600 ucb::RememberAuthentication
& Default
)
602 Default
= m_eDefaultRememberPasswordMode
;
603 return m_aRememberPasswordModes
;
609 InteractionSupplyAuthentication::setRememberPassword(
610 ucb::RememberAuthentication Remember
)
612 m_eRememberPasswordMode
= Remember
;
618 InteractionSupplyAuthentication::canSetAccount()
620 return m_bCanSetAccount
;
626 InteractionSupplyAuthentication::setAccount( const OUString
& Account
)
628 OSL_ENSURE( m_bCanSetAccount
,
629 "InteractionSupplyAuthentication::setAccount - Not supported!" );
631 if ( m_bCanSetAccount
)
632 m_aAccount
= Account
;
637 uno::Sequence
< ucb::RememberAuthentication
> SAL_CALL
638 InteractionSupplyAuthentication::getRememberAccountModes(
639 ucb::RememberAuthentication
& Default
)
641 Default
= m_eDefaultRememberAccountMode
;
642 return m_aRememberAccountModes
;
647 void SAL_CALL
InteractionSupplyAuthentication::setRememberAccount(
648 ucb::RememberAuthentication
)
653 // XInteractionSupplyAuthentication2 methods.
658 InteractionSupplyAuthentication::canUseSystemCredentials(
662 return m_bCanUseSystemCredentials
;
667 void SAL_CALL
InteractionSupplyAuthentication::setUseSystemCredentials(
668 sal_Bool UseSystemCredentials
)
670 if ( m_bCanUseSystemCredentials
)
671 m_bUseSystemCredentials
= UseSystemCredentials
;
675 // InteractionReplaceExistingData Implementation.
678 // XInterface methods.
682 void SAL_CALL
InteractionReplaceExistingData::acquire()
685 OWeakObject::acquire();
690 void SAL_CALL
InteractionReplaceExistingData::release()
693 OWeakObject::release();
699 InteractionReplaceExistingData::queryInterface( const uno::Type
& rType
)
701 uno::Any aRet
= cppu::queryInterface( rType
,
702 static_cast< lang::XTypeProvider
* >( this ),
703 static_cast< task::XInteractionContinuation
* >( this ),
704 static_cast< ucb::XInteractionReplaceExistingData
* >( this ) );
706 return aRet
.hasValue()
707 ? aRet
: InteractionContinuation::queryInterface( rType
);
711 // XTypeProvider methods.
715 uno::Sequence
< sal_Int8
> SAL_CALL
716 InteractionReplaceExistingData::getImplementationId()
718 return css::uno::Sequence
<sal_Int8
>();
723 uno::Sequence
< uno::Type
> SAL_CALL
InteractionReplaceExistingData::getTypes()
725 static cppu::OTypeCollection
s_aCollection(
726 cppu::UnoType
<lang::XTypeProvider
>::get(),
727 cppu::UnoType
<ucb::XInteractionReplaceExistingData
>::get() );
729 return s_aCollection
.getTypes();
733 // XInteractionContinuation methods.
737 void SAL_CALL
InteractionReplaceExistingData::select()
742 // InteractionAuthFallback Implementation
744 // XInterface methods.
747 void SAL_CALL
InteractionAuthFallback::acquire()
750 OWeakObject::acquire();
754 void SAL_CALL
InteractionAuthFallback::release()
757 OWeakObject::release();
762 InteractionAuthFallback::queryInterface( const uno::Type
& rType
)
764 uno::Any aRet
= cppu::queryInterface( rType
,
765 static_cast< task::XInteractionContinuation
* >( this ),
766 static_cast< ucb::XInteractionAuthFallback
* >( this ));
768 return aRet
.hasValue()
769 ? aRet
: InteractionContinuation::queryInterface( rType
);
772 // XInteractionContinuation methods.
775 void SAL_CALL
InteractionAuthFallback::select()
780 // XInteractionAuthFallback methods
783 void SAL_CALL
InteractionAuthFallback::setCode( const OUString
& code
)
788 const OUString
& InteractionAuthFallback::getCode() const
793 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */