2010-10-12 15:53:47 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2004-04-13 11:08:32 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-11 03:11:38 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2004-04-13 11:08:32 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2004-04-13 11:08:32 +00:00
|
|
|
*
|
2008-04-11 03:11:38 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2004-04-13 11:08:32 +00:00
|
|
|
*
|
2008-04-11 03:11:38 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2004-04-13 11:08:32 +00:00
|
|
|
*
|
2008-04-11 03:11:38 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2004-04-13 11:08:32 +00:00
|
|
|
*
|
2008-04-11 03:11:38 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2004-04-13 11:08:32 +00:00
|
|
|
*
|
2008-04-11 03:11:38 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2004-04-13 11:08:32 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-17 08:43:25 +00:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_desktop.hxx"
|
|
|
|
|
2004-06-11 11:13:15 +00:00
|
|
|
#include "dp_component.hrc"
|
2004-04-13 11:08:32 +00:00
|
|
|
#include "dp_backend.h"
|
2008-04-17 06:53:20 +00:00
|
|
|
#include "dp_platform.hxx"
|
2004-04-13 11:08:32 +00:00
|
|
|
#include "dp_ucb.h"
|
|
|
|
#include "rtl/string.hxx"
|
|
|
|
#include "rtl/strbuf.hxx"
|
|
|
|
#include "rtl/ustrbuf.hxx"
|
|
|
|
#include "rtl/uri.hxx"
|
|
|
|
#include "cppuhelper/exc_hlp.hxx"
|
|
|
|
#include "ucbhelper/content.hxx"
|
|
|
|
#include "comphelper/anytostring.hxx"
|
2006-03-06 09:22:07 +00:00
|
|
|
#include "comphelper/servicedecl.hxx"
|
|
|
|
#include "comphelper/sequence.hxx"
|
2004-04-13 11:08:32 +00:00
|
|
|
#include "xmlscript/xml_helper.hxx"
|
2009-10-16 00:05:16 +02:00
|
|
|
#include "svl/inettype.hxx"
|
2004-04-13 11:08:32 +00:00
|
|
|
#include "com/sun/star/lang/WrappedTargetRuntimeException.hpp"
|
2004-08-12 11:10:09 +00:00
|
|
|
#include "com/sun/star/container/XNameContainer.hpp"
|
2004-04-13 11:08:32 +00:00
|
|
|
#include "com/sun/star/container/XHierarchicalNameAccess.hpp"
|
2004-06-11 11:13:15 +00:00
|
|
|
#include "com/sun/star/container/XSet.hpp"
|
2004-04-13 11:08:32 +00:00
|
|
|
#include "com/sun/star/registry/XSimpleRegistry.hpp"
|
|
|
|
#include "com/sun/star/registry/XImplementationRegistration.hpp"
|
|
|
|
#include "com/sun/star/loader/XImplementationLoader.hpp"
|
|
|
|
#include "com/sun/star/io/XInputStream.hpp"
|
|
|
|
#include "com/sun/star/ucb/NameClash.hpp"
|
2007-10-15 11:59:46 +00:00
|
|
|
#include "com/sun/star/util/XMacroExpander.hpp"
|
2004-08-12 11:10:09 +00:00
|
|
|
#include <list>
|
2011-02-05 13:18:52 +01:00
|
|
|
#include <boost/unordered_map.hpp>
|
2004-04-13 11:08:32 +00:00
|
|
|
#include <vector>
|
|
|
|
#include <memory>
|
|
|
|
#include <algorithm>
|
2010-05-04 12:37:01 +02:00
|
|
|
#include "dp_compbackenddb.hxx"
|
2004-04-13 11:08:32 +00:00
|
|
|
|
|
|
|
using namespace ::dp_misc;
|
|
|
|
using namespace ::com::sun::star;
|
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star::ucb;
|
|
|
|
using ::rtl::OUString;
|
|
|
|
|
2004-08-12 11:10:09 +00:00
|
|
|
namespace dp_registry {
|
|
|
|
namespace backend {
|
|
|
|
namespace component {
|
2004-11-09 13:11:20 +00:00
|
|
|
namespace {
|
2004-04-13 11:08:32 +00:00
|
|
|
|
2004-11-09 13:11:20 +00:00
|
|
|
typedef ::std::list<OUString> t_stringlist;
|
2004-08-12 11:10:09 +00:00
|
|
|
typedef ::std::vector< ::std::pair<OUString, OUString> > t_stringpairvec;
|
2004-04-13 11:08:32 +00:00
|
|
|
|
2010-05-04 12:37:01 +02:00
|
|
|
#define IMPLEMENTATION_NAME "com.sun.star.comp.deployment.component.PackageRegistryBackend"
|
|
|
|
|
2007-08-17 10:52:05 +00:00
|
|
|
/** return a vector of bootstrap variables which have been provided
|
|
|
|
as command arguments.
|
|
|
|
*/
|
|
|
|
::std::vector<OUString> getCmdBootstrapVariables()
|
|
|
|
{
|
|
|
|
::std::vector<OUString> ret;
|
|
|
|
sal_uInt32 count = osl_getCommandArgCount();
|
|
|
|
for (sal_uInt32 i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
OUString arg;
|
|
|
|
osl_getCommandArg(i, &arg.pData);
|
|
|
|
if (arg.matchAsciiL("-env:", 5))
|
|
|
|
ret.push_back(arg);
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2007-03-12 10:02:40 +00:00
|
|
|
bool jarManifestHeaderPresent(
|
|
|
|
OUString const & url, OUString const & name,
|
|
|
|
Reference<XCommandEnvironment> const & xCmdEnv )
|
|
|
|
{
|
|
|
|
::rtl::OUStringBuffer buf;
|
|
|
|
buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("vnd.sun.star.zip://") );
|
|
|
|
buf.append(
|
|
|
|
::rtl::Uri::encode(
|
|
|
|
url, rtl_UriCharClassRegName, rtl_UriEncodeIgnoreEscapes,
|
|
|
|
RTL_TEXTENCODING_UTF8 ) );
|
|
|
|
buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("/META-INF/MANIFEST.MF") );
|
2007-06-05 14:06:30 +00:00
|
|
|
::ucbhelper::Content manifestContent;
|
2007-03-12 10:02:40 +00:00
|
|
|
OUString line;
|
|
|
|
return
|
|
|
|
create_ucb_content(
|
|
|
|
&manifestContent, buf.makeStringAndClear(), xCmdEnv,
|
|
|
|
false /* no throw */ )
|
|
|
|
&& readLine( &line, name, manifestContent, RTL_TEXTENCODING_ASCII_US );
|
|
|
|
}
|
|
|
|
|
2004-04-13 11:08:32 +00:00
|
|
|
//==============================================================================
|
|
|
|
class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend
|
|
|
|
{
|
2004-11-09 13:11:20 +00:00
|
|
|
class ComponentPackageImpl : public ::dp_registry::backend::Package
|
|
|
|
{
|
2008-05-20 13:33:31 +00:00
|
|
|
BackendImpl * getMyBackend() const;
|
2004-11-09 13:11:20 +00:00
|
|
|
|
|
|
|
const OUString m_loader;
|
2010-03-22 12:35:33 +01:00
|
|
|
ComponentBackendDb::Data m_registeredComponentsDb;
|
2004-11-09 13:11:20 +00:00
|
|
|
|
2005-04-04 06:58:50 +00:00
|
|
|
enum reg {
|
2009-12-04 13:39:33 +01:00
|
|
|
REG_UNINIT, REG_VOID, REG_REGISTERED, REG_NOT_REGISTERED, REG_MAYBE_REGISTERED
|
2004-11-09 13:11:20 +00:00
|
|
|
} m_registered;
|
|
|
|
|
|
|
|
Reference<loader::XImplementationLoader> getComponentInfo(
|
|
|
|
t_stringlist * pImplNames, t_stringpairvec * pSingletons,
|
|
|
|
Reference<XComponentContext> const & xContext );
|
|
|
|
|
|
|
|
virtual void SAL_CALL disposing();
|
|
|
|
|
|
|
|
// Package
|
|
|
|
virtual beans::Optional< beans::Ambiguous<sal_Bool> > isRegistered_(
|
|
|
|
::osl::ResettableMutexGuard & guard,
|
|
|
|
::rtl::Reference<AbortChannel> const & abortChannel,
|
|
|
|
Reference<XCommandEnvironment> const & xCmdEnv );
|
|
|
|
virtual void processPackage_(
|
|
|
|
::osl::ResettableMutexGuard & guard,
|
|
|
|
bool registerPackage,
|
2010-04-21 16:04:34 +02:00
|
|
|
bool startup,
|
2004-11-09 13:11:20 +00:00
|
|
|
::rtl::Reference<AbortChannel> const & abortChannel,
|
|
|
|
Reference<XCommandEnvironment> const & xCmdEnv );
|
|
|
|
|
|
|
|
const Reference<registry::XSimpleRegistry> getRDB() const;
|
|
|
|
|
2009-12-03 15:59:55 +01:00
|
|
|
//Provides the read-only registry (e.g. not the one based on the duplicated
|
|
|
|
//rdb files
|
|
|
|
const Reference<registry::XSimpleRegistry> getRDB_RO() const;
|
|
|
|
|
2004-11-09 13:11:20 +00:00
|
|
|
public:
|
2010-03-22 12:35:33 +01:00
|
|
|
ComponentPackageImpl(
|
2004-11-09 13:11:20 +00:00
|
|
|
::rtl::Reference<PackageRegistryBackend> const & myBackend,
|
|
|
|
OUString const & url, OUString const & name,
|
|
|
|
Reference<deployment::XPackageTypeInfo> const & xPackageType,
|
2010-04-19 11:33:33 +02:00
|
|
|
OUString const & loader, bool bRemoved,
|
|
|
|
OUString const & identifier);
|
2004-11-09 13:11:20 +00:00
|
|
|
};
|
|
|
|
friend class ComponentPackageImpl;
|
|
|
|
|
|
|
|
class TypelibraryPackageImpl : public ::dp_registry::backend::Package
|
|
|
|
{
|
2008-05-20 13:33:31 +00:00
|
|
|
BackendImpl * getMyBackend() const;
|
2004-11-09 13:11:20 +00:00
|
|
|
|
|
|
|
const bool m_jarFile;
|
|
|
|
Reference<container::XHierarchicalNameAccess> m_xTDprov;
|
|
|
|
|
|
|
|
virtual void SAL_CALL disposing();
|
|
|
|
|
|
|
|
// Package
|
|
|
|
virtual beans::Optional< beans::Ambiguous<sal_Bool> > isRegistered_(
|
|
|
|
::osl::ResettableMutexGuard & guard,
|
|
|
|
::rtl::Reference<AbortChannel> const & abortChannel,
|
|
|
|
Reference<XCommandEnvironment> const & xCmdEnv );
|
|
|
|
virtual void processPackage_(
|
|
|
|
::osl::ResettableMutexGuard & guard,
|
|
|
|
bool registerPackage,
|
2010-04-21 16:04:34 +02:00
|
|
|
bool startup,
|
2004-11-09 13:11:20 +00:00
|
|
|
::rtl::Reference<AbortChannel> const & abortChannel,
|
|
|
|
Reference<XCommandEnvironment> const & xCmdEnv );
|
|
|
|
|
|
|
|
public:
|
2010-03-22 12:35:33 +01:00
|
|
|
TypelibraryPackageImpl(
|
2004-11-09 13:11:20 +00:00
|
|
|
::rtl::Reference<PackageRegistryBackend> const & myBackend,
|
|
|
|
OUString const & url, OUString const & name,
|
|
|
|
Reference<deployment::XPackageTypeInfo> const & xPackageType,
|
2010-04-19 11:33:33 +02:00
|
|
|
bool jarFile, bool bRemoved,
|
|
|
|
OUString const & identifier);
|
2004-11-09 13:11:20 +00:00
|
|
|
};
|
|
|
|
friend class TypelibraryPackageImpl;
|
|
|
|
|
2011-02-10 13:54:19 +01:00
|
|
|
/** Serves for unregistering packages that were registered on a
|
|
|
|
different platform. This can happen if one has remotely mounted
|
|
|
|
/home, for example.
|
|
|
|
*/
|
|
|
|
class OtherPlatformPackageImpl : public ::dp_registry::backend::Package
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
OtherPlatformPackageImpl(
|
|
|
|
::rtl::Reference<PackageRegistryBackend> const & myBackend,
|
|
|
|
OUString const & url, OUString const & name,
|
|
|
|
Reference<deployment::XPackageTypeInfo> const & xPackageType,
|
|
|
|
bool bRemoved, OUString const & identifier, OUString const& rPlatform);
|
|
|
|
|
|
|
|
private:
|
|
|
|
BackendImpl * getMyBackend() const;
|
|
|
|
|
|
|
|
const Reference<registry::XSimpleRegistry> impl_openRDB() const;
|
|
|
|
const Reference<XInterface> impl_createInstance(OUString const& rService) const;
|
|
|
|
|
|
|
|
// Package
|
|
|
|
virtual beans::Optional< beans::Ambiguous<sal_Bool> > isRegistered_(
|
|
|
|
::osl::ResettableMutexGuard & guard,
|
|
|
|
::rtl::Reference<AbortChannel> const & abortChannel,
|
|
|
|
Reference<XCommandEnvironment> const & xCmdEnv );
|
|
|
|
virtual void processPackage_(
|
|
|
|
::osl::ResettableMutexGuard & guard,
|
|
|
|
bool registerPackage,
|
|
|
|
bool startup,
|
|
|
|
::rtl::Reference<AbortChannel> const & abortChannel,
|
|
|
|
Reference<XCommandEnvironment> const & xCmdEnv );
|
|
|
|
|
|
|
|
private:
|
|
|
|
OUString const m_aPlatform;
|
|
|
|
};
|
|
|
|
friend class OtherPlatformPackageImpl;
|
|
|
|
|
2004-08-12 11:10:09 +00:00
|
|
|
t_stringlist m_jar_typelibs;
|
|
|
|
t_stringlist m_rdb_typelibs;
|
|
|
|
t_stringlist & getTypelibs( bool jar ) {
|
|
|
|
return jar ? m_jar_typelibs : m_rdb_typelibs;
|
|
|
|
}
|
2004-06-11 11:13:15 +00:00
|
|
|
|
2004-04-13 11:08:32 +00:00
|
|
|
bool m_unorc_inited;
|
|
|
|
bool m_unorc_modified;
|
2008-09-29 08:59:45 +00:00
|
|
|
bool bSwitchedRdbFiles;
|
2004-04-13 11:08:32 +00:00
|
|
|
|
2011-02-05 13:18:52 +01:00
|
|
|
typedef ::boost::unordered_map< OUString, Reference<XInterface>,
|
2004-06-11 11:13:15 +00:00
|
|
|
::rtl::OUStringHash > t_string2object;
|
|
|
|
t_string2object m_backendObjects;
|
2004-04-13 11:08:32 +00:00
|
|
|
|
|
|
|
// PackageRegistryBackend
|
2004-06-11 11:13:15 +00:00
|
|
|
virtual Reference<deployment::XPackage> bindPackage_(
|
|
|
|
OUString const & url, OUString const & mediaType,
|
2010-04-19 11:33:33 +02:00
|
|
|
sal_Bool bRemoved, OUString const & identifier,
|
2004-06-11 11:13:15 +00:00
|
|
|
Reference<XCommandEnvironment> const & xCmdEnv );
|
2004-04-13 11:08:32 +00:00
|
|
|
|
|
|
|
virtual void SAL_CALL disposing();
|
|
|
|
|
2004-11-09 13:11:20 +00:00
|
|
|
const Reference<deployment::XPackageTypeInfo> m_xDynComponentTypeInfo;
|
|
|
|
const Reference<deployment::XPackageTypeInfo> m_xJavaComponentTypeInfo;
|
|
|
|
const Reference<deployment::XPackageTypeInfo> m_xPythonComponentTypeInfo;
|
|
|
|
const Reference<deployment::XPackageTypeInfo> m_xRDBTypelibTypeInfo;
|
|
|
|
const Reference<deployment::XPackageTypeInfo> m_xJavaTypelibTypeInfo;
|
|
|
|
Sequence< Reference<deployment::XPackageTypeInfo> > m_typeInfos;
|
2004-06-11 11:13:15 +00:00
|
|
|
|
|
|
|
OUString m_commonRDB;
|
|
|
|
OUString m_nativeRDB;
|
2009-12-03 15:59:55 +01:00
|
|
|
|
|
|
|
//URLs of the read-only rdbs (e.g. not the ones of the duplicated files)
|
|
|
|
OUString m_commonRDB_RO;
|
|
|
|
OUString m_nativeRDB_RO;
|
|
|
|
|
2010-05-04 12:37:01 +02:00
|
|
|
std::auto_ptr<ComponentBackendDb> m_backendDb;
|
|
|
|
|
|
|
|
void addDataToDb(OUString const & url, ComponentBackendDb::Data const & data);
|
|
|
|
void deleteDataFromDb(OUString const & url);
|
2010-03-22 12:35:33 +01:00
|
|
|
ComponentBackendDb::Data readDataFromDb(OUString const & url);
|
2010-05-04 12:37:01 +02:00
|
|
|
|
|
|
|
|
2009-12-03 15:59:55 +01:00
|
|
|
//These rdbs are for writing new service entries. The rdb files are copies
|
|
|
|
//which are created when services are added or removed.
|
2004-06-11 11:13:15 +00:00
|
|
|
Reference<registry::XSimpleRegistry> m_xCommonRDB;
|
|
|
|
Reference<registry::XSimpleRegistry> m_xNativeRDB;
|
2004-04-13 11:08:32 +00:00
|
|
|
|
2009-12-03 15:59:55 +01:00
|
|
|
//These rdbs are created on the read-only rdbs which are already used
|
|
|
|
//by UNO since the startup of the current session.
|
|
|
|
Reference<registry::XSimpleRegistry> m_xCommonRDB_RO;
|
|
|
|
Reference<registry::XSimpleRegistry> m_xNativeRDB_RO;
|
|
|
|
|
|
|
|
|
2004-06-11 11:13:15 +00:00
|
|
|
void unorc_verify_init( Reference<XCommandEnvironment> const & xCmdEnv );
|
|
|
|
void unorc_flush( Reference<XCommandEnvironment> const & xCmdEnv );
|
2004-04-13 11:08:32 +00:00
|
|
|
|
2004-06-11 11:13:15 +00:00
|
|
|
Reference<XInterface> getObject( OUString const & id );
|
|
|
|
Reference<XInterface> insertObject(
|
|
|
|
OUString const & id, Reference<XInterface> const & xObject );
|
|
|
|
void releaseObject( OUString const & id );
|
|
|
|
|
2004-08-12 11:10:09 +00:00
|
|
|
bool addToUnoRc( bool jarFile, OUString const & url,
|
|
|
|
Reference<XCommandEnvironment> const & xCmdEnv );
|
|
|
|
bool removeFromUnoRc( bool jarFile, OUString const & url,
|
|
|
|
Reference<XCommandEnvironment> const & xCmdEnv );
|
2006-10-12 13:10:14 +00:00
|
|
|
bool hasInUnoRc( bool jarFile, OUString const & url );
|
2004-08-12 11:10:09 +00:00
|
|
|
|
2008-09-29 08:59:45 +00:00
|
|
|
|
|
|
|
|
2004-11-09 13:11:20 +00:00
|
|
|
public:
|
2004-08-12 11:10:09 +00:00
|
|
|
BackendImpl( Sequence<Any> const & args,
|
2006-03-06 09:22:07 +00:00
|
|
|
Reference<XComponentContext> const & xComponentContext );
|
2004-06-11 11:13:15 +00:00
|
|
|
|
2004-11-09 13:11:20 +00:00
|
|
|
// XPackageRegistry
|
|
|
|
virtual Sequence< Reference<deployment::XPackageTypeInfo> > SAL_CALL
|
|
|
|
getSupportedPackageTypes() throw (RuntimeException);
|
2006-10-12 13:10:14 +00:00
|
|
|
|
|
|
|
using PackageRegistryBackend::disposing;
|
2008-09-29 08:59:45 +00:00
|
|
|
|
|
|
|
//Will be called from ComponentPackageImpl
|
|
|
|
void initServiceRdbFiles();
|
2009-12-03 15:59:55 +01:00
|
|
|
|
|
|
|
//Creates the READ ONLY registries (m_xCommonRDB_RO,m_xNativeRDB_RO)
|
|
|
|
void initServiceRdbFiles_RO();
|
2004-04-13 11:08:32 +00:00
|
|
|
};
|
|
|
|
|
2004-06-11 11:13:15 +00:00
|
|
|
//______________________________________________________________________________
|
2010-03-22 12:35:33 +01:00
|
|
|
|
|
|
|
BackendImpl::ComponentPackageImpl::ComponentPackageImpl(
|
|
|
|
::rtl::Reference<PackageRegistryBackend> const & myBackend,
|
|
|
|
OUString const & url, OUString const & name,
|
|
|
|
Reference<deployment::XPackageTypeInfo> const & xPackageType,
|
2010-04-19 11:33:33 +02:00
|
|
|
OUString const & loader, bool bRemoved,
|
|
|
|
OUString const & identifier)
|
2010-03-22 12:35:33 +01:00
|
|
|
: Package( myBackend, url, name, name /* display-name */,
|
|
|
|
xPackageType, bRemoved, identifier),
|
|
|
|
m_loader( loader ),
|
|
|
|
m_registered( REG_UNINIT )
|
|
|
|
{
|
|
|
|
if (bRemoved)
|
|
|
|
{
|
|
|
|
m_registeredComponentsDb = getMyBackend()->readDataFromDb(url);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-11-09 13:11:20 +00:00
|
|
|
const Reference<registry::XSimpleRegistry>
|
|
|
|
BackendImpl::ComponentPackageImpl::getRDB() const
|
2004-06-11 11:13:15 +00:00
|
|
|
{
|
|
|
|
BackendImpl * that = getMyBackend();
|
2009-12-03 15:59:55 +01:00
|
|
|
|
2008-09-29 08:59:45 +00:00
|
|
|
//Late "initialization" of the services rdb files
|
|
|
|
//This is to prevent problems when running several
|
|
|
|
//instances of OOo with root rights in parallel. This
|
|
|
|
//would otherwise cause problems when copying the rdbs.
|
2009-12-03 15:59:55 +01:00
|
|
|
//See http://qa.openoffice.org/issues/show_bug.cgi?id=99257
|
2008-09-29 08:59:45 +00:00
|
|
|
{
|
|
|
|
const ::osl::MutexGuard guard( getMutex() );
|
|
|
|
if (!that->bSwitchedRdbFiles)
|
|
|
|
{
|
|
|
|
that->bSwitchedRdbFiles = true;
|
|
|
|
that->initServiceRdbFiles();
|
|
|
|
}
|
|
|
|
}
|
2004-06-11 11:13:15 +00:00
|
|
|
if (m_loader.equalsAsciiL(
|
|
|
|
RTL_CONSTASCII_STRINGPARAM("com.sun.star.loader.SharedLibrary") ))
|
|
|
|
return that->m_xNativeRDB;
|
|
|
|
else
|
|
|
|
return that->m_xCommonRDB;
|
|
|
|
}
|
|
|
|
|
2009-12-03 15:59:55 +01:00
|
|
|
//Returns the read only RDB.
|
|
|
|
const Reference<registry::XSimpleRegistry>
|
|
|
|
BackendImpl::ComponentPackageImpl::getRDB_RO() const
|
|
|
|
{
|
|
|
|
BackendImpl * that = getMyBackend();
|
|
|
|
|
|
|
|
if (m_loader.equalsAsciiL(
|
|
|
|
RTL_CONSTASCII_STRINGPARAM("com.sun.star.loader.SharedLibrary") ))
|
|
|
|
return that->m_xNativeRDB_RO;
|
|
|
|
else
|
|
|
|
return that->m_xCommonRDB_RO;
|
|
|
|
}
|
|
|
|
|
2008-05-20 13:33:31 +00:00
|
|
|
BackendImpl * BackendImpl::ComponentPackageImpl::getMyBackend() const
|
|
|
|
{
|
|
|
|
BackendImpl * pBackend = static_cast<BackendImpl *>(m_myBackend.get());
|
|
|
|
if (NULL == pBackend)
|
|
|
|
{
|
|
|
|
//Throws a DisposedException
|
|
|
|
check();
|
|
|
|
//We should never get here...
|
|
|
|
throw RuntimeException(
|
|
|
|
OUSTR("Failed to get the BackendImpl"),
|
|
|
|
static_cast<OWeakObject*>(const_cast<ComponentPackageImpl *>(this)));
|
|
|
|
}
|
|
|
|
return pBackend;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-06-11 11:13:15 +00:00
|
|
|
//______________________________________________________________________________
|
2004-11-09 13:11:20 +00:00
|
|
|
void BackendImpl::ComponentPackageImpl::disposing()
|
2004-06-11 11:13:15 +00:00
|
|
|
{
|
2010-04-21 16:04:34 +02:00
|
|
|
// m_xRemoteContext.clear();
|
2004-06-11 11:13:15 +00:00
|
|
|
Package::disposing();
|
|
|
|
}
|
|
|
|
|
|
|
|
//______________________________________________________________________________
|
2004-11-09 13:11:20 +00:00
|
|
|
void BackendImpl::TypelibraryPackageImpl::disposing()
|
2004-06-11 11:13:15 +00:00
|
|
|
{
|
|
|
|
m_xTDprov.clear();
|
|
|
|
Package::disposing();
|
|
|
|
}
|
|
|
|
|
2004-04-13 11:08:32 +00:00
|
|
|
//______________________________________________________________________________
|
|
|
|
void BackendImpl::disposing()
|
|
|
|
{
|
2004-08-12 11:10:09 +00:00
|
|
|
try {
|
2004-06-11 11:13:15 +00:00
|
|
|
m_backendObjects = t_string2object();
|
2004-08-12 11:10:09 +00:00
|
|
|
if (m_xNativeRDB.is()) {
|
2004-06-11 11:13:15 +00:00
|
|
|
m_xNativeRDB->close();
|
|
|
|
m_xNativeRDB.clear();
|
|
|
|
}
|
2004-08-12 11:10:09 +00:00
|
|
|
if (m_xCommonRDB.is()) {
|
2004-06-11 11:13:15 +00:00
|
|
|
m_xCommonRDB->close();
|
|
|
|
m_xCommonRDB.clear();
|
|
|
|
}
|
|
|
|
unorc_flush( Reference<XCommandEnvironment>() );
|
2004-04-13 11:08:32 +00:00
|
|
|
|
|
|
|
PackageRegistryBackend::disposing();
|
|
|
|
}
|
2004-08-12 11:10:09 +00:00
|
|
|
catch (RuntimeException &) {
|
2004-04-13 11:08:32 +00:00
|
|
|
throw;
|
|
|
|
}
|
2004-08-12 11:10:09 +00:00
|
|
|
catch (Exception &) {
|
2004-04-13 11:08:32 +00:00
|
|
|
Any exc( ::cppu::getCaughtException() );
|
|
|
|
throw lang::WrappedTargetRuntimeException(
|
|
|
|
OUSTR("caught unexpected exception while disposing..."),
|
2004-06-11 11:13:15 +00:00
|
|
|
static_cast<OWeakObject *>(this), exc );
|
2004-04-13 11:08:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-04 12:37:01 +02:00
|
|
|
|
2008-09-29 08:59:45 +00:00
|
|
|
void BackendImpl::initServiceRdbFiles()
|
|
|
|
{
|
|
|
|
const Reference<XCommandEnvironment> xCmdEnv;
|
2010-05-04 12:37:01 +02:00
|
|
|
|
|
|
|
::ucbhelper::Content cacheDir( getCachePath(), xCmdEnv );
|
|
|
|
::ucbhelper::Content oldRDB;
|
|
|
|
// switch common rdb:
|
|
|
|
if (m_commonRDB_RO.getLength() > 0)
|
2009-12-03 15:59:55 +01:00
|
|
|
{
|
2010-05-04 12:37:01 +02:00
|
|
|
create_ucb_content(
|
|
|
|
&oldRDB, makeURL( getCachePath(), m_commonRDB_RO),
|
|
|
|
xCmdEnv, false /* no throw */ );
|
|
|
|
}
|
|
|
|
m_commonRDB = m_commonRDB_RO.equalsAsciiL(
|
|
|
|
RTL_CONSTASCII_STRINGPARAM("common.rdb") )
|
|
|
|
? OUSTR("common_.rdb") : OUSTR("common.rdb");
|
|
|
|
if (oldRDB.get().is())
|
|
|
|
{
|
|
|
|
if (! cacheDir.transferContent(
|
2008-09-29 08:59:45 +00:00
|
|
|
oldRDB, ::ucbhelper::InsertOperation_COPY,
|
|
|
|
m_commonRDB, NameClash::OVERWRITE ))
|
2009-12-03 15:59:55 +01:00
|
|
|
{
|
2010-05-04 12:37:01 +02:00
|
|
|
|
|
|
|
throw RuntimeException(
|
|
|
|
OUSTR("UCB transferContent() failed!"), 0 );
|
2009-12-03 15:59:55 +01:00
|
|
|
}
|
2010-05-04 12:37:01 +02:00
|
|
|
oldRDB = ::ucbhelper::Content();
|
|
|
|
}
|
|
|
|
// switch native rdb:
|
|
|
|
if (m_nativeRDB_RO.getLength() > 0)
|
|
|
|
{
|
|
|
|
create_ucb_content(
|
|
|
|
&oldRDB, makeURL(getCachePath(), m_nativeRDB_RO),
|
|
|
|
xCmdEnv, false /* no throw */ );
|
|
|
|
}
|
|
|
|
const OUString plt_rdb( getPlatformString() + OUSTR(".rdb") );
|
|
|
|
const OUString plt_rdb_( getPlatformString() + OUSTR("_.rdb") );
|
|
|
|
m_nativeRDB = m_nativeRDB_RO.equals( plt_rdb ) ? plt_rdb_ : plt_rdb;
|
|
|
|
if (oldRDB.get().is())
|
|
|
|
{
|
|
|
|
if (! cacheDir.transferContent(
|
2008-09-29 08:59:45 +00:00
|
|
|
oldRDB, ::ucbhelper::InsertOperation_COPY,
|
|
|
|
m_nativeRDB, NameClash::OVERWRITE ))
|
2010-05-04 12:37:01 +02:00
|
|
|
throw RuntimeException(
|
2008-09-29 08:59:45 +00:00
|
|
|
OUSTR("UCB transferContent() failed!"), 0 );
|
|
|
|
}
|
|
|
|
|
2010-05-04 12:37:01 +02:00
|
|
|
// UNO is bootstrapped, flush for next process start:
|
|
|
|
m_unorc_modified = true;
|
|
|
|
unorc_flush( Reference<XCommandEnvironment>() );
|
|
|
|
|
|
|
|
|
2008-09-29 08:59:45 +00:00
|
|
|
// common rdb for java, native rdb for shared lib components
|
|
|
|
if (m_commonRDB.getLength() > 0) {
|
|
|
|
m_xCommonRDB.set(
|
|
|
|
m_xComponentContext->getServiceManager()
|
|
|
|
->createInstanceWithContext(
|
|
|
|
OUSTR("com.sun.star.registry.SimpleRegistry"),
|
|
|
|
m_xComponentContext ), UNO_QUERY_THROW );
|
|
|
|
m_xCommonRDB->open(
|
|
|
|
makeURL( expandUnoRcUrl(getCachePath()), m_commonRDB ),
|
2010-05-04 12:37:01 +02:00
|
|
|
false, true);
|
2008-09-29 08:59:45 +00:00
|
|
|
}
|
|
|
|
if (m_nativeRDB.getLength() > 0) {
|
|
|
|
m_xNativeRDB.set(
|
|
|
|
m_xComponentContext->getServiceManager()
|
|
|
|
->createInstanceWithContext(
|
|
|
|
OUSTR("com.sun.star.registry.SimpleRegistry"),
|
|
|
|
m_xComponentContext ), UNO_QUERY_THROW );
|
|
|
|
m_xNativeRDB->open(
|
|
|
|
makeURL( expandUnoRcUrl(getCachePath()), m_nativeRDB ),
|
2010-05-04 12:37:01 +02:00
|
|
|
false, true);
|
2008-09-29 08:59:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-03 15:59:55 +01:00
|
|
|
void BackendImpl::initServiceRdbFiles_RO()
|
|
|
|
{
|
|
|
|
const Reference<XCommandEnvironment> xCmdEnv;
|
|
|
|
|
|
|
|
// common rdb for java, native rdb for shared lib components
|
|
|
|
if (m_commonRDB_RO.getLength() > 0)
|
|
|
|
{
|
|
|
|
m_xCommonRDB_RO.set(
|
|
|
|
m_xComponentContext->getServiceManager()
|
|
|
|
->createInstanceWithContext(
|
|
|
|
OUSTR("com.sun.star.registry.SimpleRegistry"),
|
|
|
|
m_xComponentContext), UNO_QUERY_THROW);
|
|
|
|
m_xCommonRDB_RO->open(
|
|
|
|
makeURL(expandUnoRcUrl(getCachePath()), m_commonRDB_RO),
|
|
|
|
sal_True, //read-only
|
|
|
|
sal_True); // create data source if necessary
|
|
|
|
}
|
|
|
|
if (m_nativeRDB_RO.getLength() > 0)
|
|
|
|
{
|
|
|
|
m_xNativeRDB_RO.set(
|
|
|
|
m_xComponentContext->getServiceManager()
|
|
|
|
->createInstanceWithContext(
|
|
|
|
OUSTR("com.sun.star.registry.SimpleRegistry"),
|
|
|
|
m_xComponentContext), UNO_QUERY_THROW);
|
|
|
|
m_xNativeRDB_RO->open(
|
|
|
|
makeURL(expandUnoRcUrl(getCachePath()), m_nativeRDB_RO),
|
|
|
|
sal_True, //read-only
|
|
|
|
sal_True); // create data source if necessary
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-04-13 11:08:32 +00:00
|
|
|
//______________________________________________________________________________
|
2004-08-12 11:10:09 +00:00
|
|
|
BackendImpl::BackendImpl(
|
|
|
|
Sequence<Any> const & args,
|
2006-03-06 09:22:07 +00:00
|
|
|
Reference<XComponentContext> const & xComponentContext )
|
|
|
|
: PackageRegistryBackend( args, xComponentContext ),
|
2004-08-12 11:10:09 +00:00
|
|
|
m_unorc_inited( false ),
|
|
|
|
m_unorc_modified( false ),
|
2008-09-29 08:59:45 +00:00
|
|
|
bSwitchedRdbFiles(false),
|
2004-11-09 13:11:20 +00:00
|
|
|
m_xDynComponentTypeInfo( new Package::TypeInfo(
|
|
|
|
OUSTR("application/"
|
|
|
|
"vnd.sun.star.uno-component;"
|
|
|
|
"type=native;platform=") +
|
|
|
|
getPlatformString(),
|
|
|
|
OUSTR("*" SAL_DLLEXTENSION),
|
|
|
|
getResourceString(RID_STR_DYN_COMPONENT),
|
2010-11-11 14:30:42 +01:00
|
|
|
RID_IMG_COMPONENT) ),
|
2004-11-09 13:11:20 +00:00
|
|
|
m_xJavaComponentTypeInfo( new Package::TypeInfo(
|
|
|
|
OUSTR("application/"
|
|
|
|
"vnd.sun.star.uno-component;"
|
|
|
|
"type=Java"),
|
|
|
|
OUSTR("*.jar"),
|
|
|
|
getResourceString(RID_STR_JAVA_COMPONENT),
|
2010-11-11 14:30:42 +01:00
|
|
|
RID_IMG_JAVA_COMPONENT) ),
|
2004-11-09 13:11:20 +00:00
|
|
|
m_xPythonComponentTypeInfo( new Package::TypeInfo(
|
|
|
|
OUSTR("application/"
|
|
|
|
"vnd.sun.star.uno-component;"
|
|
|
|
"type=Python"),
|
|
|
|
OUSTR("*.py"),
|
|
|
|
getResourceString(
|
|
|
|
RID_STR_PYTHON_COMPONENT),
|
2010-11-11 14:30:42 +01:00
|
|
|
RID_IMG_COMPONENT ) ),
|
2004-11-09 13:11:20 +00:00
|
|
|
m_xRDBTypelibTypeInfo( new Package::TypeInfo(
|
|
|
|
OUSTR("application/"
|
|
|
|
"vnd.sun.star.uno-typelibrary;"
|
|
|
|
"type=RDB"),
|
|
|
|
OUSTR("*.rdb"),
|
|
|
|
getResourceString(RID_STR_RDB_TYPELIB),
|
2010-11-11 14:30:42 +01:00
|
|
|
RID_IMG_TYPELIB ) ),
|
2004-11-09 13:11:20 +00:00
|
|
|
m_xJavaTypelibTypeInfo( new Package::TypeInfo(
|
|
|
|
OUSTR("application/"
|
|
|
|
"vnd.sun.star.uno-typelibrary;"
|
|
|
|
"type=Java"),
|
|
|
|
OUSTR("*.jar"),
|
|
|
|
getResourceString(RID_STR_JAVA_TYPELIB),
|
2010-11-11 14:30:42 +01:00
|
|
|
RID_IMG_JAVA_TYPELIB ) ),
|
2004-11-09 13:11:20 +00:00
|
|
|
m_typeInfos( 5 )
|
2004-04-13 11:08:32 +00:00
|
|
|
{
|
2004-11-09 13:11:20 +00:00
|
|
|
m_typeInfos[ 0 ] = m_xDynComponentTypeInfo;
|
|
|
|
m_typeInfos[ 1 ] = m_xJavaComponentTypeInfo;
|
|
|
|
m_typeInfos[ 2 ] = m_xPythonComponentTypeInfo;
|
|
|
|
m_typeInfos[ 3 ] = m_xRDBTypelibTypeInfo;
|
|
|
|
m_typeInfos[ 4 ] = m_xJavaTypelibTypeInfo;
|
|
|
|
|
|
|
|
const Reference<XCommandEnvironment> xCmdEnv;
|
2004-04-13 11:08:32 +00:00
|
|
|
|
|
|
|
if (transientMode())
|
|
|
|
{
|
2004-06-11 11:13:15 +00:00
|
|
|
// in-mem rdbs:
|
|
|
|
// common rdb for java, native rdb for shared lib components
|
|
|
|
m_xCommonRDB.set(
|
2004-08-12 11:10:09 +00:00
|
|
|
xComponentContext->getServiceManager()->createInstanceWithContext(
|
2004-06-11 11:13:15 +00:00
|
|
|
OUSTR("com.sun.star.registry.SimpleRegistry"),
|
2004-08-12 11:10:09 +00:00
|
|
|
xComponentContext ), UNO_QUERY_THROW );
|
2004-06-11 11:13:15 +00:00
|
|
|
m_xCommonRDB->open( OUString() /* in-mem */,
|
|
|
|
false /* ! read-only */, true /* create */ );
|
|
|
|
m_xNativeRDB.set(
|
2004-08-12 11:10:09 +00:00
|
|
|
xComponentContext->getServiceManager()->createInstanceWithContext(
|
2004-06-11 11:13:15 +00:00
|
|
|
OUSTR("com.sun.star.registry.SimpleRegistry"),
|
2004-08-12 11:10:09 +00:00
|
|
|
xComponentContext ), UNO_QUERY_THROW );
|
2004-06-11 11:13:15 +00:00
|
|
|
m_xNativeRDB->open( OUString() /* in-mem */,
|
|
|
|
false /* ! read-only */, true /* create */ );
|
2004-04-13 11:08:32 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-12-03 15:59:55 +01:00
|
|
|
//do this before initServiceRdbFiles_RO, because it determines
|
|
|
|
//m_commonRDB and m_nativeRDB
|
2004-06-11 11:13:15 +00:00
|
|
|
unorc_verify_init( xCmdEnv );
|
2009-12-03 15:59:55 +01:00
|
|
|
|
|
|
|
initServiceRdbFiles_RO();
|
|
|
|
|
2010-05-04 12:37:01 +02:00
|
|
|
OUString dbFile = makeURL(getCachePath(), OUSTR("backenddb.xml"));
|
|
|
|
m_backendDb.reset(
|
|
|
|
new ComponentBackendDb(getComponentContext(), dbFile));
|
2004-04-13 11:08:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-04 12:37:01 +02:00
|
|
|
void BackendImpl::addDataToDb(
|
|
|
|
OUString const & url, ComponentBackendDb::Data const & data)
|
|
|
|
{
|
|
|
|
if (m_backendDb.get())
|
|
|
|
m_backendDb->addEntry(url, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BackendImpl::deleteDataFromDb(OUString const & url)
|
|
|
|
{
|
|
|
|
if (m_backendDb.get())
|
|
|
|
m_backendDb->removeEntry(url);
|
|
|
|
}
|
|
|
|
|
2010-03-22 12:35:33 +01:00
|
|
|
ComponentBackendDb::Data BackendImpl::readDataFromDb(OUString const & url)
|
|
|
|
{
|
|
|
|
ComponentBackendDb::Data data;
|
|
|
|
if (m_backendDb.get())
|
|
|
|
data = m_backendDb->getEntry(url);
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
2004-11-09 13:11:20 +00:00
|
|
|
// XPackageRegistry
|
|
|
|
//______________________________________________________________________________
|
|
|
|
Sequence< Reference<deployment::XPackageTypeInfo> >
|
|
|
|
BackendImpl::getSupportedPackageTypes() throw (RuntimeException)
|
2004-04-13 11:08:32 +00:00
|
|
|
{
|
2004-11-09 13:11:20 +00:00
|
|
|
return m_typeInfos;
|
2004-04-13 11:08:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// PackageRegistryBackend
|
|
|
|
//______________________________________________________________________________
|
2004-06-11 11:13:15 +00:00
|
|
|
Reference<deployment::XPackage> BackendImpl::bindPackage_(
|
|
|
|
OUString const & url, OUString const & mediaType_,
|
2010-03-22 12:35:33 +01:00
|
|
|
sal_Bool bRemoved, OUString const & identifier,
|
2004-06-11 11:13:15 +00:00
|
|
|
Reference<XCommandEnvironment> const & xCmdEnv )
|
2004-04-13 11:08:32 +00:00
|
|
|
{
|
2004-11-09 13:11:20 +00:00
|
|
|
OUString mediaType(mediaType_);
|
|
|
|
if (mediaType.getLength() == 0 ||
|
|
|
|
mediaType.equalsAsciiL(
|
|
|
|
RTL_CONSTASCII_STRINGPARAM(
|
|
|
|
"application/vnd.sun.star.uno-component") ) ||
|
|
|
|
mediaType.equalsAsciiL(
|
|
|
|
RTL_CONSTASCII_STRINGPARAM(
|
|
|
|
"application/vnd.sun.star.uno-typelibrary") ))
|
2004-04-13 11:08:32 +00:00
|
|
|
{
|
2004-11-09 13:11:20 +00:00
|
|
|
// detect exact media-type:
|
2007-06-05 14:06:30 +00:00
|
|
|
::ucbhelper::Content ucbContent;
|
2004-08-12 11:10:09 +00:00
|
|
|
if (create_ucb_content( &ucbContent, url, xCmdEnv )) {
|
2005-01-21 16:13:33 +00:00
|
|
|
const OUString title( ucbContent.getPropertyValue(
|
|
|
|
StrTitle::get() ).get<OUString>() );
|
2004-06-11 11:13:15 +00:00
|
|
|
if (title.endsWithIgnoreAsciiCaseAsciiL(
|
|
|
|
RTL_CONSTASCII_STRINGPARAM(SAL_DLLEXTENSION) ))
|
2004-04-13 11:08:32 +00:00
|
|
|
{
|
2004-06-11 11:13:15 +00:00
|
|
|
mediaType = OUSTR("application/vnd.sun.star.uno-component;"
|
|
|
|
"type=native;platform=") +
|
|
|
|
getPlatformString();
|
2004-04-13 11:08:32 +00:00
|
|
|
}
|
2004-06-11 11:13:15 +00:00
|
|
|
else if (title.endsWithIgnoreAsciiCaseAsciiL(
|
|
|
|
RTL_CONSTASCII_STRINGPARAM(".jar") ))
|
2004-04-13 11:08:32 +00:00
|
|
|
{
|
2007-03-12 10:02:40 +00:00
|
|
|
if (jarManifestHeaderPresent(
|
|
|
|
url, OUSTR("RegistrationClassName"), xCmdEnv ))
|
|
|
|
mediaType = OUSTR(
|
|
|
|
"application/vnd.sun.star.uno-component;type=Java");
|
2004-06-11 11:13:15 +00:00
|
|
|
if (mediaType.getLength() == 0)
|
|
|
|
mediaType = OUSTR(
|
|
|
|
"application/vnd.sun.star.uno-typelibrary;type=Java");
|
2004-04-13 11:08:32 +00:00
|
|
|
}
|
2004-06-11 11:13:15 +00:00
|
|
|
else if (title.endsWithIgnoreAsciiCaseAsciiL(
|
|
|
|
RTL_CONSTASCII_STRINGPARAM(".py") ))
|
|
|
|
mediaType =
|
|
|
|
OUSTR("application/vnd.sun.star.uno-component;type=Python");
|
|
|
|
else if (title.endsWithIgnoreAsciiCaseAsciiL(
|
|
|
|
RTL_CONSTASCII_STRINGPARAM(".rdb") ))
|
|
|
|
mediaType =
|
|
|
|
OUSTR("application/vnd.sun.star.uno-typelibrary;type=RDB");
|
2004-04-13 11:08:32 +00:00
|
|
|
}
|
2004-06-11 11:13:15 +00:00
|
|
|
if (mediaType.getLength() == 0)
|
|
|
|
throw lang::IllegalArgumentException(
|
2004-11-09 13:11:20 +00:00
|
|
|
StrCannotDetectMediaType::get() + url,
|
2004-06-11 11:13:15 +00:00
|
|
|
static_cast<OWeakObject *>(this), static_cast<sal_Int16>(-1) );
|
2004-04-13 11:08:32 +00:00
|
|
|
}
|
2004-06-11 11:13:15 +00:00
|
|
|
|
|
|
|
String type, subType;
|
|
|
|
INetContentTypeParameterList params;
|
|
|
|
if (INetContentTypes::parse( mediaType, type, subType, ¶ms ))
|
2004-04-13 11:08:32 +00:00
|
|
|
{
|
2004-06-11 11:13:15 +00:00
|
|
|
if (type.EqualsIgnoreCaseAscii("application"))
|
2004-04-13 11:08:32 +00:00
|
|
|
{
|
2010-03-22 12:35:33 +01:00
|
|
|
OUString name;
|
|
|
|
if (!bRemoved)
|
|
|
|
{
|
|
|
|
::ucbhelper::Content ucbContent( url, xCmdEnv );
|
|
|
|
name = ucbContent.getPropertyValue(
|
|
|
|
StrTitle::get() ).get<OUString>();
|
|
|
|
}
|
|
|
|
|
2004-06-11 11:13:15 +00:00
|
|
|
if (subType.EqualsIgnoreCaseAscii("vnd.sun.star.uno-component"))
|
2004-04-13 11:08:32 +00:00
|
|
|
{
|
2004-06-11 11:13:15 +00:00
|
|
|
// xxx todo: probe and evaluate component xml description
|
|
|
|
|
|
|
|
INetContentTypeParameter const * param = params.find(
|
|
|
|
ByteString("platform") );
|
2011-02-10 13:54:19 +01:00
|
|
|
bool bPlatformFits(param == 0);
|
|
|
|
String aPlatform;
|
|
|
|
if (!bPlatformFits) // platform is specified, we have to check
|
|
|
|
{
|
|
|
|
aPlatform = param->m_sValue;
|
|
|
|
bPlatformFits = platform_fits(aPlatform);
|
|
|
|
}
|
|
|
|
// If the package is being removed, do not care whether
|
|
|
|
// platform fits. We won't be using it anyway.
|
|
|
|
if (bPlatformFits || bRemoved) {
|
2004-06-11 11:13:15 +00:00
|
|
|
param = params.find( ByteString("type") );
|
|
|
|
if (param != 0)
|
|
|
|
{
|
|
|
|
String const & value = param->m_sValue;
|
2004-08-12 11:10:09 +00:00
|
|
|
if (value.EqualsIgnoreCaseAscii("native")) {
|
2011-02-10 13:54:19 +01:00
|
|
|
if (bPlatformFits)
|
|
|
|
return new BackendImpl::ComponentPackageImpl(
|
|
|
|
this, url, name, m_xDynComponentTypeInfo,
|
|
|
|
OUSTR("com.sun.star.loader.SharedLibrary"),
|
|
|
|
bRemoved, identifier);
|
|
|
|
else
|
|
|
|
return new BackendImpl::OtherPlatformPackageImpl(
|
|
|
|
this, url, name, m_xDynComponentTypeInfo,
|
|
|
|
bRemoved, identifier, aPlatform);
|
2004-06-11 11:13:15 +00:00
|
|
|
}
|
2004-08-12 11:10:09 +00:00
|
|
|
if (value.EqualsIgnoreCaseAscii("Java")) {
|
2004-11-09 13:11:20 +00:00
|
|
|
return new BackendImpl::ComponentPackageImpl(
|
|
|
|
this, url, name, m_xJavaComponentTypeInfo,
|
2010-05-04 12:37:01 +02:00
|
|
|
OUSTR("com.sun.star.loader.Java2"),
|
2010-03-22 12:35:33 +01:00
|
|
|
bRemoved, identifier);
|
2004-06-11 11:13:15 +00:00
|
|
|
}
|
2004-08-12 11:10:09 +00:00
|
|
|
if (value.EqualsIgnoreCaseAscii("Python")) {
|
2004-11-09 13:11:20 +00:00
|
|
|
return new BackendImpl::ComponentPackageImpl(
|
|
|
|
this, url, name, m_xPythonComponentTypeInfo,
|
2010-05-04 12:37:01 +02:00
|
|
|
OUSTR("com.sun.star.loader.Python"),
|
2010-03-22 12:35:33 +01:00
|
|
|
bRemoved, identifier);
|
2004-06-11 11:13:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-04-13 11:08:32 +00:00
|
|
|
}
|
2004-06-11 11:13:15 +00:00
|
|
|
else if (subType.EqualsIgnoreCaseAscii(
|
|
|
|
"vnd.sun.star.uno-typelibrary"))
|
2004-04-13 11:08:32 +00:00
|
|
|
{
|
2004-06-11 11:13:15 +00:00
|
|
|
INetContentTypeParameter const * param = params.find(
|
|
|
|
ByteString("type") );
|
2004-08-12 11:10:09 +00:00
|
|
|
if (param != 0) {
|
2004-06-11 11:13:15 +00:00
|
|
|
String const & value = param->m_sValue;
|
|
|
|
if (value.EqualsIgnoreCaseAscii("RDB"))
|
|
|
|
{
|
2004-11-09 13:11:20 +00:00
|
|
|
return new BackendImpl::TypelibraryPackageImpl(
|
|
|
|
this, url, name, m_xRDBTypelibTypeInfo,
|
2010-03-22 12:35:33 +01:00
|
|
|
false /* rdb */, bRemoved, identifier);
|
2004-06-11 11:13:15 +00:00
|
|
|
}
|
2004-08-12 11:10:09 +00:00
|
|
|
if (value.EqualsIgnoreCaseAscii("Java")) {
|
2004-11-09 13:11:20 +00:00
|
|
|
return new BackendImpl::TypelibraryPackageImpl(
|
|
|
|
this, url, name, m_xJavaTypelibTypeInfo,
|
2010-03-22 12:35:33 +01:00
|
|
|
true /* jar */, bRemoved, identifier);
|
2004-06-11 11:13:15 +00:00
|
|
|
}
|
|
|
|
}
|
2004-04-13 11:08:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
throw lang::IllegalArgumentException(
|
2004-11-09 13:11:20 +00:00
|
|
|
StrUnsupportedMediaType::get() + mediaType,
|
2004-06-11 11:13:15 +00:00
|
|
|
static_cast<OWeakObject *>(this),
|
|
|
|
static_cast<sal_Int16>(-1) );
|
2004-04-13 11:08:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//##############################################################################
|
|
|
|
|
|
|
|
//______________________________________________________________________________
|
|
|
|
void BackendImpl::unorc_verify_init(
|
2004-06-11 11:13:15 +00:00
|
|
|
Reference<XCommandEnvironment> const & xCmdEnv )
|
2004-04-13 11:08:32 +00:00
|
|
|
{
|
|
|
|
if (transientMode())
|
|
|
|
return;
|
2004-11-09 13:11:20 +00:00
|
|
|
const ::osl::MutexGuard guard( getMutex() );
|
2004-04-13 11:08:32 +00:00
|
|
|
if (! m_unorc_inited)
|
|
|
|
{
|
2004-06-11 11:13:15 +00:00
|
|
|
// common rc:
|
2007-06-05 14:06:30 +00:00
|
|
|
::ucbhelper::Content ucb_content;
|
2004-04-13 11:08:32 +00:00
|
|
|
if (create_ucb_content(
|
|
|
|
&ucb_content,
|
2004-11-09 13:11:20 +00:00
|
|
|
makeURL( getCachePath(), OUSTR("unorc") ),
|
2004-04-13 11:08:32 +00:00
|
|
|
xCmdEnv, false /* no throw */ ))
|
|
|
|
{
|
|
|
|
OUString line;
|
2006-05-09 09:45:29 +00:00
|
|
|
if (readLine( &line, OUSTR("UNO_JAVA_CLASSPATH="), ucb_content,
|
2004-04-13 11:08:32 +00:00
|
|
|
RTL_TEXTENCODING_UTF8 ))
|
|
|
|
{
|
2006-05-09 09:45:29 +00:00
|
|
|
sal_Int32 index = sizeof ("UNO_JAVA_CLASSPATH=") - 1;
|
2004-08-12 11:10:09 +00:00
|
|
|
do {
|
2004-04-13 11:08:32 +00:00
|
|
|
OUString token( line.getToken( 0, ' ', index ).trim() );
|
2010-03-22 12:35:33 +01:00
|
|
|
if (token.getLength() > 0)
|
|
|
|
{
|
2010-05-07 17:02:22 +02:00
|
|
|
if (create_ucb_content(
|
|
|
|
0, expandUnoRcTerm(token), xCmdEnv,
|
|
|
|
false /* no throw */ ))
|
|
|
|
{
|
|
|
|
//The jar file may not exist anymore if a shared or bundled
|
|
|
|
//extension was removed, but it can still be in the unorc
|
|
|
|
//After running XExtensionManager::synchronize, the unorc is
|
|
|
|
//cleaned up
|
|
|
|
m_jar_typelibs.push_back( token );
|
|
|
|
}
|
2004-06-11 11:13:15 +00:00
|
|
|
}
|
2004-04-13 11:08:32 +00:00
|
|
|
}
|
|
|
|
while (index >= 0);
|
|
|
|
}
|
2006-05-09 09:45:29 +00:00
|
|
|
if (readLine( &line, OUSTR("UNO_TYPES="), ucb_content,
|
2004-08-12 11:10:09 +00:00
|
|
|
RTL_TEXTENCODING_UTF8 )) {
|
2006-05-09 09:45:29 +00:00
|
|
|
sal_Int32 index = sizeof ("UNO_TYPES=") - 1;
|
2004-08-12 11:10:09 +00:00
|
|
|
do {
|
2004-04-13 11:08:32 +00:00
|
|
|
OUString token( line.getToken( 0, ' ', index ).trim() );
|
2010-03-22 12:35:33 +01:00
|
|
|
if (token.getLength() > 0)
|
|
|
|
{
|
2004-06-11 11:13:15 +00:00
|
|
|
if (token[ 0 ] == '?')
|
|
|
|
token = token.copy( 1 );
|
2010-05-07 17:02:22 +02:00
|
|
|
if (create_ucb_content(
|
|
|
|
0, expandUnoRcTerm(token), xCmdEnv,
|
|
|
|
false /* no throw */ ))
|
|
|
|
{
|
|
|
|
//The RDB file may not exist anymore if a shared or bundled
|
|
|
|
//extension was removed, but it can still be in the unorc.
|
|
|
|
//After running XExtensionManager::synchronize, the unorc is
|
|
|
|
//cleaned up
|
|
|
|
m_rdb_typelibs.push_back( token );
|
|
|
|
}
|
2004-06-11 11:13:15 +00:00
|
|
|
}
|
2004-04-13 11:08:32 +00:00
|
|
|
}
|
|
|
|
while (index >= 0);
|
|
|
|
}
|
2006-05-09 09:45:29 +00:00
|
|
|
if (readLine( &line, OUSTR("UNO_SERVICES="), ucb_content,
|
2004-08-12 11:10:09 +00:00
|
|
|
RTL_TEXTENCODING_UTF8 )) {
|
2006-05-09 09:45:29 +00:00
|
|
|
sal_Int32 start = sizeof ("UNO_SERVICES=?$ORIGIN/") - 1;
|
2004-06-11 11:13:15 +00:00
|
|
|
sal_Int32 sep = line.indexOf( ' ', start );
|
|
|
|
OSL_ASSERT( sep > 0 );
|
2009-12-03 15:59:55 +01:00
|
|
|
m_commonRDB_RO = line.copy( start, sep - start );
|
2004-06-11 11:13:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// native rc:
|
|
|
|
if (create_ucb_content(
|
|
|
|
&ucb_content,
|
2004-11-09 13:11:20 +00:00
|
|
|
makeURL( getCachePath(), getPlatformString() + OUSTR("rc")),
|
2004-08-12 11:10:09 +00:00
|
|
|
xCmdEnv, false /* no throw */ )) {
|
2006-05-09 09:45:29 +00:00
|
|
|
if (readLine( &line, OUSTR("UNO_SERVICES="), ucb_content,
|
2004-08-12 11:10:09 +00:00
|
|
|
RTL_TEXTENCODING_UTF8 )) {
|
2009-12-03 15:59:55 +01:00
|
|
|
m_nativeRDB_RO = line.copy(
|
2006-05-09 09:45:29 +00:00
|
|
|
sizeof ("UNO_SERVICES=?$ORIGIN/") - 1 );
|
2004-06-11 11:13:15 +00:00
|
|
|
}
|
|
|
|
}
|
2004-04-13 11:08:32 +00:00
|
|
|
}
|
2004-06-11 11:13:15 +00:00
|
|
|
m_unorc_modified = false;
|
|
|
|
m_unorc_inited = true;
|
2004-04-13 11:08:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//______________________________________________________________________________
|
2004-06-11 11:13:15 +00:00
|
|
|
void BackendImpl::unorc_flush( Reference<XCommandEnvironment> const & xCmdEnv )
|
2004-04-13 11:08:32 +00:00
|
|
|
{
|
|
|
|
if (transientMode())
|
|
|
|
return;
|
|
|
|
if (!m_unorc_inited || !m_unorc_modified)
|
|
|
|
return;
|
|
|
|
|
|
|
|
::rtl::OStringBuffer buf;
|
2010-05-04 12:37:01 +02:00
|
|
|
|
|
|
|
buf.append(RTL_CONSTASCII_STRINGPARAM("ORIGIN="));
|
2010-05-07 17:02:22 +02:00
|
|
|
OUString sOrigin = dp_misc::makeRcTerm(m_cachePath);
|
2010-05-04 12:37:01 +02:00
|
|
|
::rtl::OString osOrigin = ::rtl::OUStringToOString(sOrigin, RTL_TEXTENCODING_UTF8);
|
|
|
|
buf.append(osOrigin);
|
2004-11-09 13:11:20 +00:00
|
|
|
buf.append(LF);
|
|
|
|
|
2004-04-13 11:08:32 +00:00
|
|
|
if (! m_jar_typelibs.empty())
|
|
|
|
{
|
2004-08-12 11:10:09 +00:00
|
|
|
t_stringlist::const_iterator iPos( m_jar_typelibs.begin() );
|
|
|
|
t_stringlist::const_iterator const iEnd( m_jar_typelibs.end() );
|
2006-05-09 09:45:29 +00:00
|
|
|
buf.append( RTL_CONSTASCII_STRINGPARAM("UNO_JAVA_CLASSPATH=") );
|
2004-08-12 11:10:09 +00:00
|
|
|
while (iPos != iEnd) {
|
2004-04-13 11:08:32 +00:00
|
|
|
// encoded ASCII file-urls:
|
2004-11-09 13:11:20 +00:00
|
|
|
const ::rtl::OString item(
|
2004-04-13 11:08:32 +00:00
|
|
|
::rtl::OUStringToOString( *iPos, RTL_TEXTENCODING_ASCII_US ) );
|
|
|
|
buf.append( item );
|
|
|
|
++iPos;
|
|
|
|
if (iPos != iEnd)
|
|
|
|
buf.append( ' ' );
|
|
|
|
}
|
2004-11-09 13:11:20 +00:00
|
|
|
buf.append(LF);
|
2004-04-13 11:08:32 +00:00
|
|
|
}
|
2004-06-11 11:13:15 +00:00
|
|
|
if (! m_rdb_typelibs.empty())
|
2004-04-13 11:08:32 +00:00
|
|
|
{
|
2004-08-12 11:10:09 +00:00
|
|
|
t_stringlist::const_iterator iPos( m_rdb_typelibs.begin() );
|
|
|
|
t_stringlist::const_iterator const iEnd( m_rdb_typelibs.end() );
|
2006-05-09 09:45:29 +00:00
|
|
|
buf.append( RTL_CONSTASCII_STRINGPARAM("UNO_TYPES=") );
|
2004-08-12 11:10:09 +00:00
|
|
|
while (iPos != iEnd) {
|
2004-06-11 11:13:15 +00:00
|
|
|
buf.append( '?' );
|
2004-04-13 11:08:32 +00:00
|
|
|
// encoded ASCII file-urls:
|
2004-11-09 13:11:20 +00:00
|
|
|
const ::rtl::OString item(
|
2004-04-13 11:08:32 +00:00
|
|
|
::rtl::OUStringToOString( *iPos, RTL_TEXTENCODING_ASCII_US ) );
|
|
|
|
buf.append( item );
|
|
|
|
++iPos;
|
|
|
|
if (iPos != iEnd)
|
|
|
|
buf.append( ' ' );
|
|
|
|
}
|
2004-11-09 13:11:20 +00:00
|
|
|
buf.append(LF);
|
2004-06-11 11:13:15 +00:00
|
|
|
}
|
2009-12-03 15:59:55 +01:00
|
|
|
|
|
|
|
// If we duplicated the common or native rdb then we must use those urls
|
|
|
|
//otherwise we use those of the original files. That is, m_commonRDB_RO and
|
|
|
|
//m_nativeRDB_RO;
|
|
|
|
OUString sCommonRDB(m_commonRDB.getLength() > 0 ? m_commonRDB : m_commonRDB_RO);
|
|
|
|
OUString sNativeRDB(m_nativeRDB.getLength() > 0 ? m_nativeRDB : m_nativeRDB_RO);
|
|
|
|
|
|
|
|
if (sCommonRDB.getLength() > 0 || sNativeRDB.getLength() > 0)
|
2004-06-11 11:13:15 +00:00
|
|
|
{
|
2006-05-09 09:45:29 +00:00
|
|
|
buf.append( RTL_CONSTASCII_STRINGPARAM("UNO_SERVICES=?$ORIGIN/") );
|
2004-06-11 11:13:15 +00:00
|
|
|
buf.append( ::rtl::OUStringToOString(
|
2009-12-03 15:59:55 +01:00
|
|
|
sCommonRDB, RTL_TEXTENCODING_ASCII_US ) );
|
|
|
|
if (sNativeRDB.getLength() > 0)
|
2004-06-11 11:13:15 +00:00
|
|
|
{
|
|
|
|
buf.append( RTL_CONSTASCII_STRINGPARAM(
|
2006-05-09 09:45:29 +00:00
|
|
|
" ${$ORIGIN/${_OS}_${_ARCH}rc:UNO_SERVICES}") );
|
2004-11-09 13:11:20 +00:00
|
|
|
buf.append(LF);
|
2004-06-11 11:13:15 +00:00
|
|
|
|
|
|
|
// write native rc:
|
|
|
|
::rtl::OStringBuffer buf2;
|
2010-05-04 12:37:01 +02:00
|
|
|
buf2.append(RTL_CONSTASCII_STRINGPARAM("ORIGIN="));
|
|
|
|
buf2.append(osOrigin);
|
|
|
|
buf2.append(LF);
|
2006-05-09 09:45:29 +00:00
|
|
|
buf2.append( RTL_CONSTASCII_STRINGPARAM("UNO_SERVICES=?$ORIGIN/") );
|
2004-06-11 11:13:15 +00:00
|
|
|
buf2.append( ::rtl::OUStringToOString(
|
2009-12-03 15:59:55 +01:00
|
|
|
sNativeRDB, RTL_TEXTENCODING_ASCII_US ) );
|
2004-11-09 13:11:20 +00:00
|
|
|
buf2.append(LF);
|
2004-06-11 11:13:15 +00:00
|
|
|
|
2004-11-09 13:11:20 +00:00
|
|
|
const Reference<io::XInputStream> xData(
|
2004-06-11 11:13:15 +00:00
|
|
|
::xmlscript::createInputStream(
|
|
|
|
::rtl::ByteSequence(
|
|
|
|
reinterpret_cast<sal_Int8 const *>(buf2.getStr()),
|
|
|
|
buf2.getLength() ) ) );
|
2007-06-05 14:06:30 +00:00
|
|
|
::ucbhelper::Content ucb_content(
|
2004-11-09 13:11:20 +00:00
|
|
|
makeURL( getCachePath(), getPlatformString() + OUSTR("rc") ),
|
|
|
|
xCmdEnv );
|
2004-06-11 11:13:15 +00:00
|
|
|
ucb_content.writeStream( xData, true /* replace existing */ );
|
|
|
|
}
|
2004-04-13 11:08:32 +00:00
|
|
|
}
|
|
|
|
|
2004-06-11 11:13:15 +00:00
|
|
|
// write unorc:
|
2004-11-09 13:11:20 +00:00
|
|
|
const Reference<io::XInputStream> xData(
|
2004-04-13 11:08:32 +00:00
|
|
|
::xmlscript::createInputStream(
|
|
|
|
::rtl::ByteSequence(
|
2004-06-11 11:13:15 +00:00
|
|
|
reinterpret_cast<sal_Int8 const *>(buf.getStr()),
|
2004-04-13 11:08:32 +00:00
|
|
|
buf.getLength() ) ) );
|
2007-06-05 14:06:30 +00:00
|
|
|
::ucbhelper::Content ucb_content(
|
2004-11-09 13:11:20 +00:00
|
|
|
makeURL( getCachePath(), OUSTR("unorc") ), xCmdEnv );
|
2004-04-13 11:08:32 +00:00
|
|
|
ucb_content.writeStream( xData, true /* replace existing */ );
|
|
|
|
|
2004-06-11 11:13:15 +00:00
|
|
|
m_unorc_modified = false;
|
2004-04-13 11:08:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//______________________________________________________________________________
|
2004-11-09 13:11:20 +00:00
|
|
|
bool BackendImpl::addToUnoRc( bool jarFile, OUString const & url_,
|
2004-06-11 11:13:15 +00:00
|
|
|
Reference<XCommandEnvironment> const & xCmdEnv )
|
2004-04-13 11:08:32 +00:00
|
|
|
{
|
2010-05-07 17:02:22 +02:00
|
|
|
const OUString rcterm( dp_misc::makeRcTerm(url_) );
|
2004-11-09 13:11:20 +00:00
|
|
|
const ::osl::MutexGuard guard( getMutex() );
|
2004-04-13 11:08:32 +00:00
|
|
|
unorc_verify_init( xCmdEnv );
|
2004-08-12 11:10:09 +00:00
|
|
|
t_stringlist & rSet = getTypelibs(jarFile);
|
2004-11-09 13:11:20 +00:00
|
|
|
if (::std::find( rSet.begin(), rSet.end(), rcterm ) == rSet.end()) {
|
|
|
|
rSet.push_front( rcterm ); // prepend to list, thus overriding
|
2004-08-12 11:10:09 +00:00
|
|
|
// write immediately:
|
|
|
|
m_unorc_modified = true;
|
|
|
|
unorc_flush( xCmdEnv );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return false;
|
2004-04-13 11:08:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//______________________________________________________________________________
|
|
|
|
bool BackendImpl::removeFromUnoRc(
|
2004-11-09 13:11:20 +00:00
|
|
|
bool jarFile, OUString const & url_,
|
2004-06-11 11:13:15 +00:00
|
|
|
Reference<XCommandEnvironment> const & xCmdEnv )
|
2004-04-13 11:08:32 +00:00
|
|
|
{
|
2010-05-07 17:02:22 +02:00
|
|
|
const OUString rcterm( dp_misc::makeRcTerm(url_) );
|
2004-11-09 13:11:20 +00:00
|
|
|
const ::osl::MutexGuard guard( getMutex() );
|
2004-04-13 11:08:32 +00:00
|
|
|
unorc_verify_init( xCmdEnv );
|
2004-11-09 13:11:20 +00:00
|
|
|
getTypelibs(jarFile).remove( rcterm );
|
2004-04-13 11:08:32 +00:00
|
|
|
// write immediately:
|
2004-08-12 11:10:09 +00:00
|
|
|
m_unorc_modified = true;
|
2004-04-13 11:08:32 +00:00
|
|
|
unorc_flush( xCmdEnv );
|
2004-08-12 11:10:09 +00:00
|
|
|
return true;
|
2004-04-13 11:08:32 +00:00
|
|
|
}
|
|
|
|
|
2004-06-11 11:13:15 +00:00
|
|
|
//______________________________________________________________________________
|
|
|
|
bool BackendImpl::hasInUnoRc(
|
2006-10-12 13:10:14 +00:00
|
|
|
bool jarFile, OUString const & url_ )
|
2004-06-11 11:13:15 +00:00
|
|
|
{
|
2010-05-07 17:02:22 +02:00
|
|
|
const OUString rcterm( dp_misc::makeRcTerm(url_) );
|
2004-11-09 13:11:20 +00:00
|
|
|
const ::osl::MutexGuard guard( getMutex() );
|
2004-08-12 11:10:09 +00:00
|
|
|
t_stringlist const & rSet = getTypelibs(jarFile);
|
2004-11-09 13:11:20 +00:00
|
|
|
return ::std::find( rSet.begin(), rSet.end(), rcterm ) != rSet.end();
|
2004-04-13 11:08:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//______________________________________________________________________________
|
2004-06-11 11:13:15 +00:00
|
|
|
void BackendImpl::releaseObject( OUString const & id )
|
|
|
|
{
|
2004-11-09 13:11:20 +00:00
|
|
|
const ::osl::MutexGuard guard( getMutex() );
|
2006-10-12 13:10:14 +00:00
|
|
|
if ( m_backendObjects.erase( id ) != 1 )
|
|
|
|
{
|
|
|
|
OSL_ASSERT( false );
|
|
|
|
}
|
2004-06-11 11:13:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//______________________________________________________________________________
|
|
|
|
Reference<XInterface> BackendImpl::getObject( OUString const & id )
|
|
|
|
{
|
2004-11-09 13:11:20 +00:00
|
|
|
const ::osl::MutexGuard guard( getMutex() );
|
|
|
|
const t_string2object::const_iterator iFind( m_backendObjects.find( id ) );
|
2004-06-11 11:13:15 +00:00
|
|
|
if (iFind == m_backendObjects.end())
|
|
|
|
return Reference<XInterface>();
|
|
|
|
else
|
|
|
|
return iFind->second;
|
|
|
|
}
|
|
|
|
|
|
|
|
//______________________________________________________________________________
|
|
|
|
Reference<XInterface> BackendImpl::insertObject(
|
|
|
|
OUString const & id, Reference<XInterface> const & xObject )
|
|
|
|
{
|
2004-11-09 13:11:20 +00:00
|
|
|
const ::osl::MutexGuard guard( getMutex() );
|
|
|
|
const ::std::pair<t_string2object::iterator, bool> insertion(
|
2004-06-11 11:13:15 +00:00
|
|
|
m_backendObjects.insert( t_string2object::value_type(
|
|
|
|
id, xObject ) ) );
|
|
|
|
return insertion.first->second;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2004-11-09 13:11:20 +00:00
|
|
|
Reference<XComponentContext> raise_uno_process(
|
2004-06-11 11:13:15 +00:00
|
|
|
Reference<XComponentContext> const & xContext,
|
|
|
|
::rtl::Reference<AbortChannel> const & abortChannel )
|
|
|
|
{
|
2007-10-15 11:59:46 +00:00
|
|
|
OSL_ASSERT( xContext.is() );
|
|
|
|
|
|
|
|
::rtl::OUString url(
|
|
|
|
Reference<util::XMacroExpander>(
|
|
|
|
xContext->getValueByName(
|
|
|
|
OUSTR("/singletons/com.sun.star.util.theMacroExpander") ),
|
|
|
|
UNO_QUERY_THROW )->
|
|
|
|
expandMacros( OUSTR("$URE_BIN_DIR/uno") ) );
|
|
|
|
|
2004-06-11 11:13:15 +00:00
|
|
|
::rtl::OUStringBuffer buf;
|
|
|
|
buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("uno:pipe,name=") );
|
|
|
|
OUString pipeId( generateRandomPipeId() );
|
|
|
|
buf.append( pipeId );
|
|
|
|
buf.appendAscii(
|
|
|
|
RTL_CONSTASCII_STRINGPARAM(";urp;uno.ComponentContext") );
|
2004-11-09 13:11:20 +00:00
|
|
|
const OUString connectStr( buf.makeStringAndClear() );
|
2004-06-11 11:13:15 +00:00
|
|
|
|
|
|
|
// raise core UNO process to register/run a component,
|
|
|
|
// javavm service uses unorc next to executable to retrieve deployed
|
|
|
|
// jar typelibs
|
|
|
|
|
|
|
|
::std::vector<OUString> args;
|
|
|
|
#if OSL_DEBUG_LEVEL <= 1
|
|
|
|
args.push_back( OUSTR("--quiet") );
|
|
|
|
#endif
|
|
|
|
args.push_back( OUSTR("--singleaccept") );
|
|
|
|
args.push_back( OUSTR("-u") );
|
|
|
|
args.push_back( connectStr );
|
2005-11-17 15:13:34 +00:00
|
|
|
// don't inherit from unorc:
|
|
|
|
args.push_back( OUSTR("-env:INIFILENAME=") );
|
2004-06-11 11:13:15 +00:00
|
|
|
|
2007-08-17 10:52:05 +00:00
|
|
|
//now add the bootstrap variables which were supplied on the command line
|
|
|
|
::std::vector<OUString> bootvars = getCmdBootstrapVariables();
|
|
|
|
args.insert(args.end(), bootvars.begin(), bootvars.end());
|
|
|
|
|
2004-06-11 11:13:15 +00:00
|
|
|
oslProcess hProcess = raiseProcess(
|
2007-10-15 11:59:46 +00:00
|
|
|
url, comphelper::containerToSequence(args) );
|
2004-08-12 11:10:09 +00:00
|
|
|
try {
|
2004-06-11 11:13:15 +00:00
|
|
|
return Reference<XComponentContext>(
|
|
|
|
resolveUnoURL( connectStr, xContext, abortChannel.get() ),
|
|
|
|
UNO_QUERY_THROW );
|
|
|
|
}
|
2004-08-12 11:10:09 +00:00
|
|
|
catch (...) {
|
2004-06-11 11:13:15 +00:00
|
|
|
// try to terminate process:
|
2006-10-12 13:10:14 +00:00
|
|
|
if ( osl_terminateProcess( hProcess ) != osl_Process_E_None )
|
|
|
|
{
|
|
|
|
OSL_ASSERT( false );
|
|
|
|
}
|
2004-06-11 11:13:15 +00:00
|
|
|
throw;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2004-08-12 11:10:09 +00:00
|
|
|
Reference<loader::XImplementationLoader>
|
2004-11-09 13:11:20 +00:00
|
|
|
BackendImpl::ComponentPackageImpl::getComponentInfo(
|
2004-08-12 11:10:09 +00:00
|
|
|
t_stringlist * pImplNames, t_stringpairvec * pSingletons,
|
2004-06-11 11:13:15 +00:00
|
|
|
Reference<XComponentContext> const & xContext )
|
2004-04-13 11:08:32 +00:00
|
|
|
{
|
2004-11-09 13:11:20 +00:00
|
|
|
const Reference<loader::XImplementationLoader> xLoader(
|
2004-08-12 11:10:09 +00:00
|
|
|
xContext->getServiceManager()->createInstanceWithContext(
|
|
|
|
m_loader, xContext ), UNO_QUERY );
|
|
|
|
if (! xLoader.is())
|
|
|
|
return Reference<loader::XImplementationLoader>();
|
|
|
|
|
2004-04-13 11:08:32 +00:00
|
|
|
// HACK: highly dependent on stoc/source/servicemanager
|
|
|
|
// and stoc/source/implreg implementation which rely on the same
|
|
|
|
// services.rdb format!
|
2004-06-11 11:13:15 +00:00
|
|
|
|
2004-11-09 13:11:20 +00:00
|
|
|
const Reference<registry::XSimpleRegistry> xMemReg(
|
2004-04-13 11:08:32 +00:00
|
|
|
xContext->getServiceManager()->createInstanceWithContext(
|
|
|
|
OUSTR("com.sun.star.registry.SimpleRegistry"), xContext ),
|
|
|
|
UNO_QUERY_THROW );
|
|
|
|
xMemReg->open( OUString() /* in mem */, false, true );
|
2004-08-12 11:10:09 +00:00
|
|
|
xLoader->writeRegistryInfo( xMemReg->getRootKey(), OUString(), getURL() );
|
2004-04-13 11:08:32 +00:00
|
|
|
|
2004-11-09 13:11:20 +00:00
|
|
|
const Sequence< Reference<registry::XRegistryKey> > keys(
|
2004-04-13 11:08:32 +00:00
|
|
|
xMemReg->getRootKey()->openKeys() );
|
2004-06-11 11:13:15 +00:00
|
|
|
for ( sal_Int32 pos = keys.getLength(); pos--; )
|
2004-04-13 11:08:32 +00:00
|
|
|
{
|
2004-11-09 13:11:20 +00:00
|
|
|
Reference<registry::XRegistryKey> const & xImplKey = keys[ pos ];
|
|
|
|
const OUString implName(
|
|
|
|
xImplKey->getKeyName().copy( 1 /*leading slash*/ ) );
|
2004-06-11 11:13:15 +00:00
|
|
|
|
|
|
|
// check for singletons:
|
2004-11-09 13:11:20 +00:00
|
|
|
const Reference<registry::XRegistryKey> xSingletonKey(
|
2004-06-11 11:13:15 +00:00
|
|
|
xImplKey->openKey( OUSTR("UNO/SINGLETONS") ) );
|
|
|
|
if (xSingletonKey.is() && xSingletonKey->isValid())
|
2004-04-13 11:08:32 +00:00
|
|
|
{
|
2004-11-09 13:11:20 +00:00
|
|
|
const Sequence< Reference<registry::XRegistryKey> > singletonKeys(
|
2004-06-11 11:13:15 +00:00
|
|
|
xSingletonKey->openKeys() );
|
|
|
|
for ( sal_Int32 i = singletonKeys.getLength(); i--; )
|
|
|
|
{
|
|
|
|
Reference<registry::XRegistryKey> const & xSingleton =
|
2004-11-09 13:11:20 +00:00
|
|
|
singletonKeys[ i ];
|
2004-08-12 11:10:09 +00:00
|
|
|
pSingletons->push_back(
|
|
|
|
::std::pair<OUString, OUString>(
|
|
|
|
xSingleton->getKeyName().copy(
|
|
|
|
implName.getLength() +
|
|
|
|
sizeof ("//UNO/SINGLETONS/") - 1 ),
|
|
|
|
xSingleton->getStringValue() ) );
|
2004-06-11 11:13:15 +00:00
|
|
|
}
|
2004-04-13 11:08:32 +00:00
|
|
|
}
|
2007-06-13 06:59:29 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
pImplNames->push_back( implName );
|
|
|
|
}
|
2004-04-13 11:08:32 +00:00
|
|
|
}
|
2004-06-11 11:13:15 +00:00
|
|
|
|
2004-08-12 11:10:09 +00:00
|
|
|
return xLoader;
|
2004-04-13 11:08:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Package
|
|
|
|
//______________________________________________________________________________
|
2004-08-12 11:10:09 +00:00
|
|
|
beans::Optional< beans::Ambiguous<sal_Bool> >
|
2004-11-09 13:11:20 +00:00
|
|
|
BackendImpl::ComponentPackageImpl::isRegistered_(
|
2006-10-12 13:10:14 +00:00
|
|
|
::osl::ResettableMutexGuard &,
|
2004-06-11 11:13:15 +00:00
|
|
|
::rtl::Reference<AbortChannel> const & abortChannel,
|
2006-10-12 13:10:14 +00:00
|
|
|
Reference<XCommandEnvironment> const & )
|
2004-04-13 11:08:32 +00:00
|
|
|
{
|
2004-06-11 11:13:15 +00:00
|
|
|
if (m_registered == REG_UNINIT)
|
2004-04-13 11:08:32 +00:00
|
|
|
{
|
|
|
|
m_registered = REG_NOT_REGISTERED;
|
2009-12-04 13:39:33 +01:00
|
|
|
bool bAmbiguousComponentName = false;
|
2009-12-03 15:59:55 +01:00
|
|
|
const Reference<registry::XSimpleRegistry> xRDB( getRDB_RO() );
|
2004-08-12 11:10:09 +00:00
|
|
|
if (xRDB.is())
|
2004-04-13 11:08:32 +00:00
|
|
|
{
|
2004-08-12 11:10:09 +00:00
|
|
|
// lookup rdb for location URL:
|
2004-11-09 13:11:20 +00:00
|
|
|
const Reference<registry::XRegistryKey> xRootKey(
|
|
|
|
xRDB->getRootKey() );
|
|
|
|
const Reference<registry::XRegistryKey> xImplKey(
|
2004-08-12 11:10:09 +00:00
|
|
|
xRootKey->openKey( OUSTR("IMPLEMENTATIONS") ) );
|
|
|
|
Sequence<OUString> implNames;
|
|
|
|
if (xImplKey.is() && xImplKey->isValid())
|
|
|
|
implNames = xImplKey->getKeyNames();
|
|
|
|
OUString const * pImplNames = implNames.getConstArray();
|
|
|
|
sal_Int32 pos = implNames.getLength();
|
|
|
|
for ( ; pos--; )
|
2004-04-13 11:08:32 +00:00
|
|
|
{
|
2004-08-12 11:10:09 +00:00
|
|
|
checkAborted( abortChannel );
|
2004-11-09 13:11:20 +00:00
|
|
|
const OUString key(
|
|
|
|
pImplNames[ pos ] + OUSTR("/UNO/LOCATION") );
|
|
|
|
const Reference<registry::XRegistryKey> xKey(
|
2004-08-12 11:10:09 +00:00
|
|
|
xRootKey->openKey(key) );
|
2009-12-04 13:39:33 +01:00
|
|
|
if (xKey.is() && xKey->isValid())
|
|
|
|
{
|
2004-11-09 13:11:20 +00:00
|
|
|
const OUString location( xKey->getAsciiValue() );
|
2004-08-12 11:10:09 +00:00
|
|
|
if (location.equalsIgnoreAsciiCase( getURL() ))
|
2009-12-04 13:39:33 +01:00
|
|
|
{
|
2004-08-12 11:10:09 +00:00
|
|
|
break;
|
2009-12-04 13:39:33 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//try to match only the file name
|
|
|
|
OUString thisUrl(getURL());
|
|
|
|
OUString thisFileName(thisUrl.copy(thisUrl.lastIndexOf('/')));
|
|
|
|
|
|
|
|
OUString locationFileName(location.copy(location.lastIndexOf('/')));
|
|
|
|
if (locationFileName.equalsIgnoreAsciiCase(thisFileName))
|
|
|
|
bAmbiguousComponentName = true;
|
|
|
|
}
|
2004-04-13 11:08:32 +00:00
|
|
|
}
|
|
|
|
}
|
2004-08-12 11:10:09 +00:00
|
|
|
if (pos >= 0)
|
|
|
|
m_registered = REG_REGISTERED;
|
2009-12-04 13:39:33 +01:00
|
|
|
else if (bAmbiguousComponentName)
|
|
|
|
m_registered = REG_MAYBE_REGISTERED;
|
2004-04-13 11:08:32 +00:00
|
|
|
}
|
|
|
|
}
|
2009-12-04 13:39:33 +01:00
|
|
|
|
|
|
|
//Different extensions can use the same service implementations. Then the extensions
|
|
|
|
//which was installed last will overwrite the one from the other extension. That is
|
|
|
|
//the registry will contain the path (the location) of the library or jar of the
|
|
|
|
//second extension. In this case isRegistered called for the lib of the first extension
|
|
|
|
//would return "not registered". That would mean that during uninstallation
|
|
|
|
//XPackage::registerPackage is not called, because it just was not registered. This is,
|
|
|
|
//however, necessary for jar files. Registering and unregistering update
|
|
|
|
//uno_packages/cache/registry/com.sun.star.comp.deployment.component.PackageRegistryBackend/unorc
|
|
|
|
//Therefore, we will return always "is ambiguous" if the path of this component cannot
|
|
|
|
//be found in the registry and if there is another path and both have the same file name (but
|
|
|
|
//the rest of the path is different).
|
|
|
|
//If the caller cannot precisely determine that this package was registered, then it must
|
|
|
|
//call registerPackage.
|
|
|
|
sal_Bool bAmbiguous = m_registered == REG_VOID // REG_VOID == we are in the progress of unregistration
|
|
|
|
|| m_registered == REG_MAYBE_REGISTERED;
|
2004-08-12 11:10:09 +00:00
|
|
|
return beans::Optional< beans::Ambiguous<sal_Bool> >(
|
|
|
|
true /* IsPresent */,
|
|
|
|
beans::Ambiguous<sal_Bool>(
|
2009-12-04 13:39:33 +01:00
|
|
|
m_registered == REG_REGISTERED, bAmbiguous) );
|
2004-04-13 11:08:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//______________________________________________________________________________
|
2004-11-09 13:11:20 +00:00
|
|
|
void BackendImpl::ComponentPackageImpl::processPackage_(
|
2006-10-12 13:10:14 +00:00
|
|
|
::osl::ResettableMutexGuard &,
|
|
|
|
bool doRegisterPackage,
|
2010-04-21 16:04:34 +02:00
|
|
|
bool startup,
|
2004-06-11 11:13:15 +00:00
|
|
|
::rtl::Reference<AbortChannel> const & abortChannel,
|
|
|
|
Reference<XCommandEnvironment> const & xCmdEnv )
|
2004-04-13 11:08:32 +00:00
|
|
|
{
|
|
|
|
BackendImpl * that = getMyBackend();
|
2009-12-03 15:59:55 +01:00
|
|
|
|
|
|
|
|
2004-11-09 13:11:20 +00:00
|
|
|
const bool java = m_loader.equalsAsciiL(
|
2004-04-13 11:08:32 +00:00
|
|
|
RTL_CONSTASCII_STRINGPARAM("com.sun.star.loader.Java2") );
|
2004-11-09 13:11:20 +00:00
|
|
|
const OUString url( getURL() );
|
2010-03-22 12:35:33 +01:00
|
|
|
bool isJavaTypelib;
|
|
|
|
if (m_bRemoved)
|
|
|
|
isJavaTypelib = m_registeredComponentsDb.javaTypeLibrary;
|
|
|
|
else
|
|
|
|
isJavaTypelib = java &&
|
|
|
|
!jarManifestHeaderPresent( url, OUSTR("UNO-Type-Path"), xCmdEnv );
|
2004-04-13 11:08:32 +00:00
|
|
|
|
2010-05-04 12:37:01 +02:00
|
|
|
ComponentBackendDb::Data data;
|
|
|
|
data.javaTypeLibrary = isJavaTypelib;
|
2006-10-12 13:10:14 +00:00
|
|
|
if (doRegisterPackage)
|
2004-04-13 11:08:32 +00:00
|
|
|
{
|
2010-04-21 16:04:34 +02:00
|
|
|
Reference <uno::XComponentContext> context(that->getComponentContext());
|
|
|
|
if (! startup)
|
|
|
|
{
|
|
|
|
context.set(
|
2004-08-12 11:10:09 +00:00
|
|
|
that->getObject( url ), UNO_QUERY );
|
2010-04-21 16:04:34 +02:00
|
|
|
|
|
|
|
if (! context.is()) {
|
|
|
|
context.set(
|
2004-08-12 11:10:09 +00:00
|
|
|
that->insertObject( url, raise_uno_process(
|
2004-06-11 11:13:15 +00:00
|
|
|
that->getComponentContext(),
|
|
|
|
abortChannel ) ),
|
|
|
|
UNO_QUERY_THROW );
|
|
|
|
}
|
|
|
|
}
|
2004-08-12 11:10:09 +00:00
|
|
|
|
2004-11-09 13:11:20 +00:00
|
|
|
const Reference<registry::XSimpleRegistry> xServicesRDB( getRDB() );
|
|
|
|
const Reference<registry::XImplementationRegistration> xImplReg(
|
2010-04-21 16:04:34 +02:00
|
|
|
context->getServiceManager()->createInstanceWithContext(
|
2004-06-11 11:13:15 +00:00
|
|
|
OUSTR("com.sun.star.registry.ImplementationRegistration"),
|
2010-04-21 16:04:34 +02:00
|
|
|
context ), UNO_QUERY_THROW );
|
2009-12-03 17:07:30 +01:00
|
|
|
|
2004-08-12 11:10:09 +00:00
|
|
|
xImplReg->registerImplementation( m_loader, url, xServicesRDB );
|
2009-12-03 17:07:30 +01:00
|
|
|
//only write to unorc if registration was successful.
|
|
|
|
//It may fail if there is no suitable java.
|
|
|
|
if (isJavaTypelib)
|
2010-05-04 12:37:01 +02:00
|
|
|
{
|
2009-12-03 17:07:30 +01:00
|
|
|
that->addToUnoRc( java, url, xCmdEnv );
|
2010-05-04 12:37:01 +02:00
|
|
|
data.javaTypeLibrary = true;
|
|
|
|
}
|
2004-06-11 11:13:15 +00:00
|
|
|
|
2004-08-12 11:10:09 +00:00
|
|
|
t_stringlist implNames;
|
|
|
|
t_stringpairvec singletons;
|
2010-05-04 12:37:01 +02:00
|
|
|
const Reference<loader::XImplementationLoader> xLoader(
|
2010-04-21 16:04:34 +02:00
|
|
|
getComponentInfo( &implNames, &singletons, context ) );
|
2010-05-04 12:37:01 +02:00
|
|
|
data.implementationNames = implNames;
|
|
|
|
data.singletons = singletons;
|
2004-06-11 11:13:15 +00:00
|
|
|
|
2010-05-12 16:11:41 +02:00
|
|
|
if (!startup)
|
2004-04-13 11:08:32 +00:00
|
|
|
{
|
2010-05-12 16:11:41 +02:00
|
|
|
// factories live insertion:
|
|
|
|
const Reference<container::XSet> xSet(
|
|
|
|
that->getComponentContext()->getServiceManager(), UNO_QUERY_THROW );
|
|
|
|
for ( t_stringlist::const_iterator iPos( implNames.begin() );
|
|
|
|
iPos != implNames.end(); ++iPos )
|
|
|
|
{
|
|
|
|
checkAborted( abortChannel );
|
|
|
|
OUString const & implName = *iPos;
|
|
|
|
// activate factory:
|
|
|
|
const Reference<XInterface> xFactory(
|
|
|
|
xLoader->activate(
|
|
|
|
implName, OUString(), url,
|
|
|
|
xServicesRDB->getRootKey()->openKey(
|
|
|
|
OUSTR("/IMPLEMENTATIONS/") + implName ) ) );
|
|
|
|
try {
|
|
|
|
xSet->insert( Any(xFactory) );
|
|
|
|
} // ignore if factory has already been inserted:
|
|
|
|
catch (container::ElementExistException &) {
|
|
|
|
OSL_ENSURE( 0, "### factory already registered?" );
|
|
|
|
}
|
2004-06-11 11:13:15 +00:00
|
|
|
}
|
|
|
|
|
2010-05-12 16:11:41 +02:00
|
|
|
if (! singletons.empty())
|
2004-06-11 11:13:15 +00:00
|
|
|
{
|
2010-05-12 16:11:41 +02:00
|
|
|
// singletons live insertion:
|
|
|
|
const Reference<container::XNameContainer> xRootContext(
|
|
|
|
that->getComponentContext()->getValueByName(
|
|
|
|
OUSTR("_root") ), UNO_QUERY );
|
|
|
|
if (xRootContext.is())
|
2004-08-12 11:10:09 +00:00
|
|
|
{
|
2010-05-12 16:11:41 +02:00
|
|
|
for ( t_stringpairvec::const_iterator iPos(
|
|
|
|
singletons.begin() );
|
|
|
|
iPos != singletons.end(); ++iPos )
|
|
|
|
{
|
|
|
|
::std::pair<OUString, OUString> const & sp = *iPos;
|
|
|
|
const OUString name( OUSTR("/singletons/") + sp.first );
|
|
|
|
// assure no arguments:
|
|
|
|
try {
|
|
|
|
xRootContext->removeByName( name + OUSTR("/arguments"));
|
|
|
|
} catch (container::NoSuchElementException &) {}
|
|
|
|
// used service:
|
|
|
|
try {
|
|
|
|
xRootContext->insertByName(
|
|
|
|
name + OUSTR("/service"), Any(sp.second) );
|
|
|
|
} catch (container::ElementExistException &) {
|
|
|
|
xRootContext->replaceByName(
|
|
|
|
name + OUSTR("/service"), Any(sp.second) );
|
|
|
|
}
|
|
|
|
// singleton entry:
|
|
|
|
try {
|
|
|
|
xRootContext->insertByName( name, Any() );
|
|
|
|
} catch (container::ElementExistException & exc) {
|
|
|
|
(void) exc; // avoid warnings
|
|
|
|
OSL_ENSURE(
|
|
|
|
0, OUStringToOString(
|
|
|
|
exc.Message, RTL_TEXTENCODING_UTF8 ).getStr() );
|
|
|
|
xRootContext->replaceByName( name, Any() );
|
|
|
|
}
|
2004-08-12 11:10:09 +00:00
|
|
|
}
|
|
|
|
}
|
2004-06-11 11:13:15 +00:00
|
|
|
}
|
|
|
|
}
|
2004-04-13 11:08:32 +00:00
|
|
|
|
2004-06-11 11:13:15 +00:00
|
|
|
m_registered = REG_REGISTERED;
|
2010-05-04 12:37:01 +02:00
|
|
|
getMyBackend()->addDataToDb(url, data);
|
2004-04-13 11:08:32 +00:00
|
|
|
}
|
2004-11-09 13:11:20 +00:00
|
|
|
else // revokePackage()
|
|
|
|
{
|
|
|
|
// set to VOID during revocation process:
|
|
|
|
m_registered = REG_VOID;
|
|
|
|
|
2010-04-21 16:04:34 +02:00
|
|
|
//get the remote context. If it does not exist then use the local one
|
|
|
|
Reference<XComponentContext> xContext(
|
|
|
|
that->getObject( url ), UNO_QUERY );
|
|
|
|
bool bRemoteContext = false;
|
|
|
|
if (!xContext.is())
|
2004-06-11 11:13:15 +00:00
|
|
|
xContext = that->getComponentContext();
|
2010-04-21 16:04:34 +02:00
|
|
|
else
|
|
|
|
bRemoteContext = true;
|
2004-06-11 11:13:15 +00:00
|
|
|
|
2004-08-12 11:10:09 +00:00
|
|
|
t_stringlist implNames;
|
|
|
|
t_stringpairvec singletons;
|
2010-03-22 12:35:33 +01:00
|
|
|
if (m_bRemoved)
|
|
|
|
{
|
|
|
|
implNames = m_registeredComponentsDb.implementationNames;
|
|
|
|
singletons = m_registeredComponentsDb.singletons;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
getComponentInfo( &implNames, &singletons, xContext );
|
|
|
|
}
|
2010-05-12 16:11:41 +02:00
|
|
|
|
|
|
|
if (!startup)
|
2004-06-11 11:13:15 +00:00
|
|
|
{
|
2010-05-12 16:11:41 +02:00
|
|
|
// factories live removal:
|
|
|
|
const Reference<container::XSet> xSet(
|
|
|
|
that->getComponentContext()->getServiceManager(), UNO_QUERY_THROW );
|
|
|
|
for ( t_stringlist::const_iterator iPos( implNames.begin() );
|
|
|
|
iPos != implNames.end(); ++iPos )
|
|
|
|
{
|
|
|
|
OUString const & implName = *iPos;
|
|
|
|
try {
|
|
|
|
xSet->remove( Any(implName) );
|
|
|
|
} // ignore if factory has not been live deployed:
|
|
|
|
catch (container::NoSuchElementException &) {
|
|
|
|
}
|
2004-06-11 11:13:15 +00:00
|
|
|
}
|
|
|
|
|
2010-05-12 16:11:41 +02:00
|
|
|
if (! singletons.empty())
|
2004-06-11 11:13:15 +00:00
|
|
|
{
|
2010-05-12 16:11:41 +02:00
|
|
|
// singletons live removal:
|
|
|
|
const Reference<container::XNameContainer> xRootContext(
|
|
|
|
that->getComponentContext()->getValueByName(
|
|
|
|
OUSTR("_root") ), UNO_QUERY );
|
|
|
|
if (xRootContext.is())
|
2004-08-12 11:10:09 +00:00
|
|
|
{
|
2010-05-12 16:11:41 +02:00
|
|
|
for ( t_stringpairvec::const_iterator iPos(
|
|
|
|
singletons.begin() );
|
|
|
|
iPos != singletons.end(); ++iPos )
|
|
|
|
{
|
|
|
|
::std::pair<OUString, OUString> const & sp = *iPos;
|
|
|
|
const OUString name( OUSTR("/singletons/") + sp.first );
|
|
|
|
// arguments:
|
|
|
|
try {
|
|
|
|
xRootContext->removeByName( name + OUSTR("/arguments"));
|
|
|
|
}
|
|
|
|
catch (container::NoSuchElementException &) {}
|
|
|
|
// used service:
|
|
|
|
try {
|
|
|
|
xRootContext->removeByName( name + OUSTR("/service") );
|
|
|
|
}
|
|
|
|
catch (container::NoSuchElementException &) {}
|
|
|
|
// singleton entry:
|
|
|
|
try {
|
|
|
|
xRootContext->removeByName( name );
|
|
|
|
}
|
|
|
|
catch (container::NoSuchElementException & exc) {
|
|
|
|
(void) exc; // avoid warnings
|
|
|
|
OSL_ENSURE(
|
|
|
|
0, OUStringToOString(
|
|
|
|
exc.Message, RTL_TEXTENCODING_UTF8 ).getStr() );
|
|
|
|
}
|
2004-08-12 11:10:09 +00:00
|
|
|
}
|
|
|
|
}
|
2004-06-11 11:13:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-11-09 13:11:20 +00:00
|
|
|
const Reference<registry::XSimpleRegistry> xServicesRDB( getRDB() );
|
|
|
|
const Reference<registry::XImplementationRegistration> xImplReg(
|
2004-08-12 11:10:09 +00:00
|
|
|
xContext->getServiceManager()->createInstanceWithContext(
|
|
|
|
OUSTR("com.sun.star.registry.ImplementationRegistration"),
|
|
|
|
xContext ), UNO_QUERY_THROW );
|
|
|
|
xImplReg->revokeImplementation( url, xServicesRDB );
|
2004-04-13 11:08:32 +00:00
|
|
|
|
2007-03-12 10:02:40 +00:00
|
|
|
if (isJavaTypelib)
|
2004-11-09 13:11:20 +00:00
|
|
|
that->removeFromUnoRc( java, url, xCmdEnv );
|
2004-04-13 11:08:32 +00:00
|
|
|
|
2010-04-21 16:04:34 +02:00
|
|
|
if (bRemoteContext)
|
2004-08-12 11:10:09 +00:00
|
|
|
that->releaseObject( url );
|
2004-04-13 11:08:32 +00:00
|
|
|
|
2004-06-11 11:13:15 +00:00
|
|
|
m_registered = REG_NOT_REGISTERED;
|
2010-05-04 12:37:01 +02:00
|
|
|
getMyBackend()->deleteDataFromDb(url);
|
2004-04-13 11:08:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//##############################################################################
|
2010-03-22 12:35:33 +01:00
|
|
|
BackendImpl::TypelibraryPackageImpl::TypelibraryPackageImpl(
|
|
|
|
::rtl::Reference<PackageRegistryBackend> const & myBackend,
|
|
|
|
OUString const & url, OUString const & name,
|
|
|
|
Reference<deployment::XPackageTypeInfo> const & xPackageType,
|
|
|
|
bool jarFile, bool bRemoved, OUString const & identifier)
|
|
|
|
: Package( myBackend, url, name, name /* display-name */,
|
|
|
|
xPackageType, bRemoved, identifier),
|
|
|
|
m_jarFile( jarFile )
|
|
|
|
{
|
|
|
|
}
|
2004-04-13 11:08:32 +00:00
|
|
|
|
|
|
|
// Package
|
2008-05-20 13:33:31 +00:00
|
|
|
BackendImpl * BackendImpl::TypelibraryPackageImpl::getMyBackend() const
|
|
|
|
{
|
|
|
|
BackendImpl * pBackend = static_cast<BackendImpl *>(m_myBackend.get());
|
|
|
|
if (NULL == pBackend)
|
|
|
|
{
|
|
|
|
//May throw a DisposedException
|
|
|
|
check();
|
|
|
|
//We should never get here...
|
|
|
|
throw RuntimeException(
|
|
|
|
OUSTR("Failed to get the BackendImpl"),
|
|
|
|
static_cast<OWeakObject*>(const_cast<TypelibraryPackageImpl *>(this)));
|
|
|
|
}
|
|
|
|
return pBackend;
|
|
|
|
}
|
2004-04-13 11:08:32 +00:00
|
|
|
//______________________________________________________________________________
|
2004-08-12 11:10:09 +00:00
|
|
|
beans::Optional< beans::Ambiguous<sal_Bool> >
|
2004-11-09 13:11:20 +00:00
|
|
|
BackendImpl::TypelibraryPackageImpl::isRegistered_(
|
2006-10-12 13:10:14 +00:00
|
|
|
::osl::ResettableMutexGuard &,
|
|
|
|
::rtl::Reference<AbortChannel> const &,
|
|
|
|
Reference<XCommandEnvironment> const & )
|
2004-04-13 11:08:32 +00:00
|
|
|
{
|
|
|
|
BackendImpl * that = getMyBackend();
|
2004-08-12 11:10:09 +00:00
|
|
|
return beans::Optional< beans::Ambiguous<sal_Bool> >(
|
|
|
|
true /* IsPresent */,
|
|
|
|
beans::Ambiguous<sal_Bool>(
|
2006-10-12 13:10:14 +00:00
|
|
|
that->hasInUnoRc( m_jarFile, getURL() ),
|
2004-08-12 11:10:09 +00:00
|
|
|
false /* IsAmbiguous */ ) );
|
2004-04-13 11:08:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//______________________________________________________________________________
|
2004-11-09 13:11:20 +00:00
|
|
|
void BackendImpl::TypelibraryPackageImpl::processPackage_(
|
2006-10-12 13:10:14 +00:00
|
|
|
::osl::ResettableMutexGuard &,
|
|
|
|
bool doRegisterPackage,
|
2010-04-28 11:44:09 +02:00
|
|
|
bool /*startup*/,
|
2006-10-12 13:10:14 +00:00
|
|
|
::rtl::Reference<AbortChannel> const &,
|
2004-06-11 11:13:15 +00:00
|
|
|
Reference<XCommandEnvironment> const & xCmdEnv )
|
2004-04-13 11:08:32 +00:00
|
|
|
{
|
|
|
|
BackendImpl * that = getMyBackend();
|
2004-11-09 13:11:20 +00:00
|
|
|
const OUString url( getURL() );
|
2004-08-12 11:10:09 +00:00
|
|
|
|
2006-10-12 13:10:14 +00:00
|
|
|
if (doRegisterPackage)
|
2004-04-13 11:08:32 +00:00
|
|
|
{
|
2004-06-11 11:13:15 +00:00
|
|
|
// live insertion:
|
2004-08-12 11:10:09 +00:00
|
|
|
if (m_jarFile) {
|
|
|
|
// xxx todo add to classpath at runtime: ???
|
2007-03-12 10:02:40 +00:00
|
|
|
//SB: It is probably not worth it to add the live inserted type
|
|
|
|
// library JAR to the UnoClassLoader in the soffice process. Any
|
|
|
|
// live inserted component JAR that might reference this type
|
|
|
|
// library JAR runs in its own uno process, so there is probably no
|
|
|
|
// Java code in the soffice process that would see any UNO types
|
|
|
|
// introduced by this type library JAR.
|
2004-06-11 11:13:15 +00:00
|
|
|
}
|
|
|
|
else // RDB:
|
|
|
|
{
|
|
|
|
Reference<XComponentContext> const & xContext =
|
|
|
|
that->getComponentContext();
|
|
|
|
if (! m_xTDprov.is())
|
|
|
|
{
|
2004-08-12 11:10:09 +00:00
|
|
|
m_xTDprov.set( that->getObject( url ), UNO_QUERY );
|
2004-06-11 11:13:15 +00:00
|
|
|
if (! m_xTDprov.is())
|
|
|
|
{
|
2004-11-09 13:11:20 +00:00
|
|
|
const Reference<registry::XSimpleRegistry> xReg(
|
2004-06-11 11:13:15 +00:00
|
|
|
xContext->getServiceManager()
|
|
|
|
->createInstanceWithContext(
|
|
|
|
OUSTR("com.sun.star.registry.SimpleRegistry"),
|
|
|
|
xContext ), UNO_QUERY_THROW );
|
2004-11-09 13:11:20 +00:00
|
|
|
xReg->open( expandUnoRcUrl(url),
|
2004-06-11 11:13:15 +00:00
|
|
|
true /* read-only */, false /* ! create */ );
|
2005-01-21 16:13:33 +00:00
|
|
|
const Any arg(xReg);
|
2004-06-11 11:13:15 +00:00
|
|
|
Reference<container::XHierarchicalNameAccess> xTDprov(
|
|
|
|
xContext->getServiceManager()
|
|
|
|
->createInstanceWithArgumentsAndContext(
|
|
|
|
OUSTR("com.sun.star.comp.stoc."
|
|
|
|
"RegistryTypeDescriptionProvider"),
|
|
|
|
Sequence<Any>( &arg, 1 ), xContext ), UNO_QUERY );
|
|
|
|
OSL_ASSERT( xTDprov.is() );
|
|
|
|
if (xTDprov.is())
|
2004-08-12 11:10:09 +00:00
|
|
|
m_xTDprov.set( that->insertObject( url, xTDprov ),
|
|
|
|
UNO_QUERY_THROW );
|
2004-06-11 11:13:15 +00:00
|
|
|
}
|
|
|
|
}
|
2004-08-12 11:10:09 +00:00
|
|
|
if (m_xTDprov.is()) {
|
2004-06-11 11:13:15 +00:00
|
|
|
Reference<container::XSet> xSet(
|
|
|
|
xContext->getValueByName(
|
|
|
|
OUSTR("/singletons/com.sun.star."
|
|
|
|
"reflection.theTypeDescriptionManager") ),
|
|
|
|
UNO_QUERY_THROW );
|
2005-01-21 16:13:33 +00:00
|
|
|
xSet->insert( Any(m_xTDprov) );
|
2004-06-11 11:13:15 +00:00
|
|
|
}
|
2004-04-13 11:08:32 +00:00
|
|
|
}
|
2004-08-12 11:10:09 +00:00
|
|
|
|
2004-11-09 13:11:20 +00:00
|
|
|
that->addToUnoRc( m_jarFile, url, xCmdEnv );
|
2004-04-13 11:08:32 +00:00
|
|
|
}
|
|
|
|
else // revokePackage()
|
|
|
|
{
|
2004-11-09 13:11:20 +00:00
|
|
|
that->removeFromUnoRc( m_jarFile, url, xCmdEnv );
|
2004-08-12 11:10:09 +00:00
|
|
|
|
|
|
|
// revoking types at runtime, possible, sensible?
|
2008-02-27 09:22:52 +00:00
|
|
|
if (!m_xTDprov.is())
|
|
|
|
m_xTDprov.set( that->getObject( url ), UNO_QUERY );
|
2004-08-12 11:10:09 +00:00
|
|
|
if (m_xTDprov.is()) {
|
|
|
|
// remove live:
|
2004-11-09 13:11:20 +00:00
|
|
|
const Reference<container::XSet> xSet(
|
2004-08-12 11:10:09 +00:00
|
|
|
that->getComponentContext()->getValueByName(
|
|
|
|
OUSTR("/singletons/com.sun.star."
|
|
|
|
"reflection.theTypeDescriptionManager") ),
|
|
|
|
UNO_QUERY_THROW );
|
2005-01-21 16:13:33 +00:00
|
|
|
xSet->remove( Any(m_xTDprov) );
|
2004-08-12 11:10:09 +00:00
|
|
|
|
|
|
|
that->releaseObject( url );
|
|
|
|
m_xTDprov.clear();
|
2004-04-13 11:08:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-10 13:54:19 +01:00
|
|
|
BackendImpl::OtherPlatformPackageImpl::OtherPlatformPackageImpl(
|
|
|
|
::rtl::Reference<PackageRegistryBackend> const & myBackend,
|
|
|
|
OUString const & url, OUString const & name,
|
|
|
|
Reference<deployment::XPackageTypeInfo> const & xPackageType,
|
|
|
|
bool bRemoved, OUString const & identifier, OUString const& rPlatform)
|
|
|
|
: Package(myBackend, url, name, name, xPackageType, bRemoved, identifier)
|
|
|
|
, m_aPlatform(rPlatform)
|
|
|
|
{
|
|
|
|
OSL_PRECOND(bRemoved, "this class can only be used for removing packages!");
|
|
|
|
}
|
|
|
|
|
|
|
|
BackendImpl *
|
|
|
|
BackendImpl::OtherPlatformPackageImpl::getMyBackend() const
|
|
|
|
{
|
|
|
|
BackendImpl * pBackend = static_cast<BackendImpl *>(m_myBackend.get());
|
|
|
|
if (NULL == pBackend)
|
|
|
|
{
|
|
|
|
//Throws a DisposedException
|
|
|
|
check();
|
|
|
|
//We should never get here...
|
|
|
|
throw RuntimeException(
|
|
|
|
OUSTR("Failed to get the BackendImpl"),
|
|
|
|
static_cast<OWeakObject*>(const_cast<OtherPlatformPackageImpl*>(this)));
|
|
|
|
}
|
|
|
|
return pBackend;
|
|
|
|
}
|
|
|
|
|
|
|
|
Reference<registry::XSimpleRegistry> const
|
|
|
|
BackendImpl::OtherPlatformPackageImpl::impl_openRDB() const
|
|
|
|
{
|
|
|
|
OUString const aRDB(m_aPlatform + OUString(RTL_CONSTASCII_USTRINGPARAM(".rdb")));
|
|
|
|
OUString const aRDBPath(makeURL(getMyBackend()->getCachePath(), aRDB));
|
|
|
|
|
|
|
|
Reference<registry::XSimpleRegistry> xRegistry;
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
xRegistry.set(
|
|
|
|
impl_createInstance(
|
|
|
|
OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.registry.SimpleRegistry"))),
|
|
|
|
UNO_QUERY)
|
|
|
|
;
|
|
|
|
if (xRegistry.is())
|
|
|
|
xRegistry->open(expandUnoRcUrl(aRDBPath), false, false);
|
|
|
|
}
|
|
|
|
catch (registry::InvalidRegistryException const&)
|
|
|
|
{
|
|
|
|
// If the registry does not exist, we do not need to bother at all
|
|
|
|
xRegistry.set(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
OSL_POSTCOND(xRegistry.is(), "could not create registry for the package's platform");
|
|
|
|
return xRegistry;
|
|
|
|
}
|
|
|
|
|
|
|
|
Reference<XInterface> const
|
|
|
|
BackendImpl::OtherPlatformPackageImpl::impl_createInstance(OUString const& rService)
|
|
|
|
const
|
|
|
|
{
|
|
|
|
Reference<XComponentContext> const xContext(getMyBackend()->getComponentContext());
|
|
|
|
OSL_ASSERT(xContext.is());
|
|
|
|
Reference<XInterface> xService;
|
|
|
|
if (xContext.is())
|
|
|
|
xService.set(xContext->getServiceManager()->createInstanceWithContext(rService, xContext));
|
|
|
|
return xService;
|
|
|
|
}
|
|
|
|
|
|
|
|
beans::Optional<beans::Ambiguous<sal_Bool> >
|
|
|
|
BackendImpl::OtherPlatformPackageImpl::isRegistered_(
|
|
|
|
::osl::ResettableMutexGuard& /* guard */,
|
|
|
|
::rtl::Reference<AbortChannel> const& /* abortChannel */,
|
|
|
|
Reference<XCommandEnvironment> const& /* xCmdEnv */ )
|
|
|
|
{
|
|
|
|
return beans::Optional<beans::Ambiguous<sal_Bool> >(sal_True,
|
|
|
|
beans::Ambiguous<sal_Bool>(sal_True, sal_False));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
BackendImpl::OtherPlatformPackageImpl::processPackage_(
|
|
|
|
::osl::ResettableMutexGuard& /* guard */,
|
|
|
|
bool bRegisterPackage,
|
|
|
|
bool /* bStartup */,
|
|
|
|
::rtl::Reference<AbortChannel> const& /* abortChannel */,
|
|
|
|
Reference<XCommandEnvironment> const& /* xCmdEnv */)
|
|
|
|
{
|
|
|
|
OSL_PRECOND(!bRegisterPackage, "this class can only be used for removing packages!");
|
|
|
|
(void) bRegisterPackage;
|
|
|
|
|
|
|
|
OUString const aURL(getURL());
|
|
|
|
|
|
|
|
Reference<registry::XSimpleRegistry> const xServicesRDB(impl_openRDB());
|
|
|
|
Reference<registry::XImplementationRegistration> const xImplReg(
|
|
|
|
impl_createInstance(
|
|
|
|
OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.registry.ImplementationRegistration"))),
|
|
|
|
UNO_QUERY)
|
|
|
|
;
|
|
|
|
if (xImplReg.is() && xServicesRDB.is())
|
|
|
|
xImplReg->revokeImplementation(aURL, xServicesRDB);
|
|
|
|
if (xServicesRDB.is())
|
|
|
|
xServicesRDB->close();
|
|
|
|
|
|
|
|
getMyBackend()->deleteDataFromDb(aURL);
|
|
|
|
}
|
|
|
|
|
2004-11-09 13:11:20 +00:00
|
|
|
} // anon namespace
|
|
|
|
|
2006-03-06 09:22:07 +00:00
|
|
|
namespace sdecl = comphelper::service_decl;
|
2006-03-22 10:08:27 +00:00
|
|
|
sdecl::class_<BackendImpl, sdecl::with_args<true> > serviceBI;
|
2006-03-06 09:22:07 +00:00
|
|
|
extern sdecl::ServiceDecl const serviceDecl(
|
2006-03-22 10:08:27 +00:00
|
|
|
serviceBI,
|
2010-05-04 12:37:01 +02:00
|
|
|
IMPLEMENTATION_NAME,
|
2006-03-06 09:22:07 +00:00
|
|
|
BACKEND_SERVICE_NAME );
|
2004-11-09 13:11:20 +00:00
|
|
|
|
2004-04-13 11:08:32 +00:00
|
|
|
} // namespace component
|
|
|
|
} // namespace backend
|
|
|
|
} // namespace dp_registry
|
|
|
|
|
2006-03-06 09:22:07 +00:00
|
|
|
|
2010-10-12 15:53:47 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|