LCOV - code coverage report
Current view: top level - desktop/source/pkgchk/unopkg - unopkg_app.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 243 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 11 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 "desktopdllapi.h"
      22             : #include "dp_misc.h"
      23             : #include "unopkg_main.h"
      24             : #include "unopkg_shared.h"
      25             : #include "dp_identifier.hxx"
      26             : #include <tools/extendapplicationenvironment.hxx>
      27             : #include <rtl/ustrbuf.hxx>
      28             : #include <rtl/uri.hxx>
      29             : #include <rtl/bootstrap.hxx>
      30             : #include <osl/thread.h>
      31             : #include <osl/process.h>
      32             : #include <osl/conditn.hxx>
      33             : #include <osl/file.hxx>
      34             : #include <cppuhelper/implbase1.hxx>
      35             : #include <cppuhelper/exc_hlp.hxx>
      36             : #include <comphelper/anytostring.hxx>
      37             : #include <comphelper/sequence.hxx>
      38             : #include <com/sun/star/deployment/ExtensionManager.hpp>
      39             : 
      40             : #include <com/sun/star/deployment/ui/PackageManagerDialog.hpp>
      41             : #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
      42             : #include <boost/scoped_array.hpp>
      43             : #include <com/sun/star/ui/dialogs/XDialogClosedListener.hpp>
      44             : #include <com/sun/star/bridge/BridgeFactory.hpp>
      45             : #include <stdio.h>
      46             : #include <vector>
      47             : 
      48             : 
      49             : using namespace ::com::sun::star;
      50             : using namespace ::com::sun::star::uno;
      51             : using namespace ::unopkg;
      52             : namespace {
      53             : 
      54           0 : struct ExtensionName
      55             : {
      56             :     OUString m_str;
      57           0 :     ExtensionName( OUString const & str ) : m_str( str ) {}
      58           0 :     bool operator () ( Reference<deployment::XPackage> const & e ) const
      59             :     {
      60           0 :         if (m_str.equals(dp_misc::getIdentifier(e))
      61           0 :              ||  m_str.equals(e->getName()))
      62           0 :             return true;
      63           0 :         return false;
      64             :     }
      65             : };
      66             : 
      67             : 
      68             : const char s_usingText [] =
      69             : "\n"
      70             : "using: " APP_NAME " add <options> extension-path...\n"
      71             : "       " APP_NAME " validate <options> extension-identifier...\n"
      72             : "       " APP_NAME " remove <options> extension-identifier...\n"
      73             : "       " APP_NAME " list <options> extension-identifier...\n"
      74             : "       " APP_NAME " reinstall <options>\n"
      75             : "       " APP_NAME " gui\n"
      76             : "       " APP_NAME " -V\n"
      77             : "       " APP_NAME " -h\n"
      78             : "\n"
      79             : "sub-commands:\n"
      80             : " add                     add extension\n"
      81             : " validate                checks the prerequisites of an installed extension and"
      82             : "                         registers it if possible\n"
      83             : " remove                  remove extensions by identifier\n"
      84             : " reinstall               expert feature: reinstall all deployed extensions\n"
      85             : " list                    list information about deployed extensions\n"
      86             : " gui                     raise Extension Manager Graphical User Interface (GUI)\n"
      87             : "\n"
      88             : "options:\n"
      89             : " -h, --help              this help\n"
      90             : " -V, --version           version information\n"
      91             : " -v, --verbose           verbose output to stdout\n"
      92             : " -f, --force             force overwriting existing extensions\n"
      93             : " -s, --suppress-license  prevents showing the license\n"
      94             : " --log-file <file>       custom log file; default: <cache-dir>/log.txt\n"
      95             : " --shared                expert feature: operate on shared installation\n"
      96             : "                                         deployment context;\n"
      97             : "                                         run only when no concurrent Office\n"
      98             : "                                         process(es) are running!\n"
      99             : " --bundled               expert feature: operate on bundled extensions. Only\n"
     100             : "                                         works with list, validate, reinstall;\n"
     101             : " --deployment-context    expert feature: explicit deployment context\n"
     102             : "     <context>\n"
     103             : "\n"
     104             : "To learn more about the Extension Manager and extensions, see:\n"
     105             : "http://wiki.openoffice.org/wiki/Documentation/DevGuide/Extensions/Extensions\n\n";
     106             : 
     107             : 
     108             : const OptionInfo s_option_infos [] = {
     109             :     { RTL_CONSTASCII_STRINGPARAM("help"), 'h', false },
     110             :     { RTL_CONSTASCII_STRINGPARAM("version"), 'V', false },
     111             :     { RTL_CONSTASCII_STRINGPARAM("verbose"), 'v', false },
     112             :     { RTL_CONSTASCII_STRINGPARAM("force"), 'f', false },
     113             :     { RTL_CONSTASCII_STRINGPARAM("log-file"), '\0', true },
     114             :     { RTL_CONSTASCII_STRINGPARAM("shared"), '\0', false },
     115             :     { RTL_CONSTASCII_STRINGPARAM("deployment-context"), '\0', true },
     116             :     { RTL_CONSTASCII_STRINGPARAM("bundled"), '\0', false},
     117             :     { RTL_CONSTASCII_STRINGPARAM("suppress-license"), 's', false},
     118             : 
     119             :     { 0, 0, '\0', false }
     120             : };
     121             : 
     122           0 : class DialogClosedListenerImpl :
     123             :     public ::cppu::WeakImplHelper1< ui::dialogs::XDialogClosedListener >
     124             : {
     125             :     osl::Condition & m_rDialogClosedCondition;
     126             : 
     127             : public:
     128           0 :     DialogClosedListenerImpl( osl::Condition & rDialogClosedCondition )
     129           0 :         : m_rDialogClosedCondition( rDialogClosedCondition ) {}
     130             : 
     131             :     // XEventListener (base of XDialogClosedListener)
     132             :     virtual void SAL_CALL disposing( lang::EventObject const & Source )
     133             :         throw (RuntimeException, std::exception) SAL_OVERRIDE;
     134             : 
     135             :     // XDialogClosedListener
     136             :     virtual void SAL_CALL dialogClosed(
     137             :         ui::dialogs::DialogClosedEvent const & aEvent )
     138             :         throw (RuntimeException, std::exception) SAL_OVERRIDE;
     139             : };
     140             : 
     141             : // XEventListener (base of XDialogClosedListener)
     142           0 : void DialogClosedListenerImpl::disposing( lang::EventObject const & )
     143             :     throw (RuntimeException, std::exception)
     144             : {
     145             :     // nothing to do
     146           0 : }
     147             : 
     148             : // XDialogClosedListener
     149           0 : void DialogClosedListenerImpl::dialogClosed(
     150             :     ui::dialogs::DialogClosedEvent const & )
     151             :     throw (RuntimeException, std::exception)
     152             : {
     153           0 :     m_rDialogClosedCondition.set();
     154           0 : }
     155             : 
     156             : // If a package had been installed with a pre OOo 2.2, it could not normally be
     157             : // found via its identifier; similarly (and for ease of use), a package
     158             : // installed with OOo 2.2 or later could not normally be found via its file
     159             : // name.
     160           0 : Reference<deployment::XPackage> findPackage(
     161             :     OUString const & repository,
     162             :     Reference<deployment::XExtensionManager> const & manager,
     163             :     Reference<ucb::XCommandEnvironment > const & environment,
     164             :     OUString const & idOrFileName )
     165             : {
     166             :     Sequence< Reference<deployment::XPackage> > ps(
     167           0 :         manager->getDeployedExtensions(repository,
     168           0 :             Reference<task::XAbortChannel>(), environment ) );
     169           0 :     for ( sal_Int32 i = 0; i < ps.getLength(); ++i )
     170           0 :         if ( dp_misc::getIdentifier( ps[i] ) == idOrFileName )
     171           0 :             return ps[i];
     172           0 :     for ( sal_Int32 i = 0; i < ps.getLength(); ++i )
     173           0 :         if ( ps[i]->getName() == idOrFileName )
     174           0 :             return ps[i];
     175           0 :     return Reference<deployment::XPackage>();
     176             : }
     177             : 
     178             : } // anon namespace
     179             : 
     180           0 : extern "C" int unopkg_main()
     181             : {
     182           0 :     tools::extendApplicationEnvironment();
     183           0 :     bool bNoOtherErrorMsg = false;
     184           0 :     OUString subCommand;
     185           0 :     bool option_shared = false;
     186           0 :     bool option_force = false;
     187           0 :     bool option_verbose = false;
     188           0 :     bool option_bundled = false;
     189           0 :     bool option_suppressLicense = false;
     190           0 :     bool subcmd_gui = false;
     191           0 :     OUString logFile;
     192           0 :     OUString repository;
     193           0 :     OUString cmdArg;
     194           0 :     ::std::vector<OUString> cmdPackages;
     195             : 
     196             :     OptionInfo const * info_shared = getOptionInfo(
     197           0 :         s_option_infos, "shared" );
     198             :     OptionInfo const * info_force = getOptionInfo(
     199           0 :         s_option_infos, "force" );
     200             :     OptionInfo const * info_verbose = getOptionInfo(
     201           0 :         s_option_infos, "verbose" );
     202             :     OptionInfo const * info_log = getOptionInfo(
     203           0 :         s_option_infos, "log-file" );
     204             :     OptionInfo const * info_context = getOptionInfo(
     205           0 :         s_option_infos, "deployment-context" );
     206             :     OptionInfo const * info_help = getOptionInfo(
     207           0 :         s_option_infos, "help" );
     208             :     OptionInfo const * info_version = getOptionInfo(
     209           0 :         s_option_infos, "version" );
     210             :     OptionInfo const * info_bundled = getOptionInfo(
     211           0 :         s_option_infos, "bundled" );
     212             :     OptionInfo const * info_suppressLicense = getOptionInfo(
     213           0 :         s_option_infos, "suppress-license" );
     214             : 
     215             : 
     216           0 :     Reference<XComponentContext> xComponentContext;
     217           0 :     Reference<XComponentContext> xLocalComponentContext;
     218             : 
     219             :     try {
     220           0 :         sal_uInt32 nPos = 0;
     221           0 :         sal_uInt32 nCount = osl_getCommandArgCount();
     222           0 :         if (nCount == 0 || isOption( info_help, &nPos ))
     223             :         {
     224           0 :             dp_misc::writeConsole(s_usingText);
     225           0 :             return 0;
     226             :         }
     227           0 :         else if (isOption( info_version, &nPos )) {
     228           0 :             dp_misc::writeConsole("\n" APP_NAME " Version 3.3\n");
     229           0 :             return 0;
     230             :         }
     231             :         //consume all bootstrap variables which may occur before the subcommannd
     232           0 :         while(isBootstrapVariable(&nPos))
     233             :             ;
     234             : 
     235           0 :         if(nPos >= nCount)
     236           0 :             return 0;
     237             :         //get the sub command
     238           0 :         osl_getCommandArg( nPos, &subCommand.pData );
     239           0 :         ++nPos;
     240           0 :         subCommand = subCommand.trim();
     241           0 :         bool subcmd_add = subCommand == "add";
     242           0 :         subcmd_gui = subCommand == "gui";
     243             : 
     244             :         // sun-command options and packages:
     245           0 :         while (nPos < nCount)
     246             :         {
     247           0 :             if (readArgument( &cmdArg, info_log, &nPos )) {
     248           0 :                 logFile = makeAbsoluteFileUrl(
     249           0 :                     cmdArg.trim(), getProcessWorkingDir() );
     250             :             }
     251           0 :             else if (!readOption( &option_verbose, info_verbose, &nPos ) &&
     252           0 :                      !readOption( &option_shared, info_shared, &nPos ) &&
     253           0 :                      !readOption( &option_force, info_force, &nPos ) &&
     254           0 :                      !readOption( &option_bundled, info_bundled, &nPos ) &&
     255           0 :                      !readOption( &option_suppressLicense, info_suppressLicense, &nPos ) &&
     256           0 :                      !readArgument( &repository, info_context, &nPos ) &&
     257           0 :                      !isBootstrapVariable(&nPos))
     258             :             {
     259           0 :                 osl_getCommandArg( nPos, &cmdArg.pData );
     260           0 :                 ++nPos;
     261           0 :                 cmdArg = cmdArg.trim();
     262           0 :                 if (!cmdArg.isEmpty())
     263             :                 {
     264           0 :                     if (cmdArg[ 0 ] == '-')
     265             :                     {
     266             :                         // is option:
     267             :                         dp_misc::writeConsoleError(
     268           0 :                                  "\nERROR: unexpected option " +
     269           0 :                                  cmdArg +
     270           0 :                                  "!\n       Use " APP_NAME " " +
     271           0 :                                  toString(info_help) +
     272           0 :                                  " to print all options.\n");
     273           0 :                         return 1;
     274             :                     }
     275             :                     else
     276             :                     {
     277             :                         // is package:
     278             :                         cmdPackages.push_back(
     279           0 :                             subcmd_add || subcmd_gui
     280             :                             ? makeAbsoluteFileUrl(
     281           0 :                                 cmdArg, getProcessWorkingDir() )
     282           0 :                             : cmdArg );
     283             :                     }
     284             :                 }
     285             :             }
     286             :         }
     287             : 
     288           0 :         if (repository.isEmpty())
     289             :         {
     290           0 :             if (option_shared)
     291           0 :                 repository = "shared";
     292           0 :             else if (option_bundled)
     293           0 :                 repository = "bundled";
     294             :             else
     295           0 :                 repository = "user";
     296             :         }
     297             :         else
     298             :         {
     299           0 :             if ( repository == "shared" ) {
     300           0 :                 option_shared = true;
     301             :             }
     302           0 :             else if (option_shared) {
     303             :                 dp_misc::writeConsoleError(
     304           0 :                     "WARNING: explicit context given!  Ignoring option " +
     305           0 :                     toString( info_shared ) + "!\n" );
     306             :             }
     307             :         }
     308             : 
     309           0 :         if (subCommand == "reinstall")
     310             :         {
     311             :             //We must prevent that services and types are loaded by UNO,
     312             :             //otherwise we cannot delete the registry data folder.
     313           0 :             OUString extensionUnorc;
     314           0 :             if (repository == "user")
     315           0 :                 extensionUnorc = "$UNO_USER_PACKAGES_CACHE/registry/com.sun.star.comp.deployment.component.PackageRegistryBackend/unorc";
     316           0 :             else if (repository == "shared")
     317           0 :                 extensionUnorc = "$SHARED_EXTENSIONS_USER/registry/com.sun.star.comp.deployment.component.PackageRegistryBackend/unorc";
     318           0 :             else if (repository == "bundled")
     319           0 :                 extensionUnorc = "$BUNDLED_EXTENSIONS_USER/registry/com.sun.star.comp.deployment.component.PackageRegistryBackend/unorc";
     320             :             else
     321             :                 OSL_ASSERT(false);
     322             : 
     323           0 :             ::rtl::Bootstrap::expandMacros(extensionUnorc);
     324           0 :             oslFileError e = osl_removeFile(extensionUnorc.pData);
     325           0 :             if (e != osl_File_E_None && e != osl_File_E_NOENT)
     326           0 :                 throw Exception("Could not delete " + extensionUnorc, 0);
     327             :         }
     328             : 
     329           0 :         xComponentContext = getUNO(
     330           0 :             option_verbose, option_shared, subcmd_gui, xLocalComponentContext );
     331             : 
     332             :         Reference<deployment::XExtensionManager> xExtensionManager(
     333           0 :             deployment::ExtensionManager::get( xComponentContext ) );
     334             : 
     335             :         Reference< ::com::sun::star::ucb::XCommandEnvironment > xCmdEnv(
     336             :             createCmdEnv( xComponentContext, logFile,
     337           0 :                           option_force, option_verbose, option_suppressLicense) );
     338             : 
     339             :         //synchronize bundled/shared extensions
     340             :         //Do not synchronize when command is "reinstall". This could add types and services to UNO and
     341             :         //prevent the deletion of the registry data folder
     342             :         //synching is done in XExtensionManager.reinstall
     343           0 :         if (!subcmd_gui && ! (subCommand == "reinstall")
     344           0 :             && ! dp_misc::office_is_running())
     345           0 :             dp_misc::syncRepositories(false, xCmdEnv);
     346             : 
     347           0 :         if ( subcmd_add || subCommand == "remove" )
     348             :         {
     349           0 :             for ( ::std::size_t pos = 0; pos < cmdPackages.size(); ++pos )
     350             :             {
     351           0 :                 OUString const & cmdPackage = cmdPackages[ pos ];
     352           0 :                 if (subcmd_add)
     353             :                 {
     354             :                     beans::NamedValue nvSuppress(
     355             :                         OUString("SUPPRESS_LICENSE"), option_suppressLicense ?
     356           0 :                         makeAny(OUString("1")):makeAny(OUString("0")));
     357           0 :                         xExtensionManager->addExtension(
     358             :                             cmdPackage, Sequence<beans::NamedValue>(&nvSuppress, 1),
     359           0 :                             repository, Reference<task::XAbortChannel>(), xCmdEnv);
     360             :                 }
     361             :                 else
     362             :                 {
     363             :                     try
     364             :                     {
     365           0 :                         xExtensionManager->removeExtension(
     366             :                             cmdPackage, cmdPackage, repository,
     367           0 :                             Reference<task::XAbortChannel>(), xCmdEnv );
     368             :                     }
     369           0 :                     catch (const lang::IllegalArgumentException &)
     370             :                     {
     371             :                         Reference<deployment::XPackage> p(
     372             :                              findPackage(repository,
     373           0 :                                 xExtensionManager, xCmdEnv, cmdPackage ) );
     374           0 :                         if ( !p.is())
     375           0 :                             throw;
     376           0 :                         else if (p.is())
     377           0 :                             xExtensionManager->removeExtension(
     378           0 :                                 ::dp_misc::getIdentifier(p), p->getName(),
     379             :                                 repository,
     380           0 :                                 Reference<task::XAbortChannel>(), xCmdEnv );
     381             :                     }
     382             :                 }
     383             :             }
     384             :         }
     385           0 :         else if ( subCommand == "reinstall" )
     386             :         {
     387           0 :             xExtensionManager->reinstallDeployedExtensions(
     388           0 :                 false, repository, Reference<task::XAbortChannel>(), xCmdEnv);
     389             :         }
     390           0 :         else if ( subCommand == "list" )
     391             :         {
     392           0 :             ::std::vector<Reference<deployment::XPackage> > vecExtUnaccepted;
     393             :             ::comphelper::sequenceToContainer(vecExtUnaccepted,
     394           0 :                     xExtensionManager->getExtensionsWithUnacceptedLicenses(
     395           0 :                         repository, xCmdEnv));
     396             : 
     397             :             //This vector tells what XPackage  in allExtensions has an
     398             :             //unaccepted license.
     399           0 :             std::vector<bool> vecUnaccepted;
     400           0 :             std::vector<Reference<deployment::XPackage> > allExtensions;
     401           0 :             if (cmdPackages.empty())
     402             :             {
     403             :                 Sequence< Reference<deployment::XPackage> >
     404           0 :                     packages = xExtensionManager->getDeployedExtensions(
     405           0 :                         repository, Reference<task::XAbortChannel>(), xCmdEnv );
     406             : 
     407           0 :                 ::std::vector<Reference<deployment::XPackage> > vec_packages;
     408           0 :                 ::comphelper::sequenceToContainer(vec_packages, packages);
     409             : 
     410             :                 //First copy the extensions with the unaccepted license
     411             :                 //to vector allExtensions.
     412           0 :                 allExtensions.resize(vecExtUnaccepted.size() + vec_packages.size());
     413             : 
     414             :                 ::std::vector<Reference<deployment::XPackage> >::iterator i_all_ext =
     415             :                       ::std::copy(vecExtUnaccepted.begin(), vecExtUnaccepted.end(),
     416           0 :                                   allExtensions.begin());
     417             :                 //Now copy those we got from getDeployedExtensions
     418           0 :                 ::std::copy(vec_packages.begin(), vec_packages.end(), i_all_ext);
     419             : 
     420             :                 //Now prepare the vector which tells what extension has an
     421             :                 //unaccepted license
     422           0 :                 vecUnaccepted.resize(vecExtUnaccepted.size() + vec_packages.size());
     423           0 :                 ::std::fill_n(vecUnaccepted.begin(), vecExtUnaccepted.size(), true);
     424           0 :                 ::std::fill_n(vecUnaccepted.begin() + vecExtUnaccepted.size(),
     425           0 :                       vec_packages.size(), false);
     426             : 
     427             :                 dp_misc::writeConsole(
     428           0 :                     "All deployed " + repository + " extensions:\n\n");
     429             :             }
     430             :             else
     431             :             {
     432             :                 //The user provided the names (ids or file names) of the extensions
     433             :                 //which shall be listed
     434           0 :                 for ( ::std::size_t pos = 0; pos < cmdPackages.size(); ++pos )
     435             :                 {
     436           0 :                     Reference<deployment::XPackage> extension;
     437             :                     try
     438             :                     {
     439           0 :                         extension = xExtensionManager->getDeployedExtension(
     440           0 :                             repository, cmdPackages[ pos ], cmdPackages[ pos ], xCmdEnv );
     441             :                     }
     442           0 :                     catch (const lang::IllegalArgumentException &)
     443             :                     {
     444           0 :                         extension = findPackage(repository,
     445           0 :                             xExtensionManager, xCmdEnv, cmdPackages[ pos ] );
     446             :                     }
     447             : 
     448             :                     //Now look if the requested extension has an unaccepted license
     449           0 :                     bool bUnacceptedLic = false;
     450           0 :                     if (!extension.is())
     451             :                     {
     452             :                         ::std::vector<Reference<deployment::XPackage> >::const_iterator
     453             :                             i = ::std::find_if(
     454             :                                 vecExtUnaccepted.begin(),
     455           0 :                                 vecExtUnaccepted.end(), ExtensionName(cmdPackages[pos]));
     456           0 :                         if (i != vecExtUnaccepted.end())
     457             :                         {
     458           0 :                             extension = *i;
     459           0 :                             bUnacceptedLic = true;
     460             :                         }
     461             :                     }
     462             : 
     463           0 :                     if (extension.is())
     464             :                     {
     465           0 :                         allExtensions.push_back(extension);
     466           0 :                         vecUnaccepted.push_back(bUnacceptedLic);
     467             :                     }
     468             : 
     469             :                     else
     470             :                         throw lang::IllegalArgumentException(
     471           0 :                             "There is no such extension deployed: " +
     472           0 :                             cmdPackages[pos],0,-1);
     473           0 :                 }
     474             : 
     475             :             }
     476             : 
     477           0 :             printf_packages(allExtensions, vecUnaccepted, xCmdEnv );
     478             :         }
     479           0 :         else if ( subCommand == "validate" )
     480             :         {
     481           0 :             ::std::vector<Reference<deployment::XPackage> > vecExtUnaccepted;
     482             :             ::comphelper::sequenceToContainer(
     483           0 :                 vecExtUnaccepted, xExtensionManager->getExtensionsWithUnacceptedLicenses(
     484           0 :                     repository, xCmdEnv));
     485             : 
     486           0 :             for ( ::std::size_t pos = 0; pos < cmdPackages.size(); ++pos )
     487             :             {
     488           0 :                 Reference<deployment::XPackage> extension;
     489             :                 try
     490             :                 {
     491           0 :                     extension = xExtensionManager->getDeployedExtension(
     492           0 :                         repository, cmdPackages[ pos ], cmdPackages[ pos ], xCmdEnv );
     493             :                 }
     494           0 :                 catch (const lang::IllegalArgumentException &)
     495             :                 {
     496           0 :                     extension = findPackage(
     497           0 :                         repository, xExtensionManager, xCmdEnv, cmdPackages[ pos ] );
     498             :                 }
     499             : 
     500           0 :                 if (!extension.is())
     501             :                 {
     502             :                     ::std::vector<Reference<deployment::XPackage> >::const_iterator
     503             :                         i = ::std::find_if(
     504             :                             vecExtUnaccepted.begin(),
     505           0 :                             vecExtUnaccepted.end(), ExtensionName(cmdPackages[pos]));
     506           0 :                     if (i != vecExtUnaccepted.end())
     507             :                     {
     508           0 :                         extension = *i;
     509             :                     }
     510             :                 }
     511             : 
     512           0 :                 if (extension.is())
     513           0 :                     xExtensionManager->checkPrerequisitesAndEnable(
     514           0 :                         extension, Reference<task::XAbortChannel>(), xCmdEnv);
     515           0 :             }
     516             :         }
     517           0 :         else if ( subCommand == "gui" )
     518             :         {
     519             :             Reference<ui::dialogs::XAsynchronousExecutableDialog> xDialog(
     520             :                 deployment::ui::PackageManagerDialog::createAndInstall(
     521             :                     xComponentContext,
     522           0 :                     cmdPackages.size() > 0 ? cmdPackages[0] : OUString() ));
     523             : 
     524           0 :             osl::Condition dialogEnded;
     525           0 :             dialogEnded.reset();
     526             : 
     527             :             Reference< ui::dialogs::XDialogClosedListener > xListener(
     528           0 :                 new DialogClosedListenerImpl( dialogEnded ) );
     529             : 
     530           0 :             xDialog->startExecuteModal(xListener);
     531           0 :             dialogEnded.wait();
     532           0 :             return 0;
     533             :         }
     534             :         else
     535             :         {
     536             :             dp_misc::writeConsoleError(
     537           0 :                 "\nERROR: unknown sub-command " +
     538           0 :                 subCommand + "!\n       Use " APP_NAME " " +
     539           0 :                 toString(info_help) + " to print all options.\n");
     540           0 :             return 1;
     541             :         }
     542             : 
     543           0 :         if (option_verbose)
     544           0 :             dp_misc::writeConsole("\n" APP_NAME " done.\n");
     545             :         //Force to release all bridges which connect us to the child processes
     546           0 :         dp_misc::disposeBridges(xLocalComponentContext);
     547           0 :         return 0;
     548             :     }
     549           0 :     catch (const ucb::CommandFailedException &e)
     550             :     {
     551           0 :         dp_misc::writeConsoleError(e.Message + "\n");
     552           0 :         bNoOtherErrorMsg = true;
     553             :     }
     554           0 :     catch (const ucb::CommandAbortedException &)
     555             :     {
     556           0 :         dp_misc::writeConsoleError("\n" APP_NAME " aborted!\n");
     557             :     }
     558           0 :     catch (const deployment::DeploymentException & exc)
     559             :     {
     560           0 :         OUString cause;
     561           0 :         if (option_verbose)
     562             :         {
     563           0 :             cause = ::comphelper::anyToString(exc.Cause);
     564             :         }
     565             :         else
     566             :         {
     567           0 :             css::uno::Exception e;
     568           0 :             if (exc.Cause >>= e)
     569           0 :                 cause = e.Message;
     570             :         }
     571             : 
     572           0 :         dp_misc::writeConsoleError("\nERROR: " + exc.Message + "\n");
     573           0 :         if (!cause.isEmpty())
     574           0 :             dp_misc::writeConsoleError("       Cause: " + cause + "\n");
     575             :     }
     576           0 :     catch (const LockFileException & e)
     577             :     {
     578           0 :         if (!subcmd_gui)
     579           0 :             dp_misc::writeConsoleError(e.Message);
     580           0 :         bNoOtherErrorMsg = true;
     581             :     }
     582           0 :     catch (const ::com::sun::star::uno::Exception & e ) {
     583           0 :         Any exc( ::cppu::getCaughtException() );
     584             : 
     585           0 :         dp_misc::writeConsoleError("\nERROR: " +
     586           0 :             OUString(option_verbose ? e.Message + "\nException details: \n" +
     587           0 :             ::comphelper::anyToString(exc) : e.Message) + "\n");
     588             :     }
     589           0 :     if (!bNoOtherErrorMsg)
     590           0 :         dp_misc::writeConsoleError("\n" APP_NAME " failed.\n");
     591           0 :     dp_misc::disposeBridges(xLocalComponentContext);
     592           0 :     return 1;
     593             : }
     594             : 
     595             : 
     596             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11