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

Generated by: LCOV version 1.10