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 <osl/mutex.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
;
39 // InteractionRequest Implementation.
47 struct InteractionRequest_Impl
49 rtl::Reference
< InteractionContinuation
> m_xSelection
;
50 com::sun::star::uno::Any m_aRequest
;
51 com::sun::star::uno::Sequence
<
52 com::sun::star::uno::Reference
<
53 com::sun::star::task::XInteractionContinuation
> > m_aContinuations
;
55 InteractionRequest_Impl() {}
56 InteractionRequest_Impl( const uno::Any
& rRequest
)
57 : m_aRequest( rRequest
) {}
63 InteractionRequest::InteractionRequest()
64 : m_pImpl( new InteractionRequest_Impl
)
69 InteractionRequest::InteractionRequest( const uno::Any
& rRequest
)
70 : m_pImpl( new InteractionRequest_Impl( rRequest
) )
76 InteractionRequest::~InteractionRequest()
82 void InteractionRequest::setRequest( const uno::Any
& rRequest
)
84 m_pImpl
->m_aRequest
= rRequest
;
88 void InteractionRequest::setContinuations(
89 const uno::Sequence
< uno::Reference
<
90 task::XInteractionContinuation
> > & rContinuations
)
92 m_pImpl
->m_aContinuations
= rContinuations
;
96 rtl::Reference
< InteractionContinuation
>
97 InteractionRequest::getSelection() const
99 return m_pImpl
->m_xSelection
;
103 void InteractionRequest::setSelection(
104 const rtl::Reference
< InteractionContinuation
> & rxSelection
)
106 m_pImpl
->m_xSelection
= rxSelection
;
111 // XInterface methods.
116 void SAL_CALL
InteractionRequest::acquire()
119 OWeakObject::acquire();
124 void SAL_CALL
InteractionRequest::release()
127 OWeakObject::release();
133 InteractionRequest::queryInterface( const uno::Type
& rType
)
134 throw ( uno::RuntimeException
, std::exception
)
136 uno::Any aRet
= cppu::queryInterface( rType
,
137 static_cast< lang::XTypeProvider
* >( this ),
138 static_cast< task::XInteractionRequest
* >( this ) );
140 return aRet
.hasValue() ? aRet
: OWeakObject::queryInterface( rType
);
145 // XTypeProvider methods.
150 uno::Sequence
< sal_Int8
> SAL_CALL
InteractionRequest::getImplementationId()
151 throw( uno::RuntimeException
, std::exception
)
153 return css::uno::Sequence
<sal_Int8
>();
158 uno::Sequence
< uno::Type
> SAL_CALL
InteractionRequest::getTypes()
159 throw( uno::RuntimeException
, std::exception
)
161 static cppu::OTypeCollection
* pCollection
= 0;
164 osl::Guard
< osl::Mutex
> aGuard( osl::Mutex::getGlobalMutex() );
167 static cppu::OTypeCollection
collection(
168 cppu::UnoType
<lang::XTypeProvider
>::get(),
169 cppu::UnoType
<task::XInteractionRequest
>::get() );
170 pCollection
= &collection
;
173 return (*pCollection
).getTypes();
178 // XInteractionRequest methods.
183 uno::Any SAL_CALL
InteractionRequest::getRequest()
184 throw( uno::RuntimeException
, std::exception
)
186 return m_pImpl
->m_aRequest
;
191 uno::Sequence
< uno::Reference
< task::XInteractionContinuation
> > SAL_CALL
192 InteractionRequest::getContinuations()
193 throw( uno::RuntimeException
, std::exception
)
195 return m_pImpl
->m_aContinuations
;
201 // InteractionContinuation Implementation.
209 struct InteractionContinuation_Impl
211 InteractionRequest
* m_pRequest
;
213 InteractionContinuation_Impl( InteractionRequest
* pRequest
)
214 : m_pRequest( pRequest
) {}
220 InteractionContinuation::InteractionContinuation(
221 InteractionRequest
* pRequest
)
222 : m_pImpl( new InteractionContinuation_Impl( pRequest
) )
228 InteractionContinuation::~InteractionContinuation()
234 void InteractionContinuation::recordSelection()
236 m_pImpl
->m_pRequest
->setSelection( this );
242 // InteractionAbort Implementation.
249 // XInterface methods.
254 void SAL_CALL
InteractionAbort::acquire()
257 OWeakObject::acquire();
262 void SAL_CALL
InteractionAbort::release()
265 OWeakObject::release();
271 InteractionAbort::queryInterface( const uno::Type
& rType
)
272 throw ( uno::RuntimeException
, std::exception
)
274 uno::Any aRet
= cppu::queryInterface( rType
,
275 static_cast< lang::XTypeProvider
* >( this ),
276 static_cast< task::XInteractionContinuation
* >( this ),
277 static_cast< task::XInteractionAbort
* >( this ) );
279 return aRet
.hasValue()
280 ? aRet
: InteractionContinuation::queryInterface( rType
);
285 // XTypeProvider methods.
290 uno::Sequence
< sal_Int8
> SAL_CALL
InteractionAbort::getImplementationId()
291 throw( uno::RuntimeException
, std::exception
)
293 return css::uno::Sequence
<sal_Int8
>();
298 uno::Sequence
< uno::Type
> SAL_CALL
InteractionAbort::getTypes()
299 throw( uno::RuntimeException
, std::exception
)
301 static cppu::OTypeCollection
* pCollection
= 0;
304 osl::Guard
< osl::Mutex
> aGuard( osl::Mutex::getGlobalMutex() );
307 static cppu::OTypeCollection
collection(
308 cppu::UnoType
<lang::XTypeProvider
>::get(),
309 cppu::UnoType
<task::XInteractionAbort
>::get() );
310 pCollection
= &collection
;
313 return (*pCollection
).getTypes();
318 // XInteractionContinuation methods.
323 void SAL_CALL
InteractionAbort::select()
324 throw( uno::RuntimeException
, std::exception
)
332 // InteractionRetry Implementation.
339 // XInterface methods.
344 void SAL_CALL
InteractionRetry::acquire()
347 OWeakObject::acquire();
352 void SAL_CALL
InteractionRetry::release()
355 OWeakObject::release();
361 InteractionRetry::queryInterface( const uno::Type
& rType
)
362 throw ( uno::RuntimeException
, std::exception
)
364 uno::Any aRet
= cppu::queryInterface( rType
,
365 static_cast< lang::XTypeProvider
* >( this ),
366 static_cast< task::XInteractionContinuation
* >( this ),
367 static_cast< task::XInteractionRetry
* >( this ) );
369 return aRet
.hasValue()
370 ? aRet
: InteractionContinuation::queryInterface( rType
);
375 // XTypeProvider methods.
380 uno::Sequence
< sal_Int8
> SAL_CALL
InteractionRetry::getImplementationId()
381 throw( uno::RuntimeException
, std::exception
)
383 return css::uno::Sequence
<sal_Int8
>();
388 uno::Sequence
< uno::Type
> SAL_CALL
InteractionRetry::getTypes()
389 throw( uno::RuntimeException
, std::exception
)
391 static cppu::OTypeCollection
* pCollection
= 0;
394 osl::Guard
< osl::Mutex
> aGuard( osl::Mutex::getGlobalMutex() );
397 static cppu::OTypeCollection
collection(
398 cppu::UnoType
<lang::XTypeProvider
>::get(),
399 cppu::UnoType
<task::XInteractionRetry
>::get() );
400 pCollection
= &collection
;
403 return (*pCollection
).getTypes();
408 // XInteractionContinuation methods.
413 void SAL_CALL
InteractionRetry::select()
414 throw( uno::RuntimeException
, std::exception
)
422 // InteractionApprove Implementation.
429 // XInterface methods.
434 void SAL_CALL
InteractionApprove::acquire()
437 OWeakObject::acquire();
442 void SAL_CALL
InteractionApprove::release()
445 OWeakObject::release();
451 InteractionApprove::queryInterface( const uno::Type
& rType
)
452 throw ( uno::RuntimeException
, std::exception
)
454 uno::Any aRet
= cppu::queryInterface( rType
,
455 static_cast< lang::XTypeProvider
* >( this ),
456 static_cast< task::XInteractionContinuation
* >( this ),
457 static_cast< task::XInteractionApprove
* >( this ) );
459 return aRet
.hasValue()
460 ? aRet
: InteractionContinuation::queryInterface( rType
);
465 // XTypeProvider methods.
470 uno::Sequence
< sal_Int8
> SAL_CALL
InteractionApprove::getImplementationId()
471 throw( uno::RuntimeException
, std::exception
)
473 return css::uno::Sequence
<sal_Int8
>();
478 uno::Sequence
< uno::Type
> SAL_CALL
InteractionApprove::getTypes()
479 throw( uno::RuntimeException
, std::exception
)
481 static cppu::OTypeCollection
* pCollection
= 0;
484 osl::Guard
< osl::Mutex
> aGuard( osl::Mutex::getGlobalMutex() );
487 static cppu::OTypeCollection
collection(
488 cppu::UnoType
<lang::XTypeProvider
>::get(),
489 cppu::UnoType
<task::XInteractionApprove
>::get() );
490 pCollection
= &collection
;
493 return (*pCollection
).getTypes();
498 // XInteractionContinuation methods.
503 void SAL_CALL
InteractionApprove::select()
504 throw( uno::RuntimeException
, std::exception
)
512 // InteractionDisapprove Implementation.
519 // XInterface methods.
524 void SAL_CALL
InteractionDisapprove::acquire()
527 OWeakObject::acquire();
532 void SAL_CALL
InteractionDisapprove::release()
535 OWeakObject::release();
541 InteractionDisapprove::queryInterface( const uno::Type
& rType
)
542 throw ( uno::RuntimeException
, std::exception
)
544 uno::Any aRet
= cppu::queryInterface( rType
,
545 static_cast< lang::XTypeProvider
* >( this ),
546 static_cast< task::XInteractionContinuation
* >( this ),
547 static_cast< task::XInteractionDisapprove
* >( this ) );
549 return aRet
.hasValue()
550 ? aRet
: InteractionContinuation::queryInterface( rType
);
555 // XTypeProvider methods.
560 uno::Sequence
< sal_Int8
> SAL_CALL
InteractionDisapprove::getImplementationId()
561 throw( uno::RuntimeException
, std::exception
)
563 return css::uno::Sequence
<sal_Int8
>();
568 uno::Sequence
< uno::Type
> SAL_CALL
InteractionDisapprove::getTypes()
569 throw( uno::RuntimeException
, std::exception
)
571 static cppu::OTypeCollection
* pCollection
= 0;
574 osl::Guard
< osl::Mutex
> aGuard( osl::Mutex::getGlobalMutex() );
577 static cppu::OTypeCollection
collection(
578 cppu::UnoType
<lang::XTypeProvider
>::get(),
579 cppu::UnoType
<task::XInteractionDisapprove
>::get() );
580 pCollection
= &collection
;
583 return (*pCollection
).getTypes();
588 // XInteractionContinuation methods.
593 void SAL_CALL
InteractionDisapprove::select()
594 throw( uno::RuntimeException
, std::exception
)
602 // InteractionSupplyAuthentication Implementation.
609 // XInterface methods.
614 void SAL_CALL
InteractionSupplyAuthentication::acquire()
617 OWeakObject::acquire();
622 void SAL_CALL
InteractionSupplyAuthentication::release()
625 OWeakObject::release();
631 InteractionSupplyAuthentication::queryInterface( const uno::Type
& rType
)
632 throw ( uno::RuntimeException
, std::exception
)
634 uno::Any aRet
= cppu::queryInterface( rType
,
635 static_cast< lang::XTypeProvider
* >( this ),
636 static_cast< task::XInteractionContinuation
* >( this ),
637 static_cast< ucb::XInteractionSupplyAuthentication
* >( this ),
638 static_cast< ucb::XInteractionSupplyAuthentication2
* >( this ));
640 return aRet
.hasValue()
641 ? aRet
: InteractionContinuation::queryInterface( rType
);
646 // XTypeProvider methods.
651 uno::Sequence
< sal_Int8
> SAL_CALL
652 InteractionSupplyAuthentication::getImplementationId()
653 throw( uno::RuntimeException
, std::exception
)
655 return css::uno::Sequence
<sal_Int8
>();
660 uno::Sequence
< uno::Type
> SAL_CALL
InteractionSupplyAuthentication::getTypes()
661 throw( uno::RuntimeException
, std::exception
)
663 static cppu::OTypeCollection
* pCollection
= 0;
666 osl::Guard
< osl::Mutex
> aGuard( osl::Mutex::getGlobalMutex() );
669 static cppu::OTypeCollection
collection(
670 cppu::UnoType
<lang::XTypeProvider
>::get(),
671 cppu::UnoType
<ucb::XInteractionSupplyAuthentication2
>::get() );
672 pCollection
= &collection
;
675 return (*pCollection
).getTypes();
680 // XInteractionContinuation methods.
685 void SAL_CALL
InteractionSupplyAuthentication::select()
686 throw( uno::RuntimeException
, std::exception
)
693 // XInteractionSupplyAuthentication methods.
699 InteractionSupplyAuthentication::canSetRealm()
700 throw( uno::RuntimeException
, std::exception
)
702 return m_bCanSetRealm
;
708 InteractionSupplyAuthentication::setRealm( const OUString
& Realm
)
709 throw( uno::RuntimeException
, std::exception
)
711 OSL_ENSURE( m_bCanSetPassword
,
712 "InteractionSupplyAuthentication::setRealm - Not supported!" );
714 if ( m_bCanSetRealm
)
721 InteractionSupplyAuthentication::canSetUserName()
722 throw( uno::RuntimeException
, std::exception
)
724 return m_bCanSetUserName
;
730 InteractionSupplyAuthentication::setUserName( const OUString
& UserName
)
731 throw( uno::RuntimeException
, std::exception
)
733 OSL_ENSURE( m_bCanSetUserName
,
734 "InteractionSupplyAuthentication::setUserName - Not supported!" );
736 if ( m_bCanSetUserName
)
737 m_aUserName
= UserName
;
743 InteractionSupplyAuthentication::canSetPassword()
744 throw( uno::RuntimeException
, std::exception
)
746 return m_bCanSetPassword
;
752 InteractionSupplyAuthentication::setPassword( const OUString
& Password
)
753 throw( uno::RuntimeException
, std::exception
)
755 OSL_ENSURE( m_bCanSetPassword
,
756 "InteractionSupplyAuthentication::setPassword - Not supported!" );
758 if ( m_bCanSetPassword
)
759 m_aPassword
= Password
;
764 uno::Sequence
< ucb::RememberAuthentication
> SAL_CALL
765 InteractionSupplyAuthentication::getRememberPasswordModes(
766 ucb::RememberAuthentication
& Default
)
767 throw( uno::RuntimeException
, std::exception
)
769 Default
= m_eDefaultRememberPasswordMode
;
770 return m_aRememberPasswordModes
;
776 InteractionSupplyAuthentication::setRememberPassword(
777 ucb::RememberAuthentication Remember
)
778 throw( uno::RuntimeException
, std::exception
)
780 m_eRememberPasswordMode
= Remember
;
786 InteractionSupplyAuthentication::canSetAccount()
787 throw( uno::RuntimeException
, std::exception
)
789 return m_bCanSetAccount
;
795 InteractionSupplyAuthentication::setAccount( const OUString
& Account
)
796 throw( uno::RuntimeException
, std::exception
)
798 OSL_ENSURE( m_bCanSetAccount
,
799 "InteractionSupplyAuthentication::setAccount - Not supported!" );
801 if ( m_bCanSetAccount
)
802 m_aAccount
= Account
;
807 uno::Sequence
< ucb::RememberAuthentication
> SAL_CALL
808 InteractionSupplyAuthentication::getRememberAccountModes(
809 ucb::RememberAuthentication
& Default
)
810 throw( uno::RuntimeException
, std::exception
)
812 Default
= m_eDefaultRememberAccountMode
;
813 return m_aRememberAccountModes
;
818 void SAL_CALL
InteractionSupplyAuthentication::setRememberAccount(
819 ucb::RememberAuthentication Remember
)
820 throw( uno::RuntimeException
, std::exception
)
822 m_eRememberAccountMode
= Remember
;
827 // XInteractionSupplyAuthentication2 methods.
833 InteractionSupplyAuthentication::canUseSystemCredentials(
835 throw ( uno::RuntimeException
, std::exception
)
837 Default
= m_bDefaultUseSystemCredentials
;
838 return m_bCanUseSystemCredentials
;
843 void SAL_CALL
InteractionSupplyAuthentication::setUseSystemCredentials(
844 sal_Bool UseSystemCredentials
)
845 throw ( uno::RuntimeException
, std::exception
)
847 if ( m_bCanUseSystemCredentials
)
848 m_bUseSystemCredentials
= UseSystemCredentials
;
855 // InteractionReplaceExistingData Implementation.
862 // XInterface methods.
867 void SAL_CALL
InteractionReplaceExistingData::acquire()
870 OWeakObject::acquire();
875 void SAL_CALL
InteractionReplaceExistingData::release()
878 OWeakObject::release();
884 InteractionReplaceExistingData::queryInterface( const uno::Type
& rType
)
885 throw ( uno::RuntimeException
, std::exception
)
887 uno::Any aRet
= cppu::queryInterface( rType
,
888 static_cast< lang::XTypeProvider
* >( this ),
889 static_cast< task::XInteractionContinuation
* >( this ),
890 static_cast< ucb::XInteractionReplaceExistingData
* >( this ) );
892 return aRet
.hasValue()
893 ? aRet
: InteractionContinuation::queryInterface( rType
);
898 // XTypeProvider methods.
903 uno::Sequence
< sal_Int8
> SAL_CALL
904 InteractionReplaceExistingData::getImplementationId()
905 throw( uno::RuntimeException
, std::exception
)
907 return css::uno::Sequence
<sal_Int8
>();
912 uno::Sequence
< uno::Type
> SAL_CALL
InteractionReplaceExistingData::getTypes()
913 throw( uno::RuntimeException
, std::exception
)
915 static cppu::OTypeCollection
* pCollection
= 0;
918 osl::Guard
< osl::Mutex
> aGuard( osl::Mutex::getGlobalMutex() );
921 static cppu::OTypeCollection
collection(
922 cppu::UnoType
<lang::XTypeProvider
>::get(),
923 cppu::UnoType
<ucb::XInteractionReplaceExistingData
>::get() );
924 pCollection
= &collection
;
927 return (*pCollection
).getTypes();
932 // XInteractionContinuation methods.
937 void SAL_CALL
InteractionReplaceExistingData::select()
938 throw( uno::RuntimeException
, std::exception
)
943 // InteractionAuthFallback Implementation
945 // XInterface methods.
948 void SAL_CALL
InteractionAuthFallback::acquire()
951 OWeakObject::acquire();
955 void SAL_CALL
InteractionAuthFallback::release()
958 OWeakObject::release();
963 InteractionAuthFallback::queryInterface( const uno::Type
& rType
)
964 throw ( uno::RuntimeException
, std::exception
)
966 uno::Any aRet
= cppu::queryInterface( rType
,
967 static_cast< task::XInteractionContinuation
* >( this ),
968 static_cast< ucb::XInteractionAuthFallback
* >( this ));
970 return aRet
.hasValue()
971 ? aRet
: InteractionContinuation::queryInterface( rType
);
974 // XInteractionContinuation methods.
977 void SAL_CALL
InteractionAuthFallback::select()
978 throw( uno::RuntimeException
, std::exception
)
983 // XInteractionAuthFallback methods
986 void SAL_CALL
InteractionAuthFallback::setCode( const OUString
& code
)
987 throw ( uno::RuntimeException
, std::exception
)
993 OUString SAL_CALL
InteractionAuthFallback::getCode( )
994 throw ( uno::RuntimeException
, std::exception
)
999 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */