LCOV - code coverage report
Current view: top level - ucb/source/ucp/tdoc - tdoc_passwordrequest.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 47 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 12 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.11