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 /**************************************************************************
22                                 TODO
23  **************************************************************************
24 
25  *************************************************************************/
26 #include <ucbhelper/interactionrequest.hxx>
27 
28 #include <rtl/ref.hxx>
29 #include <osl/diagnose.h>
30 #include <cppuhelper/typeprovider.hxx>
31 #include <cppuhelper/queryinterface.hxx>
32 
33 using namespace com::sun::star;
34 using namespace ucbhelper;
35 
36 
37 // InteractionRequest Implementation.
38 
39 
40 namespace ucbhelper
41 {
42 
43 struct InteractionRequest_Impl
44 {
45     rtl::Reference< InteractionContinuation > m_xSelection;
46     css::uno::Any m_aRequest;
47     css::uno::Sequence<
48         css::uno::Reference<
49             css::task::XInteractionContinuation > > m_aContinuations;
50 
InteractionRequest_Implucbhelper::InteractionRequest_Impl51     InteractionRequest_Impl() {}
InteractionRequest_Implucbhelper::InteractionRequest_Impl52     explicit InteractionRequest_Impl( const uno::Any & rRequest )
53     : m_aRequest( rRequest ) {}
54 };
55 
56 }
57 
58 
InteractionRequest()59 InteractionRequest::InteractionRequest()
60 : m_pImpl( new InteractionRequest_Impl )
61 {
62 }
63 
64 
InteractionRequest(const uno::Any & rRequest)65 InteractionRequest::InteractionRequest( const uno::Any & rRequest )
66 : m_pImpl( new InteractionRequest_Impl( rRequest ) )
67 {
68 }
69 
70 
71 // virtual
~InteractionRequest()72 InteractionRequest::~InteractionRequest()
73 {
74 }
75 
76 
setRequest(const uno::Any & rRequest)77 void InteractionRequest::setRequest( const uno::Any & rRequest )
78 {
79     m_pImpl->m_aRequest = rRequest;
80 }
81 
82 
setContinuations(const uno::Sequence<uno::Reference<task::XInteractionContinuation>> & rContinuations)83 void InteractionRequest::setContinuations(
84                 const uno::Sequence< uno::Reference<
85                     task::XInteractionContinuation > > & rContinuations )
86 {
87     m_pImpl->m_aContinuations = rContinuations;
88 }
89 
90 
91 rtl::Reference< InteractionContinuation > const &
getSelection() const92 InteractionRequest::getSelection() const
93 {
94     return m_pImpl->m_xSelection;
95 }
96 
97 
setSelection(const rtl::Reference<InteractionContinuation> & rxSelection)98 void InteractionRequest::setSelection(
99                 const rtl::Reference< InteractionContinuation > & rxSelection )
100 {
101     m_pImpl->m_xSelection = rxSelection;
102 }
103 
104 
105 // XInterface methods.
106 
107 
108 // XInteractionRequest methods.
109 
110 
111 // virtual
getRequest()112 uno::Any SAL_CALL InteractionRequest::getRequest()
113 {
114     return m_pImpl->m_aRequest;
115 }
116 
117 
118 // virtual
119 uno::Sequence< uno::Reference< task::XInteractionContinuation > > SAL_CALL
getContinuations()120 InteractionRequest::getContinuations()
121 {
122     return m_pImpl->m_aContinuations;
123 }
124 
125 
126 // InteractionContinuation Implementation.
127 
128 
InteractionContinuation(InteractionRequest * pRequest)129 InteractionContinuation::InteractionContinuation(
130                         InteractionRequest * pRequest )
131 : m_pRequest( pRequest )
132 {
133 }
134 
135 
136 // virtual
~InteractionContinuation()137 InteractionContinuation::~InteractionContinuation()
138 {
139 }
140 
141 
recordSelection()142 void InteractionContinuation::recordSelection()
143 {
144     m_pRequest->setSelection( this );
145 }
146 
147 
148 // InteractionAbort Implementation.
149 
150 
151 // XInterface methods.
152 
153 
154 // virtual
acquire()155 void SAL_CALL InteractionAbort::acquire()
156     throw()
157 {
158     OWeakObject::acquire();
159 }
160 
161 
162 // virtual
release()163 void SAL_CALL InteractionAbort::release()
164     throw()
165 {
166     OWeakObject::release();
167 }
168 
169 
170 // virtual
171 uno::Any SAL_CALL
queryInterface(const uno::Type & rType)172 InteractionAbort::queryInterface( const uno::Type & rType )
173 {
174     uno::Any aRet = cppu::queryInterface( rType,
175                 static_cast< lang::XTypeProvider * >( this ),
176                 static_cast< task::XInteractionContinuation * >( this ),
177                 static_cast< task::XInteractionAbort * >( this ) );
178 
179     return aRet.hasValue()
180             ? aRet : InteractionContinuation::queryInterface( rType );
181 }
182 
183 
184 // XTypeProvider methods.
185 
186 
187 // virtual
getImplementationId()188 uno::Sequence< sal_Int8 > SAL_CALL InteractionAbort::getImplementationId()
189 {
190     return css::uno::Sequence<sal_Int8>();
191 }
192 
193 
194 // virtual
getTypes()195 uno::Sequence< uno::Type > SAL_CALL InteractionAbort::getTypes()
196 {
197     static cppu::OTypeCollection s_aCollection(
198                 cppu::UnoType<lang::XTypeProvider>::get(),
199                 cppu::UnoType<task::XInteractionAbort>::get() );
200 
201     return s_aCollection.getTypes();
202 }
203 
204 
205 // XInteractionContinuation methods.
206 
207 
208 // virtual
select()209 void SAL_CALL InteractionAbort::select()
210 {
211     recordSelection();
212 }
213 
214 
215 // InteractionRetry Implementation.
216 
217 
218 // XInterface methods.
219 
220 
221 // virtual
acquire()222 void SAL_CALL InteractionRetry::acquire()
223     throw()
224 {
225     OWeakObject::acquire();
226 }
227 
228 
229 // virtual
release()230 void SAL_CALL InteractionRetry::release()
231     throw()
232 {
233     OWeakObject::release();
234 }
235 
236 
237 // virtual
238 uno::Any SAL_CALL
queryInterface(const uno::Type & rType)239 InteractionRetry::queryInterface( const uno::Type & rType )
240 {
241     uno::Any aRet = cppu::queryInterface( rType,
242                 static_cast< lang::XTypeProvider * >( this ),
243                 static_cast< task::XInteractionContinuation * >( this ),
244                 static_cast< task::XInteractionRetry * >( this ) );
245 
246     return aRet.hasValue()
247             ? aRet : InteractionContinuation::queryInterface( rType );
248 }
249 
250 
251 // XTypeProvider methods.
252 
253 
254 // virtual
getImplementationId()255 uno::Sequence< sal_Int8 > SAL_CALL InteractionRetry::getImplementationId()
256 {
257     return css::uno::Sequence<sal_Int8>();
258 }
259 
260 
261 // virtual
getTypes()262 uno::Sequence< uno::Type > SAL_CALL InteractionRetry::getTypes()
263 {
264     static cppu::OTypeCollection s_aCollection(
265                 cppu::UnoType<lang::XTypeProvider>::get(),
266                 cppu::UnoType<task::XInteractionRetry>::get() );
267 
268     return s_aCollection.getTypes();
269 }
270 
271 
272 // XInteractionContinuation methods.
273 
274 
275 // virtual
select()276 void SAL_CALL InteractionRetry::select()
277 {
278     recordSelection();
279 }
280 
281 
282 // InteractionApprove Implementation.
283 
284 
285 // XInterface methods.
286 
287 
288 // virtual
acquire()289 void SAL_CALL InteractionApprove::acquire()
290     throw()
291 {
292     OWeakObject::acquire();
293 }
294 
295 
296 // virtual
release()297 void SAL_CALL InteractionApprove::release()
298     throw()
299 {
300     OWeakObject::release();
301 }
302 
303 
304 // virtual
305 uno::Any SAL_CALL
queryInterface(const uno::Type & rType)306 InteractionApprove::queryInterface( const uno::Type & rType )
307 {
308     uno::Any aRet = cppu::queryInterface( rType,
309                 static_cast< lang::XTypeProvider * >( this ),
310                 static_cast< task::XInteractionContinuation * >( this ),
311                 static_cast< task::XInteractionApprove * >( this ) );
312 
313     return aRet.hasValue()
314             ? aRet : InteractionContinuation::queryInterface( rType );
315 }
316 
317 
318 // XTypeProvider methods.
319 
320 
321 // virtual
getImplementationId()322 uno::Sequence< sal_Int8 > SAL_CALL InteractionApprove::getImplementationId()
323 {
324     return css::uno::Sequence<sal_Int8>();
325 }
326 
327 
328 // virtual
getTypes()329 uno::Sequence< uno::Type > SAL_CALL InteractionApprove::getTypes()
330 {
331     static cppu::OTypeCollection s_aCollection(
332                 cppu::UnoType<lang::XTypeProvider>::get(),
333                 cppu::UnoType<task::XInteractionApprove>::get() );
334 
335     return s_aCollection.getTypes();
336 }
337 
338 
339 // XInteractionContinuation methods.
340 
341 
342 // virtual
select()343 void SAL_CALL InteractionApprove::select()
344 {
345     recordSelection();
346 }
347 
348 
349 // InteractionDisapprove Implementation.
350 
351 
352 // XInterface methods.
353 
354 
355 // virtual
acquire()356 void SAL_CALL InteractionDisapprove::acquire()
357     throw()
358 {
359     OWeakObject::acquire();
360 }
361 
362 
363 // virtual
release()364 void SAL_CALL InteractionDisapprove::release()
365     throw()
366 {
367     OWeakObject::release();
368 }
369 
370 
371 // virtual
372 uno::Any SAL_CALL
queryInterface(const uno::Type & rType)373 InteractionDisapprove::queryInterface( const uno::Type & rType )
374 {
375     uno::Any aRet = cppu::queryInterface( rType,
376                 static_cast< lang::XTypeProvider * >( this ),
377                 static_cast< task::XInteractionContinuation * >( this ),
378                 static_cast< task::XInteractionDisapprove * >( this ) );
379 
380     return aRet.hasValue()
381             ? aRet : InteractionContinuation::queryInterface( rType );
382 }
383 
384 
385 // XTypeProvider methods.
386 
387 
388 // virtual
getImplementationId()389 uno::Sequence< sal_Int8 > SAL_CALL InteractionDisapprove::getImplementationId()
390 {
391     return css::uno::Sequence<sal_Int8>();
392 }
393 
394 
395 // virtual
getTypes()396 uno::Sequence< uno::Type > SAL_CALL InteractionDisapprove::getTypes()
397 {
398     static cppu::OTypeCollection s_aCollection(
399                 cppu::UnoType<lang::XTypeProvider>::get(),
400                 cppu::UnoType<task::XInteractionDisapprove>::get() );
401 
402     return s_aCollection.getTypes();
403 }
404 
405 
406 // XInteractionContinuation methods.
407 
408 
409 // virtual
select()410 void SAL_CALL InteractionDisapprove::select()
411 {
412     recordSelection();
413 }
414 
415 
416 // InteractionSupplyAuthentication Implementation.
417 
418 
419 // XInterface methods.
420 
421 
422 // virtual
acquire()423 void SAL_CALL InteractionSupplyAuthentication::acquire()
424     throw()
425 {
426     OWeakObject::acquire();
427 }
428 
429 
430 // virtual
release()431 void SAL_CALL InteractionSupplyAuthentication::release()
432     throw()
433 {
434     OWeakObject::release();
435 }
436 
437 
438 // virtual
439 uno::Any SAL_CALL
queryInterface(const uno::Type & rType)440 InteractionSupplyAuthentication::queryInterface( const uno::Type & rType )
441 {
442     uno::Any aRet = cppu::queryInterface( rType,
443             static_cast< lang::XTypeProvider * >( this ),
444             static_cast< task::XInteractionContinuation * >( this ),
445             static_cast< ucb::XInteractionSupplyAuthentication * >( this ),
446             static_cast< ucb::XInteractionSupplyAuthentication2 * >( this ));
447 
448     return aRet.hasValue()
449             ? aRet : InteractionContinuation::queryInterface( rType );
450 }
451 
452 
453 // XTypeProvider methods.
454 
455 
456 // virtual
457 uno::Sequence< sal_Int8 > SAL_CALL
getImplementationId()458 InteractionSupplyAuthentication::getImplementationId()
459 {
460     return css::uno::Sequence<sal_Int8>();
461 }
462 
463 
464 // virtual
getTypes()465 uno::Sequence< uno::Type > SAL_CALL InteractionSupplyAuthentication::getTypes()
466 {
467     static cppu::OTypeCollection s_aCollection(
468                 cppu::UnoType<lang::XTypeProvider>::get(),
469                 cppu::UnoType<ucb::XInteractionSupplyAuthentication2>::get() );
470 
471     return s_aCollection.getTypes();
472 }
473 
474 
475 // XInteractionContinuation methods.
476 
477 
478 // virtual
select()479 void SAL_CALL InteractionSupplyAuthentication::select()
480 {
481     recordSelection();
482 }
483 
484 
485 // XInteractionSupplyAuthentication methods.
486 
487 
488 // virtual
489 sal_Bool SAL_CALL
canSetRealm()490 InteractionSupplyAuthentication::canSetRealm()
491 {
492     return m_bCanSetRealm;
493 }
494 
495 
496 // virtual
497 void SAL_CALL
setRealm(const OUString & Realm)498 InteractionSupplyAuthentication::setRealm( const OUString& Realm )
499 {
500     OSL_ENSURE( m_bCanSetPassword,
501         "InteractionSupplyAuthentication::setRealm - Not supported!" );
502 
503     if ( m_bCanSetRealm )
504         m_aRealm = Realm;
505 }
506 
507 
508 // virtual
509 sal_Bool SAL_CALL
canSetUserName()510 InteractionSupplyAuthentication::canSetUserName()
511 {
512     return m_bCanSetUserName;
513 }
514 
515 
516 // virtual
517 void SAL_CALL
setUserName(const OUString & UserName)518 InteractionSupplyAuthentication::setUserName( const OUString& UserName )
519 {
520     OSL_ENSURE( m_bCanSetUserName,
521         "InteractionSupplyAuthentication::setUserName - Not supported!" );
522 
523     if ( m_bCanSetUserName )
524         m_aUserName = UserName;
525 }
526 
527 
528 // virtual
529 sal_Bool SAL_CALL
canSetPassword()530 InteractionSupplyAuthentication::canSetPassword()
531 {
532     return m_bCanSetPassword;
533 }
534 
535 
536 // virtual
537 void SAL_CALL
setPassword(const OUString & Password)538 InteractionSupplyAuthentication::setPassword( const OUString& Password )
539 {
540     OSL_ENSURE( m_bCanSetPassword,
541         "InteractionSupplyAuthentication::setPassword - Not supported!" );
542 
543     if ( m_bCanSetPassword )
544         m_aPassword = Password;
545 }
546 
547 
548 // virtual
549 uno::Sequence< ucb::RememberAuthentication > SAL_CALL
getRememberPasswordModes(ucb::RememberAuthentication & Default)550 InteractionSupplyAuthentication::getRememberPasswordModes(
551                                     ucb::RememberAuthentication& Default )
552 {
553     Default = m_eDefaultRememberPasswordMode;
554     return m_aRememberPasswordModes;
555 }
556 
557 
558 // virtual
559 void SAL_CALL
setRememberPassword(ucb::RememberAuthentication Remember)560 InteractionSupplyAuthentication::setRememberPassword(
561                                     ucb::RememberAuthentication Remember )
562 {
563     m_eRememberPasswordMode = Remember;
564 }
565 
566 
567 // virtual
568 sal_Bool SAL_CALL
canSetAccount()569 InteractionSupplyAuthentication::canSetAccount()
570 {
571     return m_bCanSetAccount;
572 }
573 
574 
575 // virtual
576 void SAL_CALL
setAccount(const OUString &)577 InteractionSupplyAuthentication::setAccount( const OUString& /*Account*/ )
578 {
579     OSL_ENSURE( m_bCanSetAccount,
580         "InteractionSupplyAuthentication::setAccount - Not supported!" );
581 }
582 
583 
584 // virtual
585 uno::Sequence< ucb::RememberAuthentication > SAL_CALL
getRememberAccountModes(ucb::RememberAuthentication & Default)586 InteractionSupplyAuthentication::getRememberAccountModes(
587                                     ucb::RememberAuthentication& Default )
588 {
589     Default = m_eDefaultRememberAccountMode;
590     return m_aRememberAccountModes;
591 }
592 
593 
594 // virtual
setRememberAccount(ucb::RememberAuthentication)595 void SAL_CALL InteractionSupplyAuthentication::setRememberAccount(
596                                     ucb::RememberAuthentication )
597 {
598 }
599 
600 
601 // XInteractionSupplyAuthentication2 methods.
602 
603 
604 // virtual
605 sal_Bool SAL_CALL
canUseSystemCredentials(sal_Bool & Default)606 InteractionSupplyAuthentication::canUseSystemCredentials(
607         sal_Bool& Default )
608 {
609     Default = false;
610     return m_bCanUseSystemCredentials;
611 }
612 
613 
614 // virtual
setUseSystemCredentials(sal_Bool UseSystemCredentials)615 void SAL_CALL InteractionSupplyAuthentication::setUseSystemCredentials(
616         sal_Bool UseSystemCredentials )
617 {
618     if ( m_bCanUseSystemCredentials )
619         m_bUseSystemCredentials = UseSystemCredentials;
620 }
621 
622 
623 // InteractionReplaceExistingData Implementation.
624 
625 
626 // XInterface methods.
627 
628 
629 // virtual
acquire()630 void SAL_CALL InteractionReplaceExistingData::acquire()
631     throw()
632 {
633     OWeakObject::acquire();
634 }
635 
636 
637 // virtual
release()638 void SAL_CALL InteractionReplaceExistingData::release()
639     throw()
640 {
641     OWeakObject::release();
642 }
643 
644 
645 // virtual
646 uno::Any SAL_CALL
queryInterface(const uno::Type & rType)647 InteractionReplaceExistingData::queryInterface( const uno::Type & rType )
648 {
649     uno::Any aRet = cppu::queryInterface( rType,
650                 static_cast< lang::XTypeProvider * >( this ),
651                 static_cast< task::XInteractionContinuation * >( this ),
652                 static_cast< ucb::XInteractionReplaceExistingData * >( this ) );
653 
654     return aRet.hasValue()
655             ? aRet : InteractionContinuation::queryInterface( rType );
656 }
657 
658 
659 // XTypeProvider methods.
660 
661 
662 // virtual
663 uno::Sequence< sal_Int8 > SAL_CALL
getImplementationId()664 InteractionReplaceExistingData::getImplementationId()
665 {
666     return css::uno::Sequence<sal_Int8>();
667 }
668 
669 
670 // virtual
getTypes()671 uno::Sequence< uno::Type > SAL_CALL InteractionReplaceExistingData::getTypes()
672 {
673     static cppu::OTypeCollection s_aCollection(
674                 cppu::UnoType<lang::XTypeProvider>::get(),
675                 cppu::UnoType<ucb::XInteractionReplaceExistingData>::get() );
676 
677     return s_aCollection.getTypes();
678 }
679 
680 
681 // XInteractionContinuation methods.
682 
683 
684 // virtual
select()685 void SAL_CALL InteractionReplaceExistingData::select()
686 {
687     recordSelection();
688 }
689 
690 // InteractionAuthFallback Implementation
691 
692 // XInterface methods.
693 
694 // virtual
acquire()695 void SAL_CALL InteractionAuthFallback::acquire()
696     throw()
697 {
698     OWeakObject::acquire();
699 }
700 
701 // virtual
release()702 void SAL_CALL InteractionAuthFallback::release()
703     throw()
704 {
705     OWeakObject::release();
706 }
707 
708 // virtual
709 uno::Any SAL_CALL
queryInterface(const uno::Type & rType)710 InteractionAuthFallback::queryInterface( const uno::Type & rType )
711 {
712     uno::Any aRet = cppu::queryInterface( rType,
713             static_cast< task::XInteractionContinuation * >( this ),
714             static_cast< ucb::XInteractionAuthFallback * >( this ));
715 
716     return aRet.hasValue()
717             ? aRet : InteractionContinuation::queryInterface( rType );
718 }
719 
720 // XInteractionContinuation methods.
721 
722 // virtual
select()723 void SAL_CALL InteractionAuthFallback::select()
724 {
725     recordSelection();
726 }
727 
728 // XInteractionAuthFallback methods
729 
730 // virtual
setCode(const OUString & code)731 void SAL_CALL InteractionAuthFallback::setCode( const OUString& code )
732 {
733     m_aCode = code;
734 }
735 
getCode() const736 const OUString& InteractionAuthFallback::getCode() const
737 {
738     return m_aCode;
739 }
740 
741 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
742