LCOV - code coverage report
Current view: top level - ucb/source/ucp/tdoc - tdoc_passwordrequest.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 47 0.0 %
Date: 2014-11-03 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/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, std::exception ) SAL_OVERRIDE;
      48             :         virtual void SAL_CALL acquire()
      49             :             throw () SAL_OVERRIDE;
      50             :         virtual void SAL_CALL release()
      51             :             throw () SAL_OVERRIDE;
      52             : 
      53             :         // XTypeProvider
      54             :         virtual uno::Sequence< uno::Type > SAL_CALL getTypes()
      55             :             throw ( uno::RuntimeException, std::exception ) SAL_OVERRIDE;
      56             :         virtual uno::Sequence< sal_Int8 > SAL_CALL getImplementationId()
      57             :             throw ( uno::RuntimeException, std::exception ) SAL_OVERRIDE;
      58             : 
      59             :         // XInteractionContinuation
      60             :         virtual void SAL_CALL select()
      61             :             throw ( uno::RuntimeException, std::exception ) SAL_OVERRIDE;
      62             : 
      63             :         // XInteractionPassword
      64             :         virtual void SAL_CALL setPassword( const OUString & aPasswd )
      65             :             throw ( uno::RuntimeException, std::exception ) SAL_OVERRIDE;
      66             :         virtual OUString SAL_CALL getPassword()
      67             :             throw ( uno::RuntimeException, std::exception ) SAL_OVERRIDE;
      68             : 
      69             :     private:
      70             :         osl::Mutex m_aMutex;
      71             :         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, std::exception )
     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, std::exception )
     129             : {
     130           0 :     return css::uno::Sequence<sal_Int8>();
     131             : }
     132             : 
     133             : 
     134             : // virtual
     135           0 : uno::Sequence< uno::Type > SAL_CALL InteractionSupplyPassword::getTypes()
     136             :     throw( uno::RuntimeException, std::exception )
     137             : {
     138             :     static cppu::OTypeCollection * pCollection = 0;
     139           0 :     if ( !pCollection )
     140             :     {
     141           0 :         osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
     142           0 :         if ( !pCollection )
     143             :         {
     144             :             static cppu::OTypeCollection collection(
     145             :                 getCppuType( static_cast<
     146           0 :                     uno::Reference< lang::XTypeProvider > * >( 0 ) ),
     147             :                 getCppuType( static_cast<
     148           0 :                     uno::Reference< task::XInteractionPassword > * >( 0 ) ) );
     149           0 :             pCollection = &collection;
     150           0 :         }
     151             :     }
     152           0 :     return (*pCollection).getTypes();
     153             : }
     154             : 
     155             : 
     156             : 
     157             : // XInteractionContinuation methods.
     158             : 
     159             : 
     160             : 
     161             : // virtual
     162           0 : void SAL_CALL InteractionSupplyPassword::select()
     163             :     throw( uno::RuntimeException, std::exception )
     164             : {
     165           0 :     recordSelection();
     166           0 : }
     167             : 
     168             : 
     169             : 
     170             : // XInteractionPassword methods.
     171             : 
     172             : 
     173             : 
     174             : // virtual
     175             : void SAL_CALL
     176           0 : InteractionSupplyPassword::setPassword( const OUString& aPasswd )
     177             :     throw ( uno::RuntimeException, std::exception )
     178             : {
     179           0 :     osl::MutexGuard aGuard( m_aMutex );
     180           0 :     m_aPassword = aPasswd;
     181           0 : }
     182             : 
     183             : // virtual
     184           0 : OUString SAL_CALL InteractionSupplyPassword::getPassword()
     185             :     throw ( uno::RuntimeException, std::exception )
     186             : {
     187           0 :     osl::MutexGuard aGuard( m_aMutex );
     188           0 :     return m_aPassword;
     189             : }
     190             : 
     191             : 
     192             : 
     193             : 
     194             : // DocumentPasswordRequest Implementation.
     195             : 
     196             : 
     197             : 
     198             : 
     199           0 : DocumentPasswordRequest::DocumentPasswordRequest(
     200             :     task::PasswordRequestMode eMode,
     201           0 :     const OUString & rDocumentName )
     202             : {
     203             :     // Fill request...
     204           0 :     task::DocumentPasswordRequest aRequest;
     205             : //    aRequest.Message        = // OUString
     206             : //    aRequest.Context        = // XInterface
     207           0 :     aRequest.Classification = task::InteractionClassification_ERROR;
     208           0 :     aRequest.Mode           = eMode;
     209           0 :     aRequest.Name           = rDocumentName;
     210             : 
     211           0 :     setRequest( uno::makeAny( aRequest ) );
     212             : 
     213             :     // Fill continuations...
     214             :     uno::Sequence<
     215           0 :         uno::Reference< task::XInteractionContinuation > > aContinuations( 3 );
     216           0 :     aContinuations[ 0 ] = new ucbhelper::InteractionAbort( this );
     217           0 :     aContinuations[ 1 ] = new ucbhelper::InteractionRetry( this );
     218           0 :     aContinuations[ 2 ] = new InteractionSupplyPassword( this );
     219             : 
     220           0 :     setContinuations( aContinuations );
     221           0 : }
     222             : 
     223             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10