2004-04-13 11:08:32 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2005-09-08 16:27:35 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2004-04-13 11:08:32 +00:00
|
|
|
*
|
2005-09-08 16:27:35 +00:00
|
|
|
* $RCSfile: dp_component.cxx,v $
|
2004-04-13 11:08:32 +00:00
|
|
|
*
|
2006-03-06 09:22:07 +00:00
|
|
|
* $Revision: 1.11 $
|
2004-04-13 11:08:32 +00:00
|
|
|
*
|
2006-03-06 09:22:07 +00:00
|
|
|
* last change: $Author: rt $ $Date: 2006-03-06 10:22:07 $
|
2004-04-13 11:08:32 +00:00
|
|
|
*
|
2005-09-08 16:27:35 +00:00
|
|
|
* The Contents of this file are made available subject to
|
|
|
|
* the terms of GNU Lesser General Public License Version 2.1.
|
2004-04-13 11:08:32 +00:00
|
|
|
*
|
|
|
|
*
|
2005-09-08 16:27:35 +00:00
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
* =============================================
|
|
|
|
* Copyright 2005 by Sun Microsystems, Inc.
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
2004-04-13 11:08:32 +00:00
|
|
|
*
|
2005-09-08 16:27:35 +00:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License version 2.1, as published by the Free Software Foundation.
|
2004-04-13 11:08:32 +00:00
|
|
|
*
|
2005-09-08 16:27:35 +00:00
|
|
|
* This library 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 for more details.
|
2004-04-13 11:08:32 +00:00
|
|
|
*
|
2005-09-08 16:27:35 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
2004-04-13 11:08:32 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2004-06-11 11:13:15 +00:00
|
|
|
#include "dp_component.hrc"
|
2004-04-13 11:08:32 +00:00
|
|
|
#include "dp_backend.h"
|
|
|
|
#include "dp_ucb.h"
|
|
|
|
#include "rtl/string.hxx"
|
|
|
|
#include "rtl/strbuf.hxx"
|
|
|
|
#include "rtl/ustrbuf.hxx"
|
|
|
|
#include "rtl/uri.hxx"
|
2004-06-11 11:13:15 +00:00
|
|
|
#include "osl/module.hxx"
|
2004-04-13 11:08:32 +00:00
|
|
|
#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"
|
2004-06-11 11:13:15 +00:00
|
|
|
#include "svtools/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"
|
2004-08-12 11:10:09 +00:00
|
|
|
#include <list>
|
2004-06-11 11:13:15 +00:00
|
|
|
#include <hash_map>
|
2004-04-13 11:08:32 +00:00
|
|
|
#include <vector>
|
|
|
|
#include <memory>
|
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
//==============================================================================
|
|
|
|
class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend
|
|
|
|
{
|
2004-11-09 13:11:20 +00:00
|
|
|
class ComponentPackageImpl : public ::dp_registry::backend::Package
|
|
|
|
{
|
|
|
|
BackendImpl * getMyBackend() const {
|
|
|
|
return static_cast<BackendImpl *>(m_myBackend.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
const OUString m_loader;
|
|
|
|
Reference<XComponentContext> m_xRemoteContext;
|
|
|
|
|
2005-04-04 06:58:50 +00:00
|
|
|
enum reg {
|
2004-11-09 13:11:20 +00:00
|
|
|
REG_UNINIT, REG_VOID, REG_REGISTERED, REG_NOT_REGISTERED
|
|
|
|
} 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,
|
|
|
|
::rtl::Reference<AbortChannel> const & abortChannel,
|
|
|
|
Reference<XCommandEnvironment> const & xCmdEnv );
|
|
|
|
|
|
|
|
const Reference<registry::XSimpleRegistry> getRDB() const;
|
|
|
|
|
|
|
|
public:
|
|
|
|
inline ComponentPackageImpl(
|
|
|
|
::rtl::Reference<PackageRegistryBackend> const & myBackend,
|
|
|
|
OUString const & url, OUString const & name,
|
|
|
|
Reference<deployment::XPackageTypeInfo> const & xPackageType,
|
|
|
|
OUString const & loader )
|
|
|
|
: Package( myBackend, url, name, name /* display-name */,
|
|
|
|
xPackageType ),
|
|
|
|
m_loader( loader ),
|
|
|
|
m_registered( REG_UNINIT )
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
friend class ComponentPackageImpl;
|
|
|
|
|
|
|
|
class TypelibraryPackageImpl : public ::dp_registry::backend::Package
|
|
|
|
{
|
|
|
|
BackendImpl * getMyBackend() const {
|
|
|
|
return static_cast<BackendImpl *>(m_myBackend.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
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,
|
|
|
|
::rtl::Reference<AbortChannel> const & abortChannel,
|
|
|
|
Reference<XCommandEnvironment> const & xCmdEnv );
|
|
|
|
|
|
|
|
public:
|
|
|
|
inline TypelibraryPackageImpl(
|
|
|
|
::rtl::Reference<PackageRegistryBackend> const & myBackend,
|
|
|
|
OUString const & url, OUString const & name,
|
|
|
|
Reference<deployment::XPackageTypeInfo> const & xPackageType,
|
|
|
|
bool jarFile )
|
|
|
|
: Package( myBackend, url, name, name /* display-name */,
|
|
|
|
xPackageType ),
|
|
|
|
m_jarFile( jarFile )
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
friend class TypelibraryPackageImpl;
|
|
|
|
|
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;
|
|
|
|
|
2004-06-11 11:13:15 +00:00
|
|
|
typedef ::std::hash_map< OUString, Reference<XInterface>,
|
|
|
|
::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,
|
|
|
|
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;
|
|
|
|
Reference<registry::XSimpleRegistry> m_xCommonRDB;
|
|
|
|
Reference<registry::XSimpleRegistry> m_xNativeRDB;
|
2004-04-13 11:08:32 +00:00
|
|
|
|
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 );
|
2004-11-09 13:11:20 +00:00
|
|
|
bool hasInUnoRc( bool jarFile, OUString const & url,
|
|
|
|
Reference<XCommandEnvironment> const & xCmdEnv );
|
2004-08-12 11:10:09 +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);
|
2004-04-13 11:08:32 +00:00
|
|
|
};
|
|
|
|
|
2004-06-11 11:13:15 +00:00
|
|
|
//______________________________________________________________________________
|
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();
|
|
|
|
if (m_loader.equalsAsciiL(
|
|
|
|
RTL_CONSTASCII_STRINGPARAM("com.sun.star.loader.SharedLibrary") ))
|
|
|
|
return that->m_xNativeRDB;
|
|
|
|
else
|
|
|
|
return that->m_xCommonRDB;
|
|
|
|
}
|
|
|
|
|
|
|
|
//______________________________________________________________________________
|
2004-11-09 13:11:20 +00:00
|
|
|
void BackendImpl::ComponentPackageImpl::disposing()
|
2004-06-11 11:13:15 +00:00
|
|
|
{
|
|
|
|
m_xRemoteContext.clear();
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//______________________________________________________________________________
|
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 ),
|
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),
|
|
|
|
RID_IMG_COMPONENT,
|
|
|
|
RID_IMG_COMPONENT_HC ) ),
|
|
|
|
m_xJavaComponentTypeInfo( new Package::TypeInfo(
|
|
|
|
OUSTR("application/"
|
|
|
|
"vnd.sun.star.uno-component;"
|
|
|
|
"type=Java"),
|
|
|
|
OUSTR("*.jar"),
|
|
|
|
getResourceString(RID_STR_JAVA_COMPONENT),
|
|
|
|
RID_IMG_JAVA_COMPONENT,
|
|
|
|
RID_IMG_JAVA_COMPONENT_HC ) ),
|
|
|
|
m_xPythonComponentTypeInfo( new Package::TypeInfo(
|
|
|
|
OUSTR("application/"
|
|
|
|
"vnd.sun.star.uno-component;"
|
|
|
|
"type=Python"),
|
|
|
|
OUSTR("*.py"),
|
|
|
|
getResourceString(
|
|
|
|
RID_STR_PYTHON_COMPONENT),
|
|
|
|
RID_IMG_COMPONENT,
|
|
|
|
RID_IMG_COMPONENT_HC ) ),
|
|
|
|
m_xRDBTypelibTypeInfo( new Package::TypeInfo(
|
|
|
|
OUSTR("application/"
|
|
|
|
"vnd.sun.star.uno-typelibrary;"
|
|
|
|
"type=RDB"),
|
|
|
|
OUSTR("*.rdb"),
|
|
|
|
getResourceString(RID_STR_RDB_TYPELIB),
|
|
|
|
RID_IMG_TYPELIB, RID_IMG_TYPELIB_HC ) ),
|
|
|
|
m_xJavaTypelibTypeInfo( new Package::TypeInfo(
|
|
|
|
OUSTR("application/"
|
|
|
|
"vnd.sun.star.uno-typelibrary;"
|
|
|
|
"type=Java"),
|
|
|
|
OUSTR("*.jar"),
|
|
|
|
getResourceString(RID_STR_JAVA_TYPELIB),
|
|
|
|
RID_IMG_JAVA_TYPELIB,
|
|
|
|
RID_IMG_JAVA_TYPELIB_HC ) ),
|
|
|
|
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
|
|
|
|
{
|
2004-06-11 11:13:15 +00:00
|
|
|
unorc_verify_init( xCmdEnv );
|
|
|
|
|
2004-08-12 11:10:09 +00:00
|
|
|
if (! m_readOnly) {
|
2004-06-11 11:13:15 +00:00
|
|
|
::ucb::Content cacheDir( getCachePath(), xCmdEnv );
|
|
|
|
::ucb::Content oldRDB;
|
|
|
|
// switch common rdb:
|
|
|
|
if (m_commonRDB.getLength() > 0)
|
|
|
|
create_ucb_content(
|
2004-11-09 13:11:20 +00:00
|
|
|
&oldRDB, makeURL( getCachePath(), m_commonRDB ),
|
2004-06-11 11:13:15 +00:00
|
|
|
xCmdEnv, false /* no throw */ );
|
|
|
|
m_commonRDB = m_commonRDB.equalsAsciiL(
|
|
|
|
RTL_CONSTASCII_STRINGPARAM("common.rdb") )
|
|
|
|
? OUSTR("common_.rdb") : OUSTR("common.rdb");
|
|
|
|
if (oldRDB.get().is())
|
|
|
|
{
|
|
|
|
if (! cacheDir.transferContent(
|
|
|
|
oldRDB, ::ucb::InsertOperation_COPY,
|
|
|
|
m_commonRDB, NameClash::OVERWRITE ))
|
|
|
|
throw RuntimeException(
|
|
|
|
OUSTR("UCB transferContent() failed!"), 0 );
|
|
|
|
oldRDB = ::ucb::Content();
|
|
|
|
}
|
|
|
|
// switch native rdb:
|
|
|
|
if (m_nativeRDB.getLength() > 0)
|
|
|
|
create_ucb_content(
|
2004-11-09 13:11:20 +00:00
|
|
|
&oldRDB, makeURL( getCachePath(), m_nativeRDB ),
|
2004-06-11 11:13:15 +00:00
|
|
|
xCmdEnv, false /* no throw */ );
|
2004-11-09 13:11:20 +00:00
|
|
|
const OUString plt_rdb( getPlatformString() + OUSTR(".rdb") );
|
|
|
|
const OUString plt_rdb_( getPlatformString() + OUSTR("_.rdb") );
|
2004-06-11 11:13:15 +00:00
|
|
|
m_nativeRDB = m_nativeRDB.equals( plt_rdb ) ? plt_rdb_ : plt_rdb;
|
|
|
|
if (oldRDB.get().is())
|
|
|
|
{
|
|
|
|
if (! cacheDir.transferContent(
|
|
|
|
oldRDB, ::ucb::InsertOperation_COPY,
|
|
|
|
m_nativeRDB, NameClash::OVERWRITE ))
|
|
|
|
throw RuntimeException(
|
|
|
|
OUSTR("UCB transferContent() failed!"), 0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
// UNO is bootstrapped, flush for next process start:
|
|
|
|
m_unorc_modified = true;
|
|
|
|
unorc_flush( Reference<XCommandEnvironment>() );
|
|
|
|
}
|
|
|
|
|
|
|
|
// common rdb for java, native rdb for shared lib components
|
2004-08-12 11:10:09 +00:00
|
|
|
if (m_commonRDB.getLength() > 0) {
|
2004-06-11 11:13:15 +00:00
|
|
|
m_xCommonRDB.set(
|
2004-08-12 11:10:09 +00:00
|
|
|
xComponentContext->getServiceManager()
|
2004-06-11 11:13:15 +00:00
|
|
|
->createInstanceWithContext(
|
|
|
|
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(
|
2004-11-09 13:11:20 +00:00
|
|
|
makeURL( expandUnoRcUrl(getCachePath()), m_commonRDB ),
|
2004-06-11 11:13:15 +00:00
|
|
|
m_readOnly, !m_readOnly );
|
|
|
|
}
|
2004-08-12 11:10:09 +00:00
|
|
|
if (m_nativeRDB.getLength() > 0) {
|
2004-06-11 11:13:15 +00:00
|
|
|
m_xNativeRDB.set(
|
2004-08-12 11:10:09 +00:00
|
|
|
xComponentContext->getServiceManager()
|
2004-06-11 11:13:15 +00:00
|
|
|
->createInstanceWithContext(
|
|
|
|
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(
|
2004-11-09 13:11:20 +00:00
|
|
|
makeURL( expandUnoRcUrl(getCachePath()), m_nativeRDB ),
|
2004-06-11 11:13:15 +00:00
|
|
|
m_readOnly, !m_readOnly );
|
|
|
|
}
|
2004-04-13 11:08:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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_,
|
|
|
|
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:
|
2004-06-11 11:13:15 +00:00
|
|
|
::ucb::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
|
|
|
{
|
2004-06-11 11:13:15 +00:00
|
|
|
// read .jar manifest file:
|
|
|
|
::rtl::OUStringBuffer buf;
|
|
|
|
buf.appendAscii(
|
2004-08-12 11:10:09 +00:00
|
|
|
RTL_CONSTASCII_STRINGPARAM("vnd.sun.star.zip://") );
|
2004-06-11 11:13:15 +00:00
|
|
|
buf.append( ::rtl::Uri::encode( url,
|
|
|
|
rtl_UriCharClassRegName,
|
|
|
|
rtl_UriEncodeIgnoreEscapes,
|
|
|
|
RTL_TEXTENCODING_UTF8 ) );
|
|
|
|
buf.appendAscii(
|
|
|
|
RTL_CONSTASCII_STRINGPARAM("/META-INF/MANIFEST.MF") );
|
|
|
|
::ucb::Content manifestContent;
|
|
|
|
if (create_ucb_content( &manifestContent,
|
|
|
|
buf.makeStringAndClear(),
|
|
|
|
xCmdEnv, false /* no throw */ ))
|
2004-04-13 11:08:32 +00:00
|
|
|
{
|
2004-06-11 11:13:15 +00:00
|
|
|
OUString line;
|
|
|
|
if (readLine( &line, OUSTR("RegistrationClassName"),
|
|
|
|
manifestContent, RTL_TEXTENCODING_ASCII_US ))
|
|
|
|
mediaType = OUSTR(
|
|
|
|
"application/vnd.sun.star.uno-component;type=Java");
|
2004-04-13 11:08:32 +00:00
|
|
|
}
|
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
|
|
|
{
|
2004-06-11 11:13:15 +00:00
|
|
|
::ucb::Content ucbContent( url, xCmdEnv );
|
2005-01-21 16:13:33 +00:00
|
|
|
const OUString 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") );
|
2004-08-12 11:10:09 +00:00
|
|
|
if (param == 0 || platform_fits( param->m_sValue )) {
|
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")) {
|
2004-11-09 13:11:20 +00:00
|
|
|
return new BackendImpl::ComponentPackageImpl(
|
|
|
|
this, url, name, m_xDynComponentTypeInfo,
|
2004-06-11 11:13:15 +00:00
|
|
|
OUSTR("com.sun.star.loader.SharedLibrary") );
|
|
|
|
}
|
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,
|
2004-06-11 11:13:15 +00:00
|
|
|
OUSTR("com.sun.star.loader.Java2") );
|
|
|
|
}
|
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,
|
2004-06-11 11:13:15 +00:00
|
|
|
OUSTR("com.sun.star.loader.Python") );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
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,
|
|
|
|
false /* rdb */ );
|
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,
|
|
|
|
true /* jar */ );
|
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:
|
2004-04-13 11:08:32 +00:00
|
|
|
::ucb::Content ucb_content;
|
|
|
|
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-03-06 09:22:07 +00:00
|
|
|
if (readLine( &line, OUSTR("PKG_UNO_JAVA_CLASSPATH="), ucb_content,
|
2004-04-13 11:08:32 +00:00
|
|
|
RTL_TEXTENCODING_UTF8 ))
|
|
|
|
{
|
2006-03-06 09:22:07 +00:00
|
|
|
sal_Int32 index = sizeof ("PKG_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() );
|
2004-11-09 13:11:20 +00:00
|
|
|
if (token.getLength() > 0) {
|
2004-06-11 11:13:15 +00:00
|
|
|
// cleanup, check if existing:
|
2004-11-09 13:11:20 +00:00
|
|
|
if (create_ucb_content(
|
|
|
|
0, expandUnoRcTerm(token), xCmdEnv,
|
|
|
|
false /* no throw */ )) {
|
|
|
|
m_jar_typelibs.push_back( token );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
OSL_ENSURE(
|
2006-03-06 09:22:07 +00:00
|
|
|
0, "### invalid PKG_UNO_JAVA_CLASSPATH entry!");
|
2004-06-11 11:13:15 +00:00
|
|
|
}
|
2004-04-13 11:08:32 +00:00
|
|
|
}
|
|
|
|
while (index >= 0);
|
|
|
|
}
|
2006-03-06 09:22:07 +00:00
|
|
|
if (readLine( &line, OUSTR("PKG_UNO_TYPES="), ucb_content,
|
2004-08-12 11:10:09 +00:00
|
|
|
RTL_TEXTENCODING_UTF8 )) {
|
2006-03-06 09:22:07 +00:00
|
|
|
sal_Int32 index = sizeof ("PKG_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() );
|
2004-08-12 11:10:09 +00:00
|
|
|
if (token.getLength() > 0) {
|
2004-06-11 11:13:15 +00:00
|
|
|
if (token[ 0 ] == '?')
|
|
|
|
token = token.copy( 1 );
|
|
|
|
// cleanup, check if existing:
|
2004-08-12 11:10:09 +00:00
|
|
|
if (create_ucb_content(
|
2004-11-09 13:11:20 +00:00
|
|
|
0, expandUnoRcTerm(token),
|
2004-08-12 11:10:09 +00:00
|
|
|
xCmdEnv, false /* no throw */ )) {
|
|
|
|
m_rdb_typelibs.push_back( token );
|
2004-06-11 11:13:15 +00:00
|
|
|
}
|
2004-11-09 13:11:20 +00:00
|
|
|
else
|
2006-03-06 09:22:07 +00:00
|
|
|
OSL_ENSURE( 0, "### invalid PKG_UNO_TYPES entry!" );
|
2004-06-11 11:13:15 +00:00
|
|
|
}
|
2004-04-13 11:08:32 +00:00
|
|
|
}
|
|
|
|
while (index >= 0);
|
|
|
|
}
|
2006-03-06 09:22:07 +00:00
|
|
|
if (readLine( &line, OUSTR("PKG_UNO_SERVICES="), ucb_content,
|
2004-08-12 11:10:09 +00:00
|
|
|
RTL_TEXTENCODING_UTF8 )) {
|
2006-03-06 09:22:07 +00:00
|
|
|
sal_Int32 start = sizeof ("PKG_UNO_SERVICES=?$ORIGIN/") - 1;
|
2004-06-11 11:13:15 +00:00
|
|
|
sal_Int32 sep = line.indexOf( ' ', start );
|
|
|
|
OSL_ASSERT( sep > 0 );
|
|
|
|
m_commonRDB = line.copy( start, sep - start );
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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-03-06 09:22:07 +00:00
|
|
|
if (readLine( &line, OUSTR("PKG_UNO_SERVICES="), ucb_content,
|
2004-08-12 11:10:09 +00:00
|
|
|
RTL_TEXTENCODING_UTF8 )) {
|
2004-06-11 11:13:15 +00:00
|
|
|
m_nativeRDB = line.copy(
|
2006-03-06 09:22:07 +00:00
|
|
|
sizeof ("PKG_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;
|
2006-03-06 09:22:07 +00:00
|
|
|
// UNO_USER_PACKAGES_CACHE, UNO_SHARED_PACKAGES_CACHE
|
|
|
|
// have to be resolved locally:
|
2004-11-09 13:11:20 +00:00
|
|
|
if (m_eContext == CONTEXT_USER) {
|
|
|
|
buf.append( RTL_CONSTASCII_STRINGPARAM(
|
|
|
|
"UNO_USER_PACKAGES_CACHE=$ORIGIN/../..") );
|
|
|
|
}
|
|
|
|
else if (m_eContext == CONTEXT_SHARED) {
|
|
|
|
buf.append( RTL_CONSTASCII_STRINGPARAM(
|
|
|
|
"UNO_SHARED_PACKAGES_CACHE=$ORIGIN/../..") );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
OSL_ASSERT(0);
|
|
|
|
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-03-06 09:22:07 +00:00
|
|
|
buf.append( RTL_CONSTASCII_STRINGPARAM("PKG_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-03-06 09:22:07 +00:00
|
|
|
buf.append( RTL_CONSTASCII_STRINGPARAM("PKG_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
|
|
|
}
|
|
|
|
if (m_commonRDB.getLength() > 0 || m_nativeRDB.getLength() > 0)
|
|
|
|
{
|
2006-03-06 09:22:07 +00:00
|
|
|
buf.append( RTL_CONSTASCII_STRINGPARAM("PKG_UNO_SERVICES=?$ORIGIN/") );
|
2004-06-11 11:13:15 +00:00
|
|
|
buf.append( ::rtl::OUStringToOString(
|
|
|
|
m_commonRDB, RTL_TEXTENCODING_ASCII_US ) );
|
|
|
|
if (m_nativeRDB.getLength() > 0)
|
|
|
|
{
|
|
|
|
buf.append( RTL_CONSTASCII_STRINGPARAM(
|
2006-03-06 09:22:07 +00:00
|
|
|
" ${$ORIGIN/${_OS}_${_ARCH}rc:PKG_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;
|
2006-03-06 09:22:07 +00:00
|
|
|
buf2.append( RTL_CONSTASCII_STRINGPARAM(
|
|
|
|
"PKG_UNO_SERVICES=?$ORIGIN/") );
|
2004-06-11 11:13:15 +00:00
|
|
|
buf2.append( ::rtl::OUStringToOString(
|
|
|
|
m_nativeRDB, 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() ) ) );
|
|
|
|
::ucb::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() ) ) );
|
|
|
|
::ucb::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
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
inline OUString makeRcTerm( OUString const & url )
|
|
|
|
{
|
|
|
|
OSL_ASSERT( url.matchAsciiL( RTL_CONSTASCII_STRINGPARAM(
|
|
|
|
"vnd.sun.star.expand:") ) );
|
|
|
|
if (url.matchAsciiL( RTL_CONSTASCII_STRINGPARAM("vnd.sun.star.expand:") )) {
|
|
|
|
// cut protocol:
|
|
|
|
OUString rcterm( url.copy( sizeof ("vnd.sun.star.expand:") - 1 ) );
|
|
|
|
// decode uric class chars:
|
|
|
|
rcterm = ::rtl::Uri::decode(
|
|
|
|
rcterm, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 );
|
|
|
|
return rcterm;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return url;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2004-11-09 13:11:20 +00:00
|
|
|
const OUString rcterm( makeRcTerm(url_) );
|
|
|
|
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
|
|
|
{
|
2004-11-09 13:11:20 +00:00
|
|
|
const OUString rcterm( makeRcTerm(url_) );
|
|
|
|
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(
|
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-11-09 13:11:20 +00:00
|
|
|
const OUString rcterm( makeRcTerm(url_) );
|
|
|
|
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() );
|
|
|
|
const ::std::size_t erased = m_backendObjects.erase( id );
|
2004-06-11 11:13:15 +00:00
|
|
|
OSL_ASSERT( erased == 1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
//______________________________________________________________________________
|
|
|
|
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
|
|
|
void dummy() {}
|
2004-12-07 09:54:04 +00:00
|
|
|
struct ProgramDir : public rtl::StaticWithInit<const OUString, ProgramDir> {
|
|
|
|
const OUString operator () () {
|
2004-11-09 13:11:20 +00:00
|
|
|
OUString exeURL;
|
|
|
|
::osl::Module::getUrlFromAddress( (void *) dummy, exeURL );
|
|
|
|
return exeURL.copy( 0, exeURL.lastIndexOf('/') );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2004-06-11 11:13:15 +00:00
|
|
|
//------------------------------------------------------------------------------
|
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 )
|
|
|
|
{
|
|
|
|
::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 );
|
|
|
|
OSL_ASSERT( buf.getLength() == 0 );
|
|
|
|
// use only preinstalled services:
|
|
|
|
buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("-env:UNO_SERVICES=") );
|
2004-11-09 13:11:20 +00:00
|
|
|
buf.append( ProgramDir::get() );
|
2004-06-11 11:13:15 +00:00
|
|
|
buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("/services.rdb") );
|
|
|
|
args.push_back( buf.makeStringAndClear() );
|
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
|
|
|
|
|
|
|
oslProcess hProcess = raiseProcess(
|
2004-11-09 13:11:20 +00:00
|
|
|
ProgramDir::get() + OUSTR("/uno"),
|
2006-03-06 09:22:07 +00:00
|
|
|
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:
|
|
|
|
oslProcessError rc = osl_terminateProcess( hProcess );
|
|
|
|
OSL_ASSERT( rc == osl_Process_E_None );
|
|
|
|
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-08-12 11:10:09 +00:00
|
|
|
pImplNames->push_back( implName );
|
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
|
|
|
}
|
|
|
|
}
|
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_(
|
2004-04-13 11:08:32 +00:00
|
|
|
::osl::ResettableMutexGuard & guard,
|
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();
|
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;
|
2004-11-09 13:11:20 +00:00
|
|
|
const Reference<registry::XSimpleRegistry> xRDB( getRDB() );
|
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) );
|
|
|
|
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() ))
|
|
|
|
break;
|
2004-04-13 11:08:32 +00:00
|
|
|
}
|
|
|
|
}
|
2004-08-12 11:10:09 +00:00
|
|
|
if (pos >= 0)
|
|
|
|
m_registered = REG_REGISTERED;
|
2004-04-13 11:08:32 +00:00
|
|
|
}
|
|
|
|
}
|
2004-08-12 11:10:09 +00:00
|
|
|
return beans::Optional< beans::Ambiguous<sal_Bool> >(
|
|
|
|
true /* IsPresent */,
|
|
|
|
beans::Ambiguous<sal_Bool>(
|
|
|
|
m_registered == REG_REGISTERED,
|
|
|
|
m_registered == REG_VOID /* IsAmbiguous */ ) );
|
2004-04-13 11:08:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//______________________________________________________________________________
|
2004-11-09 13:11:20 +00:00
|
|
|
void BackendImpl::ComponentPackageImpl::processPackage_(
|
2004-04-13 11:08:32 +00:00
|
|
|
::osl::ResettableMutexGuard & guard,
|
2004-06-11 11:13:15 +00:00
|
|
|
bool registerPackage,
|
|
|
|
::rtl::Reference<AbortChannel> const & abortChannel,
|
|
|
|
Reference<XCommandEnvironment> const & xCmdEnv )
|
2004-04-13 11:08:32 +00:00
|
|
|
{
|
|
|
|
BackendImpl * that = getMyBackend();
|
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() );
|
2004-04-13 11:08:32 +00:00
|
|
|
|
2004-06-11 11:13:15 +00:00
|
|
|
if (registerPackage)
|
2004-04-13 11:08:32 +00:00
|
|
|
{
|
2004-06-11 11:13:15 +00:00
|
|
|
if (java) // xxx todo: add to CLASSPATH until we have an
|
|
|
|
// own extendable classloader, the sandbox
|
|
|
|
// classloader is insufficient, because the bridge
|
|
|
|
// and class com.sun.star.uno.Type load classes
|
|
|
|
// using a different classloader, so add first before
|
|
|
|
// raising the uno process
|
2004-11-09 13:11:20 +00:00
|
|
|
that->addToUnoRc( java, url, xCmdEnv );
|
2004-04-13 11:08:32 +00:00
|
|
|
|
2004-08-12 11:10:09 +00:00
|
|
|
if (! m_xRemoteContext.is()) {
|
2004-06-11 11:13:15 +00:00
|
|
|
m_xRemoteContext.set(
|
2004-08-12 11:10:09 +00:00
|
|
|
that->getObject( url ), UNO_QUERY );
|
|
|
|
if (! m_xRemoteContext.is()) {
|
2004-06-11 11:13:15 +00:00
|
|
|
m_xRemoteContext.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(
|
2004-06-11 11:13:15 +00:00
|
|
|
m_xRemoteContext->getServiceManager()->createInstanceWithContext(
|
|
|
|
OUSTR("com.sun.star.registry.ImplementationRegistration"),
|
|
|
|
m_xRemoteContext ), UNO_QUERY_THROW );
|
2004-08-12 11:10:09 +00:00
|
|
|
xImplReg->registerImplementation( m_loader, url, xServicesRDB );
|
2004-06-11 11:13:15 +00:00
|
|
|
|
2004-08-12 11:10:09 +00:00
|
|
|
t_stringlist implNames;
|
|
|
|
t_stringpairvec singletons;
|
2004-11-09 13:11:20 +00:00
|
|
|
const Reference<loader::XImplementationLoader> xLoader(
|
2004-08-12 11:10:09 +00:00
|
|
|
getComponentInfo( &implNames, &singletons, m_xRemoteContext ) );
|
2004-06-11 11:13:15 +00:00
|
|
|
|
|
|
|
// factories live insertion:
|
2004-11-09 13:11:20 +00:00
|
|
|
const Reference<container::XSet> xSet(
|
2004-06-11 11:13:15 +00:00
|
|
|
that->getComponentContext()->getServiceManager(), UNO_QUERY_THROW );
|
2004-08-12 11:10:09 +00:00
|
|
|
for ( t_stringlist::const_iterator iPos( implNames.begin() );
|
|
|
|
iPos != implNames.end(); ++iPos )
|
2004-04-13 11:08:32 +00:00
|
|
|
{
|
2004-06-11 11:13:15 +00:00
|
|
|
checkAborted( abortChannel );
|
|
|
|
OUString const & implName = *iPos;
|
|
|
|
// activate factory:
|
2004-11-09 13:11:20 +00:00
|
|
|
const Reference<XInterface> xFactory(
|
2004-06-11 11:13:15 +00:00
|
|
|
xLoader->activate(
|
2004-08-12 11:10:09 +00:00
|
|
|
implName, OUString(), url,
|
2004-06-11 11:13:15 +00:00
|
|
|
xServicesRDB->getRootKey()->openKey(
|
|
|
|
OUSTR("/IMPLEMENTATIONS/") + implName ) ) );
|
2004-08-12 11:10:09 +00:00
|
|
|
try {
|
2005-01-21 16:13:33 +00:00
|
|
|
xSet->insert( Any(xFactory) );
|
2004-08-12 11:10:09 +00:00
|
|
|
} // ignore if factory has already been inserted:
|
|
|
|
catch (container::ElementExistException &) {
|
2004-06-11 11:13:15 +00:00
|
|
|
OSL_ENSURE( 0, "### factory already registered?" );
|
|
|
|
}
|
2004-04-13 11:08:32 +00:00
|
|
|
}
|
2004-06-11 11:13:15 +00:00
|
|
|
|
2004-08-12 11:10:09 +00:00
|
|
|
if (! singletons.empty())
|
2004-04-13 11:08:32 +00:00
|
|
|
{
|
2004-08-12 11:10:09 +00:00
|
|
|
// singletons live insertion:
|
2004-11-09 13:11:20 +00:00
|
|
|
const Reference<container::XNameContainer> xRootContext(
|
2004-08-12 11:10:09 +00:00
|
|
|
that->getComponentContext()->getValueByName(
|
|
|
|
OUSTR("_root") ), UNO_QUERY );
|
|
|
|
if (xRootContext.is())
|
2004-06-11 11:13:15 +00:00
|
|
|
{
|
2004-08-12 11:10:09 +00:00
|
|
|
for ( t_stringpairvec::const_iterator iPos(
|
|
|
|
singletons.begin() );
|
|
|
|
iPos != singletons.end(); ++iPos )
|
|
|
|
{
|
|
|
|
::std::pair<OUString, OUString> const & sp = *iPos;
|
2004-11-09 13:11:20 +00:00
|
|
|
const OUString name( OUSTR("/singletons/") + sp.first );
|
2004-08-12 11:10:09 +00:00
|
|
|
// assure no arguments:
|
|
|
|
try {
|
|
|
|
xRootContext->removeByName( name + OUSTR("/arguments"));
|
|
|
|
} catch (container::NoSuchElementException &) {}
|
|
|
|
// used service:
|
|
|
|
try {
|
|
|
|
xRootContext->insertByName(
|
2005-01-21 16:13:33 +00:00
|
|
|
name + OUSTR("/service"), Any(sp.second) );
|
2004-08-12 11:10:09 +00:00
|
|
|
} catch (container::ElementExistException &) {
|
|
|
|
xRootContext->replaceByName(
|
2005-01-21 16:13:33 +00:00
|
|
|
name + OUSTR("/service"), Any(sp.second) );
|
2004-08-12 11:10:09 +00:00
|
|
|
}
|
|
|
|
// singleton entry:
|
|
|
|
try {
|
|
|
|
xRootContext->insertByName( name, Any() );
|
|
|
|
} catch (container::ElementExistException & exc) {
|
|
|
|
OSL_ENSURE(
|
|
|
|
0, OUStringToOString(
|
|
|
|
exc.Message, RTL_TEXTENCODING_UTF8 ).getStr() );
|
|
|
|
xRootContext->replaceByName( name, Any() );
|
|
|
|
}
|
|
|
|
}
|
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;
|
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;
|
|
|
|
|
2004-06-11 11:13:15 +00:00
|
|
|
Reference<XComponentContext> xContext;
|
|
|
|
if (m_xRemoteContext.is()) // has been activated in this process
|
|
|
|
xContext = m_xRemoteContext;
|
|
|
|
else // has been deployed in former times
|
|
|
|
xContext = that->getComponentContext();
|
|
|
|
|
2004-08-12 11:10:09 +00:00
|
|
|
t_stringlist implNames;
|
|
|
|
t_stringpairvec singletons;
|
|
|
|
getComponentInfo( &implNames, &singletons, xContext );
|
2004-06-11 11:13:15 +00:00
|
|
|
|
|
|
|
// factories live removal:
|
2004-11-09 13:11:20 +00:00
|
|
|
const Reference<container::XSet> xSet(
|
2004-06-11 11:13:15 +00:00
|
|
|
that->getComponentContext()->getServiceManager(), UNO_QUERY_THROW );
|
2004-08-12 11:10:09 +00:00
|
|
|
for ( t_stringlist::const_iterator iPos( implNames.begin() );
|
|
|
|
iPos != implNames.end(); ++iPos )
|
2004-06-11 11:13:15 +00:00
|
|
|
{
|
|
|
|
OUString const & implName = *iPos;
|
2004-08-12 11:10:09 +00:00
|
|
|
try {
|
2005-01-21 16:13:33 +00:00
|
|
|
xSet->remove( Any(implName) );
|
2004-08-12 11:10:09 +00:00
|
|
|
} // ignore if factory has not been live deployed:
|
|
|
|
catch (container::NoSuchElementException &) {
|
2004-06-11 11:13:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-08-12 11:10:09 +00:00
|
|
|
if (! singletons.empty())
|
2004-06-11 11:13:15 +00:00
|
|
|
{
|
2004-08-12 11:10:09 +00:00
|
|
|
// singletons live removal:
|
2004-11-09 13:11:20 +00:00
|
|
|
const Reference<container::XNameContainer> xRootContext(
|
2004-08-12 11:10:09 +00:00
|
|
|
that->getComponentContext()->getValueByName(
|
|
|
|
OUSTR("_root") ), UNO_QUERY );
|
|
|
|
if (xRootContext.is())
|
2004-06-11 11:13:15 +00:00
|
|
|
{
|
2004-08-12 11:10:09 +00:00
|
|
|
for ( t_stringpairvec::const_iterator iPos(
|
|
|
|
singletons.begin() );
|
|
|
|
iPos != singletons.end(); ++iPos )
|
|
|
|
{
|
|
|
|
::std::pair<OUString, OUString> const & sp = *iPos;
|
2004-11-09 13:11:20 +00:00
|
|
|
const OUString name( OUSTR("/singletons/") + sp.first );
|
2004-08-12 11:10:09 +00:00
|
|
|
// 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) {
|
|
|
|
OSL_ENSURE(
|
|
|
|
0, OUStringToOString(
|
|
|
|
exc.Message, RTL_TEXTENCODING_UTF8 ).getStr() );
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
|
|
|
|
if (java) // xxx todo: add to CLASSPATH until we have an
|
|
|
|
// own extendable classloader, the sandbox
|
|
|
|
// classloader is insufficient, because the bridge
|
|
|
|
// and class com.sun.star.uno.Type load classes
|
2004-06-11 11:13:15 +00:00
|
|
|
// using a different classloader
|
2004-11-09 13:11:20 +00:00
|
|
|
that->removeFromUnoRc( java, url, xCmdEnv );
|
2004-04-13 11:08:32 +00:00
|
|
|
|
2004-08-12 11:10:09 +00:00
|
|
|
if (m_xRemoteContext.is()) {
|
|
|
|
that->releaseObject( url );
|
2004-06-11 11:13:15 +00:00
|
|
|
m_xRemoteContext.clear();
|
|
|
|
}
|
2004-04-13 11:08:32 +00:00
|
|
|
|
2004-06-11 11:13:15 +00:00
|
|
|
m_registered = REG_NOT_REGISTERED;
|
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::TypelibraryPackageImpl::isRegistered_(
|
2004-04-13 11:08:32 +00:00
|
|
|
::osl::ResettableMutexGuard & guard,
|
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();
|
2004-08-12 11:10:09 +00:00
|
|
|
return beans::Optional< beans::Ambiguous<sal_Bool> >(
|
|
|
|
true /* IsPresent */,
|
|
|
|
beans::Ambiguous<sal_Bool>(
|
2004-11-09 13:11:20 +00:00
|
|
|
that->hasInUnoRc( m_jarFile, getURL(), xCmdEnv ),
|
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_(
|
2004-04-13 11:08:32 +00:00
|
|
|
::osl::ResettableMutexGuard & guard,
|
2004-06-11 11:13:15 +00:00
|
|
|
bool registerPackage,
|
|
|
|
::rtl::Reference<AbortChannel> const & abortChannel,
|
|
|
|
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
|
|
|
|
2004-06-11 11:13:15 +00:00
|
|
|
if (registerPackage)
|
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: ???
|
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?
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-11-09 13:11:20 +00:00
|
|
|
} // anon namespace
|
|
|
|
|
2006-03-06 09:22:07 +00:00
|
|
|
namespace sdecl = comphelper::service_decl;
|
|
|
|
extern sdecl::ServiceDecl const serviceDecl(
|
|
|
|
sdecl::class_<BackendImpl, sdecl::with_args<true> >(),
|
|
|
|
"com.sun.star.comp.deployment.component.PackageRegistryBackend",
|
|
|
|
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
|
|
|
|