From 26bba85c9b3ad11a5d5728e0653ed199eb4793e8 Mon Sep 17 00:00:00 2001 From: Tobias Krause Date: Fri, 18 Dec 2009 08:24:03 +0100 Subject: tkr33: #i107136# The UCB now considers configuration changes (new UCPs) of UCPs during runtime. --- ucbhelper/inc/ucbhelper/configureucb.hxx | 204 ------------------------------ ucbhelper/inc/ucbhelper/contentbroker.hxx | 2 +- ucbhelper/inc/ucbhelper/registerucb.hxx | 132 +++++++++++++++++++ ucbhelper/prj/d.lst | 2 +- ucbhelper/source/client/contentbroker.cxx | 16 ++- ucbhelper/source/provider/makefile.mk | 2 - ucbhelper/source/provider/registerucb.cxx | 40 +----- ucbhelper/source/provider/registerucb.hxx | 99 --------------- 8 files changed, 145 insertions(+), 352 deletions(-) delete mode 100644 ucbhelper/inc/ucbhelper/configureucb.hxx create mode 100644 ucbhelper/inc/ucbhelper/registerucb.hxx delete mode 100644 ucbhelper/source/provider/registerucb.hxx diff --git a/ucbhelper/inc/ucbhelper/configureucb.hxx b/ucbhelper/inc/ucbhelper/configureucb.hxx deleted file mode 100644 index 479130c0624f..000000000000 --- a/ucbhelper/inc/ucbhelper/configureucb.hxx +++ /dev/null @@ -1,204 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: configureucb.hxx,v $ - * $Revision: 1.8 $ - * - * This file is part of OpenOffice.org. - * - * 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. - * - * 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). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef _UCBHELPER_CONFIGUREUCB_HXX_ -#define _UCBHELPER_CONFIGUREUCB_HXX_ - -#include -#include -#include -#include - -#include -#include "ucbhelper/ucbhelperdllapi.h" - -namespace com { namespace sun { namespace star { - namespace lang { class XMultiServiceFactory; } - namespace ucb { - class XContentProvider; - class XContentProviderManager; - } - namespace uno { class Any; } -} } } - -namespace ucbhelper { - -//============================================================================ -/** Information about a registered content provider, passed from - configureUcb to unconfigureUcb (and from - registerAtUcb to deregisterFromUcb). - */ -struct ContentProviderRegistrationInfo -{ - /** The registered content provider (or null if registration failed). - */ - com::sun::star::uno::Reference< com::sun::star::ucb::XContentProvider > - m_xProvider; - - /** The arguments the content provider was instantiated with. - */ - rtl::OUString m_aArguments; - - /** The URL template the content provider is registered on. - */ - rtl::OUString m_aTemplate; -}; - //@@@ if registerucb.hxx were exported, too, this might better reside in - // there... - -typedef std::vector< ContentProviderRegistrationInfo > - ContentProviderRegistrationInfoList; - -//============================================================================ -/** Information about a content provider, passed to - configureUcb. - */ -struct ContentProviderData -{ - /** The UNO service name to use to instanciate the content provider. - */ - rtl::OUString ServiceName; - - /** The URL template to use to instanciate the content provider. - */ - rtl::OUString URLTemplate; - - /** The arguments to use to instanciate the content provider. - */ - rtl::OUString Arguments; - - ContentProviderData() {}; - ContentProviderData( const rtl::OUString & rService, - const rtl::OUString & rTemplate, - const rtl::OUString & rArgs ) - : ServiceName( rService ), URLTemplate( rTemplate ), Arguments( rArgs ) {} -}; - -typedef std::vector< ContentProviderData > ContentProviderDataList; - -//============================================================================ -/** Configure a (newly instantiated) Universal Content Broker. - - @descr This function tries to register at the given content provider - manager all the content provider services listed under a given key in the - configuration database. - - @param rManager A content provider manager (normally, this would be a - newly intantiated UCB). - - @param rServiceFactory A service factory through which to obtain the - various services required. - - @param rData A list containing the data for the content providers for - the UCB to configure. - - @pInfos If not null, an entry will be added to this vector for every - content provider that is registered (sucessfully or not). - - @return True if the UCB has successfuly been configured (though not all - content providers have necessarily been registered due to individual - problems). - */ -bool -configureUcb( - com::sun::star::uno::Reference< - com::sun::star::ucb::XContentProviderManager > const & - rManager, - com::sun::star::uno::Reference< - com::sun::star::lang::XMultiServiceFactory > const & - rServiceFactory, - ContentProviderDataList const & rData, - ContentProviderRegistrationInfoList * pInfos) - throw (com::sun::star::uno::RuntimeException); - - -//============================================================================ -/** Configure a (newly instantiated) Universal Content Broker. - - @descr This function tries to register at the given content provider - manager all the content provider services listed under a given key in the - configuration database. - - @param rManager A content provider manager (normally, this would be a - newly intantiated UCB). - - @param rServiceFactory A service factory through which to obtain the - various services required. - - @param rArguments A sequence of at least two strings: the primary and - secondary key addressing a chosen UCB configuration in the configuration - database. The sequence can be longer, in which case the excess elements - must be strings that form key/value pairs. These key/value pairs will be - used to replace placeholders in the data from the configuration database - with (dynamic) values. This is a (rather unstructured) sequence of - Anys, since normally this parameter will simply be forwarded - by the UCB's initialize method, which has a parameter of - the same type. - - @pInfos If not null, an entry will be added to this vector for every - content provider that is registered (sucessfully or not). - - @return True if the UCB has successfuly been configured (though not all - content providers have necessarily been registered due to individual - problems). - */ -UCBHELPER_DLLPUBLIC bool -configureUcb( - com::sun::star::uno::Reference< - com::sun::star::ucb::XContentProviderManager > const & - rManager, - com::sun::star::uno::Reference< - com::sun::star::lang::XMultiServiceFactory > const & - rServiceFactory, - com::sun::star::uno::Sequence< com::sun::star::uno::Any > const & - rArguments, - std::vector< ContentProviderRegistrationInfo > * pInfos) - throw (com::sun::star::uno::RuntimeException); - -//============================================================================ -/** Undo the configuration of a Universal Content Broker. - - @descr This function is the reverse of configureUcb. - - @param rManager A content provider manager. - - @param rInfos Information about all the registered content providers. - */ -void -unconfigureUcb( - com::sun::star::uno::Reference< - com::sun::star::ucb::XContentProviderManager > const & - rManager, - std::vector< ContentProviderRegistrationInfo > const & rInfos) - throw (com::sun::star::uno::RuntimeException); - -} - -#endif // _UCBHELPER_CONFIGUREUCB_HXX_ diff --git a/ucbhelper/inc/ucbhelper/contentbroker.hxx b/ucbhelper/inc/ucbhelper/contentbroker.hxx index f119e9c61284..ee28333303cd 100644 --- a/ucbhelper/inc/ucbhelper/contentbroker.hxx +++ b/ucbhelper/inc/ucbhelper/contentbroker.hxx @@ -44,7 +44,7 @@ namespace com { namespace sun { namespace star { namespace ucb { class XContentProviderManager; class XCommandProcessor; } } } } -#include +#include #include "ucbhelper/ucbhelperdllapi.h" namespace ucbhelper diff --git a/ucbhelper/inc/ucbhelper/registerucb.hxx b/ucbhelper/inc/ucbhelper/registerucb.hxx new file mode 100644 index 000000000000..4eca71c6f0cd --- /dev/null +++ b/ucbhelper/inc/ucbhelper/registerucb.hxx @@ -0,0 +1,132 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: registerucb.hxx,v $ + * $Revision: 1.6 $ + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _UCBHELPER_REGISTERUCB_HXX_ +#define _UCBHELPER_REGISTERUCB_HXX_ + +#include +#include +#include +#include +#include + +#include "ucbhelper/ucbhelperdllapi.h" + +namespace com { namespace sun { namespace star { + namespace lang { class XMultiServiceFactory; } +} } } + +namespace rtl { class OUString; } + +namespace ucbhelper { + +//============================================================================ +/** Information about a registered content provider. + */ +struct ContentProviderRegistrationInfo +{ + /** The registered content provider (or null if registration failed). + */ + com::sun::star::uno::Reference< com::sun::star::ucb::XContentProvider > + m_xProvider; + + /** The arguments the content provider was instantiated with. + */ + rtl::OUString m_aArguments; + + /** The URL template the content provider is registered on. + */ + rtl::OUString m_aTemplate; +}; + +typedef std::vector< ContentProviderRegistrationInfo > + ContentProviderRegistrationInfoList; + +//============================================================================ +/** Information about a content provider, passed to + configureUcb. + */ +struct ContentProviderData +{ + /** The UNO service name to use to instanciate the content provider. + */ + rtl::OUString ServiceName; + + /** The URL template to use to instanciate the content provider. + */ + rtl::OUString URLTemplate; + + /** The arguments to use to instanciate the content provider. + */ + rtl::OUString Arguments; + + ContentProviderData() {}; + ContentProviderData( const rtl::OUString & rService, + const rtl::OUString & rTemplate, + const rtl::OUString & rArgs ) + : ServiceName( rService ), URLTemplate( rTemplate ), Arguments( rArgs ) {} +}; + +typedef std::vector< ContentProviderData > ContentProviderDataList; +//============================================================================ +/** Register a content provider at a Universal Content Broker. + + @param rManager A content provider manager (normally, this would be a + UCB). May be null, which is only useful if the content provider is an + XParamterizedContentProviders. + + @param rServiceFactory A factory through which to obtain the required + services. + + @param rName The service name of the content provider. + + @param rArguments Any arguments to instantiate the content provider with. + + @param rTemplate The URL template to register the content provider on. + + @param pInfo If not null, this output parameter is filled with + information about the (atemptively) registered provider. + */ + +UCBHELPER_DLLPUBLIC bool registerAtUcb( + com::sun::star::uno::Reference< + com::sun::star::ucb::XContentProviderManager > const & + rManager, + com::sun::star::uno::Reference< + com::sun::star::lang::XMultiServiceFactory > const & + rServiceFactory, + rtl::OUString const & rName, + rtl::OUString const & rArguments, + rtl::OUString const & rTemplate, + ContentProviderRegistrationInfo * pInfo) + throw (com::sun::star::uno::RuntimeException); + +} +#endif // _UCBHELPER_REGISTERUCB_HXX_ diff --git a/ucbhelper/prj/d.lst b/ucbhelper/prj/d.lst index 64da268b6143..d11414525e8c 100644 --- a/ucbhelper/prj/d.lst +++ b/ucbhelper/prj/d.lst @@ -9,7 +9,7 @@ mkdir: %_DEST%\inc%_EXT%\ucbhelper ..\inc\ucbhelper\configurationkeys.hxx %_DEST%\inc%_EXT%\ucbhelper\configurationkeys.hxx -..\inc\ucbhelper\configureucb.hxx %_DEST%\inc%_EXT%\ucbhelper\configureucb.hxx +..\inc\ucbhelper\configureucb.hxx %_DEST%\inc%_EXT%\ucbhelper\registerucb.hxx ..\inc\ucbhelper\content.hxx %_DEST%\inc%_EXT%\ucbhelper\content.hxx ..\inc\ucbhelper\contentbroker.hxx %_DEST%\inc%_EXT%\ucbhelper\contentbroker.hxx ..\inc\ucbhelper\commandenvironment.hxx %_DEST%\inc%_EXT%\ucbhelper\commandenvironment.hxx diff --git a/ucbhelper/source/client/contentbroker.cxx b/ucbhelper/source/client/contentbroker.cxx index 43d1491d8507..cbd43c807073 100644 --- a/ucbhelper/source/client/contentbroker.cxx +++ b/ucbhelper/source/client/contentbroker.cxx @@ -301,14 +301,18 @@ bool ContentBroker_Impl::initialize() if ( m_xProviderMgr.is() ) { - if ( !configureUcb( m_xProviderMgr, - m_xSMgr, - m_aProvData, - 0 ) ) + ContentProviderDataList::const_iterator aEnd(m_aProvData.end()); + for (ContentProviderDataList::const_iterator aIt(m_aProvData.begin()); + aIt != aEnd; ++aIt) { - OSL_ENSURE( false, "Failed to configure UCB!" ); - return false; + registerAtUcb(m_xProviderMgr, + m_xSMgr, + aIt->ServiceName, + aIt->Arguments, + aIt->URLTemplate, + 0); } + } } } diff --git a/ucbhelper/source/provider/makefile.mk b/ucbhelper/source/provider/makefile.mk index acb213ec201d..97d4616e4161 100644 --- a/ucbhelper/source/provider/makefile.mk +++ b/ucbhelper/source/provider/makefile.mk @@ -47,7 +47,6 @@ ENABLE_EXCEPTIONS=TRUE .IF "$(header)" == "" SLOFILES=\ - $(SLO)$/configureucb.obj \ $(SLO)$/contentidentifier.obj \ $(SLO)$/providerhelper.obj \ $(SLO)$/contenthelper.obj \ @@ -57,7 +56,6 @@ SLOFILES=\ $(SLO)$/resultsetmetadata.obj \ $(SLO)$/resultset.obj \ $(SLO)$/resultsethelper.obj \ - $(SLO)$/provconf.obj \ $(SLO)$/commandenvironmentproxy.obj \ $(SLO)$/interactionrequest.obj \ $(SLO)$/simpleinteractionrequest.obj \ diff --git a/ucbhelper/source/provider/registerucb.cxx b/ucbhelper/source/provider/registerucb.cxx index 584aa21561e0..5aeaaec273ce 100644 --- a/ucbhelper/source/provider/registerucb.cxx +++ b/ucbhelper/source/provider/registerucb.cxx @@ -30,7 +30,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_ucbhelper.hxx" -#include +#include #include #include #include @@ -38,7 +38,6 @@ #include #include "osl/diagnose.h" -#include using namespace com::sun::star; @@ -165,41 +164,4 @@ registerAtUcb( return bSuccess; } -//============================================================================ -// -// deregisterFromUcb -// -//============================================================================ - -void -deregisterFromUcb( - uno::Reference< ucb::XContentProviderManager > const & rManager, - ContentProviderRegistrationInfo const & rInfo) - throw (uno::RuntimeException) -{ - uno::Reference< ucb::XContentProvider > - xProvider(rInfo.m_xProvider); - uno::Reference< ucb::XParameterizedContentProvider > - xParameterized(xProvider, uno::UNO_QUERY); - if (xParameterized.is()) - { - uno::Reference< ucb::XContentProvider > xInstance; - try - { - xInstance - = xParameterized->deregisterInstance(rInfo.m_aTemplate, - rInfo.m_aArguments); - } - catch (lang::IllegalArgumentException const &) {} - - if (xInstance.is()) - xProvider = xInstance; - } - - if (rManager.is()) - rManager->deregisterContentProvider(xProvider, rInfo.m_aTemplate); - //@@@ if this fails, a roll-back of deregisterInstance() is - // missing -} - } diff --git a/ucbhelper/source/provider/registerucb.hxx b/ucbhelper/source/provider/registerucb.hxx deleted file mode 100644 index f345d774dcfd..000000000000 --- a/ucbhelper/source/provider/registerucb.hxx +++ /dev/null @@ -1,99 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: registerucb.hxx,v $ - * $Revision: 1.6 $ - * - * This file is part of OpenOffice.org. - * - * 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. - * - * 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). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef _UCBHELPER_REGISTERUCB_HXX_ -#define _UCBHELPER_REGISTERUCB_HXX_ - -#include -#include - -namespace com { namespace sun { namespace star { - namespace lang { class XMultiServiceFactory; } - namespace ucb { class XContentProviderManager; } -} } } -namespace rtl { class OUString; } - -namespace ucbhelper { - -struct ContentProviderRegistrationInfo; - -//============================================================================ -/** Register a content provider at a Universal Content Broker. - - @param rManager A content provider manager (normally, this would be a - UCB). May be null, which is only useful if the content provider is an - XParamterizedContentProviders. - - @param rServiceFactory A factory through which to obtain the required - services. - - @param rName The service name of the content provider. - - @param rArguments Any arguments to instantiate the content provider with. - - @param rTemplate The URL template to register the content provider on. - - @param pInfo If not null, this output parameter is filled with - information about the (atemptively) registered provider. - */ -bool -registerAtUcb( - com::sun::star::uno::Reference< - com::sun::star::ucb::XContentProviderManager > const & - rManager, - com::sun::star::uno::Reference< - com::sun::star::lang::XMultiServiceFactory > const & - rServiceFactory, - rtl::OUString const & rName, - rtl::OUString const & rArguments, - rtl::OUString const & rTemplate, - ContentProviderRegistrationInfo * pInfo) - throw (com::sun::star::uno::RuntimeException); - -//============================================================================ -/** Deregister a content provider from a Universal Content Broker. - - @param rManager A content provider manager (normally, this would be a - UCB). May be null, which is only useful if the content provider is an - XParamterizedContentProviders. - - @param rInfo Information about the content provider to deregister. - */ -void -deregisterFromUcb( - com::sun::star::uno::Reference< - com::sun::star::ucb::XContentProviderManager > const & - rManager, - ContentProviderRegistrationInfo const & rInfo) - throw (com::sun::star::uno::RuntimeException); - -} - -#endif // _UCBHELPER_REGISTERUCB_HXX_ -- cgit