Files
libreoffice/desktop/source/deployment/registry/dp_backend.cxx

831 lines
25 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
re-base on ALv2 code. Includes: Patch contributed by: Jurgen Schmidt remove onlineregistration with dependencies http://svn.apache.org/viewvc?view=revision&revision=1240245 imported patch package_eventlistener.patch http://svn.apache.org/viewvc?view=revision&revision=1172103 Patch contributed by Pedro Giffuni Accept Google Chrome OS fonts as equivalent to MS fonts. http://svn.apache.org/viewvc?view=revision&revision=1233155 http://svn.apache.org/viewvc?view=revision&revision=1233408 Patch contributed by Andre Fischer Do not add targets for junit tests when junit is disabled. http://svn.apache.org/viewvc?view=revision&revision=1241508 Patches contributed by Mathias Bauer (and others) gnumake4 work variously http://svn.apache.org/viewvc?view=revision&revision=1394707 http://svn.apache.org/viewvc?view=revision&revision=1394326 cws mba34issues01: #i114600#: remove forbidden characters from list of unencoded characters http://svn.apache.org/viewvc?view=revision&revision=1172370 Patches contributed by Oliver Rainer-Wittman some clean up in JPEGReader due to memory constraints http://svn.apache.org/viewvc?view=revision&revision=1299729 119114 - method <UpdateDialog::addSpecificError(..)> - create entry with correct type http://svn.apache.org/viewvc?view=revision&revision=1305265 Patches contributed by Ariel Constenla-Haile i118707 - make toolbar control's popup window grab focus http://svn.apache.org/viewvc?view=revision&revision=1225846 Patches contributed by Herbert Duerr #i118662# remove usage of BerkeleyDB in desktop module http://svn.apache.org/viewvc?view=revision&revision=1213171 minor cleanups in dp_persmap.* http://svn.apache.org/viewvc?view=revision&revision=1215064 flush early to prevent problem with extension manager not cleaning up its objects http://svn.apache.org/viewvc?view=revision&revision=1228147 i118726 do not flush *pmap file while reading it http://svn.apache.org/viewvc?view=revision&revision=1230614 #i119048# migrate BDB extension entries using a simple heuristic http://svn.apache.org/viewvc?view=revision&revision=1300972 #i119048# handle edge cases when importing BDB hash files http://svn.apache.org/viewvc?view=revision&revision=1301428 #i119113# fix of-by-one when importing BDB files http://svn.apache.org/viewvc?view=revision&revision=1305420 restore our encryption settings, icon themes, and dictionaries. removed wrapper hacks, kill obsolete bundled extension blob / pre-registration handling, remove duplicated quickstart code. remove OS/2 conditionals.
2012-11-15 17:28:16 +00:00
/*
* This file is part of the LibreOffice project.
*
re-base on ALv2 code. Includes: Patch contributed by: Jurgen Schmidt remove onlineregistration with dependencies http://svn.apache.org/viewvc?view=revision&revision=1240245 imported patch package_eventlistener.patch http://svn.apache.org/viewvc?view=revision&revision=1172103 Patch contributed by Pedro Giffuni Accept Google Chrome OS fonts as equivalent to MS fonts. http://svn.apache.org/viewvc?view=revision&revision=1233155 http://svn.apache.org/viewvc?view=revision&revision=1233408 Patch contributed by Andre Fischer Do not add targets for junit tests when junit is disabled. http://svn.apache.org/viewvc?view=revision&revision=1241508 Patches contributed by Mathias Bauer (and others) gnumake4 work variously http://svn.apache.org/viewvc?view=revision&revision=1394707 http://svn.apache.org/viewvc?view=revision&revision=1394326 cws mba34issues01: #i114600#: remove forbidden characters from list of unencoded characters http://svn.apache.org/viewvc?view=revision&revision=1172370 Patches contributed by Oliver Rainer-Wittman some clean up in JPEGReader due to memory constraints http://svn.apache.org/viewvc?view=revision&revision=1299729 119114 - method <UpdateDialog::addSpecificError(..)> - create entry with correct type http://svn.apache.org/viewvc?view=revision&revision=1305265 Patches contributed by Ariel Constenla-Haile i118707 - make toolbar control's popup window grab focus http://svn.apache.org/viewvc?view=revision&revision=1225846 Patches contributed by Herbert Duerr #i118662# remove usage of BerkeleyDB in desktop module http://svn.apache.org/viewvc?view=revision&revision=1213171 minor cleanups in dp_persmap.* http://svn.apache.org/viewvc?view=revision&revision=1215064 flush early to prevent problem with extension manager not cleaning up its objects http://svn.apache.org/viewvc?view=revision&revision=1228147 i118726 do not flush *pmap file while reading it http://svn.apache.org/viewvc?view=revision&revision=1230614 #i119048# migrate BDB extension entries using a simple heuristic http://svn.apache.org/viewvc?view=revision&revision=1300972 #i119048# handle edge cases when importing BDB hash files http://svn.apache.org/viewvc?view=revision&revision=1301428 #i119113# fix of-by-one when importing BDB files http://svn.apache.org/viewvc?view=revision&revision=1305420 restore our encryption settings, icon themes, and dictionaries. removed wrapper hacks, kill obsolete bundled extension blob / pre-registration handling, remove duplicated quickstart code. remove OS/2 conditionals.
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/.
*
re-base on ALv2 code. Includes: Patch contributed by: Jurgen Schmidt remove onlineregistration with dependencies http://svn.apache.org/viewvc?view=revision&revision=1240245 imported patch package_eventlistener.patch http://svn.apache.org/viewvc?view=revision&revision=1172103 Patch contributed by Pedro Giffuni Accept Google Chrome OS fonts as equivalent to MS fonts. http://svn.apache.org/viewvc?view=revision&revision=1233155 http://svn.apache.org/viewvc?view=revision&revision=1233408 Patch contributed by Andre Fischer Do not add targets for junit tests when junit is disabled. http://svn.apache.org/viewvc?view=revision&revision=1241508 Patches contributed by Mathias Bauer (and others) gnumake4 work variously http://svn.apache.org/viewvc?view=revision&revision=1394707 http://svn.apache.org/viewvc?view=revision&revision=1394326 cws mba34issues01: #i114600#: remove forbidden characters from list of unencoded characters http://svn.apache.org/viewvc?view=revision&revision=1172370 Patches contributed by Oliver Rainer-Wittman some clean up in JPEGReader due to memory constraints http://svn.apache.org/viewvc?view=revision&revision=1299729 119114 - method <UpdateDialog::addSpecificError(..)> - create entry with correct type http://svn.apache.org/viewvc?view=revision&revision=1305265 Patches contributed by Ariel Constenla-Haile i118707 - make toolbar control's popup window grab focus http://svn.apache.org/viewvc?view=revision&revision=1225846 Patches contributed by Herbert Duerr #i118662# remove usage of BerkeleyDB in desktop module http://svn.apache.org/viewvc?view=revision&revision=1213171 minor cleanups in dp_persmap.* http://svn.apache.org/viewvc?view=revision&revision=1215064 flush early to prevent problem with extension manager not cleaning up its objects http://svn.apache.org/viewvc?view=revision&revision=1228147 i118726 do not flush *pmap file while reading it http://svn.apache.org/viewvc?view=revision&revision=1230614 #i119048# migrate BDB extension entries using a simple heuristic http://svn.apache.org/viewvc?view=revision&revision=1300972 #i119048# handle edge cases when importing BDB hash files http://svn.apache.org/viewvc?view=revision&revision=1301428 #i119113# fix of-by-one when importing BDB files http://svn.apache.org/viewvc?view=revision&revision=1305420 restore our encryption settings, icon themes, and dictionaries. removed wrapper hacks, kill obsolete bundled extension blob / pre-registration handling, remove duplicated quickstart code. remove OS/2 conditionals.
2012-11-15 17:28:16 +00:00
* This file incorporates work covered by the following license notice:
*
re-base on ALv2 code. Includes: Patch contributed by: Jurgen Schmidt remove onlineregistration with dependencies http://svn.apache.org/viewvc?view=revision&revision=1240245 imported patch package_eventlistener.patch http://svn.apache.org/viewvc?view=revision&revision=1172103 Patch contributed by Pedro Giffuni Accept Google Chrome OS fonts as equivalent to MS fonts. http://svn.apache.org/viewvc?view=revision&revision=1233155 http://svn.apache.org/viewvc?view=revision&revision=1233408 Patch contributed by Andre Fischer Do not add targets for junit tests when junit is disabled. http://svn.apache.org/viewvc?view=revision&revision=1241508 Patches contributed by Mathias Bauer (and others) gnumake4 work variously http://svn.apache.org/viewvc?view=revision&revision=1394707 http://svn.apache.org/viewvc?view=revision&revision=1394326 cws mba34issues01: #i114600#: remove forbidden characters from list of unencoded characters http://svn.apache.org/viewvc?view=revision&revision=1172370 Patches contributed by Oliver Rainer-Wittman some clean up in JPEGReader due to memory constraints http://svn.apache.org/viewvc?view=revision&revision=1299729 119114 - method <UpdateDialog::addSpecificError(..)> - create entry with correct type http://svn.apache.org/viewvc?view=revision&revision=1305265 Patches contributed by Ariel Constenla-Haile i118707 - make toolbar control's popup window grab focus http://svn.apache.org/viewvc?view=revision&revision=1225846 Patches contributed by Herbert Duerr #i118662# remove usage of BerkeleyDB in desktop module http://svn.apache.org/viewvc?view=revision&revision=1213171 minor cleanups in dp_persmap.* http://svn.apache.org/viewvc?view=revision&revision=1215064 flush early to prevent problem with extension manager not cleaning up its objects http://svn.apache.org/viewvc?view=revision&revision=1228147 i118726 do not flush *pmap file while reading it http://svn.apache.org/viewvc?view=revision&revision=1230614 #i119048# migrate BDB extension entries using a simple heuristic http://svn.apache.org/viewvc?view=revision&revision=1300972 #i119048# handle edge cases when importing BDB hash files http://svn.apache.org/viewvc?view=revision&revision=1301428 #i119113# fix of-by-one when importing BDB files http://svn.apache.org/viewvc?view=revision&revision=1305420 restore our encryption settings, icon themes, and dictionaries. removed wrapper hacks, kill obsolete bundled extension blob / pre-registration handling, remove duplicated quickstart code. remove OS/2 conditionals.
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 .
*/
#include "sal/config.h"
#include <cassert>
#include "dp_backend.h"
#include "dp_ucb.h"
#include "rtl/ustring.hxx"
#include "rtl/uri.hxx"
#include "rtl/bootstrap.hxx"
#include "osl/file.hxx"
#include "cppuhelper/exc_hlp.hxx"
#include "comphelper/servicedecl.hxx"
#include "comphelper/unwrapargs.hxx"
#include "ucbhelper/content.hxx"
#include "com/sun/star/lang/WrappedTargetRuntimeException.hpp"
#include "com/sun/star/deployment/InvalidRemovedParameterException.hpp"
#include "com/sun/star/deployment/thePackageManagerFactory.hpp"
#include "com/sun/star/ucb/InteractiveAugmentedIOException.hpp"
#include "com/sun/star/ucb/IOErrorCode.hpp"
#include "com/sun/star/beans/StringPair.hpp"
#include "com/sun/star/sdbc/XResultSet.hpp"
#include "com/sun/star/sdbc/XRow.hpp"
#include "unotools/tempfile.hxx"
using namespace ::dp_misc;
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::ucb;
namespace dp_registry {
namespace backend {
PackageRegistryBackend::~PackageRegistryBackend()
{
}
void PackageRegistryBackend::disposing( lang::EventObject const & event )
throw (RuntimeException, std::exception)
{
Reference<deployment::XPackage> xPackage(
event.Source, UNO_QUERY_THROW );
OUString url( xPackage->getURL() );
::osl::MutexGuard guard( getMutex() );
if ( m_bound.erase( url ) != 1 )
{
SAL_WARN("desktop.deployment", "erase(" << url << ") != 1");
}
}
PackageRegistryBackend::PackageRegistryBackend(
Sequence<Any> const & args,
Reference<XComponentContext> const & xContext )
: t_BackendBase( getMutex() ),
m_xComponentContext( xContext ),
m_eContext( CONTEXT_UNKNOWN ),
m_readOnly( false )
{
assert(xContext.is());
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;
if ( m_context == "user" )
m_eContext = CONTEXT_USER;
else if ( m_context == "shared" )
m_eContext = CONTEXT_SHARED;
else if ( m_context == "bundled" )
m_eContext = CONTEXT_BUNDLED;
else if ( m_context == "tmp" )
m_eContext = CONTEXT_TMP;
else if (m_context.matchIgnoreAsciiCase("vnd.sun.star.tdoc:/"))
m_eContext = CONTEXT_DOCUMENT;
else
m_eContext = CONTEXT_UNKNOWN;
}
void PackageRegistryBackend::check()
{
::osl::MutexGuard guard( getMutex() );
if (rBHelper.bInDispose || rBHelper.bDisposed) {
throw lang::DisposedException(
"PackageRegistryBackend instance has already been disposed!",
static_cast<OWeakObject *>(this) );
}
}
void PackageRegistryBackend::disposing()
{
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();
m_xComponentContext.clear();
WeakComponentImplHelperBase::disposing();
}
2011-12-06 00:19:44 +09:00
catch (const RuntimeException &) {
throw;
}
2011-12-06 00:19:44 +09:00
catch (const Exception &) {
Any exc( ::cppu::getCaughtException() );
throw lang::WrappedTargetRuntimeException(
"caught unexpected exception while disposing!",
static_cast<OWeakObject *>(this), exc );
}
}
// XPackageRegistry
Reference<deployment::XPackage> PackageRegistryBackend::bindPackage(
OUString const & url, OUString const & mediaType, sal_Bool bRemoved,
OUString const & identifier, Reference<XCommandEnvironment> const & xCmdEnv )
throw (deployment::DeploymentException,
deployment::InvalidRemovedParameterException,
ucb::CommandFailedException,
lang::IllegalArgumentException, RuntimeException, std::exception)
{
::osl::ResettableMutexGuard guard( getMutex() );
check();
t_string2ref::const_iterator const iFind( m_bound.find( url ) );
if (iFind != m_bound.end())
{
Reference<deployment::XPackage> xPackage( iFind->second );
if (xPackage.is())
{
if (!mediaType.isEmpty() &&
mediaType != xPackage->getPackageType()->getMediaType())
throw lang::IllegalArgumentException
("XPackageRegistry::bindPackage: media type does not match",
static_cast<OWeakObject*>(this), 1);
if (xPackage->isRemoved() != bRemoved)
throw deployment::InvalidRemovedParameterException(
"XPackageRegistry::bindPackage: bRemoved parameter does not match",
static_cast<OWeakObject*>(this), xPackage->isRemoved(), xPackage);
return xPackage;
}
}
guard.clear();
Reference<deployment::XPackage> xNewPackage;
try {
xNewPackage = bindPackage_( url, mediaType, bRemoved,
identifier, xCmdEnv );
}
2011-12-06 00:19:44 +09:00
catch (const RuntimeException &) {
throw;
}
2011-12-06 00:19:44 +09:00
catch (const CommandFailedException &) {
throw;
}
2011-12-06 00:19:44 +09:00
catch (const deployment::DeploymentException &) {
throw;
}
2011-12-06 00:19:44 +09:00
catch (const Exception &) {
Any exc( ::cppu::getCaughtException() );
throw deployment::DeploymentException(
"Error binding package: " + url,
static_cast<OWeakObject *>(this), exc );
}
guard.reset();
::std::pair< t_string2ref::iterator, bool > insertion(
m_bound.insert( t_string2ref::value_type( url, xNewPackage ) ) );
if (insertion.second)
{ // first insertion
SAL_WARN_IF(
Reference<XInterface>(insertion.first->second) != xNewPackage,
"desktop.deployment", "mismatch");
}
else
{ // found existing entry
Reference<deployment::XPackage> xPackage( insertion.first->second );
if (xPackage.is())
return xPackage;
insertion.first->second = xNewPackage;
}
guard.clear();
xNewPackage->addEventListener( this ); // listen for disposing events
return xNewPackage;
}
OUString PackageRegistryBackend::createFolder(
OUString const & relUrl,
Reference<ucb::XCommandEnvironment> const & xCmdEnv)
{
const OUString sDataFolder = makeURL(getCachePath(), relUrl);
//make sure the folder exist
ucbhelper::Content dataContent;
::dp_misc::create_folder(&dataContent, sDataFolder, xCmdEnv);
const OUString baseDir(sDataFolder);
const ::utl::TempFile aTemp(&baseDir, true);
const OUString url = aTemp.GetURL();
return sDataFolder + url.copy(url.lastIndexOf('/'));
}
//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.
void PackageRegistryBackend::deleteTempFolder(
OUString const & folderUrl)
{
if (!folderUrl.isEmpty())
{
erase_path( folderUrl, Reference<XCommandEnvironment>(),
false /* no throw: ignore errors */ );
if (folderUrl.endsWith("_"))
{
const OUString tempFile = folderUrl.copy(0, folderUrl.getLength() - 1);
erase_path( tempFile, Reference<XCommandEnvironment>(),
false /* no throw: ignore errors */ );
}
}
}
//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.
void PackageRegistryBackend::deleteUnusedFolders(
OUString const & relUrl,
::std::list< OUString> const & usedFolders)
{
try
{
const OUString sDataFolder = makeURL(getCachePath(), relUrl);
::ucbhelper::Content tempFolder(
sDataFolder, Reference<ucb::XCommandEnvironment>(), m_xComponentContext);
Reference<sdbc::XResultSet> xResultSet(
StrTitle::createCursor( tempFolder, ::ucbhelper::INCLUDE_FOLDERS_ONLY ) );
// get all temp directories:
::std::vector<OUString> tempEntries;
2010-11-20 16:29:14 +01:00
const char tmp[] = ".tmp";
while (xResultSet->next())
{
OUString title(
Reference<sdbc::XRow>(
xResultSet, UNO_QUERY_THROW )->getString(
1 /* Title */ ) );
if (title.endsWith(tmp))
tempEntries.push_back(
makeURLAppendSysPathSegment(sDataFolder, title));
}
for ( ::std::size_t pos = 0; pos < tempEntries.size(); ++pos )
{
if (::std::find( usedFolders.begin(), usedFolders.end(), tempEntries[pos] ) ==
usedFolders.end())
{
deleteTempFolder(tempEntries[pos]);
}
}
}
2011-12-06 00:19:44 +09:00
catch (const ucb::InteractiveAugmentedIOException& e)
{
//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;
}
}
Package::~Package()
{
}
Package::Package( ::rtl::Reference<PackageRegistryBackend> const & myBackend,
OUString const & url,
2010-05-10 11:06:01 +02:00
OUString const & rName,
OUString const & displayName,
Reference<deployment::XPackageTypeInfo> const & xPackageType,
bool bRemoved,
OUString const & identifier)
: t_PackageBase( getMutex() ),
m_myBackend( myBackend ),
m_url( url ),
2010-05-10 11:06:01 +02:00
m_name( rName ),
m_displayName( displayName ),
m_xPackageType( xPackageType ),
m_bRemoved(bRemoved),
m_identifier(identifier)
{
if (m_bRemoved)
{
//We use the last segment of the URL
SAL_WARN_IF(
!m_name.isEmpty(), "desktop.deployment", "non-empty m_name");
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);
}
}
void Package::disposing()
{
m_myBackend.clear();
WeakComponentImplHelperBase::disposing();
}
void Package::check() const
{
::osl::MutexGuard guard( getMutex() );
if (rBHelper.bInDispose || rBHelper.bDisposed) {
throw lang::DisposedException(
"Package instance has already been disposed!",
static_cast<OWeakObject *>(const_cast<Package *>(this)));
}
}
// XComponent
void Package::dispose() throw (RuntimeException, std::exception)
{
re-base on ALv2 code. Includes: Patch contributed by: Jurgen Schmidt remove onlineregistration with dependencies http://svn.apache.org/viewvc?view=revision&revision=1240245 imported patch package_eventlistener.patch http://svn.apache.org/viewvc?view=revision&revision=1172103 Patch contributed by Pedro Giffuni Accept Google Chrome OS fonts as equivalent to MS fonts. http://svn.apache.org/viewvc?view=revision&revision=1233155 http://svn.apache.org/viewvc?view=revision&revision=1233408 Patch contributed by Andre Fischer Do not add targets for junit tests when junit is disabled. http://svn.apache.org/viewvc?view=revision&revision=1241508 Patches contributed by Mathias Bauer (and others) gnumake4 work variously http://svn.apache.org/viewvc?view=revision&revision=1394707 http://svn.apache.org/viewvc?view=revision&revision=1394326 cws mba34issues01: #i114600#: remove forbidden characters from list of unencoded characters http://svn.apache.org/viewvc?view=revision&revision=1172370 Patches contributed by Oliver Rainer-Wittman some clean up in JPEGReader due to memory constraints http://svn.apache.org/viewvc?view=revision&revision=1299729 119114 - method <UpdateDialog::addSpecificError(..)> - create entry with correct type http://svn.apache.org/viewvc?view=revision&revision=1305265 Patches contributed by Ariel Constenla-Haile i118707 - make toolbar control's popup window grab focus http://svn.apache.org/viewvc?view=revision&revision=1225846 Patches contributed by Herbert Duerr #i118662# remove usage of BerkeleyDB in desktop module http://svn.apache.org/viewvc?view=revision&revision=1213171 minor cleanups in dp_persmap.* http://svn.apache.org/viewvc?view=revision&revision=1215064 flush early to prevent problem with extension manager not cleaning up its objects http://svn.apache.org/viewvc?view=revision&revision=1228147 i118726 do not flush *pmap file while reading it http://svn.apache.org/viewvc?view=revision&revision=1230614 #i119048# migrate BDB extension entries using a simple heuristic http://svn.apache.org/viewvc?view=revision&revision=1300972 #i119048# handle edge cases when importing BDB hash files http://svn.apache.org/viewvc?view=revision&revision=1301428 #i119113# fix of-by-one when importing BDB files http://svn.apache.org/viewvc?view=revision&revision=1305420 restore our encryption settings, icon themes, and dictionaries. removed wrapper hacks, kill obsolete bundled extension blob / pre-registration handling, remove duplicated quickstart code. remove OS/2 conditionals.
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
WeakComponentImplHelperBase::dispose();
}
void Package::addEventListener(
Reference<lang::XEventListener> const & xListener ) throw (RuntimeException, std::exception)
{
re-base on ALv2 code. Includes: Patch contributed by: Jurgen Schmidt remove onlineregistration with dependencies http://svn.apache.org/viewvc?view=revision&revision=1240245 imported patch package_eventlistener.patch http://svn.apache.org/viewvc?view=revision&revision=1172103 Patch contributed by Pedro Giffuni Accept Google Chrome OS fonts as equivalent to MS fonts. http://svn.apache.org/viewvc?view=revision&revision=1233155 http://svn.apache.org/viewvc?view=revision&revision=1233408 Patch contributed by Andre Fischer Do not add targets for junit tests when junit is disabled. http://svn.apache.org/viewvc?view=revision&revision=1241508 Patches contributed by Mathias Bauer (and others) gnumake4 work variously http://svn.apache.org/viewvc?view=revision&revision=1394707 http://svn.apache.org/viewvc?view=revision&revision=1394326 cws mba34issues01: #i114600#: remove forbidden characters from list of unencoded characters http://svn.apache.org/viewvc?view=revision&revision=1172370 Patches contributed by Oliver Rainer-Wittman some clean up in JPEGReader due to memory constraints http://svn.apache.org/viewvc?view=revision&revision=1299729 119114 - method <UpdateDialog::addSpecificError(..)> - create entry with correct type http://svn.apache.org/viewvc?view=revision&revision=1305265 Patches contributed by Ariel Constenla-Haile i118707 - make toolbar control's popup window grab focus http://svn.apache.org/viewvc?view=revision&revision=1225846 Patches contributed by Herbert Duerr #i118662# remove usage of BerkeleyDB in desktop module http://svn.apache.org/viewvc?view=revision&revision=1213171 minor cleanups in dp_persmap.* http://svn.apache.org/viewvc?view=revision&revision=1215064 flush early to prevent problem with extension manager not cleaning up its objects http://svn.apache.org/viewvc?view=revision&revision=1228147 i118726 do not flush *pmap file while reading it http://svn.apache.org/viewvc?view=revision&revision=1230614 #i119048# migrate BDB extension entries using a simple heuristic http://svn.apache.org/viewvc?view=revision&revision=1300972 #i119048# handle edge cases when importing BDB hash files http://svn.apache.org/viewvc?view=revision&revision=1301428 #i119113# fix of-by-one when importing BDB files http://svn.apache.org/viewvc?view=revision&revision=1305420 restore our encryption settings, icon themes, and dictionaries. removed wrapper hacks, kill obsolete bundled extension blob / pre-registration handling, remove duplicated quickstart code. remove OS/2 conditionals.
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
WeakComponentImplHelperBase::addEventListener( xListener );
}
void Package::removeEventListener(
Reference<lang::XEventListener> const & xListener ) throw (RuntimeException, std::exception)
{
re-base on ALv2 code. Includes: Patch contributed by: Jurgen Schmidt remove onlineregistration with dependencies http://svn.apache.org/viewvc?view=revision&revision=1240245 imported patch package_eventlistener.patch http://svn.apache.org/viewvc?view=revision&revision=1172103 Patch contributed by Pedro Giffuni Accept Google Chrome OS fonts as equivalent to MS fonts. http://svn.apache.org/viewvc?view=revision&revision=1233155 http://svn.apache.org/viewvc?view=revision&revision=1233408 Patch contributed by Andre Fischer Do not add targets for junit tests when junit is disabled. http://svn.apache.org/viewvc?view=revision&revision=1241508 Patches contributed by Mathias Bauer (and others) gnumake4 work variously http://svn.apache.org/viewvc?view=revision&revision=1394707 http://svn.apache.org/viewvc?view=revision&revision=1394326 cws mba34issues01: #i114600#: remove forbidden characters from list of unencoded characters http://svn.apache.org/viewvc?view=revision&revision=1172370 Patches contributed by Oliver Rainer-Wittman some clean up in JPEGReader due to memory constraints http://svn.apache.org/viewvc?view=revision&revision=1299729 119114 - method <UpdateDialog::addSpecificError(..)> - create entry with correct type http://svn.apache.org/viewvc?view=revision&revision=1305265 Patches contributed by Ariel Constenla-Haile i118707 - make toolbar control's popup window grab focus http://svn.apache.org/viewvc?view=revision&revision=1225846 Patches contributed by Herbert Duerr #i118662# remove usage of BerkeleyDB in desktop module http://svn.apache.org/viewvc?view=revision&revision=1213171 minor cleanups in dp_persmap.* http://svn.apache.org/viewvc?view=revision&revision=1215064 flush early to prevent problem with extension manager not cleaning up its objects http://svn.apache.org/viewvc?view=revision&revision=1228147 i118726 do not flush *pmap file while reading it http://svn.apache.org/viewvc?view=revision&revision=1230614 #i119048# migrate BDB extension entries using a simple heuristic http://svn.apache.org/viewvc?view=revision&revision=1300972 #i119048# handle edge cases when importing BDB hash files http://svn.apache.org/viewvc?view=revision&revision=1301428 #i119113# fix of-by-one when importing BDB files http://svn.apache.org/viewvc?view=revision&revision=1305420 restore our encryption settings, icon themes, and dictionaries. removed wrapper hacks, kill obsolete bundled extension blob / pre-registration handling, remove duplicated quickstart code. remove OS/2 conditionals.
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
WeakComponentImplHelperBase::removeEventListener( xListener );
}
// XModifyBroadcaster
void Package::addModifyListener(
Reference<util::XModifyListener> const & xListener )
throw (RuntimeException, std::exception)
{
check();
rBHelper.addListener( ::getCppuType( &xListener ), xListener );
}
void Package::removeModifyListener(
Reference<util::XModifyListener> const & xListener )
throw (RuntimeException, std::exception)
{
check();
rBHelper.removeListener( ::getCppuType( &xListener ), xListener );
}
void Package::checkAborted(
::rtl::Reference<AbortChannel> const & abortChannel )
{
if (abortChannel.is() && abortChannel->isAborted()) {
throw CommandAbortedException(
"abort!", static_cast<OWeakObject *>(this) );
}
}
// XPackage
Reference<task::XAbortChannel> Package::createAbortChannel()
throw (RuntimeException, std::exception)
{
check();
return new AbortChannel;
}
sal_Bool Package::isBundle() throw (RuntimeException, std::exception)
{
return false; // default
}
::sal_Int32 Package::checkPrerequisites(
const css::uno::Reference< css::task::XAbortChannel >&,
const css::uno::Reference< css::ucb::XCommandEnvironment >&,
sal_Bool)
throw (css::deployment::DeploymentException,
css::deployment::ExtensionRemovedException,
css::ucb::CommandFailedException,
css::ucb::CommandAbortedException,
css::uno::RuntimeException, std::exception)
{
if (m_bRemoved)
throw deployment::ExtensionRemovedException();
return 0;
}
sal_Bool Package::checkDependencies(
CWS-TOOLING: integrate CWS extmgr01 2009-07-28 15:37:52 +0200 dv r274410 : #i103856# Create dialog before using it 2009-07-27 15:24:42 +0200 dv r274368 : #i103831# Made selectEntry virtual so the correct function will be used from the listbox with buttons 2009-07-27 14:17:08 +0200 dv r274366 : #i103831# Made selectEntry virtual so the correct function will be used from the listbox with buttons 2009-07-07 08:23:17 +0200 dv r273765 : #i102666# Extension check on startup after office update -> fixed repaint problem 2009-07-06 11:28:28 +0200 dv r273729 : #i102666# Extension check on startup after office update -> fixed Mac OS X issues 2009-07-02 15:01:35 +0200 dv r273654 : #i102666# Extension check on startup after office update -> set last checked to never when aborting 2009-07-01 12:18:52 +0200 dv r273564 : Removed unused variable 2009-07-01 07:25:01 +0200 dv r273542 : #i102666# Extension check on startup after office update -> better layout 2009-06-30 14:56:16 +0200 dv r273506 : #i102666# Extension check on startup after office update -> mark incompatible extensions in extension manager 2009-06-30 12:43:55 +0200 dv r273502 : CWS-TOOLING: rebase CWS extmgr01 to trunk@273468 (milestone: DEV300:m51) 2009-06-29 13:26:54 +0200 dv r273469 : Now with newline at the end 2009-06-29 11:54:07 +0200 dv r273462 : #i102666# Extension check on startup after office update -> exit button of dialog disables extensions, too 2009-06-26 16:26:02 +0200 dv r273428 : #i102666# Extension check on startup after office update -> better progress handling 2009-06-26 14:50:34 +0200 dv r273417 : fixed crash when shutting down while initial waiting 2009-06-26 14:46:40 +0200 dv r273416 : #i102666# Extension check on startup after office update 2009-06-24 07:30:57 +0200 dv r273306 : #i102666# Extension check on startup after update 2009-06-11 12:03:10 +0200 dv r272863 : #i102666# Extension check on startup after update 2009-06-11 11:59:29 +0200 dv r272862 : #i102666# Extension check on startup after update 2009-06-09 15:50:05 +0200 dv r272773 : CWS-TOOLING: rebase CWS extmgr01 to trunk@272291 (milestone: DEV300:m49)
2009-08-06 09:32:55 +00:00
const css::uno::Reference< css::ucb::XCommandEnvironment >& )
throw (css::deployment::DeploymentException,
css::deployment::ExtensionRemovedException,
css::ucb::CommandFailedException,
css::uno::RuntimeException, std::exception)
CWS-TOOLING: integrate CWS extmgr01 2009-07-28 15:37:52 +0200 dv r274410 : #i103856# Create dialog before using it 2009-07-27 15:24:42 +0200 dv r274368 : #i103831# Made selectEntry virtual so the correct function will be used from the listbox with buttons 2009-07-27 14:17:08 +0200 dv r274366 : #i103831# Made selectEntry virtual so the correct function will be used from the listbox with buttons 2009-07-07 08:23:17 +0200 dv r273765 : #i102666# Extension check on startup after office update -> fixed repaint problem 2009-07-06 11:28:28 +0200 dv r273729 : #i102666# Extension check on startup after office update -> fixed Mac OS X issues 2009-07-02 15:01:35 +0200 dv r273654 : #i102666# Extension check on startup after office update -> set last checked to never when aborting 2009-07-01 12:18:52 +0200 dv r273564 : Removed unused variable 2009-07-01 07:25:01 +0200 dv r273542 : #i102666# Extension check on startup after office update -> better layout 2009-06-30 14:56:16 +0200 dv r273506 : #i102666# Extension check on startup after office update -> mark incompatible extensions in extension manager 2009-06-30 12:43:55 +0200 dv r273502 : CWS-TOOLING: rebase CWS extmgr01 to trunk@273468 (milestone: DEV300:m51) 2009-06-29 13:26:54 +0200 dv r273469 : Now with newline at the end 2009-06-29 11:54:07 +0200 dv r273462 : #i102666# Extension check on startup after office update -> exit button of dialog disables extensions, too 2009-06-26 16:26:02 +0200 dv r273428 : #i102666# Extension check on startup after office update -> better progress handling 2009-06-26 14:50:34 +0200 dv r273417 : fixed crash when shutting down while initial waiting 2009-06-26 14:46:40 +0200 dv r273416 : #i102666# Extension check on startup after office update 2009-06-24 07:30:57 +0200 dv r273306 : #i102666# Extension check on startup after update 2009-06-11 12:03:10 +0200 dv r272863 : #i102666# Extension check on startup after update 2009-06-11 11:59:29 +0200 dv r272862 : #i102666# Extension check on startup after update 2009-06-09 15:50:05 +0200 dv r272773 : CWS-TOOLING: rebase CWS extmgr01 to trunk@272291 (milestone: DEV300:m49)
2009-08-06 09:32:55 +00:00
{
if (m_bRemoved)
throw deployment::ExtensionRemovedException();
CWS-TOOLING: integrate CWS extmgr01 2009-07-28 15:37:52 +0200 dv r274410 : #i103856# Create dialog before using it 2009-07-27 15:24:42 +0200 dv r274368 : #i103831# Made selectEntry virtual so the correct function will be used from the listbox with buttons 2009-07-27 14:17:08 +0200 dv r274366 : #i103831# Made selectEntry virtual so the correct function will be used from the listbox with buttons 2009-07-07 08:23:17 +0200 dv r273765 : #i102666# Extension check on startup after office update -> fixed repaint problem 2009-07-06 11:28:28 +0200 dv r273729 : #i102666# Extension check on startup after office update -> fixed Mac OS X issues 2009-07-02 15:01:35 +0200 dv r273654 : #i102666# Extension check on startup after office update -> set last checked to never when aborting 2009-07-01 12:18:52 +0200 dv r273564 : Removed unused variable 2009-07-01 07:25:01 +0200 dv r273542 : #i102666# Extension check on startup after office update -> better layout 2009-06-30 14:56:16 +0200 dv r273506 : #i102666# Extension check on startup after office update -> mark incompatible extensions in extension manager 2009-06-30 12:43:55 +0200 dv r273502 : CWS-TOOLING: rebase CWS extmgr01 to trunk@273468 (milestone: DEV300:m51) 2009-06-29 13:26:54 +0200 dv r273469 : Now with newline at the end 2009-06-29 11:54:07 +0200 dv r273462 : #i102666# Extension check on startup after office update -> exit button of dialog disables extensions, too 2009-06-26 16:26:02 +0200 dv r273428 : #i102666# Extension check on startup after office update -> better progress handling 2009-06-26 14:50:34 +0200 dv r273417 : fixed crash when shutting down while initial waiting 2009-06-26 14:46:40 +0200 dv r273416 : #i102666# Extension check on startup after office update 2009-06-24 07:30:57 +0200 dv r273306 : #i102666# Extension check on startup after update 2009-06-11 12:03:10 +0200 dv r272863 : #i102666# Extension check on startup after update 2009-06-11 11:59:29 +0200 dv r272862 : #i102666# Extension check on startup after update 2009-06-09 15:50:05 +0200 dv r272773 : CWS-TOOLING: rebase CWS extmgr01 to trunk@272291 (milestone: DEV300:m49)
2009-08-06 09:32:55 +00:00
return true;
}
Sequence< Reference<deployment::XPackage> > Package::getBundle(
Reference<task::XAbortChannel> const &,
Reference<XCommandEnvironment> const & )
throw (deployment::DeploymentException,
CommandFailedException, CommandAbortedException,
lang::IllegalArgumentException, RuntimeException, std::exception)
{
return Sequence< Reference<deployment::XPackage> >();
}
OUString Package::getName() throw (RuntimeException, std::exception)
{
return m_name;
}
beans::Optional<OUString> Package::getIdentifier() throw (RuntimeException, std::exception)
{
if (m_bRemoved)
return beans::Optional<OUString>(true, m_identifier);
return beans::Optional<OUString>();
}
OUString Package::getVersion() throw (
deployment::ExtensionRemovedException,
RuntimeException, std::exception)
{
if (m_bRemoved)
throw deployment::ExtensionRemovedException();
return OUString();
}
OUString Package::getURL() throw (RuntimeException, std::exception)
{
return m_url;
}
OUString Package::getDisplayName() throw (
deployment::ExtensionRemovedException, RuntimeException, std::exception)
{
if (m_bRemoved)
throw deployment::ExtensionRemovedException();
return m_displayName;
}
OUString Package::getDescription() throw (
deployment::ExtensionRemovedException,RuntimeException, std::exception)
{
if (m_bRemoved)
throw deployment::ExtensionRemovedException();
return OUString();
}
OUString Package::getLicenseText() throw (
deployment::ExtensionRemovedException,RuntimeException, std::exception)
{
if (m_bRemoved)
throw deployment::ExtensionRemovedException();
return OUString();
}
Sequence<OUString> Package::getUpdateInformationURLs() throw (
deployment::ExtensionRemovedException, RuntimeException, std::exception)
{
if (m_bRemoved)
throw deployment::ExtensionRemovedException();
return Sequence<OUString>();
}
css::beans::StringPair Package::getPublisherInfo() throw (
deployment::ExtensionRemovedException, RuntimeException, std::exception)
{
if (m_bRemoved)
throw deployment::ExtensionRemovedException();
css::beans::StringPair aEmptyPair;
return aEmptyPair;
}
uno::Reference< css::graphic::XGraphic > Package::getIcon( sal_Bool /*bHighContrast*/ )
throw (deployment::ExtensionRemovedException, RuntimeException, std::exception )
{
if (m_bRemoved)
throw deployment::ExtensionRemovedException();
uno::Reference< css::graphic::XGraphic > aEmpty;
return aEmpty;
}
Reference<deployment::XPackageTypeInfo> Package::getPackageType()
throw (RuntimeException, std::exception)
{
return m_xPackageType;
}
void Package::exportTo(
OUString const & destFolderURL, OUString const & newTitle,
sal_Int32 nameClashAction, Reference<XCommandEnvironment> const & xCmdEnv )
throw (deployment::ExtensionRemovedException,
CommandFailedException, CommandAbortedException, RuntimeException, std::exception)
{
if (m_bRemoved)
throw deployment::ExtensionRemovedException();
::ucbhelper::Content destFolder( destFolderURL, xCmdEnv, getMyBackend()->getComponentContext() );
::ucbhelper::Content sourceContent( getURL(), xCmdEnv, getMyBackend()->getComponentContext() );
if (! destFolder.transferContent(
sourceContent, ::ucbhelper::InsertOperation_COPY,
newTitle, nameClashAction ))
throw RuntimeException( "UCB transferContent() failed!", 0 );
}
void Package::fireModified()
{
::cppu::OInterfaceContainerHelper * container = rBHelper.getContainer(
::getCppuType( static_cast<Reference<
util::XModifyListener> const *>(0) ) );
if (container != 0) {
Sequence< Reference<XInterface> > elements(
container->getElements() );
lang::EventObject evt( static_cast<OWeakObject *>(this) );
for ( sal_Int32 pos = 0; pos < elements.getLength(); ++pos )
{
Reference<util::XModifyListener> xListener(
elements[ pos ], UNO_QUERY );
if (xListener.is())
xListener->modified( evt );
}
}
}
// XPackage
beans::Optional< beans::Ambiguous<sal_Bool> > Package::isRegistered(
Reference<task::XAbortChannel> const & xAbortChannel,
Reference<XCommandEnvironment> const & xCmdEnv )
throw (deployment::DeploymentException,
CommandFailedException, CommandAbortedException, RuntimeException, std::exception)
{
try {
::osl::ResettableMutexGuard guard( getMutex() );
return isRegistered_( guard,
AbortChannel::get(xAbortChannel),
xCmdEnv );
}
2011-12-06 00:19:44 +09:00
catch (const RuntimeException &) {
throw;
}
2011-12-06 00:19:44 +09:00
catch (const CommandFailedException &) {
throw;
}
2011-12-06 00:19:44 +09:00
catch (const CommandAbortedException &) {
throw;
}
2011-12-06 00:19:44 +09:00
catch (const deployment::DeploymentException &) {
throw;
}
2011-12-06 00:19:44 +09:00
catch (const Exception &) {
Any exc( ::cppu::getCaughtException() );
throw deployment::DeploymentException(
"unexpected exception occurred!",
static_cast<OWeakObject *>(this), exc );
}
}
void Package::processPackage_impl(
bool doRegisterPackage,
bool startup,
Reference<task::XAbortChannel> const & xAbortChannel,
Reference<XCommandEnvironment> const & xCmdEnv )
{
check();
bool action = false;
try {
try {
::osl::ResettableMutexGuard guard( getMutex() );
beans::Optional< beans::Ambiguous<sal_Bool> > option(
isRegistered_( guard, AbortChannel::get(xAbortChannel),
xCmdEnv ) );
action = (option.IsPresent &&
(option.Value.IsAmbiguous ||
(doRegisterPackage ? !option.Value.Value
: option.Value.Value)));
if (action) {
OUString displayName = isRemoved() ? getName() : getDisplayName();
ProgressLevel progress(
xCmdEnv,
(doRegisterPackage
? PackageRegistryBackend::StrRegisteringPackage::get()
: PackageRegistryBackend::StrRevokingPackage::get())
+ displayName );
processPackage_( guard,
doRegisterPackage,
startup,
AbortChannel::get(xAbortChannel),
xCmdEnv );
}
}
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) {
SAL_WARN(
"desktop.deployment",
"unexpected RuntimeException \"" << e.Message << '"');
throw;
}
2011-12-06 00:19:44 +09:00
catch (const CommandFailedException &) {
throw;
}
2011-12-06 00:19:44 +09:00
catch (const CommandAbortedException &) {
throw;
}
2011-12-06 00:19:44 +09:00
catch (const deployment::DeploymentException &) {
throw;
}
2011-12-06 00:19:44 +09:00
catch (const Exception &) {
Any exc( ::cppu::getCaughtException() );
throw deployment::DeploymentException(
(doRegisterPackage
? getResourceString(RID_STR_ERROR_WHILE_REGISTERING)
: getResourceString(RID_STR_ERROR_WHILE_REVOKING))
+ getDisplayName(), static_cast<OWeakObject *>(this), exc );
}
}
catch (...) {
if (action)
fireModified();
throw;
}
if (action)
fireModified();
}
void Package::registerPackage(
sal_Bool startup,
Reference<task::XAbortChannel> const & xAbortChannel,
Reference<XCommandEnvironment> const & xCmdEnv )
throw (deployment::DeploymentException,
deployment::ExtensionRemovedException,
CommandFailedException, CommandAbortedException,
lang::IllegalArgumentException, RuntimeException, std::exception)
{
if (m_bRemoved)
throw deployment::ExtensionRemovedException();
processPackage_impl( true /* register */, startup, xAbortChannel, xCmdEnv );
}
void Package::revokePackage(
sal_Bool startup,
Reference<task::XAbortChannel> const & xAbortChannel,
Reference<XCommandEnvironment> const & xCmdEnv )
throw (deployment::DeploymentException,
CommandFailedException, CommandAbortedException,
lang::IllegalArgumentException, RuntimeException, std::exception)
{
processPackage_impl( false /* revoke */, startup, xAbortChannel, xCmdEnv );
}
PackageRegistryBackend * Package::getMyBackend() const
{
PackageRegistryBackend * pBackend = m_myBackend.get();
if (NULL == pBackend)
{
//May throw a DisposedException
check();
//We should never get here...
throw RuntimeException(
"Failed to get the BackendImpl",
static_cast<OWeakObject*>(const_cast<Package *>(this)));
}
return pBackend;
}
OUString Package::getRepositoryName()
throw (RuntimeException, std::exception)
{
PackageRegistryBackend * backEnd = getMyBackend();
return backEnd->getContext();
}
beans::Optional< OUString > Package::getRegistrationDataURL()
throw (deployment::ExtensionRemovedException,
css::uno::RuntimeException, std::exception)
{
if (m_bRemoved)
throw deployment::ExtensionRemovedException();
return beans::Optional<OUString>();
}
sal_Bool Package::isRemoved()
throw (RuntimeException, std::exception)
{
return m_bRemoved;
}
Package::TypeInfo::~TypeInfo()
{
}
// XPackageTypeInfo
OUString Package::TypeInfo::getMediaType() throw (RuntimeException, std::exception)
{
return m_mediaType;
}
OUString Package::TypeInfo::getDescription()
throw (deployment::ExtensionRemovedException, RuntimeException, std::exception)
{
return getShortDescription();
}
OUString Package::TypeInfo::getShortDescription()
throw (deployment::ExtensionRemovedException, RuntimeException, std::exception)
{
return m_shortDescr;
}
OUString Package::TypeInfo::getFileFilter() throw (RuntimeException, std::exception)
{
return m_fileFilter;
}
/**************************
* 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
*/
Any Package::TypeInfo::getIcon( sal_Bool /*highContrast*/, sal_Bool smallIcon )
throw (RuntimeException, std::exception)
{
if (! smallIcon)
return Any();
const sal_uInt16 nIconId = m_smallIcon;
return Any( &nIconId, getCppuType( static_cast<sal_uInt16 const *>(0) ) );
}
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */