LCOV - code coverage report
Current view: top level - libreoffice/desktop/source/deployment/manager - dp_commandenvironments.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 104 0.0 %
Date: 2012-12-27 Functions: 0 20 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 "com/sun/star/deployment/VersionException.hpp"
      22             : #include "com/sun/star/deployment/LicenseException.hpp"
      23             : #include "com/sun/star/deployment/InstallException.hpp"
      24             : #include "com/sun/star/deployment/DependencyException.hpp"
      25             : #include "com/sun/star/deployment/PlatformException.hpp"
      26             : #include "com/sun/star/task/XInteractionApprove.hpp"
      27             : #include "com/sun/star/task/XInteractionAbort.hpp"
      28             : #include "com/sun/star/task/XInteractionHandler.hpp"
      29             : #include "com/sun/star/ucb/XCommandEnvironment.hpp"
      30             : #include "com/sun/star/uno/XComponentContext.hpp"
      31             : #include "dp_commandenvironments.hxx"
      32             : 
      33             : namespace deployment = com::sun::star::deployment;
      34             : namespace task = com::sun::star::task;
      35             : namespace ucb = com::sun::star::ucb;
      36             : namespace uno = com::sun::star::uno;
      37             : 
      38             : #define OUSTR(s) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s))
      39             : 
      40             : using ::com::sun::star::uno::Reference;
      41             : using ::rtl::OUString;
      42             : 
      43             : namespace dp_manager {
      44             : 
      45           0 : BaseCommandEnv::BaseCommandEnv()
      46             : {
      47           0 : }
      48             : 
      49           0 : BaseCommandEnv::BaseCommandEnv(
      50             :     Reference< task::XInteractionHandler> const & handler)
      51           0 :     : m_forwardHandler(handler)
      52             : {
      53           0 : }
      54             : 
      55           0 : BaseCommandEnv::~BaseCommandEnv()
      56             : {
      57           0 : }
      58             : // XCommandEnvironment
      59             : //______________________________________________________________________________
      60           0 : Reference<task::XInteractionHandler> BaseCommandEnv::getInteractionHandler()
      61             : throw (uno::RuntimeException)
      62             : {
      63           0 :     return this;
      64             : }
      65             : 
      66             : //______________________________________________________________________________
      67           0 : Reference<ucb::XProgressHandler> BaseCommandEnv::getProgressHandler()
      68             : throw (uno::RuntimeException)
      69             : {
      70           0 :     return this;
      71             : }
      72             : 
      73           0 : void BaseCommandEnv::handle(
      74             :     Reference< task::XInteractionRequest> const & /*xRequest*/ )
      75             :     throw (uno::RuntimeException)
      76             : {
      77           0 : }
      78             : 
      79           0 : void BaseCommandEnv::handle_(bool approve, bool abort,
      80             :                              Reference< task::XInteractionRequest> const & xRequest )
      81             : {
      82           0 :     if (approve == false && abort == false)
      83             :     {
      84             :         //not handled so far -> forwarding
      85           0 :         if (m_forwardHandler.is())
      86           0 :             m_forwardHandler->handle(xRequest);
      87             :         else
      88           0 :             return; //cannot handle
      89             :     }
      90             :     else
      91             :     {
      92             :         // select:
      93             :         uno::Sequence< Reference< task::XInteractionContinuation > > conts(
      94           0 :             xRequest->getContinuations() );
      95             :         Reference< task::XInteractionContinuation > const * pConts =
      96           0 :             conts.getConstArray();
      97           0 :         sal_Int32 len = conts.getLength();
      98           0 :         for ( sal_Int32 pos = 0; pos < len; ++pos )
      99             :         {
     100           0 :             if (approve) {
     101             :                 Reference< task::XInteractionApprove > xInteractionApprove(
     102           0 :                     pConts[ pos ], uno::UNO_QUERY );
     103           0 :                 if (xInteractionApprove.is()) {
     104           0 :                     xInteractionApprove->select();
     105             :                     // don't query again for ongoing continuations:
     106           0 :                     approve = false;
     107           0 :                 }
     108             :             }
     109           0 :             else if (abort) {
     110             :                 Reference< task::XInteractionAbort > xInteractionAbort(
     111           0 :                     pConts[ pos ], uno::UNO_QUERY );
     112           0 :                 if (xInteractionAbort.is()) {
     113           0 :                     xInteractionAbort->select();
     114             :                     // don't query again for ongoing continuations:
     115           0 :                     abort = false;
     116           0 :                 }
     117             :             }
     118           0 :         }
     119             :     }
     120             : 
     121             : }
     122             : 
     123             : // XProgressHandler
     124           0 : void BaseCommandEnv::push( uno::Any const & /*Status*/ )
     125             : throw (uno::RuntimeException)
     126             : {
     127           0 : }
     128             : 
     129           0 : void BaseCommandEnv::update( uno::Any const & /*Status */)
     130             : throw (uno::RuntimeException)
     131             : {
     132           0 : }
     133             : 
     134           0 : void BaseCommandEnv::pop() throw (uno::RuntimeException)
     135             : {
     136           0 : }
     137             : //==============================================================================
     138             : 
     139           0 : TmpRepositoryCommandEnv::TmpRepositoryCommandEnv()
     140             : {
     141           0 : }
     142             : 
     143           0 : TmpRepositoryCommandEnv::TmpRepositoryCommandEnv(
     144             :     css::uno::Reference< css::task::XInteractionHandler> const & handler):
     145           0 :     BaseCommandEnv(handler)
     146             : {
     147           0 : }
     148             : // XInteractionHandler
     149           0 : void TmpRepositoryCommandEnv::handle(
     150             :     Reference< task::XInteractionRequest> const & xRequest )
     151             :     throw (uno::RuntimeException)
     152             : {
     153           0 :     uno::Any request( xRequest->getRequest() );
     154             :     OSL_ASSERT( request.getValueTypeClass() == uno::TypeClass_EXCEPTION );
     155             : 
     156           0 :     deployment::VersionException verExc;
     157           0 :     deployment::LicenseException licExc;
     158           0 :     deployment::InstallException instExc;
     159             : 
     160           0 :     bool approve = false;
     161           0 :     bool abort = false;
     162             : 
     163           0 :     if ((request >>= verExc)
     164           0 :         || (request >>= licExc)
     165           0 :         || (request >>= instExc))
     166             :     {
     167           0 :         approve = true;
     168             :     }
     169             : 
     170           0 :     handle_(approve, abort, xRequest);
     171           0 : }
     172             : //================================================================================
     173             : 
     174           0 : LicenseCommandEnv::LicenseCommandEnv(
     175             :     css::uno::Reference< css::task::XInteractionHandler> const & handler,
     176             :     bool bSuppressLicense,
     177             :     OUString const & repository):
     178             :     BaseCommandEnv(handler), m_repository(repository),
     179           0 :     m_bSuppressLicense(bSuppressLicense)
     180             : {
     181           0 : }
     182             : // XInteractionHandler
     183           0 : void LicenseCommandEnv::handle(
     184             :     Reference< task::XInteractionRequest> const & xRequest )
     185             :     throw (uno::RuntimeException)
     186             : {
     187           0 :     uno::Any request( xRequest->getRequest() );
     188             :     OSL_ASSERT( request.getValueTypeClass() == uno::TypeClass_EXCEPTION );
     189             : 
     190           0 :     deployment::LicenseException licExc;
     191             : 
     192           0 :     bool approve = false;
     193           0 :     bool abort = false;
     194             : 
     195           0 :     if (request >>= licExc)
     196             :     {
     197           0 :         if (m_bSuppressLicense
     198           0 :             || m_repository.equals(OUSTR("bundled"))
     199           0 :             || licExc.AcceptBy.equals(OUSTR("admin")))
     200             :         {
     201             :             //always approve in bundled case, because we do not support
     202             :             //showing licenses anyway.
     203             :             //The "admin" already accepted the license when installing the
     204             :             // shared extension
     205           0 :             approve = true;
     206             :         }
     207             :     }
     208             : 
     209           0 :     handle_(approve, abort, xRequest);
     210           0 : }
     211             : 
     212             : //================================================================================
     213             : 
     214           0 : NoLicenseCommandEnv::NoLicenseCommandEnv(
     215             :     css::uno::Reference< css::task::XInteractionHandler> const & handler):
     216           0 :     BaseCommandEnv(handler)
     217             : {
     218           0 : }
     219             : // XInteractionHandler
     220           0 : void NoLicenseCommandEnv::handle(
     221             :     Reference< task::XInteractionRequest> const & xRequest )
     222             :     throw (uno::RuntimeException)
     223             : {
     224           0 :     uno::Any request( xRequest->getRequest() );
     225             :     OSL_ASSERT( request.getValueTypeClass() == uno::TypeClass_EXCEPTION );
     226             : 
     227           0 :     deployment::LicenseException licExc;
     228             : 
     229           0 :     bool approve = false;
     230           0 :     bool abort = false;
     231             : 
     232           0 :     if (request >>= licExc)
     233             :     {
     234           0 :         approve = true;
     235             :     }
     236           0 :     handle_(approve, abort, xRequest);
     237           0 : }
     238             : 
     239           0 : SilentCheckPrerequisitesCommandEnv::SilentCheckPrerequisitesCommandEnv()
     240             : {
     241           0 : }
     242             : 
     243           0 : void SilentCheckPrerequisitesCommandEnv::handle(
     244             :        Reference< task::XInteractionRequest> const & xRequest )
     245             :     throw (uno::RuntimeException)
     246             : {
     247           0 :     uno::Any request( xRequest->getRequest() );
     248             :     OSL_ASSERT( request.getValueTypeClass() == uno::TypeClass_EXCEPTION );
     249             : 
     250           0 :     deployment::LicenseException licExc;
     251           0 :     deployment::PlatformException platformExc;
     252           0 :     deployment::DependencyException depExc;
     253           0 :     bool approve = false;
     254           0 :     bool abort = false;
     255             : 
     256           0 :     if (request >>= licExc)
     257             :     {
     258           0 :         approve = true;
     259           0 :         handle_(approve, abort, xRequest);
     260             :     }
     261           0 :     else if ((request >>= platformExc)
     262           0 :              || (request >>= depExc))
     263             :     {
     264           0 :         m_Exception = request;
     265             :     }
     266             :     else
     267             :     {
     268           0 :         m_UnknownException = request;
     269           0 :     }
     270           0 : }
     271             : 
     272             : }
     273             : 
     274             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10