LCOV - code coverage report
Current view: top level - desktop/source/pkgchk/unopkg - unopkg_app.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 246 0.0 %
Date: 2014-04-14 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" DESKTOP_DLLPUBLIC 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_add = false;
     191           0 :     bool subcmd_gui = false;
     192           0 :     OUString logFile;
     193           0 :     OUString repository;
     194           0 :     OUString cmdArg;
     195           0 :     ::std::vector<OUString> cmdPackages;
     196             : 
     197             :     OptionInfo const * info_shared = getOptionInfo(
     198           0 :         s_option_infos, "shared" );
     199             :     OptionInfo const * info_force = getOptionInfo(
     200           0 :         s_option_infos, "force" );
     201             :     OptionInfo const * info_verbose = getOptionInfo(
     202           0 :         s_option_infos, "verbose" );
     203             :     OptionInfo const * info_log = getOptionInfo(
     204           0 :         s_option_infos, "log-file" );
     205             :     OptionInfo const * info_context = getOptionInfo(
     206           0 :         s_option_infos, "deployment-context" );
     207             :     OptionInfo const * info_help = getOptionInfo(
     208           0 :         s_option_infos, "help" );
     209             :     OptionInfo const * info_version = getOptionInfo(
     210           0 :         s_option_infos, "version" );
     211             :     OptionInfo const * info_bundled = getOptionInfo(
     212           0 :         s_option_infos, "bundled" );
     213             :     OptionInfo const * info_suppressLicense = getOptionInfo(
     214           0 :         s_option_infos, "suppress-license" );
     215             : 
     216             : 
     217           0 :     Reference<XComponentContext> xComponentContext;
     218           0 :     Reference<XComponentContext> xLocalComponentContext;
     219             : 
     220             :     try {
     221           0 :         sal_uInt32 nPos = 0;
     222           0 :         sal_uInt32 nCount = osl_getCommandArgCount();
     223           0 :         if (nCount == 0 || isOption( info_help, &nPos ))
     224             :         {
     225           0 :             dp_misc::writeConsole(s_usingText);
     226           0 :             return 0;
     227             :         }
     228           0 :         else if (isOption( info_version, &nPos )) {
     229           0 :             dp_misc::writeConsole("\n" APP_NAME " Version 3.3\n");
     230           0 :             return 0;
     231             :         }
     232             :         //consume all bootstrap variables which may occur before the subcommannd
     233           0 :         while(isBootstrapVariable(&nPos))
     234             :             ;
     235             : 
     236           0 :         if(nPos >= nCount)
     237           0 :             return 0;
     238             :         //get the sub command
     239           0 :         osl_getCommandArg( nPos, &subCommand.pData );
     240           0 :         ++nPos;
     241           0 :         subCommand = subCommand.trim();
     242           0 :         subcmd_add = subCommand == "add";
     243           0 :         subcmd_gui = subCommand == "gui";
     244             : 
     245             :         // sun-command options and packages:
     246           0 :         while (nPos < nCount)
     247             :         {
     248           0 :             if (readArgument( &cmdArg, info_log, &nPos )) {
     249           0 :                 logFile = makeAbsoluteFileUrl(
     250           0 :                     cmdArg.trim(), getProcessWorkingDir() );
     251             :             }
     252           0 :             else if (!readOption( &option_verbose, info_verbose, &nPos ) &&
     253           0 :                      !readOption( &option_shared, info_shared, &nPos ) &&
     254           0 :                      !readOption( &option_force, info_force, &nPos ) &&
     255           0 :                      !readOption( &option_bundled, info_bundled, &nPos ) &&
     256           0 :                      !readOption( &option_suppressLicense, info_suppressLicense, &nPos ) &&
     257           0 :                      !readArgument( &repository, info_context, &nPos ) &&
     258           0 :                      !isBootstrapVariable(&nPos))
     259             :             {
     260           0 :                 osl_getCommandArg( nPos, &cmdArg.pData );
     261           0 :                 ++nPos;
     262           0 :                 cmdArg = cmdArg.trim();
     263           0 :                 if (!cmdArg.isEmpty())
     264             :                 {
     265           0 :                     if (cmdArg[ 0 ] == '-')
     266             :                     {
     267             :                         // is option:
     268             :                         dp_misc::writeConsoleError(
     269           0 :                                  "\nERROR: unexpected option " +
     270           0 :                                  cmdArg +
     271           0 :                                  "!\n" +
     272           0 :                                  "       Use " + APP_NAME + " " +
     273           0 :                                  toString(info_help) +
     274           0 :                                  " to print all options.\n");
     275           0 :                         return 1;
     276             :                     }
     277             :                     else
     278             :                     {
     279             :                         // is package:
     280             :                         cmdPackages.push_back(
     281           0 :                             subcmd_add || subcmd_gui
     282             :                             ? makeAbsoluteFileUrl(
     283           0 :                                 cmdArg, getProcessWorkingDir() )
     284           0 :                             : cmdArg );
     285             :                     }
     286             :                 }
     287             :             }
     288             :         }
     289             : 
     290           0 :         if (repository.isEmpty())
     291             :         {
     292           0 :             if (option_shared)
     293           0 :                 repository = "shared";
     294           0 :             else if (option_bundled)
     295           0 :                 repository = "bundled";
     296             :             else
     297           0 :                 repository = "user";
     298             :         }
     299             :         else
     300             :         {
     301           0 :             if ( repository == "shared" ) {
     302           0 :                 option_shared = true;
     303             :             }
     304           0 :             else if (option_shared) {
     305             :                 dp_misc::writeConsoleError(
     306           0 :                     OUString("WARNING: explicit context given!  ") +
     307           0 :                     "Ignoring option " + toString( info_shared ) + "!\n" );
     308             :             }
     309             :         }
     310             : 
     311           0 :         if (subCommand == "reinstall")
     312             :         {
     313             :             //We must prevent that services and types are loaded by UNO,
     314             :             //otherwise we cannot delete the registry data folder.
     315           0 :             OUString extensionUnorc;
     316           0 :             if (repository == "user")
     317           0 :                 extensionUnorc = "$UNO_USER_PACKAGES_CACHE/registry/com.sun.star.comp.deployment.component.PackageRegistryBackend/unorc";
     318           0 :             else if (repository == "shared")
     319           0 :                 extensionUnorc = "$SHARED_EXTENSIONS_USER/registry/com.sun.star.comp.deployment.component.PackageRegistryBackend/unorc";
     320           0 :             else if (repository == "bundled")
     321           0 :                 extensionUnorc = "$BUNDLED_EXTENSIONS_USER/registry/com.sun.star.comp.deployment.component.PackageRegistryBackend/unorc";
     322             :             else
     323             :                 OSL_ASSERT(false);
     324             : 
     325           0 :             ::rtl::Bootstrap::expandMacros(extensionUnorc);
     326           0 :             oslFileError e = osl_removeFile(extensionUnorc.pData);
     327           0 :             if (e != osl_File_E_None && e != osl_File_E_NOENT)
     328           0 :                 throw Exception("Could not delete " + extensionUnorc, 0);
     329             :         }
     330             : 
     331           0 :         xComponentContext = getUNO(
     332           0 :             option_verbose, option_shared, subcmd_gui, xLocalComponentContext );
     333             : 
     334             :         Reference<deployment::XExtensionManager> xExtensionManager(
     335           0 :             deployment::ExtensionManager::get( xComponentContext ) );
     336             : 
     337             :         Reference< ::com::sun::star::ucb::XCommandEnvironment > xCmdEnv(
     338             :             createCmdEnv( xComponentContext, logFile,
     339           0 :                           option_force, option_verbose, option_suppressLicense) );
     340             : 
     341             :         //synchronize bundled/shared extensions
     342             :         //Do not synchronize when command is "reinstall". This could add types and services to UNO and
     343             :         //prevent the deletion of the registry data folder
     344             :         //synching is done in XExtensionManager.reinstall
     345           0 :         if (!subcmd_gui && ! (subCommand == "reinstall")
     346           0 :             && ! dp_misc::office_is_running())
     347           0 :             dp_misc::syncRepositories(false, xCmdEnv);
     348             : 
     349           0 :         if ( subcmd_add || subCommand == "remove" )
     350             :         {
     351           0 :             for ( ::std::size_t pos = 0; pos < cmdPackages.size(); ++pos )
     352             :             {
     353           0 :                 OUString const & cmdPackage = cmdPackages[ pos ];
     354           0 :                 if (subcmd_add)
     355             :                 {
     356             :                     beans::NamedValue nvSuppress(
     357             :                         OUString("SUPPRESS_LICENSE"), option_suppressLicense ?
     358           0 :                         makeAny(OUString("1")):makeAny(OUString("0")));
     359           0 :                         xExtensionManager->addExtension(
     360             :                             cmdPackage, Sequence<beans::NamedValue>(&nvSuppress, 1),
     361           0 :                             repository, Reference<task::XAbortChannel>(), xCmdEnv);
     362             :                 }
     363             :                 else
     364             :                 {
     365             :                     try
     366             :                     {
     367           0 :                         xExtensionManager->removeExtension(
     368             :                             cmdPackage, cmdPackage, repository,
     369           0 :                             Reference<task::XAbortChannel>(), xCmdEnv );
     370             :                     }
     371           0 :                     catch (const lang::IllegalArgumentException &)
     372             :                     {
     373             :                         Reference<deployment::XPackage> p(
     374             :                              findPackage(repository,
     375           0 :                                 xExtensionManager, xCmdEnv, cmdPackage ) );
     376           0 :                         if ( !p.is())
     377           0 :                             throw;
     378           0 :                         else if (p.is())
     379           0 :                             xExtensionManager->removeExtension(
     380           0 :                                 ::dp_misc::getIdentifier(p), p->getName(),
     381             :                                 repository,
     382           0 :                                 Reference<task::XAbortChannel>(), xCmdEnv );
     383             :                     }
     384             :                 }
     385             :             }
     386             :         }
     387           0 :         else if ( subCommand == "reinstall" )
     388             :         {
     389           0 :             xExtensionManager->reinstallDeployedExtensions(
     390           0 :                 false, repository, Reference<task::XAbortChannel>(), xCmdEnv);
     391             :         }
     392           0 :         else if ( subCommand == "list" )
     393             :         {
     394           0 :             ::std::vector<Reference<deployment::XPackage> > vecExtUnaccepted;
     395             :             ::comphelper::sequenceToContainer(vecExtUnaccepted,
     396           0 :                     xExtensionManager->getExtensionsWithUnacceptedLicenses(
     397           0 :                         repository, xCmdEnv));
     398             : 
     399             :             //This vector tells what XPackage  in allExtensions has an
     400             :             //unaccepted license.
     401           0 :             std::vector<bool> vecUnaccepted;
     402           0 :             std::vector<Reference<deployment::XPackage> > allExtensions;
     403           0 :             if (cmdPackages.empty())
     404             :             {
     405             :                 Sequence< Reference<deployment::XPackage> >
     406           0 :                     packages = xExtensionManager->getDeployedExtensions(
     407           0 :                         repository, Reference<task::XAbortChannel>(), xCmdEnv );
     408             : 
     409           0 :                 ::std::vector<Reference<deployment::XPackage> > vec_packages;
     410           0 :                 ::comphelper::sequenceToContainer(vec_packages, packages);
     411             : 
     412             :                 //First copy the extensions with the unaccepted license
     413             :                 //to vector allExtensions.
     414           0 :                 allExtensions.resize(vecExtUnaccepted.size() + vec_packages.size());
     415             : 
     416             :                 ::std::vector<Reference<deployment::XPackage> >::iterator i_all_ext =
     417             :                       ::std::copy(vecExtUnaccepted.begin(), vecExtUnaccepted.end(),
     418           0 :                                   allExtensions.begin());
     419             :                 //Now copy those we got from getDeployedExtensions
     420           0 :                 ::std::copy(vec_packages.begin(), vec_packages.end(), i_all_ext);
     421             : 
     422             :                 //Now prepare the vector which tells what extension has an
     423             :                 //unaccepted license
     424           0 :                 vecUnaccepted.resize(vecExtUnaccepted.size() + vec_packages.size());
     425           0 :                 ::std::fill_n(vecUnaccepted.begin(), vecExtUnaccepted.size(), true);
     426           0 :                 ::std::fill_n(vecUnaccepted.begin() + vecExtUnaccepted.size(),
     427           0 :                       vec_packages.size(), false);
     428             : 
     429             :                 dp_misc::writeConsole(
     430           0 :                     OUString("All deployed ") + repository + " extensions:\n\n");
     431             :             }
     432             :             else
     433             :             {
     434             :                 //The user provided the names (ids or file names) of the extensions
     435             :                 //which shall be listed
     436           0 :                 for ( ::std::size_t pos = 0; pos < cmdPackages.size(); ++pos )
     437             :                 {
     438           0 :                     Reference<deployment::XPackage> extension;
     439             :                     try
     440             :                     {
     441           0 :                         extension = xExtensionManager->getDeployedExtension(
     442           0 :                             repository, cmdPackages[ pos ], cmdPackages[ pos ], xCmdEnv );
     443             :                     }
     444           0 :                     catch (const lang::IllegalArgumentException &)
     445             :                     {
     446           0 :                         extension = findPackage(repository,
     447           0 :                             xExtensionManager, xCmdEnv, cmdPackages[ pos ] );
     448             :                     }
     449             : 
     450             :                     //Now look if the requested extension has an unaccepted license
     451           0 :                     bool bUnacceptedLic = false;
     452           0 :                     if (!extension.is())
     453             :                     {
     454             :                         ::std::vector<Reference<deployment::XPackage> >::const_iterator
     455             :                             i = ::std::find_if(
     456             :                                 vecExtUnaccepted.begin(),
     457           0 :                                 vecExtUnaccepted.end(), ExtensionName(cmdPackages[pos]));
     458           0 :                         if (i != vecExtUnaccepted.end())
     459             :                         {
     460           0 :                             extension = *i;
     461           0 :                             bUnacceptedLic = true;
     462             :                         }
     463             :                     }
     464             : 
     465           0 :                     if (extension.is())
     466             :                     {
     467           0 :                         allExtensions.push_back(extension);
     468           0 :                         vecUnaccepted.push_back(bUnacceptedLic);
     469             :                     }
     470             : 
     471             :                     else
     472             :                         throw lang::IllegalArgumentException(
     473           0 :                             "There is no such extension deployed: " +
     474           0 :                             cmdPackages[pos],0,-1);
     475           0 :                 }
     476             : 
     477             :             }
     478             : 
     479           0 :             printf_packages(allExtensions, vecUnaccepted, xCmdEnv );
     480             :         }
     481           0 :         else if ( subCommand == "validate" )
     482             :         {
     483           0 :             ::std::vector<Reference<deployment::XPackage> > vecExtUnaccepted;
     484             :             ::comphelper::sequenceToContainer(
     485           0 :                 vecExtUnaccepted, xExtensionManager->getExtensionsWithUnacceptedLicenses(
     486           0 :                     repository, xCmdEnv));
     487             : 
     488           0 :             for ( ::std::size_t pos = 0; pos < cmdPackages.size(); ++pos )
     489             :             {
     490           0 :                 Reference<deployment::XPackage> extension;
     491             :                 try
     492             :                 {
     493           0 :                     extension = xExtensionManager->getDeployedExtension(
     494           0 :                         repository, cmdPackages[ pos ], cmdPackages[ pos ], xCmdEnv );
     495             :                 }
     496           0 :                 catch (const lang::IllegalArgumentException &)
     497             :                 {
     498           0 :                     extension = findPackage(
     499           0 :                         repository, xExtensionManager, xCmdEnv, cmdPackages[ pos ] );
     500             :                 }
     501             : 
     502           0 :                 if (!extension.is())
     503             :                 {
     504             :                     ::std::vector<Reference<deployment::XPackage> >::const_iterator
     505             :                         i = ::std::find_if(
     506             :                             vecExtUnaccepted.begin(),
     507           0 :                             vecExtUnaccepted.end(), ExtensionName(cmdPackages[pos]));
     508           0 :                     if (i != vecExtUnaccepted.end())
     509             :                     {
     510           0 :                         extension = *i;
     511             :                     }
     512             :                 }
     513             : 
     514           0 :                 if (extension.is())
     515           0 :                     xExtensionManager->checkPrerequisitesAndEnable(
     516           0 :                         extension, Reference<task::XAbortChannel>(), xCmdEnv);
     517           0 :             }
     518             :         }
     519           0 :         else if ( subCommand == "gui" )
     520             :         {
     521             :             Reference<ui::dialogs::XAsynchronousExecutableDialog> xDialog(
     522             :                 deployment::ui::PackageManagerDialog::createAndInstall(
     523             :                     xComponentContext,
     524           0 :                     cmdPackages.size() > 0 ? cmdPackages[0] : OUString() ));
     525             : 
     526           0 :             osl::Condition dialogEnded;
     527           0 :             dialogEnded.reset();
     528             : 
     529             :             Reference< ui::dialogs::XDialogClosedListener > xListener(
     530           0 :                 new DialogClosedListenerImpl( dialogEnded ) );
     531             : 
     532           0 :             xDialog->startExecuteModal(xListener);
     533           0 :             dialogEnded.wait();
     534           0 :             return 0;
     535             :         }
     536             :         else
     537             :         {
     538             :             dp_misc::writeConsoleError(
     539           0 :                 "\nERROR: unknown sub-command " +
     540           0 :                 subCommand + "!\n" +
     541           0 :                 "       Use " + APP_NAME + " " +
     542           0 :                 toString(info_help) + " to print all options.\n");
     543           0 :             return 1;
     544             :         }
     545             : 
     546           0 :         if (option_verbose)
     547           0 :             dp_misc::writeConsole(OUString("\n") + APP_NAME + " done.\n");
     548             :         //Force to release all bridges which connect us to the child processes
     549           0 :         dp_misc::disposeBridges(xLocalComponentContext);
     550           0 :         return 0;
     551             :     }
     552           0 :     catch (const ucb::CommandFailedException &e)
     553             :     {
     554           0 :         dp_misc::writeConsoleError(e.Message + "\n");
     555           0 :         bNoOtherErrorMsg = true;
     556             :     }
     557           0 :     catch (const ucb::CommandAbortedException &)
     558             :     {
     559           0 :         dp_misc::writeConsoleError("\n" APP_NAME " aborted!\n");
     560             :     }
     561           0 :     catch (const deployment::DeploymentException & exc)
     562             :     {
     563           0 :         OUString cause;
     564           0 :         if (option_verbose)
     565             :         {
     566           0 :             cause = ::comphelper::anyToString(exc.Cause);
     567             :         }
     568             :         else
     569             :         {
     570           0 :             css::uno::Exception e;
     571           0 :             if (exc.Cause >>= e)
     572           0 :                 cause = e.Message;
     573             :         }
     574             : 
     575           0 :         dp_misc::writeConsoleError("\nERROR: " + exc.Message + "\n");
     576           0 :         if (!cause.isEmpty())
     577           0 :             dp_misc::writeConsoleError("       Cause: " + cause + "\n");
     578             :     }
     579           0 :     catch (const LockFileException & e)
     580             :     {
     581           0 :         if (!subcmd_gui)
     582           0 :             dp_misc::writeConsoleError(e.Message);
     583           0 :         bNoOtherErrorMsg = true;
     584             :     }
     585           0 :     catch (const ::com::sun::star::uno::Exception & e ) {
     586           0 :         Any exc( ::cppu::getCaughtException() );
     587             : 
     588           0 :         dp_misc::writeConsoleError("\nERROR: " +
     589           0 :             OUString(option_verbose ? e.Message + "\nException details: \n" +
     590           0 :             ::comphelper::anyToString(exc) : e.Message) + "\n");
     591             :     }
     592           0 :     if (!bNoOtherErrorMsg)
     593           0 :         dp_misc::writeConsoleError("\n" APP_NAME " failed.\n");
     594           0 :     dp_misc::disposeBridges(xLocalComponentContext);
     595           0 :     return 1;
     596             : }
     597             : 
     598             : 
     599             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10