2010-10-12 15:53:47 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-11-15 17:28:16 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
2004-04-13 11:07:59 +00:00
|
|
|
*
|
2012-11-15 17:28:16 +00:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
2004-04-13 11:07:59 +00:00
|
|
|
*
|
2012-11-15 17:28:16 +00:00
|
|
|
* This file incorporates work covered by the following license notice:
|
2004-04-13 11:07:59 +00:00
|
|
|
*
|
2012-11-15 17:28:16 +00:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2004-04-13 11:07:59 +00:00
|
|
|
|
2012-10-26 16:13:45 +02:00
|
|
|
#include "sal/config.h"
|
|
|
|
|
|
|
|
#include <cassert>
|
2006-09-17 08:42:56 +00:00
|
|
|
|
2004-04-13 11:07:59 +00:00
|
|
|
#include "dp_backend.h"
|
|
|
|
#include "dp_ucb.h"
|
2012-09-17 17:11:09 -05:00
|
|
|
#include "rtl/ustring.hxx"
|
2004-04-13 11:07:59 +00:00
|
|
|
#include "rtl/uri.hxx"
|
2010-04-19 11:33:33 +02:00
|
|
|
#include "rtl/bootstrap.hxx"
|
2010-03-25 10:32:07 +01:00
|
|
|
#include "osl/file.hxx"
|
2004-04-13 11:07:59 +00:00
|
|
|
#include "cppuhelper/exc_hlp.hxx"
|
2006-03-06 09:21:41 +00:00
|
|
|
#include "comphelper/servicedecl.hxx"
|
|
|
|
#include "comphelper/unwrapargs.hxx"
|
2004-08-12 11:09:42 +00:00
|
|
|
#include "ucbhelper/content.hxx"
|
2004-04-13 11:07:59 +00:00
|
|
|
#include "com/sun/star/lang/WrappedTargetRuntimeException.hpp"
|
2010-03-22 12:35:33 +01:00
|
|
|
#include "com/sun/star/deployment/InvalidRemovedParameterException.hpp"
|
2010-09-29 09:11:20 +02:00
|
|
|
#include "com/sun/star/deployment/thePackageManagerFactory.hpp"
|
2010-03-25 10:32:07 +01:00
|
|
|
#include "com/sun/star/ucb/InteractiveAugmentedIOException.hpp"
|
|
|
|
#include "com/sun/star/ucb/IOErrorCode.hpp"
|
2008-06-06 07:10:59 +00:00
|
|
|
#include "com/sun/star/beans/StringPair.hpp"
|
2010-03-25 10:32:07 +01:00
|
|
|
#include "com/sun/star/sdbc/XResultSet.hpp"
|
|
|
|
#include "com/sun/star/sdbc/XRow.hpp"
|
2011-02-21 15:37:12 +01:00
|
|
|
#include "unotools/tempfile.hxx"
|
2004-04-13 11:07:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
using namespace ::dp_misc;
|
|
|
|
using namespace ::com::sun::star;
|
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star::ucb;
|
|
|
|
|
2004-08-12 11:09:42 +00:00
|
|
|
namespace dp_registry {
|
|
|
|
namespace backend {
|
2004-04-13 11:07:59 +00:00
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2004-04-13 11:07:59 +00:00
|
|
|
PackageRegistryBackend::~PackageRegistryBackend()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2004-06-11 11:11:31 +00:00
|
|
|
void PackageRegistryBackend::disposing( lang::EventObject const & event )
|
2014-02-25 21:31:58 +01:00
|
|
|
throw (RuntimeException, std::exception)
|
2004-04-13 11:07:59 +00:00
|
|
|
{
|
2004-06-11 11:11:31 +00:00
|
|
|
Reference<deployment::XPackage> xPackage(
|
|
|
|
event.Source, UNO_QUERY_THROW );
|
|
|
|
OUString url( xPackage->getURL() );
|
|
|
|
::osl::MutexGuard guard( getMutex() );
|
2006-10-12 13:09:59 +00:00
|
|
|
if ( m_bound.erase( url ) != 1 )
|
|
|
|
{
|
2012-07-20 11:10:05 +02:00
|
|
|
SAL_WARN("desktop.deployment", "erase(" << url << ") != 1");
|
2006-10-12 13:09:59 +00:00
|
|
|
}
|
2004-04-13 11:07:59 +00:00
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2004-06-11 11:11:31 +00:00
|
|
|
PackageRegistryBackend::PackageRegistryBackend(
|
2004-08-12 11:09:42 +00:00
|
|
|
Sequence<Any> const & args,
|
2006-03-06 09:21:41 +00:00
|
|
|
Reference<XComponentContext> const & xContext )
|
2004-06-11 11:11:31 +00:00
|
|
|
: t_BackendBase( getMutex() ),
|
|
|
|
m_xComponentContext( xContext ),
|
|
|
|
m_eContext( CONTEXT_UNKNOWN ),
|
2004-11-09 13:10:41 +00:00
|
|
|
m_readOnly( false )
|
2004-04-13 11:07:59 +00:00
|
|
|
{
|
2012-10-26 16:13:45 +02:00
|
|
|
assert(xContext.is());
|
2006-03-06 09:21:41 +00:00
|
|
|
boost::optional<OUString> cachePath;
|
|
|
|
boost::optional<bool> readOnly;
|
|
|
|
comphelper::unwrapArgs( args, m_context, cachePath, readOnly );
|
|
|
|
if (cachePath)
|
|
|
|
m_cachePath = *cachePath;
|
|
|
|
if (readOnly)
|
|
|
|
m_readOnly = *readOnly;
|
2004-08-12 11:09:42 +00:00
|
|
|
|
2012-04-06 15:05:52 +02:00
|
|
|
if ( m_context == "user" )
|
2004-08-12 11:09:42 +00:00
|
|
|
m_eContext = CONTEXT_USER;
|
2012-04-06 15:05:52 +02:00
|
|
|
else if ( m_context == "shared" )
|
2004-08-12 11:09:42 +00:00
|
|
|
m_eContext = CONTEXT_SHARED;
|
2012-04-06 15:05:52 +02:00
|
|
|
else if ( m_context == "bundled" )
|
2010-05-04 12:37:01 +02:00
|
|
|
m_eContext = CONTEXT_BUNDLED;
|
2012-04-06 15:05:52 +02:00
|
|
|
else if ( m_context == "tmp" )
|
2010-05-04 12:37:01 +02:00
|
|
|
m_eContext = CONTEXT_TMP;
|
2012-12-30 11:10:48 +01:00
|
|
|
else if (m_context.matchIgnoreAsciiCase("vnd.sun.star.tdoc:/"))
|
2004-08-12 11:09:42 +00:00
|
|
|
m_eContext = CONTEXT_DOCUMENT;
|
|
|
|
else
|
|
|
|
m_eContext = CONTEXT_UNKNOWN;
|
2004-06-11 11:11:31 +00:00
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2004-06-11 11:11:31 +00:00
|
|
|
void PackageRegistryBackend::check()
|
|
|
|
{
|
|
|
|
::osl::MutexGuard guard( getMutex() );
|
2004-08-12 11:09:42 +00:00
|
|
|
if (rBHelper.bInDispose || rBHelper.bDisposed) {
|
2004-06-11 11:11:31 +00:00
|
|
|
throw lang::DisposedException(
|
2012-12-30 11:10:48 +01:00
|
|
|
"PackageRegistryBackend instance has already been disposed!",
|
2004-06-11 11:11:31 +00:00
|
|
|
static_cast<OWeakObject *>(this) );
|
2004-04-13 11:07:59 +00:00
|
|
|
}
|
2004-06-11 11:11:31 +00:00
|
|
|
}
|
2004-04-13 11:07:59 +00:00
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2004-04-13 11:07:59 +00:00
|
|
|
void PackageRegistryBackend::disposing()
|
|
|
|
{
|
2004-08-12 11:09:42 +00:00
|
|
|
try {
|
2011-01-06 14:03:55 +00:00
|
|
|
for ( t_string2ref::const_iterator i = m_bound.begin(); i != m_bound.end(); ++i)
|
2010-10-11 15:04:50 +01:00
|
|
|
i->second->removeEventListener(this);
|
|
|
|
m_bound.clear();
|
2004-04-13 11:07:59 +00:00
|
|
|
m_xComponentContext.clear();
|
2004-06-11 11:11:31 +00:00
|
|
|
WeakComponentImplHelperBase::disposing();
|
2004-04-13 11:07:59 +00:00
|
|
|
}
|
2011-12-06 00:19:44 +09:00
|
|
|
catch (const RuntimeException &) {
|
2004-04-13 11:07:59 +00:00
|
|
|
throw;
|
|
|
|
}
|
2011-12-06 00:19:44 +09:00
|
|
|
catch (const Exception &) {
|
2004-04-13 11:07:59 +00:00
|
|
|
Any exc( ::cppu::getCaughtException() );
|
|
|
|
throw lang::WrappedTargetRuntimeException(
|
2012-12-30 11:10:48 +01:00
|
|
|
"caught unexpected exception while disposing!",
|
2004-06-11 11:11:31 +00:00
|
|
|
static_cast<OWeakObject *>(this), exc );
|
2004-04-13 11:07:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// XPackageRegistry
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2004-06-11 11:11:31 +00:00
|
|
|
Reference<deployment::XPackage> PackageRegistryBackend::bindPackage(
|
2010-03-22 12:35:33 +01:00
|
|
|
OUString const & url, OUString const & mediaType, sal_Bool bRemoved,
|
|
|
|
OUString const & identifier, Reference<XCommandEnvironment> const & xCmdEnv )
|
|
|
|
throw (deployment::DeploymentException,
|
|
|
|
deployment::InvalidRemovedParameterException,
|
|
|
|
ucb::CommandFailedException,
|
2014-02-25 21:31:58 +01:00
|
|
|
lang::IllegalArgumentException, RuntimeException, std::exception)
|
2004-04-13 11:07:59 +00:00
|
|
|
{
|
2004-06-11 11:11:31 +00:00
|
|
|
::osl::ResettableMutexGuard guard( getMutex() );
|
|
|
|
check();
|
2010-03-22 12:35:33 +01:00
|
|
|
|
|
|
|
t_string2ref::const_iterator const iFind( m_bound.find( url ) );
|
|
|
|
if (iFind != m_bound.end())
|
2010-05-04 12:37:01 +02:00
|
|
|
{
|
2010-03-22 12:35:33 +01:00
|
|
|
Reference<deployment::XPackage> xPackage( iFind->second );
|
|
|
|
if (xPackage.is())
|
2010-05-04 12:37:01 +02:00
|
|
|
{
|
2011-12-20 19:01:12 -02:00
|
|
|
if (!mediaType.isEmpty() &&
|
2010-03-22 12:35:33 +01:00
|
|
|
mediaType != xPackage->getPackageType()->getMediaType())
|
|
|
|
throw lang::IllegalArgumentException
|
2012-12-30 11:10:48 +01:00
|
|
|
("XPackageRegistry::bindPackage: media type does not match",
|
2010-03-22 12:35:33 +01:00
|
|
|
static_cast<OWeakObject*>(this), 1);
|
|
|
|
if (xPackage->isRemoved() != bRemoved)
|
|
|
|
throw deployment::InvalidRemovedParameterException(
|
2012-12-30 11:10:48 +01:00
|
|
|
"XPackageRegistry::bindPackage: bRemoved parameter does not match",
|
2010-03-22 12:35:33 +01:00
|
|
|
static_cast<OWeakObject*>(this), xPackage->isRemoved(), xPackage);
|
|
|
|
return xPackage;
|
2010-05-04 12:37:01 +02:00
|
|
|
}
|
2004-06-11 11:11:31 +00:00
|
|
|
}
|
2010-03-22 12:35:33 +01:00
|
|
|
|
2004-06-11 11:11:31 +00:00
|
|
|
guard.clear();
|
|
|
|
|
|
|
|
Reference<deployment::XPackage> xNewPackage;
|
2004-08-12 11:09:42 +00:00
|
|
|
try {
|
2010-04-19 11:33:33 +02:00
|
|
|
xNewPackage = bindPackage_( url, mediaType, bRemoved,
|
|
|
|
identifier, xCmdEnv );
|
2004-04-13 11:07:59 +00:00
|
|
|
}
|
2011-12-06 00:19:44 +09:00
|
|
|
catch (const RuntimeException &) {
|
2004-04-13 11:07:59 +00:00
|
|
|
throw;
|
|
|
|
}
|
2011-12-06 00:19:44 +09:00
|
|
|
catch (const CommandFailedException &) {
|
2004-06-11 11:11:31 +00:00
|
|
|
throw;
|
2004-04-13 11:07:59 +00:00
|
|
|
}
|
2011-12-06 00:19:44 +09:00
|
|
|
catch (const deployment::DeploymentException &) {
|
2004-04-13 11:07:59 +00:00
|
|
|
throw;
|
|
|
|
}
|
2011-12-06 00:19:44 +09:00
|
|
|
catch (const Exception &) {
|
2004-06-11 11:11:31 +00:00
|
|
|
Any exc( ::cppu::getCaughtException() );
|
|
|
|
throw deployment::DeploymentException(
|
2012-12-30 11:10:48 +01:00
|
|
|
"Error binding package: " + url,
|
2004-06-11 11:11:31 +00:00
|
|
|
static_cast<OWeakObject *>(this), exc );
|
2004-04-13 11:07:59 +00:00
|
|
|
}
|
|
|
|
|
2004-06-11 11:11:31 +00:00
|
|
|
guard.reset();
|
2010-03-22 12:35:33 +01:00
|
|
|
|
|
|
|
::std::pair< t_string2ref::iterator, bool > insertion(
|
|
|
|
m_bound.insert( t_string2ref::value_type( url, xNewPackage ) ) );
|
|
|
|
if (insertion.second)
|
|
|
|
{ // first insertion
|
2011-11-22 09:34:46 +01:00
|
|
|
SAL_WARN_IF(
|
|
|
|
Reference<XInterface>(insertion.first->second) != xNewPackage,
|
2012-07-20 11:10:05 +02:00
|
|
|
"desktop.deployment", "mismatch");
|
2004-04-13 11:07:59 +00:00
|
|
|
}
|
2010-03-22 12:35:33 +01:00
|
|
|
else
|
|
|
|
{ // found existing entry
|
|
|
|
Reference<deployment::XPackage> xPackage( insertion.first->second );
|
|
|
|
if (xPackage.is())
|
|
|
|
return xPackage;
|
|
|
|
insertion.first->second = xNewPackage;
|
|
|
|
}
|
|
|
|
|
2004-06-11 11:11:31 +00:00
|
|
|
guard.clear();
|
|
|
|
xNewPackage->addEventListener( this ); // listen for disposing events
|
|
|
|
return xNewPackage;
|
2004-04-13 11:07:59 +00:00
|
|
|
}
|
|
|
|
|
2010-03-25 10:32:07 +01:00
|
|
|
OUString PackageRegistryBackend::createFolder(
|
|
|
|
OUString const & relUrl,
|
|
|
|
Reference<ucb::XCommandEnvironment> const & xCmdEnv)
|
|
|
|
{
|
2011-02-21 15:37:12 +01:00
|
|
|
const OUString sDataFolder = makeURL(getCachePath(), relUrl);
|
2010-03-25 10:32:07 +01:00
|
|
|
//make sure the folder exist
|
|
|
|
ucbhelper::Content dataContent;
|
|
|
|
::dp_misc::create_folder(&dataContent, sDataFolder, xCmdEnv);
|
|
|
|
|
2013-07-01 10:33:48 -05:00
|
|
|
const OUString baseDir(sDataFolder);
|
|
|
|
const ::utl::TempFile aTemp(&baseDir, true);
|
2011-02-21 15:37:12 +01:00
|
|
|
const OUString url = aTemp.GetURL();
|
|
|
|
return sDataFolder + url.copy(url.lastIndexOf('/'));
|
2010-03-25 10:32:07 +01:00
|
|
|
}
|
|
|
|
|
2011-02-21 15:37:12 +01:00
|
|
|
//folderURL can have the extension .tmp or .tmp_
|
|
|
|
//Before OOo 3.4 the created a tmp file with osl_createTempFile and
|
|
|
|
//then created a Folder with a same name and a trailing '_'
|
|
|
|
//If the folderURL has no '_' then there is no corresponding tmp file.
|
2010-05-07 17:02:22 +02:00
|
|
|
void PackageRegistryBackend::deleteTempFolder(
|
|
|
|
OUString const & folderUrl)
|
|
|
|
{
|
2011-12-20 19:01:12 -02:00
|
|
|
if (!folderUrl.isEmpty())
|
2010-05-07 17:02:22 +02:00
|
|
|
{
|
|
|
|
erase_path( folderUrl, Reference<XCommandEnvironment>(),
|
|
|
|
false /* no throw: ignore errors */ );
|
2011-02-21 15:37:12 +01:00
|
|
|
|
2013-10-21 10:21:01 +02:00
|
|
|
if (folderUrl.endsWith("_"))
|
2011-02-21 15:37:12 +01:00
|
|
|
{
|
|
|
|
const OUString tempFile = folderUrl.copy(0, folderUrl.getLength() - 1);
|
|
|
|
erase_path( tempFile, Reference<XCommandEnvironment>(),
|
|
|
|
false /* no throw: ignore errors */ );
|
|
|
|
}
|
2010-05-07 17:02:22 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-21 15:37:12 +01:00
|
|
|
//usedFolders can contain folder names which have the extension .tmp or .tmp_
|
|
|
|
//Before OOo 3.4 we created a tmp file with osl_createTempFile and
|
|
|
|
//then created a Folder with a same name and a trailing '_'
|
|
|
|
//If the folderURL has no '_' then there is no corresponding tmp file.
|
2010-03-25 10:32:07 +01:00
|
|
|
void PackageRegistryBackend::deleteUnusedFolders(
|
|
|
|
OUString const & relUrl,
|
|
|
|
::std::list< OUString> const & usedFolders)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
const OUString sDataFolder = makeURL(getCachePath(), relUrl);
|
|
|
|
::ucbhelper::Content tempFolder(
|
2012-09-14 18:08:57 +02:00
|
|
|
sDataFolder, Reference<ucb::XCommandEnvironment>(), m_xComponentContext);
|
2012-03-29 12:02:59 +01:00
|
|
|
|
2010-03-25 10:32:07 +01:00
|
|
|
Reference<sdbc::XResultSet> xResultSet(
|
2012-03-29 12:02:59 +01:00
|
|
|
StrTitle::createCursor( tempFolder, ::ucbhelper::INCLUDE_FOLDERS_ONLY ) );
|
|
|
|
|
2010-03-25 10:32:07 +01:00
|
|
|
// get all temp directories:
|
|
|
|
::std::vector<OUString> tempEntries;
|
|
|
|
|
2010-11-20 16:29:14 +01:00
|
|
|
const char tmp[] = ".tmp";
|
2010-03-25 10:32:07 +01:00
|
|
|
|
|
|
|
while (xResultSet->next())
|
|
|
|
{
|
|
|
|
OUString title(
|
|
|
|
Reference<sdbc::XRow>(
|
|
|
|
xResultSet, UNO_QUERY_THROW )->getString(
|
|
|
|
1 /* Title */ ) );
|
|
|
|
|
2012-12-30 11:10:48 +01:00
|
|
|
if (title.endsWith(tmp))
|
2010-03-25 10:32:07 +01:00
|
|
|
tempEntries.push_back(
|
|
|
|
makeURLAppendSysPathSegment(sDataFolder, title));
|
|
|
|
}
|
|
|
|
|
|
|
|
for ( ::std::size_t pos = 0; pos < tempEntries.size(); ++pos )
|
|
|
|
{
|
2011-02-21 15:37:12 +01:00
|
|
|
if (::std::find( usedFolders.begin(), usedFolders.end(), tempEntries[pos] ) ==
|
2010-03-25 10:32:07 +01:00
|
|
|
usedFolders.end())
|
|
|
|
{
|
2011-02-21 15:37:12 +01:00
|
|
|
deleteTempFolder(tempEntries[pos]);
|
2010-03-25 10:32:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-12-06 00:19:44 +09:00
|
|
|
catch (const ucb::InteractiveAugmentedIOException& e)
|
2010-03-25 10:32:07 +01:00
|
|
|
{
|
|
|
|
//In case the folder containing all the data folder does not
|
|
|
|
//exist yet, we ignore the exception
|
|
|
|
if (e.Code != ucb::IOErrorCode_NOT_EXISTING)
|
2012-02-01 22:52:43 +01:00
|
|
|
throw;
|
2010-03-25 10:32:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2004-04-13 11:07:59 +00:00
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2004-04-13 11:07:59 +00:00
|
|
|
Package::~Package()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2004-06-11 11:11:31 +00:00
|
|
|
Package::Package( ::rtl::Reference<PackageRegistryBackend> const & myBackend,
|
|
|
|
OUString const & url,
|
2010-05-10 11:06:01 +02:00
|
|
|
OUString const & rName,
|
2004-06-11 11:11:31 +00:00
|
|
|
OUString const & displayName,
|
2010-05-04 12:37:01 +02:00
|
|
|
Reference<deployment::XPackageTypeInfo> const & xPackageType,
|
2010-03-22 12:35:33 +01:00
|
|
|
bool bRemoved,
|
|
|
|
OUString const & identifier)
|
2004-06-11 11:11:31 +00:00
|
|
|
: t_PackageBase( getMutex() ),
|
|
|
|
m_myBackend( myBackend ),
|
|
|
|
m_url( url ),
|
2010-05-10 11:06:01 +02:00
|
|
|
m_name( rName ),
|
2004-06-11 11:11:31 +00:00
|
|
|
m_displayName( displayName ),
|
2010-05-04 12:37:01 +02:00
|
|
|
m_xPackageType( xPackageType ),
|
2010-03-22 12:35:33 +01:00
|
|
|
m_bRemoved(bRemoved),
|
|
|
|
m_identifier(identifier)
|
2004-04-13 11:07:59 +00:00
|
|
|
{
|
2010-04-19 11:33:33 +02:00
|
|
|
if (m_bRemoved)
|
|
|
|
{
|
|
|
|
//We use the last segment of the URL
|
2012-07-20 11:10:05 +02:00
|
|
|
SAL_WARN_IF(
|
|
|
|
!m_name.isEmpty(), "desktop.deployment", "non-empty m_name");
|
2010-04-19 11:33:33 +02:00
|
|
|
OUString name = m_url;
|
|
|
|
rtl::Bootstrap::expandMacros(name);
|
|
|
|
sal_Int32 index = name.lastIndexOf('/');
|
|
|
|
if (index != -1 && index < name.getLength())
|
|
|
|
m_name = name.copy(index + 1);
|
|
|
|
}
|
2004-04-13 11:07:59 +00:00
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2004-04-13 11:07:59 +00:00
|
|
|
void Package::disposing()
|
|
|
|
{
|
|
|
|
m_myBackend.clear();
|
2004-06-11 11:11:31 +00:00
|
|
|
WeakComponentImplHelperBase::disposing();
|
2004-04-13 11:07:59 +00:00
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2008-05-20 13:33:14 +00:00
|
|
|
void Package::check() const
|
2004-04-13 11:07:59 +00:00
|
|
|
{
|
|
|
|
::osl::MutexGuard guard( getMutex() );
|
2004-08-12 11:09:42 +00:00
|
|
|
if (rBHelper.bInDispose || rBHelper.bDisposed) {
|
2004-06-11 11:11:31 +00:00
|
|
|
throw lang::DisposedException(
|
2012-12-30 11:10:48 +01:00
|
|
|
"Package instance has already been disposed!",
|
2008-05-20 13:33:14 +00:00
|
|
|
static_cast<OWeakObject *>(const_cast<Package *>(this)));
|
2004-04-13 11:07:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-06-11 11:11:31 +00:00
|
|
|
// XComponent
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
void Package::dispose() throw (RuntimeException, std::exception)
|
2004-04-13 11:07:59 +00:00
|
|
|
{
|
2012-11-15 17:28:16 +00:00
|
|
|
//Do not call check here. We must not throw an exception here if the object
|
|
|
|
//is being disposed or is already disposed. See com.sun.star.lang.XComponent
|
2004-06-11 11:11:31 +00:00
|
|
|
WeakComponentImplHelperBase::dispose();
|
2004-04-13 11:07:59 +00:00
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2004-06-11 11:11:31 +00:00
|
|
|
void Package::addEventListener(
|
2014-02-25 21:31:58 +01:00
|
|
|
Reference<lang::XEventListener> const & xListener ) throw (RuntimeException, std::exception)
|
2004-04-13 11:07:59 +00:00
|
|
|
{
|
2012-11-15 17:28:16 +00:00
|
|
|
//Do not call check here. We must not throw an exception here if the object
|
|
|
|
//is being disposed or is already disposed. See com.sun.star.lang.XComponent
|
2004-06-11 11:11:31 +00:00
|
|
|
WeakComponentImplHelperBase::addEventListener( xListener );
|
2004-04-13 11:07:59 +00:00
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2004-06-11 11:11:31 +00:00
|
|
|
void Package::removeEventListener(
|
2014-02-25 21:31:58 +01:00
|
|
|
Reference<lang::XEventListener> const & xListener ) throw (RuntimeException, std::exception)
|
2004-04-13 11:07:59 +00:00
|
|
|
{
|
2012-11-15 17:28:16 +00:00
|
|
|
//Do not call check here. We must not throw an exception here if the object
|
|
|
|
//is being disposed or is already disposed. See com.sun.star.lang.XComponent
|
2004-06-11 11:11:31 +00:00
|
|
|
WeakComponentImplHelperBase::removeEventListener( xListener );
|
|
|
|
}
|
|
|
|
|
|
|
|
// XModifyBroadcaster
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2004-06-11 11:11:31 +00:00
|
|
|
void Package::addModifyListener(
|
|
|
|
Reference<util::XModifyListener> const & xListener )
|
2014-02-25 21:31:58 +01:00
|
|
|
throw (RuntimeException, std::exception)
|
2004-06-11 11:11:31 +00:00
|
|
|
{
|
|
|
|
check();
|
|
|
|
rBHelper.addListener( ::getCppuType( &xListener ), xListener );
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2004-06-11 11:11:31 +00:00
|
|
|
void Package::removeModifyListener(
|
|
|
|
Reference<util::XModifyListener> const & xListener )
|
2014-02-25 21:31:58 +01:00
|
|
|
throw (RuntimeException, std::exception)
|
2004-06-11 11:11:31 +00:00
|
|
|
{
|
|
|
|
check();
|
|
|
|
rBHelper.removeListener( ::getCppuType( &xListener ), xListener );
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2004-06-11 11:11:31 +00:00
|
|
|
void Package::checkAborted(
|
|
|
|
::rtl::Reference<AbortChannel> const & abortChannel )
|
|
|
|
{
|
2004-11-09 13:10:41 +00:00
|
|
|
if (abortChannel.is() && abortChannel->isAborted()) {
|
2004-06-11 11:11:31 +00:00
|
|
|
throw CommandAbortedException(
|
2012-12-30 11:10:48 +01:00
|
|
|
"abort!", static_cast<OWeakObject *>(this) );
|
2004-11-09 13:10:41 +00:00
|
|
|
}
|
2004-06-11 11:11:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// XPackage
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2004-06-11 11:11:31 +00:00
|
|
|
Reference<task::XAbortChannel> Package::createAbortChannel()
|
2014-02-25 21:31:58 +01:00
|
|
|
throw (RuntimeException, std::exception)
|
2004-06-11 11:11:31 +00:00
|
|
|
{
|
|
|
|
check();
|
|
|
|
return new AbortChannel;
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
sal_Bool Package::isBundle() throw (RuntimeException, std::exception)
|
2004-06-11 11:11:31 +00:00
|
|
|
{
|
|
|
|
return false; // default
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2010-04-19 11:33:33 +02:00
|
|
|
::sal_Int32 Package::checkPrerequisites(
|
2006-10-12 13:09:59 +00:00
|
|
|
const css::uno::Reference< css::task::XAbortChannel >&,
|
2006-12-20 13:30:03 +00:00
|
|
|
const css::uno::Reference< css::ucb::XCommandEnvironment >&,
|
2010-04-19 11:33:33 +02:00
|
|
|
sal_Bool)
|
2006-07-13 16:06:05 +00:00
|
|
|
throw (css::deployment::DeploymentException,
|
2010-03-22 12:35:33 +01:00
|
|
|
css::deployment::ExtensionRemovedException,
|
|
|
|
css::ucb::CommandFailedException,
|
|
|
|
css::ucb::CommandAbortedException,
|
2014-02-25 21:31:58 +01:00
|
|
|
css::uno::RuntimeException, std::exception)
|
2006-07-13 16:06:05 +00:00
|
|
|
{
|
2010-03-22 12:35:33 +01:00
|
|
|
if (m_bRemoved)
|
|
|
|
throw deployment::ExtensionRemovedException();
|
2010-04-19 11:33:33 +02:00
|
|
|
return 0;
|
2006-07-13 16:06:05 +00:00
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2014-04-03 13:52:06 +02:00
|
|
|
sal_Bool Package::checkDependencies(
|
2009-08-06 09:32:55 +00:00
|
|
|
const css::uno::Reference< css::ucb::XCommandEnvironment >& )
|
|
|
|
throw (css::deployment::DeploymentException,
|
2010-03-22 12:35:33 +01:00
|
|
|
css::deployment::ExtensionRemovedException,
|
|
|
|
css::ucb::CommandFailedException,
|
2014-02-25 21:31:58 +01:00
|
|
|
css::uno::RuntimeException, std::exception)
|
2009-08-06 09:32:55 +00:00
|
|
|
{
|
2010-03-22 12:35:33 +01:00
|
|
|
if (m_bRemoved)
|
|
|
|
throw deployment::ExtensionRemovedException();
|
2009-08-06 09:32:55 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2006-07-13 16:06:05 +00:00
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2004-06-11 11:11:31 +00:00
|
|
|
Sequence< Reference<deployment::XPackage> > Package::getBundle(
|
2006-10-12 13:09:59 +00:00
|
|
|
Reference<task::XAbortChannel> const &,
|
|
|
|
Reference<XCommandEnvironment> const & )
|
2004-06-11 11:11:31 +00:00
|
|
|
throw (deployment::DeploymentException,
|
|
|
|
CommandFailedException, CommandAbortedException,
|
2014-02-25 21:31:58 +01:00
|
|
|
lang::IllegalArgumentException, RuntimeException, std::exception)
|
2004-06-11 11:11:31 +00:00
|
|
|
{
|
|
|
|
return Sequence< Reference<deployment::XPackage> >();
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
OUString Package::getName() throw (RuntimeException, std::exception)
|
2004-06-11 11:11:31 +00:00
|
|
|
{
|
|
|
|
return m_name;
|
|
|
|
}
|
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
beans::Optional<OUString> Package::getIdentifier() throw (RuntimeException, std::exception)
|
2006-12-20 13:30:03 +00:00
|
|
|
{
|
2010-03-22 12:35:33 +01:00
|
|
|
if (m_bRemoved)
|
|
|
|
return beans::Optional<OUString>(true, m_identifier);
|
|
|
|
|
2006-12-20 13:30:03 +00:00
|
|
|
return beans::Optional<OUString>();
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2010-03-22 12:35:33 +01:00
|
|
|
OUString Package::getVersion() throw (
|
|
|
|
deployment::ExtensionRemovedException,
|
2014-02-25 21:31:58 +01:00
|
|
|
RuntimeException, std::exception)
|
2006-10-04 15:55:05 +00:00
|
|
|
{
|
2010-03-22 12:35:33 +01:00
|
|
|
if (m_bRemoved)
|
|
|
|
throw deployment::ExtensionRemovedException();
|
2006-10-04 15:55:05 +00:00
|
|
|
return OUString();
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
OUString Package::getURL() throw (RuntimeException, std::exception)
|
2004-06-11 11:11:31 +00:00
|
|
|
{
|
|
|
|
return m_url;
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2010-03-22 12:35:33 +01:00
|
|
|
OUString Package::getDisplayName() throw (
|
2014-02-25 21:31:58 +01:00
|
|
|
deployment::ExtensionRemovedException, RuntimeException, std::exception)
|
2004-06-11 11:11:31 +00:00
|
|
|
{
|
2010-03-22 12:35:33 +01:00
|
|
|
if (m_bRemoved)
|
|
|
|
throw deployment::ExtensionRemovedException();
|
2004-06-11 11:11:31 +00:00
|
|
|
return m_displayName;
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2010-03-22 12:35:33 +01:00
|
|
|
OUString Package::getDescription() throw (
|
2014-02-25 21:31:58 +01:00
|
|
|
deployment::ExtensionRemovedException,RuntimeException, std::exception)
|
2004-06-11 11:11:31 +00:00
|
|
|
{
|
2010-03-22 12:35:33 +01:00
|
|
|
if (m_bRemoved)
|
|
|
|
throw deployment::ExtensionRemovedException();
|
2008-07-17 10:47:48 +00:00
|
|
|
return OUString();
|
2004-06-11 11:11:31 +00:00
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2010-09-28 10:03:56 +02:00
|
|
|
OUString Package::getLicenseText() throw (
|
2014-02-25 21:31:58 +01:00
|
|
|
deployment::ExtensionRemovedException,RuntimeException, std::exception)
|
2010-09-28 10:03:56 +02:00
|
|
|
{
|
|
|
|
if (m_bRemoved)
|
|
|
|
throw deployment::ExtensionRemovedException();
|
|
|
|
return OUString();
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2010-03-22 12:35:33 +01:00
|
|
|
Sequence<OUString> Package::getUpdateInformationURLs() throw (
|
2014-02-25 21:31:58 +01:00
|
|
|
deployment::ExtensionRemovedException, RuntimeException, std::exception)
|
2006-12-20 13:30:03 +00:00
|
|
|
{
|
2010-03-22 12:35:33 +01:00
|
|
|
if (m_bRemoved)
|
|
|
|
throw deployment::ExtensionRemovedException();
|
2006-12-20 13:30:03 +00:00
|
|
|
return Sequence<OUString>();
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2010-03-22 12:35:33 +01:00
|
|
|
css::beans::StringPair Package::getPublisherInfo() throw (
|
2014-02-25 21:31:58 +01:00
|
|
|
deployment::ExtensionRemovedException, RuntimeException, std::exception)
|
2008-06-06 07:10:59 +00:00
|
|
|
{
|
2010-03-22 12:35:33 +01:00
|
|
|
if (m_bRemoved)
|
|
|
|
throw deployment::ExtensionRemovedException();
|
2008-06-06 07:10:59 +00:00
|
|
|
css::beans::StringPair aEmptyPair;
|
|
|
|
return aEmptyPair;
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2010-03-22 12:35:33 +01:00
|
|
|
uno::Reference< css::graphic::XGraphic > Package::getIcon( sal_Bool /*bHighContrast*/ )
|
2014-02-25 21:31:58 +01:00
|
|
|
throw (deployment::ExtensionRemovedException, RuntimeException, std::exception )
|
2008-06-16 11:55:58 +00:00
|
|
|
{
|
2010-03-22 12:35:33 +01:00
|
|
|
if (m_bRemoved)
|
|
|
|
throw deployment::ExtensionRemovedException();
|
|
|
|
|
2008-06-16 11:55:58 +00:00
|
|
|
uno::Reference< css::graphic::XGraphic > aEmpty;
|
|
|
|
return aEmpty;
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2004-11-09 13:10:41 +00:00
|
|
|
Reference<deployment::XPackageTypeInfo> Package::getPackageType()
|
2014-02-25 21:31:58 +01:00
|
|
|
throw (RuntimeException, std::exception)
|
2004-06-11 11:11:31 +00:00
|
|
|
{
|
2004-11-09 13:10:41 +00:00
|
|
|
return m_xPackageType;
|
2004-06-11 11:11:31 +00:00
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2004-08-12 11:09:42 +00:00
|
|
|
void Package::exportTo(
|
|
|
|
OUString const & destFolderURL, OUString const & newTitle,
|
|
|
|
sal_Int32 nameClashAction, Reference<XCommandEnvironment> const & xCmdEnv )
|
2010-03-22 12:35:33 +01:00
|
|
|
throw (deployment::ExtensionRemovedException,
|
2014-02-25 21:31:58 +01:00
|
|
|
CommandFailedException, CommandAbortedException, RuntimeException, std::exception)
|
2004-08-12 11:09:42 +00:00
|
|
|
{
|
2010-03-22 12:35:33 +01:00
|
|
|
if (m_bRemoved)
|
|
|
|
throw deployment::ExtensionRemovedException();
|
|
|
|
|
2012-09-14 18:08:57 +02:00
|
|
|
::ucbhelper::Content destFolder( destFolderURL, xCmdEnv, getMyBackend()->getComponentContext() );
|
|
|
|
::ucbhelper::Content sourceContent( getURL(), xCmdEnv, getMyBackend()->getComponentContext() );
|
2004-08-12 11:09:42 +00:00
|
|
|
if (! destFolder.transferContent(
|
2007-06-05 14:06:01 +00:00
|
|
|
sourceContent, ::ucbhelper::InsertOperation_COPY,
|
2004-08-12 11:09:42 +00:00
|
|
|
newTitle, nameClashAction ))
|
2012-12-30 11:10:48 +01:00
|
|
|
throw RuntimeException( "UCB transferContent() failed!", 0 );
|
2004-08-12 11:09:42 +00:00
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2004-06-11 11:11:31 +00:00
|
|
|
void Package::fireModified()
|
|
|
|
{
|
|
|
|
::cppu::OInterfaceContainerHelper * container = rBHelper.getContainer(
|
|
|
|
::getCppuType( static_cast<Reference<
|
|
|
|
util::XModifyListener> const *>(0) ) );
|
2004-08-12 11:09:42 +00:00
|
|
|
if (container != 0) {
|
2004-06-11 11:11:31 +00:00
|
|
|
Sequence< Reference<XInterface> > elements(
|
|
|
|
container->getElements() );
|
|
|
|
lang::EventObject evt( static_cast<OWeakObject *>(this) );
|
2004-11-09 13:10:41 +00:00
|
|
|
for ( sal_Int32 pos = 0; pos < elements.getLength(); ++pos )
|
|
|
|
{
|
2004-06-11 11:11:31 +00:00
|
|
|
Reference<util::XModifyListener> xListener(
|
|
|
|
elements[ pos ], UNO_QUERY );
|
|
|
|
if (xListener.is())
|
|
|
|
xListener->modified( evt );
|
|
|
|
}
|
2004-04-13 11:07:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-06-11 11:11:31 +00:00
|
|
|
// XPackage
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2004-08-12 11:09:42 +00:00
|
|
|
beans::Optional< beans::Ambiguous<sal_Bool> > Package::isRegistered(
|
2004-06-11 11:11:31 +00:00
|
|
|
Reference<task::XAbortChannel> const & xAbortChannel,
|
|
|
|
Reference<XCommandEnvironment> const & xCmdEnv )
|
|
|
|
throw (deployment::DeploymentException,
|
2014-02-25 21:31:58 +01:00
|
|
|
CommandFailedException, CommandAbortedException, RuntimeException, std::exception)
|
2004-04-13 11:07:59 +00:00
|
|
|
{
|
2004-08-12 11:09:42 +00:00
|
|
|
try {
|
2004-04-13 11:07:59 +00:00
|
|
|
::osl::ResettableMutexGuard guard( getMutex() );
|
2004-08-12 11:09:42 +00:00
|
|
|
return isRegistered_( guard,
|
|
|
|
AbortChannel::get(xAbortChannel),
|
|
|
|
xCmdEnv );
|
2004-04-13 11:07:59 +00:00
|
|
|
}
|
2011-12-06 00:19:44 +09:00
|
|
|
catch (const RuntimeException &) {
|
2004-06-11 11:11:31 +00:00
|
|
|
throw;
|
|
|
|
}
|
2011-12-06 00:19:44 +09:00
|
|
|
catch (const CommandFailedException &) {
|
2004-06-11 11:11:31 +00:00
|
|
|
throw;
|
|
|
|
}
|
2011-12-06 00:19:44 +09:00
|
|
|
catch (const CommandAbortedException &) {
|
2004-06-11 11:11:31 +00:00
|
|
|
throw;
|
|
|
|
}
|
2011-12-06 00:19:44 +09:00
|
|
|
catch (const deployment::DeploymentException &) {
|
2004-06-11 11:11:31 +00:00
|
|
|
throw;
|
|
|
|
}
|
2011-12-06 00:19:44 +09:00
|
|
|
catch (const Exception &) {
|
2004-06-11 11:11:31 +00:00
|
|
|
Any exc( ::cppu::getCaughtException() );
|
|
|
|
throw deployment::DeploymentException(
|
2012-12-30 11:10:48 +01:00
|
|
|
"unexpected exception occurred!",
|
2004-06-11 11:11:31 +00:00
|
|
|
static_cast<OWeakObject *>(this), exc );
|
2004-04-13 11:07:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2006-10-12 13:09:59 +00:00
|
|
|
void Package::processPackage_impl(
|
|
|
|
bool doRegisterPackage,
|
2010-04-21 16:04:34 +02:00
|
|
|
bool startup,
|
2004-06-11 11:11:31 +00:00
|
|
|
Reference<task::XAbortChannel> const & xAbortChannel,
|
|
|
|
Reference<XCommandEnvironment> const & xCmdEnv )
|
2004-04-13 11:07:59 +00:00
|
|
|
{
|
|
|
|
check();
|
2004-11-09 13:10:41 +00:00
|
|
|
bool action = false;
|
2004-06-11 11:11:31 +00:00
|
|
|
|
2004-08-12 11:09:42 +00:00
|
|
|
try {
|
2004-11-09 13:10:41 +00:00
|
|
|
try {
|
|
|
|
::osl::ResettableMutexGuard guard( getMutex() );
|
|
|
|
beans::Optional< beans::Ambiguous<sal_Bool> > option(
|
|
|
|
isRegistered_( guard, AbortChannel::get(xAbortChannel),
|
|
|
|
xCmdEnv ) );
|
|
|
|
action = (option.IsPresent &&
|
|
|
|
(option.Value.IsAmbiguous ||
|
2006-10-12 13:09:59 +00:00
|
|
|
(doRegisterPackage ? !option.Value.Value
|
2004-11-09 13:10:41 +00:00
|
|
|
: option.Value.Value)));
|
|
|
|
if (action) {
|
2010-03-22 12:35:33 +01:00
|
|
|
|
|
|
|
OUString displayName = isRemoved() ? getName() : getDisplayName();
|
2004-11-09 13:10:41 +00:00
|
|
|
ProgressLevel progress(
|
|
|
|
xCmdEnv,
|
2006-10-12 13:09:59 +00:00
|
|
|
(doRegisterPackage
|
2004-11-09 13:10:41 +00:00
|
|
|
? PackageRegistryBackend::StrRegisteringPackage::get()
|
|
|
|
: PackageRegistryBackend::StrRevokingPackage::get())
|
|
|
|
+ displayName );
|
|
|
|
processPackage_( guard,
|
2006-10-12 13:09:59 +00:00
|
|
|
doRegisterPackage,
|
2010-04-21 16:04:34 +02:00
|
|
|
startup,
|
2004-11-09 13:10:41 +00:00
|
|
|
AbortChannel::get(xAbortChannel),
|
|
|
|
xCmdEnv );
|
|
|
|
}
|
|
|
|
}
|
2013-02-05 12:52:46 +01:00
|
|
|
catch (lang::IllegalArgumentException &) {
|
|
|
|
Any e(cppu::getCaughtException());
|
|
|
|
throw deployment::DeploymentException(
|
|
|
|
((doRegisterPackage
|
|
|
|
? getResourceString(RID_STR_ERROR_WHILE_REGISTERING)
|
|
|
|
: getResourceString(RID_STR_ERROR_WHILE_REVOKING))
|
|
|
|
+ getDisplayName()),
|
|
|
|
static_cast< OWeakObject * >(this), e);
|
|
|
|
}
|
2011-12-06 00:19:44 +09:00
|
|
|
catch (const RuntimeException &e) {
|
2011-11-23 15:45:43 +01:00
|
|
|
SAL_WARN(
|
2012-07-20 11:10:05 +02:00
|
|
|
"desktop.deployment",
|
|
|
|
"unexpected RuntimeException \"" << e.Message << '"');
|
2004-11-09 13:10:41 +00:00
|
|
|
throw;
|
|
|
|
}
|
2011-12-06 00:19:44 +09:00
|
|
|
catch (const CommandFailedException &) {
|
2004-11-09 13:10:41 +00:00
|
|
|
throw;
|
|
|
|
}
|
2011-12-06 00:19:44 +09:00
|
|
|
catch (const CommandAbortedException &) {
|
2004-11-09 13:10:41 +00:00
|
|
|
throw;
|
|
|
|
}
|
2011-12-06 00:19:44 +09:00
|
|
|
catch (const deployment::DeploymentException &) {
|
2004-11-09 13:10:41 +00:00
|
|
|
throw;
|
|
|
|
}
|
2011-12-06 00:19:44 +09:00
|
|
|
catch (const Exception &) {
|
2004-11-09 13:10:41 +00:00
|
|
|
Any exc( ::cppu::getCaughtException() );
|
|
|
|
throw deployment::DeploymentException(
|
2006-10-12 13:09:59 +00:00
|
|
|
(doRegisterPackage
|
2004-11-09 13:10:41 +00:00
|
|
|
? getResourceString(RID_STR_ERROR_WHILE_REGISTERING)
|
|
|
|
: getResourceString(RID_STR_ERROR_WHILE_REVOKING))
|
|
|
|
+ getDisplayName(), static_cast<OWeakObject *>(this), exc );
|
2004-04-13 11:07:59 +00:00
|
|
|
}
|
|
|
|
}
|
2004-11-09 13:10:41 +00:00
|
|
|
catch (...) {
|
|
|
|
if (action)
|
|
|
|
fireModified();
|
2004-04-13 11:07:59 +00:00
|
|
|
throw;
|
|
|
|
}
|
2004-11-09 13:10:41 +00:00
|
|
|
if (action)
|
2004-06-11 11:11:31 +00:00
|
|
|
fireModified();
|
2004-11-09 13:10:41 +00:00
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2004-11-09 13:10:41 +00:00
|
|
|
void Package::registerPackage(
|
2010-04-21 16:04:34 +02:00
|
|
|
sal_Bool startup,
|
2004-11-09 13:10:41 +00:00
|
|
|
Reference<task::XAbortChannel> const & xAbortChannel,
|
|
|
|
Reference<XCommandEnvironment> const & xCmdEnv )
|
|
|
|
throw (deployment::DeploymentException,
|
2010-03-22 12:35:33 +01:00
|
|
|
deployment::ExtensionRemovedException,
|
2004-11-09 13:10:41 +00:00
|
|
|
CommandFailedException, CommandAbortedException,
|
2014-02-25 21:31:58 +01:00
|
|
|
lang::IllegalArgumentException, RuntimeException, std::exception)
|
2004-11-09 13:10:41 +00:00
|
|
|
{
|
2010-03-22 12:35:33 +01:00
|
|
|
if (m_bRemoved)
|
|
|
|
throw deployment::ExtensionRemovedException();
|
2010-04-21 16:04:34 +02:00
|
|
|
processPackage_impl( true /* register */, startup, xAbortChannel, xCmdEnv );
|
2004-04-13 11:07:59 +00:00
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2004-06-11 11:11:31 +00:00
|
|
|
void Package::revokePackage(
|
2012-04-26 16:06:30 +02:00
|
|
|
sal_Bool startup,
|
2004-06-11 11:11:31 +00:00
|
|
|
Reference<task::XAbortChannel> const & xAbortChannel,
|
|
|
|
Reference<XCommandEnvironment> const & xCmdEnv )
|
|
|
|
throw (deployment::DeploymentException,
|
|
|
|
CommandFailedException, CommandAbortedException,
|
2014-02-25 21:31:58 +01:00
|
|
|
lang::IllegalArgumentException, RuntimeException, std::exception)
|
2004-04-13 11:07:59 +00:00
|
|
|
{
|
2012-04-26 16:06:30 +02:00
|
|
|
processPackage_impl( false /* revoke */, startup, xAbortChannel, xCmdEnv );
|
2010-05-04 12:37:01 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
PackageRegistryBackend * Package::getMyBackend() const
|
|
|
|
{
|
|
|
|
PackageRegistryBackend * pBackend = m_myBackend.get();
|
|
|
|
if (NULL == pBackend)
|
|
|
|
{
|
|
|
|
//May throw a DisposedException
|
|
|
|
check();
|
|
|
|
//We should never get here...
|
|
|
|
throw RuntimeException(
|
2012-12-30 11:10:48 +01:00
|
|
|
"Failed to get the BackendImpl",
|
2010-05-04 12:37:01 +02:00
|
|
|
static_cast<OWeakObject*>(const_cast<Package *>(this)));
|
|
|
|
}
|
|
|
|
return pBackend;
|
2004-11-09 13:10:41 +00:00
|
|
|
}
|
2010-05-04 12:37:01 +02:00
|
|
|
OUString Package::getRepositoryName()
|
2014-02-25 21:31:58 +01:00
|
|
|
throw (RuntimeException, std::exception)
|
2010-05-04 12:37:01 +02:00
|
|
|
{
|
|
|
|
PackageRegistryBackend * backEnd = getMyBackend();
|
|
|
|
return backEnd->getContext();
|
2010-03-22 12:35:33 +01:00
|
|
|
}
|
|
|
|
|
2010-04-06 17:15:01 +02:00
|
|
|
beans::Optional< OUString > Package::getRegistrationDataURL()
|
|
|
|
throw (deployment::ExtensionRemovedException,
|
2014-02-25 21:31:58 +01:00
|
|
|
css::uno::RuntimeException, std::exception)
|
2010-04-06 17:15:01 +02:00
|
|
|
{
|
|
|
|
if (m_bRemoved)
|
|
|
|
throw deployment::ExtensionRemovedException();
|
|
|
|
return beans::Optional<OUString>();
|
|
|
|
}
|
|
|
|
|
2010-03-22 12:35:33 +01:00
|
|
|
sal_Bool Package::isRemoved()
|
2014-02-25 21:31:58 +01:00
|
|
|
throw (RuntimeException, std::exception)
|
2010-03-22 12:35:33 +01:00
|
|
|
{
|
|
|
|
return m_bRemoved;
|
|
|
|
}
|
2004-06-11 11:11:31 +00:00
|
|
|
|
2004-11-09 13:10:41 +00:00
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2004-11-09 13:10:41 +00:00
|
|
|
Package::TypeInfo::~TypeInfo()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// XPackageTypeInfo
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
OUString Package::TypeInfo::getMediaType() throw (RuntimeException, std::exception)
|
2004-11-09 13:10:41 +00:00
|
|
|
{
|
|
|
|
return m_mediaType;
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2010-03-22 12:35:33 +01:00
|
|
|
OUString Package::TypeInfo::getDescription()
|
2014-02-25 21:31:58 +01:00
|
|
|
throw (deployment::ExtensionRemovedException, RuntimeException, std::exception)
|
2004-11-09 13:10:41 +00:00
|
|
|
{
|
|
|
|
return getShortDescription();
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2010-03-22 12:35:33 +01:00
|
|
|
OUString Package::TypeInfo::getShortDescription()
|
2014-02-25 21:31:58 +01:00
|
|
|
throw (deployment::ExtensionRemovedException, RuntimeException, std::exception)
|
2004-11-09 13:10:41 +00:00
|
|
|
{
|
|
|
|
return m_shortDescr;
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
OUString Package::TypeInfo::getFileFilter() throw (RuntimeException, std::exception)
|
2004-11-09 13:10:41 +00:00
|
|
|
{
|
|
|
|
return m_fileFilter;
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2010-11-11 14:30:42 +01:00
|
|
|
/**************************
|
|
|
|
* Get Icon
|
|
|
|
*
|
|
|
|
* @param highContrast NOTE: disabled the returning of high contrast icons.
|
|
|
|
* This bool is a noop now.
|
|
|
|
* @param smallIcon Return the small version of the icon
|
|
|
|
*/
|
2010-11-11 16:01:55 +00:00
|
|
|
Any Package::TypeInfo::getIcon( sal_Bool /*highContrast*/, sal_Bool smallIcon )
|
2014-02-25 21:31:58 +01:00
|
|
|
throw (RuntimeException, std::exception)
|
2004-11-09 13:10:41 +00:00
|
|
|
{
|
|
|
|
if (! smallIcon)
|
|
|
|
return Any();
|
2010-11-11 14:30:42 +01:00
|
|
|
const sal_uInt16 nIconId = m_smallIcon;
|
2005-01-21 16:12:57 +00:00
|
|
|
return Any( &nIconId, getCppuType( static_cast<sal_uInt16 const *>(0) ) );
|
2004-04-13 11:07:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-12 15:53:47 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|